Commit 10dee8198748c720ed6521f238cc13a9feacab88
1 parent
ecac355e
Exists in
master
and in
110 other branches
clean JobsMgr and ExplorerModule
Showing
3 changed files
with
553 additions
and
464 deletions
Show diff stats
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +env: | ||
2 | + browser: true | ||
3 | +extends: 'eslint:all' | ||
4 | +globals: | ||
5 | + Ext: true | ||
6 | +plugins: | ||
7 | + - extjs | ||
8 | +rules: | ||
9 | + indent: [error, 2, SwitchCase: 1] | ||
10 | + semi: [warn, never] | ||
11 | + max-len: [error, code: 120] | ||
12 | + max-lines: [error, 600] | ||
13 | + linebreak-style: [error, unix] | ||
14 | + quotes: [error, single] | ||
15 | + strict: [error, global] | ||
16 | + quote-props: [error, as-needed] | ||
17 | + max-statements: [warn, 20] | ||
18 | + array-bracket-newline: [warn, consistent] | ||
19 | + consistent-this: [error, me] | ||
20 | + padded-blocks: off | ||
21 | + no-tabs: off | ||
22 | + no-warning-comments: off | ||
23 | + func-names: off | ||
24 | + function-paren-newline: off | ||
25 | + init-declarations: off | ||
26 | + sort-keys: off | ||
27 | + id-length: off | ||
28 | + no-magic-numbers: off | ||
29 | + no-invalid-this: off | ||
30 | + | ||
31 | +# ES3/5 compatibility: | ||
32 | + prefer-template: off | ||
33 | + no-var: off | ||
34 | + prefer-arrow-callback: off | ||
35 | + object-shorthand: off | ||
36 | + prefer-rest-params: off |
js/app/controllers/ExplorerModule.js
1 | -/** | 1 | +/** |
2 | * Project : AMDA-NG | 2 | * Project : AMDA-NG |
3 | * Name : ExplorerModule.js | 3 | * Name : ExplorerModule.js |
4 | - * @class amdaDesktop.ExplorerModule | 4 | + * @class amdaDesktop.ExplorerModule |
5 | * @extends amdaDesktop.AmdaModule | 5 | * @extends amdaDesktop.AmdaModule |
6 | * @brief Explorer Module controller definition | 6 | * @brief Explorer Module controller definition |
7 | * @author CDA | 7 | * @author CDA |
8 | */ | 8 | */ |
9 | 9 | ||
10 | -Ext.define('amdaDesktop.ExplorerModule', | ||
11 | -{ | ||
12 | - extend: 'amdaDesktop.AmdaModule', | ||
13 | - | ||
14 | - requires : [ | ||
15 | - 'amdaUI.ExplorerUI', | ||
16 | - 'amdaUI.AliasUI', | ||
17 | - // Node Models | ||
18 | - 'amdaModel.BkgJobNode', | ||
19 | - 'amdaModel.DerivedParamNode', | ||
20 | - 'amdaModel.LocalParamNode', | ||
21 | - 'amdaModel.RemoteParamNode', | ||
22 | - 'amdaModel.RemoteSimuParamNode', | ||
23 | - 'amdaModel.AliasNode', | ||
24 | - 'amdaModel.TimeTableNode', | ||
25 | - 'amdaModel.CatalogNode', | ||
26 | - 'amdaModel.StatisticsNode', // singleton; not shown in the tree | ||
27 | - 'amdaModel.sharedTimeTableNode', | ||
28 | - 'amdaModel.sharedCatalogNode', | ||
29 | - 'amdaModel.MyDataParamNode', | ||
30 | - 'amdaModel.MyDataNode', | ||
31 | - 'amdaModel.PlotNode', | ||
32 | - 'amdaModel.DownloadNode', // singleton; not shown in the tree | ||
33 | - 'amdaModel.SearchNode', | ||
34 | - // Object Models | ||
35 | - 'amdaModel.Parameter', | ||
36 | - 'amdaModel.Search', | ||
37 | - 'amdaModel.Download', | ||
38 | - 'amdaModel.TimeTable', | ||
39 | - 'amdaModel.Catalog', | ||
40 | - 'amdaModel.Stats', | ||
41 | - 'amdaModel.FileObject', | ||
42 | - 'amdaModel.FileParamObject', | ||
43 | - 'amdaModel.FilterInfo' | ||
44 | - ], | ||
45 | - | ||
46 | - contentId : 'explorerUI', | ||
47 | - | ||
48 | - filter : null, | ||
49 | - filtersStore : null, | ||
50 | - | ||
51 | - paramInfoRegistry : {}, | ||
52 | - | ||
53 | - constructor : function(config) | ||
54 | - { | ||
55 | - this.callParent(arguments); | ||
56 | - if (!this.filtersStore) | ||
57 | - { | ||
58 | - this.filtersStore = Ext.create('Ext.data.Store', { | ||
59 | - model: 'amdaModel.FilterList' | ||
60 | - }); | ||
61 | - this.filtersStore.load(); | ||
62 | - // amdaDesktop.ExplorerModule.filtersStore = this.filtersStore; | ||
63 | - } | ||
64 | - }, | ||
65 | - | ||
66 | - createWindow : function() | ||
67 | - { | ||
68 | - var desktop = this.app.getDesktop(); | ||
69 | - | ||
70 | - var win = desktop.getWindow(this.id); | ||
71 | - if (!win) { | ||
72 | - win = desktop.createWindow( { | ||
73 | - id : this.id, | ||
74 | - title : this.title, | ||
75 | - width : 340, | ||
76 | - height : 500, | ||
77 | - iconCls : this.icon, | ||
78 | - animCollapse : false, | ||
79 | - border : false, | ||
80 | - // constrainHeader : true, | ||
81 | - closable: false, | ||
82 | - stateful : true, | ||
83 | - stateId : this.id, | ||
84 | - stateEvents: ['move','show','resize'], | ||
85 | - constrain: true, | ||
86 | - layout : | ||
87 | - { | ||
88 | - type : 'border', | ||
89 | - align : 'stretch' | ||
90 | - }, | ||
91 | - x : 5, | ||
92 | - y : 5, | ||
93 | - items : [ | ||
94 | - { | ||
95 | - xtype: 'panelExplorer', | ||
96 | - id : this.contentId, | ||
97 | - region: 'center' | ||
98 | - }, | ||
99 | - { | ||
100 | - xtype: 'panel', | ||
101 | - id : 'LogPanel', | ||
102 | - region: 'south', | ||
103 | - height : 150, | ||
104 | - split : true, | ||
105 | - layout: { | ||
106 | - type: 'vbox', | ||
107 | - align : 'stretch', | ||
108 | - autoSize : true | ||
109 | - }, | ||
110 | - autoScroll : true, | ||
111 | - stateful : true, | ||
112 | - stateId : 'LogPanel', | ||
113 | - buttons : [{ | ||
114 | - scope: this, | ||
115 | - text : 'Clear', | ||
116 | - handler: function(){ | ||
117 | - win.items.get('LogPanel').removeAll(); | ||
118 | - this.addLogMessage('<b>Log</b>'); | ||
119 | - } | ||
120 | - }] | ||
121 | - } | ||
122 | - ] | ||
123 | - }); | ||
124 | - } | ||
125 | - | ||
126 | - win.on({ | ||
127 | - activate: { | ||
128 | - fn : function() | ||
129 | - { | ||
130 | - myDesktopApp.getLoadedModule(this.id, true, function (module) { | ||
131 | - // on activation when there's a pinedModule 'null' | ||
132 | - if (module.pinedModule===null) { | ||
133 | - // get the ZIndex manager | ||
134 | - var manager = myDesktopApp.desktop.getDesktopZIndexManager(); | ||
135 | - // ordering to send back this window | ||
136 | - manager.sendToBack(win); | ||
137 | - } | ||
138 | - }); | ||
139 | - }, | ||
140 | - scope: this | ||
141 | - } | ||
142 | - }); | ||
143 | - | ||
144 | - win.on({ | ||
145 | - show : | ||
146 | - { | ||
147 | - fn : function(o) | ||
148 | - { | ||
149 | - //set current filter | ||
150 | - this.setCrtFilter(); | ||
151 | - //resize the explorer in relation with the desktop size | ||
152 | - if (win.y + win.height > myDesktopApp.desktop.el.getHeight()) | ||
153 | - win.setHeight(myDesktopApp.desktop.el.getHeight() - win.y); | ||
154 | - }, | ||
155 | - scope : this | ||
156 | - } | ||
157 | - }); | ||
158 | - | ||
159 | - win.addCls('window-active'); | ||
160 | - win.show(); | ||
161 | - this.addLogMessage('<b>Log</b>'); | ||
162 | - return win; | ||
163 | - }, | ||
164 | - | ||
165 | - pinedModule : null, | ||
166 | - | ||
167 | - /** | ||
168 | - * Getter of pinedModule | ||
169 | - * @return {amdaDesktop.InteractiveModule} The pined module | ||
170 | - */ | ||
171 | - getPinedModule : function() | ||
172 | - { | ||
173 | - // get the pined Module | ||
174 | - return this.pinedModule; | ||
175 | - }, | 10 | +'use strict' |
176 | 11 | ||
177 | - /** | ||
178 | - * Setter of pinedModule | ||
179 | - * @param {amdaDesktop.InteractiveModule} The pined module | ||
180 | - */ | ||
181 | - setPinedModule : function(amdaModule) | ||
182 | - { | ||
183 | - // set the pined Module | ||
184 | - this.pinedModule = amdaModule; | ||
185 | - }, | ||
186 | - | ||
187 | - /** | ||
188 | - * Module Attachment Method | ||
189 | - * @param {amdaDesktop.InteractiveModule} The module to attach | ||
190 | - */ | ||
191 | - pinMechanism : function(amdaModule) | ||
192 | - { | ||
193 | - // if there is an old pined module | ||
194 | - if (this.getPinedModule()!=null) { | ||
195 | - // get old pined module : | ||
196 | - var oldPinedModule = this.getPinedModule(); | ||
197 | - // call uncolor method on the old pined Module | ||
198 | - myDesktopApp.getLoadedModule(oldPinedModule).uncolorHeaderModule(); | ||
199 | - } | ||
200 | - // set pined module | ||
201 | - this.setPinedModule(amdaModule); | ||
202 | - // call color method on pined Module | ||
203 | - myDesktopApp.getLoadedModule(amdaModule).colorHeaderModule(); | ||
204 | - }, | ||
205 | - | ||
206 | - | ||
207 | - addLogMessage : function(message) | ||
208 | - { | ||
209 | - var height = 40; | ||
210 | - var msg = Ext.create('Ext.Component', { | ||
211 | - height: height, | ||
212 | - html: message, | ||
213 | - style: { color : '#555555'} | ||
214 | - }); | ||
215 | - var desktop = myDesktopApp.getDesktop(); | ||
216 | - var win = desktop.getWindow(this.id); | ||
217 | - var panel = win.items.get('LogPanel'); | ||
218 | - panel.add(msg); | ||
219 | - }, | ||
220 | - | ||
221 | - // | ||
222 | - setCrtFilter : function() | ||
223 | - { | ||
224 | - var me = this; | ||
225 | - //get current filter to apply | ||
226 | - AmdaAction.getCrtFilterResult(function (result, e) | ||
227 | - { | ||
228 | - var t = e.getTransaction(); | ||
229 | - if (e.status) | ||
230 | - { | ||
231 | - if (result) | ||
232 | - { | ||
233 | - //apply current filter | ||
234 | - this.filter = result; | ||
235 | - // add saved filter to Explorer List | ||
236 | - if (!this.filtersStore.getById(this.filter.id)) | ||
237 | - this.filtersStore.add({id : this.filter.id, name : this.filter.name}); | ||
238 | - | ||
239 | - //apply filter to the tree | ||
240 | - var desktop = myDesktopApp.getDesktop(); | ||
241 | - var win = desktop.getWindow(this.id); | ||
242 | - if (win) | ||
243 | - { | ||
244 | - var explorerUI = win.query('#'+this.contentId); | ||
245 | - explorerUI[0].updateFilter(); | ||
246 | - } | ||
247 | - } | ||
248 | - else | ||
249 | - Ext.Msg.show( { | ||
250 | - title : 'Filter', | ||
251 | - msg : 'Cannot apply filter', | ||
252 | - modal : true, | ||
253 | - icon : Ext.Msg.ERROR, | ||
254 | - buttons : Ext.Msg.OK | ||
255 | - }); | ||
256 | - } | ||
257 | - else | ||
258 | - { | ||
259 | - // FAILURE | ||
260 | - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | ||
261 | - } | ||
262 | - },this); | ||
263 | - }, | ||
264 | - | ||
265 | - resetFilter : function() | ||
266 | - { | ||
267 | - AmdaAction.resetFilter( function (result, e) | ||
268 | - { | ||
269 | - var t = e.getTransaction(); | ||
270 | - if (e.status) | ||
271 | - { | ||
272 | - if (result) | ||
273 | - { | ||
274 | - this.setCrtFilter(); | ||
275 | - //update filter win | ||
276 | - var desktop = myDesktopApp.getDesktop(); | ||
277 | - var win = desktop.getWindow(myDesktopApp.dynamicModules.filters.id); | ||
278 | - if (win) | ||
279 | - { | ||
280 | - var filterUI = win.query('panelFilters'); | ||
281 | - filterUI[0].reloadFilter(); | ||
282 | - } | ||
283 | - } | ||
284 | - else | ||
285 | - Ext.Msg.show( { | ||
286 | - title : 'Filter', | ||
287 | - msg : 'Cannot reset filter', | ||
288 | - modal : true, | ||
289 | - icon : Ext.Msg.ERROR, | ||
290 | - buttons : Ext.Msg.OK | ||
291 | - }); | ||
292 | - } | ||
293 | - else | ||
294 | - { | ||
295 | - // FAILURE | ||
296 | - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | ||
297 | - } | ||
298 | - },this); | ||
299 | - }, | ||
300 | - | ||
301 | - getParamInfo : function(paramId, onReady) | ||
302 | - { | ||
303 | - if (this.paramInfoRegistry[paramId]) | ||
304 | - { | ||
305 | - if (onReady) | ||
306 | - onReady(this.paramInfoRegistry[paramId]); | ||
307 | - return this.paramInfoRegistry[paramId]; | ||
308 | - } | ||
309 | - | ||
310 | - var me = this; | ||
311 | - AmdaAction.getParamInfo({"paramId" : paramId}, function (result, e) | ||
312 | - { | ||
313 | - var paramInfo = null; | ||
314 | - if (e.status === true) | ||
315 | - { | ||
316 | - if (!result.success) | ||
317 | - { | ||
318 | - //No available info for this parameter. Do not display an error message | ||
319 | - /*if (result.message && result.message != '') | ||
320 | - Ext.Msg.show({title:'Get parameter arguments error ', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | ||
321 | - else | ||
322 | - Ext.Msg.show({title:'Get parameter arguments error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});*/ | ||
323 | - } | ||
324 | - else | ||
325 | - { | ||
326 | - //Store parameter info in registry | ||
327 | - me.paramInfoRegistry[paramId] = result; | ||
328 | - paramInfo = result; | ||
329 | - } | ||
330 | - } | ||
331 | - else | ||
332 | - { | ||
333 | - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | ||
334 | - } | 12 | +/* global AmdaAction, myDesktopApp */ |
335 | 13 | ||
336 | - if (onReady) | ||
337 | - onReady(paramInfo); | ||
338 | - }); | ||
339 | - | ||
340 | - return null; | ||
341 | - } | ||
342 | - | ||
343 | -}); | 14 | +/** |
15 | + * @typedef {AmdaApp} myDesktopApp | ||
16 | + * @typedef {Object} AmdaAction | ||
17 | + * @typedef {Object} Ext | ||
18 | + */ | ||
19 | + | ||
20 | +Ext.define('amdaDesktop.ExplorerModule', | ||
21 | + { | ||
22 | + extend: 'amdaDesktop.AmdaModule', | ||
23 | + requires: [ | ||
24 | + 'amdaUI.ExplorerUI', | ||
25 | + 'amdaUI.AliasUI', | ||
26 | + // Node Models | ||
27 | + 'amdaModel.BkgJobNode', | ||
28 | + 'amdaModel.DerivedParamNode', | ||
29 | + 'amdaModel.LocalParamNode', | ||
30 | + 'amdaModel.RemoteParamNode', | ||
31 | + 'amdaModel.RemoteSimuParamNode', | ||
32 | + 'amdaModel.AliasNode', | ||
33 | + 'amdaModel.TimeTableNode', | ||
34 | + 'amdaModel.CatalogNode', | ||
35 | + // StatisticsNode: singleton, not shown in the tree | ||
36 | + 'amdaModel.StatisticsNode', | ||
37 | + 'amdaModel.sharedTimeTableNode', | ||
38 | + 'amdaModel.sharedCatalogNode', | ||
39 | + 'amdaModel.MyDataParamNode', | ||
40 | + 'amdaModel.MyDataNode', | ||
41 | + 'amdaModel.PlotNode', | ||
42 | + // DownloadNode: singleton, not shown in the tree | ||
43 | + 'amdaModel.DownloadNode', | ||
44 | + 'amdaModel.SearchNode', | ||
45 | + // Object Models | ||
46 | + 'amdaModel.Parameter', | ||
47 | + 'amdaModel.Search', | ||
48 | + 'amdaModel.Download', | ||
49 | + 'amdaModel.TimeTable', | ||
50 | + 'amdaModel.Catalog', | ||
51 | + 'amdaModel.Stats', | ||
52 | + 'amdaModel.FileObject', | ||
53 | + 'amdaModel.FileParamObject', | ||
54 | + 'amdaModel.FilterInfo' | ||
55 | + ], | ||
56 | + | ||
57 | + contentId: 'explorerUI', | ||
58 | + filter: null, | ||
59 | + filtersStore: null, | ||
60 | + paramInfoRegistry: {}, | ||
61 | + | ||
62 | + constructor: function () { | ||
63 | + this.superclass.constructor.apply(this, arguments) | ||
64 | + if (!this.filtersStore) { | ||
65 | + this.filtersStore = Ext.create('Ext.data.Store', {model: 'amdaModel.FilterList'}) | ||
66 | + this.filtersStore.load() | ||
67 | + // Note: amdaDesktop.ExplorerModule.filtersStore = this.filtersStore; | ||
68 | + } | ||
69 | + }, | ||
70 | + | ||
71 | + createWindow: function () { | ||
72 | + var desktop, win | ||
73 | + | ||
74 | + desktop = this.app.getDesktop() | ||
75 | + win = desktop.getWindow(this.id) | ||
76 | + if (!win) { | ||
77 | + win = desktop.createWindow({ | ||
78 | + id: this.id, | ||
79 | + title: this.title, | ||
80 | + width: 340, | ||
81 | + height: 500, | ||
82 | + iconCls: this.icon, | ||
83 | + animCollapse: false, | ||
84 | + border: false, | ||
85 | + closable: false, | ||
86 | + stateful: true, | ||
87 | + stateId: this.id, | ||
88 | + stateEvents: [ | ||
89 | + 'move', | ||
90 | + 'show', | ||
91 | + 'resize' | ||
92 | + ], | ||
93 | + constrain: true, | ||
94 | + layout: | ||
95 | + { | ||
96 | + type: 'border', | ||
97 | + align: 'stretch' | ||
98 | + }, | ||
99 | + x: 5, | ||
100 | + y: 5, | ||
101 | + items: [ | ||
102 | + { | ||
103 | + xtype: 'panelExplorer', | ||
104 | + id: this.contentId, | ||
105 | + region: 'center' | ||
106 | + }, | ||
107 | + { | ||
108 | + xtype: 'panel', | ||
109 | + id: 'LogPanel', | ||
110 | + region: 'south', | ||
111 | + height: 150, | ||
112 | + split: true, | ||
113 | + layout: { | ||
114 | + type: 'vbox', | ||
115 | + align: 'stretch', | ||
116 | + autoSize: true | ||
117 | + }, | ||
118 | + autoScroll: true, | ||
119 | + stateful: true, | ||
120 | + stateId: 'LogPanel', | ||
121 | + buttons: [{ | ||
122 | + scope: this, | ||
123 | + text: 'Clear', | ||
124 | + handler: function () { | ||
125 | + var logPanel = win.items.get('LogPanel') | ||
126 | + logPanel.removeAll() | ||
127 | + } | ||
128 | + }] | ||
129 | + } | ||
130 | + ] | ||
131 | + }) | ||
132 | + } | ||
133 | + | ||
134 | + win.on('activate', function () { | ||
135 | + var manager | ||
136 | + myDesktopApp.getLoadedModule(this.id, true, function (module) { | ||
137 | + // On activation when there's a pinedModule 'null' | ||
138 | + if (module.pinedModule === null) { | ||
139 | + // Get the ZIndex manager | ||
140 | + manager = myDesktopApp.desktop.getDesktopZIndexManager() | ||
141 | + // Ordering to send back this window | ||
142 | + manager.sendToBack(win) | ||
143 | + } | ||
144 | + }) | ||
145 | + }, this) | ||
146 | + | ||
147 | + win.on('show', function () { | ||
148 | + var desktopHeight | ||
149 | + // Set current filter | ||
150 | + this.setCrtFilter() | ||
151 | + // Resize the explorer in relation with the desktop size | ||
152 | + if (win.y + win.height > myDesktopApp.desktop.el.getHeight()) { | ||
153 | + desktopHeight = myDesktopApp.desktop.el.getHeight() | ||
154 | + win.setHeight(desktopHeight - win.y) | ||
155 | + } | ||
156 | + }, this) | ||
157 | + | ||
158 | + win.addCls('window-active') | ||
159 | + win.show() | ||
160 | + return win | ||
161 | + }, | ||
162 | + | ||
163 | + pinedModule: null, | ||
164 | + | ||
165 | + /** | ||
166 | + * Getter of pinedModule | ||
167 | + * @return {amdaDesktop.InteractiveModule} The pined module | ||
168 | + */ | ||
169 | + getPinedModule: function () { | ||
170 | + // Get the pined Module | ||
171 | + return this.pinedModule | ||
172 | + }, | ||
173 | + | ||
174 | + /** | ||
175 | + * Setter of pinedModule | ||
176 | + * @param {amdaDesktop.InteractiveModule} amdaModule The pined module | ||
177 | + * @returns {void} | ||
178 | + */ | ||
179 | + setPinedModule: function (amdaModule) { | ||
180 | + // Set the pined Module | ||
181 | + this.pinedModule = amdaModule | ||
182 | + }, | ||
183 | + | ||
184 | + /** | ||
185 | + * Module Attachment Method | ||
186 | + * @param {amdaDesktop.InteractiveModule} amdaModule The module to attach | ||
187 | + * @returns {void} | ||
188 | + */ | ||
189 | + pinMechanism: function (amdaModule) { | ||
190 | + var loadedAmdaModule, loadedPinedModule, oldPinedModule | ||
191 | + // If there is an old pined module | ||
192 | + if (this.getPinedModule() !== null) { | ||
193 | + // Get old pined module : | ||
194 | + oldPinedModule = this.getPinedModule() | ||
195 | + loadedPinedModule = myDesktopApp.getLoadedModule(oldPinedModule) | ||
196 | + // Call uncolor method on the old pined Module | ||
197 | + loadedPinedModule.uncolorHeaderModule() | ||
198 | + } | ||
199 | + // Set pined module | ||
200 | + this.setPinedModule(amdaModule) | ||
201 | + // Call color method on pined Module | ||
202 | + loadedAmdaModule = myDesktopApp.getLoadedModule(amdaModule) | ||
203 | + loadedAmdaModule.colorHeaderModule() | ||
204 | + }, | ||
205 | + | ||
206 | + addLogMessage: function (message) { | ||
207 | + var height, msg, panel, win | ||
208 | + height = 40 | ||
209 | + msg = Ext.create('Ext.Component', { | ||
210 | + height: height, | ||
211 | + html: message, | ||
212 | + style: {color: '#555555'} | ||
213 | + }) | ||
214 | + win = myDesktopApp.getDesktop().getWindow(this.id) | ||
215 | + panel = win.items.get('LogPanel') | ||
216 | + panel.add(msg) | ||
217 | + }, | ||
218 | + | ||
219 | + // | ||
220 | + setCrtFilter: function () { | ||
221 | + // Get current filter to apply | ||
222 | + AmdaAction.getCrtFilterResult(function (result, e) { | ||
223 | + var explorerUI, win | ||
224 | + if (!e.status) { | ||
225 | + Ext.Msg.show({ | ||
226 | + title: 'Error System', | ||
227 | + msg: e.message, | ||
228 | + icon: Ext.MessageBox.ERROR, | ||
229 | + buttons: Ext.Msg.OK | ||
230 | + }) | ||
231 | + } else if (result) { | ||
232 | + // Apply current filter | ||
233 | + this.filter = result | ||
234 | + // Add saved filter to Explorer List | ||
235 | + if (!this.filtersStore.getById(this.filter.id)) { | ||
236 | + this.filtersStore.add({ | ||
237 | + id: this.filter.id, | ||
238 | + name: this.filter.name | ||
239 | + }) | ||
240 | + } | ||
241 | + | ||
242 | + // Apply filter to the tree | ||
243 | + win = myDesktopApp.getDesktop().getWindow(this.id) | ||
244 | + if (win) { | ||
245 | + explorerUI = win.query('#' + this.contentId) | ||
246 | + explorerUI[0].updateFilter() | ||
247 | + } | ||
248 | + } else { | ||
249 | + Ext.Msg.show({ | ||
250 | + title: 'Filter', | ||
251 | + msg: 'Cannot apply filter', | ||
252 | + modal: true, | ||
253 | + icon: Ext.Msg.ERROR, | ||
254 | + buttons: Ext.Msg.OK | ||
255 | + }) | ||
256 | + } | ||
257 | + }, this) | ||
258 | + }, | ||
259 | + | ||
260 | + resetFilter: function () { | ||
261 | + AmdaAction.resetFilter(function (result, e) { | ||
262 | + var filterUI, win | ||
263 | + if (!e.status) { | ||
264 | + Ext.Msg.show({ | ||
265 | + title: 'Error System', | ||
266 | + msg: e.message, | ||
267 | + icon: Ext.MessageBox.ERROR, | ||
268 | + buttons: Ext.Msg.OK | ||
269 | + }) | ||
270 | + } else if (result) { | ||
271 | + this.setCrtFilter() | ||
272 | + // Update filter win | ||
273 | + win = myDesktopApp.getDesktop().getWindow(myDesktopApp.dynamicModules.filters.id) | ||
274 | + if (win) { | ||
275 | + filterUI = win.query('panelFilters') | ||
276 | + filterUI[0].reloadFilter() | ||
277 | + } | ||
278 | + } else { | ||
279 | + Ext.Msg.show({ | ||
280 | + title: 'Filter', | ||
281 | + msg: 'Cannot reset filter', | ||
282 | + modal: true, | ||
283 | + icon: Ext.Msg.ERROR, | ||
284 | + buttons: Ext.Msg.OK | ||
285 | + }) | ||
286 | + } | ||
287 | + }, this) | ||
288 | + }, | ||
289 | + | ||
290 | + getParamInfo: function (paramId, onReady) { | ||
291 | + var me = this | ||
292 | + | ||
293 | + if (this.paramInfoRegistry[paramId]) { | ||
294 | + if (onReady) { | ||
295 | + onReady(this.paramInfoRegistry[paramId]) | ||
296 | + } | ||
297 | + return this.paramInfoRegistry[paramId] | ||
298 | + } | ||
299 | + | ||
300 | + AmdaAction.getParamInfo({paramId: paramId}, function (result, e) { | ||
301 | + var paramInfo = null | ||
302 | + if (e.status === true) { | ||
303 | + // No available info for this parameter, do not display an error message if no success | ||
304 | + if (result.success) { | ||
305 | + // Store parameter info in registry | ||
306 | + me.paramInfoRegistry[paramId] = result | ||
307 | + paramInfo = result | ||
308 | + } | ||
309 | + } else { | ||
310 | + Ext.Msg.show({ | ||
311 | + title: 'Error System', | ||
312 | + msg: e.message, | ||
313 | + icon: Ext.MessageBox.ERROR, | ||
314 | + buttons: Ext.Msg.OK | ||
315 | + }) | ||
316 | + } | ||
317 | + | ||
318 | + if (onReady) { | ||
319 | + onReady(paramInfo) | ||
320 | + } | ||
321 | + }) | ||
322 | + | ||
323 | + return null | ||
324 | + } | ||
325 | + | ||
326 | + }) |
js/app/controllers/JobsMgr.js
1 | -/** | 1 | +/** |
2 | * Project : AMDA-NG4 | 2 | * Project : AMDA-NG4 |
3 | * Name : JobsMgr.js | 3 | * Name : JobsMgr.js |
4 | - * @class amdaDesktop.JobsMgr | ||
5 | - * @extends Ext.AbstractManager | 4 | + * @class amdaDesktop.JobsMgr |
5 | + * @extends Ext.AbstractManager | ||
6 | * @brief Manages Jobs In Progress | 6 | * @brief Manages Jobs In Progress |
7 | * @author elena | 7 | * @author elena |
8 | * @version $Id: JobsMgr.js 2759 2015-02-19 12:32:31Z elena $ | 8 | * @version $Id: JobsMgr.js 2759 2015-02-19 12:32:31Z elena $ |
9 | - * @todo | ||
10 | ******************************************************************************* | 9 | ******************************************************************************* |
11 | * FT Id : Date : Name - Description | 10 | * FT Id : Date : Name - Description |
12 | ******************************************************************************* | 11 | ******************************************************************************* |
13 | - * : :28/01/2011: | ||
14 | - | 12 | + * : :28/01/2011: |
15 | */ | 13 | */ |
14 | + | ||
15 | +'use strict' | ||
16 | +/* global AmdaAction, myDesktopApp, amdaDesktop, amdaModel, amdaUI */ | ||
17 | + | ||
18 | +/** | ||
19 | + * @typedef {{ | ||
20 | + * success: boolean, | ||
21 | + * id: string | ||
22 | + * name: string | ||
23 | + * status: string | ||
24 | + * jobType: string | ||
25 | + * info: string | ||
26 | + * start: string | ||
27 | + * stop: string | ||
28 | + * folder: string | ||
29 | + * result: string | ||
30 | + * format: string | ||
31 | + * compression: string | ||
32 | + * sendToSamp: boolean | ||
33 | + * }} Job | ||
34 | + */ | ||
35 | + | ||
36 | +/** | ||
37 | + * @typedef {{ | ||
38 | + * success: boolean, | ||
39 | + * nFinished: number, | ||
40 | + * nError: number, | ||
41 | + * nInProgress: number, | ||
42 | + * jobsFinished: Array.<Job>, | ||
43 | + * jobsInProgress: Array.<Job> | ||
44 | + * }} Result | ||
45 | + */ | ||
46 | + | ||
47 | +/** | ||
48 | + * @typedef {{ | ||
49 | + * status: boolean | ||
50 | + * }} Error | ||
51 | + */ | ||
52 | + | ||
16 | Ext.define('amdaDesktop.JobsMgr', { | 53 | Ext.define('amdaDesktop.JobsMgr', { |
17 | - | ||
18 | - extend: 'Ext.AbstractManager', | ||
19 | - singleton: true, | ||
20 | - first : true, | ||
21 | - jobsInProgress : 0, | ||
22 | - jobsFinished : 0, | ||
23 | - jobsError : 0, | ||
24 | - updateStatus : null, | ||
25 | - interval : 60000, // //msec 60000 | ||
26 | - | ||
27 | - jobTree : null, | ||
28 | - | ||
29 | - | ||
30 | -//TODO first => at login !!! | ||
31 | - | ||
32 | - getStatus : function(){ | ||
33 | - | ||
34 | - AmdaAction.getJobs(function(res,e){ | ||
35 | -//TODO Errors processing | ||
36 | - if (e.status) { | ||
37 | - if (res.success) { | ||
38 | -// Update from Server Jobs Running and Finished | ||
39 | - if (res.nFinished > 0 || res.nError ) { | ||
40 | - Ext.each(res.jobsFinished, function(item, index, all){ | ||
41 | - if (item.status != 'old') { | ||
42 | - switch (item.jobType) { | ||
43 | - case 'condition' : var type = 'Data Mining '; break; | ||
44 | - case 'request' : var type = 'Plot '; break; | ||
45 | - case 'download' : var type = 'Download '; break; | ||
46 | - case 'statistics' : var type = 'Statistics '; break; | ||
47 | - default: var type = 'unknown'; | ||
48 | - } | ||
49 | - var message = Ext.Date.format(new Date(), 'd-m-Y H:i:s: ') + ': '+ type + ' '+item.name + ' completed'; | ||
50 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id, true, function (module) { | ||
51 | - module.addLogMessage(message); | ||
52 | - }); | ||
53 | - } | ||
54 | - }); | ||
55 | - | ||
56 | - } | ||
57 | - | ||
58 | - if (amdaDesktop.JobsMgr.first && (res.nInProgress > 0 || res.nFinished > 0 || res.nError > 0)) { | ||
59 | - myDesktopApp.infoMsg('You have '+ res.nFinished + ' new finished jobs, ' + res.nInProgress + ' jobs in progress and ' + res.nError + 'jobs in error'); | ||
60 | - } | ||
61 | - | ||
62 | - amdaDesktop.JobsMgr.jobsInProgress = res.nInProgress; | ||
63 | - amdaDesktop.JobsMgr.jobsFinished = res.nFinished; | ||
64 | - amdaDesktop.JobsMgr.jobsError = res.nError; | ||
65 | - | ||
66 | - if (res.nInProgress == 0 && amdaDesktop.JobsMgr.updateStatus) | ||
67 | - { | ||
68 | - Ext.TaskManager.stop(amdaDesktop.JobsMgr.updateStatus); | ||
69 | - amdaDesktop.JobsMgr.updateStatus = null; | ||
70 | - } | ||
71 | - if (res.nInProgress > 0 && !amdaDesktop.JobsMgr.updateStatus) | ||
72 | - { | ||
73 | - amdaDesktop.JobsMgr.updateStatus = | ||
74 | - Ext.TaskManager.start({ | ||
75 | - run : amdaDesktop.JobsMgr.getStatus, | ||
76 | - interval : amdaDesktop.JobsMgr.interval | ||
77 | - }); | ||
78 | - } | ||
79 | - | ||
80 | - if ((res.nFinished > 0 || res.nError) && !amdaDesktop.JobsMgr.first) { | ||
81 | - if (!amdaDesktop.JobsMgr.jobTree) | ||
82 | - amdaDesktop.JobsMgr.jobTree = Ext.getCmp(amdaUI.ExplorerUI.JOB_TAB.TREE_ID); | ||
83 | - | ||
84 | - Ext.each(res.jobsFinished, function(job) { | ||
85 | - | ||
86 | - switch (job.jobType) { | ||
87 | - case 'condition': | ||
88 | -//TODO get root nodes depending on conditions | ||
89 | - var resRootNode = | ||
90 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.RES_ROOT_NODE.CONDITION, true); | ||
91 | - var jobRootNode = | ||
92 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.JOB_ROOT_NODE.CONDITION, true); | ||
93 | - break; | ||
94 | - case 'request' : | ||
95 | - var resRootNode = | ||
96 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.RES_ROOT_NODE.PLOT, true); | ||
97 | - var jobRootNode = | ||
98 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.JOB_ROOT_NODE.PLOT, true); | ||
99 | - break; | ||
100 | - case 'download' : | ||
101 | - var resRootNode = | ||
102 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.RES_ROOT_NODE.DOWNLOAD, true); | ||
103 | - var jobRootNode = | ||
104 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.JOB_ROOT_NODE.DOWNLOAD, true); | ||
105 | - break; | ||
106 | - case 'statistics' : | ||
107 | - var resRootNode = | ||
108 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.RES_ROOT_NODE.STATISTICS, true); | ||
109 | - var jobRootNode = | ||
110 | - amdaDesktop.JobsMgr.jobTree.getRootNode().findChild('id',amdaModel.BkgJobNode.JOB_ROOT_NODE.STATISTICS, true); | ||
111 | - break; | ||
112 | - default : | ||
113 | - } | ||
114 | -//TODO check: job sub tree is always expanded - after the first job is launched - there cannot be too many unfinished jobs on login | ||
115 | -// so callback is not needed | ||
116 | - if (!resRootNode.parentNode.isExpanded()) resRootNode.parentNode.expand(false); | ||
117 | - if (!jobRootNode.parentNode.isExpanded()) jobRootNode.parentNode.expand(false); | ||
118 | - if (!jobRootNode.isExpanded()) jobRootNode.expand(false); | ||
119 | - | ||
120 | - //AKKA - use processid to find job | ||
121 | - var nodeToMove = jobRootNode.findChild('id', job.id, false); | ||
122 | - nodeToMove.set('status',job.status); | ||
123 | -//TODO check if really job.status | ||
124 | - nodeToMove.set('iconCls','icon-'+job.status); | ||
125 | - | ||
126 | - jobRootNode.removeChild(nodeToMove); | ||
127 | - | ||
128 | - if (!resRootNode.isExpanded()) { | ||
129 | - resRootNode.expand(false, function(){ | ||
130 | - if (!resRootNode.findChild('id', nodeToMove.get('processId'))) | ||
131 | - resRootNode.appendChild(nodeToMove); | ||
132 | - }); | ||
133 | - } | ||
134 | - else resRootNode.appendChild(nodeToMove); | ||
135 | - }); | ||
136 | - } | ||
137 | - } | 54 | + extend: 'Ext.AbstractManager', |
55 | + first: true, | ||
56 | + interval: 60000, | ||
57 | + jobTree: null, | ||
58 | + jobsError: 0, | ||
59 | + jobsFinished: 0, | ||
60 | + jobsInProgress: 0, | ||
61 | + singleton: true, | ||
62 | + updateStatus: null, | ||
63 | + | ||
64 | + // TODO first => at login !!! | ||
65 | + getStatus: function () { | ||
66 | + AmdaAction.getJobs( | ||
67 | + | ||
68 | + /** | ||
69 | + * Callback function for AmdaAction.getJobs. | ||
70 | + * @param {Result} res Server response of the PROCESSRUNNINGINFO request. | ||
71 | + * @param {Error} error Error, if any. | ||
72 | + * @returns {void} | ||
73 | + */ | ||
74 | + function (res, error) { | ||
75 | + // TODO Errors processing | ||
76 | + var message, strDate, type | ||
77 | + if (error.status && res.success && res.jobsFinished) { | ||
78 | + // Update from Server Jobs Running and Finished | ||
79 | + if (res.nFinished > 0 || res.nError) { | ||
80 | + Ext.Array.each(res.jobsFinished, function (job) { | ||
81 | + | ||
82 | + /** | ||
83 | + * Called asynchronously on each finished job | ||
84 | + * @param {Job} job The finished job. | ||
85 | + */ | ||
86 | + if (job.status !== 'old') { | ||
87 | + switch (job.jobType) { | ||
88 | + case 'condition': | ||
89 | + type = 'Data Mining ' | ||
90 | + break | ||
91 | + case 'request': | ||
92 | + type = 'Plot ' | ||
93 | + break | ||
94 | + case 'download': | ||
95 | + type = 'Download ' | ||
96 | + break | ||
97 | + case 'statistics': | ||
98 | + type = 'Statistics ' | ||
99 | + break | ||
100 | + default: | ||
101 | + type = 'unknown' | ||
102 | + } | ||
103 | + strDate = Ext.Date.format(new Date(), 'd-m-Y H:i:s: ') | ||
104 | + message = strDate + type + ' ' + job.name + ' completed' | ||
105 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id, true, | ||
106 | + function (mod) { | ||
107 | + mod.addLogMessage(message) | ||
108 | + }) | ||
109 | + } | ||
110 | + }) | ||
111 | + } | ||
112 | + | ||
113 | + if (amdaDesktop.JobsMgr.first && (res.nInProgress > 0 || res.nFinished > 0 || res.nError > 0)) { | ||
114 | + myDesktopApp.infoMsg('You have ' + res.nFinished + ' new finished jobs, ' + | ||
115 | + res.nInProgress + ' jobs in progress ' + | ||
116 | + 'and ' + res.nError + 'jobs in error') | ||
117 | + } | ||
118 | + | ||
119 | + amdaDesktop.JobsMgr.jobsInProgress = res.nInProgress | ||
120 | + amdaDesktop.JobsMgr.jobsFinished = res.nFinished | ||
121 | + amdaDesktop.JobsMgr.jobsError = res.nError | ||
122 | + | ||
123 | + if (res.nInProgress === 0 && amdaDesktop.JobsMgr.updateStatus) { | ||
124 | + Ext.TaskManager.stop(amdaDesktop.JobsMgr.updateStatus) | ||
125 | + amdaDesktop.JobsMgr.updateStatus = null | ||
126 | + } | ||
127 | + if (res.nInProgress > 0 && !amdaDesktop.JobsMgr.updateStatus) { | ||
128 | + amdaDesktop.JobsMgr.updateStatus = | ||
129 | + Ext.TaskManager.start({ | ||
130 | + interval: amdaDesktop.JobsMgr.interval, | ||
131 | + run: amdaDesktop.JobsMgr.getStatus | ||
132 | + }) | ||
133 | + } | ||
134 | + | ||
135 | + if ((res.nFinished > 0 || res.nError) && !amdaDesktop.JobsMgr.first && res.jobsFinished) { | ||
136 | + if (!amdaDesktop.JobsMgr.jobTree) { | ||
137 | + amdaDesktop.JobsMgr.jobTree = Ext.getCmp(amdaUI.ExplorerUI.JOB_TAB.TREE_ID) | ||
138 | } | 138 | } |
139 | - amdaDesktop.JobsMgr.first = false; | ||
140 | - }); | ||
141 | - } | 139 | + |
140 | + Ext.Array.each(res.jobsFinished, | ||
141 | + | ||
142 | + /** | ||
143 | + * Called asynchronously on each finished job. | ||
144 | + * @param {Job} job The finished job. | ||
145 | + * @return {void} | ||
146 | + */ | ||
147 | + function (job) { | ||
148 | + var bkgJob, jobRootNode, nodeToMove, resRootNode, root | ||
149 | + bkgJob = amdaModel.BkgJobNode | ||
150 | + root = amdaDesktop.JobsMgr.jobTree.getRootNode() | ||
151 | + switch (job.jobType) { | ||
152 | + case 'condition': | ||
153 | + resRootNode = root.findChild('id', bkgJob.RES_ROOT_NODE.CONDITION, true) | ||
154 | + jobRootNode = root.findChild('id', bkgJob.JOB_ROOT_NODE.CONDITION, true) | ||
155 | + break | ||
156 | + case 'request': | ||
157 | + resRootNode = root.findChild('id', bkgJob.RES_ROOT_NODE.PLOT, true) | ||
158 | + jobRootNode = root.findChild('id', bkgJob.JOB_ROOT_NODE.PLOT, true) | ||
159 | + break | ||
160 | + case 'download': | ||
161 | + resRootNode = root.findChild('id', bkgJob.RES_ROOT_NODE.DOWNLOAD, true) | ||
162 | + jobRootNode = root.findChild('id', bkgJob.JOB_ROOT_NODE.DOWNLOAD, true) | ||
163 | + break | ||
164 | + case 'statistics': | ||
165 | + resRootNode = root.findChild('id', bkgJob.RES_ROOT_NODE.STATISTICS, true) | ||
166 | + jobRootNode = root.findChild('id', bkgJob.JOB_ROOT_NODE.STATISTICS, true) | ||
167 | + break | ||
168 | + default: | ||
169 | + break | ||
170 | + } | ||
171 | + | ||
172 | + /* | ||
173 | + * TODO check job sub tree is always expanded - after the first job is launched - there | ||
174 | + * cannot be too many unfinished jobs on login so callback is not needed | ||
175 | + */ | ||
176 | + | ||
177 | + if (!resRootNode.parentNode.isExpanded()) { | ||
178 | + resRootNode.parentNode.expand(false) | ||
179 | + } | ||
180 | + if (!jobRootNode.parentNode.isExpanded()) { | ||
181 | + jobRootNode.parentNode.expand(false) | ||
182 | + } | ||
183 | + if (!jobRootNode.isExpanded()) { | ||
184 | + jobRootNode.expand(false) | ||
185 | + } | ||
186 | + | ||
187 | + // AKKA - use processid to find job | ||
188 | + nodeToMove = jobRootNode.findChild('id', job.id, false) | ||
189 | + nodeToMove.set('status', job.status) | ||
190 | + | ||
191 | + // TODO check if really job.status | ||
192 | + | ||
193 | + nodeToMove.set('iconCls', 'icon-' + job.status) | ||
194 | + jobRootNode.removeChild(nodeToMove) | ||
195 | + | ||
196 | + if (resRootNode.isExpanded()) { | ||
197 | + resRootNode.appendChild(nodeToMove) | ||
198 | + } else { | ||
199 | + resRootNode.expand(false, function () { | ||
200 | + var wantedId = nodeToMove.get('processId') | ||
201 | + if (!resRootNode.findChild('id', wantedId)) { | ||
202 | + resRootNode.appendChild(nodeToMove) | ||
203 | + } | ||
204 | + }) | ||
205 | + } | ||
206 | + }) | ||
207 | + } | ||
208 | + } | ||
209 | + amdaDesktop.JobsMgr.first = false | ||
210 | + }) | ||
211 | + } | ||
142 | }) | 212 | }) |