Commit 0f0c3ffb authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_parameter_editor: Display "Empty" as error if instance tree is empty

   If the instance empty dont display green but red, indicating something is wrong.

   Clean up and minimize the configuration a bit more, so it is easy to navigate.
parent a4bfd4e2
...@@ -72,33 +72,11 @@ ...@@ -72,33 +72,11 @@
.ui-btn-no-data a, .ui-btn-no-data a,
.ui-btn-no-data:active a, .ui-btn-no-data:active a,
.ui-btn-no-data:hover a { .ui-btn-no-data:hover a {
color: grey !important;
background: grey !important;
text-align: center;
}
.ui-btn-color-white,
.ui-btn-color-white:active,
.ui-btn-color-white:hover,
.ui-btn-color-white a,
.ui-btn-color-white:active a,
.ui-btn-color-white:hover a {
color: white !important; color: white !important;
background: grey !important; background: grey !important;
text-align: center; text-align: center;
} }
.ui-btn-white,
.ui-btn-white:active,
.ui-btn-white:hover,
.ui-btn-white a,
.ui-btn-white:active a,
.ui-btn-white:hover a {
background: white !important;
text-align: center;
}
a.ui-icon-desktop::before { a.ui-icon-desktop::before {
margin-left: 5px; margin-left: 5px;
} }
......
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
return 'ui-btn-no-data'; return 'ui-btn-no-data';
} }
if (!options.instance.length) {
return 'ui-btn-is-empty';
}
for (instance in options.instance) { for (instance in options.instance) {
if (options.instance.hasOwnProperty(instance)) { if (options.instance.hasOwnProperty(instance)) {
if (options.instance[instance].text.startsWith("#error")) { if (options.instance[instance].text.startsWith("#error")) {
...@@ -129,10 +133,10 @@ ...@@ -129,10 +133,10 @@
function getStatus(gadget, result) { function getStatus(gadget, result) {
var status_class = 'ui-btn-no-data', var status_class = 'ui-btn-no-data',
main_status_div = gadget.element.querySelector(".main-status"), status_div = gadget.element.querySelector(".main-status"),
monitor_url = '', monitor_url = '',
main_link_configuration_dict = { configuration_dict = {
"class": "ui-btn ui-btn-icon-left ui-icon-desktop" "class": "ui-btn ui-btn-icon-left"
}; };
if (result && result.monitor_url) { if (result && result.monitor_url) {
...@@ -140,78 +144,74 @@ ...@@ -140,78 +144,74 @@
} }
if (result && result.portal_type && result.portal_type === "Compute Node") { if (result && result.portal_type && result.portal_type === "Compute Node") {
main_link_configuration_dict.text = 'Node'; configuration_dict.text = 'Node';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
status_class = getComputeNodeStatus(result); status_class = getComputeNodeStatus(result);
} else if (result && result.portal_type && } else if (result && result.portal_type &&
result.portal_type === "Software Installation") { result.portal_type === "Software Installation") {
status_class = getSoftwareInstallationStatus(result); status_class = getSoftwareInstallationStatus(result);
main_link_configuration_dict.text = "Installation"; configuration_dict.text = "Installation";
if (status_class === "ui-btn-is-building") { if (status_class === "ui-btn-is-building") {
main_link_configuration_dict.text = "Building"; configuration_dict.text = "Building";
status_class = "ui-btn-no-data"; status_class = "ui-btn-no-data";
} else if (status_class === "ui-btn-ok") { } else if (status_class === "ui-btn-ok") {
main_link_configuration_dict.text = "Available"; configuration_dict.text = "Available";
} else if (status_class === "ui-btn-error") { } else if (status_class === "ui-btn-error") {
main_link_configuration_dict.text = "Error"; configuration_dict.text = "Error";
} }
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
} else if (result && result.portal_type && ( } else if (result && result.portal_type && (
result.portal_type === "Software Instance" || result.portal_type === "Software Instance" ||
result.portal_type === "Slave Instance" result.portal_type === "Slave Instance"
)) { )) {
configuration_dict.text = 'Instance';
status_class = getInstanceStatus(result); status_class = getInstanceStatus(result);
if (status_class === 'ui-btn-is-slave') { if (status_class === 'ui-btn-is-slave') {
status_class = 'ui-btn-color-white'; status_class = 'ui-btn-no-data';
main_link_configuration_dict.text = 'Slave'; configuration_dict.text = 'Slave';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
} else if (status_class === 'ui-btn-is-stopped') { } else if (status_class === 'ui-btn-is-stopped') {
status_class = 'ui-btn-color-white'; status_class = 'ui-btn-no-data';
main_link_configuration_dict.text = 'Stopped'; configuration_dict.text = 'Stopped';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
} else if (status_class === 'ui-btn-is-destroyed') { } else if (status_class === 'ui-btn-is-destroyed') {
status_class = 'ui-btn-color-white'; status_class = 'ui-btn-no-data';
main_link_configuration_dict.text = 'Destroyed'; configuration_dict.text = 'Destroyed';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
} else { } else {
main_link_configuration_dict.href = monitor_url; configuration_dict.href = monitor_url;
main_link_configuration_dict.target = "_target"; configuration_dict.target = "_target";
main_link_configuration_dict.text = 'Instance'; configuration_dict["class"] += "ui-icon-desktop";
} }
} else if (result && result.portal_type && } else if (result && result.portal_type &&
result.portal_type === "Instance Tree") { result.portal_type === "Instance Tree") {
configuration_dict.text = 'Instance';
status_class = getInstanceTreeStatus(result); status_class = getInstanceTreeStatus(result);
// it should verify if the monitor-base-url is ready. // it should verify if the monitor-base-url is ready.
if (status_class === 'ui-btn-is-slave') { if (status_class === 'ui-btn-is-slave') {
status_class = 'ui-btn-color-white'; status_class = 'ui-btn-no-data';
main_link_configuration_dict.text = 'Slave Only'; configuration_dict.text = 'Slave Only';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
} else if (status_class === 'ui-btn-is-stopped') { } else if (status_class === 'ui-btn-is-stopped') {
status_class = 'ui-btn-color-white'; status_class = 'ui-btn-no-data';
main_link_configuration_dict.text = 'Stopped'; configuration_dict.text = 'Stopped';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left"; } else if (status_class === 'ui-btn-is-empty') {
status_class = 'ui-btn-error';
configuration_dict.text = 'Empty';
} else if (status_class === 'ui-btn-is-destroyed') { } else if (status_class === 'ui-btn-is-destroyed') {
status_class = 'ui-btn-color-white'; status_class = 'ui-btn-no-data';
main_link_configuration_dict.text = 'Destroyed'; configuration_dict.text = 'Destroyed';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
} else { } else {
main_link_configuration_dict.href = monitor_url; configuration_dict.href = monitor_url;
main_link_configuration_dict.target = "_target"; configuration_dict.target = "_target";
main_link_configuration_dict.text = 'Instance'; configuration_dict["class"] += " ui-icon-desktop";
} }
} else { } else {
main_link_configuration_dict.text = 'Node'; configuration_dict.text = 'Node';
main_link_configuration_dict["class"] = "ui-btn ui-btn-icon-left";
status_class = getComputeNodeStatusList(result); status_class = getComputeNodeStatusList(result);
} }
main_link_configuration_dict.text = ' ' + main_link_configuration_dict.text; configuration_dict.text = ' ' + configuration_dict.text;
domsugar(main_status_div.querySelector('div'), domsugar(status_div.querySelector('div'),
{ {
"class": "ui-bar ui-corner-all first-child " + status_class "class": "ui-bar ui-corner-all first-child " + status_class
}, [ }, [
domsugar(main_link_configuration_dict.href ? "a" : "span", domsugar(configuration_dict.href ? "a" : "span",
main_link_configuration_dict) configuration_dict)
]); ]);
return gadget; return gadget;
} }
......
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