Commit 4799e5a6 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_web: Show parameters values which are not part of the schema

On most of schemas, we are not strict with the format, so allow us be flexible, include additional fields for the user don't loose values if the schema changes.
parent c1fa452d
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
label, label,
input, input,
default_value, default_value,
default_used_list = [],
default_div, default_div,
span_error, span_error,
span_info; span_info;
...@@ -200,6 +201,7 @@ ...@@ -200,6 +201,7 @@
input.setAttribute("class", "slapos-parameter"); input.setAttribute("class", "slapos-parameter");
div_input.appendChild(input); div_input.appendChild(input);
} }
default_used_list.push(key);
if (json_field.properties[key]['default'] !== undefined) { if (json_field.properties[key]['default'] !== undefined) {
span_info = document.createElement("span"); span_info = document.createElement("span");
span_info.textContent = '(default = ' + json_field.properties[key]['default'] + ')'; span_info.textContent = '(default = ' + json_field.properties[key]['default'] + ')';
...@@ -212,7 +214,34 @@ ...@@ -212,7 +214,34 @@
root.appendChild(div); root.appendChild(div);
} }
} }
for (key in default_dict) {
if (default_dict.hasOwnProperty(key)) {
if (default_used_list.indexOf(key) < 0 ) {
div = document.createElement("div");
div.setAttribute("class", "subfield");
div.title = key;
label = document.createElement("label");
label.textContent = key;
div.appendChild(label);
div_input = document.createElement("div");
div_input.setAttribute("class", "input");
input = render_field({"type": "string"}, default_dict[key]);
input.name = path + "/" + key;
input.setAttribute("class", "slapos-parameter");
div_input.appendChild(input);
default_used_list.push(key);
span_info = document.createElement("span");
span_info.textContent = '(Not part of the schema)';
div_input.appendChild(span_info);
span_error = document.createElement("span");
span_error.setAttribute("class", "error");
div_input.appendChild(span_error);
div.appendChild(div_input);
root.appendChild(div);
}
}
}
return root; return root;
} }
...@@ -396,7 +425,6 @@ ...@@ -396,7 +425,6 @@
software_type = getSoftwareTypeFromForm(g.props.element), software_type = getSoftwareTypeFromForm(g.props.element),
json_dict = getFormValuesAsJSONDict(g.props.element), json_dict = getFormValuesAsJSONDict(g.props.element),
serialisation_type = getSerialisationTypeFromForm(g.props.element); serialisation_type = getSerialisationTypeFromForm(g.props.element);
if (software_type === "") { if (software_type === "") {
if (g.options.parameter.shared) { if (g.options.parameter.shared) {
throw new Error("The software type is not part of the json (" + software_type + " as slave)"); throw new Error("The software type is not part of the json (" + software_type + " as slave)");
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.53504.63330.8328</string> </value> <value> <string>950.63459.41632.30105</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1461863673.55</float> <float>1462374087.76</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