Commit 69cb7ecb021cf0600d335dccb941c216f52a2a4a
Exists in
master
and in
112 other branches
Merge branch 'master' of https://gitlab.irap.omp.eu/CDPP/AMDA_IHM
Showing
10 changed files
with
580 additions
and
228 deletions
Show diff stats
js/app/controllers/CatalogModule.js
... | ... | @@ -15,6 +15,7 @@ Ext.define('amdaDesktop.CatalogModule', { |
15 | 15 | ], |
16 | 16 | |
17 | 17 | contentId : 'catalogUI', |
18 | + isOperationOnShow : true, | |
18 | 19 | |
19 | 20 | /** |
20 | 21 | * @cfg {String} data models |
... | ... | @@ -30,6 +31,17 @@ Ext.define('amdaDesktop.CatalogModule', { |
30 | 31 | height: 700, |
31 | 32 | uiType : 'panelCatalog', |
32 | 33 | helpTitle : 'Help on Catalog Module', |
33 | - helpFile : 'catalogHelp' | |
34 | - | |
34 | + helpFile : 'catalogHelp', | |
35 | + | |
36 | + operationOnShow: function() { | |
37 | + var obj = this.linkedNode.get('object'); | |
38 | + if (obj && obj.get('id') == '' && !obj.get('fromPlugin')) { | |
39 | + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number:', function(btn, text){ | |
40 | + if (btn == 'ok'){ | |
41 | + AmdaAction.initTTCache(this.getUiContent().isCatalog, text, this.getUiContent().onAfterInit, this.getUiContent()); | |
42 | + } | |
43 | + }, this); | |
44 | + } | |
45 | + | |
46 | + } | |
35 | 47 | }); |
... | ... |
js/app/controllers/InteractiveModule.js
... | ... | @@ -5,13 +5,7 @@ |
5 | 5 | * @extends amdaDesktop.AmdaModule |
6 | 6 | * @brief Generic Interactive Module controller definition |
7 | 7 | * @author CDA |
8 | - * @version $Id: InteractiveModule.js 2109 2014-02-19 17:47:37Z elena $ | |
9 | - ******************************************************************************* | |
10 | - * FT Id : Date : Name - Description | |
11 | - ******************************************************************************* | |
12 | - * : :08/06/2011: CDA - Migration extjs4 | |
13 | - * : :09/06/2011: elena - generic Interactive modules methods: init(), createWindow(), | |
14 | - * createLinkedNode(), createObject() now are defined here | |
8 | + * @version $Id: InteractiveModule.js 2109 2014-02-19 17:47:37Z elena $ | |
15 | 9 | */ |
16 | 10 | |
17 | 11 | Ext.define('amdaDesktop.InteractiveModule', { |
... | ... | @@ -82,65 +76,70 @@ Ext.define('amdaDesktop.InteractiveModule', { |
82 | 76 | ], |
83 | 77 | items : [ |
84 | 78 | { |
85 | - xtype : this.uiType, | |
86 | - object : this.linkedNode.get('object'), | |
87 | - id : this.contentId | |
79 | + xtype : this.uiType, | |
80 | + object : this.linkedNode.get('object'), | |
81 | + id : this.contentId | |
88 | 82 | } |
89 | 83 | ] |
90 | 84 | }); |
91 | 85 | |
92 | 86 | this.closed = false; |
93 | 87 | win.on({ |
94 | - scope: this, | |
95 | - // on window activation event | |
96 | - activate: function(){ | |
97 | - // order to pin this Module with WsExplorer | |
98 | - this.pin(); | |
99 | - }, | |
100 | - // on window closing event | |
101 | - beforeclose: function (win, eOpts) { | |
102 | - | |
103 | - this.saveState(); | |
104 | - | |
105 | - var isDirty = this.getUiContent().fclose(); | |
106 | - | |
107 | - if (!this.closed && isDirty) { | |
108 | - Ext.Msg.confirm('Close', 'Current window has been modified.\nDo you want to close the window ?' , function (btn, text){ | |
109 | - if (btn == 'yes'){ | |
110 | - // mark this.closed as true before the call to close() as that will fire the beforeclose event again | |
111 | - this.closed = true; | |
112 | - win.close(); | |
113 | - } | |
88 | + scope: this, | |
89 | + // on window activation event | |
90 | + activate: function(){ | |
91 | + // order to pin this Module with WsExplorer | |
92 | + this.pin(); | |
93 | + }, | |
94 | + // on window closing event | |
95 | + beforeclose: function (win, eOpts) { | |
96 | + | |
97 | + this.saveState(); | |
98 | + | |
99 | + var isDirty = this.getUiContent().fclose(); | |
100 | + | |
101 | + if (!this.closed && isDirty) { | |
102 | + Ext.Msg.confirm('Close', 'Current window has been modified.\nDo you want to close the window ?' , function (btn, text){ | |
103 | + if (btn == 'yes'){ | |
104 | + // mark this.closed as true before the call to close() as that will fire the beforeclose event again | |
105 | + this.closed = true; | |
106 | + win.close(); | |
107 | + } | |
114 | 108 | },this); |
115 | - } else if (!isDirty) { | |
116 | - this.closed = true; | |
117 | - } | |
109 | + } else if (!isDirty) { | |
110 | + this.closed = true; | |
111 | + } | |
118 | 112 | |
119 | - if (this.closed) { | |
120 | - //remove object from linkedNode in order to minimize used memory | |
121 | - this.linkedNode.set('object',''); | |
122 | - // unlink Node | |
123 | - this.setLinkedNode(null); | |
124 | - // order to unpin this Module from WsExplorer | |
125 | - this.unpin(); | |
126 | - } | |
113 | + if (this.closed) { | |
114 | + //remove object from linkedNode in order to minimize used memory | |
115 | + this.linkedNode.set('object',''); | |
116 | + // unlink Node | |
117 | + this.setLinkedNode(null); | |
118 | + // order to unpin this Module from WsExplorer | |
119 | + this.unpin(); | |
120 | + } | |
127 | 121 | |
128 | - // Don't automatically close if the form is dirty, let the call to this.close() within the confirm box close the window. | |
129 | - return this.closed; | |
130 | - }, | |
131 | - minimize: function (win, eOpts) { | |
122 | + // Don't automatically close if the form is dirty, let the call to this.close() within the confirm box close the window. | |
123 | + return this.closed; | |
124 | + }, | |
125 | + minimize: function (win, eOpts) { | |
132 | 126 | // Save form |
133 | 127 | if (this.getUiContent().formPanel) |
134 | - this.getUiContent().formPanel.getForm().updateRecord(this.linkedNode.get('object')); | |
128 | + this.getUiContent().formPanel.getForm().updateRecord(this.linkedNode.get('object')); | |
135 | 129 | else |
136 | - this.getUiContent().items.getAt(0).getForm().updateRecord(this.linkedNode.get('object')); | |
130 | + this.getUiContent().items.getAt(0).getForm().updateRecord(this.linkedNode.get('object')); | |
137 | 131 | // Save grids |
138 | 132 | this.getUiContent().updateObject(); |
139 | - } | |
133 | + }, | |
134 | + show: function() { | |
135 | + // configuration of empty catalog | |
136 | + if (this.isOperationOnShow) | |
137 | + this.operationOnShow(); | |
138 | + } | |
140 | 139 | }); |
141 | - | |
142 | 140 | } else { |
143 | - this.getUiContent().setObject(this.linkedNode.get('object')); | |
141 | + // second arg 'true' is used in CatalogUI to mark if Grid Reconfiguration is needed | |
142 | + this.getUiContent().setObject(this.linkedNode.get('object'), true); | |
144 | 143 | } |
145 | 144 | win.show(); |
146 | 145 | }, |
... | ... |
js/app/models/BkgJobNode.js
... | ... | @@ -170,18 +170,20 @@ Ext.define('amdaModel.BkgJobNode', { |
170 | 170 | Ext.TaskManager.stop(amdaDesktop.JobsMgr.updateStatus); |
171 | 171 | amdaDesktop.JobsMgr.updateStatus = null; |
172 | 172 | |
173 | - switch (this.get('jobType')) { | |
174 | - case 'condition' : var type = 'Data Mining '; break; | |
175 | - case 'request' : var type = 'Plot '; break; | |
176 | - case 'download' : var type = 'Download '; break; | |
177 | - default: var type = 'unknown'; | |
178 | - } | |
173 | + switch (this.get('jobType')) { | |
174 | + case 'condition' : var type = 'Data Mining '; break; | |
175 | + case 'request' : var type = 'Plot '; break; | |
176 | + case 'download' : var type = 'Download '; break; | |
177 | + case 'statistics' : var type = 'Statistics '; break; | |
178 | + default: var type = 'unknown'; | |
179 | + } | |
180 | + | |
179 | 181 | var message = Ext.Date.format(new Date(), 'd-m-Y H:i:s: ') + ': '+ type + ' '+this.get('text') + ' killed'; |
180 | 182 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id, true, function (module) { |
181 | 183 | module.addLogMessage(message); |
182 | 184 | }); |
183 | 185 | } |
184 | -//delete fieldset from Result Module if it is open | |
186 | + //delete fieldset from Result Module if it is open | |
185 | 187 | else { |
186 | 188 | var me = this; |
187 | 189 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.result.id, true, function (module) { |
... | ... |
js/app/views/CatalogUI.js
... | ... | @@ -10,21 +10,28 @@ |
10 | 10 | Ext.define('amdaUI.CatalogUI', { |
11 | 11 | extend: 'Ext.container.Container', |
12 | 12 | alias: 'widget.panelCatalog', |
13 | - | |
13 | + | |
14 | + requires: [ | |
15 | + 'Ext.grid.plugin.BufferedRenderer' | |
16 | + ], | |
17 | + | |
14 | 18 | isCatalog : true, |
15 | 19 | |
20 | + | |
16 | 21 | constructor: function(config) |
17 | 22 | { |
18 | 23 | this.init(config); |
19 | - this.callParent(arguments);; | |
24 | + this.callParent(arguments); | |
25 | + this.toReconfigure = true; | |
20 | 26 | if (this.object) this.loadObject(); |
21 | 27 | }, |
22 | 28 | |
23 | - setObject : function (object) | |
24 | - { | |
25 | - // set object | |
26 | - this.object = object; | |
27 | - | |
29 | + setObject : function (object, toReconfigure) | |
30 | + { | |
31 | + if (toReconfigure) | |
32 | + this.toReconfigure = true; | |
33 | + // set object | |
34 | + this.object = object; | |
28 | 35 | // load object into view |
29 | 36 | this.loadObject(); |
30 | 37 | }, |
... | ... | @@ -77,44 +84,38 @@ Ext.define('amdaUI.CatalogUI', { |
77 | 84 | this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); |
78 | 85 | }, |
79 | 86 | |
80 | - /** | |
81 | - * load object catalog into this view | |
82 | - */ | |
83 | - loadObject : function() | |
84 | - { | |
85 | - // load object into form | |
86 | - this.formPanel.getForm().loadRecord(this.object); | |
87 | + | |
88 | + | |
89 | + onAfterInit: function(result, e) { | |
87 | 90 | |
88 | - this.status = null; | |
89 | - | |
90 | 91 | var me = this; |
91 | 92 | |
92 | - var onAfterInit = function(result, e) | |
93 | - { | |
94 | - if (!result || !result.success) | |
95 | - { | |
96 | - if (result.message) | |
97 | - myDesktopApp.errorMsg(result.message); | |
98 | - else | |
99 | - myDesktopApp.errorMsg('Unknown error during catalog cache initialisation'); | |
100 | - return; | |
101 | - } | |
102 | - | |
93 | + if (!result || !result.success) | |
94 | + { | |
95 | + if (result.message) | |
96 | + myDesktopApp.errorMsg(result.message); | |
97 | + else | |
98 | + myDesktopApp.errorMsg('Unknown error during catalog cache initialisation'); | |
99 | + return; | |
100 | + } | |
101 | + | |
102 | + if (me.toReconfigure) | |
103 | + { | |
103 | 104 | var fields = [], columns = [], i = 3, width, index; |
104 | 105 | |
105 | 106 | var fieldsConfig = [{ name : 'start' },{ name : 'stop' },{ name: 'cacheId', type : 'int'}, |
106 | 107 | { name: 'isNew', type : 'boolean', defaultValue: false }, |
107 | - { name: 'isModified', type : 'boolean', defaultValue: false} | |
108 | + { name: 'isModified', type : 'boolean', defaultValue: false} | |
108 | 109 | ]; |
109 | 110 | |
110 | 111 | for (var j = 0; j < 5; j++) fields[j] = Ext.create('Ext.data.Field', fieldsConfig[j]); |
111 | 112 | |
112 | - columns[0] = Ext.create('Ext.grid.column.RowNumberer'); | |
113 | + columns[0] = Ext.create('Ext.grid.column.RowNumberer'); | |
113 | 114 | |
114 | 115 | columns[1] = Ext.create('Ext.grid.column.Column', { text: 'Start Time', sortable : false, dataIndex: 'start', |
115 | - width : 120, menuDisabled: true }); | |
116 | + width : 120, menuDisabled: true, editor : { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}}); | |
116 | 117 | columns[2] = Ext.create('Ext.grid.column.Column', { text: 'Stop Time', sortable : false, dataIndex: 'stop', |
117 | - width : 120, menuDisabled: true }); | |
118 | + width : 120, menuDisabled: true, editor : { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}}); | |
118 | 119 | |
119 | 120 | Ext.Array.each(result.parameters, function(obj) |
120 | 121 | { |
... | ... | @@ -122,12 +123,12 @@ Ext.define('amdaUI.CatalogUI', { |
122 | 123 | fields[i+2] = Ext.create('Ext.data.Field',{ name : index }); |
123 | 124 | width = 50. * parseInt(obj.size); |
124 | 125 | columns[i] = Ext.create('Ext.grid.column.Column', { text: obj.name, sortable : false, dataIndex: index, |
125 | - width : width, menuDisabled: true }); | |
126 | + width : width, menuDisabled: true, editor: 'textfield' }); | |
126 | 127 | i++; |
127 | 128 | }); |
128 | - | |
129 | - | |
130 | - | |
129 | + | |
130 | + | |
131 | + | |
131 | 132 | var store = Ext.create('Ext.data.Store', { |
132 | 133 | fields: fields, |
133 | 134 | autoDestroy: false, |
... | ... | @@ -161,11 +162,11 @@ Ext.define('amdaUI.CatalogUI', { |
161 | 162 | // this.fireEvent("refresh"); |
162 | 163 | } |
163 | 164 | } |
164 | - }); | |
165 | - | |
165 | + }); | |
166 | + | |
166 | 167 | me.TTGrid.reconfigure(store, columns); |
167 | - | |
168 | - me.TTGrid.getSelectionModel().deselectAll(); | |
168 | + } | |
169 | + me.TTGrid.getSelectionModel().deselectAll(); | |
169 | 170 | // |
170 | 171 | // // clear filters |
171 | 172 | // me.TTGrid.getStore().clearFilter(true); |
... | ... | @@ -173,41 +174,50 @@ Ext.define('amdaUI.CatalogUI', { |
173 | 174 | // //clear sort |
174 | 175 | // me.TTGrid.getStore().sorters.clear(); |
175 | 176 | // //me.TTGrid.getStore().sorters = new Ext.util.MixedCollection(); |
176 | - // | |
177 | + | |
177 | 178 | //set cache token to the Catalog object |
178 | - me.object.set('cacheToken', result.token); | |
179 | - me.setParamInfo(result.parameters); | |
180 | - | |
181 | - me.TTGrid.getStore().load(); | |
179 | + me.object.set('cacheToken', result.token); | |
180 | + me.setParamInfo(result.parameters); | |
181 | + | |
182 | + me.TTGrid.getStore().load(); | |
182 | 183 | |
183 | - me.status = result.status; | |
184 | - }; | |
185 | - | |
184 | + me.status = result.status; | |
185 | + }, | |
186 | + | |
187 | + /** | |
188 | + * load object catalog into this view | |
189 | + */ | |
190 | + loadObject : function() | |
191 | + { | |
192 | + // load object into form | |
193 | + this.formPanel.getForm().loadRecord(this.object); | |
194 | + | |
195 | + this.status = null; | |
196 | + | |
186 | 197 | if (this.object.get('fromPlugin')) |
187 | 198 | { |
188 | 199 | if (this.object.get('objFormat') && this.object.get('objFormat') != '') |
189 | 200 | { |
190 | 201 | //From uploaded file |
191 | - //AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), onAfterInit); | |
202 | + //AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.onAfterInit, this); | |
192 | 203 | } |
193 | 204 | else |
194 | 205 | { |
195 | - //From tmp object (ie Search result) | |
196 | - AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, onAfterInit); | |
206 | + //From tmp object (ie Statistics result) | |
207 | + AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this); | |
197 | 208 | } |
198 | 209 | } |
199 | 210 | else |
200 | 211 | { |
201 | - var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType; | |
212 | + // var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType; | |
202 | 213 | if (this.object.get('id') == '') |
203 | - { | |
204 | - //Init empty cache | |
205 | - AmdaAction.initTTCache(this.isCatalog, onAfterInit); | |
214 | + { | |
215 | + | |
206 | 216 | } |
207 | 217 | else |
208 | 218 | { |
209 | 219 | //From existing TT file |
210 | - AmdaAction.initTTCacheFromTT(this.object.get('id'), 'catalog', onAfterInit); | |
220 | + AmdaAction.initTTCacheFromTT(this.object.get('id'), 'catalog', this.onAfterInit, this); | |
211 | 221 | } |
212 | 222 | } |
213 | 223 | }, |
... | ... | @@ -221,8 +231,9 @@ Ext.define('amdaUI.CatalogUI', { |
221 | 231 | */ |
222 | 232 | saveProcess : function(toRename) |
223 | 233 | { |
224 | - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); | |
225 | - | |
234 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); | |
235 | + // store / columns are the same - not needed to reconfigure grid | |
236 | + this.toReconfigure = false; | |
226 | 237 | // if the name has been modified this is a creation |
227 | 238 | if (this.fclose()) |
228 | 239 | { |
... | ... | @@ -243,15 +254,28 @@ Ext.define('amdaUI.CatalogUI', { |
243 | 254 | this.object = obj; |
244 | 255 | if (toRename) module.linkedNode.toRename = true; |
245 | 256 | } |
246 | - module.linkedNode.create({callback : function() {module.linkedNode.update();}, scope : this}); | |
257 | + module.linkedNode.create(/*{callback : function() {module.linkedNode.update();}, scope : this}*/); | |
247 | 258 | } else { |
248 | - //update | |
259 | + //update | |
249 | 260 | module.linkedNode.update(); |
250 | 261 | } |
262 | + | |
251 | 263 | } |
252 | 264 | }, |
253 | 265 | |
254 | 266 | /** |
267 | + * overwrite metod called by Save button | |
268 | + */ | |
269 | + overwriteProcess : function(btn) | |
270 | + { | |
271 | + if (btn == 'cancel') return; | |
272 | + | |
273 | + this.fieldName.clearInvalid(); | |
274 | + this.saveProcess(true); | |
275 | + | |
276 | + }, | |
277 | + | |
278 | + /** | |
255 | 279 | * Check if changes were made before closing window |
256 | 280 | * @return true if changes |
257 | 281 | */ |
... | ... | @@ -263,8 +287,7 @@ Ext.define('amdaUI.CatalogUI', { |
263 | 287 | var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); |
264 | 288 | return isDirty; |
265 | 289 | }, |
266 | - | |
267 | - | |
290 | + | |
268 | 291 | init : function (config) |
269 | 292 | { |
270 | 293 | this.object = config.object; |
... | ... | @@ -282,39 +305,97 @@ Ext.define('amdaUI.CatalogUI', { |
282 | 305 | return this.validFlag; |
283 | 306 | } |
284 | 307 | }); |
285 | - | |
308 | + | |
309 | + var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{ | |
310 | +// clicksToEdit: 2, | |
311 | + onEditComplete : function(ed, value, startValue) { | |
312 | + var me = this, | |
313 | + activeColumn = me.getActiveColumn(), | |
314 | + context = me.context, | |
315 | + record; | |
316 | + | |
317 | + if (activeColumn) { | |
318 | + record = context.record; | |
319 | + | |
320 | + me.setActiveEditor(null); | |
321 | + me.setActiveColumn(null); | |
322 | + me.setActiveRecord(null); | |
323 | + | |
324 | + context.value = value; | |
325 | + if (!me.validateEdit()) { | |
326 | + me.editing = false; | |
327 | + return; | |
328 | + } | |
329 | + | |
330 | + // Only update the record if the new value is different than the | |
331 | + // startValue. When the view refreshes its el will gain focus | |
332 | + if (!record.isEqual(value, startValue)) { | |
333 | + var obj = {}; | |
334 | + | |
335 | + obj['cacheId'] = record.get('cacheId'); | |
336 | + obj['isCatalog'] = true; | |
337 | + obj[activeColumn.dataIndex] = value; | |
338 | + | |
339 | + //Interval is modified on the server side | |
340 | + me.editing = true; | |
341 | + | |
342 | + AmdaAction.modifyTTCacheInterval(obj, function (result, e) { | |
343 | + | |
344 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); | |
345 | + if (module) | |
346 | + module.getUiContent().status = result.status; | |
347 | + context.grid.getSelectionModel().deselectAll(); | |
348 | + context.store.reload({ | |
349 | + callback : function(records, options, success) { | |
350 | + context.view.bufferedRenderer.scrollTo(context.rowIdx, true, function() { | |
351 | + me.fireEvent('edit', me, context); | |
352 | + me.editing = false; | |
353 | + }, me); | |
354 | + } | |
355 | + }); | |
356 | + }, this); | |
357 | + } | |
358 | + else | |
359 | + me.editing = false; | |
360 | + } | |
361 | + } | |
362 | + }); | |
286 | 363 | |
287 | 364 | this.TTGrid = Ext.create('Ext.grid.Panel', { |
288 | 365 | height: 530, |
289 | 366 | columns: [ ], |
290 | 367 | frame: true, |
368 | + columnLines: true, | |
369 | + // selType: 'cellmodel', | |
370 | + plugins: [ cellEditing, { ptype : 'bufferedrenderer'} ], | |
291 | 371 | dockedItems: [{ |
292 | 372 | xtype: 'toolbar', |
293 | 373 | items: [{ |
294 | 374 | iconCls: 'icon-add', |
295 | 375 | scope: this, |
296 | 376 | handler: function(){ |
297 | - alert('NOT IMPLEMENTED YET'); | |
298 | - // cellEditing.cancelEdit(); | |
299 | - // | |
300 | - // var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; | |
301 | - // var row = 0; | |
302 | - // if (selection) | |
303 | - // row = store.indexOf(selection) + 1; | |
304 | - // this.TTGrid.getSelectionModel().deselectAll(); | |
305 | - // | |
306 | - // var me = this; | |
307 | - // AmdaAction.addTTCacheInterval({'index' : row}, function (result, e) { | |
308 | - // this.status = result.status; | |
309 | - // this.TTGrid.getStore().reload({ | |
310 | - // callback : function(records, options, success) { | |
311 | - // me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { | |
312 | - // me.TTGrid.getView().select(row); | |
313 | - // cellEditing.startEditByPosition({row: row, column: 1}); | |
314 | - // }, me); | |
315 | - // } | |
316 | - // }); | |
317 | - // }, this); | |
377 | + | |
378 | + cellEditing.cancelEdit(); | |
379 | + var store = this.TTGrid.getStore(); | |
380 | + | |
381 | + var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; | |
382 | + var row = 0; | |
383 | + if (selection) | |
384 | + row = store.indexOf(selection) + 1; | |
385 | + this.TTGrid.getSelectionModel().deselectAll(); | |
386 | + | |
387 | + var me = this; | |
388 | + AmdaAction.addTTCacheInterval({'index' : row, 'isCatalog' : true}, function (result, e) { | |
389 | + this.status = result.status; | |
390 | + this.TTGrid.getStore().reload({ | |
391 | + callback : function(records, options, success) { | |
392 | + me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { | |
393 | + me.TTGrid.getView().select(row); | |
394 | + cellEditing.startEditByPosition({row: row, column: 1}); | |
395 | + }, me); | |
396 | + } | |
397 | + }); | |
398 | + }, this); | |
318 | 399 | } |
319 | 400 | },{ |
320 | 401 | iconCls: 'icon-delete', |
... | ... | @@ -325,8 +406,7 @@ Ext.define('amdaUI.CatalogUI', { |
325 | 406 | var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; |
326 | 407 | if (selection) |
327 | 408 | { |
328 | - var rowId = selection.get('cacheId'); | |
329 | - console.log(selection); | |
409 | + var rowId = selection.get('cacheId'); | |
330 | 410 | this.TTGrid.getSelectionModel().deselectAll(); |
331 | 411 | AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) { |
332 | 412 | this.status = result.status; |
... | ... | @@ -458,7 +538,7 @@ Ext.define('amdaUI.CatalogUI', { |
458 | 538 | |
459 | 539 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { |
460 | 540 | |
461 | - //temporary linked node - as Visu module is 'pseud' intercative - no 'save', no 'execute' | |
541 | + //temporary linked node - as Visu module is 'pseudo' interactive - no 'save', no 'execute' | |
462 | 542 | var temporaryNode = Ext.create('amdaModel.CatalogNode', { |
463 | 543 | leaf : true |
464 | 544 | }); |
... | ... |
js/app/views/ExplorerUI.js
... | ... | @@ -588,16 +588,17 @@ Ext.define('amdaUI.ExplorerUI', { |
588 | 588 | { |
589 | 589 | case 'myData' : |
590 | 590 | case 'myDataParam' : |
591 | - case 'derivedParam' : | |
592 | - case 'timeTable' : | |
593 | - case 'sharedtimeTable' : | |
594 | - case 'request' : | |
595 | - case 'condition' : | |
591 | + case 'derivedParam' : | |
592 | + case 'timeTable' : | |
593 | + case 'sharedtimeTable' : | |
594 | + case 'catalog' : | |
595 | + case 'request' : | |
596 | + case 'condition' : | |
596 | 597 | record.editLeaf(); |
597 | 598 | break; |
598 | - case 'localParam' : | |
599 | + case 'localParam' : | |
599 | 600 | case 'remoteParam': |
600 | - case 'remoteSimuParam': | |
601 | + case 'remoteSimuParam': | |
601 | 602 | record.createAlias(record); |
602 | 603 | break; |
603 | 604 | case 'bkgWorks' : |
... | ... |
js/app/views/VisuUI.js
... | ... | @@ -42,13 +42,20 @@ Ext.define('amdaUI.VisuUI', { |
42 | 42 | this.object.set('name',this.object.get('name')); |
43 | 43 | } |
44 | 44 | // load object into view |
45 | - this.loadObject(); | |
45 | + if (this.object.get('id') != '') | |
46 | + this.loadObject(); | |
46 | 47 | }, |
47 | 48 | |
48 | 49 | reset : function() { |
49 | - | |
50 | - this.parCombo.reset(); | |
51 | - this.parCombo1.reset(); | |
50 | + | |
51 | + //reset all fieldsets except the first one (name, intervals) | |
52 | + var form = this.items.items[0].items.items[0]; | |
53 | + for (var i = 1; i < 4; i++) { | |
54 | + var fieldset = form.items.items[i]; | |
55 | + Ext.each(fieldset.query('field'), function(field) { | |
56 | + field.reset(); | |
57 | + }); | |
58 | + } | |
52 | 59 | this.resetChart(); |
53 | 60 | |
54 | 61 | }, |
... | ... | @@ -139,8 +146,7 @@ Ext.define('amdaUI.VisuUI', { |
139 | 146 | } |
140 | 147 | |
141 | 148 | AmdaAction.initForChart(this.object.get('id'), this.object.get('objName'), this.fromPlugin, 'catalog', onAfterInit); |
142 | - | |
143 | - | |
149 | + | |
144 | 150 | }, |
145 | 151 | |
146 | 152 | |
... | ... | @@ -156,12 +162,27 @@ Ext.define('amdaUI.VisuUI', { |
156 | 162 | |
157 | 163 | resetChart : function () { |
158 | 164 | |
165 | + var emptyAxesConfig = [{ | |
166 | + type: 'Numeric', | |
167 | + position: 'bottom', | |
168 | + fields: [], | |
169 | + title: 'x axe', | |
170 | + grid : true | |
171 | + }, { | |
172 | + type: 'Numeric', | |
173 | + position: 'left', | |
174 | + fields: [], | |
175 | + title: 'y axe', | |
176 | + grid: true | |
177 | + }]; | |
178 | + | |
159 | 179 | this.chartConfig.series[0].xField = ''; |
160 | 180 | this.chartConfig.series[0].yField = ''; |
161 | - | |
162 | - this.chartConfig.axes[0].title = 'x axe'; | |
163 | - this.chartConfig.axes[1].title = 'y axe'; | |
164 | 181 | |
182 | + this.chartConfig.theme = 'Blue'; | |
183 | + | |
184 | + this.chartConfig.axes = emptyAxesConfig; | |
185 | + | |
165 | 186 | var chart = Ext.create('Ext.chart.Chart', this.chartConfig); |
166 | 187 | this.replaceChart(chart); |
167 | 188 | |
... | ... | @@ -169,12 +190,45 @@ Ext.define('amdaUI.VisuUI', { |
169 | 190 | |
170 | 191 | plotChart : function () { |
171 | 192 | |
172 | - this.chartConfig.store=this.chartStore; | |
173 | - var chart = Ext.create('Ext.chart.Chart', this.chartConfig); | |
193 | + this.chartConfig.store = this.chartStore; | |
194 | + | |
195 | + var xTitle = this.items.items[0].items.items[0].items.items[1].items.items[2].getValue(); | |
196 | + var yTitle = this.items.items[0].items.items[0].items.items[2].items.items[2].getValue(); | |
197 | + | |
198 | + if (xTitle) this.chartConfig.axes[0].title = xTitle; | |
199 | + if (xTitle) this.chartConfig.axes[1].title = yTitle; | |
200 | + | |
201 | + // axis modifs | |
202 | + if (this.comboXrange.getValue() == 'manual') { | |
203 | + var minX = this.comboXrange.next().next().getValue(); | |
204 | + var maxX = this.comboXrange.next().next().next().next().getValue(); | |
205 | + this.chartConfig.axes[0].minimum = minX; | |
206 | + this.chartConfig.axes[0].maximum = maxX ; | |
207 | + } else { | |
208 | + // unset min/max in config | |
209 | + delete this.chartConfig.axes[0].minimum; | |
210 | + delete this.chartConfig.axes[0].maximum; | |
211 | + } | |
212 | + if (this.comboYrange.getValue() == 'manual') { | |
213 | + var minX = this.comboYrange.next().next().getValue(); | |
214 | + var maxX = this.comboYrange.next().next().next().next().getValue(); | |
215 | + // if (minX && maxX) { | |
216 | + this.chartConfig.axes[1].minimum = minX; | |
217 | + this.chartConfig.axes[1].maximum = maxX; | |
218 | + // } | |
219 | + } else { | |
220 | + // unset min/max in config | |
221 | + delete this.chartConfig.axes[1].minimum; | |
222 | + delete this.chartConfig.axes[1].maximum; | |
223 | + } | |
224 | + | |
225 | + var chart = Ext.create('Ext.chart.Chart', this.chartConfig); | |
226 | + | |
174 | 227 | this.replaceChart(chart); |
175 | 228 | |
176 | 229 | }, |
177 | 230 | |
231 | + | |
178 | 232 | replaceChart: function(chart) { |
179 | 233 | |
180 | 234 | var chartPanel = this.items.items[0].items.items[1]; |
... | ... | @@ -191,15 +245,21 @@ Ext.define('amdaUI.VisuUI', { |
191 | 245 | autoload : false |
192 | 246 | }); |
193 | 247 | |
248 | + var rangeStore = Ext.create('Ext.data.Store', { | |
249 | + fields : [], | |
250 | + autoload : false | |
251 | + }); | |
252 | + | |
253 | + | |
194 | 254 | this.chartConfig = { |
195 | 255 | width: 500, |
196 | 256 | height: 500, |
197 | 257 | animate: false, |
198 | 258 | mask: false, |
199 | 259 | shadow: false, |
200 | - // theme:'Category2', | |
260 | + theme:'Blue', | |
201 | 261 | store: store, |
202 | - axes: [{ | |
262 | + axes: [{ | |
203 | 263 | type: 'Numeric', |
204 | 264 | position: 'bottom', |
205 | 265 | fields: [], |
... | ... | @@ -214,38 +274,34 @@ Ext.define('amdaUI.VisuUI', { |
214 | 274 | }], |
215 | 275 | series: [{ |
216 | 276 | type: 'scatter', |
217 | - showMarkers: false, | |
277 | + showMarkers: true, | |
278 | + highlight: true, | |
218 | 279 | // markerConfig: { |
219 | -// radius: 5, | |
280 | + // radius: 5, | |
220 | 281 | // size: 5 |
221 | 282 | // }, |
222 | 283 | // // axes: ['left', 'bottom'], |
223 | 284 | xField: '', |
224 | 285 | yField: '', |
225 | - label: { | |
226 | -// display: 'under', | |
227 | -// renderer: function(value, label, storeItem, item, i, display, animate, index) { | |
228 | -// return storeItem.param3; | |
229 | -// } | |
230 | - } | |
231 | - }], | |
232 | - listeners: { | |
233 | -// select: { | |
234 | -// fn: function(me, selection) { | |
235 | -// me.setZoom(selection); | |
236 | -// me.mask.hide(); | |
237 | -// } | |
238 | -// } | |
239 | - } | |
286 | +// label: { | |
287 | +// // display: 'under', | |
288 | +// // renderer: function(value, label, storeItem, item, i, display, animate, index) { | |
289 | +// // return storeItem.param3; | |
290 | +// // } | |
291 | +// }, | |
292 | + tips: { | |
293 | +// trackMouse: true, | |
294 | + width: 10, | |
295 | + height: 20, | |
296 | + hideDelay: 100, //200 ms | |
297 | + mouseOffset: [0,0], //[15,18] | |
298 | + renderer: function(storeItem, item) { | |
299 | + this.setTitle(storeItem.index + 1); | |
300 | + } | |
301 | + } | |
302 | + } | |
303 | + ] | |
240 | 304 | } |
241 | - | |
242 | - var plotTypeList = Ext.create('Ext.data.Store', { | |
243 | - fields: ['type'], | |
244 | - data: [ | |
245 | - { 'type': 'line' }, | |
246 | - { 'type': 'scatter' } | |
247 | - ] | |
248 | - }); | |
249 | 305 | |
250 | 306 | this.parList = Ext.create('Ext.data.Store', { |
251 | 307 | fields : [ 'text', 'id'] |
... | ... | @@ -284,7 +340,7 @@ Ext.define('amdaUI.VisuUI', { |
284 | 340 | listeners : { |
285 | 341 | scope : this, |
286 | 342 | change : function(combo, newValue, oldValue) { |
287 | - if (newValue) { | |
343 | + if (newValue) { | |
288 | 344 | this.chartConfig.axes[1].fields = [newValue]; |
289 | 345 | var rec = combo.findRecordByValue(newValue); |
290 | 346 | this.chartConfig.axes[1].title = rec.get('text'); |
... | ... | @@ -297,19 +353,60 @@ Ext.define('amdaUI.VisuUI', { |
297 | 353 | var plotTypeCombo = Ext.create('Ext.form.ComboBox', { |
298 | 354 | emptyText: 'select plot type', |
299 | 355 | editable: false, |
300 | - store: plotTypeList, | |
356 | + store: ['scatter', 'line'], | |
301 | 357 | queryMode: 'local', |
302 | - displayField: 'type', | |
303 | 358 | valueField: 'type', |
359 | + value: 'scatter', | |
304 | 360 | listeners : { |
305 | 361 | scope : this, |
306 | 362 | change : function(combo, newValue, oldValue) { |
307 | 363 | this.chartConfig.series[0].type = newValue; |
308 | 364 | } |
309 | 365 | } |
310 | - }); | |
311 | - | |
312 | - | |
366 | + }); | |
367 | + | |
368 | + var plotThemeCombo = Ext.create('Ext.form.ComboBox', { | |
369 | + emptyText: 'select theme', | |
370 | + editable: false, | |
371 | + store: ['Base','Green','Sky','Red','Purple','Blue','Yellow'], | |
372 | + //'Category1','Category2','Category3','Category4','Category5','Category6'], | |
373 | + queryMode: 'local', | |
374 | + valueField: 'type', | |
375 | + value: 'Blue', | |
376 | + listeners : { | |
377 | + scope : this, | |
378 | + change : function(combo, newValue, oldValue) { | |
379 | + this.chartConfig.theme = newValue; | |
380 | + } | |
381 | + } | |
382 | + }); | |
383 | + | |
384 | + var comboRangeConfig = { | |
385 | + // fieldLabel:'X Range', | |
386 | + name:'scaling', | |
387 | + valueField: 'scaling', | |
388 | + queryMode:'local', | |
389 | + store:['auto','manual'], | |
390 | + forceSelection:true, | |
391 | + value: 'auto', | |
392 | + width: 80, | |
393 | + listeners : { | |
394 | + scope : this, | |
395 | + change : function(combo, newValue, oldValue) { | |
396 | + var minValue = combo.next().next(); | |
397 | + var maxValue = minValue.next().next(); | |
398 | + var disabled = newValue == "auto"; | |
399 | + minValue.reset(); | |
400 | + maxValue.reset(); | |
401 | + minValue.setDisabled(disabled); | |
402 | + maxValue.setDisabled(disabled); | |
403 | + } | |
404 | + } | |
405 | + }; | |
406 | + | |
407 | + this.comboXrange = Ext.create('Ext.form.ComboBox', comboRangeConfig); | |
408 | + this.comboYrange = Ext.create('Ext.form.ComboBox', comboRangeConfig); | |
409 | + | |
313 | 410 | var formPanel = Ext.create('Ext.form.Panel', { |
314 | 411 | region : 'center', |
315 | 412 | layout: 'hbox', |
... | ... | @@ -345,17 +442,31 @@ Ext.define('amdaUI.VisuUI', { |
345 | 442 | xtype : 'fieldcontainer', |
346 | 443 | layout: 'hbox', |
347 | 444 | items: [{ |
348 | - xtype: 'textfield', | |
349 | - flex: 1 | |
350 | - }, { | |
351 | - xtype: 'splitter' | |
352 | - }, { | |
353 | - xtype: 'textfield', | |
354 | - flex: 1 | |
445 | + xtype:'fieldset', | |
446 | + title: 'X Range', | |
447 | + border: false, | |
448 | + layout: 'hbox', | |
449 | + items: [ | |
450 | + this.comboXrange, | |
451 | + { | |
452 | + xtype: 'splitter' | |
453 | + }, { | |
454 | + xtype: 'numberfield', | |
455 | + hideTrigger: true, | |
456 | + width: 50, | |
457 | + disabled: true | |
458 | + },{ | |
459 | + xtype: 'splitter' | |
460 | + },{ | |
461 | + xtype: 'numberfield', | |
462 | + hideTrigger: true, | |
463 | + width: 50, | |
464 | + disabled: true | |
465 | + }] | |
355 | 466 | }] |
356 | 467 | }, |
357 | - { xtype : 'checkbox' }, | |
358 | - { xtype : 'checkbox' } | |
468 | +// { xtype : 'checkbox', boxLabel: 'Logarithmic'}, | |
469 | + { xtype: 'textfield', fieldLabel: 'X title', name: 'xtitle'} | |
359 | 470 | ] |
360 | 471 | }, |
361 | 472 | { |
... | ... | @@ -367,25 +478,47 @@ Ext.define('amdaUI.VisuUI', { |
367 | 478 | xtype : 'fieldcontainer', |
368 | 479 | layout: 'hbox', |
369 | 480 | items: [{ |
370 | - xtype: 'textfield', | |
371 | - flex: 1 | |
372 | - }, { | |
373 | - xtype: 'splitter' | |
374 | - }, { | |
375 | - xtype: 'textfield', | |
376 | - flex: 1 | |
377 | - } | |
378 | - ] | |
481 | + xtype:'fieldset', | |
482 | + title: 'Y Range', | |
483 | + border: false, | |
484 | + layout: 'hbox', | |
485 | + items: [ | |
486 | + this.comboYrange, | |
487 | + { | |
488 | + xtype: 'splitter' | |
489 | + }, { | |
490 | + xtype: 'numberfield', | |
491 | + hideTrigger: true, | |
492 | + width: 50, | |
493 | + disabled: true | |
494 | + },{ | |
495 | + xtype: 'splitter' | |
496 | + },{ | |
497 | + xtype: 'numberfield', | |
498 | + hideTrigger: true, | |
499 | + width: 50, | |
500 | + disabled: true | |
501 | + }] | |
502 | + }] | |
379 | 503 | }, |
380 | - { xtype : 'checkbox' }, | |
381 | - { xtype : 'checkbox' } | |
504 | +// { xtype : 'checkbox', boxLabel: 'Logarithmic', | |
505 | +// listeners: { | |
506 | +// scope: this, | |
507 | +// change : function( check, newValue, oldValue) { | |
508 | +// | |
509 | +// } | |
510 | +// } | |
511 | +// }, | |
512 | + { xtype: 'textfield', fieldLabel: 'Y title', name: 'ytitle'} | |
513 | + | |
382 | 514 | ] |
383 | 515 | }, |
384 | 516 | { |
385 | 517 | xtype : 'fieldset', |
386 | 518 | title : 'Plotting Options', |
387 | 519 | items : [ |
388 | - plotTypeCombo | |
520 | + plotTypeCombo, | |
521 | + plotThemeCombo | |
389 | 522 | ] |
390 | 523 | } |
391 | 524 | ], |
... | ... |
php/classes/AmdaAction.php
... | ... | @@ -678,7 +678,7 @@ class AmdaAction { |
678 | 678 | $objectMgr = new TimeTableMgr(); |
679 | 679 | break; |
680 | 680 | case 'catalog' : |
681 | - $objectMgr = new Catalog(); | |
681 | + $objectMgr = new CatalogMgr(); | |
682 | 682 | break; |
683 | 683 | case 'condition' : |
684 | 684 | case 'request' : |
... | ... | @@ -937,12 +937,12 @@ class AmdaAction { |
937 | 937 | return $result; |
938 | 938 | } |
939 | 939 | |
940 | - public function initTTCache($isCatalog = false) | |
940 | + public function initTTCache($isCatalog = false, $nparams) | |
941 | 941 | { |
942 | 942 | if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); |
943 | 943 | else $cacheMgr = new CatalogCacheMgr(); |
944 | 944 | |
945 | - return $cacheMgr->initTTCache(); | |
945 | + return $cacheMgr->initTTCache($nparams); | |
946 | 946 | } |
947 | 947 | |
948 | 948 | |
... | ... | @@ -1002,7 +1002,9 @@ class AmdaAction { |
1002 | 1002 | |
1003 | 1003 | public function addTTCacheInterval($o) |
1004 | 1004 | { |
1005 | - $cacheMgr = new TimeTableCacheMgr(); | |
1005 | + if ($o->isCatalog) $cacheMgr = new CatalogCacheMgr(); | |
1006 | + else $cacheMgr = new TimeTableCacheMgr(); | |
1007 | + | |
1006 | 1008 | return $cacheMgr->addInterval($o->index, $o->start, $o->stop); |
1007 | 1009 | } |
1008 | 1010 | |
... | ... | @@ -1010,13 +1012,20 @@ class AmdaAction { |
1010 | 1012 | { |
1011 | 1013 | if ($isCatalog) $cacheMgr = new CatalogCacheMgr(); |
1012 | 1014 | else $cacheMgr = new TimeTableCacheMgr(); |
1013 | - | |
1015 | + | |
1014 | 1016 | return $cacheMgr->removeIntervalFromId($id); |
1015 | 1017 | } |
1016 | 1018 | |
1017 | 1019 | public function modifyTTCacheInterval($o) |
1018 | 1020 | { |
1019 | - $cacheMgr = new TimeTableCacheMgr(); | |
1021 | + if ($o->isCatalog) { | |
1022 | + | |
1023 | + $cacheMgr = new CatalogCacheMgr(); | |
1024 | + return $cacheMgr->modifyIntervalFromId($o); | |
1025 | + | |
1026 | + } | |
1027 | + else $cacheMgr = new TimeTableCacheMgr(); | |
1028 | + | |
1020 | 1029 | return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->start, $o->stop); |
1021 | 1030 | } |
1022 | 1031 | |
... | ... |
php/classes/CatalogCacheMgr.php
... | ... | @@ -226,12 +226,42 @@ class CatalogCacheObject extends TimeTableCacheObject |
226 | 226 | |
227 | 227 | return true; |
228 | 228 | } |
229 | + | |
230 | + public function modifyIntervalFromId($obj) { | |
231 | + | |
232 | + foreach ($this->intervals as $interval) | |
233 | + { | |
234 | + if ($interval->getId() == $obj->cacheId) | |
235 | + { | |
236 | + foreach((array)$obj as $key => $val) { | |
237 | + | |
238 | + if ($key == 'start') | |
239 | + $interval->setStartFromISO($val); | |
240 | + else if ($key == 'stop') | |
241 | + $interval->setStopFromISO($val); | |
242 | + else { | |
243 | + if (strpos($key, 'param') === false) | |
244 | + continue; | |
245 | + $params = $interval->getParams(); | |
246 | + $paramIndex = (int)substr($key,5); | |
247 | + $params[$paramIndex-2] = $val; | |
248 | + $interval->setParams($params); | |
249 | + } | |
250 | + } | |
251 | + $interval->setIsModified(true); | |
252 | + $this->isModified = true; | |
253 | + return true; | |
254 | + } | |
255 | + } | |
256 | + | |
257 | + return false; | |
258 | + } | |
229 | 259 | } |
230 | 260 | |
231 | 261 | class CatalogCacheMgr extends TimeTableCacheMgr |
232 | 262 | { |
233 | 263 | |
234 | - protected static $cache_file = "cacheCat"; | |
264 | + protected static $cache_file = "cacheCat"; | |
235 | 265 | |
236 | 266 | protected $ttMgr = null; |
237 | 267 | protected $cache = null; |
... | ... | @@ -298,7 +328,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr |
298 | 328 | } |
299 | 329 | |
300 | 330 | $paramHeaders = $intervals_res['parameters']; |
301 | - | |
331 | + | |
302 | 332 | $this->cache->setParamsNumber(count($paramHeaders)); |
303 | 333 | $this->cache->setParamsSizes($paramHeaders); |
304 | 334 | unset($intervals_res); |
... | ... | @@ -350,6 +380,61 @@ class CatalogCacheMgr extends TimeTableCacheMgr |
350 | 380 | $this->cache->reset(); |
351 | 381 | |
352 | 382 | return $this->ttMgr->saveIntervals($id, $intervals, $action); |
353 | - } | |
383 | + } | |
384 | + | |
385 | + public function addInterval($index, $start, $stop, $params) { | |
386 | + if (!$this->loadFromFile()) | |
387 | + return array('success' => false, 'message' => 'Cannot load cache file'); | |
388 | + | |
389 | + if (!isset($index)) | |
390 | + $index = 0; | |
391 | + | |
392 | + if (!isset($start)) | |
393 | + $start = date('Y-m-d\TH:i:s'); | |
394 | + | |
395 | + if (!isset($stop)) | |
396 | + $stop = date('Y-m-d\TH:i:s'); | |
397 | + | |
398 | + if (!isset($params)) | |
399 | + $params = []; | |
400 | + | |
401 | + $this->cache->addInterval($start, $stop, $params, true, $index); | |
402 | + | |
403 | + //$this->cache->updateIndexes(); | |
404 | + | |
405 | + $this->saveToFile(); | |
406 | + | |
407 | + return array('success' => true, 'index' => $index, 'status' => $this->cache->getStatus()); | |
408 | + } | |
409 | + | |
410 | + public function modifyIntervalFromId($obj) { | |
411 | + if (!$this->loadFromFile()) | |
412 | + return array('success' => false, 'message' => 'Cannot load cache file'); | |
413 | + | |
414 | + $this->cache->modifyIntervalFromId($obj); | |
415 | + | |
416 | + $this->saveToFile(); | |
417 | + | |
418 | + return array('success' => true, 'status' => $this->cache->getStatus()); | |
419 | + } | |
420 | + | |
421 | + public function initTTCache($nparams) { | |
422 | + //Create new cache | |
423 | + $this->cache = new CatalogCacheObject(); | |
424 | + $this->cache->setParamsNumber((int)$nparams); | |
425 | + $paramHeaders = array(); | |
426 | + | |
427 | + for ($i = 0; $i < (int)$nparams; $i++) { | |
428 | + $paramHeaders[$i]['id'] = 'id_'.(string)($i+1); | |
429 | + $paramHeaders[$i]['name'] = 'param_'.(string)($i+1); | |
430 | + $paramHeaders[$i]['size'] = 1; | |
431 | + $paramHeaders[$i]['type'] = 'Float'; | |
432 | + | |
433 | + } | |
434 | + $this->cache->setParamsSizes($paramHeaders); | |
435 | + //Save cache file | |
436 | + return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), | |
437 | + 'status' => $this->cache->getStatus(), 'parameters' => $paramHeaders); | |
438 | + } | |
354 | 439 | } |
355 | 440 | ?> |
356 | 441 | \ No newline at end of file |
... | ... |
php/classes/CatalogMgr.php
... | ... | @@ -379,6 +379,37 @@ class CatalogMgr extends TimeTableMgr { |
379 | 379 | ); |
380 | 380 | |
381 | 381 | } |
382 | - | |
382 | + | |
383 | +// public function modifyObject($p) { | |
384 | +// $folder = $this->getObjectFolder($p->id); | |
385 | +// | |
386 | +// //Copy TT in a tempory file | |
387 | +// $ttFilePath = USERTTDIR.$p->id.'.xml'; | |
388 | +// $tmpFileExist = FALSE; | |
389 | +// if (file_exists($ttFilePath)) | |
390 | +// $tmpFileExist = copy($ttFilePath,$ttFilePath.".tmp"); | |
391 | +// | |
392 | +// //Delete TT | |
393 | +// $this->deleteObject($p); | |
394 | +// | |
395 | +// //Save modifications | |
396 | +// try { | |
397 | +// $result = $this->createObject($p, $folder); | |
398 | +// if ($result['error']) | |
399 | +// throw new Exception($result['error']); | |
400 | +// if ($tmpFileExist) | |
401 | +// unlink($ttFilePath.".tmp"); | |
402 | +// return array('id' => $p->id, 'info' => $result['nbIntervals'].' intervals' ); | |
403 | +// } | |
404 | +// catch (Exception $e) { | |
405 | +// //Restore TT file | |
406 | +// if ($tmpFileExist) | |
407 | +// { | |
408 | +// copy($ttFilePath.".tmp", $ttFilePath); | |
409 | +// unlink($ttFilePath.".tmp"); | |
410 | +// } | |
411 | +// return array ('error' => $e->getMessage()); | |
412 | +// } | |
413 | +// } | |
383 | 414 | } |
384 | 415 | ?> |
... | ... |