Commit 9d616e9d authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio: disable gadget status onLoop

Instead of jio.get, the paramers must provide the url to query,
otherwise, it is not possible to use this gadget in the full ERP5JS
parent 9195232f
/*globals console, window, rJS, domsugar, JSON */ /*globals console, window, rJS, domsugar */
/*jslint indent: 2, nomen: true, maxlen: 80 */ /*jslint indent: 2, nomen: true, maxlen: 80 */
(function (window, rJS, domsugar, JSON) { (function (window, rJS, domsugar) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
...@@ -198,8 +198,6 @@ ...@@ -198,8 +198,6 @@
} }
function getStatus(gadget, result) { function getStatus(gadget, result) {
console.log('status getStatus', result);
var status_class = 'ui-btn-no-data', var status_class = 'ui-btn-no-data',
right_class = 'ui-btn-no-data', right_class = 'ui-btn-no-data',
main_status_div = gadget.element.querySelector(".main-status"), main_status_div = gadget.element.querySelector(".main-status"),
...@@ -340,15 +338,14 @@ ...@@ -340,15 +338,14 @@
return {}; return {};
}) })
/* XXX disabled for now. Gadget parameters must provide
the url to query again to fetch updated data
.onLoop(function () { .onLoop(function () {
console.log('status onloop');
var gadget = this; var gadget = this;
if (typeof gadget.state.jio_key === 'string' && if (typeof gadget.state.jio_key === 'string' &&
gadget.state.jio_key !== '') { gadget.state.jio_key !== '') {
return gadget.jio_get(gadget.state.jio_key) return gadget.jio_get(gadget.state.jio_key)
.push(function (result) { .push(function (result) {
console.log('status after get', result);
var state_dict = result.news || {}; var state_dict = result.news || {};
state_dict.jio_key = gadget.state.jio_key; state_dict.jio_key = gadget.state.jio_key;
return gadget.changeState(state_dict); return gadget.changeState(state_dict);
...@@ -359,14 +356,13 @@ ...@@ -359,14 +356,13 @@
JSON.stringify(gadget.state.jio_key) JSON.stringify(gadget.state.jio_key)
); );
}, 300000) }, 300000)
*/
.onStateChange(function () { .onStateChange(function () {
console.log('status getStatus');
return getStatus(this, this.state); return getStatus(this, this.state);
}) })
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
console.log('status render', options);
// crash as soon as possible to detect wrong configuration // crash as soon as possible to detect wrong configuration
if (!(options.hasOwnProperty('jio_key') && if (!(options.hasOwnProperty('jio_key') &&
...@@ -383,4 +379,4 @@ ...@@ -383,4 +379,4 @@
return this.changeState(state_dict); return this.changeState(state_dict);
}); });
}(window, rJS, domsugar, JSON)); }(window, rJS, domsugar));
\ No newline at end of file \ No newline at end of file
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.24757.23775.49783</string> </value> <value> <string>1010.24775.45627.23261</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -298,7 +298,7 @@ ...@@ -298,7 +298,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691747920.75</float> <float>1691748972.83</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