Project

General

Profile

« Previous | Next » 

Revision 27025

moved some function from common js

View differences:

modules/dnet-modular-workflows-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/workflows/common/common.st
1
$ui/workflows/common/node_edit()$
2
$ui/workflows/common/metawf_edit()$
3
$ui/workflows/common/wf_clone()$
4
$ui/workflows/common/wf_monitor()$
5
$ui/workflows/common/wf_monitor_proc()$
6
$ui/workflows/common/wf_monitor_proc_node()$
7
$ui/workflows/common/wf_journal()$
modules/dnet-modular-workflows-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/workflows.st
11 11
}, body={
12 12
	<div ng-app="workflowsUI" ng-controller="workflowsCtrl">
13 13
	
14
		$ui/workflows/common/common()$
14
		$ui/workflows/common/node_edit()$
15
		$ui/workflows/common/metawf_edit()$
16
		$ui/workflows/common/wf_clone()$
17
		$ui/workflows/common/wf_monitor()$
18
		$ui/workflows/common/wf_monitor_proc()$
19
		$ui/workflows/common/wf_monitor_proc_node()$
20
		$ui/workflows/common/wf_journal()$
15 21

  
16 22
		<div class="row">
17 23
			<div class="col-xs-12 col-sm-12 col-md-4 col-lg-3">$ui/workflows/common/left_menu()$</div>
modules/dnet-modular-workflows-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/workflow_journal.st
32 32
}, body={
33 33
	<div ng-app="wfJournalUI" ng-controller="wfJournalCtrl">
34 34
	
35
		$ui/workflows/common/common()$
35
		$ui/workflows/common/wf_monitor()$
36
		$ui/workflows/common/wf_monitor_proc()$
37
		$ui/workflows/common/wf_monitor_proc_node()$
38
		$ui/workflows/common/wf_journal()$
36 39
	
37 40
		<div class="row">
38 41
			<div class="col-xs-12 col-md-6">
modules/dnet-modular-workflows-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/dnet_workflows.js
8 8
	$scope.initialMetaWf = getInitialMetaWf();
9 9
	$scope.datasourceId = getDatasourceId();
10 10

  
11
	$scope.gridUserParams = {
12
			data : 'currentNode.userParams',
13
			enableCellSelection : false,
14
			enableRowSelection : false,
15
			enableCellEditOnFocus : true,
16
			enablePaging : false,
17
			columnDefs : [
18
					{ field : 'name', displayName : 'Name', enableCellEdit : false, width : '12%' },
19
					{ field : 'required', displayName : 'Required', enableCellEdit : false, width : '8%' },
20
					{ field : 'type', displayName : 'Type', enableCellEdit : false, width : '8%' },
21
					{ field : 'value', displayName : 'Value', enableCellEdit : true, editableCellTemplate : "<input ng-show=\"!row.getProperty('function')\" type='text' ng-model='row.entity.value' ng-input='row.entity.value' ng-class=\"'colt' + col.index\" style='width: 98%;' />"
22
								+ "<select ng-show=\"row.getProperty('function')\" ng-model='row.entity.value' ng-input='row.entity.value' ng-class=\"'colt' + col.index\" ng-options=\"item.id as item.name for item in listValidValuesForUserParam(row.getProperty('function'))\"><option value=''></option></select>"
23
					}
24
				]
25
		};
26

  
27
		$scope.gridSystemParams = {
28
			data : 'currentNode.systemParams',
29
			enableCellSelection : false,
30
			enableRowSelection : false,
31
			enableCellEditOnFocus : false,
32
			enablePaging : false,
33
			columnDefs : [ 
34
			              { field : 'name',     displayName : 'Name',     width : '12%' },
35
			              { field : 'required', displayName : 'Required', width : '8%' },
36
			              { field : 'type',     displayName : 'Type',     width : '8%' },
37
			              { field : 'value',    displayName : 'Value'}
38
			             ]
39
		};
40
	
41
	
42
	
11 43
	$scope.reload = function(loadFirstElement) {
12 44
		if      ($scope.datasourceId)   { $scope.getWorkflows(loadFirstElement, 'dsId='    + $scope.datasourceId)   }
13 45
		else if ($scope.currentSection) { $scope.getWorkflows(loadFirstElement, 'section=' + $scope.currentSection) }
14 46
		else                            { $scope.hideSpinner(); }
15 47
	}
48
	
49
	$scope.getMetaWorkflow = function(id) {
50
		$scope.showSpinner();
51
		$http.get('wf_metaworkflow.json?id=' + id).success(function(data) {
52
			$scope.currentMetaWorkflow = data;
53
			$scope.hideSpinner();
54
			$scope.currentTab = 'metawf';
55
		}).error(function() {
56
			$scope.showError('Something really bad must have happened to our fellow hamster..');
57
			$scope.hideSpinner();
58
		});
59
	}
60
	
61
	$scope.getAtomicWorkflow = function(id) {
62
		$scope.showSpinner();
63
		$http.get('wf_atomic_workflow.json?id=' + id).success(function(data) {
64
			$scope.currentWorkflow = data;
65
			$scope.hideSpinner();
66
			$scope.currentTab = 'atomwf';
67
		}).error(function() {
68
			$scope.showError('Something really bad must have happened to our fellow hamster..');
69
			$scope.hideSpinner();
70
		});
71
	}
16 72

  
17 73
	$scope.getWorkflows = function(loadFirstElement, params) {
18 74
		$scope.showSpinner();
19 75

  
20
		$http.get('list_metaworkflows.json?' + params).success(
21
            function(data) {
22
            	$scope.metaworkflows = data;
23
                $scope.hideSpinner();
76
		$http.get('list_metaworkflows.json?' + params).success(function(data) {
77
			$scope.metaworkflows = data;
78
			$scope.hideSpinner();
24 79

  
25
				if (loadFirstElement) {
26
					if ($scope.initialMetaWf) {
27
						angular.forEach($scope.metaworkflows, function(mw, key) {
28
							if (mw.wfId == $scope.initialMetaWf) {
29
								$scope.getMetaWorkflow(mw.wfId);
30
								return;
31
							}
32
						});
33
					} else if ($scope.metaworkflows.length > 0) {
34
						var id = $scope.metaworkflows[0].wfId;
35
						$scope.getMetaWorkflow(id);
36
					}
37
				} else {
38
					angular.forEach($scope.metaworkflows, function(value, key){
39
						if (value.wfId == $scope.currentMetaWorkflow.wfId) {
40
							$scope.currentMetaWorkflow = value;
80
			if (loadFirstElement) {
81
				if ($scope.initialMetaWf) {
82
					angular.forEach($scope.metaworkflows, function(mw, key) {
83
						if (mw.wfId == $scope.initialMetaWf) {
84
							$scope.getMetaWorkflow(mw.wfId);
85
							return;
41 86
						}
42 87
					});
88
				} else if ($scope.metaworkflows.length > 0) {
89
					var id = $scope.metaworkflows[0].wfId;
90
					$scope.getMetaWorkflow(id);
43 91
				}
44
            }
45
        ).error(
46
            function() {
47
            	$scope.showError('Something really bad must have happened to our fellow hamster..');
48
            	$scope.hideSpinner();
49
            }
50
        );	
92
			} else {
93
				angular.forEach($scope.metaworkflows, function(value, key){
94
					if (value.wfId == $scope.currentMetaWorkflow.wfId) {
95
						$scope.currentMetaWorkflow = value;
96
					}
97
				});
98
			}
99
		}).error(function() {
100
			$scope.showError('Something really bad must have happened to our fellow hamster..');
101
			$scope.hideSpinner();
102
		});	
51 103
	}
52
		
104
	
105
	$scope.executeWf = function() {
106
		$http.get('wf.start?id=' + $scope.currentWorkflow.wfId).success(function(data) {
107
			$scope.updateMetaWorkflowHistory();
108
			$('#monitorWfModal').modal('show');
109
		}).error(function() {
110
			$scope.showError('Something really bad must have happened to our fellow hamster..');
111
		});
112
	};
113

  
114
	$scope.executeMetaWf = function() {
115
		$http.get('metawf.start?id=' + $scope.currentMetaWorkflow.wfId).success(function(data) {
116
			$scope.updateMetaWorkflowHistory();
117
			$('#monitorWfModal').modal('show');
118
		}).error(function() {
119
			$scope.showError('Something really bad must have happened to our fellow hamster..');
120
		});
121
	};
122
	
123
	$scope.prepareMetaWfEdit = function() {
124
		$scope.tempMetaWorkflow = angular.copy($scope.currentMetaWorkflow);
125
	};
126
	
53 127
	$scope.cloneMetaWf = function(id, name) {
54 128
		$scope.showSpinner();
55 129
		$http.get('wf_metaworkflow.clone?id=' + id +'&name=' + name)
......
66 140
            }
67 141
        );
68 142
	}
143
	
144
	$scope.saveCurrentMetaWf = function() {
145
		$scope.showSpinner();
146
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
147
		$http.post('wf_metaworkflow.edit', $.param({
148
			'json' : JSON.stringify($scope.tempMetaWorkflow)
149
		})).success(function(data) {
150
			$scope.hideSpinner();
69 151

  
152
			angular.forEach($scope.metaworkflows, function(value, key) {
153
				if (value.wfId == $scope.tempMetaWorkflow.wfId) {
154
					value.name = $scope.tempMetaWorkflow.name;
155
				}
156
			});
157

  
158
			$scope.getMetaWorkflow($scope.tempMetaWorkflow.wfId);
159
		}).error(function() {
160
			$scope.showError('Something really bad must have happened to our fellow hamster..');
161
			$scope.hideSpinner();
162
		});
163
	};
164
	
165
	$scope.saveCurrentNode = function() {
166
		$scope.showSpinner();
167
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
168
		$http.post('wf_workflow_node.save', $.param({
169
			'wf' : $scope.currentWorkflow.wfId,
170
			'json' : JSON.stringify($scope.currentNode)
171
		})).success(function(data) {
172
			$scope.hideSpinner();
173
			$scope.getAtomicWorkflow($scope.currentWorkflow.wfId);
174
		}).error(function() {
175
			$scope.showError('Something really bad must have happened to our fellow hamster..');
176
			$scope.hideSpinner();
177
		});
178
	}
179
	
180
	$scope.showPriorityDialog = function(b) {
181
		var s = prompt("New workflow priority [0..100]", $scope.currentWorkflow.priority);
182
		if (s == null) {
183
			return;
184
		}
185
		var value = parseInt(s);
186
		if (isNaN(value) || value < 0 || value > 100) {
187
			$scope.showError('Invalid value: ' + value);
188
			return;
189
		}
190
		$http.get('wf_atomic_workflow.priority?value=' + value + "&id="	+ $scope.currentWorkflow.wfId).success(function(data) {
191
			$scope.showNotification('Priority updated, new value is ' + value);
192
			$scope.currentWorkflow.priority = value;
193
			$scope.hideSpinner();
194
		}).error(function() {
195
			$scope.showError('Something really bad must have happened to our fellow hamster..');
196
			$scope.hideSpinner();
197
		});
198
	}
199
	
200
	$scope.listValidValuesForUserParam = function(func) {
201
		if (!$scope.validParamValuesCache[func]) {
202
			$scope.showSpinner();
203
			try {
204
				$scope.validParamValuesCache[func] = eval(func);
205
			} catch (e) {
206
				alert('Error evaluating function: ' + func);
207
				$scope.validParamValuesCache[func] = [];
208
			}
209
			$scope.hideSpinner();
210
		}
211
		return $scope.validParamValuesCache[func];
212
	}
213

  
70 214
	$scope.reload(true);
71 215
}
modules/dnet-modular-workflows-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/dnet_workflows_common.js
10 10
	$scope.currentProcNode = {};
11 11
	$scope.currentNode = {
12 12
		userParams : [],
13

  
14 13
	};
15 14
	$scope.metaworkflows = [];
16 15
	$scope.currentTab = 'metawf';
......
23 22
		filterText : ''
24 23
	};
25 24

  
26
	$scope.to_trusted = function(html_code) {
27
		return $sce.trustAsHtml(html_code);
28
	}
29

  
30 25
	$scope.gridCurrentWfJournal = {
31 26
		data : 'currentWorkflowJournal',
32 27
		enableCellSelection : false,
......
71 66
			displayName : 'Value'
72 67
		} ]
73 68
	};
69
	
70
	$scope.to_trusted = function(html_code) {
71
		return $sce.trustAsHtml(html_code);
72
	}
74 73

  
75 74
	$scope.showError = function(error) {
76 75
		show_notification("error", error);
......
90 89

  
91 90
	initSpinner();
92 91

  
93
	$scope.listValidValuesForUserParam = function(func) {
94
		if (!$scope.validParamValuesCache[func]) {
95
			$scope.showSpinner();
96
			try {
97
				$scope.validParamValuesCache[func] = eval(func);
98
			} catch (e) {
99
				alert('Error evaluating function: ' + func);
100
				$scope.validParamValuesCache[func] = [];
101
			}
102
			$scope.hideSpinner();
103
		}
104
		return $scope.validParamValuesCache[func];
105
	}
106

  
107
	$scope.gridUserParams = {
108
		data : 'currentNode.userParams',
109
		enableCellSelection : false,
110
		enableRowSelection : false,
111
		enableCellEditOnFocus : true,
112
		enablePaging : false,
113
		columnDefs : [
114
				{
115
					field : 'name',
116
					displayName : 'Name',
117
					enableCellEdit : false,
118
					width : '12%'
119
				},
120
				{
121
					field : 'required',
122
					displayName : 'Required',
123
					enableCellEdit : false,
124
					width : '8%'
125
				},
126
				{
127
					field : 'type',
128
					displayName : 'Type',
129
					enableCellEdit : false,
130
					width : '8%'
131
				},
132
				{
133
					field : 'value',
134
					displayName : 'Value',
135
					enableCellEdit : true,
136
					editableCellTemplate : "<input ng-show=\"!row.getProperty('function')\" type='text' ng-model='row.entity.value' ng-input='row.entity.value' ng-class=\"'colt' + col.index\" style='width: 98%;' />"
137
							+ "<select ng-show=\"row.getProperty('function')\" ng-model='row.entity.value' ng-input='row.entity.value' ng-class=\"'colt' + col.index\" ng-options=\"item.id as item.name for item in listValidValuesForUserParam(row.getProperty('function'))\"><option value=''></option></select>"
138
				} ]
139
	};
140

  
141
	$scope.gridSystemParams = {
142
		data : 'currentNode.systemParams',
143
		enableCellSelection : false,
144
		enableRowSelection : false,
145
		enableCellEditOnFocus : false,
146
		enablePaging : false,
147
		columnDefs : [ {
148
			field : 'name',
149
			displayName : 'Name',
150
			width : '12%'
151
		}, {
152
			field : 'required',
153
			displayName : 'Required',
154
			width : '8%'
155
		}, {
156
			field : 'type',
157
			displayName : 'Type',
158
			width : '8%'
159
		}, {
160
			field : 'value',
161
			displayName : 'Value'
162
		} ]
163
	};
164

  
165 92
	$scope.gridMetaWfHistory = {
166 93
		data : 'currentMetaWfHistory',
167 94
		enableCellEditOnFocus : false,
......
202 129
				} ]
203 130
	};
204 131

  
205
	$scope.getMetaWorkflow = function(id) {
206
		$scope.showSpinner();
207
		$http
208
				.get('wf_metaworkflow.json?id=' + id)
209
				.success(function(data) {
210
					$scope.currentMetaWorkflow = data;
211
					$scope.hideSpinner();
212
					$scope.currentTab = 'metawf';
213
				})
214
				.error(
215
						function() {
216
							$scope
217
									.showError('Something really bad must have happened to our fellow hamster..');
218
							$scope.hideSpinner();
219
						});
220
	}
221

  
222
	$scope.getAtomicWorkflow = function(id) {
223
		$scope.showSpinner();
224
		$http
225
				.get('wf_atomic_workflow.json?id=' + id)
226
				.success(function(data) {
227
					$scope.currentWorkflow = data;
228
					$scope.hideSpinner();
229
					$scope.currentTab = 'atomwf';
230
				})
231
				.error(
232
						function() {
233
							$scope
234
									.showError('Something really bad must have happened to our fellow hamster..');
235
							$scope.hideSpinner();
236
						});
237
	}
238

  
239 132
	$scope.getNode = function(wf, node) {
240 133
		$scope.showSpinner();
241 134
		$http
......
253 146
						});
254 147
	}
255 148

  
256
	$scope.saveCurrentNode = function() {
257
		$scope.showSpinner();
258
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
259
		$http
260
				.post('wf_workflow_node.save', $.param({
261
					'wf' : $scope.currentWorkflow.wfId,
262
					'json' : JSON.stringify($scope.currentNode)
263
				}))
264
				.success(function(data) {
265
					$scope.hideSpinner();
266
					$scope.getAtomicWorkflow($scope.currentWorkflow.wfId);
267
				})
268
				.error(
269
						function() {
270
							$scope
271
									.showError('Something really bad must have happened to our fellow hamster..');
272
							$scope.hideSpinner();
273
						});
274
	}
275

  
276
	$scope.prepareMetaWfEdit = function() {
277
		$scope.tempMetaWorkflow = angular.copy($scope.currentMetaWorkflow);
278
	};
279

  
280
	$scope.saveCurrentMetaWf = function() {
281
		$scope.showSpinner();
282
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
283
		$http
284
				.post('wf_metaworkflow.edit', $.param({
285
					'json' : JSON.stringify($scope.tempMetaWorkflow)
286
				}))
287
				.success(function(data) {
288
					$scope.hideSpinner();
289

  
290
					angular.forEach($scope.metaworkflows, function(value, key) {
291
						if (value.wfId == $scope.tempMetaWorkflow.wfId) {
292
							value.name = $scope.tempMetaWorkflow.name;
293
						}
294
					});
295

  
296
					$scope.getMetaWorkflow($scope.tempMetaWorkflow.wfId);
297
				})
298
				.error(
299
						function() {
300
							$scope
301
									.showError('Something really bad must have happened to our fellow hamster..');
302
							$scope.hideSpinner();
303
						});
304
	};
305

  
306
	$scope.executeWf = function() {
307
		$http
308
				.get('wf.start?id=' + $scope.currentWorkflow.wfId)
309
				.success(function(data) {
310
					$scope.updateMetaWorkflowHistory();
311
					$('#monitorWfModal').modal('show');
312
				})
313
				.error(
314
						function() {
315
							$scope
316
									.showError('Something really bad must have happened to our fellow hamster..');
317
						});
318
	};
319

  
320
	$scope.executeMetaWf = function() {
321
		$http
322
				.get('metawf.start?id=' + $scope.currentMetaWorkflow.wfId)
323
				.success(function(data) {
324
					$scope.updateMetaWorkflowHistory();
325
					$('#monitorWfModal').modal('show');
326
				})
327
				.error(
328
						function() {
329
							$scope
330
									.showError('Something really bad must have happened to our fellow hamster..');
331
						});
332
	};
333

  
334 149
	$scope.updateMetaWorkflowHistory = function() {
335 150
		$scope.currentMetaWfHistory = [];
336 151
		$scope.showSpinner();
......
428 243
						});
429 244
	}
430 245

  
431
	$scope.showPriorityDialog = function(b) {
432
		var s = prompt("New workflow priority [0..100]",
433
				$scope.currentWorkflow.priority);
434
		if (s == null) {
435
			return;
436
		}
437
		var value = parseInt(s);
438
		if (isNaN(value) || value < 0 || value > 100) {
439
			$scope.showError('Invalid value: ' + value);
440
			return;
441
		}
442
		$http
443
				.get(
444
						'wf_atomic_workflow.priority?value=' + value + "&id="
445
								+ $scope.currentWorkflow.wfId)
446
				.success(
447
						function(data) {
448
							$scope
449
									.showNotification('Priority updated, new value is '
450
											+ value);
451
							$scope.currentWorkflow.priority = value;
452
							$scope.hideSpinner();
453
						})
454
				.error(
455
						function() {
456
							$scope
457
									.showError('Something really bad must have happened to our fellow hamster..');
458
							$scope.hideSpinner();
459
						});
460
	}
461

  
462 246
	$scope.updateWfJournal = function(id) {
463 247
		$scope.currentWorkflowJournal = [];
464 248

  

Also available in: Unified diff