Commit 60dbaeb2 authored by Alain Takoudjou's avatar Alain Takoudjou

[erp5_web_monitoring] load monitoring parameter from json serialized connection parameter

parent 58b41696
......@@ -260,26 +260,55 @@
});
}
function getParameterDictFromUrl(uri_param) {
if (uri_param.has('url') && uri_param.has('password') &&
uri_param.has('username') && uri_param.get('url').startsWith('http')) {
return {
opml_url: uri_param.get('url'),
username: uri_param.get('username'),
password: uri_param.get('password')
};
}
}
function getParameterFromconnectionDict(connection_dict) {
if (connection_dict["monitor-url"] &&
connection_dict["monitor-url"].startsWith('http') &&
connection_dict["monitor-user"] &&
connection_dict["monitor-password"]) {
return {
opml_url: connection_dict["monitor-url"],
username: connection_dict["monitor-user"],
password: connection_dict["monitor-password"]
};
}
}
function readMonitoringParameter(parmeter_xml) {
var parser = new DOMParser(),
xmlDoc = parser.parseFromString(parmeter_xml, "text/xml"),
parameter,
uri_param,
json_parameter,
parameter_dict,
monitor_dict = {};
json_parameter = xmlDoc.getElementById("_");
if (json_parameter !== undefined && json_parameter !== null) {
parameter_dict = JSON.parse(json_parameter.textContent);
if (parameter_dict.hasOwnProperty("monitor-setup-url")) {
return getParameterDictFromUrl(
new URLSearchParams(parameter_dict["monitor-setup-url"])
);
}
return getParameterFromconnectionDict(parameter_dict);
}
parameter = xmlDoc.getElementById("monitor-setup-url");
if (parameter !== undefined && parameter !== null) {
// monitor-setup-url exists
uri_param = new URLSearchParams(parameter.textContent);
if (uri_param.has('url') && uri_param.has('password') &&
uri_param.has('username') && uri_param.get('url').startsWith('http')) {
return {
opml_url: uri_param.get('url'),
username: uri_param.get('username'),
password: uri_param.get('password')
};
return getParameterDictFromUrl(uri_param);
}
} else {
parameter = xmlDoc.getElementById("monitor-url");
if (parameter !== undefined && parameter !== null) {
monitor_dict.url = parameter.textContent.trim();
......@@ -296,7 +325,6 @@
return monitor_dict;
}
}
}
function getInstanceOPMLListFromMaster(gadget, limit) {
var hosting_subscription_list = [],
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.42470.47064.30003</string> </value>
<value> <string>967.60726.55816.57890</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1519233144.55</float>
<float>1527847350.32</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,7 +108,7 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n
# generated on Fri, 21 Fev 2018 10:37:42 +0000\n
# generated on Fri, 20 May 2018 17:47:45 +0000\n
# XXX + fonts\n
# images/ajax-loader.gif\n
CACHE:\n
......@@ -387,7 +387,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.42293.15886.45994</string> </value>
<value> <string>966.64659.26947.45004</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -405,7 +405,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1519222522.75</float>
<float>1527847381.11</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