Commit 671d7339 authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio/panel: restore status gadget first rendering

onLoop must be fixed probably
parent b392fccc
......@@ -198,6 +198,8 @@
}
function getStatus(gadget, result) {
console.log('status getStatus', result);
var i, status_class = 'ui-btn-no-data',
right_class = 'ui-btn-no-data',
main_status_div = gadget.element.querySelector(".main-status"),
......@@ -337,10 +339,13 @@
})
.onLoop(function () {
console.log('status onloop');
var gadget = this;
if (typeof gadget.state.jio_key === 'string' && gadget.state.jio_key !== '') {
return gadget.jio_get(gadget.state.jio_key)
.push(function (result) {
console.log('status after get', result);
var state_dict = result.news || {};
state_dict.jio_key = gadget.state.jio_key;
return gadget.changeState(state_dict);
......@@ -353,14 +358,27 @@
}, 300000)
.onStateChange(function () {
console.log('status getStatus');
return getStatus(this, this.state);
})
.declareMethod("render", function (options) {
console.log('status render', options);
// crash as soon as possible to detect wrong configuration
if (!(options.hasOwnProperty('jio_key') &&
options.hasOwnProperty('portal_type') &&
options.hasOwnProperty('result'))) {
throw new Error(
'status gadget did not receive jio_key, portal_type and result values'
);
}
// Save will force the gadget to be updated so
// result is empty.
var state_dict = options.result || {};
state_dict.jio_key = options.jio_key;
state_dict.portal_type = options.portal_type;
return this.changeState(state_dict);
});
......
......@@ -278,7 +278,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.14961.23101.61474</string> </value>
<value> <string>1010.24667.53982.38792</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -298,7 +298,7 @@
</tuple>
<state>
<tuple>
<float>1691674603.33</float>
<float>1691742501.46</float>
<string>UTC</string>
</tuple>
</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