Commit c9db9962b0bb6b2ee173e793958673406a5f4b9f
1 parent
04084c4e
Exists in
master
and in
95 other branches
WIP
Showing
5 changed files
with
106 additions
and
127 deletions
Show diff stats
js/app/models/PlotObjects/MultiplotRequestObject.js
@@ -18,7 +18,8 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { | @@ -18,7 +18,8 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { | ||
18 | idProperty: 'id', | 18 | idProperty: 'id', |
19 | 19 | ||
20 | requires: [ | 20 | requires: [ |
21 | - 'amdaModel.PlotNode' | 21 | + 'amdaModel.PlotNode', |
22 | + 'amdaPlotObj.PlotRequestObject' | ||
22 | ], | 23 | ], |
23 | 24 | ||
24 | hasMany: { | 25 | hasMany: { |
@@ -44,11 +45,25 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { | @@ -44,11 +45,25 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { | ||
44 | }, | 45 | }, |
45 | 46 | ||
46 | createNewPlot: function() { | 47 | createNewPlot: function() { |
48 | + var plotObject = Ext.create('amdaPlotObj.PlotRequestObject'); | ||
49 | + return this.createNewPlotFromObject(plotObject); | ||
50 | + }, | ||
51 | + | ||
52 | + duplicatePlot: function(plotNode) { | ||
53 | + var clonedObject = plotNode.get('object').copy(); | ||
54 | + console.log(plotNode); | ||
55 | + this.plots().each(function(node) { | ||
56 | + console.log(node); | ||
57 | + }); | ||
58 | + //this.plots().store.removeAt(index); | ||
59 | + //store.insert(index, newValue); | ||
60 | + }, | ||
61 | + | ||
62 | + createNewPlotFromObject: function(plotObject) { | ||
47 | var plotNode = Ext.create('amdaModel.PlotNode', { | 63 | var plotNode = Ext.create('amdaModel.PlotNode', { |
48 | leaf : true, | 64 | leaf : true, |
49 | contextNode : this | 65 | contextNode : this |
50 | }); | 66 | }); |
51 | - var plotObject = Ext.create(plotNode.get('objectDataModel')); | ||
52 | plotNode.set('object',plotObject); | 67 | plotNode.set('object',plotObject); |
53 | this.plots().add(plotNode); | 68 | this.plots().add(plotNode); |
54 | return this.plots().getAt(this.plots().count()-1); | 69 | return this.plots().getAt(this.plots().count()-1); |
js/app/models/PlotObjects/PlotRequestObject.js
@@ -233,6 +233,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', { | @@ -233,6 +233,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', { | ||
233 | var requestValues = new Object(); | 233 | var requestValues = new Object(); |
234 | 234 | ||
235 | requestValues['nodeType'] = 'request'; | 235 | requestValues['nodeType'] = 'request'; |
236 | + requestValues['leaf'] = true; | ||
236 | 237 | ||
237 | requestValues['id'] = this.get('id'); | 238 | requestValues['id'] = this.get('id'); |
238 | 239 |
js/app/views/PlotComponents/PlotTabContent.js
@@ -49,11 +49,82 @@ Ext.define('amdaPlotComp.PlotTabContent', { | @@ -49,11 +49,82 @@ Ext.define('amdaPlotComp.PlotTabContent', { | ||
49 | this.plotNode.execute(); | 49 | this.plotNode.execute(); |
50 | }, | 50 | }, |
51 | 51 | ||
52 | - init : function(config) { | 52 | + savePlot : function() { |
53 | + var object = this.plotNode.get('object'); | ||
54 | + if (!object) | ||
55 | + return; | ||
56 | + | ||
57 | + if ((object.get('id') != '') && (this.plotNode.get('text') == object.get('name'))) { | ||
58 | + //update existing request | ||
59 | + this.plotNode.update(); | ||
60 | + return; | ||
61 | + } | ||
62 | + | ||
63 | + //save new request | ||
53 | var me = this; | 64 | var me = this; |
54 | - me.plotNode = config.plotNode; | 65 | + this.plotNode.isValidName(object.get('name'), function (res) { |
66 | + if (!res) { | ||
67 | + myDesktopApp.errorMsg('Error during object validation'); | ||
68 | + return; | ||
69 | + } | ||
70 | + if (!res.valid) { | ||
71 | + if (res.error) { | ||
72 | + if (res.error.search('subtree') != -1) { | ||
73 | + Ext.Msg.show( { title : 'Warning', | ||
74 | + msg: res.error + '<br/>Do you want to overwrite it?', | ||
75 | + width: 300, | ||
76 | + buttons: Ext.Msg.OKCANCEL, | ||
77 | + icon: Ext.Msg.WARNING, | ||
78 | + fn : me.overwritePlot, | ||
79 | + scope : me | ||
80 | + }); | ||
81 | + } | ||
82 | + else { | ||
83 | + myDesktopApp.errorMsg(res.error); | ||
84 | + } | ||
85 | + } | ||
86 | + else { | ||
87 | + myDesktopApp.errorMsg('Invalid object name'); | ||
88 | + } | ||
89 | + return; | ||
90 | + } | ||
91 | + me.saveProcess(false); | ||
92 | + }); | ||
93 | + }, | ||
94 | + | ||
95 | + overwritePlot : function(btn) { | ||
96 | + if (btn == 'cancel') return; | ||
97 | + this.saveProcess(true); | ||
98 | + }, | ||
99 | + | ||
100 | + saveProcess : function(toRename) { | ||
101 | + if (toRename) { | ||
102 | + this.plotNode.update(); | ||
103 | + } | ||
104 | + else { | ||
105 | + if (this.plotNode.get('object').get('id') != '') { | ||
106 | + //Duplicate request | ||
107 | + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | ||
108 | + if (!plotModule) | ||
109 | + return; | ||
110 | + this.plotNode = plotModule.linkedNode.get('object').duplicatePlot(this.plotNode); | ||
111 | + this.updateUI(); | ||
112 | + } | ||
113 | + this.plotNode.create(); | ||
114 | + } | ||
115 | + }, | ||
116 | + | ||
117 | + updateUI : function() { | ||
118 | + this.plotOutput.setObject(this.plotNode.get('object')); | ||
119 | + this.timeSelector.intervalSel.setInterval(this.plotNode.get('object').get('startDate'), this.plotNode.get('object').get('stopDate')); | ||
120 | + this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables')); | ||
121 | + this.treePlot.buildTree(this.plotNode.get('object')); | ||
122 | + }, | ||
123 | + | ||
124 | + init : function(config) { | ||
125 | + this.plotNode = config.plotNode; | ||
55 | 126 | ||
56 | - this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + me.plotNode.id, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} ); | 127 | + this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + this.plotNode.id, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} ); |
57 | this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 11}); | 128 | this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 11}); |
58 | this.treePlot = new amdaPlotComp.PlotTree({flex: 11, plotElementPanel: this.plotElement}); | 129 | this.treePlot = new amdaPlotComp.PlotTree({flex: 11, plotElementPanel: this.plotElement}); |
59 | this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 6, collapseDirection : 'bottom', collapsible : true }); | 130 | this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 6, collapseDirection : 'bottom', collapsible : true }); |
@@ -110,10 +181,7 @@ Ext.define('amdaPlotComp.PlotTabContent', { | @@ -110,10 +181,7 @@ Ext.define('amdaPlotComp.PlotTabContent', { | ||
110 | ], | 181 | ], |
111 | listeners: { | 182 | listeners: { |
112 | afterrender: function(comp, eOpts) { | 183 | afterrender: function(comp, eOpts) { |
113 | - this.plotOutput.setObject(this.plotNode.get('object')); | ||
114 | - this.timeSelector.intervalSel.setInterval(this.plotNode.get('object').get('startDate'), this.plotNode.get('object').get('stopDate')); | ||
115 | - this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables')); | ||
116 | - this.treePlot.buildTree(this.plotNode.get('object')); | 184 | + this.updateUI(); |
117 | }, | 185 | }, |
118 | scope: this | 186 | scope: this |
119 | } | 187 | } |
js/app/views/PlotUI.js
@@ -37,39 +37,6 @@ Ext.define('amdaUI.PlotUI', { | @@ -37,39 +37,6 @@ Ext.define('amdaUI.PlotUI', { | ||
37 | this.plotTabs.setMultiplotObject(this.object); | 37 | this.plotTabs.setMultiplotObject(this.object); |
38 | }, | 38 | }, |
39 | 39 | ||
40 | - /** | ||
41 | - * overwrite metod called by Save button | ||
42 | - */ | ||
43 | - overwriteProcess : function(btn) | ||
44 | - { | ||
45 | - if (btn == 'cancel') return; | ||
46 | - this.saveProcess(true); | ||
47 | - }, | ||
48 | - | ||
49 | - | ||
50 | - /** | ||
51 | - * save method called by Save button to launch the save process | ||
52 | - */ | ||
53 | - saveProcess : function(toRename) { | ||
54 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | ||
55 | - if (!plotModule) | ||
56 | - return; | ||
57 | - | ||
58 | - if (toRename) { | ||
59 | - plotModule.linkedNode.set('object',this.object); | ||
60 | - plotModule.linkedNode.update(); | ||
61 | - } | ||
62 | - else { | ||
63 | - //Save | ||
64 | - if (this.object.get('id') != '') { | ||
65 | - //Duplicate request | ||
66 | - plotModule.createLinkedNode(); | ||
67 | - plotModule.linkedNode.set('object',this.object); | ||
68 | - } | ||
69 | - plotModule.linkedNode.create(); | ||
70 | - } | ||
71 | - }, | ||
72 | - | ||
73 | resetProcess : function(){ | 40 | resetProcess : function(){ |
74 | var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | 41 | var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); |
75 | plotModule.createLinkedNode(); | 42 | plotModule.createLinkedNode(); |
@@ -209,66 +176,11 @@ Ext.define('amdaUI.PlotUI', { | @@ -209,66 +176,11 @@ Ext.define('amdaUI.PlotUI', { | ||
209 | }); | 176 | }); |
210 | }, | 177 | }, |
211 | 178 | ||
212 | - savePlotRequest : function(allTabs) { | ||
213 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | ||
214 | - if (!plotModule) | ||
215 | - return; | ||
216 | - this.updateObject(); | ||
217 | - this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); | ||
218 | - var me = this; | ||
219 | - | ||
220 | - if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) { | ||
221 | - //update existing request | ||
222 | - if (!allTabs) { | ||
223 | - this.keepOnlySelectedTabInObject(true, function() { | ||
224 | - plotModule.linkedNode.update(); | ||
225 | - }); | ||
226 | - } | ||
227 | - else { | ||
228 | - plotModule.linkedNode.update(); | ||
229 | - } | ||
230 | - return; | ||
231 | - } | ||
232 | - | ||
233 | - //save new request | ||
234 | - var me = this; | ||
235 | - plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { | ||
236 | - if (!res) { | ||
237 | - myDesktopApp.errorMsg('Error during object validation'); | ||
238 | - return; | ||
239 | - } | ||
240 | - if (!res.valid) { | ||
241 | - if (res.error) { | ||
242 | - if (res.error.search('subtree') != -1) { | ||
243 | - Ext.Msg.show( { title : 'Warning', | ||
244 | - msg: res.error + '<br/>Do you want to overwrite it?', | ||
245 | - width: 300, | ||
246 | - buttons: Ext.Msg.OKCANCEL, | ||
247 | - icon: Ext.Msg.WARNING, | ||
248 | - fn : me.overwriteProcess, | ||
249 | - scope : me | ||
250 | - }); | ||
251 | - } | ||
252 | - else { | ||
253 | - myDesktopApp.errorMsg(res.error); | ||
254 | - } | ||
255 | - } | ||
256 | - else { | ||
257 | - myDesktopApp.errorMsg('Invalid object name'); | ||
258 | - } | ||
259 | - return; | ||
260 | - } | ||
261 | - if (!allTabs) { | ||
262 | - me.keepOnlySelectedTabInObject((me.object.get('id') == ''), function() { | ||
263 | - me.saveProcess(false); | ||
264 | - me.setObject(me.object); | ||
265 | - }); | ||
266 | - } | ||
267 | - else { | ||
268 | - me.saveProcess(false); | ||
269 | - } | ||
270 | - }); | ||
271 | - }, | 179 | + savePlotRequest : function() { |
180 | + var plotTab = this.plotTabs.getCurrentPlotTabContent(); | ||
181 | + if (plotTab) | ||
182 | + plotTab.savePlot(); | ||
183 | + }, | ||
272 | 184 | ||
273 | init : function(config) { | 185 | init : function(config) { |
274 | this.plotTabs = new amdaPlotComp.PlotTabPanel({plotUI : this}); | 186 | this.plotTabs = new amdaPlotComp.PlotTabPanel({plotUI : this}); |
@@ -306,22 +218,11 @@ Ext.define('amdaUI.PlotUI', { | @@ -306,22 +218,11 @@ Ext.define('amdaUI.PlotUI', { | ||
306 | this.resetProcess(); | 218 | this.resetProcess(); |
307 | } | 219 | } |
308 | },'->', '-', { | 220 | },'->', '-', { |
309 | - xtype: 'splitbutton', | ||
310 | - text: 'Save All Tabs', | ||
311 | - menu: { | ||
312 | - items: [ | ||
313 | - { | ||
314 | - text: 'Save Current Tab', | ||
315 | - scope: this, | ||
316 | - handler: function() { | ||
317 | - this.savePlotRequest(false); | ||
318 | - } | ||
319 | - }, | ||
320 | - ] | ||
321 | - }, | 221 | + xtype: 'button', |
222 | + text: 'Save', | ||
322 | scope: this, | 223 | scope: this, |
323 | handler: function(button) { | 224 | handler: function(button) { |
324 | - this.savePlotRequest(true); | 225 | + this.savePlotRequest(); |
325 | } | 226 | } |
326 | } | 227 | } |
327 | ] | 228 | ] |
php/classes/RequestMgr.php
@@ -258,17 +258,12 @@ class RequestMgr extends AmdaObjectMgr | @@ -258,17 +258,12 @@ class RequestMgr extends AmdaObjectMgr | ||
258 | switch ($obj->nodeType) | 258 | switch ($obj->nodeType) |
259 | { | 259 | { |
260 | case 'request' : | 260 | case 'request' : |
261 | - foreach ($obj->tabs as $tab) | ||
262 | - { | ||
263 | - $timesrc = $tab->{'multi-plot-linked'} ? $obj->timesrc : $tab->timesrc; | ||
264 | - | 261 | + |
265 | //TODO check TT as well (first start and last stop ?) | 262 | //TODO check TT as well (first start and last stop ?) |
266 | - if ($timesrc != 'Interval') continue; | ||
267 | - // select active tab | ||
268 | - if (!$tab->{'multi-plot-linked'} && $tab->id != $obj->{'last-plotted-tab'}) continue; | 263 | + if ($obj->timesrc != 'Interval') continue; |
269 | 264 | ||
270 | $argsTab = array(); | 265 | $argsTab = array(); |
271 | - foreach ($tab->panels as $panel) | 266 | + foreach ($obj->panels as $panel) |
272 | { | 267 | { |
273 | $params = array(); | 268 | $params = array(); |
274 | foreach ($panel->params as $param) | 269 | foreach ($panel->params as $param) |
@@ -283,12 +278,11 @@ class RequestMgr extends AmdaObjectMgr | @@ -283,12 +278,11 @@ class RequestMgr extends AmdaObjectMgr | ||
283 | if (count($params) > 0) | 278 | if (count($params) > 0) |
284 | { | 279 | { |
285 | $argsTab['param'] = array_unique($params); | 280 | $argsTab['param'] = array_unique($params); |
286 | - $argsTab['startTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->startDate; | ||
287 | - $argsTab['stopTime'] = $tab->{'multi-plot-linked'} ? $obj->stopDate : $tab->stopDate; | 281 | + $argsTab['startTime'] = $obj->startDate; |
282 | + $argsTab['stopTime'] = $$obj->stopDate; | ||
288 | } | 283 | } |
289 | } | 284 | } |
290 | if (count($argsTab) > 0) $args[] = $argsTab; | 285 | if (count($argsTab) > 0) $args[] = $argsTab; |
291 | - } | ||
292 | break; | 286 | break; |
293 | case 'condition' : | 287 | case 'condition' : |
294 | //$argsTab = array(); | 288 | //$argsTab = array(); |