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 @@
.declareMethod('render', function (options) {
var restricted_softwaretype = false,
software_type_list = [],
parameter_dict,
parameter_hash,
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 = options.parameter_hash,
// XXX Do we directly get parameter_xml parameter?
parameter_xml = options.parameter_xml;
parameter_hash = parameter_dict.parameter_hash,
// XXX Do we directly get parameter_xml parameter?
parameter_xml = parameter_dict.parameter_xml;
if (parameter_hash !== undefined) {
// A JSON where provided via gadgetfield
parameter_xml = atob(parameter_hash);
}
if (parameter_dict.software_type_list !== undefined) {
software_type_list = parameter_dict.software_type_list;
if (options.software_type_list !== undefined) {
software_type_list = options.software_type_list;
}
if (parameter_dict.softwaretype !== undefined) {
if (options.softwaretype !== undefined) {
restricted_softwaretype = true;
// exceptional situation where the default item must be in
// the list.
software_type_list.push(parameter_dict.softwaretype);
software_type_list.push(options.softwaretype);
}
return this.changeState({
......@@ -540,13 +529,13 @@
// hidden: options.hidden,
// key: options.key,
serialisation: options.serialisation,
json_url: parameter_dict.json_url,
json_url: options.json_url,
parameter_xml: parameter_xml,
restricted_softwaretype: restricted_softwaretype,
shared: parameter_dict.shared,
softwaretype: parameter_dict.softwaretype,
software_type_list: software_type_list,
softwareindex: parameter_dict.softwareindex,
shared: options.shared,
softwaretype: options.softwaretype,
softwareindex: options.softwareindex,
editable: options.editable,
// Force refresh in any case
render_timestamp: new Date().getTime()
......@@ -654,4 +643,4 @@
}, {mutex: 'statechange'});
}(window, rJS, XMLSerializer, DOMParser, vkbeautify,
domsugar, Boolean, URI));
\ No newline at end of file
domsugar, Boolean, URI));
......@@ -124,7 +124,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_cloud/SoftwareInstance_viewRenameAndRequestDestroyAction',
'slapos_cloud/Base_getSupportRequestInProgress',
'slapos_cloud/SoftwareInstance_checkDuplicationOnInstanceTreeConsistency',
'slapos_cloud/Base_getParameterEditorDict',
'slapos_cloud/ComputerNetwork_getRelatedSoftwareReleaseList',
'slapos_crm_monitoring/ComputeNode_checkInstanceOnCloseAllocation',
'slapos_crm_monitoring/SiteMessage_setSlapOSUserSourceAndDestinatationList',
......
......@@ -115,16 +115,14 @@
page_title_translation = result[2][9];
var doc = result[1],
parameter_dict = {
'parameter' : {
'json_url': doc.url_string.split('?')[0] + ".json",
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance/>')
}
'json_url': doc.url_string.split('?')[0] + ".json",
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance/>')
};
if (options.software_type) {
parameter_dict["parameter"]['softwaretype'] = options.software_type;
parameter_dict['softwaretype'] = options.software_type;
}
if (options.shared) {
parameter_dict["parameter"]['shared'] = true;
parameter_dict['shared'] = true;
}
return result[0].render({
......@@ -155,7 +153,7 @@
"your_text_content": {
"description": "",
"title": result[2][5],
"default": parameter_dict,
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
......@@ -163,7 +161,8 @@
"sandbox": "",
"key": "text_content",
"hidden": 0,
"type": "GadgetField"
"type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
},
"your_computer_guid": {
"description": result[2][2],
......
......@@ -283,7 +283,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1008.22803.51783.61098</string> </value>
<value> <string>1010.44014.55766.17408</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -303,7 +303,7 @@
</tuple>
<state>
<tuple>
<float>1683853456.43</float>
<float>1692989933.58</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -228,15 +228,13 @@
['connection_value', result[1][14]]
],
parameter_dict = {
'parameter' : {
'json_url': gadget.state.doc.url_string.split('?')[0] + ".json",
'softwaretype': gadget.state.doc.source_reference,
'shared': gadget.state.doc.root_slave ? 1 : 0,
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>')
}
'json_url': gadget.state.doc.url_string.split('?')[0] + ".json",
'softwaretype': gadget.state.doc.source_reference,
'shared': gadget.state.doc.root_slave ? 1 : 0,
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>')
};
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")
.push(function (url) {
......@@ -314,7 +312,7 @@
"my_text_content": {
"description": "",
"title": result[1][19],
"default": parameter_dict,
"default": "",
"css_class": "",
"required": 0,
"editable": 1,
......@@ -322,7 +320,9 @@
"sandbox": "",
"key": "text_content",
"hidden": 0,
"type": "GadgetField"
"type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
},
"my_source_project": {
"description": result[1][20],
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1009.49086.48551.49459</string> </value>
<value> <string>1010.44015.51861.27016</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1692645657.66</float>
<float>1692924255.67</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, btoa */
/*global window, rJS, RSVP, btoa, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3, sub:true */
(function (window, rJS, RSVP) {
(function (window, rJS, RSVP, btoa, JSON) {
"use strict";
rJS(window)
......@@ -106,13 +106,11 @@
parameter_hash = btoa(gadget.state.parameter_output);
}
parameter_dict = {
'parameter' : {
'json_url': gadget.state.url_string.split('?')[0] + ".json",
'parameter_hash': parameter_hash
}
'json_url': gadget.state.url_string.split('?')[0] + ".json",
'parameter_hash': parameter_hash
};
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({
erp5_document: {
......@@ -131,7 +129,7 @@
"your_text_content": {
"description": "",
"title": "Parameters",
"default": parameter_dict,
"default": "",
"css_class": "",
"required": 1,
"editable": gadget.state.url_string !== "",
......@@ -139,7 +137,8 @@
"sandbox": "",
"key": "text_content",
"hidden": gadget.state.url_string === "",
"type": "GadgetField"
"type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
},
"your_software_type": {
"description": "",
......@@ -207,4 +206,4 @@
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
}(window, rJS, RSVP, btoa, JSON));
\ No newline at end of file
......@@ -281,7 +281,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.41258.43166.28757</string> </value>
<value> <string>1010.42602.14389.54903</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -301,7 +301,7 @@
</tuple>
<state>
<tuple>
<float>1669664533.48</float>
<float>1692903464.84</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, btoa */
/*global window, rJS, RSVP, btoa, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3, sub:true */
(function (window, rJS, RSVP) {
(function (window, rJS, RSVP, btoa, JSON) {
"use strict";
rJS(window)
......@@ -112,15 +112,13 @@
parameter_hash = btoa(gadget.state.parameter_output);
}
parameter_dict = {
'parameter' : {
'json_url': gadget.state.url_string.split('?')[0] + ".json",
'parameter_hash': parameter_hash,
'softwaretype': gadget.state.software_type,
'restricted_softwaretype': false
}
'json_url': gadget.state.url_string.split('?')[0] + ".json",
'parameter_hash': parameter_hash,
'softwaretype': gadget.state.software_type,
'restricted_softwaretype': false
};
if (gadget.state.shared === 'yes') {
parameter_dict['parameter']['shared'] = true;
parameter_dict['shared'] = true;
}
return result[0].render({
erp5_document: {
......@@ -139,7 +137,7 @@
"your_text_content": {
"description": "",
"title": "Parameters",
"default": parameter_dict,
"default": "",
"css_class": "",
"required": 1,
"editable": 0,
......@@ -147,7 +145,8 @@
"sandbox": "",
"key": "text_content",
"hidden": gadget.state.url_string === "",
"type": "GadgetField"
"type": "GadgetField",
"renderjs_extra": JSON.stringify(parameter_dict)
},
"your_software_type": {
"description": "Software Type",
......@@ -216,4 +215,4 @@
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
}(window, rJS, RSVP, btoa, JSON));
\ No newline at end of file
......@@ -281,7 +281,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.32728.24062.25344</string> </value>
<value> <string>1010.44012.38164.19575</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -301,7 +301,7 @@
</tuple>
<state>
<tuple>
<float>1669152031.46</float>
<float>1692982452.93</float>
<string>UTC</string>
</tuple>
</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