@@ -46,6 +46,15 @@ module openflow {
4646 if ( data . data . command == "invokecompleted" ) {
4747 this . arguments = data . data . data ;
4848 }
49+ if ( data . data . command == "invokefailed" ) {
50+ if ( data . data && data . data . data && data . data . data . Message ) {
51+ this . errormessage = data . data . data . Message ;
52+ } else {
53+ this . errormessage = JSON . stringify ( data . data ) ;
54+ }
55+
56+ }
57+
4958 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
5059 } ) ;
5160
@@ -64,16 +73,13 @@ module openflow {
6473 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
6574 }
6675 async submit ( ) : Promise < void > {
76+ this . errormessage = "" ;
6777 var rpacommand = {
6878 command : "invoke" ,
6979 workflowid : this . model . _id ,
7080 data : this . arguments
7181 }
7282 if ( this . arguments === null || this . arguments === undefined ) { this . arguments = { } ; }
73- // var message = {
74- // jwt: this.WebSocketClient.jwt,
75- // payload: rpacommand
76- // }
7783 var result : any = await this . api . QueueMessage ( this . user . _id , rpacommand ) ;
7884 try {
7985 // result = JSON.parse(result);
@@ -98,7 +104,7 @@ module openflow {
98104 console . debug ( "RPAWorkflowsCtrl" ) ;
99105 this . collection = "openrpa" ;
100106 this . basequery = { _type : "workflow" } ;
101- this . baseprojection = { _type : 1 , type : 1 , name : 1 , _created : 1 , _createdby : 1 , _modified : 1 } ;
107+ this . baseprojection = { _type : 1 , type : 1 , name : 1 , _created : 1 , _createdby : 1 , _modified : 1 , projectandname : 1 } ;
102108 this . postloadData = this . processdata ;
103109 WebSocketClient . onSignedin ( ( user : TokenUser ) => {
104110 this . loadData ( ) ;
@@ -2642,8 +2648,8 @@ module openflow {
26422648 "api"
26432649 ] ;
26442650 public messages : string = "" ;
2651+ public errormessage : string = "" ;
26452652 public queuename : string = "webtest" ;
2646- public message : string = "Hi mom" ;
26472653 public noderedurl : string = "" ;
26482654 public instance : any = null ;
26492655 public instancestatus : string = "" ;
@@ -2692,30 +2698,37 @@ module openflow {
26922698 } ) ;
26932699 }
26942700 async save ( ) {
2695- if ( this . limitsmemory != "" ) {
2696- if ( this . user . nodered == null ) this . user . nodered = new noderedconfig ( ) ;
2697- if ( this . user . nodered . resources == null ) this . user . nodered . resources = new resources ( ) ;
2698- if ( this . user . nodered . resources . limits == null ) this . user . nodered . resources . limits = new resourcevalues ( ) ;
2699- if ( this . user . nodered . resources . limits . memory != this . limitsmemory ) {
2700- this . user . nodered . resources . limits . memory = this . limitsmemory ;
2701- }
2702- } else {
2703- if ( this . user . nodered != null && this . user . nodered . resources != null && this . user . nodered . resources . limits != null ) {
2704- if ( this . limitsmemory != this . user . nodered . resources . limits . memory ) {
2701+ try {
2702+ this . errormessage = "" ;
2703+ if ( this . limitsmemory != "" ) {
2704+ if ( this . user . nodered == null ) this . user . nodered = new noderedconfig ( ) ;
2705+ if ( this . user . nodered . resources == null ) this . user . nodered . resources = new resources ( ) ;
2706+ if ( this . user . nodered . resources . limits == null ) this . user . nodered . resources . limits = new resourcevalues ( ) ;
2707+ if ( this . user . nodered . resources . limits . memory != this . limitsmemory ) {
27052708 this . user . nodered . resources . limits . memory = this . limitsmemory ;
27062709 }
2710+ } else {
2711+ if ( this . user . nodered != null && this . user . nodered . resources != null && this . user . nodered . resources . limits != null ) {
2712+ if ( this . limitsmemory != this . user . nodered . resources . limits . memory ) {
2713+ this . user . nodered . resources . limits . memory = this . limitsmemory ;
2714+ }
2715+ }
27072716 }
2717+ this . loading = true ;
2718+ this . messages += 'Updating ' + this . user . name + "\n" ;
2719+ if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
2720+ await this . api . Update ( "users" , this . user ) ;
2721+ this . loading = false ;
2722+ this . messages += 'update complete\n' ;
2723+ } catch ( error ) {
2724+ this . errormessage = error ;
27082725 }
2709- this . loading = true ;
2710- this . messages += 'Updating ' + this . user . name + "\n" ;
2711- if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
2712- await this . api . Update ( "users" , this . user ) ;
27132726 this . loading = false ;
2714- this . messages += 'update complete\n' ;
27152727 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
27162728 }
27172729 async GetNoderedInstance ( ) {
27182730 try {
2731+ this . errormessage = "" ;
27192732 this . instancestatus = "fetching status" ;
27202733
27212734 this . instance = await this . api . GetNoderedInstance ( this . userid , this . name ) ;
@@ -2732,6 +2745,7 @@ module openflow {
27322745 }
27332746 this . messages += "GetNoderedInstance completed, status " + this . instancestatus + "\n" ;
27342747 } catch ( error ) {
2748+ this . errormessage = error ;
27352749 this . messages += error + "\n" ;
27362750 this . instancestatus = "" ;
27372751 console . error ( error ) ;
@@ -2741,13 +2755,15 @@ module openflow {
27412755 }
27422756 async GetNoderedInstanceLog ( ) {
27432757 try {
2758+ this . errormessage = "" ;
27442759 this . instancestatus = "fetching log" ;
27452760 console . debug ( "GetNoderedInstanceLog:" ) ;
27462761 this . instancelog = await this . api . GetNoderedInstanceLog ( this . userid , this . name ) ;
27472762 this . instancelog = this . instancelog . split ( "\n" ) . reverse ( ) . join ( "\n" ) ;
27482763 this . messages += "GetNoderedInstanceLog completed\n" ;
27492764 this . instancestatus = "" ;
27502765 } catch ( error ) {
2766+ this . errormessage = error ;
27512767 this . messages += error + "\n" ;
27522768 this . instancestatus = "" ;
27532769 console . error ( error ) ;
@@ -2756,9 +2772,11 @@ module openflow {
27562772 }
27572773 async EnsureNoderedInstance ( ) {
27582774 try {
2775+ this . errormessage = "" ;
27592776 await this . api . EnsureNoderedInstance ( this . userid , this . name ) ;
27602777 this . messages += "EnsureNoderedInstance completed" + "\n" ;
27612778 } catch ( error ) {
2779+ this . errormessage = error ;
27622780 this . messages += error + "\n" ;
27632781 console . error ( error ) ;
27642782 }
@@ -2767,9 +2785,11 @@ module openflow {
27672785 }
27682786 async DeleteNoderedInstance ( ) {
27692787 try {
2788+ this . errormessage = "" ;
27702789 await this . api . DeleteNoderedInstance ( this . userid , this . name ) ;
27712790 this . messages += "DeleteNoderedInstance completed" + "\n" ;
27722791 } catch ( error ) {
2792+ this . errormessage = error ;
27732793 this . messages += error + "\n" ;
27742794 console . error ( error ) ;
27752795 }
@@ -2778,9 +2798,11 @@ module openflow {
27782798 }
27792799 async RestartNoderedInstance ( ) {
27802800 try {
2801+ this . errormessage = "" ;
27812802 await this . api . RestartNoderedInstance ( this . userid , this . name ) ;
27822803 this . messages += "RestartNoderedInstance completed" + "\n" ;
27832804 } catch ( error ) {
2805+ this . errormessage = error ;
27842806 this . messages += error + "\n" ;
27852807 console . error ( error ) ;
27862808 }
@@ -2789,9 +2811,11 @@ module openflow {
27892811 }
27902812 async StartNoderedInstance ( ) {
27912813 try {
2814+ this . errormessage = "" ;
27922815 await this . api . StartNoderedInstance ( this . userid , this . name ) ;
27932816 this . messages += "StartNoderedInstance completed" + "\n" ;
27942817 } catch ( error ) {
2818+ this . errormessage = error ;
27952819 this . messages += error + "\n" ;
27962820 console . error ( error ) ;
27972821 }
@@ -2800,24 +2824,24 @@ module openflow {
28002824 }
28012825 async StopNoderedInstance ( ) {
28022826 try {
2827+ this . errormessage = "" ;
28032828 await this . api . StopNoderedInstance ( this . userid , this . name ) ;
28042829 this . messages += "StopNoderedInstance completed" + "\n" ;
28052830 } catch ( error ) {
2831+ this . errormessage = error ;
28062832 this . messages += error + "\n" ;
28072833 console . error ( error ) ;
28082834 }
28092835 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
28102836 this . GetNoderedInstance ( ) ;
28112837 }
2812-
2813- async submit ( ) {
2814- await this . SendOne ( this . queuename , this . message ) ;
2815- }
28162838 async SendOne ( queuename : string , message : any ) : Promise < void > {
28172839 var result : any = await this . api . QueueMessage ( queuename , message ) ;
28182840 try {
2841+ this . errormessage = "" ;
28192842 // result = JSON.parse(result);
28202843 } catch ( error ) {
2844+ this . errormessage = error ;
28212845 }
28222846 this . messages += result + "\n" ;
28232847 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
0 commit comments