Commit 25edb671 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Unify status gadget

parent a7f1ec63
......@@ -38,7 +38,7 @@
hidden: 0,
"default": {jio_key: value, result: value},
key: "status",
url: "gadget_slapos_installation_status.html",
url: "gadget_slapos_status.html",
title: "Status",
type: "GadgetField"
}
......
......@@ -281,7 +281,7 @@
</tuple>
<state>
<tuple>
<float>1654875173.93</float>
<float>1655115844.0</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -39,7 +39,7 @@
hidden: 0,
"default": {jio_key: jio_key_value, result: value},
key: "status",
url: "gadget_slapos_instance_status.html",
url: "gadget_slapos_status.html",
title: gadget.title_translation,
type: "GadgetField"
}
......@@ -357,11 +357,11 @@
"description": "",
"title": result[1][23],
"default": {jio_key: gadget.state.jio_key,
result: gadget.state.doc.news},
result: gadget.state.doc},
"css_class": "",
"required": 0,
"editable": 0,
"url": "gadget_slapos_instance_tree_status.html",
"url": "gadget_slapos_status.html",
"sandbox": "",
"key": "monitoring_status",
"hidden": 0,
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>992.39464.63395.50176</string> </value>
<value> <string>999.2068.62564.17</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1623227290.36</float>
<float>1655115718.45</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -63,7 +63,7 @@
hidden: 0,
"default": {jio_key: value_jio_key, result: value},
key: "status",
url: "gadget_slapos_instance_tree_status.html",
url: "gadget_slapos_status.html",
title: gadget.title_translation,
type: "GadgetField"
}
......
......@@ -247,7 +247,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.31175.43828.12919</string> </value>
<value> <string>1000.54051.30712.44322</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -265,7 +265,7 @@
</tuple>
<state>
<tuple>
<float>1654875088.05</float>
<float>1655115677.76</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -30,7 +30,7 @@
hidden: 0,
default: {jio_key: value, result: news},
key: "status",
url: "gadget_slapos_instance_tree_status.html",
url: "gadget_slapos_status.html",
type: "GadgetField"
}
};
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>991.63523.46105.2850</string> </value>
<value> <string>999.2068.62564.17</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1621432757.5</float>
<float>1655115655.51</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -157,7 +157,7 @@
"css_class": "",
"required": 1,
"editable": 0,
"url": "gadget_slapos_installation_status.html",
"url": "gadget_slapos_status.html",
"sandbox": "",
"key": "monitoring_status",
"hidden": 0,
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.11768.7153.56183</string> </value>
<value> <string>999.2068.62564.17</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1602256822.25</float>
<float>1655115861.91</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.41365.5795.26487</string> </value>
<value> <string>1000.58063.29277.1706</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1654159125.9</float>
<float>1655115820.43</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Background</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="gadget_slapos_installation_status.js"></script>
<link href="gadget_slapos_compute_node_status.css" rel="stylesheet" type="text/css"/>
<script id="inline-status-template" type="text/x-handlebars-template">
<div class="ui-block-a" style="width:50%"><div class="ui-bar ui-corner-all first-child {{status_class}}" style="{{status_style}}" >{{status_title}}</div></div>
<div class="ui-block-c" style="width:50%"><div class="ui-bar ui-corner-all last-child {{right_class}}" style="{{right_style}}">{{right_title}}</div></div>
</script>
<script id="loading-template" type="text/x-handlebars-template">
<button data-i18n="loading" type="submit" class="responsive ui-btn ui-icon-spinner ui-icon-spin ui-btn-icon-center ui-disabled" style="border:none;">loading</button>
</script>
</head>
<body>
<div class="ui-block-a" style="width:50%">
<div class="ui-bar ui-corner-all first-child ui-btn-no-data">
<a class="ui-btn ui-btn-icon-left ui-icon-spinner" style="color: white !important;"> Installations </a>
</div>
</div>
</body>
</html>
\ No newline at end of file
/*globals console, window, rJS, RSVP, loopEventListener, i18n, Handlebars, $*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, rJS, RSVP, Handlebars) {
"use strict";
var gadget_klass = rJS(window),
inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template")
.innerHTML,
inline_status_template = Handlebars.compile(inline_status_source);
function checkInstallationStatus(options) {
if ((!options) || (options && !options.news)) {
return 'ui-btn-no-data';
}
if (options.news.text.startsWith("#access")) {
return 'ui-btn-ok';
} else if (options.news.text.startsWith("#building")) {
return 'ui-btn-warning';
} else {
if (options.no_data) {
return 'ui-btn-no-data';
}
return 'ui-btn-error';
}
}
function getStatus(gadget) {
return new RSVP.Queue()
.push(function () {
return gadget.jio_get(gadget.options.value.jio_key);
})
.push(function (result) {
var status_class = 'ui-btn-no-data',
status_title = 'Installation',
status_style = "";
status_class = checkInstallationStatus(result);
if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;";
}
gadget.element.innerHTML = inline_status_template({
status_class: status_class,
status_title: status_title,
status_style: status_style
});
return gadget;
});
}
gadget_klass
.ready(function (gadget) {
gadget.props = {};
return gadget.getSetting("hateoas_url")
.push(function (url) {
gadget.props.hateoas_url = url;
});
})
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareJob("getStatus", function (result) {
var gadget = this,
status_class = 'ui-btn-no-data',
status_title = 'Installation',
status_style = "";
status_class = checkInstallationStatus({news: result});
if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;";
}
gadget.element.innerHTML = inline_status_template({
status_class: status_class,
status_title: status_title,
status_style: status_style
});
return gadget;
})
.onLoop(function () {
var gadget = this;
return getStatus(gadget);
}, 300000)
.declareMethod("render", function (options) {
var gadget = this;
gadget.options = options;
gadget.flag = options.value.jio_key;
return gadget.getStatus(options.value.result);
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Background</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="gadget_slapos_instance_status.js"></script>
<link href="gadget_slapos_compute_node_status.css" rel="stylesheet" type="text/css"/>
<script id="inline-status-no-link-template" type="text/x-handlebars-template">
<div class="ui-block-a" style="width:50%"><div class="ui-bar ui-corner-all first-child {{status_class}}" style="{{status_style}}" >{{status_title}}</div></div>
</script>
<script id="inline-status-template" type="text/x-handlebars-template">
<div class="ui-block-a" style="width:50%"><div class="ui-bar ui-corner-all first-child {{status_class}}" style="{{status_style}}" >
<a class="ui-btn ui-btn-icon-left ui-icon-desktop" href="{{monitor_url}}" target=_blank>{{status_title}}</a></div></div>
</script>
<script id="loading-template" type="text/x-handlebars-template">
<button data-i18n="loading" type="submit" class="responsive ui-btn ui-icon-spinner ui-icon-spin ui-btn-icon-center ui-disabled" style="border:none;">loading</button>
</script>
</head>
<body>
<div class="ui-block-a" style="width:50%">
<div class="ui-bar ui-corner-all first-child ui-btn-no-data">
<a class="ui-btn ui-btn-icon-left ui-icon-spinner" style="color: white !important;"> Instance </a>
</div>
</div>
</body>
</html>
\ No newline at end of file
/*globals console, window, rJS, RSVP, loopEventListener, i18n, Handlebars, $*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, rJS, RSVP, Handlebars) {
"use strict";
var gadget_klass = rJS(window),
inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template")
.innerHTML,
inline_status_template = Handlebars.compile(inline_status_source),
inline_status_no_link_source = gadget_klass.__template_element
.getElementById("inline-status-no-link-template")
.innerHTML,
inline_status_no_link_template = Handlebars
.compile(inline_status_no_link_source);
function checkInstanceStatus(options) {
if ((!options) || (options && !options.news)) {
return 'ui-btn-no-data';
}
if (options.news.text.startsWith("#access")) {
return 'ui-btn-ok';
} else {
if (options.news.no_data) {
return 'ui-btn-no-data';
}
else if (options.news.is_slave) {
return 'ui-btn-is-slave';
}
else if (options.news.is_stopped) {
return 'ui-btn-is-stopped';
}
else if (options.news.is_destroyed) {
return 'ui-btn-is-destroyed';
}
return 'ui-btn-error';
}
}
function getStatus(gadget, result) {
var status_class = 'ui-btn-no-data',
status_title = 'Instance',
status_style = "",
monitor_url,
template = inline_status_template;
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20AND%20reference%3A%22' + result.reference + '%22';
status_class = checkInstanceStatus(result);
if (status_class === 'ui-btn-is-slave') {
status_class = 'ui-btn-no-data';
status_style = "color: white !important;";
status_title = 'Slave';
}
else if (status_class === 'ui-btn-is-stopped') {
status_class = 'ui-btn-no-data';
status_style = "color: white !important;";
status_title = 'Stopped';
}
else if (status_class === 'ui-btn-is-destroyed') {
status_class = 'ui-btn-no-data';
status_style = "color: white !important;";
status_title = 'Destroyed';
}
if (status_class === 'ui-btn-no-data') {
gadget.element.innerHTML = inline_status_no_link_template({
status_class: status_class,
status_title: status_title,
status_style: status_style
});
} else {
gadget.element.innerHTML = inline_status_template({
monitor_url: monitor_url,
status_class: status_class,
status_title: status_title,
status_style: status_style
});
}
return gadget;
}
function getStatusLoop(gadget) {
return new RSVP.Queue()
.push(function () {
return gadget.jio_get(gadget.options.value.jio_key);
})
.push(function (result) {
return getStatus(gadget, result);
});
}
gadget_klass
.ready(function (gadget) {
gadget.props = {};
return gadget.getSetting("hateoas_url")
.push(function (url) {
gadget.props.hateoas_url = url;
});
})
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareJob("getStatus", function (result) {
var gadget = this;
return getStatus(gadget, {news: result});
})
.onLoop(function () {
var gadget = this;
return getStatusLoop(gadget);
}, 300000)
.declareMethod("render", function (options) {
var gadget = this;
gadget.options = options;
gadget.flag = options.value.jio_key;
return gadget.getStatus(options.value.result);
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Background</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="gadget_slapos_instance_tree_status.js"></script>
<link href="gadget_slapos_compute_node_status.css" rel="stylesheet" type="text/css"/>
<script id="inline-status-template" type="text/x-handlebars-template">
<div class="ui-block-a" style="width:50%"><div class="ui-bar ui-corner-all first-child {{status_class}}" style="{{status_style}}" >
<a class="ui-btn ui-btn-icon-left ui-icon-desktop" href="{{monitor_url}}" target=_blank> {{status_title}} </a></div></div>
</script>
<script id="inline-status-no-link-template" type="text/x-handlebars-template">
<div class="ui-block-a" style="width:50%"><div class="ui-bar ui-corner-all first-child {{status_class}}" style="{{status_style}}" >{{status_title}}</div></div>
</script>
<script id="loading-template" type="text/x-handlebars-template">
<button data-i18n="loading" type="submit" class="responsive ui-btn ui-icon-spinner ui-icon-spin ui-btn-icon-center ui-disabled" style="border:none;">loading</button>
</script>
</head>
<body>
<div class="ui-block-a" style="width:50%">
<div class="ui-bar ui-corner-all first-child ui-btn-no-data">
<a class="ui-btn ui-btn-icon-left ui-icon-spinner" style="color: white !important;"> Instances </a>
</div>
</div>
</body>
</html>
\ No newline at end of file
/*globals console, window, rJS, RSVP, loopEventListener, i18n, Handlebars, $*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, rJS, RSVP, Handlebars) {
"use strict";
var gadget_klass = rJS(window),
inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template")
.innerHTML,
inline_status_template = Handlebars.compile(inline_status_source),
inline_status_no_link_source = gadget_klass.__template_element
.getElementById("inline-status-no-link-template")
.innerHTML,
inline_status_no_link_template = Handlebars
.compile(inline_status_no_link_source);
function checkInstanceTreeStatus(options) {
var message,
instance,
partition_class = 'ui-btn-ok',
error_amount = 0,
total_amount = 0;
if ((!options) || (options && !options.instance)) {
return 'ui-btn-no-data';
}
if (options.is_slave) {
return 'ui-btn-is-slave';
}
else if (options.is_stopped) {
return 'ui-btn-is-stopped';
}
else if (options.is_destroyed) {
return 'ui-btn-is-destroyed';
}
for (instance in options.instance) {
message = options.instance[instance].text;
if (message.startsWith("#error")) {
partition_class = 'ui-btn-warning';
error_amount++;
}
total_amount++;
if ((error_amount > 0) && (error_amount < total_amount)) {
// No need to continue the result will be a warnning
return partition_class;
}
}
if (error_amount === total_amount) {
// No need to continue the result will be a warnning
return 'ui-btn-error';
}
return partition_class;
}
function getDoc(gadget) {
if (gadget.options.doc && gadget.options.doc !== undefined) {
return gadget.options.doc;
}
return gadget.jio_get(gadget.options.value.jio_key);
}
function getStatus(gadget, result) {
return new RSVP.Queue()
.push(function () {
return getDoc(gadget);
})
.push(function (jio_doc) {
var monitor_url,
connection_key,
status_class = 'ui-btn-no-data',
status_title = 'Instances',
status_style = "";
result = jio_doc;
status_class = checkInstanceTreeStatus(result.news);
// it should verify if the monitor-base-url is ready.
for (connection_key in result.connection_parameter_list) {
if (result.connection_parameter_list[connection_key].connection_key === "monitor-setup-url") {
monitor_url = result.connection_parameter_list[connection_key].connection_value;
}
}
if (monitor_url === "") {
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type%3A%22Instance%20Tree%22%20AND%20title%3A' + result.title;
}
if (status_class === 'ui-btn-is-slave') {
status_class = 'ui-btn-no-data';
status_style = "color: white !important;";
status_title = 'Slave Only';
}
else if (status_class === 'ui-btn-is-stopped') {
status_class = 'ui-btn-no-data';
status_style = "color: white !important;";
status_title = 'Stopped';
}
else if (status_class === 'ui-btn-is-destroyed') {
status_class = 'ui-btn-no-data';
status_style = "color: white !important;";
status_title = 'Destroyed';
}
if (status_class === 'ui-btn-no-data') {
gadget.element.innerHTML = inline_status_no_link_template({
status_class: status_class,
status_title: status_title,
status_style: status_style
});
} else {
gadget.element.innerHTML = inline_status_template({
monitor_url: monitor_url,
status_class: status_class,
status_title: status_title,
status_style: status_style
});
}
return gadget;
}
);
}
function getStatusLoop(gadget) {
return new RSVP.Queue()
.push(function () {
return gadget.jio_get(gadget.options.value.jio_key);
})
.push(function (result) {
return getStatus(gadget, result);
});
}
gadget_klass
.setState({
has_monitor_info: false
})
.ready(function (gadget) {
gadget.props = {};
return gadget.getSetting("hateoas_url")
.push(function (url) {
gadget.props.hateoas_url = url;
});
})
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareJob("getStatus", function (result) {
var gadget = this;
return getStatus(gadget, {news: result});
})
.onLoop(function () {
var gadget = this;
return getStatusLoop(gadget);
}, 300000)
.declareMethod("render", function (options) {
var gadget = this;
gadget.options = options;
gadget.flag = options.value.jio_key;
return gadget.getStatus(options.value.result);
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
......@@ -24,6 +24,10 @@
color: white !important;
}
.ui-btn-hide {
display: none;
}
.ui-bar {
position: relative;
padding: .4em 1em;
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.54026.12481.29013</string> </value>
<value> <string>1000.57958.38485.23927</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1654873584.88</float>
<float>1655110268.61</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -274,7 +274,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.54027.11178.31948</string> </value>
<value> <string>1000.58055.14909.921</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -292,7 +292,7 @@
</tuple>
<state>
<tuple>
<float>1654873641.14</float>
<float>1655115505.83</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -179,12 +179,6 @@ web_page_module/rjs_gadget_slapos_event_discussion_entry_html
web_page_module/rjs_gadget_slapos_event_discussion_entry_js
web_page_module/rjs_gadget_slapos_header_html
web_page_module/rjs_gadget_slapos_header_js
web_page_module/rjs_gadget_slapos_instance_tree_status_html
web_page_module/rjs_gadget_slapos_instance_tree_status_js
web_page_module/rjs_gadget_slapos_installation_status_html
web_page_module/rjs_gadget_slapos_installation_status_js
web_page_module/rjs_gadget_slapos_instance_status_html
web_page_module/rjs_gadget_slapos_instance_status_js
web_page_module/rjs_gadget_slapos_invoice_printout_html
web_page_module/rjs_gadget_slapos_invoice_printout_js
web_page_module/rjs_gadget_slapos_invoice_state_html
......
......@@ -184,12 +184,6 @@ web_page_module/rjs_gadget_slapos_event_discussion_entry_html
web_page_module/rjs_gadget_slapos_event_discussion_entry_js
web_page_module/rjs_gadget_slapos_header_html
web_page_module/rjs_gadget_slapos_header_js
web_page_module/rjs_gadget_slapos_installation_status_html
web_page_module/rjs_gadget_slapos_installation_status_js
web_page_module/rjs_gadget_slapos_instance_status_html
web_page_module/rjs_gadget_slapos_instance_status_js
web_page_module/rjs_gadget_slapos_instance_tree_status_html
web_page_module/rjs_gadget_slapos_instance_tree_status_js
web_page_module/rjs_gadget_slapos_invoice_printout_html
web_page_module/rjs_gadget_slapos_invoice_printout_js
web_page_module/rjs_gadget_slapos_invoice_state_html
......
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