From 8ba47f7212de2e2a584e5fc2cab2e384828362dd Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 17 Jan 2019 11:42:33 +0100 Subject: [PATCH] rest actualisation et supprimer double message --- js/app/models/DerivedParamNode.js | 70 +++++++++++++++++++++++++++++++++++++++++++++++----------------------- js/app/models/InteractiveNode.js | 2 +- js/app/models/Parameter.js | 6 +++++- js/app/views/ExplorerUI.js | 4 ++-- js/app/views/ParameterUI.js | 44 ++++++++++++++++++++++++++++++++++++++++++-- php/classes/AmdaAction.php | 32 ++++++++++++++++++++++++++++---- php/classes/DerivedParamMgr.php | 4 ++-- php/classes/UserMgr.php | 17 +++++++++-------- php/config.php | 1 + 9 files changed, 137 insertions(+), 43 deletions(-) diff --git a/js/app/models/DerivedParamNode.js b/js/app/models/DerivedParamNode.js index 41ed1fc..806aa69 100644 --- a/js/app/models/DerivedParamNode.js +++ b/js/app/models/DerivedParamNode.js @@ -9,46 +9,70 @@ */ Ext.define('amdaModel.DerivedParamNode', { - extend: 'amdaModel.InteractiveNode', + requires:[], + statics:{ nodeType: 'derivedParam', objectName: 'Parameter' }, - constructor : function(config){ + constructor : function(config){ this.callParent(arguments); this.set('moduleId',myDesktopApp.dynamicModules.param.id); this.set('objectDataModel',amdaModel.Parameter.$className); this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); - if (this.get('leaf')) this.set('iconCls', 'icon-scalar'); + if (this.get('isParameter')) { + console.log(this); + if( (this.get('dim_1') == 3 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 3)){ + this.set('iconCls', 'icon-vector'); + } else if ( (this.get('dim_1') > 1 && this.get('dim_2') >=1)|| (this.get('dim_1') >=1 && this.get('dim_2') >1)) { + this.set('iconCls','icon-spectra'); + } else { + this.set('iconCls', 'icon-unknowntype'); + } + } }, - localMenuItems : function() { - var menuItems = - [{ +localMenuItems : function() { + var menuItems = + [{ fnId : 'leaf-plotParam', - text : 'Plot Parameter', - hidden : true - }, { - fnId : 'leaf-downParam', - text : 'Download Parameter', - hidden : true - }]; - return menuItems; - }, + text : 'Plot Parameter', + hidden : true + }, { + fnId : 'leaf-downParam', + text : 'Download Parameter', + hidden : true + }]; + return menuItems; +}, - getAllContextMenuItems: function(){ +getAllContextMenuItems: function(){ - var menuItems = this.allMenuItems(); - var locMenuItems = this.localMenuItems(); + var menuItems = this.allMenuItems(); + var locMenuItems = this.localMenuItems(); - return Ext.Array.merge(menuItems,locMenuItems); - }, + return Ext.Array.merge(menuItems,locMenuItems); +}, - isParameter : function(){ - return this.get('isParameter'); - } +isParameter : function(){ + return this.get('isParameter'); +}, + +specialUpdate : function(res, timeUpdate) { + if (this.get('isParameter')) { + console.log(this); + if( (this.get('dim_1') == 3 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 3)){ + this.set('iconCls', 'icon-vector'); + } else if ((this.get('dim_1') > 1 && this.get('dim_2') >= 1)|| (this.get('dim_1') >= 1 && this.get('dim_2') >1)) { + this.set('iconCls','icon-spectra'); + } else { + this.set('iconCls', 'icon-unknowntype'); + } + } + +} }); diff --git a/js/app/models/InteractiveNode.js b/js/app/models/InteractiveNode.js index c31dbd8..d9aa84b 100644 --- a/js/app/models/InteractiveNode.js +++ b/js/app/models/InteractiveNode.js @@ -203,7 +203,7 @@ Ext.define('amdaModel.InteractiveNode', { this.set('info',res.info); } - // myDataParam special update + // myDataParam and Parameter special update this.specialUpdate(res, false); // reload object into the view of corresponding Module diff --git a/js/app/models/Parameter.js b/js/app/models/Parameter.js index f60a053..e7f9256 100644 --- a/js/app/models/Parameter.js +++ b/js/app/models/Parameter.js @@ -23,7 +23,9 @@ Ext.define('amdaModel.Parameter', { {name: 'units', type: 'string'}, {name: 'buildchain', type: 'string'}, {name: 'description', type: 'string'}, - {name: 'ytitle', type: 'string'} + {name: 'ytitle', type: 'string'}, + {name: 'dim_1', type: 'number'}, + {name: 'dim_2', type: 'number'} ], /** @@ -49,6 +51,8 @@ Ext.define('amdaModel.Parameter', { if (this.get('units').match(/[a-z,0-9]/gi) != null) { myValues.units = this.get('units'); } + myValues.dim_1 = this.get('dim_1'); + myValues.dim_2 = this.get('dim_2'); myValues.nodeType = amdaModel.DerivedParamNode.nodeType; return myValues; } diff --git a/js/app/views/ExplorerUI.js b/js/app/views/ExplorerUI.js index cf43d73..fa4e170 100644 --- a/js/app/views/ExplorerUI.js +++ b/js/app/views/ExplorerUI.js @@ -575,13 +575,13 @@ Ext.define('amdaUI.ExplorerUI', { }); } - if (record.isLeaf() || record.data.isParameter) + if (record.isLeaf() || record.data.isParameter) switch (record.get('nodeType')) { case 'myData' : case 'myDataParam' : case 'derivedParam' : - case 'timeTable' : + case 'timeTable' : case 'sharedtimeTable' : case 'sharedcatalog' : case 'catalog' : diff --git a/js/app/views/ParameterUI.js b/js/app/views/ParameterUI.js index b22e923..1f9f0cd 100755 --- a/js/app/views/ParameterUI.js +++ b/js/app/views/ParameterUI.js @@ -159,6 +159,46 @@ Ext.define('amdaUI.ParameterUI', } }); }, + + + + /** + * Generate info for parameter desplay + */ + generateParamInfo : function($action) + { + var me = this; + var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id); + + var obj = { + paramId : 'ws_'+this.object.get('name') + }; + AmdaAction.generateParamInfo(obj, function (result, e) { + if (!result || !result.success) + { + if (result.message) + myDesktopApp.warningMsg(result.message); + else + myDesktopApp.warningMsg('Unknown error during parameter compilation'); + return; + } + + paramModule.linkedNode.get('object').set('dim_1', parseInt(result.dimensions.dim_1)); + paramModule.linkedNode.get('object').set('dim_2', parseInt(result.dimensions.dim_2)); + console.log(me); + paramModule.linkedNode.update({scope : me, + failure: function(record, operation) { + + }, + callback: function() { + console.log(paramModule.linkedNode); + } + }); + console.log(paramModule.linkedNode); + + }); + }, + /** * save method called by Save button @@ -188,13 +228,13 @@ Ext.define('amdaUI.ParameterUI', this.object = paramobj; if (toRename) paramModule.linkedNode.toRename = true; } - paramModule.linkedNode.create({scope : this, callback : this.compilParam}); + paramModule.linkedNode.create({scope : this, callback : this.generateParamInfo}); paramModule.linkedNode.set('iconCls', 'icon-scalar'); paramModule.linkedNode.set('isParameter', true); } else { paramModule.linkedNode.set('contextNode',paramModule.contextNode); - paramModule.linkedNode.update({scope : this, callback : this.compilParam}); + paramModule.linkedNode.update({scope : this, callback : this.generateParamInfo}); } } }, diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index fece986..1b98e0b 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -141,6 +141,8 @@ class AmdaAction //TODO MAKE PROPERLY as function of nodetype !!!! $info = ''; + $dim_1 = 1; + $dim_2 = 1; $id = $child->getAttribute('xml:id'); $name = $child->getAttribute('name'); $help = $child->getAttribute('att'); @@ -206,6 +208,14 @@ class AmdaAction break; case 'derivedParam': $info = $child->getAttribute('buildchain'); + + if ($child->hasAttribute('dim_1')) { + $dim_1 = $child->getAttribute('dim_1'); + } + if ($child->hasAttribute('dim_2')) { + $dim_2 = $child->getAttribute('dim_2'); + } + if ($isLeaf) $isParameter = true; break; @@ -544,7 +554,7 @@ class AmdaAction } $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, - 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter); + 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2); } } // if $childrenToReturn we have to return [] @@ -764,7 +774,7 @@ class AmdaAction if ($obj->nodeType == 'derivedParam' && $this->amdaStat->success) $this->amdaStat->addTask($this->user, 'create', null); $objectMgr = new DerivedParamMgr($obj->nodeType); - break; + break; case 'timeTable' : $objectMgr = new TimeTableMgr(); break; @@ -902,12 +912,13 @@ class AmdaAction // Check user if access to DD Server and / or possible 'space consuming' action if ( $function == FunctionTypeEnumClass::PARAMS || $function == FunctionTypeEnumClass::ACTION || - $function == FunctionTypeEnumClass::PARAMSGEN ) + $function == FunctionTypeEnumClass::PARAMSGEN || + $function == FunctionTypeEnumClass::PARAMSINFOGEN ) { $res = $this->checkUser($obj); if (!$res['success']) return $res; } - + $requestManager = new RequestManagerClass(); try { $res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj); @@ -941,9 +952,22 @@ class AmdaAction */ public function compilParam($obj) { +error_log(print_r($obj,TRUE)); return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN); } + +/* + * Generate parameter info for display (e.g size) + */ + public function generateParamInfo($obj) + { + return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSINFOGEN); + } + + + + /* * Delete derived parameter compilation */ diff --git a/php/classes/DerivedParamMgr.php b/php/classes/DerivedParamMgr.php index 56c190b..8bb7a47 100644 --- a/php/classes/DerivedParamMgr.php +++ b/php/classes/DerivedParamMgr.php @@ -19,7 +19,7 @@ class DerivedParamMgr extends AmdaObjectMgr $this->contentRootId = 'derivedParam-treeRootNode'; $this->contentRootTag = 'paramList'; //node attributes and object XML tags - $this->attributes = array('name' => '', 'buildchain' => '', 'timestep' => ''); + $this->attributes = array('name' => '', 'buildchain' => '', 'timestep' => '', 'dim_1' => '1', 'dim_2' => '1'); // + tags in object XML $this->optionalAttributes = array('units' => 'undefined','description' => 'undefined', 'ytitle' => 'undefined'); $this->objTagName = 'param'; @@ -143,7 +143,7 @@ class DerivedParamMgr extends AmdaObjectMgr $this->createObjectDescription($p); $this->addToContent($p, $folder); - return array('id' => $this->id, 'info' => $p->buildchain); + return array('id' => $this->id, 'info' => $p->buildchain, 'dim_1' => $p->dim_1, 'dim_2' => $p->dim_2); } // myData parameter else diff --git a/php/classes/UserMgr.php b/php/classes/UserMgr.php index 703472e..35e7c18 100644 --- a/php/classes/UserMgr.php +++ b/php/classes/UserMgr.php @@ -276,9 +276,9 @@ class UserMgr else { // totally rewrite if ($base->hasAttribute('isSimulation')) { - $centerNode = $this->makeSimulationBase($baseId); + /*$centerNode = $this->makeSimulationBase($baseId); $center = new $baseId(); - $centerNode->setAttribute('available', $center->monitor()); + $centerNode->setAttribute('available', $center->monitor());*/ } else { $center = new $baseId(); @@ -353,10 +353,10 @@ class UserMgr protected function makeNewBase($baseId) { // no data base description ; skip this data base - if (!@file_exists(RemoteData.$baseId.'/base.xml')) continue; + if (!@file_exists(RemoteData.$baseId.'/base.xml')) return; // can't read base.xml ; skip this data base - if (!@$this->baseExtXml->load(RemoteData.$baseId.'/base.xml')) continue; + if (!@$this->baseExtXml->load(RemoteData.$baseId.'/base.xml')) return; $base = $this->paramMgr->basesDom->getElementById($baseId); @@ -527,7 +527,7 @@ class UserMgr public function init() - { + { if ($this->ddLogin() != 0) die('

You are trying to log in as '.$this->user.'
Please check that you entered a valid password

'); @@ -573,11 +573,12 @@ class UserMgr $this->setPath(); $this->userGrps = $this->getUserGrps(); - + if (!$this->makeLocalTree()) die("Login for ".$this->user." failed: Can't make LocalParams.xml");; - - $ok = $this->makeRemoteTree(); + //$ok = $this->makeRemoteTree(); + +//die("BRE"); if (!file_exists(USERWSDIR.'Request.xml')) $reqMgr = new RequestMgr(); if (!file_exists(USERWSDIR.'Tt.xml')) $ttMgr = new TimeTableMgr(); diff --git a/php/config.php b/php/config.php index 6b65948..d89cb36 100644 --- a/php/config.php +++ b/php/config.php @@ -147,6 +147,7 @@ $API = array( 'execute'=>array('len'=>2), //'formHandler'=>true 'compilParam'=>array('len'=>1), + 'generateParamInfo'=>array('len'=>1), 'compilParamDelete'=>array('len'=>1), 'killPlotRequest'=>array('len'=>0), 'merge'=>array('len'=>1), -- libgit2 0.21.2