Commit a1810e17 authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_monitoring: create jio_storage only once for each storage and update...

slapos_monitoring: create jio_storage only once for each storage and update when configuration change
parent d89d412a
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n CACHE MANIFEST\n
# generated on Fri, 22 July 2016 11:47:33 +0000\n # generated on Fri, 12 sept 2016 11:47:33 +0000\n
# XXX + fonts\n # XXX + fonts\n
# images/ajax-loader.gif\n # images/ajax-loader.gif\n
CACHE:\n CACHE:\n
...@@ -343,7 +343,7 @@ NETWORK:\n ...@@ -343,7 +343,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.47296.53851.40738</string> </value> <value> <string>952.47297.6275.10444</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -361,7 +361,7 @@ NETWORK:\n ...@@ -361,7 +361,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1469182145.68</float> <float>1473673613.98</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -323,9 +323,9 @@ html head + body .ui-panel-overview > h2 { ...@@ -323,9 +323,9 @@ html head + body .ui-panel-overview > h2 {
} }
.label { .label {
display: inline; display: inline;
padding: .2em .6em .3em; padding: .4em .8em;
font-weight: 700; font-weight: 700;
line-height: 1; line-height: 2.1em;
color: #fff; color: #fff;
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>952.63103.15334.28893</string> </value> <value> <string>953.56608.44648.59067</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1470133968.93</float> <float>1473673058.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -361,7 +361,6 @@ ...@@ -361,7 +361,6 @@
var timer; var timer;
if ($(element).prop('checked')) { if ($(element).prop('checked')) {
timer = parseInt($(element).val(), 10); timer = parseInt($(element).val(), 10);
console.log(timer);
if (timer && !isNaN(timer)) { if (timer && !isNaN(timer)) {
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>953.36447.50256.8499</string> </value> <value> <string>953.40906.11702.46250</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1472468803.41</float> <float>1473673242.84</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
.ready(function (g) { .ready(function (g) {
g.props = {}; g.props = {};
g.props.jio_storage_dict = {}; g.props.jio_storage_dict = {};
g.props.storage_signature_dict = {};
return g.getDeclaredGadget('jio_gadget') return g.getDeclaredGadget('jio_gadget')
.push(function (jio_gadget) { .push(function (jio_gadget) {
g.props.jio_gadget = jio_gadget; g.props.jio_gadget = jio_gadget;
...@@ -68,18 +69,41 @@ ...@@ -68,18 +69,41 @@
return error_message; return error_message;
} }
function getJioGadget(gadget, hash) { function getJioGadget(gadget, storage_dict, query) {
var hash,
url;
if (storage_dict.sub_storage.hasOwnProperty('sub_storage')) {
url = storage_dict.sub_storage.sub_storage.url;
} else {
url = storage_dict.sub_storage.url;
}
hash = rusha.digestFromString(url);
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
var storage_signature = rusha.digestFromString(
JSON.stringify(storage_dict)
);
if (gadget.props.jio_storage_dict.hasOwnProperty(hash)) { if (gadget.props.jio_storage_dict.hasOwnProperty(hash)) {
if (!gadget.props.storage_signature_dict.hasOwnProperty(hash)) {
gadget.props.storage_signature_dict[hash] = '';
}
if (gadget.props.storage_signature_dict[hash] !== storage_signature) {
// recreate jio_gadget as storage config changed
gadget.props.storage_signature_dict[hash] = storage_signature;
jio_declared_gadget.createJio(storage_dict, true, query);
}
return gadget.props.jio_storage_dict[hash]; return gadget.props.jio_storage_dict[hash];
} else { } else {
return gadget.declareGadget("gadget_monitoring_jio.html", return gadget.declareGadget("gadget_monitoring_jio.html",
{ {
scope: hash scope: 'jio_' + hash
} }
) )
.push(function (jio_declared_gadget) { .push(function (jio_declared_gadget) {
gadget.props.storage_signature_dict[hash] = storage_signature;
jio_declared_gadget.createJio(storage_dict, true, query);
gadget.props.jio_storage_dict[hash] = jio_declared_gadget; gadget.props.jio_storage_dict[hash] = jio_declared_gadget;
return jio_declared_gadget; return jio_declared_gadget;
}); });
...@@ -88,37 +112,30 @@ ...@@ -88,37 +112,30 @@
} }
function syncStorage(gadget, storage_dict, query) { function syncStorage(gadget, storage_dict, query) {
var hash;
//gadget.props.jio_gadget.createJio(storage_dict, true, query);
hash = rusha.digestFromString(storage_dict.title.replace(/\s*/g, "") +
'_' + storage_dict.sub_storage.type);
return getJioGadget(gadget, hash) return getJioGadget(gadget, storage_dict, query)
.push(function (jio_declared_gadget) { .push(function (jio_declared_gadget) {
jio_declared_gadget.createJio(storage_dict, true, query); //jio_declared_gadget.createJio(storage_dict, true, query);
return jio_declared_gadget.repair(); return jio_declared_gadget.repair();
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
console.log(error);
gadget.props.error_list.push({ gadget.props.error_list.push({
storage_dict: storage_dict, storage_dict: storage_dict,
query: query query: query
}); });
console.log(error);
}); });
} }
function updateStatus(gadget, storage_dict, status) { function updateStatus(gadget, storage_dict, status) {
var promise_list = [], var promise_list = [],
jio_gadget, jio_gadget,
hash, url,
i; i;
hash = rusha.digestFromString(storage_dict.title.replace(/\s*/g, "") +
'_' + storage_dict.sub_storage.type);
return getJioGadget(gadget, hash) return getJioGadget(gadget, storage_dict)
.push(function (jio_declared_gadget) { .push(function (jio_declared_gadget) {
jio_gadget = jio_declared_gadget; jio_gadget = jio_declared_gadget;
jio_gadget.createJio(storage_dict);
return jio_gadget.allDocs({include_docs: true}); return jio_gadget.allDocs({include_docs: true});
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>953.32835.32275.40806</string> </value> <value> <string>953.46897.62166.5307</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1472247230.79</float> <float>1473673110.13</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