Commit 1e99a9aa authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Make software type read only whenever you cannot change it

  Instance tree cannot change software type, so make the software type selection field as read only, improving users experience.
  Remove duplicated Software type on instance tree view, since it is already present on Parameter editor.
parent 7d07dfdd
...@@ -226,7 +226,6 @@ ...@@ -226,7 +226,6 @@
'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,
//'json_url': "https://lab.node.vifib.com/nexedi/slapos/raw/master/software/kvm/software.cfg.json",
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>'), 'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>'),
'restricted_softwaretype': true 'restricted_softwaretype': true
} }
...@@ -294,17 +293,6 @@ ...@@ -294,17 +293,6 @@
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
}, },
"my_source_reference": {
"description": "",
"title": result[1][17],
"default": gadget.state.doc.source_reference,
"css_class": "",
"required": 1,
"editable": 0,
"key": "source_reference",
"hidden": 0,
"type": "StringField"
},
"my_url_string": { "my_url_string": {
"description": "", "description": "",
"title": result[1][18], "title": result[1][18],
...@@ -488,7 +476,7 @@ ...@@ -488,7 +476,7 @@
[["my_slap_state_title"], ['my_monitoring_status'], ['my_monitor_scope'], ['my_upgrade_scope'], ['my_source_project'], ['my_source']] [["my_slap_state_title"], ['my_monitoring_status'], ['my_monitor_scope'], ['my_upgrade_scope'], ['my_source_project'], ['my_source']]
], ["center", ], ["center",
[["my_source_reference"], ["my_url_string"], ["my_list_image"]] [["my_url_string"], ["my_list_image"]]
], [ ], [
"bottom", "bottom",
[["ticket_listbox"], ["connection_listbox"], ["my_text_content"], ["listbox"]] [["ticket_listbox"], ["connection_listbox"], ["my_text_content"], ["listbox"]]
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1001.26171.19762.42854</string> </value> <value> <string>1004.26871.45800.22818</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>1658173330.65</float> <float>1668800165.86</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
padding-top: 10px; padding-top: 10px;
} }
.subfield span:not(.slapos-parameter) {
.subfield span {
font-weight: normal; font-weight: normal;
font-style: italic; font-style: italic;
padding-left: 7px; padding-left: 7px;
...@@ -22,12 +19,8 @@ ...@@ -22,12 +19,8 @@
font-weight: 700; font-weight: 700;
} }
.input button {margin-left: 10px;} .input button {margin-left: 10px;}
.bt_close, .subfield .slapos-parameter-dict-key span.bt_close{ .bt_close, .subfield .slapos-parameter-dict-key span.bt_close{
padding: 0 6px; padding: 0 6px;
display: block; display: block;
...@@ -62,7 +55,6 @@ ...@@ -62,7 +55,6 @@
word-break: keep-all; word-break: keep-all;
} }
.non-editable > div.input {border: 1px solid rgb(201, 201, 201); padding: 5px; background: white; font-weight: normal; .non-editable > div.input {border: 1px solid rgb(201, 201, 201); padding: 5px; background: white; font-weight: normal;
margin: 5px 0 10px; max-height: 250px; width: 80%;} margin: 5px 0 10px; max-height: 250px; width: 80%;}
...@@ -84,6 +76,7 @@ label.slapos-parameter-dict-key-colapse::before { ...@@ -84,6 +76,7 @@ label.slapos-parameter-dict-key-colapse::before {
} }
div.slapos-parameter-dict-key { div.slapos-parameter-dict-key {
margin-top: 10px; margin-top: 10px;
margin-left: 6px;
background: rgb(245, 245, 245); background: rgb(245, 245, 245);
border: 1px solid rgb(230, 230, 230); border: 1px solid rgb(230, 230, 230);
padding: 5px; padding: 5px;
...@@ -91,7 +84,6 @@ div.slapos-parameter-dict-key { ...@@ -91,7 +84,6 @@ div.slapos-parameter-dict-key {
/* cleanup */ /* cleanup */
fieldset > .subfield > label:not(.slapos-parameter-dict-key) { fieldset > .subfield > label:not(.slapos-parameter-dict-key) {
font-size: 113%;
color: rgb(112, 125, 136); color: rgb(112, 125, 136);
} }
fieldset > div.subfield { fieldset > div.subfield {
...@@ -103,24 +95,30 @@ fieldset > div.subfield { ...@@ -103,24 +95,30 @@ fieldset > div.subfield {
.field input ~ span, .field input ~ span,
.subfield input ~ span { .subfield input ~ span {
position: relative; position: relative;
top: -30px; top: -27px;
pointer-events: none; pointer-events: none;
cursor: text; cursor: text;
} }
.field input:not(:placeholder-shown) ~ span:not(.error), .field input:not(:placeholder-shown) ~ span:not(.error),
.subfield input:not(:placeholder-shown) ~ span:not(.error) { .subfield input:not(:placeholder-shown) ~ span:not(.error),
.field select:not(:placeholder-shown) ~ span:not(.error),
.subfield select:not(:placeholder-shown) ~ span:not(.error) {
visibility: hidden; visibility: hidden;
} }
.field input ~ span:not(.error), .field input ~ span:not(.error),
.subfield input ~ span:not(.error) { .subfield input ~ span:not(.error),
.field select ~ span:not(.error),
.subfield select ~ span:not(.error) {
opacity: .7; opacity: .7;
} }
.field input:focus ~ span, .field input:focus ~ span,
.subfield input:focus ~ span { .subfield input:focus ~ span,
.field select:focus ~ span,
.subfield select:focus ~ span {
visibility: hidden; visibility: hidden;
} }
.subfield .input { .subfield .input {
margin-bottom: -20px; margin-bottom: -15px;
} }
.subfield .error { .subfield .error {
float: right; float: right;
...@@ -135,7 +133,6 @@ fieldset > div.subfield { ...@@ -135,7 +133,6 @@ fieldset > div.subfield {
.slapos-show-form { .slapos-show-form {
cursor: pointer; cursor: pointer;
font-style: italic; font-style: italic;
font-size: 14px;
color: #000; color: #000;
} }
.slapos-show-form, .slapos-show-form,
...@@ -147,7 +144,6 @@ label.slapos-parameter-dict-key { ...@@ -147,7 +144,6 @@ label.slapos-parameter-dict-key {
text-transform: capitalize; text-transform: capitalize;
} }
label.slapos-parameter-dict-key ~ div.input label { label.slapos-parameter-dict-key ~ div.input label {
font-size: 113%;
color: rgb(112, 125, 136); color: rgb(112, 125, 136);
} }
.slapos-parameter-dict-key label { .slapos-parameter-dict-key label {
...@@ -180,14 +176,20 @@ label.slapos-parameter-dict-key ~ div.input label { ...@@ -180,14 +176,20 @@ label.slapos-parameter-dict-key ~ div.input label {
left: 4px; left: 4px;
} }
.subfield { .subfield {
min-height: 5em; min-height: 5em;
} }
.subfield select { .subfield select {
margin-bottom: 0; margin-bottom: 0;
} }
.subfield .input select + span { .subfield .input select + span {
position: relative; position: relative;
top: -1.9em; top: -1.9em;
opacity: .7; opacity: .7;
} }
select.readonly {
background: #EEE;
pointer-events: none;
touch-action: none;
}
...@@ -776,6 +776,12 @@ ...@@ -776,6 +776,12 @@
lowest_index = 999, lowest_index = 999,
lowest_option_index; lowest_option_index;
if (restricted_softwaretype === true) {
input.classList.add("readonly");
input["aria-disabled"] = "true";
input["tab-index"] = "-1";
}
if (input.children.length === 0) { if (input.children.length === 0) {
if (option_selected === undefined) { if (option_selected === undefined) {
// search by the lowest index // search by the lowest index
...@@ -795,19 +801,25 @@ ...@@ -795,19 +801,25 @@
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)) {
option = document.createElement("option");
if (json['software-type'][option_index].shared === undefined) {
json['software-type'][option_index].shared = false;
}
option = domsugar("option", {
text: json['software-type'][option_index].title,
value: option_index
});
option['data-id'] = option_index;
option['data-index'] = 999;
option['data-shared'] = json['software-type'][option_index].shared
if (json['software-type'][option_index]['software-type'] !== undefined) { if (json['software-type'][option_index]['software-type'] !== undefined) {
option.value = json['software-type'][option_index]['software-type']; option.value = json['software-type'][option_index]['software-type'];
} else {
option.value = option_index;
} }
option['data-id'] = option_index;
option.textContent = json['software-type'][option_index].title;
if (json['software-type'][option_index].index) { if (json['software-type'][option_index].index) {
option['data-index'] = json['software-type'][option_index].index; option['data-index'] = json['software-type'][option_index].index;
} else {
option['data-index'] = 999;
} }
if (option_index === lowest_option_index) { if (option_index === lowest_option_index) {
...@@ -824,12 +836,6 @@ ...@@ -824,12 +836,6 @@
} }
} }
if (json['software-type'][option_index].shared === undefined) {
json['software-type'][option_index].shared = false;
}
option['data-shared'] = json['software-type'][option_index].shared;
if ((option_selected_index === undefined) && if ((option_selected_index === undefined) &&
(option.value === option_selected) && (option.value === option_selected) &&
(Boolean(shared) === Boolean(json['software-type'][option_index].shared))) { (Boolean(shared) === Boolean(json['software-type'][option_index].shared))) {
...@@ -846,6 +852,8 @@ ...@@ -846,6 +852,8 @@
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);
// We expect a single possible occurence per software type
break;
} }
} }
} else { } else {
......
...@@ -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.33938.61743.7680</string> </value> <value> <string>1004.26824.9734.39150</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>1669224195.85</float> <float>1668799098.86</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