Commit 9d412dda0cbff0aca563714839fa7a0ee9eba349

Authored by elena
1 parent 7c187e26

catalog tmp and regular

js/app/models/CatalogNode.js
... ... @@ -75,10 +75,17 @@ Ext.define('amdaModel.CatalogNode', {
75 75  
76 76 var me = this;
77 77  
78   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
79   - // Opening parameter window
80   - module.createWindow();
81   - module.getUiContent().setObject(me.get('text'), me.get('id'));
  78 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
  79 +
  80 + // Catalog & TimeTable nodes normally use no objects in the tree
  81 + var obj = {'id' : me.get('id'), 'name' : me.get('text') };
  82 + object = Ext.create(me.get('objectDataModel'), obj);
  83 + me.set('object',object);
  84 +
  85 + module.setLinkedNode(me);
  86 +
  87 + module.createWindow();
  88 +
82 89 });
83 90 }
84 91 });
... ...
js/app/views/CatalogUI.js
... ... @@ -457,9 +457,16 @@ Ext.define('amdaUI.CatalogUI', {
457 457 var me = this;
458 458  
459 459 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
460   - // Opening parameter window
461   - module.createWindow();
462   - module.getUiContent().setObject(me.object.get('name'), me.object.get('id'));
  460 +
  461 + //temporary linked node - as Visu module is 'pseud' intercative - no 'save', no 'execute'
  462 + var temporaryNode = Ext.create('amdaModel.CatalogNode', {
  463 + leaf : true
  464 + });
  465 +
  466 + if (temporaryNode) temporaryNode.set('object',me.object);
  467 + module.setLinkedNode(temporaryNode);
  468 +
  469 + module.createWindow();
463 470 });
464 471 }
465 472 }
... ...
js/app/views/VisuUI.js
... ... @@ -4,30 +4,47 @@
4 4 * @class amdaUI.visuUI
5 5 * @extends Ext.container.Container
6 6 * @brief Visualization Module UI definition (View)
7   - * @author elena
  7 + * @author elena
8 8 */
9 9  
10 10 Ext.define('amdaUI.VisuUI', {
11 11 extend: 'Ext.container.Container',
12   - alias: 'widget.panelVisu',
13   -
  12 + alias: 'widget.panelVisu',
  13 +
14 14 constructor: function(config)
15 15 {
16 16 this.init(config);
17   - this.callParent(arguments);
  17 + this.callParent(arguments);
  18 + if (this.object) this.reformObject();
18 19 },
19 20  
20   - setObject : function (name,id)
21   - {
22   - // set object
23   - this.object.set('id',id);
24   - this.object.set('name',name);
25   -
  21 + setObject : function (obj) {
  22 +
  23 + this.object = obj;
  24 + this.reformObject();
  25 + },
  26 +
  27 + updateObject : function () {
  28 +
  29 + return true;
  30 + },
  31 +
  32 + reformObject : function ()
  33 + {
  34 + this.fromPlugin = this.object.get('fromPlugin');
  35 +
  36 + if (this.fromPlugin) {
  37 + this.object.set('id',this.object.get('folderId'));
  38 + this.object.set('objName',this.object.get('objName'));
  39 + }
  40 + else {
  41 + this.object.set('id',this.object.get('id'));
  42 + this.object.set('name',this.object.get('name'));
  43 + }
26 44 // load object into view
27 45 this.loadObject();
28 46 },
29   -
30   -
  47 +
31 48 reset : function() {
32 49  
33 50 this.parCombo.reset();
... ... @@ -40,8 +57,7 @@ Ext.define('amdaUI.VisuUI', {
40 57 */
41 58 loadObject : function()
42 59 {
43   -
44   -
  60 +
45 61 var me = this;
46 62  
47 63 var onAfterInit = function(result, e)
... ... @@ -55,10 +71,11 @@ Ext.define('amdaUI.VisuUI', {
55 71 return;
56 72 }
57 73  
58   -
  74 + me.object.set('name', result.name);
  75 + me.object.set('nbIntervals', result.totalCount);
59 76  
60 77 var fields = [], i = 0, index;
61   -
  78 +
62 79 Ext.Array.each(result.parameters, function(obj)
63 80 {
64 81  
... ... @@ -96,7 +113,8 @@ Ext.define('amdaUI.VisuUI', {
96 113 read : AmdaAction.readIntervalsForChart
97 114 },
98 115 // remplir automatiquement tt, sharedtt , catalog, shared catalog
99   - extraParams : {'typeTT' : 'catalog', 'id' : me.object.get('id')},
  116 + extraParams : {'typeTT' : 'catalog', 'id' : me.object.get('id'),
  117 + 'name' : me.object.get('objName'), 'fromPlugin' : me.fromPlugin},
100 118 reader:
101 119 {
102 120 type: 'json',
... ... @@ -108,8 +126,8 @@ Ext.define('amdaUI.VisuUI', {
108 126 scope : me,
109 127 load: function(store,records) {
110 128 //TODO enable plot button
111   - me.object.set('nbIntervals',me.chartStore.getTotalCount());
112   -
  129 + // me.object.set('nbIntervals',me.chartStore.getTotalCount());
  130 +
113 131 // load object into form
114 132 var formPanel = me.items.items[0].items.items[0];
115 133 formPanel.getForm().loadRecord(me.object);
... ... @@ -121,8 +139,10 @@ Ext.define('amdaUI.VisuUI', {
121 139  
122 140 }
123 141  
124   - if (this.object.get('id'))
125   - AmdaAction.initForChartFromTT(this.object.get('id'), 'catalog', onAfterInit);
  142 +
  143 +
  144 + AmdaAction.initForChart(this.object.get('id'), this.object.get('objName'), this.fromPlugin, 'catalog', onAfterInit);
  145 +
126 146  
127 147 },
128 148  
... ... @@ -209,7 +229,15 @@ Ext.define('amdaUI.VisuUI', {
209 229 // return storeItem.param3;
210 230 // }
211 231 }
212   - }]
  232 + }],
  233 + listeners: {
  234 + select: {
  235 + fn: function(me, selection) {
  236 + me.setZoom(selection);
  237 + me.mask.hide();
  238 + }
  239 + }
  240 + }
213 241 }
214 242  
215 243 var plotTypeList = Ext.create('Ext.data.Store', {
... ...
php/classes/AmdaAction.php
... ... @@ -954,12 +954,11 @@ class AmdaAction {
954 954 return $cacheMgr->initFromTT($id, $type);
955 955 }
956 956  
957   - public function initForChartFromTT($id, $type)
  957 + public function initForChart($id, $name, $isTmpObject, $type)
958 958 {
959 959 if ($type == 'catalog') $objMgr = new CatalogMgr();
960   -
961   -
962   - return $objMgr->initForChartFromTT($id, $type);
  960 +
  961 + return $objMgr->initForChart($id, $name, $isTmpObject, $type);
963 962 }
964 963  
965 964 public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false)
... ... @@ -992,7 +991,7 @@ class AmdaAction {
992 991 if ($o->typeTT == 'catalog') $objMgr = new CatalogMgr();
993 992  
994 993  
995   - return $objMgr->getIntervalsForChart($o->id, $o->typeTT);
  994 + return $objMgr->getIntervalsForChart($o->id, $o->name, $o->fromPlugin, $o->typeTT);
996 995 }
997 996  
998 997 public function saveTTCacheIntervalsInTT($o)
... ...
php/classes/CatalogMgr.php
... ... @@ -249,14 +249,14 @@ class CatalogMgr extends TimeTableMgr {
249 249  
250 250 }
251 251  
252   - public function initForChartFromTT($id, $typeTT)
  252 + public function initForChart($id, $name, $isTmpObject, $typeTT)
253 253 {
254   - $intervals_res = $this->loadIntervalsFromTT($id,$typeTT);
  254 + $intervals_res = $this->getCatalogParamDescription($id, $name, $isTmpObject, $typeTT);
255 255  
256 256 if (!$intervals_res['success'])
257 257 return $intervals_res;
258 258  
259   - $paramHeaders = [];
  259 + $paramHeaders = array();
260 260  
261 261 foreach ( $intervals_res['parameters'] as $param ) {
262 262  
... ... @@ -276,14 +276,19 @@ class CatalogMgr extends TimeTableMgr {
276 276 }
277 277 }
278 278  
279   - unset($intervals_res);
  279 + // unset($intervals_res);
280 280  
281   - return array('success' => true, 'parameters' => $paramHeaders);
  281 + return array('success' => true, 'parameters' => $paramHeaders,
  282 + 'totalCount' => $intervals_res['totalCount'], 'name' => $intervals_res['name']);
282 283 }
283 284  
284   - public function getIntervalsForChart($id, $type) {
  285 +
  286 + public function getIntervalsForChart($id, $name, $isTmpObject, $type) {
285 287  
286   - $intervals_res = $this->loadIntervalsFromTT($id,$type);
  288 + if ($isTmpObject)
  289 + $intervals_res = $this->getTmpObject($id, $name);
  290 + else
  291 + $intervals_res = $this->loadIntervalsFromTT($id,$type);
287 292  
288 293 if (!$intervals_res['success'])
289 294 return $intervals_res;
... ... @@ -318,5 +323,62 @@ class CatalogMgr extends TimeTableMgr {
318 323  
319 324 }
320 325  
  326 + public function getCatalogParamDescription($id, $name, $isTmpObject, $typeTT)
  327 + {
  328 + if ($typeTT == 'sharedcatalog') {
  329 + $pathid = SHAREDPATH.'TT/'.$id;
  330 + }
  331 + elseif (!$isTmpObject) {
  332 + $pathid = USERTTDIR.$id;
  333 + }
  334 + else {
  335 + $pathid = USERWORKINGDIR.$id.'/'.$name;
  336 + }
  337 +
  338 + //load intervals from Catalog id
  339 + if (!file_exists($pathid.'.xml'))
  340 + return array('success' => false, 'message' => "Cannot find Catalog file ".$id);
  341 +
  342 + if (!$this->objectDom->load($pathid.'.xml'))
  343 + return array('success' => false, 'message' => "Cannot load Catalog file ".$id);
  344 +
  345 +// if (!($objToGet = $this->objectDom->getElementById($id)))
  346 +// return array('success' => false, 'message' => NO_SUCH_ID." ".$id);
  347 +
  348 + $nameNodes = $this->objectDom->getElementsByTagName('name');
  349 +
  350 + if ($nameNodes->length > 0)
  351 + $nameReal = $nameNodes->item(0)->nodeValue;
  352 + else
  353 + $nameReal = $name;
  354 +
  355 + $xpath = new DOMXPath($this->objectDom);
  356 + $intervals = $xpath->query('//intervals');
  357 +
  358 +
  359 + // params header
  360 + $paramsNodes = $xpath->query('//parameters/parameter');
  361 + $paramsArray = array();
  362 +
  363 + if ($paramsNodes->length > 0)
  364 + {
  365 + foreach ($paramsNodes as $paramNode)
  366 + {
  367 + $oneParam = array();
  368 + foreach ($paramNode->attributes as $attr)
  369 + $oneParam[$attr->nodeName] = $attr->nodeValue;
  370 + $paramsArray[] = $oneParam;
  371 + }
  372 + }
  373 +
  374 + return array(
  375 + 'name' => $nameReal,
  376 + 'totalCount' => $intervals->length,
  377 + 'parameters' => $paramsArray,
  378 + 'success' => true
  379 + );
  380 +
  381 + }
  382 +
321 383 }
322 384 ?>
... ...
php/config.php
... ... @@ -278,8 +278,8 @@ $API = array(
278 278 'initTTCacheFromTT' => array(
279 279 'len'=>2
280 280 ),
281   - 'initForChartFromTT' => array(
282   - 'len'=>2
  281 + 'initForChart' => array(
  282 + 'len'=>4
283 283 ),
284 284 'initTTCacheFromTmpObject' => array(
285 285 'len'=>3
... ...