@@ -1147,49 +1147,49 @@ module openflow {
11471147 } ) ;
11481148 }
11491149
1150- async EnsureNoderedInstance ( ) {
1150+ async EnsureNoderedInstance ( name : string ) {
11511151 try {
1152- await this . api . EnsureNoderedInstance ( ) ;
1152+ await this . api . EnsureNoderedInstance ( name ) ;
11531153 this . messages += "EnsureNoderedInstance completed" + "\n" ;
11541154 } catch ( error ) {
11551155 this . messages += error + "\n" ;
11561156 console . error ( error ) ;
11571157 }
11581158 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
11591159 }
1160- async DeleteNoderedInstance ( ) {
1160+ async DeleteNoderedInstance ( name : string ) {
11611161 try {
1162- await this . api . DeleteNoderedInstance ( ) ;
1162+ await this . api . DeleteNoderedInstance ( name ) ;
11631163 this . messages += "DeleteNoderedInstance completed" + "\n" ;
11641164 } catch ( error ) {
11651165 this . messages += error + "\n" ;
11661166 console . error ( error ) ;
11671167 }
11681168 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
11691169 }
1170- async RestartNoderedInstance ( ) {
1170+ async RestartNoderedInstance ( name : string ) {
11711171 try {
1172- await this . api . RestartNoderedInstance ( ) ;
1172+ await this . api . RestartNoderedInstance ( name ) ;
11731173 this . messages += "RestartNoderedInstance completed" + "\n" ;
11741174 } catch ( error ) {
11751175 this . messages += error + "\n" ;
11761176 console . error ( error ) ;
11771177 }
11781178 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
11791179 }
1180- async StartNoderedInstance ( ) {
1180+ async StartNoderedInstance ( name : string ) {
11811181 try {
1182- await this . api . StartNoderedInstance ( ) ;
1182+ await this . api . StartNoderedInstance ( name ) ;
11831183 this . messages += "StartNoderedInstance completed" + "\n" ;
11841184 } catch ( error ) {
11851185 this . messages += error + "\n" ;
11861186 console . error ( error ) ;
11871187 }
11881188 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
11891189 }
1190- async StopNoderedInstance ( ) {
1190+ async StopNoderedInstance ( name : string ) {
11911191 try {
1192- await this . api . StopNoderedInstance ( ) ;
1192+ await this . api . StopNoderedInstance ( name ) ;
11931193 this . messages += "StopNoderedInstance completed" + "\n" ;
11941194 } catch ( error ) {
11951195 this . messages += error + "\n" ;
@@ -2400,6 +2400,7 @@ module openflow {
24002400 public instance : any = null ;
24012401 public instancestatus : string = "" ;
24022402 public instancelog : string = "" ;
2403+ public name : string = "" ;
24032404 constructor (
24042405 public $scope : ng . IScope ,
24052406 public $location : ng . ILocationService ,
@@ -2410,10 +2411,13 @@ module openflow {
24102411 console . debug ( "NoderedCtrl" ) ;
24112412 WebSocketClient . onSignedin ( async ( user : TokenUser ) => {
24122413 await api . RegisterQueue ( ) ;
2413- var name = WebSocketClient . user . username ;
2414- name = name . split ( "@" ) . join ( "" ) . split ( "." ) . join ( "" ) ;
2415- name = name . toLowerCase ( ) ;
2416- this . noderedurl = "https://" + WebSocketClient . nodered_domain_schema . replace ( "$nodered_id$" , name ) ;
2414+ this . name = $routeParams . id ;
2415+ if ( this . name == null || this . name == undefined || this . name == "" ) {
2416+ this . name = WebSocketClient . user . username ;
2417+ }
2418+ this . name = this . name . split ( "@" ) . join ( "" ) . split ( "." ) . join ( "" ) ;
2419+ this . name = this . name . toLowerCase ( ) ;
2420+ this . noderedurl = "https://" + WebSocketClient . nodered_domain_schema . replace ( "$nodered_id$" , this . name ) ;
24172421 // // this.GetNoderedInstance();
24182422 this . GetNoderedInstance ( ) ;
24192423 } ) ;
@@ -2422,7 +2426,7 @@ module openflow {
24222426 try {
24232427 this . instancestatus = "fetching status" ;
24242428
2425- this . instance = await this . api . GetNoderedInstance ( ) ;
2429+ this . instance = await this . api . GetNoderedInstance ( this . name ) ;
24262430 console . debug ( "GetNoderedInstance:" ) ;
24272431 if ( this . instance !== null && this . instance !== undefined ) {
24282432 if ( this . instance . metadata . deletionTimestamp !== undefined ) {
@@ -2446,7 +2450,7 @@ module openflow {
24462450 try {
24472451 this . instancestatus = "fetching log" ;
24482452 console . debug ( "GetNoderedInstanceLog:" ) ;
2449- this . instancelog = await this . api . GetNoderedInstanceLog ( ) ;
2453+ this . instancelog = await this . api . GetNoderedInstanceLog ( this . name ) ;
24502454 this . instancelog = this . instancelog . split ( "\n" ) . reverse ( ) . join ( "\n" ) ;
24512455 this . messages += "GetNoderedInstanceLog completed\n" ;
24522456 this . instancestatus = "" ;
@@ -2459,7 +2463,7 @@ module openflow {
24592463 }
24602464 async EnsureNoderedInstance ( ) {
24612465 try {
2462- await this . api . EnsureNoderedInstance ( ) ;
2466+ await this . api . EnsureNoderedInstance ( this . name ) ;
24632467 this . messages += "EnsureNoderedInstance completed" + "\n" ;
24642468 } catch ( error ) {
24652469 this . messages += error + "\n" ;
@@ -2470,7 +2474,7 @@ module openflow {
24702474 }
24712475 async DeleteNoderedInstance ( ) {
24722476 try {
2473- await this . api . DeleteNoderedInstance ( ) ;
2477+ await this . api . DeleteNoderedInstance ( this . name ) ;
24742478 this . messages += "DeleteNoderedInstance completed" + "\n" ;
24752479 } catch ( error ) {
24762480 this . messages += error + "\n" ;
@@ -2481,7 +2485,7 @@ module openflow {
24812485 }
24822486 async RestartNoderedInstance ( ) {
24832487 try {
2484- await this . api . RestartNoderedInstance ( ) ;
2488+ await this . api . RestartNoderedInstance ( this . name ) ;
24852489 this . messages += "RestartNoderedInstance completed" + "\n" ;
24862490 } catch ( error ) {
24872491 this . messages += error + "\n" ;
@@ -2492,7 +2496,7 @@ module openflow {
24922496 }
24932497 async StartNoderedInstance ( ) {
24942498 try {
2495- await this . api . StartNoderedInstance ( ) ;
2499+ await this . api . StartNoderedInstance ( this . name ) ;
24962500 this . messages += "StartNoderedInstance completed" + "\n" ;
24972501 } catch ( error ) {
24982502 this . messages += error + "\n" ;
@@ -2503,7 +2507,7 @@ module openflow {
25032507 }
25042508 async StopNoderedInstance ( ) {
25052509 try {
2506- await this . api . StopNoderedInstance ( ) ;
2510+ await this . api . StopNoderedInstance ( this . name ) ;
25072511 this . messages += "StopNoderedInstance completed" + "\n" ;
25082512 } catch ( error ) {
25092513 this . messages += error + "\n" ;
@@ -2590,6 +2594,7 @@ module openflow {
25902594 console . debug ( "RolesCtrl" ) ;
25912595 this . basequery = { _type : "user" } ;
25922596 this . collection = "users" ;
2597+ this . postloadData = this . processdata ;
25932598 this . preloadData = ( ) => {
25942599 var dt = new Date ( new Date ( ) . toISOString ( ) ) ;
25952600 if ( this . showinactive ) {
@@ -2610,6 +2615,20 @@ module openflow {
26102615 this . loadData ( ) ;
26112616 } ) ;
26122617 }
2618+ processdata ( ) {
2619+ for ( var i = 0 ; i < this . models . length ; i ++ ) {
2620+ var model : any = this . models [ i ] ;
2621+ ( model as any ) . hasnodered = false ;
2622+ if ( model . _noderedheartbeat != undefined && model . _noderedheartbeat != null ) {
2623+ var dt = new Date ( model . _noderedheartbeat )
2624+ var now : Date = new Date ( ) ,
2625+ secondsPast : number = ( now . getTime ( ) - dt . getTime ( ) ) / 1000 ;
2626+ if ( secondsPast < 60 ) ( model as any ) . hasnodered = true ;
2627+ }
2628+ }
2629+ this . loading = false ;
2630+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
2631+ }
26132632 ShowWorkflows ( model : any ) {
26142633 this . userdata . data . basequeryas = model . _id ;
26152634 this . $location . path ( "/RPAWorkflows" ) ;
0 commit comments