11'use strict' ;
22
33angular . module ( 'composeUiApp' )
4+ . config ( function ( $sceDelegateProvider ) {
5+ $ . get ( '/api/v1/web_console_pattern' , ( response ) => {
6+ if ( response . web_console_pattern ) {
7+ var parser = document . createElement ( 'a' ) ,
8+ whitelistUrlPattern ;
9+
10+ parser . href = response . web_console_pattern ;
11+ whitelistUrlPattern = parser . protocol + '//' + parser . host + '/**' ;
12+
13+ $sceDelegateProvider . resourceUrlWhitelist ( [
14+ 'self' ,
15+ whitelistUrlPattern
16+ ] ) ;
17+ }
18+ } ) ;
19+ } )
420 . directive ( 'projectDetail' , function ( $resource , $log , projectService , $window , $location ) {
521 return {
622 restrict : 'E' ,
@@ -18,11 +34,10 @@ angular.module('composeUiApp')
1834 }
1935 } ) ;
2036
21-
22-
2337 var Host = $resource ( 'api/v1/host' ) ;
2438 var Yml = $resource ( 'api/v1/projects/yml/:id' ) ;
2539 var Readme = $resource ( 'api/v1/projects/readme/:id' ) ;
40+ var WebConsolePattern = $resource ( 'api/v1/web_console_pattern' ) ;
2641
2742 $scope . $watch ( 'projectId' , function ( val ) {
2843 if ( val ) {
@@ -57,7 +72,24 @@ angular.module('composeUiApp')
5772 $scope . logs = data . logs ;
5873 } ) ;
5974 } ;
75+
76+ $scope . containerConsolePattern = null ;
77+ WebConsolePattern . get ( function ( data ) {
78+ if ( data . web_console_pattern ) {
79+ $scope . containerConsolePattern = data . web_console_pattern ;
80+ }
81+ } ) ;
6082
83+ $scope . openConsole = function ( containerName , shell ) {
84+ if ( $scope . containerConsolePattern ) {
85+ console . log ( 'Opening console for ' + containerName + ' with shell ' + shell ) ;
86+
87+ $scope . containerConsoleUrl = $scope . containerConsolePattern . replace ( '{containerName}' , containerName ) . replace ( '{command}' , shell ) ;
88+ $scope . containerName = containerName ;
89+ $scope . showConsoleDialog = true ;
90+ }
91+ } ;
92+
6193 $scope . rebuild = function ( serviceName ) {
6294 $scope . working = true ;
6395 Project . save ( { id : $scope . projectId , service_names : [ serviceName ] , do_build : true } ,
0 commit comments