Commit e6d95fd8 authored by Alain Takoudjou's avatar Alain Takoudjou

[erp5_web_monitoring] make monitoring works with broken some broken opml

Allow to sync opml event when some password are missing or broken (will only display public informations)
parent b69c896d
...@@ -24,5 +24,13 @@ ...@@ -24,5 +24,13 @@
data-gadget-sandbox="public"> data-gadget-sandbox="public">
</div> </div>
</form> </form>
<div class="ui-field-contain">
<div class="btn-nopasswd left padding-tb-20" style="display: none">
<button class="danger-button" id="saveOPMLNoPwd" data-i18n="Save OPML with broken password">
Save OPML Anyway!
</button>
<span><i data-i18n="with all associated data">Information which require password won't be displayed in monitor.</i></span>
</div>
</div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.29479.31715.56712</string> </value> <value> <string>971.63817.9300.38417</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542210800.49</float> <float>1543855483.74</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
rJS(window) rJS(window)
.setState({auto_sync: true}) .setState({auto_sync: true, check_pwd: true})
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -19,6 +19,16 @@ ...@@ -19,6 +19,16 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.onEvent('click', function (event) {
var gadget = this;
if (event.target.id === "saveOPMLNoPwd") {
return gadget.changeState({check_pwd: false})
.push(function () {
return gadget.element.querySelector('button[type="submit"]').click();
});
}
}, false, false)
.onEvent('submit', function () { .onEvent('submit', function () {
var gadget = this, var gadget = this,
opml_gadget, opml_gadget,
...@@ -43,20 +53,20 @@ ...@@ -43,20 +53,20 @@
return gadget.notifySubmitting() return gadget.notifySubmitting()
.push(function () { .push(function () {
doc.title = ""; doc.title = "";
return opml_gadget.saveOPML(doc, true); return opml_gadget.saveOPML(doc, gadget.state.check_pwd);
}) })
.push(function (status) { .push(function (state) {
var msg = {message: 'OPML document added', status: 'success'}; var msg = {message: 'OPML document added', status: 'success'};
if (!status) { if (!state) {
msg = {message: 'Failed to add OPML document', status: "error"}; msg = {message: 'Failed to add OPML document', status: "error"};
} }
return RSVP.all([ return RSVP.all([
gadget.notifySubmitted(msg), gadget.notifySubmitted(msg),
status state
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
if (result_list[1]) { if (result_list[1].status) {
if (gadget.state.auto_sync) { if (gadget.state.auto_sync) {
return gadget.getDeclaredGadget('sync_gadget') return gadget.getDeclaredGadget('sync_gadget')
.push(function (sync_gadget) { .push(function (sync_gadget) {
...@@ -75,6 +85,10 @@ ...@@ -75,6 +85,10 @@
"options": {"page": "settings_configurator"} "options": {"page": "settings_configurator"}
}); });
} }
if (result_list[1].can_force) {
gadget.element.getElementsByClassName("btn-nopasswd")[0]
.style.display = "";
}
}); });
} }
}); });
...@@ -88,6 +102,9 @@ ...@@ -88,6 +102,9 @@
var gadget = this; var gadget = this;
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
var button_no_pwd = gadget.element.getElementsByClassName("btn-nopasswd");
button_no_pwd[0].style.display = "none";
return RSVP.all([ return RSVP.all([
gadget.getDeclaredGadget('form_view'), gadget.getDeclaredGadget('form_view'),
gadget.getSetting('portal_type') gadget.getSetting('portal_type')
......
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.40858.48738.62941</string> </value> <value> <string>971.63895.24146.65194</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542298099.06</float> <float>1543593135.84</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -190,6 +190,12 @@ ...@@ -190,6 +190,12 @@
} }
for (i = 0; i < gadget.state.instance_dict.data.total_rows; i += 1) { for (i = 0; i < gadget.state.instance_dict.data.total_rows; i += 1) {
if (gadget.state.instance_dict.data.rows[i]
.value.aggregate_reference === undefined) {
// Instance is not Synchronized!
promise_list.push(false);
continue;
}
gadget_element = document.createElement("div"); gadget_element = document.createElement("div");
element.appendChild(gadget_element); element.appendChild(gadget_element);
promise_list.push( promise_list.push(
...@@ -205,17 +211,19 @@ ...@@ -205,17 +211,19 @@
.push(function (parameter_gadget_list) { .push(function (parameter_gadget_list) {
var i, var i,
promise_list = []; promise_list = [];
gadget.props.parameter_form_list = parameter_gadget_list;
for (i = 0; i < parameter_gadget_list.length; i += 1) { for (i = 0; i < parameter_gadget_list.length; i += 1) {
gadget.props.parameter_form_list = parameter_gadget_list; if (parameter_gadget_list[i]) {
promise_list.push( promise_list.push(
parameter_gadget_list[i].render({ parameter_gadget_list[i].render({
url: gadget.state.instance_dict.data.rows[i].value._links.private_url.href url: gadget.state.instance_dict.data.rows[i].value._links.private_url.href
.replace('jio_private', 'private') + '/config', .replace('jio_private', 'private') + '/config',
basic_login: gadget.state.opml.basic_login, basic_login: gadget.state.opml.basic_login,
title: "Parameters " + gadget.state.instance_dict.data.rows[i].value.title, title: "Parameters " + gadget.state.instance_dict.data.rows[i].value.title,
parameters: gadget.state.instance_dict.data.rows[i].value.parameters parameters: gadget.state.instance_dict.data.rows[i].value.parameters
}) })
); );
}
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
}); });
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.37886.23794.37102</string> </value> <value> <string>972.4007.38246.25361</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>1542965932.66</float> <float>1543845609.21</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -57,18 +57,18 @@ ...@@ -57,18 +57,18 @@
doc.title = gadget.state.opml_title; doc.title = gadget.state.opml_title;
return opml_gadget.saveOPML(doc, verify_opml); return opml_gadget.saveOPML(doc, verify_opml);
}) })
.push(function (status) { .push(function (state) {
var msg = {message: 'Document Updated', status: 'success'}; var msg = {message: 'Document Updated', status: 'success'};
if (!status) { if (!state.status) {
msg = {message: 'Document update failed', status: "error"}; msg = {message: 'Document update failed', status: "error"};
} }
return RSVP.all([ return RSVP.all([
gadget.notifySubmitted(msg), gadget.notifySubmitted(msg),
status state
]); ]);
}) })
.push(function (result) { .push(function (result) {
if (result[1]) { if (result[1].status) {
return gadget.changeState({ return gadget.changeState({
"password": doc.password "password": doc.password
}); });
......
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.13430.32819.27989</string> </value> <value> <string>971.63925.15236.1962</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542036791.1</float> <float>1543595657.95</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
var pass_url, var pass_url,
public_url, public_url,
private_url, private_url,
rss_url,
current_document = gadget.state.instance; current_document = gadget.state.instance;
if (current_document._embedded !== undefined && if (current_document._embedded !== undefined &&
...@@ -74,12 +75,18 @@ ...@@ -74,12 +75,18 @@
current_document.software_release = current_document._embedded.instance['software-release']; current_document.software_release = current_document._embedded.instance['software-release'];
} }
// fix URLs // fix URLs
private_url = gadget.state.instance._links if (gadget.state.instance._links !== undefined) {
.private_url.href.replace("jio_private", "private"); private_url = gadget.state.instance._links
public_url = gadget.state.instance._links .private_url.href.replace("jio_private", "private");
.public_url.href.replace("jio_public", "public"); public_url = gadget.state.instance._links
pass_url = "https://" + atob(gadget.state.opml.basic_login) + .public_url.href.replace("jio_public", "public");
"@" + private_url.split("//")[1]; pass_url = "https://" + atob(gadget.state.opml.basic_login) +
"@" + private_url.split("//")[1];
rss_url = current_document._links.rss_url.href;
}
if (gadget.state.instance.state === undefined) {
current_document.state = {error: "", success: ""};
}
return gadget.changeState({ return gadget.changeState({
jio_key: options.jio_key, jio_key: options.jio_key,
...@@ -90,7 +97,7 @@ ...@@ -90,7 +97,7 @@
success: current_document.state.success, success: current_document.state.success,
public_url: public_url, public_url: public_url,
private_url: pass_url, private_url: pass_url,
rss_url: current_document._links.rss_url.href, rss_url: rss_url,
//resource_url: tmp_url, //resource_url: tmp_url,
//process_url: tmp_process_url, //process_url: tmp_process_url,
hosting_title: gadget.state.opml.title, hosting_title: gadget.state.opml.title,
...@@ -191,11 +198,19 @@ ...@@ -191,11 +198,19 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
var graph_options = { var graph_options = {
data_url: "",
data_filename: "monitor_state.data",
basic_login: ""
};
if (gadget.state.instance._links !== undefined) {
graph_options = {
data_url: gadget.state.instance._links.private_url.href + data_url: gadget.state.instance._links.private_url.href +
'documents/', 'documents/',
data_filename: gadget.state.instance.data.state, data_filename: gadget.state.instance.data.state,
basic_login: gadget.state.opml.basic_login basic_login: gadget.state.opml.basic_login
}; };
}
graph_options.extract_method = function (element_dict) { graph_options.extract_method = function (element_dict) {
var promise_data = [ var promise_data = [
...@@ -260,11 +275,12 @@ ...@@ -260,11 +275,12 @@
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
var column_list = [ var column_list = [
['category', 'Status'], ['category', 'Status'],
['source', 'Promise'], ['source', 'Promise'],
['lastBuildDate', 'Promise Date'], ['lastBuildDate', 'Promise Date'],
['description', 'Message'] ['description', 'Message']
]; ],
hide_link = (gadget.state.instance._links === undefined) ? 1 : 0;
return form_gadget.render({ return form_gadget.render({
erp5_document: { erp5_document: {
"_embedded": {"_view": { "_embedded": {"_view": {
...@@ -316,7 +332,7 @@ ...@@ -316,7 +332,7 @@
"required": 0, "required": 0,
"editable": 0, "editable": 0,
"key": "public_url", "key": "public_url",
"hidden": 0, "hidden": hide_link,
"type": "EditorField" "type": "EditorField"
}, },
"your_private_url": { "your_private_url": {
...@@ -331,7 +347,7 @@ ...@@ -331,7 +347,7 @@
"required": 0, "required": 0,
"editable": 0, "editable": 0,
"key": "private_url", "key": "private_url",
"hidden": 0, "hidden": hide_link,
"type": "EditorField" "type": "EditorField"
}, },
"your_error_count": { "your_error_count": {
...@@ -368,7 +384,7 @@ ...@@ -368,7 +384,7 @@
"required": 0, "required": 0,
"editable": 0, "editable": 0,
"key": "software_release_url", "key": "software_release_url",
"hidden": 0, "hidden": hide_link,
"type": "EditorField" "type": "EditorField"
}, },
"your_rss_url": { "your_rss_url": {
...@@ -383,7 +399,7 @@ ...@@ -383,7 +399,7 @@
"required": 0, "required": 0,
"editable": 0, "editable": 0,
"key": "rss_url", "key": "rss_url",
"hidden": 0, "hidden": hide_link,
"type": "EditorField" "type": "EditorField"
}, },
"your_hosting_title": { "your_hosting_title": {
...@@ -530,15 +546,18 @@ ...@@ -530,15 +546,18 @@
]); ]);
}) })
.push(function (url_list) { .push(function (url_list) {
return gadget.updateHeader({ var options = {
page_title: "Instance: " + gadget.state.title, page_title: "Instance: " + gadget.state.title,
selection_url: url_list[0], selection_url: url_list[0],
previous_url: url_list[1], previous_url: url_list[1],
next_url: url_list[2], next_url: url_list[2],
resources_url: url_list[3], refresh_action: true
processes_url: url_list[4], };
refresh_action: true if (gadget.state.instance._links !== undefined) {
}); options.resources_url = url_list[3];
options.processes_url = url_list[4];
}
return gadget.updateHeader(options);
}); });
}); });
}(window, rJS, RSVP, Handlebars, atob)); }(window, rJS, RSVP, Handlebars, atob));
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.52392.46096.61883</string> </value> <value> <string>972.4061.47106.61696</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542962862.93</float> <float>1543848850.64</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<item> <item>
<key> <string>text_content</string> </key> <key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n <value> <string>CACHE MANIFEST\n
# generated on Fri, 19 Nov 2018 16:43:45 +0000\n # generated on Fri, 19 Nov 2018 12:54:57 +0000\n
# XXX + fonts\n # XXX + fonts\n
# images/ajax-loader.gif\n # images/ajax-loader.gif\n
CACHE:\n CACHE:\n
...@@ -389,7 +389,7 @@ NETWORK:\n ...@@ -389,7 +389,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.57732.65002.56098</string> </value> <value> <string>972.4099.58600.53947</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -407,7 +407,7 @@ NETWORK:\n ...@@ -407,7 +407,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1543224326.23</float> <float>1543855489.22</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -150,7 +150,8 @@ ...@@ -150,7 +150,8 @@
has_monitor: true, has_monitor: true,
state: doc.state || (doc.active === "on" ? "Started" : "Stopped") state: doc.state || (doc.active === "on" ? "Started" : "Stopped")
}, },
update_password_list = []; update_password_list = [],
allow_force = false;
gadget.state.message.textContent = ""; gadget.state.message.textContent = "";
function validateOPML() { function validateOPML() {
...@@ -177,7 +178,7 @@ ...@@ -177,7 +178,7 @@
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
var message_text, var message_text,
code = 0; code = 0;
if (error instanceof jIO.util.jIOError) { if (error instanceof jIO.util.jIOError) {
message_text = error.message; message_text = error.message;
code = error.status_code; code = error.status_code;
...@@ -238,6 +239,7 @@ ...@@ -238,6 +239,7 @@
error_msg += 'Login/password invalid for instance: ' + error_msg += 'Login/password invalid for instance: ' +
status_list[i].title + '. ' + status_list[i].title + '. ' +
status_list[i].msg + '\n'; status_list[i].msg + '\n';
allow_force = true;
} }
} }
if (used_new_passwd_count > 0 && if (used_new_passwd_count > 0 &&
...@@ -322,10 +324,10 @@ ...@@ -322,10 +324,10 @@
return gadget.jio_put(opml_dict.url, opml_dict) return gadget.jio_put(opml_dict.url, opml_dict)
.push(function () { .push(function () {
gadget.state.message.textContent = ""; gadget.state.message.textContent = "";
return status; return {status: status, can_force: allow_force};
}); });
} }
return status; return {status: status, can_force: allow_force};
}); });
} }
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.37897.12342.12851</string> </value> <value> <string>971.63860.22689.21760</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>1542281232.26</float> <float>1543593317.26</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -346,7 +346,7 @@ ...@@ -346,7 +346,7 @@
}); });
} }
function loadSubStorage(context, storage_spec, parent_id, type) { function loadSubStorage(context, storage_spec, parent_id, index, type) {
var sub_storage, var sub_storage,
result_dict, result_dict,
storage_key, storage_key,
...@@ -361,7 +361,8 @@ ...@@ -361,7 +361,8 @@
type: type || storage_spec.type, type: type || storage_spec.type,
current_signature: {}, current_signature: {},
result: {data: {total_rows: 0}}, result: {data: {total_rows: 0}},
url: url url: url,
parent_index: index
}; };
return sub_storage.allDocs({include_docs: true}) return sub_storage.allDocs({include_docs: true})
.push(undefined, function (error) { .push(undefined, function (error) {
...@@ -536,6 +537,7 @@ ...@@ -536,6 +537,7 @@
} }
}, },
id_hash, id_hash,
i,
'promise' 'promise'
)); ));
// Load private docs // Load private docs
...@@ -548,7 +550,8 @@ ...@@ -548,7 +550,8 @@
basic_login: basic_login, basic_login: basic_login,
timeout: context._request_timeout timeout: context._request_timeout
}, },
id_hash id_hash,
i
)); ));
} }
...@@ -598,15 +601,15 @@ ...@@ -598,15 +601,15 @@
var i, var i,
j, j,
start, start,
extra_dict, extra_dict;
item_signature_dict = {};
function applyItemToTree(item, item_result, extra_dict) { function applyItemToTree(item, item_result, extra_dict) {
var id_hash, var id_hash,
element = item.doc, element = item.doc,
signature, signature,
item_id = item.guid || item.id, item_id = item.guid || item.id,
status = (element.status || element.category); status = (element.status || element.category),
item_signature_dict = {};
if (element.type === 'global') { if (element.type === 'global') {
updateHostingSubscriptionState(hosting_subscription, element); updateHostingSubscriptionState(hosting_subscription, element);
...@@ -658,6 +661,11 @@ ...@@ -658,6 +661,11 @@
id: id_hash, id: id_hash,
doc: element doc: element
}); });
attachment_document_list.push({
id: item_result.parent_id,
name: item_result.url,
doc: item_signature_dict
});
} }
for (i = 0; i < result_list.length; i += 1) { for (i = 0; i < result_list.length; i += 1) {
...@@ -681,12 +689,6 @@ ...@@ -681,12 +689,6 @@
extra_dict extra_dict
); );
} }
attachment_document_list.push({
id: result_list[i].parent_id,
name: result_list[i].url,
doc: item_signature_dict
});
item_signature_dict = {};
delete_key_list.push.apply( delete_key_list.push.apply(
delete_key_list, delete_key_list,
Object.keys(result_list[i].current_signature) Object.keys(result_list[i].current_signature)
...@@ -701,6 +703,28 @@ ...@@ -701,6 +703,28 @@
doc: result_list[i].current_signature doc: result_list[i].current_signature
}); });
} }
else if (context._remote_storage_unreachable_status !== undefined) {
if (result_list[i].type === "webhttp") {
// In case it was impossible to get software Instance
// Add an empty Software Instance with unreachable status
applyItemToTree(
{
id: "monitor.global",
doc: {
portal_type: "Software Instance",
status: context._remote_storage_unreachable_status,
title: opml_result_list.data.rows[result_list[i]
.parent_index].doc.title,
date: new Date().toUTCString() + "+0000",
specialise_title: opml_result_list.data.rows[result_list[i]
.parent_index].doc.opml_title
}
},
result_list[i],
undefined
);
}
}
} }
opml_document_list.push({ opml_document_list.push({
id: id, id: id,
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.53440.65205.20872</string> </value> <value> <string>972.3978.30023.34679</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>1542966332.7</float> <float>1543851108.12</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