Commit 73332133 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Refactor Status gadget

   Drop code duplication, clean up code and use changeState()
parent 20299121
...@@ -294,11 +294,12 @@ ...@@ -294,11 +294,12 @@
"description": "", "description": "",
"title": results[2][29], "title": results[2][29],
"default": {jio_key: gadget.state.jio_key, "default": {jio_key: gadget.state.jio_key,
result: gadget.state.doc.news}, result: gadget.state.doc.news,
portal_type: "Compute Node"},
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
"url": "gadget_slapos_compute_node_status.html", "url": "gadget_slapos_status.html",
"sandbox": "", "sandbox": "",
"key": "monitoring_status", "key": "monitoring_status",
"hidden": 0, "hidden": 0,
......
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.49476.87.8891</string> </value> <value> <string>1000.54050.10449.30976</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1617118020.93</float> <float>1654875173.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
css_class: "", css_class: "",
description: "The Status", description: "The Status",
hidden: 0, hidden: 0,
"default": {jio_key: value, result: value}, "default": {jio_key: value, result: value, portal_type: "Compute Node"},
key: "status", key: "status",
url: "gadget_slapos_compute_node_status.html", url: "gadget_slapos_status.html",
title: gadget.title_translation, title: gadget.title_translation,
type: "GadgetField" type: "GadgetField"
} }
...@@ -141,7 +141,6 @@ ...@@ -141,7 +141,6 @@
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
}, },
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": result[1][5], "title": result[1][5],
...@@ -150,7 +149,7 @@ ...@@ -150,7 +149,7 @@
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
"url": "gadget_slapos_network_status.html", "url": "gadget_slapos_status.html",
"sandbox": "", "sandbox": "",
"key": "monitoring_status", "key": "monitoring_status",
"hidden": 0, "hidden": 0,
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11833.796.41028</string> </value> <value> <string>1000.54048.48557.60893</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>1602260725.77</float> <float>1654874936.04</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
hidden: 0, hidden: 0,
"default": {jio_key: value_jio_key, result: value}, "default": {jio_key: value_jio_key, result: value},
key: "status", key: "status",
url: "gadget_slapos_compute_node_status.html", url: "gadget_slapos_status.html",
title: gadget.title_translation, title: gadget.title_translation,
type: "GadgetField" type: "GadgetField"
} }
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
hidden: 0, hidden: 0,
"default": {jio_key: value_jio_key, result: value}, "default": {jio_key: value_jio_key, result: value},
key: "status", key: "status",
url: "gadget_slapos_network_status.html", url: "gadget_slapos_status.html",
title: gadget.title_translation, title: gadget.title_translation,
type: "GadgetField" type: "GadgetField"
} }
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
"url": "gadget_slapos_project_status.html", "url": "gadget_slapos_status.html",
"sandbox": "", "sandbox": "",
"key": "monitoring_status", "key": "monitoring_status",
"hidden": 0, "hidden": 0,
......
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1000.20987.4444.10700</string> </value> <value> <string>1000.31175.43828.12919</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1652891827.46</float> <float>1654875088.05</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
css_class: "", css_class: "",
description: gadget.description_translation, description: gadget.description_translation,
hidden: 0, hidden: 0,
"default": {jio_key: value_jio_key, result: value}, "default": {jio_key: value_jio_key, result: value, portal_type: "Compute Node"},
key: "status", key: "status",
url: "gadget_slapos_compute_node_status.html", url: "gadget_slapos_status.html",
title: gadget.title_translation, title: gadget.title_translation,
type: "GadgetField" type: "GadgetField"
} }
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
"url": "gadget_slapos_site_status.html", "url": "gadget_slapos_status.html",
"sandbox": "", "sandbox": "",
"key": "monitoring_status", "key": "monitoring_status",
"hidden": 0, "hidden": 0,
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11773.24735.44390</string> </value> <value> <string>999.2068.62564.17</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602257151.8</float> <float>1654874891.91</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>986.45437.22132.61764</string> </value> <value> <string>1000.41365.5795.26487</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>1602256742.16</float> <float>1654159125.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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_compute_node_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>
<div class="ui-block-c" style="width:50%"><div class="ui-bar ui-corner-all last-child {{right_class}}" style="{{right_style}}">
<a class="ui-btn ui-btn-icon-left ui-icon-desktop" href="{{monitor_url}}" target=_blank> {{right_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;"> Compute Node </a>
</div>
</div>
<div class="ui-block-c" 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;"> Partitions </a>
</div>
</div>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<list>
<string>Manager</string>
<string>Authenticated</string>
<string>Developer</string>
<string>Owner</string>
</list>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>ERP5TypeTestCase</string>
<string>zope</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_compute_node_status.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_compute_node_status_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523884656.58</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Compute Node Status</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1502472194.78</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.58781.43824.3635</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1530120172.2</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1502472099.8</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*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 checkComputeNodeStatus(options) {
if (!options || !options.news || !options.news.text) {
return 'ui-btn-no-data';
}
if (options.news.text.startsWith("#access")) {
if (options.news.no_data_since_15_minutes) {
return 'ui-btn-error';
}
if (options.news.no_data_since_5_minutes) {
return 'ui-btn-warning';
}
return 'ui-btn-ok';
}
if (options.news.no_data) {
return 'ui-btn-no-data';
}
return 'ui-btn-error';
}
function checkComputePartitionStatus(options) {
var message,
compute_partition,
partition_class = 'ui-btn-ok',
error_amount = 0,
total_amount = 0;
if (!options || !options.compute_partition_news) {
return 'ui-btn-no-data';
}
for (compute_partition in options.compute_partition_news) {
if (options.compute_partition_news.hasOwnProperty(compute_partition) &&
options.compute_partition_news[compute_partition].text) {
message = options.compute_partition_news[compute_partition].text;
if (message.startsWith("#error")) {
partition_class = 'ui-btn-warning';
error_amount += 1;
}
total_amount += 1;
if ((error_amount > 0) && (error_amount < total_amount)) {
// No need to continue the result will be a warnning
return partition_class;
}
}
}
if (total_amount === 0) {
return 'ui-btn-no-data';
}
if (error_amount === total_amount) {
// No need to continue the result will be a warnning
return 'ui-btn-error';
}
return partition_class;
}
function getStatus(gadget, result) {
var monitor_url,
status_class = 'ui-btn-no-data',
status_title = 'Compute Node',
right_title = 'Partitions',
right_class = 'ui-btn-no-data',
status_style = '',
right_style = '';
if (result && result.news && result.news.compute_node) {
status_class = checkComputeNodeStatus({news: result.news.compute_node});
}
if ((status_class === 'ui-btn-error') ||
(status_class === 'ui-btn-no-data')) {
right_class = status_class;
} else {
if (result && result.news && result.news.partition) {
right_class = checkComputePartitionStatus(
{compute_partition_news: result.news.partition}
);
}
}
monitor_url = 'https://monitor.app.officejs.com/#/' +
'?page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20' +
'AND%20aggregate_reference%3A%22' + result.reference + '%22';
gadget.element.innerHTML = inline_status_template({
monitor_url: monitor_url,
status_class: status_class,
status_title: status_title,
status_style: status_style,
right_class: right_class,
right_title: right_title,
right_style: right_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
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<list>
<string>Manager</string>
<string>Authenticated</string>
<string>Developer</string>
<string>Owner</string>
</list>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>ERP5TypeTestCase</string>
<string>zope</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_compute_node_status.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_compute_node_status_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523884656.64</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Compute Node Status JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1503589584.61</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.25610.31873.42666</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1568302726.92</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1503589449.87</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!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_network_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;"> Compute Node </a>
</div>
</div>
<div class="ui-block-c" 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;"> Partitions </a>
</div>
</div>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<list>
<string>Manager</string>
<string>Authenticated</string>
<string>Developer</string>
<string>Owner</string>
</list>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_network_status.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_network_status_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523884657.31</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Network Status</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1510027167.54</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.58781.43824.3635</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1530120141.03</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1510027148.47</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*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 checkComputeNodeStatus(options) {
if (!options) {
return 'ui-btn-no-data';
}
if (options.text.startsWith("#access")) {
if (options.no_data_since_15_minutes) {
return 'ui-btn-error';
}
if (options.no_data_since_5_minutes) {
return 'ui-btn-warning';
}
return 'ui-btn-ok';
} else {
if (options.no_data) {
return 'ui-btn-no-data';
}
return 'ui-btn-error';
}
}
function checkComputePartitionStatus(options) {
var message,
compute_partition,
partition_class = 'ui-btn-ok',
error_amount = 0,
total_amount = 0;
if (!options) {
return 'ui-btn-no-data';
}
for (compute_partition in options) {
message = options[compute_partition].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 (!total_amount) {
return 'ui-btn-no-data';
}
if (error_amount === total_amount) {
return 'ui-btn-error';
}
return partition_class;
}
function checkNetworkStatus(options) {
var previous_status = "START",
status = 'ui-btn-no-data',
i;
for (i in options.news.compute_node) {
status = checkComputeNodeStatus(options.news.compute_node[i]);
if (previous_status === "START") {
previous_status = status;
}
if (previous_status !== status) {
if ((previous_status === 'ui-btn-error') && (status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if ((status === 'ui-btn-error') && (previous_status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if (status === 'ui-btn-no-data') {
status = previous_status;
}
}
}
return status;
}
function checkNetworkPartitionStatus(options) {
var compute_node_reference,
status = 'ui-btn-no-data',
previous_status = "START";
for (compute_node_reference in options.news.partition) {
status = checkComputePartitionStatus(
options.news.partition[compute_node_reference]);
if (previous_status === "START") {
previous_status = status;
}
if (status === 'ui-btn-warning') {
// If status is warning, nothing after will change it.
return status;
}
if (previous_status !== status) {
if ((previous_status === 'ui-btn-error') && (status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if ((status === 'ui-btn-error') && (previous_status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if (status === 'ui-btn-no-data') {
status = previous_status;
}
}
}
return status;
}
function getStatus(gadget, result) {
var status_class = 'ui-btn-no-data',
status_title = 'Compute Node',
right_title = 'Partitions',
right_class = 'ui-btn-no-data';
status_class = checkNetworkStatus(result);
if ((status_class === 'ui-btn-error') ||
(status_class === 'ui-btn-no-data')) {
right_class = status_class;
} else {
right_class = checkNetworkPartitionStatus(result);
}
gadget.element.innerHTML = inline_status_template({
status_class: status_class,
status_title: status_title,
right_class: right_class,
right_title: right_title
});
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
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_network_status.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_network_status_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523884657.33</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Network Status JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1510027216.38</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.62049.17150.785</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1555352227.27</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1510027196.68</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!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_project_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>
<div class="ui-block-c" style="width:50%"><div class="ui-bar ui-corner-all last-child {{right_class}}" style="{{right_style}}">
<a class="ui-btn ui-btn-icon-left ui-icon-desktop" href="{{monitor_url}}" target=_blank> {{right_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;"> Compute Node </a>
</div>
</div>
<div class="ui-block-c" 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;"> Partitions </a>
</div>
</div>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<list>
<string>Manager</string>
<string>Authenticated</string>
<string>Developer</string>
<string>Owner</string>
</list>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_project_status.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_project_status_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523884657.52</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Project Status</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1513177217.87</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.58781.43824.3635</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1530120154.6</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1513176618.65</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_project_status.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_project_status_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523884657.55</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Project Status JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1513177043.03</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.25609.22500.25258</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1568302679.29</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1513176618.6</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!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_site_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>
<div class="ui-block-c" style="width:50%"><div class="ui-bar ui-corner-all last-child {{right_class}}" style="{{right_style}}">
<a class="ui-btn ui-btn-icon-left ui-icon-desktop" href="{{monitor_url}}" target=_blank> {{right_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;"> Compute Node </a>
</div>
</div>
<div class="ui-block-c" 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;"> Partitions </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 checkComputeNodeStatus(options) {
if (!options) {
return 'ui-btn-no-data';
}
if (options.text.startsWith("#access")) {
if (options.no_data_since_15_minutes) {
return 'ui-btn-error';
}
if (options.no_data_since_5_minutes) {
return 'ui-btn-warning';
}
return 'ui-btn-ok';
} else {
if (options.no_data) {
return 'ui-btn-no-data';
}
return 'ui-btn-error';
}
}
function checkComputePartitionStatus(options) {
var message,
compute_partition,
partition_class = 'ui-btn-ok',
error_amount = 0,
total_amount = 0;
if (!options) {
return 'ui-btn-no-data';
}
for (compute_partition in options) {
message = options[compute_partition].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 (!total_amount) {
return 'ui-btn-no-data';
}
if (error_amount === total_amount) {
return 'ui-btn-error';
}
return partition_class;
}
function checkSiteStatus(options) {
var previous_status = "START",
status = 'ui-btn-no-data',
i;
for (i in options.news.compute_node) {
status = checkComputeNodeStatus(options.news.compute_node[i]);
if (previous_status === "START") {
previous_status = status;
}
if (previous_status !== status) {
if ((previous_status === 'ui-btn-error') && (status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if ((status === 'ui-btn-error') && (previous_status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if (status === 'ui-btn-no-data') {
status = previous_status;
}
}
}
return status;
}
function checkSitePartitionStatus(options) {
var compute_node_reference,
status = 'ui-btn-no-data',
previous_status = "START";
for (compute_node_reference in options.news.partition) {
status = checkComputePartitionStatus(
options.news.partition[compute_node_reference]);
if (previous_status === "START") {
previous_status = status;
}
if (status === 'ui-btn-warning') {
// If status is warning, nothing after will change it.
return status;
}
if (previous_status !== status) {
if ((previous_status === 'ui-btn-error') && (status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if ((status === 'ui-btn-error') && (previous_status === 'ui-btn-ok')) {
return 'ui-btn-warning';
}
if (status === 'ui-btn-no-data') {
status = previous_status;
}
}
}
return status;
}
function getStatus(gadget, result) {
var monitor_url,
status_class = 'ui-btn-no-data',
status_title = 'Compute Node',
right_title = 'Partitions',
right_class = 'ui-btn-no-data',
status_style = '',
right_style = '';
status_class = checkSiteStatus(result);
if ((status_class === 'ui-btn-error') ||
(status_class === 'ui-btn-no-data')) {
right_class = status_class;
} else {
right_class = checkSitePartitionStatus(result);
}
monitor_url = gadget.props.hateoas_url + gadget.options.value.jio_key + '/Base_redirectToMonitor';
gadget.element.innerHTML = inline_status_template({
monitor_url: monitor_url,
status_class: status_class,
status_title: status_title,
status_style: status_style,
right_class: right_class,
right_title: right_title,
right_style: right_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
...@@ -16,6 +16,14 @@ ...@@ -16,6 +16,14 @@
clear: left; clear: left;
} }
.ui-block-50 {
width: 50%;
}
.ui-btn-color-white {
color: white !important;
}
.ui-bar { .ui-bar {
position: relative; position: relative;
padding: .4em 1em; padding: .4em 1em;
......
...@@ -71,11 +71,13 @@ ...@@ -71,11 +71,13 @@
</item> </item>
<item> <item>
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/css</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_compute_node_status.css</string> </value> <value> <string>gadget_slapos_status.css</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -85,7 +87,7 @@ ...@@ -85,7 +87,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_compute_node_status_css</string> </value> <value> <string>rjs_gadget_slapos_status_css</string> </value>
</item> </item>
<item> <item>
<key> <string>language</string> </key> <key> <string>language</string> </key>
...@@ -103,7 +105,7 @@ ...@@ -103,7 +105,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Gadget SlapOS Compute Node Status</string> </value> <value> <string>Gadget SlapOS Status</string> </value>
</item> </item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
...@@ -240,7 +242,7 @@ ...@@ -240,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>992.39464.63395.50176</string> </value> <value> <string>1000.54026.12481.29013</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +260,7 @@ ...@@ -258,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1623147492.18</float> <float>1654873584.88</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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="domsugar.js"></script>
<script src="gadget_slapos_status.js"></script>
<link href="gadget_slapos_status.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="ui-block-a ui-block-50 compute-node-status">
<div class="ui-bar ui-corner-all first-child ui-btn-no-data">
<a class="ui-btn ui-btn-icon-left ui-icon-spinner ui-btn-color-white"> Compute Node </a>
</div>
</div>
<div class="ui-block-c ui-block-50 compute-partition-status">
<div class="ui-bar ui-corner-all first-child ui-btn-no-data">
<a class="ui-btn ui-btn-icon-left ui-icon-spinner ui-btn-color-white"> Partitions </a>
</div>
</div>
</body>
</html>
\ No newline at end of file
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
</item> </item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_site_status.html</string> </value> <value> <string>gadget_slapos_status.html</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_site_status_html</string> </value> <value> <string>rjs_gadget_slapos_status_html</string> </value>
</item> </item>
<item> <item>
<key> <string>language</string> </key> <key> <string>language</string> </key>
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Gadget SlapOS Site Status</string> </value> <value> <string>Gadget SlapOS Status</string> </value>
</item> </item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>966.58781.43824.3635</string> </value> <value> <string>1000.54027.62249.36386</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -296,7 +296,7 @@ ...@@ -296,7 +296,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1530120162.62</float> <float>1654874040.84</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*globals console, window, rJS, RSVP, loopEventListener, i18n, Handlebars, $*/ /*globals console, window, rJS, i18n, domsugar*/
/*jslint indent: 2, nomen: true, maxlen: 90*/ /*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, domsugar) {
"use strict"; "use strict";
var gadget_klass = rJS(window), 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 checkComputeNodeStatus(options) { function getComputeNodeStatus(options) {
if (!options || !options.text) { if (!options || !options.text) {
return 'ui-btn-no-data'; return 'ui-btn-no-data';
} }
...@@ -28,7 +24,7 @@ ...@@ -28,7 +24,7 @@
return 'ui-btn-error'; return 'ui-btn-error';
} }
function checkComputePartitionStatus(options) { function getComputePartitionStatus(options) {
var message, var message,
compute_partition, compute_partition,
partition_class = 'ui-btn-ok', partition_class = 'ui-btn-ok',
...@@ -48,7 +44,6 @@ ...@@ -48,7 +44,6 @@
error_amount += 1; error_amount += 1;
} }
total_amount += 1; total_amount += 1;
if ((error_amount > 0) && (error_amount < total_amount)) { if ((error_amount > 0) && (error_amount < total_amount)) {
// No need to continue the result will be a warnning // No need to continue the result will be a warnning
return partition_class; return partition_class;
...@@ -65,7 +60,7 @@ ...@@ -65,7 +60,7 @@
return partition_class; return partition_class;
} }
function checkProjectStatus(options) { function getComputeNodeStatusList(options) {
var previous_status = "START", var previous_status = "START",
status = 'ui-btn-no-data', status = 'ui-btn-no-data',
i; i;
...@@ -74,7 +69,7 @@ ...@@ -74,7 +69,7 @@
} }
for (i in options.news.compute_node) { for (i in options.news.compute_node) {
if (options.news.compute_node.hasOwnProperty(i)) { if (options.news.compute_node.hasOwnProperty(i)) {
status = checkComputeNodeStatus(options.news.compute_node[i]); status = getComputeNodeStatus(options.news.compute_node[i]);
if (previous_status === "START") { if (previous_status === "START") {
previous_status = status; previous_status = status;
} }
...@@ -94,15 +89,14 @@ ...@@ -94,15 +89,14 @@
return status; return status;
} }
function checkProjectPartitionStatus(options) { function getComputePartitionStatusList(options) {
var compute_node_reference, var compute_node_reference,
status = 'ui-btn-no-data', status = 'ui-btn-no-data',
previous_status = "START"; previous_status = "START";
for (compute_node_reference in options.news.partition) { for (compute_node_reference in options.news.partition) {
if (options.news.partition.hasOwnProperty(compute_node_reference)) { if (options.news.partition.hasOwnProperty(compute_node_reference)) {
status = checkComputePartitionStatus( status = getComputePartitionStatus(
options.news.partition[compute_node_reference] options.news.partition[compute_node_reference]);
);
if (previous_status === "START") { if (previous_status === "START") {
previous_status = status; previous_status = status;
} }
...@@ -126,76 +120,95 @@ ...@@ -126,76 +120,95 @@
return status; return status;
} }
function getStatus(gadget, result) { function getStatus(gadget, result) {
var monitor_url, var status_class = 'ui-btn-no-data',
status_class = 'ui-btn-no-data',
status_title = 'Compute Node',
right_title = 'Partitions',
right_class = 'ui-btn-no-data', right_class = 'ui-btn-no-data',
status_style = '', computer_node_div = gadget.element.querySelector("compute-node-status"),
right_style = ''; compute_partition_div = gadget.element.querySelector("compute-node-status"),
monitor_url = '';
status_class = checkProjectStatus(result); if (result && result.portal_type && result.portal_type === "Compute Node") {
if ((status_class === 'ui-btn-error') || monitor_url = 'https://monitor.app.officejs.com/#/' +
(status_class === 'ui-btn-no-data')) { '?page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20' +
right_class = status_class; 'AND%20aggregate_reference%3A%22' + result.reference + '%22';
if (result && result.news && result.news.compute_node) {
status_class = getComputeNodeStatus({news: result.news.compute_node});
}
if ((status_class === 'ui-btn-error') ||
(status_class === 'ui-btn-no-data')) {
right_class = status_class;
} else {
if (result && result.news && result.news.partition) {
right_class = getComputePartitionStatus(
{compute_partition_news: result.news.partition}
);
}
}
} else { } else {
right_class = checkProjectPartitionStatus(result); monitor_url = gadget.options.value.jio_key + '/Base_redirectToMonitor';
status_class = getComputeNodeStatusList(result);
if ((status_class === 'ui-btn-error') ||
(status_class === 'ui-btn-no-data')) {
right_class = status_class;
} else {
right_class = getComputePartitionStatusList(result);
}
} }
monitor_url = gadget.props.hateoas_url + domsugar(computer_node_div.firstChild,
gadget.options.value.jio_key + '/Base_redirectToMonitor'; {
gadget.element.innerHTML = inline_status_template({ class: "ui-bar ui-corner-all first-child " + status_class
monitor_url: monitor_url, }, [
status_class: status_class, domsugar("a",
status_title: status_title, {
status_style: status_style, class: "ui-btn ui-btn-icon-left ui-icon-desktop",
right_class: right_class, href: monitor_url,
right_title: right_title, target: "_blank",
right_style: right_style // missing translation
}); text: 'Compute Node'
})
]);
domsugar(compute_partition_div.firstChild,
{
class: "ui-bar ui-corner-all last-child " + right_class
}, [
domsugar("a",
{
class: "ui-btn ui-btn-icon-left ui-icon-desktop",
href: monitor_url,
target: "_blank",
// missing translation
text: 'Partitions'
})
]);
return gadget; 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 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("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () { .declareMethod("getContent", function () {
return {}; return {};
}) })
.declareJob("getStatus", function (result) {
var gadget = this;
return getStatus(gadget, {news: result});
})
.onLoop(function () { .onLoop(function () {
var gadget = this; var gadget = this;
return getStatusLoop(gadget); if (gadget.state.jio_key) {
return gadget.jio_get(gadget.state.jio_key)
.push(function (result) {
return gadget.changeState(result);
});
}
}, 300000) }, 300000)
.onStateChange(function () {
return getStatus(this, this.state);
})
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this; var state_dict = options.value.result;
gadget.options = options; state_dict.jio_key = options.value.jio_key;
gadget.flag = options.value.jio_key; return this.changeState(state_dict);
return gadget.getStatus(options.value.result);
}); });
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file }(window, rJS, domsugar));
\ No newline at end of file
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
</item> </item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_site_status.js</string> </value> <value> <string>gadget_slapos_status.js</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>rjs_gadget_slapos_site_status_js</string> </value> <value> <string>rjs_gadget_slapos_status_js</string> </value>
</item> </item>
<item> <item>
<key> <string>language</string> </key> <key> <string>language</string> </key>
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Gadget SlapOS Site Status JS</string> </value> <value> <string>Gadget SlapOS Status JS</string> </value>
</item> </item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.62049.17150.785</string> </value> <value> <string>1000.54027.11178.31948</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1555352069.34</float> <float>1654873641.14</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -173,9 +173,7 @@ web_page_module/rjs_gadget_slapos_alert_listbox_field_js ...@@ -173,9 +173,7 @@ web_page_module/rjs_gadget_slapos_alert_listbox_field_js
web_page_module/rjs_gadget_slapos_appcache web_page_module/rjs_gadget_slapos_appcache
web_page_module/rjs_gadget_slapos_compute_node_map_html web_page_module/rjs_gadget_slapos_compute_node_map_html
web_page_module/rjs_gadget_slapos_compute_node_map_js web_page_module/rjs_gadget_slapos_compute_node_map_js
web_page_module/rjs_gadget_slapos_compute_node_status_css web_page_module/rjs_gadget_slapos_status_css
web_page_module/rjs_gadget_slapos_compute_node_status_html
web_page_module/rjs_gadget_slapos_compute_node_status_js
web_page_module/rjs_gadget_slapos_event_discussion_entry_css web_page_module/rjs_gadget_slapos_event_discussion_entry_css
web_page_module/rjs_gadget_slapos_event_discussion_entry_html 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_event_discussion_entry_js
...@@ -193,15 +191,11 @@ web_page_module/rjs_gadget_slapos_invoice_state_html ...@@ -193,15 +191,11 @@ web_page_module/rjs_gadget_slapos_invoice_state_html
web_page_module/rjs_gadget_slapos_invoice_state_js web_page_module/rjs_gadget_slapos_invoice_state_js
web_page_module/rjs_gadget_slapos_label_listbox_field_html web_page_module/rjs_gadget_slapos_label_listbox_field_html
web_page_module/rjs_gadget_slapos_label_listbox_field_js web_page_module/rjs_gadget_slapos_label_listbox_field_js
web_page_module/rjs_gadget_slapos_network_status_html
web_page_module/rjs_gadget_slapos_network_status_js
web_page_module/rjs_gadget_slapos_panel_html web_page_module/rjs_gadget_slapos_panel_html
web_page_module/rjs_gadget_slapos_panel_js web_page_module/rjs_gadget_slapos_panel_js
web_page_module/rjs_gadget_slapos_payment_result_js** web_page_module/rjs_gadget_slapos_payment_result_js**
web_page_module/rjs_gadget_slapos_project_status_html web_page_module/rjs_gadget_slapos_status_html
web_page_module/rjs_gadget_slapos_project_status_js web_page_module/rjs_gadget_slapos_status_js
web_page_module/rjs_gadget_slapos_site_status_html
web_page_module/rjs_gadget_slapos_site_status_js
web_page_module/rjs_gadget_slapos_translation_data_js web_page_module/rjs_gadget_slapos_translation_data_js
web_page_module/rjs_gadget_slapos_translation_html web_page_module/rjs_gadget_slapos_translation_html
web_page_module/rjs_gadget_trial_panel_html web_page_module/rjs_gadget_trial_panel_html
...@@ -213,12 +207,10 @@ web_page_module/rjs_slapos_load_meta_schema_json ...@@ -213,12 +207,10 @@ web_page_module/rjs_slapos_load_meta_schema_json
web_page_module/rjs_slapos_load_meta_schema_xml_in_json_json web_page_module/rjs_slapos_load_meta_schema_xml_in_json_json
web_page_module/rjs_slapos_load_meta_schema_xml_json web_page_module/rjs_slapos_load_meta_schema_xml_json
web_page_module/rjs_slapos_load_software_schema_json web_page_module/rjs_slapos_load_software_schema_json
web_page_module/rjs_gadget_erp5_page_slapos_access_html
web_page_module/rjs_gadget_erp5_page_slapos_access_js
web_page_module/rjs_gadget_slapos_login_page_css web_page_module/rjs_gadget_slapos_login_page_css
web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_html web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_html
web_page_module/rjs_tv4_min_js web_page_module/rjs_tv4_min_js
web_page_module/rjs_vkbeautify_js web_page_module/rjs_vkbeautify_js
web_site_module/hostingjs web_site_module/hostingjs
web_site_module/hostingjs/** web_site_module/hostingjs/**
\ No newline at end of file
...@@ -157,8 +157,6 @@ web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html ...@@ -157,8 +157,6 @@ web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html
web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_js web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_js
web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_html web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_html
web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_js web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_js
web_page_module/rjs_gadget_erp5_page_slapos_access_html
web_page_module/rjs_gadget_erp5_page_slapos_access_js
web_page_module/rjs_gadget_erp5_page_slapos_css web_page_module/rjs_gadget_erp5_page_slapos_css
web_page_module/rjs_gadget_erp5_page_slapos_html web_page_module/rjs_gadget_erp5_page_slapos_html
web_page_module/rjs_gadget_erp5_page_slapos_html web_page_module/rjs_gadget_erp5_page_slapos_html
...@@ -181,9 +179,6 @@ web_page_module/rjs_gadget_slapos_annotated_helper_js ...@@ -181,9 +179,6 @@ web_page_module/rjs_gadget_slapos_annotated_helper_js
web_page_module/rjs_gadget_slapos_appcache web_page_module/rjs_gadget_slapos_appcache
web_page_module/rjs_gadget_slapos_compute_node_map_html web_page_module/rjs_gadget_slapos_compute_node_map_html
web_page_module/rjs_gadget_slapos_compute_node_map_js web_page_module/rjs_gadget_slapos_compute_node_map_js
web_page_module/rjs_gadget_slapos_compute_node_status_css
web_page_module/rjs_gadget_slapos_compute_node_status_html
web_page_module/rjs_gadget_slapos_compute_node_status_js
web_page_module/rjs_gadget_slapos_event_discussion_entry_css web_page_module/rjs_gadget_slapos_event_discussion_entry_css
web_page_module/rjs_gadget_slapos_event_discussion_entry_html 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_event_discussion_entry_js
...@@ -202,15 +197,12 @@ web_page_module/rjs_gadget_slapos_invoice_state_js ...@@ -202,15 +197,12 @@ web_page_module/rjs_gadget_slapos_invoice_state_js
web_page_module/rjs_gadget_slapos_label_listbox_field_html web_page_module/rjs_gadget_slapos_label_listbox_field_html
web_page_module/rjs_gadget_slapos_label_listbox_field_js web_page_module/rjs_gadget_slapos_label_listbox_field_js
web_page_module/rjs_gadget_slapos_login_page_css web_page_module/rjs_gadget_slapos_login_page_css
web_page_module/rjs_gadget_slapos_network_status_html
web_page_module/rjs_gadget_slapos_network_status_js
web_page_module/rjs_gadget_slapos_panel_html web_page_module/rjs_gadget_slapos_panel_html
web_page_module/rjs_gadget_slapos_panel_js web_page_module/rjs_gadget_slapos_panel_js
web_page_module/rjs_gadget_slapos_payment_result_js** web_page_module/rjs_gadget_slapos_payment_result_js**
web_page_module/rjs_gadget_slapos_project_status_html web_page_module/rjs_gadget_slapos_status_css
web_page_module/rjs_gadget_slapos_project_status_js web_page_module/rjs_gadget_slapos_status_html
web_page_module/rjs_gadget_slapos_site_status_html web_page_module/rjs_gadget_slapos_status_js
web_page_module/rjs_gadget_slapos_site_status_js
web_page_module/rjs_gadget_slapos_translation_data_js web_page_module/rjs_gadget_slapos_translation_data_js
web_page_module/rjs_gadget_slapos_translation_html web_page_module/rjs_gadget_slapos_translation_html
web_page_module/rjs_gadget_slapos_utils_js web_page_module/rjs_gadget_slapos_utils_js
......
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