diff --git a/js/app/models/CatalogNode.js b/js/app/models/CatalogNode.js index be9c32a..ce2e5b2 100644 --- a/js/app/models/CatalogNode.js +++ b/js/app/models/CatalogNode.js @@ -75,10 +75,17 @@ Ext.define('amdaModel.CatalogNode', { var me = this; - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { - // Opening parameter window - module.createWindow(); - module.getUiContent().setObject(me.get('text'), me.get('id')); + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { + + // Catalog & TimeTable nodes normally use no objects in the tree + var obj = {'id' : me.get('id'), 'name' : me.get('text') }; + object = Ext.create(me.get('objectDataModel'), obj); + me.set('object',object); + + module.setLinkedNode(me); + + module.createWindow(); + }); } }); diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js index de624c9..1f3da5c 100644 --- a/js/app/views/CatalogUI.js +++ b/js/app/views/CatalogUI.js @@ -457,9 +457,16 @@ Ext.define('amdaUI.CatalogUI', { var me = this; myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { - // Opening parameter window - module.createWindow(); - module.getUiContent().setObject(me.object.get('name'), me.object.get('id')); + + //temporary linked node - as Visu module is 'pseud' intercative - no 'save', no 'execute' + var temporaryNode = Ext.create('amdaModel.CatalogNode', { + leaf : true + }); + + if (temporaryNode) temporaryNode.set('object',me.object); + module.setLinkedNode(temporaryNode); + + module.createWindow(); }); } } diff --git a/js/app/views/VisuUI.js b/js/app/views/VisuUI.js index fd4e620..2eac20a 100644 --- a/js/app/views/VisuUI.js +++ b/js/app/views/VisuUI.js @@ -4,30 +4,47 @@ * @class amdaUI.visuUI * @extends Ext.container.Container * @brief Visualization Module UI definition (View) - * @author elena + * @author elena */ Ext.define('amdaUI.VisuUI', { extend: 'Ext.container.Container', - alias: 'widget.panelVisu', - + alias: 'widget.panelVisu', + constructor: function(config) { this.init(config); - this.callParent(arguments); + this.callParent(arguments); + if (this.object) this.reformObject(); }, - setObject : function (name,id) - { - // set object - this.object.set('id',id); - this.object.set('name',name); - + setObject : function (obj) { + + this.object = obj; + this.reformObject(); + }, + + updateObject : function () { + + return true; + }, + + reformObject : function () + { + this.fromPlugin = this.object.get('fromPlugin'); + + if (this.fromPlugin) { + this.object.set('id',this.object.get('folderId')); + this.object.set('objName',this.object.get('objName')); + } + else { + this.object.set('id',this.object.get('id')); + this.object.set('name',this.object.get('name')); + } // load object into view this.loadObject(); }, - - + reset : function() { this.parCombo.reset(); @@ -40,8 +57,7 @@ Ext.define('amdaUI.VisuUI', { */ loadObject : function() { - - + var me = this; var onAfterInit = function(result, e) @@ -55,10 +71,11 @@ Ext.define('amdaUI.VisuUI', { return; } - + me.object.set('name', result.name); + me.object.set('nbIntervals', result.totalCount); var fields = [], i = 0, index; - + Ext.Array.each(result.parameters, function(obj) { @@ -96,7 +113,8 @@ Ext.define('amdaUI.VisuUI', { read : AmdaAction.readIntervalsForChart }, // remplir automatiquement tt, sharedtt , catalog, shared catalog - extraParams : {'typeTT' : 'catalog', 'id' : me.object.get('id')}, + extraParams : {'typeTT' : 'catalog', 'id' : me.object.get('id'), + 'name' : me.object.get('objName'), 'fromPlugin' : me.fromPlugin}, reader: { type: 'json', @@ -108,8 +126,8 @@ Ext.define('amdaUI.VisuUI', { scope : me, load: function(store,records) { //TODO enable plot button - me.object.set('nbIntervals',me.chartStore.getTotalCount()); - + // me.object.set('nbIntervals',me.chartStore.getTotalCount()); + // load object into form var formPanel = me.items.items[0].items.items[0]; formPanel.getForm().loadRecord(me.object); @@ -121,8 +139,10 @@ Ext.define('amdaUI.VisuUI', { } - if (this.object.get('id')) - AmdaAction.initForChartFromTT(this.object.get('id'), 'catalog', onAfterInit); + + + AmdaAction.initForChart(this.object.get('id'), this.object.get('objName'), this.fromPlugin, 'catalog', onAfterInit); + }, @@ -209,7 +229,15 @@ Ext.define('amdaUI.VisuUI', { // return storeItem.param3; // } } - }] + }], + listeners: { + select: { + fn: function(me, selection) { + me.setZoom(selection); + me.mask.hide(); + } + } + } } var plotTypeList = Ext.create('Ext.data.Store', { diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 20b3271..6fe3420 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -954,12 +954,11 @@ class AmdaAction { return $cacheMgr->initFromTT($id, $type); } - public function initForChartFromTT($id, $type) + public function initForChart($id, $name, $isTmpObject, $type) { if ($type == 'catalog') $objMgr = new CatalogMgr(); - - - return $objMgr->initForChartFromTT($id, $type); + + return $objMgr->initForChart($id, $name, $isTmpObject, $type); } public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false) @@ -992,7 +991,7 @@ class AmdaAction { if ($o->typeTT == 'catalog') $objMgr = new CatalogMgr(); - return $objMgr->getIntervalsForChart($o->id, $o->typeTT); + return $objMgr->getIntervalsForChart($o->id, $o->name, $o->fromPlugin, $o->typeTT); } public function saveTTCacheIntervalsInTT($o) diff --git a/php/classes/CatalogMgr.php b/php/classes/CatalogMgr.php index 7cbdd81..f422f12 100644 --- a/php/classes/CatalogMgr.php +++ b/php/classes/CatalogMgr.php @@ -249,14 +249,14 @@ class CatalogMgr extends TimeTableMgr { } - public function initForChartFromTT($id, $typeTT) + public function initForChart($id, $name, $isTmpObject, $typeTT) { - $intervals_res = $this->loadIntervalsFromTT($id,$typeTT); + $intervals_res = $this->getCatalogParamDescription($id, $name, $isTmpObject, $typeTT); if (!$intervals_res['success']) return $intervals_res; - $paramHeaders = []; + $paramHeaders = array(); foreach ( $intervals_res['parameters'] as $param ) { @@ -276,14 +276,19 @@ class CatalogMgr extends TimeTableMgr { } } - unset($intervals_res); + // unset($intervals_res); - return array('success' => true, 'parameters' => $paramHeaders); + return array('success' => true, 'parameters' => $paramHeaders, + 'totalCount' => $intervals_res['totalCount'], 'name' => $intervals_res['name']); } - public function getIntervalsForChart($id, $type) { + + public function getIntervalsForChart($id, $name, $isTmpObject, $type) { - $intervals_res = $this->loadIntervalsFromTT($id,$type); + if ($isTmpObject) + $intervals_res = $this->getTmpObject($id, $name); + else + $intervals_res = $this->loadIntervalsFromTT($id,$type); if (!$intervals_res['success']) return $intervals_res; @@ -318,5 +323,62 @@ class CatalogMgr extends TimeTableMgr { } + public function getCatalogParamDescription($id, $name, $isTmpObject, $typeTT) + { + if ($typeTT == 'sharedcatalog') { + $pathid = SHAREDPATH.'TT/'.$id; + } + elseif (!$isTmpObject) { + $pathid = USERTTDIR.$id; + } + else { + $pathid = USERWORKINGDIR.$id.'/'.$name; + } + + //load intervals from Catalog id + if (!file_exists($pathid.'.xml')) + return array('success' => false, 'message' => "Cannot find Catalog file ".$id); + + if (!$this->objectDom->load($pathid.'.xml')) + return array('success' => false, 'message' => "Cannot load Catalog file ".$id); + +// if (!($objToGet = $this->objectDom->getElementById($id))) +// return array('success' => false, 'message' => NO_SUCH_ID." ".$id); + + $nameNodes = $this->objectDom->getElementsByTagName('name'); + + if ($nameNodes->length > 0) + $nameReal = $nameNodes->item(0)->nodeValue; + else + $nameReal = $name; + + $xpath = new DOMXPath($this->objectDom); + $intervals = $xpath->query('//intervals'); + + + // params header + $paramsNodes = $xpath->query('//parameters/parameter'); + $paramsArray = array(); + + if ($paramsNodes->length > 0) + { + foreach ($paramsNodes as $paramNode) + { + $oneParam = array(); + foreach ($paramNode->attributes as $attr) + $oneParam[$attr->nodeName] = $attr->nodeValue; + $paramsArray[] = $oneParam; + } + } + + return array( + 'name' => $nameReal, + 'totalCount' => $intervals->length, + 'parameters' => $paramsArray, + 'success' => true + ); + + } + } ?> diff --git a/php/config.php b/php/config.php index b285f47..9d1154c 100644 --- a/php/config.php +++ b/php/config.php @@ -278,8 +278,8 @@ $API = array( 'initTTCacheFromTT' => array( 'len'=>2 ), - 'initForChartFromTT' => array( - 'len'=>2 + 'initForChart' => array( + 'len'=>4 ), 'initTTCacheFromTmpObject' => array( 'len'=>3 -- libgit2 0.21.2