Commit eab88e82 authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio/panel: restore status gadget first rendering

onLoop must be fixed probably
parent 74e42bb5
......@@ -128,7 +128,9 @@
}
function getStatus(gadget, result) {
var status_class = 'ui-btn-no-data',
var i, status_class = 'ui-btn-no-data',
right_class = 'ui-btn-no-data',
main_status_div = gadget.element.querySelector(".main-status"),
monitor_url = '',
main_link_configuration_dict = {
......@@ -222,11 +224,35 @@
return {};
})
<<<<<<< HEAD
=======
.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);
});
}
throw new Error(
'jio_key dont contains a proper value: ' +
JSON.stringify(gadget.state.jio_key)
);
}, 300000)
>>>>>>> 671d73395 (slapos_jio/panel: restore status gadget first rendering)
.onStateChange(function () {
console.log('status getStatus');
return getStatus(this, this.state);
})
.declareMethod("render", function (options) {
<<<<<<< HEAD
// crash as soon as possible to detect wrong configuration
if (!(options.hasOwnProperty('jio_key') &&
options.hasOwnProperty('result'))) {
......@@ -234,10 +260,24 @@
'status gadget did not receive jio_key and result values'
);
}
=======
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'
);
}
>>>>>>> 671d73395 (slapos_jio/panel: restore status gadget first rendering)
// 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