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