1
|
var module = angular.module('workflowsUI', [
|
2
|
'ngRoute',
|
3
|
'wfFormFields',
|
4
|
'cronMaker',
|
5
|
'wfProcessViewer',
|
6
|
'wfGraphViewer',
|
7
|
'repoAccessParamsEditor'
|
8
|
]);
|
9
|
|
10
|
module.config(function ($routeProvider) {
|
11
|
$routeProvider
|
12
|
.when('/list/:section*', {
|
13
|
controller: 'wfListCtrl',
|
14
|
templateUrl: '/html/wf/wf-list.html'
|
15
|
})
|
16
|
.when('/wf/:wf*', {
|
17
|
controller: 'workflowCtrl',
|
18
|
templateUrl: function (params) {
|
19
|
if (params.wf == '_') {
|
20
|
return "/html/wf/empty.html";
|
21
|
} else {
|
22
|
return '/page/wf?id=' + params.wf + '&dt=' + new Date().getTime();
|
23
|
}
|
24
|
}
|
25
|
}).when('/ds/:repoId*/api/:ifaceId*', {
|
26
|
controller: 'repoApiCtrl',
|
27
|
templateUrl: function (params) {
|
28
|
return '/page/datasource_api?dsId=' + params.repoId + "&ifaceId=" + params.ifaceId + '&dt=' + new Date().getTime();
|
29
|
}
|
30
|
})
|
31
|
.otherwise({redirectTo: '/'});
|
32
|
});
|
33
|
|
34
|
module.directive('wfFormUpdate', function ($http) {
|
35
|
return {
|
36
|
restrict: 'E',
|
37
|
templateUrl: '/html/wf/wf-form-update.html',
|
38
|
scope: {
|
39
|
wfId: '@'
|
40
|
},
|
41
|
link: function (scope) {
|
42
|
initSpinner();
|
43
|
|
44
|
scope.showCronMakerModal = false;
|
45
|
scope.wf = {};
|
46
|
scope.emailMessages = [];
|
47
|
|
48
|
showSpinner();
|
49
|
$http.defaults.headers.post["Content-Type"] = "application/json; charset=utf-8";
|
50
|
$http.post('/ajax/wfs/validValues/listProfiles', {
|
51
|
'kind' : 'conf',
|
52
|
'type' : 'template',
|
53
|
'cond' : '//TEMPLATE/@type="email"',
|
54
|
'xpath' : '//TEMPLATE_NAME'
|
55
|
}).success(function (data) {
|
56
|
hideSpinner();
|
57
|
scope.emailMessages = data;
|
58
|
}).error(function (err) {
|
59
|
show_notification("error", err.message);
|
60
|
hideSpinner();
|
61
|
});
|
62
|
|
63
|
scope.reset = function () {
|
64
|
showSpinner();
|
65
|
$http.get('/ajax/wfs/workflowManagementParams?wfId=' + scope.wfId).success(function (data) {
|
66
|
hideSpinner();
|
67
|
scope.wf = data;
|
68
|
}).error(function (err) {
|
69
|
show_notification("error", err.message);
|
70
|
hideSpinner();
|
71
|
})
|
72
|
|
73
|
scope.wf = angular.copy(scope.originalWf);
|
74
|
};
|
75
|
|
76
|
scope.addNotification = function() {
|
77
|
if (!scope.wf) { scope.wf = { 'notifications': [ {} ] } }
|
78
|
else if (!scope.wf.notifications) { scope.wf.notifications = [ {} ] }
|
79
|
else { scope.wf.notifications.push ( {} ) }
|
80
|
};
|
81
|
|
82
|
scope.dropNotification = function(pos) {
|
83
|
if (scope.wf && scope.wf.notifications && pos >= 0 && pos < scope.wf.notifications.length) {
|
84
|
scope.wf.notifications.splice(pos, 1);
|
85
|
}
|
86
|
};
|
87
|
|
88
|
scope.showCronMaker = function() {
|
89
|
scope.showCronMakerModal = true;
|
90
|
}
|
91
|
|
92
|
scope.updateWf = function () {
|
93
|
showSpinner();
|
94
|
$http.defaults.headers.post["Content-Type"] = "application/json; charset=utf-8";
|
95
|
$http.post('/ajax/wfs/workflowManagementParams?wfId=' + scope.wfId, scope.wf).success(function (data) {
|
96
|
hideSpinner();
|
97
|
show_notification("info", 'Workflow updated !');
|
98
|
}).error(function (err) {
|
99
|
show_notification("error", err.message);
|
100
|
hideSpinner();
|
101
|
});
|
102
|
};
|
103
|
|
104
|
scope.reset();
|
105
|
|
106
|
}
|
107
|
}
|
108
|
});
|
109
|
|
110
|
module.directive('bsHasErrorSimple', function () {
|
111
|
return {
|
112
|
restrict: "A",
|
113
|
link: function (scope, element, attrs, ctrl) {
|
114
|
element.toggleClass('has-feedback', true);
|
115
|
var input = element.find('input[ng-model], select[ng-model]');
|
116
|
if (input) {
|
117
|
scope.$watch(function () {
|
118
|
if (input.controller('ngModel').$invalid) {
|
119
|
return 0;
|
120
|
} else {
|
121
|
return 1;
|
122
|
}
|
123
|
}, function (code) {
|
124
|
if (code < 0) return;
|
125
|
element.toggleClass('has-error', (code == 0));
|
126
|
element.toggleClass('has-success', (code == 1));
|
127
|
});
|
128
|
}
|
129
|
}
|
130
|
};
|
131
|
});
|
132
|
|
133
|
|
134
|
module.directive('wfSubWorkflows', function ($http) {
|
135
|
return {
|
136
|
restrict: 'E',
|
137
|
templateUrl: '/html/wf/wf-sub-workflows.html',
|
138
|
scope: {
|
139
|
wfId: '@',
|
140
|
graphId: '=',
|
141
|
showGraphModal: '='
|
142
|
},
|
143
|
link: function (scope) {
|
144
|
scope.currentProcId = '';
|
145
|
scope.currentWorker = '';
|
146
|
scope.showProcModal = false;
|
147
|
scope.subWorkflows = [];
|
148
|
|
149
|
$http.get('/ajax/wfs/subWorkflows?wfId=' + scope.wfId).success(function (data) {
|
150
|
scope.subWorkflows = data;
|
151
|
}).error(function (err) {
|
152
|
show_notification('error', 'error fetching sub workflows: ' + err.message);
|
153
|
});
|
154
|
|
155
|
scope.executeWf = function (wfId, name, parent, isTemplate, warning) {
|
156
|
|
157
|
if (warning && !confirm("You are launching a part of a not well configured workflow. Are you sure ?")) {
|
158
|
show_notification("info", "Execution aborted");
|
159
|
return;
|
160
|
}
|
161
|
|
162
|
var url = '';
|
163
|
if (isTemplate) {
|
164
|
url = '/ajax/wfs/startWorkflowTemplate?node=' + name + '&parentWf=' + parent;
|
165
|
} else {
|
166
|
url = '/ajax/wfs/startWorkflow?wfId=' + wfId;
|
167
|
}
|
168
|
|
169
|
$http.get(url).success(function (data) {
|
170
|
scope.currentProcId = data.procId;
|
171
|
scope.currentWorker = data.worker;
|
172
|
scope.showProcModal = true;
|
173
|
}).error(function (err) {
|
174
|
show_notification("error", "Error executing wf: " + err.message);
|
175
|
});
|
176
|
};
|
177
|
|
178
|
scope.showGraph = function (wfId) {
|
179
|
scope.graphId = wfId;
|
180
|
scope.showGraphModal = true;
|
181
|
};
|
182
|
}
|
183
|
}
|
184
|
});
|
185
|
|
186
|
module.directive('wfHistory', function () {
|
187
|
return {
|
188
|
restrict: 'E',
|
189
|
templateUrl: '/html/wf/wf-history.html',
|
190
|
scope: {
|
191
|
ngModel: '=',
|
192
|
onRefresh: '&'
|
193
|
},
|
194
|
link: function (scope) {
|
195
|
scope.currentId = '';
|
196
|
scope.currentProc = {};
|
197
|
|
198
|
scope.showGraphModal = false;
|
199
|
scope.showLogModal = false;
|
200
|
|
201
|
scope.doOnRefesh = function () {
|
202
|
scope.onRefresh();
|
203
|
}
|
204
|
scope.showProcess = function (procId) {
|
205
|
scope.currentId = procId;
|
206
|
scope.showGraphModal = true;
|
207
|
}
|
208
|
scope.showProcessLog = function (proc) {
|
209
|
scope.currentProc = proc;
|
210
|
scope.showLogModal = true;
|
211
|
}
|
212
|
}
|
213
|
}
|
214
|
});
|
215
|
|
216
|
|
217
|
module.controller('wfListCtrl', function ($scope, $http, $routeParams) {
|
218
|
$scope.currentSection = $routeParams.section.replace(/(\_|\+)/g, ' ');
|
219
|
$scope.wfList = [];
|
220
|
$http.get('/ajax/wfs/list?section=' + $scope.currentSection).success(function (data) {
|
221
|
$scope.wfList = data;
|
222
|
}).error(function (err) {
|
223
|
show_notification("error", err.message);
|
224
|
});
|
225
|
}
|
226
|
);
|
227
|
|
228
|
|
229
|
module.controller('workflowCtrl', function ($scope, $http, $sce, $location, $route, $routeParams) {
|
230
|
$scope.currentWorkflowId = $routeParams.wf;
|
231
|
|
232
|
$scope.currentProcId = '';
|
233
|
$scope.currentWorker = '';
|
234
|
$scope.showProcModal = false;
|
235
|
$scope.showAccessParamsModal = false;
|
236
|
|
237
|
$scope.currentGraphId = '';
|
238
|
$scope.showGraphModal = false;
|
239
|
|
240
|
$scope.history = [];
|
241
|
$scope.params = {};
|
242
|
$scope.originalParams = {};
|
243
|
|
244
|
$scope.showGraph = function (wfId) {
|
245
|
$scope.currentGraphId = wfId;
|
246
|
$scope.showGraphModal = true;
|
247
|
};
|
248
|
|
249
|
$scope.executeWf = function (wfId) {
|
250
|
$http.get('/ajax/wfs/startWorkflow?wfId=' + wfId).success(function (data) {
|
251
|
$scope.currentProcId = data.procId;
|
252
|
$scope.currentWorker = data.worker;
|
253
|
$scope.showProcModal = true;
|
254
|
}).error(function (err) {
|
255
|
show_notification('error', 'Error executing wf: ' + err.message);
|
256
|
});
|
257
|
};
|
258
|
|
259
|
$scope.editAccessParams = function () {
|
260
|
$scope.showAccessParamsModal = true;
|
261
|
};
|
262
|
|
263
|
$scope.refresh = function () {
|
264
|
$route.reload();
|
265
|
};
|
266
|
|
267
|
$scope.updateHistory = function (wfId) {
|
268
|
$http.get('/ajax/wfs/logs?wf=' + wfId).success(function (data) {
|
269
|
$scope.history = data;
|
270
|
}).error(function (err) {
|
271
|
show_notification('error', 'Error fetching history: ' + err.message);
|
272
|
});
|
273
|
};
|
274
|
|
275
|
$scope.updateParameters = function (wfId, params) {
|
276
|
showSpinner();
|
277
|
|
278
|
$http.defaults.headers.post["Content-Type"] = "application/json; charset=utf-8";
|
279
|
$http.post('/ajax/wfs/workflowParams?wfId=' + wfId, params).success(function (b) {
|
280
|
hideSpinner();
|
281
|
show_notification('info', 'Workflow updated !');
|
282
|
$scope.originalParams = angular.copy($scope.params);
|
283
|
}).error(function (err) {
|
284
|
hideSpinner();
|
285
|
show_notification('error', 'Error updating wf: ' + err.message);
|
286
|
});
|
287
|
}
|
288
|
|
289
|
$scope.resetParameters = function () {
|
290
|
$scope.params = angular.copy($scope.originalParams);
|
291
|
}
|
292
|
|
293
|
});
|
294
|
|
295
|
module.controller('repoApiCtrl', function ($scope, $http, $timeout, $sce, $route, $routeParams, $location) {
|
296
|
|
297
|
initSpinner();
|
298
|
|
299
|
$scope.params = {};
|
300
|
$scope.originalParams = {};
|
301
|
|
302
|
$scope.currentProcId = '';
|
303
|
$scope.currentWorker = '';
|
304
|
$scope.showProcModal = false;
|
305
|
$scope.showAccessParamsModal = false;
|
306
|
|
307
|
$scope.availableRepohiWfs = [];
|
308
|
|
309
|
$scope.refresh = function () {
|
310
|
$route.reload();
|
311
|
};
|
312
|
|
313
|
$scope.editAccessParams = function () {
|
314
|
$scope.showAccessParamsModal = true;
|
315
|
};
|
316
|
|
317
|
$scope.updateCompatibilityLevel = function(dsId, ifaceId, level) {
|
318
|
var url = '';
|
319
|
if (level) { url = '/ajax/wfs/ds/compliance/override/' + level + '?dsId=' + dsId + '&ifaceId=' + ifaceId }
|
320
|
else { url = '/ajax/wfs/ds/compliance/reset?dsId=' + dsId + '&ifaceId=' + ifaceId }
|
321
|
|
322
|
showSpinner();
|
323
|
$http.get(url).success(function (data) {
|
324
|
hideSpinner();
|
325
|
show_notification('info', 'Api correctly updated !');
|
326
|
$route.reload();
|
327
|
}).error(function (err) {
|
328
|
hideSpinner();
|
329
|
show_notification('error', 'Error updating compliance: ' + err.message);
|
330
|
});
|
331
|
};
|
332
|
|
333
|
$scope.findRepoHiWorkflows = function(compliance, type) {
|
334
|
showSpinner();
|
335
|
|
336
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
337
|
$http.post('wf/repohi_wfs.find', $.param({
|
338
|
'compliance' : compliance,
|
339
|
'type' : type
|
340
|
})).success(function (data) {
|
341
|
hideSpinner();
|
342
|
$scope.availableRepohiWfs = data;
|
343
|
}).error(function (err) {
|
344
|
show_notification('error', 'Error listing repo-hi workflows: ' + err.message);
|
345
|
hideSpinner();
|
346
|
});
|
347
|
};
|
348
|
|
349
|
$scope.newRepoWorkflow = function (repoId, ifaceId, repoHiWfId) {
|
350
|
showSpinner();
|
351
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
352
|
$http.post('wf/repohi.start', $.param({
|
353
|
'id': repoId,
|
354
|
'iface': ifaceId,
|
355
|
'wf': repoHiWfId
|
356
|
})).success(function (data) {
|
357
|
if (data && data.length == 1) {
|
358
|
$scope.currentProcId = data[0];
|
359
|
$scope.currentWorker = '???';
|
360
|
$scope.showProcModal = true;
|
361
|
}
|
362
|
}).error(function (err) {
|
363
|
hideSpinner();
|
364
|
show_notification('error', 'Error starting REPO_HI workflow:' + err.message);
|
365
|
});
|
366
|
};
|
367
|
|
368
|
$scope.destroyRepoWorkflow = function (wfId) {
|
369
|
showSpinner();
|
370
|
$http.post('wf/repobye.start?wf=' + wfId).success(function (data) {
|
371
|
if (data && data.length == 1) {
|
372
|
$scope.currentProcId = data[0];
|
373
|
$scope.currentWorker = '???';
|
374
|
$scope.showProcModal = true;
|
375
|
}
|
376
|
}).error(function (err) {
|
377
|
hideSpinner();
|
378
|
show_notification('error', 'Error starting REPO_BYE workflow:' + err.message);
|
379
|
});
|
380
|
};
|
381
|
});
|
382
|
|