Commit 69bb9229 authored by Rafael Monnerat's avatar Rafael Monnerat

Refactor status gadget (unify)

See merge request nexedi/slapos.core!394
parents a0e68da7 c90d01c9
...@@ -78,7 +78,9 @@ class SlapOSCacheMixin: ...@@ -78,7 +78,9 @@ class SlapOSCacheMixin:
'since': '%s' % last_modified, 'since': '%s' % last_modified,
'state': "", 'state': "",
"text": "#error no data found for %s" % self.getReference(), "text": "#error no data found for %s" % self.getReference(),
"no_data": 1 "no_data": 1,
'reference': self.getReference(),
'portal_type': self.getPortalType()
} }
# Prepare for xml marshalling # Prepare for xml marshalling
#data_dict["text"] = data_dict["text"].decode("UTF-8") #data_dict["text"] = data_dict["text"].decode("UTF-8")
...@@ -128,7 +130,9 @@ class SlapOSCacheMixin: ...@@ -128,7 +130,9 @@ class SlapOSCacheMixin:
'created_at': '%s' % created_at, 'created_at': '%s' % created_at,
'text': '%s' % text, 'text': '%s' % text,
'since': '%s' % since, 'since': '%s' % since,
'state': state 'state': state,
'reference': self.getReference(),
'portal_type': self.getPortalType()
}) })
cache_duration = self._getAccessStatusCacheFactory().cache_duration cache_duration = self._getAccessStatusCacheFactory().cache_duration
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SlapOSCacheMixin</string> </value> <value> <string>SlapOSCacheMixin</string> </value>
...@@ -61,28 +55,13 @@ ...@@ -61,28 +55,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -95,7 +74,7 @@ ...@@ -95,7 +74,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -104,7 +83,7 @@ ...@@ -104,7 +83,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -163,20 +163,11 @@ url_list = [ ...@@ -163,20 +163,11 @@ url_list = [
"gadget_erp5_attention_point.js", "gadget_erp5_attention_point.js",
"gadget_slapos_compute_node_map.html", "gadget_slapos_compute_node_map.html",
"gadget_slapos_compute_node_map.js", "gadget_slapos_compute_node_map.js",
"gadget_slapos_compute_node_status.css",
"gadget_slapos_compute_node_status.html",
"gadget_slapos_compute_node_status.js",
"gadget_slapos_event_discussion_entry.css", "gadget_slapos_event_discussion_entry.css",
"gadget_slapos_event_discussion_entry.html", "gadget_slapos_event_discussion_entry.html",
"gadget_slapos_event_discussion_entry.js", "gadget_slapos_event_discussion_entry.js",
"gadget_slapos_header.html", "gadget_slapos_header.html",
"gadget_slapos_header.js", "gadget_slapos_header.js",
"gadget_slapos_instance_tree_status.html",
"gadget_slapos_instance_tree_status.js",
"gadget_slapos_installation_status.html",
"gadget_slapos_installation_status.js",
"gadget_slapos_instance_status.html",
"gadget_slapos_instance_status.js",
"gadget_slapos_invoice_printout.html", "gadget_slapos_invoice_printout.html",
"gadget_slapos_invoice_printout.js", "gadget_slapos_invoice_printout.js",
"gadget_slapos_invoice_state.html", "gadget_slapos_invoice_state.html",
...@@ -186,17 +177,14 @@ url_list = [ ...@@ -186,17 +177,14 @@ url_list = [
"gadget_slapos_alert_listbox_field.js", "gadget_slapos_alert_listbox_field.js",
"gadget_slapos_alert_listbox_field.css", "gadget_slapos_alert_listbox_field.css",
"gadget_slapos_alert_listbox_field.html", "gadget_slapos_alert_listbox_field.html",
"gadget_slapos_network_status.html",
"gadget_slapos_network_status.js",
"gadget_slapos_panel.html", "gadget_slapos_panel.html",
"gadget_slapos_panel.js", "gadget_slapos_panel.js",
"gadget_slapos_panel.png?format=png", "gadget_slapos_panel.png?format=png",
"gadget_slapos_invoice_logo.png?format=", "gadget_slapos_invoice_logo.png?format=",
"gadget_slapos_payment_result.js", "gadget_slapos_payment_result.js",
"gadget_slapos_project_status.html", "gadget_slapos_status.css",
"gadget_slapos_project_status.js", "gadget_slapos_status.html",
"gadget_slapos_site_status.html", "gadget_slapos_status.js",
"gadget_slapos_site_status.js",
"gadget_slapos_utils.js", "gadget_slapos_utils.js",
"leaflet.css", "leaflet.css",
"leaflet.js", "leaflet.js",
......
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
tmp.style['min-width'] = '210px'; tmp.style['min-width'] = '210px';
container.appendChild(tmp); container.appendChild(tmp);
e.target._queue.push(function () { e.target._queue.push(function () {
return gadget.declareGadget('gadget_slapos_site_status.html', { return gadget.declareGadget('gadget_slapos_status.html', {
element: tmp element: tmp
}); });
}) })
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>superrafael</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.51816.55280.41267</string> </value> <value> <string>1001.24988.19785.29030</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>1554319312.07</float> <float>1656977110.45</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -30,9 +30,10 @@ ...@@ -30,9 +30,10 @@
description: "The Status", description: "The Status",
hidden: 0, hidden: 0,
"default": {jio_key: value, "default": {jio_key: value,
result: news}, result: news,
portal_type: "Compute Node"},
key: "status", key: "status",
url: "gadget_slapos_compute_node_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
type: "GadgetField" type: "GadgetField"
} }
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>995.25915.28776.41745</string> </value> <value> <string>1001.20429.28253.1211</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>1634219804.24</float> <float>1656703797.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument") .declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
...@@ -36,9 +35,12 @@ ...@@ -36,9 +35,12 @@
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: "Software Installation"},
key: "status", key: "status",
url: "gadget_slapos_installation_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
type: "GadgetField" type: "GadgetField"
} }
...@@ -294,11 +296,12 @@ ...@@ -294,11 +296,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.58064.4435.24422</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>1656716026.45</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument") .declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
...@@ -27,18 +28,23 @@ ...@@ -27,18 +28,23 @@
var gadget = this; var gadget = this;
return gadget.jio_allDocs(param_list[0]) return gadget.jio_allDocs(param_list[0])
.push(function (result) { .push(function (result) {
var i, value, len = result.data.total_rows; var i, value, news, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (1 || (result.data.rows[i].value.hasOwnProperty("ComputeNode_getNewsDict"))) { if (1 || (result.data.rows[i].value.hasOwnProperty("ComputeNode_getNewsDict"))) {
value = result.data.rows[i].value.ComputeNode_getNewsDict; value = result.data.rows[i].id;
news = result.data.rows[i].value.ComputeNode_getNewsDict;
result.data.rows[i].value.ComputeNode_getNewsDict = { result.data.rows[i].value.ComputeNode_getNewsDict = {
field_gadget_param : { field_gadget_param : {
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: news,
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"
} }
...@@ -102,7 +108,8 @@ ...@@ -102,7 +108,8 @@
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
gadget.getDeclaredGadget('form_view'), gadget.getDeclaredGadget('form_view'),
gadget.getTranslationList(translation_list) gadget.getTranslationList(translation_list),
gadget.getSetting("hateoas_url")
]); ]);
}) })
.push(function (result) { .push(function (result) {
...@@ -141,7 +148,6 @@ ...@@ -141,7 +148,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 +156,7 @@ ...@@ -150,7 +156,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,
...@@ -186,11 +192,11 @@ ...@@ -186,11 +192,11 @@
"editable_column_list": [], "editable_column_list": [],
"key": "slap_project_compute_node_listbox", "key": "slap_project_compute_node_listbox",
"lines": 10, "lines": 10,
"list_method": "portal_catalog", "list_method": "ComputerNetwork_getComputeNodeList",
// XXX TODO Filter by default_strict_allocation_scope_uid="!=%s" % context.getPortalObject().portal_categories.allocation_scope.close.forever.getUid(), "list_method_template": result[2] + "ERP5Document_getHateoas?mode=search&" +
"query": "urn:jio:allDocs?query=portal_type%3A%22" + "list_method=ComputerNetwork_getComputeNodeList&relative_url=" +
"Compute Node" + "%22%20AND%20" + gadget.state.jio_key + "&default_param_json=eyJpZ25vcmVfdW5rbm93bl9jb2x1bW5zIjogdHJ1ZX0={&query,select_list*,limit*,sort_on*,local_roles*}",
"subordination_reference%3A" + gadget.state.doc.reference, "query": "urn:jio:allDocs?query=",
"portal_type": [], "portal_type": [],
"search_column_list": column_list, "search_column_list": column_list,
"sort_column_list": column_list, "sort_column_list": column_list,
......
...@@ -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>1001.44818.54264.13038</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>1658167069.0</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
hidden: 0, hidden: 0,
"default": {jio_key: jio_key_value, result: value}, "default": {jio_key: jio_key_value, result: value},
key: "status", key: "status",
url: "gadget_slapos_instance_status.html", url: "gadget_slapos_status.html",
title: gadget.title_translation, title: gadget.title_translation,
type: "GadgetField" type: "GadgetField"
} }
...@@ -357,11 +357,11 @@ ...@@ -357,11 +357,11 @@
"description": "", "description": "",
"title": result[1][23], "title": result[1][23],
"default": {jio_key: gadget.state.jio_key, "default": {jio_key: gadget.state.jio_key,
result: gadget.state.doc.news}, result: gadget.state.doc},
"css_class": "", "css_class": "",
"required": 0, "required": 0,
"editable": 0, "editable": 0,
"url": "gadget_slapos_instance_tree_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>992.39464.63395.50176</string> </value> <value> <string>999.2068.62564.17</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>1623227290.36</float> <float>1655115718.45</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
"default": {jio_key: value, "default": {jio_key: value,
result: news}, result: news},
key: "status", key: "status",
url: "gadget_slapos_network_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
type: "GadgetField" type: "GadgetField"
} }
......
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.16656.9604.44475</string> </value> <value> <string>1000.2322.46712.16657</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>1584111719.27</float> <float>1656703774.51</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
hidden: 0, hidden: 0,
"default": {jio_key: value, result: news}, "default": {jio_key: value, result: news},
key: "status", key: "status",
url: "gadget_slapos_project_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
type: "GadgetField" type: "GadgetField"
} }
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.32516.46874.3959</string> </value> <value> <string>1000.2322.46712.16657</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>1584107816.84</float> <float>1656975508.53</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"
} }
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,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_instance_tree_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.54051.30712.44322</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>1655115677.76</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
hidden: 0, hidden: 0,
default: {jio_key: value, result: news}, default: {jio_key: value, result: news},
key: "status", key: "status",
url: "gadget_slapos_instance_tree_status.html", url: "gadget_slapos_status.html",
type: "GadgetField" type: "GadgetField"
} }
}; };
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>991.63523.46105.2850</string> </value> <value> <string>999.2068.62564.17</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>1621432757.5</float> <float>1655115655.51</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,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_site_status.html', url: 'gadget_slapos_status.html',
title: 'Status', title: 'Status',
type: 'GadgetField' type: 'GadgetField'
} }
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>994.33249.63216.2816</string> </value> <value> <string>999.2068.62564.17</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>1630552438.1</float> <float>1656975585.67</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>
......
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
"url": "gadget_slapos_installation_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.11768.7153.56183</string> </value> <value> <string>999.2068.62564.17</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>1602256822.25</float> <float>1655115861.91</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -162,11 +162,15 @@ ...@@ -162,11 +162,15 @@
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": result[2][2], "title": result[2][2],
"default": {jio_key: gadget.state.jio_key}, "default": {
jio_key: gadget.state.jio_key,
result: gadget.state.doc.news,
portal_type: gadget.state.doc.portal_type
},
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 0, "editable": 0,
"url": "gadget_slapos_instance_status.html", "url": "gadget_slapos_status.html",
"sandbox": "", "sandbox": "",
"key": "monitoring_status", "key": "monitoring_status",
"hidden": gadget.state.doc.portal_type === "Slave Instance", "hidden": gadget.state.doc.portal_type === "Slave Instance",
......
...@@ -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.58063.29277.1706</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>1655115820.43</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
...@@ -26,7 +28,10 @@ ...@@ -26,7 +28,10 @@
.onEvent('submit', function () { .onEvent('submit', function () {
var gadget = this; var gadget = this;
return gadget.getDeclaredGadget('form_view') return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return form_gadget.getContent();
}) })
...@@ -37,9 +42,13 @@ ...@@ -37,9 +42,13 @@
url + doc.relative_url + "/InstanceTree_requestPerson", {state: "started"}); url + doc.relative_url + "/InstanceTree_requestPerson", {state: "started"});
}); });
}) })
.push(function () {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", "options": {"page": "slap_controller"}}); return gadget.redirect({"command": "change",
"options": {"page": "slap_controller"}});
});
}); });
}) })
...@@ -52,7 +61,9 @@ ...@@ -52,7 +61,9 @@
page_title_translation, page_title_translation,
translation_list = [ translation_list = [
"Parent Relative Url", "Parent Relative Url",
"Start Instance Tree:" "Start Instance Tree:",
"Service is Started."
]; ];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -65,6 +76,7 @@ ...@@ -65,6 +76,7 @@
.push(function (result) { .push(function (result) {
options.doc = result[1]; options.doc = result[1];
page_title_translation = result[2][1]; page_title_translation = result[2][1];
gadget.message_translation = result[2][2];
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
"_embedded": {"_view": { "_embedded": {"_view": {
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11753.9371.59426</string> </value> <value> <string>1001.45009.50995.61354</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602256083.33</float> <float>1658181254.36</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_post", "jio_post")
...@@ -26,7 +28,10 @@ ...@@ -26,7 +28,10 @@
.onEvent('submit', function () { .onEvent('submit', function () {
var gadget = this; var gadget = this;
return gadget.getDeclaredGadget('form_view') return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return form_gadget.getContent();
}) })
...@@ -37,9 +42,13 @@ ...@@ -37,9 +42,13 @@
url + doc.relative_url + "/InstanceTree_requestPerson", {state: "stopped"}); url + doc.relative_url + "/InstanceTree_requestPerson", {state: "stopped"});
}); });
}) })
.push(function () {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", "options": {"page": "slap_controller"}}); return gadget.redirect({"command": "change",
"options": {"page": "slap_controller"}});
});
}); });
}) })
...@@ -52,7 +61,9 @@ ...@@ -52,7 +61,9 @@
page_title_translation, page_title_translation,
translation_list = [ translation_list = [
"Parent Relative Url", "Parent Relative Url",
"Stop Instance Tree:" "Stop Instance Tree:",
"Service is Stopped."
]; ];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -65,6 +76,7 @@ ...@@ -65,6 +76,7 @@
.push(function (result) { .push(function (result) {
options.doc = result[1]; options.doc = result[1];
page_title_translation = result[2][1]; page_title_translation = result[2][1];
gadget.message_translation = result[2][2];
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
"_embedded": {"_view": { "_embedded": {"_view": {
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11752.29554.51882</string> </value> <value> <string>1001.45008.17324.2952</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602255869.31</float> <float>1658207423.89</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1000.49354.9268.54869</string> </value> <value> <string>1000.49358.11392.5905</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1654593490.4</float> <float>1656976881.1</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,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_site_status.html", url: "gadget_slapos_status.html",
title: "Status", title: "Status",
type: "GadgetField" type: "GadgetField"
} }
......
...@@ -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.49340.48222.40550</string> </value> <value> <string>1000.49358.14576.324</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>1654593493.33</float> <float>1656976814.1</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
/*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
<!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
<!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
/*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
<!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
<!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
...@@ -16,6 +16,18 @@ ...@@ -16,6 +16,18 @@
clear: left; clear: left;
} }
.ui-block-50 {
width: 50%;
}
.ui-btn-color-white {
color: white !important;
}
.ui-btn-hide {
display: none;
}
.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.57958.38485.23927</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>1655110268.61</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -10,4 +10,7 @@ for compute_node in compute_node_list: ...@@ -10,4 +10,7 @@ for compute_node in compute_node_list:
compute_partition_dict[compute_node.getReference()] = news_dict["partition"] compute_partition_dict[compute_node.getReference()] = news_dict["partition"]
return {"compute_node": compute_node_dict, return {"compute_node": compute_node_dict,
"partition": compute_partition_dict} "partition": compute_partition_dict,
"reference": context.getReference(),
"portal_type": context.getPortalType(),
"monitor_url": context.Base_getStatusMonitorUrl()}
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Base_redirectToMonitor</string> </value> <value> <string>Base_getStatusMonitorUrl</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
This diff is collapsed.
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