Skip to content

Commit 9b29e7c

Browse files
committed
Add calling rpa workflows to public
1 parent 6f3148d commit 9b29e7c

6 files changed

Lines changed: 131 additions & 15 deletions

File tree

OpenFlow/src/public/CommonControllers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ module openflow {
3434
//formerlog.apply(console, { arguments: arguments });
3535
formerlog(msg);
3636
var log = { message: msg, _type: "message", host: window.location.hostname };
37-
this.Insert("jslog", log);
37+
this.Insert("jslog", log).catch(() => { });
3838
}
3939
console.warn = (msg) => {
4040
//formerwarn.apply(console, { arguments: arguments });
4141
formerwarn(msg);
4242
var log = { message: msg, _type: "warning", host: window.location.hostname };
43-
this.Insert("jslog", log);
43+
this.Insert("jslog", log).catch(() => { });
4444
}
4545
console.debug = (msg) => {
4646
//formerdebug.apply(console, { arguments: arguments });
4747
formerdebug(msg);
4848
var log = { message: msg, _type: "debug", host: window.location.hostname };
49-
this.Insert("jslog", log);
49+
this.Insert("jslog", log).catch(() => { });
5050
}
5151
window.onerror = (message, url, linenumber) => {
5252
var log = { message: message, url: url, linenumber: linenumber, _type: "error", host: window.location.hostname };
53-
this.Insert("jslog", log);
53+
this.Insert("jslog", log).catch(() => { });
5454
}
5555
var cleanup = $rootScope.$on('queuemessage', (event, data: QueueMessage) => {
5656
if (event && data) { }

OpenFlow/src/public/Controllers.ts

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,74 @@ module openflow {
1313
}
1414
declare var jsondiffpatch: any;
1515

16+
export class RPAWorkflowCtrl extends entityCtrl<openflow.RPAWorkflow> {
17+
public arguments: any;
18+
public users: TokenUser[];
19+
public user: TokenUser;
20+
public messages: string;
21+
constructor(
22+
public $scope: ng.IScope,
23+
public $location: ng.ILocationService,
24+
public $routeParams: ng.route.IRouteParamsService,
25+
public WebSocketClient: WebSocketClient,
26+
public api: api
27+
) {
28+
super($scope, $location, $routeParams, WebSocketClient, api);
29+
console.debug("RPAWorkflowCtrl");
30+
this.collection = "openrpa";
31+
this.messages = "";
32+
WebSocketClient.onSignedin(async (_user: TokenUser) => {
33+
if (this.id !== null && this.id !== undefined) {
34+
await api.RegisterQueue();
35+
await this.loadData();
36+
await this.loadUsers();
37+
$scope.$on('queuemessage', (event, data: QueueMessage) => {
38+
if (event && data) { }
39+
// console.log("queuemessage");
40+
// console.log(event);
41+
console.log(data);
42+
this.messages += data.data.command + "\n";
43+
if (data.data.command == "invokecompleted") {
44+
this.arguments = data.data.data;
45+
}
46+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
47+
});
48+
49+
} else {
50+
console.error("Missing id");
51+
}
52+
});
53+
}
54+
async loadUsers(): Promise<void> {
55+
this.users = await this.api.Query("users", { $or: [{ _type: "user" }, { _type: "role" }] }, null, null);
56+
this.users.forEach(user => {
57+
if (user._id == this.model._createdbyid || user._id == this.model._createdbyid) {
58+
this.user = user;
59+
}
60+
});
61+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
62+
}
63+
async submit(): Promise<void> {
64+
var rpacommand = {
65+
command: "invoke",
66+
workflowid: this.model._id,
67+
data: this.arguments
68+
}
69+
// var message = {
70+
// jwt: this.WebSocketClient.jwt,
71+
// payload: rpacommand
72+
// }
73+
console.log("QueueMessage");
74+
console.log(rpacommand);
75+
var result: any = await this.api.QueueMessage(this.user._id, rpacommand);
76+
console.log("result:");
77+
console.log(result);
78+
try {
79+
// result = JSON.parse(result);
80+
} catch (error) {
81+
}
82+
}
83+
}
1684

1785
export class RPAWorkflowsCtrl extends entitiesCtrl<openflow.Base> {
1886
public message: string = "";
@@ -636,7 +704,7 @@ module openflow {
636704
}
637705
export class RoleCtrl extends entityCtrl<openflow.Role> {
638706
public addthis: any = "";
639-
public users: any[] = null;
707+
public users: TokenUser[] = null;
640708
constructor(
641709
public $scope: ng.IScope,
642710
public $location: ng.ILocationService,
@@ -658,13 +726,7 @@ module openflow {
658726
});
659727
}
660728
async loadUsers(): Promise<void> {
661-
var q: QueryMessage = new QueryMessage();
662-
q.collectionname = this.collection;
663-
// q.query = {};
664-
q.query = { $or: [{ _type: "user" }, { _type: "role" }] };
665-
var msg: Message = new Message(); msg.command = "query"; msg.data = JSON.stringify(q);
666-
q = await this.WebSocketClient.Send<QueryMessage>(msg);
667-
this.users = q.result;
729+
this.users = await this.api.Query(this.collection, { $or: [{ _type: "user" }, { _type: "role" }] }, null, null);
668730
var ids: string[] = [];
669731
if (this.model.members === undefined) { this.model.members = []; }
670732
for (var i: number = 0; i < this.model.members.length; i++) {
@@ -675,8 +737,7 @@ module openflow {
675737
this.users.splice(i, 1);
676738
}
677739
}
678-
this.addthis = q.result[0]._id;
679-
740+
this.addthis = this.users[0]._id;
680741
if (!this.$scope.$$phase) { this.$scope.$apply(); }
681742
}
682743
async submit(): Promise<void> {

OpenFlow/src/public/Entities.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ module openflow {
5959
_id: string;
6060
}
6161

62+
export class RPAWorkflowParameter {
63+
public name: string;
64+
public type: string;
65+
public direction: string;
66+
}
67+
export class RPAWorkflow extends Base {
68+
constructor() {
69+
super();
70+
this._type = "workflow";
71+
}
72+
public Parameters: RPAWorkflowParameter[];
73+
public Serializable: boolean;
74+
public Filename: string;
75+
public projectid: string;
76+
}
77+
6278
export class Form extends Base {
6379
constructor() {
6480
super();
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<div class="row">
2+
<div class="col-sm-7">
3+
<h1 class="pagetitle"><span translate lib="web">detailsfor</span> {{ctrl.model.name}}</h1>
4+
</div>
5+
</div>
6+
<pre ng-show="ctrl.message!=null">{{ ctrl.message }}</pre>
7+
<form ng-submit="ctrl.submit()" class="form-horizontal" role="form" autocomplete="off" ng-hide="ctrl.showjson==true">
8+
<section>
9+
<div class="form-group">
10+
<label class="col-sm-3 control-label"><span translate lib="web">Robot</span>
11+
</label>
12+
<div class="col-sm-9">
13+
<select ng-model="ctrl.user" ng-options="item as item.name for item in ctrl.users">
14+
</select>
15+
</div>
16+
</div>
17+
</section>
18+
<section ng-repeat="model in ctrl.model.Parameters">
19+
<div class="form-group">
20+
<label class="col-sm-3 control-label"><span translate lib="web">{{ model.name }}</span> ({{ model.type }}):
21+
</label>
22+
<div class="col-sm-9">
23+
<input ng-model="ctrl.arguments[model.name]" class="form-control input-md"
24+
ng-disabled="ctrl.loading==true" />
25+
</div>
26+
</div>
27+
</section>
28+
<div class="form-group">
29+
<div class="col-sm-offset-2 col-sm-10">
30+
<button type="submit" ng-disabled="ctrl.loading==true" class="btn btn-success" translate
31+
lib="web">invoke</button>
32+
</div>
33+
</div>
34+
</form>
35+
{{ ctrl.arguments }}
36+
37+
<pre ng-show="ctrl.messages!=null">{{ ctrl.messages }}</pre>

OpenFlow/src/public/RPAWorkflows.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ <h1 translate lib="web">entities</h1>
2929
</canvas>
3030
</td>
3131
<td class="btn-cell">
32-
<a href ng-click="ctrl.DeleteOne(model)" ng-disabled="ctrl.loading==true" translate lib="web">delete</a>
32+
<a ng-href="#/RPAWorkflow/{{model._id}}" ng-disabled="ctrl.loading==true" translate lib="web">invoke</a>
33+
3334
</td>
3435
</tr>
3536
</tbody>

OpenFlow/src/public/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module openflow {
3131
.when('/Role/:id', { templateUrl: 'Role.html', controller: RoleCtrl, controllerAs: 'ctrl' })
3232

3333
.when('/RPAWorkflows', { templateUrl: 'RPAWorkflows.html', controller: RPAWorkflowsCtrl, controllerAs: 'ctrl' })
34+
.when('/RPAWorkflow/:id', { templateUrl: 'RPAWorkflow.html', controller: RPAWorkflowCtrl, controllerAs: 'ctrl' })
3435

3536
.when('/Workflows', { templateUrl: 'Workflows.html', controller: WorkflowsCtrl, controllerAs: 'ctrl' })
3637
.when('/Reports', { templateUrl: 'Reports.html', controller: ReportsCtrl, controllerAs: 'ctrl' })

0 commit comments

Comments
 (0)