Commit 8b284f16 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Accept a list of software types to filter the values from the software.cfg.json

  Accept a list of Software types for limit the user's choice for software type, keeping the actual value (at least) even if they aren't part of the list (in case of existing instances).

  The list DO not extend the software type options provided by the software release (software.cfg.json) only act as a filter.
parent 5aa5af44
...@@ -790,7 +790,6 @@ ...@@ -790,7 +790,6 @@
var serialisation = gadget.state.serialisation, var serialisation = gadget.state.serialisation,
json_url = gadget.state.json_url, json_url = gadget.state.json_url,
parameter_xml = gadget.state.parameter_xml, parameter_xml = gadget.state.parameter_xml,
restricted_softwaretype = gadget.state.restricted_softwaretype,
shared = gadget.state.shared, shared = gadget.state.shared,
softwaretype = gadget.state.softwaretype, softwaretype = gadget.state.softwaretype,
softwareindex = gadget.state.softwareindex, softwareindex = gadget.state.softwareindex,
...@@ -823,7 +822,7 @@ ...@@ -823,7 +822,7 @@
lowest_index = 999, lowest_index = 999,
lowest_option_index; lowest_option_index;
if (!editable || restricted_softwaretype === true) { if (!editable || gadget.state.restricted_softwaretype === true) {
input.classList.add("readonly"); input.classList.add("readonly");
input["aria-disabled"] = "true"; input["aria-disabled"] = "true";
input["tab-index"] = "-1"; input["tab-index"] = "-1";
...@@ -834,6 +833,8 @@ ...@@ -834,6 +833,8 @@
// search by the lowest index // search by the lowest index
for (option_index in json['software-type']) { for (option_index in json['software-type']) {
if (json['software-type'].hasOwnProperty(option_index)) { if (json['software-type'].hasOwnProperty(option_index)) {
if ((gadget.state.software_type_list.length === 0) ||
(gadget.state.software_type_list.includes(option_index))) {
if (json['software-type'][option_index].index === undefined) { if (json['software-type'][option_index].index === undefined) {
json['software-type'][option_index].index = 999; json['software-type'][option_index].index = 999;
} }
...@@ -845,9 +846,12 @@ ...@@ -845,9 +846,12 @@
} }
} }
} }
}
for (option_index in json['software-type']) { for (option_index in json['software-type']) {
if (json['software-type'].hasOwnProperty(option_index)) { if (json['software-type'].hasOwnProperty(option_index)) {
if ((gadget.state.software_type_list.length === 0) ||
(gadget.state.software_type_list.includes(option_index))) {
if (json['software-type'][option_index].shared === undefined) { if (json['software-type'][option_index].shared === undefined) {
json['software-type'][option_index].shared = false; json['software-type'][option_index].shared = false;
...@@ -895,7 +899,7 @@ ...@@ -895,7 +899,7 @@
} }
} }
if (restricted_softwaretype === true) { if (gadget.state.restricted_softwaretype === true) {
if (option.value === softwaretype) { if (option.value === softwaretype) {
if (Boolean(shared) === Boolean(json['software-type'][option_index].shared)) { if (Boolean(shared) === Boolean(json['software-type'][option_index].shared)) {
selection_option_list.push(option); selection_option_list.push(option);
...@@ -909,6 +913,7 @@ ...@@ -909,6 +913,7 @@
} }
} }
} }
}
selection_option_list.sort(function (a, b) { selection_option_list.sort(function (a, b) {
return a["data-index"] - b["data-index"]; return a["data-index"] - b["data-index"];
...@@ -1069,7 +1074,8 @@ ...@@ -1069,7 +1074,8 @@
}) })
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var restricted_softwaretype, var restricted_softwaretype = false,
software_type_list = [],
parameter_hash = options.value.parameter.parameter_hash, parameter_hash = options.value.parameter.parameter_hash,
// XXX Do we directly get parameter_xml parameter? // XXX Do we directly get parameter_xml parameter?
parameter_xml = options.value.parameter.parameter_xml; parameter_xml = options.value.parameter.parameter_xml;
...@@ -1079,12 +1085,18 @@ ...@@ -1079,12 +1085,18 @@
parameter_xml = atob(parameter_hash); parameter_xml = atob(parameter_hash);
} }
if (options.value.parameter.software_type_list !== undefined) {
software_type_list = options.value.parameter.software_type_list;
}
if (options.value.parameter.softwaretype !== undefined) { if (options.value.parameter.softwaretype !== undefined) {
restricted_softwaretype = true; restricted_softwaretype = true;
} else { // exceptional situation where the default item must be in
restricted_softwaretype = false; // the list.
software_type_list.push(options.value.parameter.softwaretype);
} }
return this.changeState({ return this.changeState({
// Not used parameters // Not used parameters
// hidden: options.hidden, // hidden: options.hidden,
...@@ -1095,6 +1107,7 @@ ...@@ -1095,6 +1107,7 @@
restricted_softwaretype: restricted_softwaretype, restricted_softwaretype: restricted_softwaretype,
shared: options.value.parameter.shared, shared: options.value.parameter.shared,
softwaretype: options.value.parameter.softwaretype, softwaretype: options.value.parameter.softwaretype,
software_type_list: software_type_list,
softwareindex: options.value.parameter.softwareindex, softwareindex: options.value.parameter.softwareindex,
editable: options.editable, editable: options.editable,
// Force refresh in any case // Force refresh in any case
......
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1004.35244.29312.7338</string> </value> <value> <string>1004.35604.19918.32529</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -298,7 +298,7 @@ ...@@ -298,7 +298,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1669310000.93</float> <float>1669324961.21</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