Blame view

js/app/controllers/ExplorerModule.js 10.8 KB
10dee819   Nathanael Jourdane   clean JobsMgr and...
1
/**
f792a3de   elena   catalog ihm
2
 * Project  : AMDA-NG
16035364   Benjamin Renard   First commit
3
 * Name     : ExplorerModule.js
10dee819   Nathanael Jourdane   clean JobsMgr and...
4
 * @class   amdaDesktop.ExplorerModule
16035364   Benjamin Renard   First commit
5
6
7
 * @extends amdaDesktop.AmdaModule
 * @brief   Explorer Module controller definition
 * @author  CDA
16035364   Benjamin Renard   First commit
8
9
 */

10dee819   Nathanael Jourdane   clean JobsMgr and...
10
'use strict'
16035364   Benjamin Renard   First commit
11

10dee819   Nathanael Jourdane   clean JobsMgr and...
12
/* global AmdaAction, myDesktopApp */
bb6e93d9   Benjamin Renard   Implement templat...
13

10dee819   Nathanael Jourdane   clean JobsMgr and...
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * @typedef {AmdaApp} myDesktopApp
 * @typedef {Object} AmdaAction
 * @typedef {Object} Ext
 */

Ext.define('amdaDesktop.ExplorerModule',
  {
    extend: 'amdaDesktop.AmdaModule',
    requires: [
      'amdaUI.ExplorerUI',
      'amdaUI.AliasUI',
      // Node Models
      'amdaModel.BkgJobNode',
      'amdaModel.DerivedParamNode',
      'amdaModel.LocalParamNode',
      'amdaModel.RemoteParamNode',
      'amdaModel.RemoteSimuParamNode',
      'amdaModel.AliasNode',
      'amdaModel.TimeTableNode',
      'amdaModel.CatalogNode',
      // StatisticsNode: singleton, not shown in the tree
      'amdaModel.StatisticsNode',
      'amdaModel.sharedTimeTableNode',
      'amdaModel.sharedCatalogNode',
      'amdaModel.MyDataParamNode',
      'amdaModel.MyDataNode',
      'amdaModel.PlotNode',
      // DownloadNode: singleton, not shown in the tree
      'amdaModel.DownloadNode',
      'amdaModel.SearchNode',
      // Object Models
      'amdaModel.Parameter',
      'amdaModel.Search',
      'amdaModel.Download',
      'amdaModel.TimeTable',
      'amdaModel.Catalog',
2e7079bb   Benjamin Renard   First implementat...
51
      'amdaModel.Statistic',
10dee819   Nathanael Jourdane   clean JobsMgr and...
52
53
      'amdaModel.FileObject',
      'amdaModel.FileParamObject',
b0f72ee0   Erdogan Furkan   #10557 For now
54
55
      'amdaModel.FilterInfo',
      'amdaModel.SpecialParamNode'
10dee819   Nathanael Jourdane   clean JobsMgr and...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    ],

    contentId: 'explorerUI',
    filter: null,
    filtersStore: null,
    paramInfoRegistry: {},

    constructor: function () {
      this.superclass.constructor.apply(this, arguments)
      if (!this.filtersStore) {
        this.filtersStore = Ext.create('Ext.data.Store', {model: 'amdaModel.FilterList'})
        this.filtersStore.load()
        // Note: amdaDesktop.ExplorerModule.filtersStore = this.filtersStore;
      }
    },

    createWindow: function () {
      var desktop, win

      desktop = this.app.getDesktop()
      win = desktop.getWindow(this.id)
      if (!win) {
        win = desktop.createWindow({
          id: this.id,
          title: this.title,
          width: 340,
          height: 500,
          iconCls: this.icon,
          animCollapse: false,
          border: false,
          closable: false,
          stateful: true,
          stateId: this.id,
          stateEvents: [
            'move',
            'show',
            'resize'
          ],
          constrain: true,
          layout:
            {
              type: 'border',
              align: 'stretch'
            },
          x: 5,
          y: 5,
          items: [
            {
              xtype: 'panelExplorer',
              id: this.contentId,
7acf223d   Nathanael Jourdane   fix ws scrollbar bug
106
              region: 'center'
b1a19dfa   Nathanael Jourdane   Sort amda tree logs
107
108
            },
            {
10dee819   Nathanael Jourdane   clean JobsMgr and...
109
              xtype: 'panel',
8429ea57   Nathanael Jourdane   Fix resize bug on...
110
              title: 'Log',
10dee819   Nathanael Jourdane   clean JobsMgr and...
111
              id: 'LogPanel',
25bf0977   Nathanael Jourdane   Add collapse button
112
              collapsible: true,
42863f42   Elena.Budnik   collapseMode: "he...
113
              collapseMode: 'header',
255bfc47   NathanaĆ«l Jourdane   log pannel: Hide ...
114
              iconCls: 'icon-align-left',
10dee819   Nathanael Jourdane   clean JobsMgr and...
115
              region: 'south',
10dee819   Nathanael Jourdane   clean JobsMgr and...
116
              split: true,
8429ea57   Nathanael Jourdane   Fix resize bug on...
117
              height: 150,
10dee819   Nathanael Jourdane   clean JobsMgr and...
118
119
              stateful: true,
              stateId: 'LogPanel',
8429ea57   Nathanael Jourdane   Fix resize bug on...
120
              tools: [{
9105f661   Nathanael Jourdane   Replace clear ico...
121
                type: 'trash',
8429ea57   Nathanael Jourdane   Fix resize bug on...
122
                tooltip: 'Clear logs',
10dee819   Nathanael Jourdane   clean JobsMgr and...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
                handler: function () {
                  var logPanel = win.items.get('LogPanel')
                  logPanel.removeAll()
                }
              }]
            }
          ]
        })
      }

      win.on('activate', function () {
        var manager
        myDesktopApp.getLoadedModule(this.id, true, function (module) {
          // On activation when there's a pinedModule 'null'
          if (module.pinedModule === null) {
            // Get the ZIndex manager
            manager = myDesktopApp.desktop.getDesktopZIndexManager()
            // Ordering to send back this window
            manager.sendToBack(win)
          }
        })
      }, this)

      win.on('show', function () {
        var desktopHeight
        // Set current filter
        this.setCrtFilter()
        // Resize the explorer in relation with the desktop size
        if (win.y + win.height > myDesktopApp.desktop.el.getHeight()) {
          desktopHeight = myDesktopApp.desktop.el.getHeight()
          win.setHeight(desktopHeight - win.y)
        }
      }, this)

      win.addCls('window-active')
      win.show()
      return win
    },

    pinedModule: null,

    /**
     * Getter of pinedModule
     * @return {amdaDesktop.InteractiveModule} The pined module
     */
    getPinedModule: function () {
      // Get the pined Module
      return this.pinedModule
    },

    /**
     * Setter of pinedModule
     * @param {amdaDesktop.InteractiveModule} amdaModule The pined module
     * @returns {void}
     */
    setPinedModule: function (amdaModule) {
      // Set the pined Module
      this.pinedModule = amdaModule
    },

    /**
     * Module Attachment Method
     * @param {amdaDesktop.InteractiveModule} amdaModule The module to attach
     * @returns {void}
     */
    pinMechanism: function (amdaModule) {
      var loadedAmdaModule, loadedPinedModule, oldPinedModule
      // If there is an old pined module
      if (this.getPinedModule() !== null) {
        // Get old pined module :
        oldPinedModule = this.getPinedModule()
        loadedPinedModule = myDesktopApp.getLoadedModule(oldPinedModule)
        // Call uncolor method on the old pined Module
        loadedPinedModule.uncolorHeaderModule()
      }
      // Set pined module
      this.setPinedModule(amdaModule)
      // Call color method on pined Module
      loadedAmdaModule = myDesktopApp.getLoadedModule(amdaModule)
      loadedAmdaModule.colorHeaderModule()
    },

    addLogMessage: function (message) {
      var height, msg, panel, win
      height = 40
      msg = Ext.create('Ext.Component', {
        height: height,
        html: message,
        style: {color: '#555555'}
      })
      win = myDesktopApp.getDesktop().getWindow(this.id)
      panel = win.items.get('LogPanel')
b1a19dfa   Nathanael Jourdane   Sort amda tree logs
215
      panel.insert(0, msg)
10dee819   Nathanael Jourdane   clean JobsMgr and...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
    },

    //
    setCrtFilter: function () {
      // Get current filter to apply
      AmdaAction.getCrtFilterResult(function (result, e) {
        var explorerUI, win
        if (!e.status) {
          Ext.Msg.show({
            title: 'Error System',
            msg: e.message,
            icon: Ext.MessageBox.ERROR,
            buttons: Ext.Msg.OK
          })
        } else if (result) {
          // Apply current filter
          this.filter = result
          // Add saved filter to Explorer List
          if (!this.filtersStore.getById(this.filter.id)) {
            this.filtersStore.add({
              id: this.filter.id,
              name: this.filter.name
            })
          }

          // Apply filter to the tree
          win = myDesktopApp.getDesktop().getWindow(this.id)
          if (win) {
            explorerUI = win.query('#' + this.contentId)
            explorerUI[0].updateFilter()
          }
        } else {
          Ext.Msg.show({
            title: 'Filter',
            msg: 'Cannot apply filter',
            modal: true,
            icon: Ext.Msg.ERROR,
            buttons: Ext.Msg.OK
          })
        }
      }, this)
    },

    resetFilter: function () {
      AmdaAction.resetFilter(function (result, e) {
        var filterUI, win
        if (!e.status) {
          Ext.Msg.show({
            title: 'Error System',
            msg: e.message,
            icon: Ext.MessageBox.ERROR,
            buttons: Ext.Msg.OK
          })
        } else if (result) {
          this.setCrtFilter()
          // Update filter win
          win = myDesktopApp.getDesktop().getWindow(myDesktopApp.dynamicModules.filters.id)
          if (win) {
            filterUI = win.query('panelFilters')
            filterUI[0].reloadFilter()
          }
        } else {
          Ext.Msg.show({
            title: 'Filter',
            msg: 'Cannot reset filter',
            modal: true,
            icon: Ext.Msg.ERROR,
            buttons: Ext.Msg.OK
          })
        }
      }, this)
    },
10dee819   Nathanael Jourdane   clean JobsMgr and...
288
    getParamInfo: function (paramId, onReady) {
bf776dc8   Benjamin Renard   working
289
      var me = this;
10dee819   Nathanael Jourdane   clean JobsMgr and...
290
291
292
293
294
295
      if (this.paramInfoRegistry[paramId]) {
        if (onReady) {
          onReady(this.paramInfoRegistry[paramId])
        }
        return this.paramInfoRegistry[paramId]
      }
22d8d756   Hacene SI HADJ MOHAND   resolu
296
297
298
     var pattParamWs = new RegExp("ws_");
     var pattParamWsd = new RegExp("wsd_");
     if(pattParamWs.test(paramId)){
0cefcae2   Benjamin Renard   il reste click droit
299
300
301
302
303
304
         var regExp = /\(([\d]+)\)/;
         var matches = regExp.exec(paramId);
         if(matches)
         {
             paramId=paramId.substr(0,paramId.length-3);
         }
bf776dc8   Benjamin Renard   working
305
306
307
308
309
310
311
312
313
    /* case of derived parameter */
       AmdaAction.getDerivedParamInfo({paramId: paramId}, function (result, e) {
        var paramInfo = null
        if (e.status === true) {
          // No available info for this parameter, do not display an error message if no success
          if (result.success) {
            // Store parameter info in registry
            me.paramInfoRegistry[paramId] = result;
            paramInfo = result
22d8d756   Hacene SI HADJ MOHAND   resolu
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
          }
        } else {
          Ext.Msg.show({
            title: 'Error System',
            msg: e.message,
            icon: Ext.MessageBox.ERROR,
            buttons: Ext.Msg.OK
          })
        }

        if (onReady) {
          onReady(paramInfo)
        }
      })
     }else if(pattParamWsd.test(paramId)){
         var regExp = /\(([\d]+)\)/;
         var matches = regExp.exec(paramId);
         if(matches)
         {
             paramId=paramId.substr(0,paramId.length-3);
         }
    /* case of derived parameter */
       AmdaAction.getMyDataParamInfo({paramId: paramId}, function (result, e) {
        var paramInfo = null
        if (e.status === true) {
          // No available info for this parameter, do not display an error message if no success
          if (result.success) {
            // Store parameter info in registry
            me.paramInfoRegistry[paramId] = result;
            paramInfo = result
bf776dc8   Benjamin Renard   working
344
345
346
347
348
349
350
351
352
          }
        } else {
          Ext.Msg.show({
            title: 'Error System',
            msg: e.message,
            icon: Ext.MessageBox.ERROR,
            buttons: Ext.Msg.OK
          })
        }
10dee819   Nathanael Jourdane   clean JobsMgr and...
353

bf776dc8   Benjamin Renard   working
354
355
356
357
358
        if (onReady) {
          onReady(paramInfo)
        }
      })
     }else{
10dee819   Nathanael Jourdane   clean JobsMgr and...
359
360
361
362
363
364
      AmdaAction.getParamInfo({paramId: paramId}, function (result, e) {
        var paramInfo = null
        if (e.status === true) {
          // No available info for this parameter, do not display an error message if no success
          if (result.success) {
            // Store parameter info in registry
0cefcae2   Benjamin Renard   il reste click droit
365
            me.paramInfoRegistry[paramId] = result;
10dee819   Nathanael Jourdane   clean JobsMgr and...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
            paramInfo = result
          }
        } else {
          Ext.Msg.show({
            title: 'Error System',
            msg: e.message,
            icon: Ext.MessageBox.ERROR,
            buttons: Ext.Msg.OK
          })
        }

        if (onReady) {
          onReady(paramInfo)
        }
      })
bf776dc8   Benjamin Renard   working
381
    }
10dee819   Nathanael Jourdane   clean JobsMgr and...
382
383
384
385
386

      return null
    }

  })