From 2fa56f95cf2a13d9ff21abf9b081d41e01dad521 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 19 Oct 2020 16:30:10 +0200 Subject: [PATCH] Predefined templated params - First step --- js/app/controllers/InteractiveModule.js | 24 +++++++++++++++++++++--- js/app/models/InteractiveNode.js | 1 + js/app/models/PlotObjects/PlotPanelObject.js | 4 ++++ js/app/views/DownloadUI.js | 19 ++++++++++++++++--- js/app/views/PlotComponents/PlotTree.js | 25 +++++++++++++++++++------ php/classes/AmdaAction.php | 15 ++++++++++++++- 6 files changed, 75 insertions(+), 13 deletions(-) diff --git a/js/app/controllers/InteractiveModule.js b/js/app/controllers/InteractiveModule.js index 866ecdf..b4f484c 100644 --- a/js/app/controllers/InteractiveModule.js +++ b/js/app/controllers/InteractiveModule.js @@ -253,11 +253,29 @@ Ext.define('amdaDesktop.InteractiveModule', { * @param {String} objectName The name of sent object * @param {String} isLeaf boolean true if it's a leaf parameter */ - addParam : function(objectName, isLeaf, needsArgs, components) { + addParam : function(objectName, isLeaf, needsArgs, components, predefined_args) { var uiContent = this.getUiContent(); - uiContent.addParam(objectName, isLeaf, needsArgs, components); + uiContent.addParam(objectName, isLeaf, needsArgs, components, predefined_args); }, - + + parseTemplatedParam: function(templatedParamId, onParamParsed) { + AmdaAction.parseTemplatedParam(templatedParamId, function(res,e) { + if (!res || !res.success) { + if (!res || !res.message) { + myDesktopApp.errorMsg('Internal Error - Cannot parse the templated parameter'); + } + else { + myDesktopApp.errorMsg('Internal Error - ' + res.message); + } + } + else { + if (onParamParsed) { + onParamParsed(res.info); + } + } + }); + }, + saveState : Ext.emptyFn, getState : function() { diff --git a/js/app/models/InteractiveNode.js b/js/app/models/InteractiveNode.js index 58d5ea4..cd3a2af 100644 --- a/js/app/models/InteractiveNode.js +++ b/js/app/models/InteractiveNode.js @@ -18,6 +18,7 @@ Ext.define('amdaModel.InteractiveNode', { {name: 'moduleId', type: 'string', persist: false}, {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, {name: 'needsArgs', type:'boolean', defaultValue: false}, + {name: 'predefinedArgs', type:'boolean', defaultValue: false}, {name: 'disable', type: 'boolean', defaultValue: false, persist: false} ], diff --git a/js/app/models/PlotObjects/PlotPanelObject.js b/js/app/models/PlotObjects/PlotPanelObject.js index 9f72b42..1e22f0d 100644 --- a/js/app/models/PlotObjects/PlotPanelObject.js +++ b/js/app/models/PlotObjects/PlotPanelObject.js @@ -298,6 +298,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', { var isTTCat = (typeof data !== "undefined") && (typeof data.isTTCat !== "undefined") && data.isTTCat; var isVector = (typeof data !== "undefined") && (typeof data.isVector !== "undefined") && data.isVector; var components = (typeof data !== "undefined") && (typeof data.components !== "undefined") && data.components ? data.components : null; + var template_args = (typeof data !== "undefined") && (typeof data.template_args !== "undefined") && data.template_args ? data.template_args : null; this.set('last-param-id', this.get('last-param-id') + 1); @@ -308,6 +309,9 @@ Ext.define('amdaPlotObj.PlotPanelObject', { var recs = this.params().add(obj); recs[0].set('paramid', paramId); recs[0].set('plotonly', isPlotOnly); + if (template_args) { + recs[0].set('template_args', template_args); + } if (components != null) { if (components['index1']) { diff --git a/js/app/views/DownloadUI.js b/js/app/views/DownloadUI.js index 115f6be..b41bcd9 100644 --- a/js/app/views/DownloadUI.js +++ b/js/app/views/DownloadUI.js @@ -91,7 +91,7 @@ Ext.define('amdaUI.DownloadUI', { this.timeSelector.intervalSel.updateDuration(); }, - addParam: function (paramId, isLeaf, needArgs, components) + addParam: function (paramId, isLeaf, needArgs, components, predefined_args) { // adding the parameter to the paramGrid var paramObj = amdaModel.RequestParamObject.getEmptyObj(); @@ -109,6 +109,10 @@ Ext.define('amdaUI.DownloadUI', { } } + if (predefined_args) { + paramObj.template_args = predefined_args; + } + var r = Ext.create('amdaModel.DownloadParam', paramObj); var pos = this.paramGrid.store.getCount(); this.paramGrid.store.insert(pos, r); @@ -504,8 +508,17 @@ Ext.define('amdaUI.DownloadUI', { return false; } var downModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id); - if (downModule) - downModule.addParam(idToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components); + if (downModule) { + if (data.records[0].get('predefinedArgs')) { + downModule.parseTemplatedParam(idToSent, function(param_info) { + downModule.addParam(param_info.paramid, true, true, components, param_info.template_args); + }); + } + else { + downModule.addParam(idToSent, data.records[0].get('leaf'), data.records[0].get('needsArgs'), components); + return true; + } + } return true; } }); diff --git a/js/app/views/PlotComponents/PlotTree.js b/js/app/views/PlotComponents/PlotTree.js index 4c3bf70..cded7aa 100644 --- a/js/app/views/PlotComponents/PlotTree.js +++ b/js/app/views/PlotComponents/PlotTree.js @@ -643,11 +643,24 @@ Ext.define('amdaPlotComp.PlotTree', { //Create param object var me = this; - panelObject.createNewParam(paramId, data, function (newParamObject) { - //Rebuild params node - me.buildPanelsNode(newParamObject.getId()); - //BRE newParamObject - }); + if ((typeof data !== "undefined") && (typeof data.predefinedArgs !== "undefined") && data.predefinedArgs) { + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); + plotModule.parseTemplatedParam(paramId, function(param_info) { + data.template_args = param_info.template_args; + panelObject.createNewParam(param_info.paramid, data, function (newParamObject) { + //Rebuild params node + me.buildPanelsNode(newParamObject.getId()); + }); + //downModule.addParam(param_info.paramid, true, true, components, param_info.template_args); + }); + } + else { + panelObject.createNewParam(paramId, data, function (newParamObject) { + //Rebuild params node + me.buildPanelsNode(newParamObject.getId()); + //BRE newParamObject + }); + } }, dropRecord: function (record, targetNode, position) @@ -693,7 +706,7 @@ Ext.define('amdaPlotComp.PlotTree', { if (component_info.index2) components['index2'] = component_info.index2; } - this.dropParamToCreate(targetNode, position, param_id, {'components': components, 'isVector': isVector, 'plotOnly': plot_only}); + this.dropParamToCreate(targetNode, position, param_id, {'components': components, 'isVector': isVector, 'plotOnly': plot_only, 'predefinedArgs': record.get('predefinedArgs')}); } return true; case 'amdaModel.AliasNode' : diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 47f915a..f2203c1 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -268,6 +268,9 @@ class AmdaAction $isParameter = true; if ($child->hasAttribute('TemplatedParameter')) $needsArgs = true; + + if ($child->hasAttribute('PredefinedTemplatedParameter')) + $predefinedArgs = true; if ($child->parentNode->hasAttribute('dataStart')) { $globalStart = $child->parentNode->getAttribute('dataStart'); @@ -332,7 +335,7 @@ class AmdaAction 'id' => $id,'nodeType' => $nodeType, 'info' => $info, "component_info" => $component_info, 'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction, 'leaf' => $isLeaf, 'isParameter' => $isParameter,'isSpectra' => $isSpectra, - 'is2dSpectra' => $is2dSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet); + 'is2dSpectra' => $is2dSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'predefinedArgs' => $predefinedArgs, 'help' => $help, 'notyet' => $not_yet); } else { if ($child->hasAttribute('rank')) { @@ -1443,6 +1446,7 @@ class AmdaAction $inputobj = (Object)array( 'paramId' => $obj->paramId, + 'predefinedArgs' => !empty($obj->predefinedArgs), 'type' => $type ); return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO); @@ -1603,5 +1607,14 @@ class AmdaAction { return $this->executeRequest($obj->processId, FunctionTypeEnumClass::PROCESSGETREQUEST); } + + public function parseTemplatedParam($paramTemplateId) + { + $args = (Object)array( + 'paramId' => $paramTemplateId, + 'type' => 'param_parse_template' + ); + return $this->executeRequest($args, FunctionTypeEnumClass::PARAMINFO); + } } ?> -- libgit2 0.21.2