Commit bd00e486 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud&jio: Parameter is passed directly via renderjs_extra

   This make it complies better with ERP5 Form
   Reduce a level on expected options for parameter editor, since there
   is no need to use 'parameter' inside parameter_dict, this was used
   due legacy probably.
parent fd20044c
import base64
text_content = context.getTextContent()
if context.getTextContent() is None:
text_content = '<?xml version="1.0" encoding="utf-8" ?><instance></instance>'
parameter_dict = {
'parameter' : {
'json_url': ".".join([context.getUrlString(), "json"]),
'softwaretype': context.getSourceReference(),
'shared': context.getRootSlave(),
'parameter_hash': base64.b64encode(text_content)
}
}
import json
return json.dumps(parameter_dict)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getParameterEditorDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -504,35 +504,24 @@ ...@@ -504,35 +504,24 @@
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var restricted_softwaretype = false, var restricted_softwaretype = false,
software_type_list = [], software_type_list = [],
parameter_dict, parameter_hash = options.parameter_hash,
parameter_hash, // XXX Do we directly get parameter_xml parameter?
parameter_xml; parameter_xml = options.parameter_xml;
if ((options.value !== undefined) && (typeof options.value === "string")) {
parameter_dict = JSON.parse(options.value).parameter
} else {
parameter_dict = options.value.parameter;
}
parameter_hash = parameter_dict.parameter_hash,
// XXX Do we directly get parameter_xml parameter?
parameter_xml = parameter_dict.parameter_xml;
if (parameter_hash !== undefined) { if (parameter_hash !== undefined) {
// A JSON where provided via gadgetfield // A JSON where provided via gadgetfield
parameter_xml = atob(parameter_hash); parameter_xml = atob(parameter_hash);
} }
if (parameter_dict.software_type_list !== undefined) { if (options.software_type_list !== undefined) {
software_type_list = parameter_dict.software_type_list; software_type_list = options.software_type_list;
} }
if (parameter_dict.softwaretype !== undefined) { if (options.softwaretype !== undefined) {
restricted_softwaretype = true; restricted_softwaretype = true;
// exceptional situation where the default item must be in // exceptional situation where the default item must be in
// the list. // the list.
software_type_list.push(parameter_dict.softwaretype); software_type_list.push(options.softwaretype);
} }
return this.changeState({ return this.changeState({
...@@ -540,13 +529,13 @@ ...@@ -540,13 +529,13 @@
// hidden: options.hidden, // hidden: options.hidden,
// key: options.key, // key: options.key,
serialisation: options.serialisation, serialisation: options.serialisation,
json_url: parameter_dict.json_url, json_url: options.json_url,
parameter_xml: parameter_xml, parameter_xml: parameter_xml,
restricted_softwaretype: restricted_softwaretype, restricted_softwaretype: restricted_softwaretype,
shared: parameter_dict.shared,
softwaretype: parameter_dict.softwaretype,
software_type_list: software_type_list, software_type_list: software_type_list,
softwareindex: parameter_dict.softwareindex, shared: options.shared,
softwaretype: options.softwaretype,
softwareindex: options.softwareindex,
editable: options.editable, editable: options.editable,
// Force refresh in any case // Force refresh in any case
render_timestamp: new Date().getTime() render_timestamp: new Date().getTime()
...@@ -654,4 +643,4 @@ ...@@ -654,4 +643,4 @@
}, {mutex: 'statechange'}); }, {mutex: 'statechange'});
}(window, rJS, XMLSerializer, DOMParser, vkbeautify, }(window, rJS, XMLSerializer, DOMParser, vkbeautify,
domsugar, Boolean, URI)); domsugar, Boolean, URI));
\ No newline at end of file
...@@ -124,7 +124,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -124,7 +124,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_cloud/SoftwareInstance_viewRenameAndRequestDestroyAction', 'slapos_cloud/SoftwareInstance_viewRenameAndRequestDestroyAction',
'slapos_cloud/Base_getSupportRequestInProgress', 'slapos_cloud/Base_getSupportRequestInProgress',
'slapos_cloud/SoftwareInstance_checkDuplicationOnInstanceTreeConsistency', 'slapos_cloud/SoftwareInstance_checkDuplicationOnInstanceTreeConsistency',
'slapos_cloud/Base_getParameterEditorDict',
'slapos_cloud/ComputerNetwork_getRelatedSoftwareReleaseList', 'slapos_cloud/ComputerNetwork_getRelatedSoftwareReleaseList',
'slapos_crm_monitoring/ComputeNode_checkInstanceOnCloseAllocation', 'slapos_crm_monitoring/ComputeNode_checkInstanceOnCloseAllocation',
'slapos_crm_monitoring/SiteMessage_setSlapOSUserSourceAndDestinatationList', 'slapos_crm_monitoring/SiteMessage_setSlapOSUserSourceAndDestinatationList',
......
...@@ -115,16 +115,14 @@ ...@@ -115,16 +115,14 @@
page_title_translation = result[2][9]; page_title_translation = result[2][9];
var doc = result[1], var doc = result[1],
parameter_dict = { parameter_dict = {
'parameter' : { 'json_url': doc.url_string.split('?')[0] + ".json",
'json_url': doc.url_string.split('?')[0] + ".json", 'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance/>')
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance/>')
}
}; };
if (options.software_type) { if (options.software_type) {
parameter_dict["parameter"]['softwaretype'] = options.software_type; parameter_dict['softwaretype'] = options.software_type;
} }
if (options.shared) { if (options.shared) {
parameter_dict["parameter"]['shared'] = true; parameter_dict['shared'] = true;
} }
return result[0].render({ return result[0].render({
...@@ -155,7 +153,7 @@ ...@@ -155,7 +153,7 @@
"your_text_content": { "your_text_content": {
"description": "", "description": "",
"title": result[2][5], "title": result[2][5],
"default": parameter_dict, "default": "",
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 1, "editable": 1,
...@@ -163,7 +161,8 @@ ...@@ -163,7 +161,8 @@
"sandbox": "", "sandbox": "",
"key": "text_content", "key": "text_content",
"hidden": 0, "hidden": 0,
"type": "GadgetField" "type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
}, },
"your_computer_guid": { "your_computer_guid": {
"description": result[2][2], "description": result[2][2],
......
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.22803.51783.61098</string> </value> <value> <string>1010.44014.55766.17408</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1683853456.43</float> <float>1692989933.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -228,15 +228,13 @@ ...@@ -228,15 +228,13 @@
['connection_value', result[1][14]] ['connection_value', result[1][14]]
], ],
parameter_dict = { parameter_dict = {
'parameter' : { 'json_url': gadget.state.doc.url_string.split('?')[0] + ".json",
'json_url': gadget.state.doc.url_string.split('?')[0] + ".json", 'softwaretype': gadget.state.doc.source_reference,
'softwaretype': gadget.state.doc.source_reference, 'shared': gadget.state.doc.root_slave ? 1 : 0,
'shared': gadget.state.doc.root_slave ? 1 : 0, 'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>')
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>')
}
}; };
if (gadget.state.doc.text_content !== undefined) { if (gadget.state.doc.text_content !== undefined) {
parameter_dict.parameter.parameter_hash = btoa(gadget.state.doc.text_content); parameter_dict.parameter_hash = btoa(gadget.state.doc.text_content);
} }
return gadget.getSetting("hateoas_url") return gadget.getSetting("hateoas_url")
.push(function (url) { .push(function (url) {
...@@ -314,7 +312,7 @@ ...@@ -314,7 +312,7 @@
"my_text_content": { "my_text_content": {
"description": "", "description": "",
"title": result[1][19], "title": result[1][19],
"default": parameter_dict, "default": "",
"css_class": "", "css_class": "",
"required": 0, "required": 0,
"editable": 1, "editable": 1,
...@@ -322,7 +320,9 @@ ...@@ -322,7 +320,9 @@
"sandbox": "", "sandbox": "",
"key": "text_content", "key": "text_content",
"hidden": 0, "hidden": 0,
"type": "GadgetField" "type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
}, },
"my_source_project": { "my_source_project": {
"description": result[1][20], "description": result[1][20],
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1009.49086.48551.49459</string> </value> <value> <string>1010.44015.51861.27016</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1692645657.66</float> <float>1692924255.67</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, btoa */ /*global window, rJS, RSVP, btoa, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3, sub:true */ /*jslint nomen: true, indent: 2, maxerr: 3, sub:true */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, btoa, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -106,13 +106,11 @@ ...@@ -106,13 +106,11 @@
parameter_hash = btoa(gadget.state.parameter_output); parameter_hash = btoa(gadget.state.parameter_output);
} }
parameter_dict = { parameter_dict = {
'parameter' : { 'json_url': gadget.state.url_string.split('?')[0] + ".json",
'json_url': gadget.state.url_string.split('?')[0] + ".json", 'parameter_hash': parameter_hash
'parameter_hash': parameter_hash
}
}; };
if (gadget.state.software_type_list) { if (gadget.state.software_type_list) {
parameter_dict.parameter.software_type_list = gadget.state.software_type_list.split(','); parameter_dict.software_type_list = gadget.state.software_type_list.split(',');
} }
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
...@@ -131,7 +129,7 @@ ...@@ -131,7 +129,7 @@
"your_text_content": { "your_text_content": {
"description": "", "description": "",
"title": "Parameters", "title": "Parameters",
"default": parameter_dict, "default": "",
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": gadget.state.url_string !== "", "editable": gadget.state.url_string !== "",
...@@ -139,7 +137,8 @@ ...@@ -139,7 +137,8 @@
"sandbox": "", "sandbox": "",
"key": "text_content", "key": "text_content",
"hidden": gadget.state.url_string === "", "hidden": gadget.state.url_string === "",
"type": "GadgetField" "type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
}, },
"your_software_type": { "your_software_type": {
"description": "", "description": "",
...@@ -207,4 +206,4 @@ ...@@ -207,4 +206,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, btoa, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1004.41258.43166.28757</string> </value> <value> <string>1010.42602.14389.54903</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1669664533.48</float> <float>1692903464.84</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, btoa */ /*global window, rJS, RSVP, btoa, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3, sub:true */ /*jslint nomen: true, indent: 2, maxerr: 3, sub:true */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, btoa, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -112,15 +112,13 @@ ...@@ -112,15 +112,13 @@
parameter_hash = btoa(gadget.state.parameter_output); parameter_hash = btoa(gadget.state.parameter_output);
} }
parameter_dict = { parameter_dict = {
'parameter' : { 'json_url': gadget.state.url_string.split('?')[0] + ".json",
'json_url': gadget.state.url_string.split('?')[0] + ".json", 'parameter_hash': parameter_hash,
'parameter_hash': parameter_hash, 'softwaretype': gadget.state.software_type,
'softwaretype': gadget.state.software_type, 'restricted_softwaretype': false
'restricted_softwaretype': false
}
}; };
if (gadget.state.shared === 'yes') { if (gadget.state.shared === 'yes') {
parameter_dict['parameter']['shared'] = true; parameter_dict['shared'] = true;
} }
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
...@@ -139,7 +137,7 @@ ...@@ -139,7 +137,7 @@
"your_text_content": { "your_text_content": {
"description": "", "description": "",
"title": "Parameters", "title": "Parameters",
"default": parameter_dict, "default": "",
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
...@@ -147,7 +145,8 @@ ...@@ -147,7 +145,8 @@
"sandbox": "", "sandbox": "",
"key": "text_content", "key": "text_content",
"hidden": gadget.state.url_string === "", "hidden": gadget.state.url_string === "",
"type": "GadgetField" "type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
}, },
"your_software_type": { "your_software_type": {
"description": "Software Type", "description": "Software Type",
...@@ -216,4 +215,4 @@ ...@@ -216,4 +215,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, btoa, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1004.32728.24062.25344</string> </value> <value> <string>1010.44012.38164.19575</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1669152031.46</float> <float>1692982452.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment