Commit 01bfd371 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Use onLoop instead RSVP.delay and make a major clean up on the code.

parent a298c46e
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
<script src="gadget_slapos_computer_status.js"></script> <script src="gadget_slapos_computer_status.js"></script>
<link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/> <link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/>
<script id="sensor-status-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child {{status_class}}" data-i18n={{status_title}} >{{status_title}}</a></li>
<li><a class="ui-btn ui-first-child {{right_class}}" style="{{right_style}}">{{right_title}}</a></li>
</ul>
</script>
<script id="inline-status-template" type="text/x-handlebars-template"> <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}}" > <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> <a class="ui-btn ui-btn-icon-left ui-icon-desktop" href={{monitor_url}} target=_blank> {{status_title}} </a></div></div>
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -73,6 +84,15 @@ ...@@ -73,6 +84,15 @@
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/html</string> </value> <value> <string>text/html</string> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>ERP5TypeTestCase</string>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_computer_status.html</string> </value> <value> <string>gadget_slapos_computer_status.html</string> </value>
...@@ -91,6 +111,25 @@ ...@@ -91,6 +111,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value> <value> <string>Web Page</string> </value>
...@@ -234,7 +273,7 @@ ...@@ -234,7 +273,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.65216.36649.54425</string> </value> <value> <string>966.58781.43824.3635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +291,7 @@ ...@@ -252,7 +291,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520342668.3</float> <float>1530120172.2</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,18 +4,10 @@ ...@@ -4,18 +4,10 @@
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
sensor_status_source = gadget_klass.__template_element
.getElementById("sensor-status-template")
.innerHTML,
sensor_status_template = Handlebars.compile(sensor_status_source),
inline_status_source = gadget_klass.__template_element inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template") .getElementById("inline-status-template")
.innerHTML, .innerHTML,
inline_status_template = Handlebars.compile(inline_status_source), inline_status_template = Handlebars.compile(inline_status_source);
loading_source = gadget_klass.__template_element
.getElementById("loading-template")
.innerHTML,
loading_template = Handlebars.compile(loading_source);
function checkComputerStatus(options) { function checkComputerStatus(options) {
if ((!options) || (options && !options.news)) { if ((!options) || (options && !options.news)) {
...@@ -73,89 +65,70 @@ ...@@ -73,89 +65,70 @@
return partition_class; return partition_class;
} }
gadget_klass function getStatus(gadget) {
.ready(function (gadget) { return new RSVP.Queue()
gadget.props = {}; .push(function () {
return gadget.getSetting("hateoas_url") return gadget.jio_get(gadget.options.value.jio_key);
.push(function (url) {
gadget.props.hateoas_url = url;
});
})
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareMethod("render", function (options) {
var gadget = this,
status_style,
middle_style,
queue = new RSVP.Queue();
function getComputerStatus(options) {
queue.push(function () {
return gadget.jio_get(options.value.jio_key);
// return gadget.jio_get("computer_module/20171103-94D99B");
}) })
.push(function (result) { .push(function (result) {
var project, var monitor_url,
data_supply_line,
data_supply_line_list,
count = 0,
tmp,
sum = 0,
i,
no_data = true,
no_data_since_24_hours = true,
value = "",
template,
monitor_url,
status_class = 'ui-btn-no-data', status_class = 'ui-btn-no-data',
status_title = 'Computer', status_title = 'Computer',
right_title = 'Partitions', right_title = 'Partitions',
right_class = 'ui-btn-no-data', right_class = 'ui-btn-no-data',
status_style = "color: transparent !important;", status_style = '',
right_style = 'color: transparent !important;'; right_style = '';
if ((options.value !== undefined) && (options.doc === undefined)) {
options.doc = options.value.doc;
}
status_class = checkComputerStatus(result); status_class = checkComputerStatus(result);
right_class = checkComputerPartitionStatus(result); right_class = checkComputerPartitionStatus(result);
i = options;
// right_title = value.max? Math.round(value.max * 100 * 10) / 10 + '%': 'nan';
right_style = '';
status_style = '';
template = inline_status_template;
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20AND%20aggregate_reference%3A%22' + result.reference + '%22'; monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20AND%20aggregate_reference%3A%22' + result.reference + '%22';
if (status_class === 'ui-btn-no-data') { if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;"; status_style = "color: transparent !important;";
//monitor_url = "";
} }
gadget.element.innerHTML = template({ gadget.element.innerHTML = inline_status_template({
monitor_url: monitor_url, monitor_url: monitor_url,
status_class: status_class, status_class: status_class,
status_title: status_title, status_title: status_title,
status_style: status_style, status_style: status_style,
middle_style: middle_style,
right_class: right_class, right_class: right_class,
right_title: right_title, right_title: right_title,
right_style: right_style right_style: right_style
}); });
return RSVP.delay(300000); return gadget;
})
.push(function () {
gadget.element.innerHTML = loading_template();
return getComputerStatus(options);
}); });
} }
return queue.push(getComputerStatus(options));
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 () {
var gadget = this;
return getStatus(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();
}); });
}(window, rJS, RSVP, Handlebars)); }(window, rJS, RSVP, Handlebars));
\ No newline at end of file
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -69,6 +80,15 @@ ...@@ -69,6 +80,15 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>ERP5TypeTestCase</string>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_computer_status.js</string> </value> <value> <string>gadget_slapos_computer_status.js</string> </value>
...@@ -87,6 +107,25 @@ ...@@ -87,6 +107,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -230,7 +269,7 @@ ...@@ -230,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.42326.49975.23552</string> </value> <value> <string>968.33041.14393.16810</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +287,7 @@ ...@@ -248,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520343714.57</float> <float>1530119165.7</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,13 +12,6 @@ ...@@ -12,13 +12,6 @@
<script src="gadget_slapos_hosting_subscription_status.js"></script> <script src="gadget_slapos_hosting_subscription_status.js"></script>
<link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/> <link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/>
<script id="sensor-status-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child {{status_class}}" data-i18n={{status_title}} >{{status_title}}</a></li>
</ul>
</script>
<script id="inline-status-template" type="text/x-handlebars-template"> <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}}" > <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> <a class="ui-btn ui-btn-icon-left ui-icon-desktop" href="{{monitor_url}}" target=_blank> {{status_title}} </a></div></div>
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -73,6 +84,14 @@ ...@@ -73,6 +84,14 @@
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/html</string> </value> <value> <string>text/html</string> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_hosting_subscription_status.html</string> </value> <value> <string>gadget_slapos_hosting_subscription_status.html</string> </value>
...@@ -91,6 +110,25 @@ ...@@ -91,6 +110,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.83</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value> <value> <string>Web Page</string> </value>
...@@ -234,7 +272,7 @@ ...@@ -234,7 +272,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.42084.6603.48605</string> </value> <value> <string>968.33074.267.61440</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +290,7 @@ ...@@ -252,7 +290,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520343086.84</float> <float>1530120259.86</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,18 +4,10 @@ ...@@ -4,18 +4,10 @@
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
sensor_status_source = gadget_klass.__template_element
.getElementById("sensor-status-template")
.innerHTML,
sensor_status_template = Handlebars.compile(sensor_status_source),
inline_status_source = gadget_klass.__template_element inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template") .getElementById("inline-status-template")
.innerHTML, .innerHTML,
inline_status_template = Handlebars.compile(inline_status_source), inline_status_template = Handlebars.compile(inline_status_source);
loading_source = gadget_klass.__template_element
.getElementById("loading-template")
.innerHTML,
loading_template = Handlebars.compile(loading_source);
function checkHostingSubscriptionStatus(options) { function checkHostingSubscriptionStatus(options) {
var message, var message,
...@@ -52,78 +44,62 @@ ...@@ -52,78 +44,62 @@
return partition_class; return partition_class;
} }
gadget_klass function getStatus(gadget) {
.ready(function (gadget) { return new RSVP.Queue()
gadget.props = {}; .push(function () {
return gadget.getSetting("hateoas_url") return gadget.jio_get(gadget.options.value.jio_key);
.push(function (url) {
gadget.props.hateoas_url = url;
});
})
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareMethod("render", function (options) {
var gadget = this,
status_style,
middle_style,
queue = new RSVP.Queue();
function getInstallationStatus(options) {
queue.push(function () {
return gadget.jio_get(options.value.jio_key);
}) })
.push(function (result) { .push(function (result) {
var project, var monitor_url,
data_supply_line,
data_supply_line_list,
count = 0,
tmp,
sum = 0,
i,
no_data = true,
no_data_since_24_hours = true,
value = "",
template,
monitor_url,
status_class = 'ui-btn-no-data', status_class = 'ui-btn-no-data',
status_title = 'Instances', status_title = 'Instances',
status_style = "color: transparent !important;"; status_style = "";
if ((options.value !== undefined) && (options.doc === undefined)) {
options.doc = options.value.doc;
}
status_class = checkHostingSubscriptionStatus(result); status_class = checkHostingSubscriptionStatus(result);
status_style = '';
template = inline_status_template;
monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type%3A%22Hosting%20Subscription%22%20AND%20title%3A' + result.title; monitor_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type%3A%22Hosting%20Subscription%22%20AND%20title%3A' + result.title;
if (status_class === 'ui-btn-no-data') { if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;"; status_style = "color: transparent !important;";
} }
gadget.element.innerHTML = inline_status_template({
gadget.element.innerHTML = template({
monitor_url: monitor_url, monitor_url: monitor_url,
status_class: status_class, status_class: status_class,
status_title: status_title, status_title: status_title,
status_style: status_style, status_style: status_style
middle_style: middle_style
}); });
return RSVP.delay(300000); return gadget;
}) }
);
}
.push(function () { gadget_klass
gadget.element.innerHTML = loading_template(); .ready(function (gadget) {
return getInstallationStatus(options); gadget.props = {};
return gadget.getSetting("hateoas_url")
.push(function (url) {
gadget.props.hateoas_url = url;
}); });
} })
return queue.push(getInstallationStatus(options)); .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareJob("getStatus", function () {
var gadget = this;
return getStatus(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();
}); });
}(window, rJS, RSVP, Handlebars)); }(window, rJS, RSVP, Handlebars));
\ No newline at end of file
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_hosting_subscription_status.js</string> </value> <value> <string>gadget_slapos_hosting_subscription_status.js</string> </value>
...@@ -87,6 +95,25 @@ ...@@ -87,6 +95,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.86</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -216,7 +243,7 @@ ...@@ -216,7 +243,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +257,7 @@ ...@@ -230,7 +257,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>964.17481.5463.24917</string> </value> <value> <string>968.33068.10194.31522</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +275,7 @@ ...@@ -248,7 +275,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519209652.66</float> <float>1530119779.91</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
<script src="gadget_slapos_installation_status.js"></script> <script src="gadget_slapos_installation_status.js"></script>
<link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/> <link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/>
<script id="sensor-status-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child {{status_class}}" data-i18n={{status_title}} >{{status_title}}</a></li>
<li><a class="ui-btn ui-first-child {{right_class}}" style="{{right_style}}">{{right_title}}</a></li>
</ul>
</script>
<script id="inline-status-template" type="text/x-handlebars-template"> <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-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> <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>
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -73,6 +84,14 @@ ...@@ -73,6 +84,14 @@
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/html</string> </value> <value> <string>text/html</string> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_installation_status.html</string> </value> <value> <string>gadget_slapos_installation_status.html</string> </value>
...@@ -91,6 +110,25 @@ ...@@ -91,6 +110,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.9</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value> <value> <string>Web Page</string> </value>
...@@ -234,7 +272,7 @@ ...@@ -234,7 +272,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.65289.26932.60672</string> </value> <value> <string>966.58781.43824.3635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +290,7 @@ ...@@ -252,7 +290,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520343230.79</float> <float>1530120100.87</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,18 +4,10 @@ ...@@ -4,18 +4,10 @@
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
sensor_status_source = gadget_klass.__template_element
.getElementById("sensor-status-template")
.innerHTML,
sensor_status_template = Handlebars.compile(sensor_status_source),
inline_status_source = gadget_klass.__template_element inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template") .getElementById("inline-status-template")
.innerHTML, .innerHTML,
inline_status_template = Handlebars.compile(inline_status_source), inline_status_template = Handlebars.compile(inline_status_source);
loading_source = gadget_klass.__template_element
.getElementById("loading-template")
.innerHTML,
loading_template = Handlebars.compile(loading_source);
function checkInstallationStatus(options) { function checkInstallationStatus(options) {
if ((!options) || (options && !options.news)) { if ((!options) || (options && !options.news)) {
...@@ -33,6 +25,29 @@ ...@@ -33,6 +25,29 @@
} }
} }
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 gadget_klass
.ready(function (gadget) { .ready(function (gadget) {
gadget.props = {}; gadget.props = {};
...@@ -48,61 +63,20 @@ ...@@ -48,61 +63,20 @@
.declareMethod("getContent", function () { .declareMethod("getContent", function () {
return {}; return {};
}) })
.declareMethod("render", function (options) { .declareJob("getStatus", function () {
var gadget = this, var gadget = this;
status_style, return getStatus(gadget);
middle_style,
queue = new RSVP.Queue();
function getInstallationStatus(options) {
queue.push(function () {
return gadget.jio_get(options.value.jio_key);
}) })
.push(function (result) { .onLoop(function () {
var project, var gadget = this;
data_supply_line, return getStatus(gadget);
data_supply_line_list, }, 300000)
count = 0,
tmp,
sum = 0,
i,
no_data = true,
no_data_since_24_hours = true,
value = "",
template,
status_class = 'ui-btn-no-data',
status_title = 'Installation',
status_style = "color: transparent !important;";
if ((options.value !== undefined) && (options.doc === undefined)) {
options.doc = options.value.doc;
}
status_class = checkInstallationStatus(result);
// i = options; .declareMethod("render", function (options) {
// right_title = value.max? Math.round(value.max * 100 * 10) / 10 + '%': 'nan'; var gadget = this;
status_style = ''; gadget.options = options;
gadget.flag = options.value.jio_key;
template = inline_status_template; return gadget.getStatus();
if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;";
}
gadget.element.innerHTML = template({
status_class: status_class,
status_title: status_title,
status_style: status_style,
middle_style: middle_style
}); });
return RSVP.delay(300000);
})
.push(function () {
gadget.element.innerHTML = loading_template();
return getInstallationStatus(options);
});
}
return queue.push(getInstallationStatus(options));
});
}(window, rJS, RSVP, Handlebars)); }(window, rJS, RSVP, Handlebars));
\ No newline at end of file
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_installation_status.js</string> </value> <value> <string>gadget_slapos_installation_status.js</string> </value>
...@@ -87,6 +95,25 @@ ...@@ -87,6 +95,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.94</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -216,7 +243,7 @@ ...@@ -216,7 +243,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +257,7 @@ ...@@ -230,7 +257,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.19451.40512.41966</string> </value> <value> <string>968.33049.60346.61764</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +275,7 @@ ...@@ -248,7 +275,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519209691.44</float> <float>1530119205.48</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,13 +12,6 @@ ...@@ -12,13 +12,6 @@
<script src="gadget_slapos_instance_status.js"></script> <script src="gadget_slapos_instance_status.js"></script>
<link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/> <link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/>
<script id="sensor-status-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child {{status_class}}" data-i18n={{status_title}} >{{status_title}}</a></li>
</ul>
</script>
<script id="inline-status-template" type="text/x-handlebars-template"> <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-a" style="width:50%"><div class="ui-bar ui-corner-all first-child {{status_class}}" style="{{status_style}}" >{{status_title}}</div></div>
</script> </script>
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -73,6 +84,14 @@ ...@@ -73,6 +84,14 @@
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/html</string> </value> <value> <string>text/html</string> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_instance_status.html</string> </value> <value> <string>gadget_slapos_instance_status.html</string> </value>
...@@ -91,6 +110,25 @@ ...@@ -91,6 +110,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.03</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value> <value> <string>Web Page</string> </value>
...@@ -234,7 +272,7 @@ ...@@ -234,7 +272,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.19451.40512.41966</string> </value> <value> <string>966.58781.43824.3635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +290,7 @@ ...@@ -252,7 +290,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520343033.6</float> <float>1530120129.88</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,18 +4,10 @@ ...@@ -4,18 +4,10 @@
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
sensor_status_source = gadget_klass.__template_element
.getElementById("sensor-status-template")
.innerHTML,
sensor_status_template = Handlebars.compile(sensor_status_source),
inline_status_source = gadget_klass.__template_element inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template") .getElementById("inline-status-template")
.innerHTML, .innerHTML,
inline_status_template = Handlebars.compile(inline_status_source), inline_status_template = Handlebars.compile(inline_status_source);
loading_source = gadget_klass.__template_element
.getElementById("loading-template")
.innerHTML,
loading_template = Handlebars.compile(loading_source);
function checkInstanceStatus(options) { function checkInstanceStatus(options) {
if ((!options) || (options && !options.news)) { if ((!options) || (options && !options.news)) {
...@@ -31,6 +23,30 @@ ...@@ -31,6 +23,30 @@
} }
} }
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 = 'Instance',
status_style = "";
status_class = checkInstanceStatus(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 gadget_klass
.ready(function (gadget) { .ready(function (gadget) {
gadget.props = {}; gadget.props = {};
...@@ -46,59 +62,20 @@ ...@@ -46,59 +62,20 @@
.declareMethod("getContent", function () { .declareMethod("getContent", function () {
return {}; return {};
}) })
.declareMethod("render", function (options) { .declareJob("getStatus", function () {
var gadget = this, var gadget = this;
status_style, return getStatus(gadget);
middle_style,
queue = new RSVP.Queue();
function getInstallationStatus(options) {
queue.push(function () {
return gadget.jio_get(options.value.jio_key);
}) })
.push(function (result) { .onLoop(function () {
var project, var gadget = this;
data_supply_line, return getStatus(gadget);
data_supply_line_list, }, 300000)
count = 0,
tmp,
sum = 0,
i,
no_data = true,
no_data_since_24_hours = true,
value = "",
template,
status_class = 'ui-btn-no-data',
status_title = 'Instance',
status_style = "color: transparent !important;";
if ((options.value !== undefined) && (options.doc === undefined)) {
options.doc = options.value.doc;
}
status_class = checkInstanceStatus(result);
status_style = '';
template = inline_status_template;
if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;";
}
gadget.element.innerHTML = template({ .declareMethod("render", function (options) {
status_class: status_class, var gadget = this;
status_title: status_title, gadget.options = options;
status_style: status_style, gadget.flag = options.value.jio_key;
middle_style: middle_style return gadget.getStatus();
}); });
return RSVP.delay(300000);
})
.push(function () {
gadget.element.innerHTML = loading_template();
return getInstallationStatus(options);
});
}
return queue.push(getInstallationStatus(options));
});
}(window, rJS, RSVP, Handlebars)); }(window, rJS, RSVP, Handlebars));
\ No newline at end of file
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_instance_status.js</string> </value> <value> <string>gadget_slapos_instance_status.js</string> </value>
...@@ -87,6 +95,25 @@ ...@@ -87,6 +95,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.06</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -216,7 +243,7 @@ ...@@ -216,7 +243,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +257,7 @@ ...@@ -230,7 +257,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.19451.40512.41966</string> </value> <value> <string>968.33056.31297.6997</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +275,7 @@ ...@@ -248,7 +275,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519209680.32</float> <float>1530119074.09</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
<script src="gadget_slapos_network_status.js"></script> <script src="gadget_slapos_network_status.js"></script>
<link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/> <link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/>
<script id="sensor-status-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child {{status_class}}" data-i18n={{status_title}} >{{status_title}}</a></li>
<li><a class="ui-btn ui-first-child {{right_class}}" style="{{right_style}}">{{right_title}}</a></li>
</ul>
</script>
<script id="inline-status-template" type="text/x-handlebars-template"> <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-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> <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>
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -73,6 +84,14 @@ ...@@ -73,6 +84,14 @@
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/html</string> </value> <value> <string>text/html</string> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_network_status.html</string> </value> <value> <string>gadget_slapos_network_status.html</string> </value>
...@@ -91,6 +110,25 @@ ...@@ -91,6 +110,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value> <value> <string>Web Page</string> </value>
...@@ -234,7 +272,7 @@ ...@@ -234,7 +272,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.19451.40512.41966</string> </value> <value> <string>966.58781.43824.3635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +290,7 @@ ...@@ -252,7 +290,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520342734.64</float> <float>1530120141.03</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,18 +4,10 @@ ...@@ -4,18 +4,10 @@
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
sensor_status_source = gadget_klass.__template_element
.getElementById("sensor-status-template")
.innerHTML,
sensor_status_template = Handlebars.compile(sensor_status_source),
inline_status_source = gadget_klass.__template_element inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template") .getElementById("inline-status-template")
.innerHTML, .innerHTML,
inline_status_template = Handlebars.compile(inline_status_source), inline_status_template = Handlebars.compile(inline_status_source);
loading_source = gadget_klass.__template_element
.getElementById("loading-template")
.innerHTML,
loading_template = Handlebars.compile(loading_source);
function checkComputerStatus(options) { function checkComputerStatus(options) {
if (!options) { if (!options) {
...@@ -125,85 +117,68 @@ ...@@ -125,85 +117,68 @@
return status; return status;
} }
function getStatus(gadget) {
gadget_klass return new RSVP.Queue()
.ready(function (gadget) { .push(function () {
gadget.props = {}; return gadget.jio_get(gadget.options.value.jio_key);
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 {};
})
.declareMethod("render", function (options) {
var gadget = this,
status_style,
middle_style,
queue = new RSVP.Queue();
function getNetworkStatus(options) {
queue.push(function () {
return gadget.jio_get(options.value.jio_key);
}) })
.push(function (result) { .push(function (result) {
var project, var status_class = 'ui-btn-no-data',
data_supply_line,
data_supply_line_list,
count = 0,
tmp,
sum = 0,
i,
no_data = true,
no_data_since_24_hours = true,
value = "",
template,
status_class = 'ui-btn-no-data',
status_title = 'Computer', status_title = 'Computer',
right_title = 'Partitions', right_title = 'Partitions',
right_class = 'ui-btn-no-data', right_class = 'ui-btn-no-data',
status_style = "color: transparent !important;", status_style = '',
right_style = 'color: transparent !important;'; right_style = '';
if ((options.value !== undefined) && (options.doc === undefined)) {
options.doc = options.value.doc;
}
status_class = checkNetworkStatus(result); status_class = checkNetworkStatus(result);
right_class = checkNetworkPartitionStatus(result); right_class = checkNetworkPartitionStatus(result);
i = options;
// right_title = value.max? Math.round(value.max * 100 * 10) / 10 + '%': 'nan';
right_style = '';
status_style = '';
template = inline_status_template;
if (status_class === 'ui-btn-no-data') { if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;"; status_style = "color: transparent !important;";
} }
gadget.element.innerHTML = template({ gadget.element.innerHTML = inline_status_template({
status_class: status_class, status_class: status_class,
status_title: status_title, status_title: status_title,
status_style: status_style, status_style: status_style,
middle_style: middle_style,
right_class: right_class, right_class: right_class,
right_title: right_title, right_title: right_title,
right_style: right_style right_style: right_style
}); });
return RSVP.delay(300000); return gadget;
})
.push(function () {
gadget.element.innerHTML = loading_template();
return getNetworkStatus(options);
}); });
} }
return queue.push(getNetworkStatus(options));
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 () {
var gadget = this;
return getStatus(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();
});
}(window, rJS, RSVP, Handlebars)); }(window, rJS, RSVP, Handlebars));
\ No newline at end of file
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_network_status.js</string> </value> <value> <string>gadget_slapos_network_status.js</string> </value>
...@@ -87,6 +95,25 @@ ...@@ -87,6 +95,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -216,7 +243,7 @@ ...@@ -216,7 +243,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +257,7 @@ ...@@ -230,7 +257,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>964.7092.16949.32648</string> </value> <value> <string>968.33063.24201.50227</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +275,7 @@ ...@@ -248,7 +275,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519209669.69</float> <float>1530119497.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
<script src="gadget_slapos_project_status.js"></script> <script src="gadget_slapos_project_status.js"></script>
<link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/> <link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/>
<script id="sensor-status-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child {{status_class}}" data-i18n={{status_title}} >{{status_title}}</a></li>
<li><a class="ui-btn ui-first-child {{right_class}}" style="{{right_style}}">{{right_title}}</a></li>
</ul>
</script>
<script id="inline-status-template" type="text/x-handlebars-template"> <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}}" > <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> <a class="ui-btn ui-btn-icon-left ui-icon-desktop" href={{monitor_url}} target=_blank> {{status_title}} </a></div></div>
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -73,6 +84,14 @@ ...@@ -73,6 +84,14 @@
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/html</string> </value> <value> <string>text/html</string> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_project_status.html</string> </value> <value> <string>gadget_slapos_project_status.html</string> </value>
...@@ -91,6 +110,25 @@ ...@@ -91,6 +110,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value> <value> <string>Web Page</string> </value>
...@@ -234,7 +272,7 @@ ...@@ -234,7 +272,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.42084.41084.17220</string> </value> <value> <string>966.58781.43824.3635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +290,7 @@ ...@@ -252,7 +290,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520342719.17</float> <float>1530120154.6</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,18 +4,10 @@ ...@@ -4,18 +4,10 @@
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
sensor_status_source = gadget_klass.__template_element
.getElementById("sensor-status-template")
.innerHTML,
sensor_status_template = Handlebars.compile(sensor_status_source),
inline_status_source = gadget_klass.__template_element inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template") .getElementById("inline-status-template")
.innerHTML, .innerHTML,
inline_status_template = Handlebars.compile(inline_status_source), inline_status_template = Handlebars.compile(inline_status_source);
loading_source = gadget_klass.__template_element
.getElementById("loading-template")
.innerHTML,
loading_template = Handlebars.compile(loading_source);
function checkComputerStatus(options) { function checkComputerStatus(options) {
if (!options) { if (!options) {
...@@ -126,87 +118,69 @@ ...@@ -126,87 +118,69 @@
} }
gadget_klass function getStatus(gadget) {
.ready(function (gadget) { return new RSVP.Queue()
gadget.props = {}; .push(function () {
return gadget.getSetting("hateoas_url") return gadget.jio_get(gadget.options.value.jio_key);
.push(function (url) {
gadget.props.hateoas_url = url;
});
})
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareMethod("render", function (options) {
var gadget = this,
status_style,
middle_style,
queue = new RSVP.Queue();
function getStatus(options) {
queue.push(function () {
return gadget.jio_get(options.value.jio_key);
}) })
.push(function (result) { .push(function (result) {
var project, var monitor_url,
data_supply_line,
data_supply_line_list,
count = 0,
tmp,
sum = 0,
i,
no_data = true,
no_data_since_24_hours = true,
value = "",
template,
monitor_url,
status_class = 'ui-btn-no-data', status_class = 'ui-btn-no-data',
status_title = 'Computer', status_title = 'Computer',
right_title = 'Partitions', right_title = 'Partitions',
right_class = 'ui-btn-no-data', right_class = 'ui-btn-no-data',
status_style = "color: transparent !important;", status_style = '',
right_style = 'color: transparent !important;'; right_style = '';
if ((options.value !== undefined) && (options.doc === undefined)) {
options.doc = options.value.doc;
}
status_class = checkProjectStatus(result); status_class = checkProjectStatus(result);
right_class = checkProjectPartitionStatus(result); right_class = checkProjectPartitionStatus(result);
i = options;
// right_title = value.max? Math.round(value.max * 100 * 10) / 10 + '%': 'nan';
right_style = '';
status_style = '';
template = inline_status_template;
if (status_class === 'ui-btn-no-data') { if (status_class === 'ui-btn-no-data') {
status_style = "color: transparent !important;"; status_style = "color: transparent !important;";
} }
monitor_url = gadget.props.hateoas_url + gadget.options.value.jio_key + '/Base_redirectToMonitor';
monitor_url = gadget.props.hateoas_url + options.value.jio_key + '/Base_redirectToMonitor'; gadget.element.innerHTML = inline_status_template({
gadget.element.innerHTML = template({
monitor_url: monitor_url, monitor_url: monitor_url,
status_class: status_class, status_class: status_class,
status_title: status_title, status_title: status_title,
status_style: status_style, status_style: status_style,
middle_style: middle_style,
right_class: right_class, right_class: right_class,
right_title: right_title, right_title: right_title,
right_style: right_style right_style: right_style
}); });
return RSVP.delay(300000); return gadget;
}) }
);
}
.push(function () { gadget_klass
gadget.element.innerHTML = loading_template(); .ready(function (gadget) {
return getStatus(options); gadget.props = {};
return gadget.getSetting("hateoas_url")
.push(function (url) {
gadget.props.hateoas_url = url;
}); });
} })
return queue.push(getStatus(options)); .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareMethod("getContent", function () {
return {};
})
.declareJob("getStatus", function () {
var gadget = this;
return getStatus(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();
}); });
}(window, rJS, RSVP, Handlebars)); }(window, rJS, RSVP, Handlebars));
\ No newline at end of file
...@@ -69,6 +69,14 @@ ...@@ -69,6 +69,14 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_slapos_project_status.js</string> </value> <value> <string>gadget_slapos_project_status.js</string> </value>
...@@ -87,6 +95,25 @@ ...@@ -87,6 +95,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -216,7 +243,7 @@ ...@@ -216,7 +243,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +257,7 @@ ...@@ -230,7 +257,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>964.17488.45396.32614</string> </value> <value> <string>968.33071.21265.51541</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +275,7 @@ ...@@ -248,7 +275,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519209644.29</float> <float>1530119961.69</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
<script src="gadget_slapos_site_status.js"></script> <script src="gadget_slapos_site_status.js"></script>
<link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/> <link href="gadget_slapos_computer_status.css" rel="stylesheet" type="text/css"/>
<script id="sensor-status-template" type="text/x-handlebars-template">
<ul class="grid-items">
<li><a class="ui-btn ui-first-child {{status_class}}" data-i18n={{status_title}} >{{status_title}}</a></li>
<li><a class="ui-btn ui-first-child {{right_class}}" style="{{right_style}}">{{right_title}}</a></li>
</ul>
</script>
<script id="inline-status-template" type="text/x-handlebars-template"> <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}}" > <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> <a class="ui-btn ui-btn-icon-left ui-icon-desktop" href={{monitor_url}} target=_blank> {{status_title}} </a></div></div>
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -73,6 +84,14 @@ ...@@ -73,6 +84,14 @@
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>text/html</string> </value> <value> <string>text/html</string> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</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_site_status.html</string> </value>
...@@ -91,6 +110,25 @@ ...@@ -91,6 +110,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.62</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value> <value> <string>Web Page</string> </value>
...@@ -234,7 +272,7 @@ ...@@ -234,7 +272,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.64689.21845.43827</string> </value> <value> <string>966.58781.43824.3635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +290,7 @@ ...@@ -252,7 +290,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520342697.92</float> <float>1530120162.62</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,18 +4,10 @@ ...@@ -4,18 +4,10 @@
(function (window, rJS, RSVP, Handlebars) { (function (window, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
sensor_status_source = gadget_klass.__template_element
.getElementById("sensor-status-template")
.innerHTML,
sensor_status_template = Handlebars.compile(sensor_status_source),
inline_status_source = gadget_klass.__template_element inline_status_source = gadget_klass.__template_element
.getElementById("inline-status-template") .getElementById("inline-status-template")
.innerHTML, .innerHTML,
inline_status_template = Handlebars.compile(inline_status_source), inline_status_template = Handlebars.compile(inline_status_source);
loading_source = gadget_klass.__template_element
.getElementById("loading-template")
.innerHTML,
loading_template = Handlebars.compile(loading_source);
function checkComputerStatus(options) { function checkComputerStatus(options) {
if (!options) { if (!options) {
......
...@@ -39,6 +39,17 @@ ...@@ -39,6 +39,17 @@
</tuple> </tuple>
</value> </value>
</item> </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> <item>
<key> <string>_Modify_portal_content_Permission</string> </key> <key> <string>_Modify_portal_content_Permission</string> </key>
<value> <value>
...@@ -69,6 +80,14 @@ ...@@ -69,6 +80,14 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>zope</string>
</tuple>
</value>
</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_site_status.js</string> </value>
...@@ -87,6 +106,25 @@ ...@@ -87,6 +106,25 @@
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value> <string>en</string> </value>
</item> </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.64</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -216,7 +254,7 @@ ...@@ -216,7 +254,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +268,7 @@ ...@@ -230,7 +268,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>964.17501.33036.24234</string> </value> <value> <string>966.58781.43824.3635</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +286,7 @@ ...@@ -248,7 +286,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519209630.33</float> <float>1530119121.08</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment