1 |
39746
|
michele.ar
|
var dnetWorkflowsControllers = angular.module('dnetWorkflowsControllers', ['ngGrid']);
|
2 |
|
|
|
3 |
40634
|
michele.ar
|
|
4 |
|
|
dnetWorkflowsControllers.controller('wfListCtrl', ['$scope', '$http', '$routeParams',
|
5 |
|
|
function ($scope, $http, $routeParams) {
|
6 |
|
|
$scope.currentSection = $routeParams.section.replace(/(\_|\+)/g, ' ');
|
7 |
|
|
$scope.wfList = [];
|
8 |
|
|
$http.get('wf/list_workflows.json?section=' + $scope.currentSection).success(function (data) {
|
9 |
|
|
$scope.wfList = data;
|
10 |
|
|
}).error(function (err) {
|
11 |
|
|
show_notification("error", err.message);
|
12 |
|
|
});
|
13 |
|
|
}
|
14 |
|
|
]);
|
15 |
|
|
|
16 |
|
|
|
17 |
39746
|
michele.ar
|
dnetWorkflowsControllers.controller('workflowCtrl', [
|
18 |
39916
|
michele.ar
|
'$scope', '$http', '$sce', '$location', '$route', '$routeParams', 'sharedProperties',
|
19 |
|
|
function ($scope, $http, $sce, $location, $route, $routeParams, sharedProperties) {
|
20 |
40634
|
michele.ar
|
$scope.currentWorkflowId = $routeParams.wf;
|
21 |
39746
|
michele.ar
|
|
22 |
39798
|
michele.ar
|
$scope.currentProc = {};
|
23 |
39848
|
michele.ar
|
$scope.history = [];
|
24 |
40578
|
michele.ar
|
$scope.subWorkflows = [];
|
25 |
39798
|
michele.ar
|
$scope.currentProc = {};
|
26 |
39947
|
michele.ar
|
$scope.params = {};
|
27 |
|
|
$scope.originalParams = {};
|
28 |
39798
|
michele.ar
|
|
29 |
|
|
$scope.executeWf = function (wfId) {
|
30 |
39948
|
michele.ar
|
$http.get('wf/wf.start?id=' + wfId).success(function (data) {
|
31 |
39798
|
michele.ar
|
$scope.currentProc = data;
|
32 |
|
|
$('#monitorProcWfModal').modal('show');
|
33 |
|
|
}).error(function (err) {
|
34 |
41339
|
michele.ar
|
show_notification('error', 'Error executing wf: ' + err.message);
|
35 |
39798
|
michele.ar
|
});
|
36 |
|
|
};
|
37 |
|
|
|
38 |
39916
|
michele.ar
|
$scope.refresh = function () {
|
39 |
|
|
$route.reload();
|
40 |
|
|
};
|
41 |
|
|
|
42 |
39848
|
michele.ar
|
$scope.updateHistory = function (wfId) {
|
43 |
39948
|
michele.ar
|
$http.get('wf/journal.find?wfs=' + wfId).success(function (data) {
|
44 |
39848
|
michele.ar
|
$scope.history = data;
|
45 |
|
|
}).error(function (err) {
|
46 |
41339
|
michele.ar
|
show_notification('error', 'Error fetching history: ' + err.message);
|
47 |
39848
|
michele.ar
|
});
|
48 |
39798
|
michele.ar
|
};
|
49 |
|
|
|
50 |
40578
|
michele.ar
|
$scope.updateSubWorkflows = function (wfId) {
|
51 |
|
|
$http.get('wf/obtainSubWorkflows.do?id=' + wfId).success(function (data) {
|
52 |
|
|
$scope.subWorkflows = data;
|
53 |
|
|
}).error(function (err) {
|
54 |
41339
|
michele.ar
|
show_notification('error', 'error fetching sub workflows: ' + err.message);
|
55 |
40578
|
michele.ar
|
});
|
56 |
|
|
};
|
57 |
|
|
|
58 |
39947
|
michele.ar
|
$scope.updateParameters = function (wfId, params) {
|
59 |
|
|
showSpinner();
|
60 |
39798
|
michele.ar
|
|
61 |
39947
|
michele.ar
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
62 |
39948
|
michele.ar
|
$http.post('wf/saveParams.do', $.param({
|
63 |
39947
|
michele.ar
|
'wf': wfId,
|
64 |
|
|
'params': JSON.stringify(params)
|
65 |
|
|
})).success(function (b) {
|
66 |
|
|
hideSpinner();
|
67 |
41339
|
michele.ar
|
show_notification('info', 'Workflow updated !');
|
68 |
39947
|
michele.ar
|
$scope.originalParams = angular.copy($scope.params);
|
69 |
|
|
}).error(function (err) {
|
70 |
|
|
hideSpinner();
|
71 |
41339
|
michele.ar
|
show_notification('error', 'Error updating wf: ' + err.message);
|
72 |
39947
|
michele.ar
|
});
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
$scope.resetParameters = function () {
|
76 |
|
|
$scope.params = angular.copy($scope.originalParams);
|
77 |
|
|
}
|
78 |
|
|
|
79 |
40639
|
michele.ar
|
$scope.resetGraph = function () {
|
80 |
|
|
sharedProperties.resetGraph();
|
81 |
|
|
}
|
82 |
|
|
|
83 |
40182
|
michele.ar
|
$scope.redrawGraph = function () {
|
84 |
|
|
sharedProperties.rearrangeNodes();
|
85 |
|
|
}
|
86 |
|
|
|
87 |
39746
|
michele.ar
|
}
|
88 |
39947
|
michele.ar
|
]);
|
89 |
41332
|
michele.ar
|
|
90 |
|
|
dnetWorkflowsControllers.controller('repoApiCtrl', [
|
91 |
41339
|
michele.ar
|
'$scope', '$http', '$timeout', '$sce', '$route', '$routeParams', '$location',
|
92 |
|
|
function ($scope, $http, $timeout, $sce, $route, $routeParams, $location) {
|
93 |
|
|
|
94 |
|
|
initSpinner();
|
95 |
|
|
|
96 |
41356
|
michele.ar
|
$scope.params = {};
|
97 |
|
|
$scope.originalParams = {};
|
98 |
|
|
|
99 |
41426
|
michele.ar
|
$scope.availableRepohiWfs = [];
|
100 |
41356
|
michele.ar
|
|
101 |
41339
|
michele.ar
|
$scope.refresh = function () {
|
102 |
|
|
$route.reload();
|
103 |
|
|
};
|
104 |
|
|
|
105 |
|
|
$scope.updateCompatibilityLevel = function(repoId, ifaceId, level) {
|
106 |
|
|
var url = '';
|
107 |
41423
|
michele.ar
|
if (level) { url = 'repo/repoApiCompliance.update?id=' + repoId + '&iface=' + ifaceId + '&compliance=' + level; }
|
108 |
|
|
else { url = 'repo/repoApiCompliance.reset?id=' + repoId + '&iface=' + ifaceId }
|
109 |
41339
|
michele.ar
|
|
110 |
|
|
showSpinner();
|
111 |
|
|
$http.get(url).success(function (data) {
|
112 |
|
|
hideSpinner();
|
113 |
|
|
show_notification('info', 'Api correctly updated !');
|
114 |
|
|
$route.reload();
|
115 |
|
|
}).error(function (err) {
|
116 |
|
|
hideSpinner();
|
117 |
|
|
show_notification('error', 'Error updating compliance: ' + err.message);
|
118 |
|
|
});
|
119 |
|
|
};
|
120 |
41387
|
michele.ar
|
|
121 |
|
|
$scope.updateRepoApi = function(repoId, ifaceId, p) {
|
122 |
|
|
showSpinner();
|
123 |
|
|
var map = {};
|
124 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
125 |
|
|
|
126 |
|
|
var params = {};
|
127 |
|
|
angular.forEach(p, function (value, key) {
|
128 |
|
|
if (angular.isArray(value)) {
|
129 |
|
|
params[key] = value.join(',')
|
130 |
|
|
} else {
|
131 |
|
|
params[key] = value;
|
132 |
|
|
}
|
133 |
|
|
});
|
134 |
41384
|
michele.ar
|
|
135 |
41423
|
michele.ar
|
$http.post('repo/repoApi.update', $.param({
|
136 |
41387
|
michele.ar
|
'id': repoId,
|
137 |
|
|
'iface': ifaceId,
|
138 |
|
|
'accessParams': JSON.stringify(params)
|
139 |
|
|
})).success(function (data) {
|
140 |
|
|
show_notification('info', 'Api correctly saved !');
|
141 |
|
|
hideSpinner();
|
142 |
|
|
$route.reload();
|
143 |
|
|
}).error(function (err) {
|
144 |
|
|
show_notification('error', 'Error saving access parameters: ' + err.message);
|
145 |
|
|
hideSpinner();
|
146 |
|
|
});
|
147 |
41384
|
michele.ar
|
};
|
148 |
41423
|
michele.ar
|
|
149 |
|
|
$scope.findRepoHiWorkflows = function(compliance, type) {
|
150 |
|
|
showSpinner();
|
151 |
|
|
|
152 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
153 |
|
|
$http.post('wf/repohi_wfs.find', $.param({
|
154 |
|
|
'compliance' : compliance,
|
155 |
|
|
'type' : type
|
156 |
|
|
})).success(function (data) {
|
157 |
|
|
hideSpinner();
|
158 |
41426
|
michele.ar
|
$scope.availableRepohiWfs = data;
|
159 |
41423
|
michele.ar
|
}).error(function (err) {
|
160 |
|
|
show_notification('error', 'Error listing repo-hi workflows: ' + err.message);
|
161 |
|
|
hideSpinner();
|
162 |
|
|
});
|
163 |
41426
|
michele.ar
|
};
|
164 |
|
|
|
165 |
41430
|
michele.ar
|
$scope.newRepoWorkflow = function (repoId, ifaceId, repoHiWfId) {
|
166 |
|
|
showSpinner();
|
167 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
168 |
|
|
$http.post('wf/repohi.start', $.param({
|
169 |
|
|
'id': repoId,
|
170 |
|
|
'iface': ifaceId,
|
171 |
|
|
'wf': repoHiWfId
|
172 |
|
|
})).success(function (data) {
|
173 |
|
|
$timeout(function () {
|
174 |
|
|
hideSpinner();
|
175 |
|
|
$route.reload();
|
176 |
|
|
}, 500);
|
177 |
|
|
}).error(function (err) {
|
178 |
|
|
hideSpinner();
|
179 |
|
|
show_notification('error', 'Error starting REPO_HI workflow:' + err.message);
|
180 |
|
|
});
|
181 |
41426
|
michele.ar
|
};
|
182 |
41339
|
michele.ar
|
|
183 |
|
|
/*
|
184 |
41332
|
michele.ar
|
common_init($scope, $http, $sce, $location);
|
185 |
|
|
|
186 |
|
|
commonInitialize($scope, $http, $sce);
|
187 |
|
|
wf_init($scope, $http, $sce);
|
188 |
|
|
|
189 |
|
|
$scope.availableRepohiWfs = getAvailableRepohiWfs();
|
190 |
|
|
$scope.compatibilityLevels = getCompatibilityLevels();
|
191 |
|
|
|
192 |
|
|
$scope.currentRepoApi = {};
|
193 |
|
|
$scope.currentSets = [];
|
194 |
|
|
$scope.selectedSets = [];
|
195 |
|
|
|
196 |
|
|
$scope.newRepoWorkflow = function (wf) {
|
197 |
|
|
|
198 |
|
|
if (wf == undefined) {
|
199 |
|
|
$scope.showError('Please choose a workflow !');
|
200 |
|
|
return;
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
$scope.showSpinner();
|
204 |
|
|
|
205 |
|
|
$scope.metaworkflows.push({"id": "", "name": "Waiting...", "status": "MISSING", "progress": 0});
|
206 |
|
|
|
207 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
208 |
|
|
$http.post('repoMetaWf.new', $.param({
|
209 |
|
|
'wf': wf,
|
210 |
|
|
'iface': $scope.currentRepoApi.id,
|
211 |
|
|
'id': $scope.currentRepoApi.repoId,
|
212 |
|
|
'name': $scope.currentRepoApi.repoName
|
213 |
|
|
})).success(
|
214 |
|
|
function (data) {
|
215 |
|
|
$scope.hideSpinner();
|
216 |
|
|
$(".btnRefreshApi").attr("disabled", "disabled");
|
217 |
|
|
$timeout(function () {
|
218 |
|
|
$route.reload();
|
219 |
|
|
}, 7000);
|
220 |
|
|
}
|
221 |
|
|
).error(
|
222 |
|
|
function () {
|
223 |
|
|
$scope.showError('Something really bad must have happened to our fellow hamster..');
|
224 |
|
|
$scope.hideSpinner();
|
225 |
|
|
}
|
226 |
|
|
);
|
227 |
|
|
};
|
228 |
|
|
|
229 |
|
|
$scope.destroyWorkflow = function (metaWf) {
|
230 |
|
|
|
231 |
|
|
if (metaWf.destroyWorkflow == undefined) {
|
232 |
|
|
$scope.showError('Destroy wf is missing !');
|
233 |
|
|
return;
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
if (!confirm("Are you sure ?")) {
|
237 |
|
|
return;
|
238 |
|
|
}
|
239 |
|
|
|
240 |
|
|
$scope.showSpinner();
|
241 |
|
|
|
242 |
|
|
metaWf.deleting = true;
|
243 |
|
|
|
244 |
|
|
$http.get('repoMetaWf.destroy?destroyWf=' + metaWf.destroyWorkflow)
|
245 |
|
|
.success(
|
246 |
|
|
function (data) {
|
247 |
|
|
$scope.hideSpinner();
|
248 |
|
|
$(".btnRefreshApi").attr("disabled", "disabled");
|
249 |
|
|
$timeout(function () {
|
250 |
|
|
$route.reload();
|
251 |
|
|
}, 7000);
|
252 |
|
|
}
|
253 |
|
|
).error(
|
254 |
|
|
function () {
|
255 |
|
|
$scope.showError('Something really bad must have happened to our fellow hamster..');
|
256 |
|
|
$scope.hideSpinner();
|
257 |
|
|
}
|
258 |
|
|
);
|
259 |
|
|
};
|
260 |
|
|
|
261 |
41430
|
michele.ar
|
|
262 |
41332
|
michele.ar
|
|
263 |
41430
|
michele.ar
|
|
264 |
|
|
|
265 |
41332
|
michele.ar
|
|
266 |
|
|
|
267 |
41430
|
michele.ar
|
|
268 |
41332
|
michele.ar
|
|
269 |
41430
|
michele.ar
|
|
270 |
41332
|
michele.ar
|
|
271 |
|
|
|
272 |
|
|
*/
|
273 |
|
|
}
|
274 |
|
|
|
275 |
|
|
]);
|