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