Commit b992c34e authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_monitoring: fix monitor instance registration

parent 8d66b2e4
...@@ -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, 28 April 2016 11:47:33 +0000\n # generated on Fri, 29 April 2016 15:47:33 +0000\n
# XXX + fonts\n # XXX + fonts\n
# images/ajax-loader.gif\n # images/ajax-loader.gif\n
CACHE:\n CACHE:\n
...@@ -126,6 +126,7 @@ gadget_jio.html\n ...@@ -126,6 +126,7 @@ gadget_jio.html\n
gadget_jio.js\n gadget_jio.js\n
gadget_translate.html\n gadget_translate.html\n
gadget_translate.js\n gadget_translate.js\n
gadget_translation.html\n
handlebars.js\n handlebars.js\n
i18next.js\n i18next.js\n
jiodev.js\n jiodev.js\n
...@@ -326,7 +327,7 @@ NETWORK:\n ...@@ -326,7 +327,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.53381.7699.19968</string> </value> <value> <string>950.54525.37134.26453</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -344,7 +345,7 @@ NETWORK:\n ...@@ -344,7 +345,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1461861221.53</float> <float>1461945469.4</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -691,6 +691,59 @@ html table.instance-overview td:first-child > a, html table.instance-overview td ...@@ -691,6 +691,59 @@ html table.instance-overview td:first-child > a, html table.instance-overview td
margin: 20px auto; margin: 20px auto;
} }
/* Alert box custom */
.alert {
padding: 8px 35px 8px 14px;
margin-bottom: 8px;
margin-top: 8px;
color: #c09853;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
background-color: #fcf8e3;
border: 1px solid #fbeed5;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.alert-heading {
color: inherit;
}
.alert .close {
position: relative;
top: -2px;
right: -21px;
line-height: 18px;
}
.alert-success {
color: #468847;
background-color: #dff0d8;
border-color: #d6e9c6;
}
.alert-danger,
.alert-error {
color: #b94a48;
background-color: #f2dede;
border-color: #eed3d7;
}
.alert-info {
color: #3a87ad;
background-color: #d9edf7;
border-color: #bce8f1;
}
.alert-block > p,
.alert-block > ul {
margin-bottom: 0;
}
.alert-block p + p {
margin-top: 5px;
}
/************** Media @ **********************/ /************** Media @ **********************/
@media all and (max-width: 62em) { @media all and (max-width: 62em) {
form.search .ui-block-a { form.search .ui-block-a {
......
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>superalain</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.11464.24567.15445</string> </value> <value> <string>950.54665.64561.63931</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>1459341758.63</float> <float>1461939565.36</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -60,9 +60,11 @@ ...@@ -60,9 +60,11 @@
if (doc.hasOwnProperty(key)) { if (doc.hasOwnProperty(key)) {
doc[key].hash = btoa(login + ':' + password); doc[key].hash = btoa(login + ':' + password);
doc[key].url = url; doc[key].url = url;
doc[key].login = login;
} else { } else {
doc[key] = { doc[key] = {
hash: btoa(login + ':' + password), hash: btoa(login + ':' + password),
login: login,
url: url, url: url,
parent_url: ''}; parent_url: ''};
} }
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.51968.20423.17902</string> </value> <value> <string>950.54785.50611.22596</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>1461832953.11</float> <float>1461942642.99</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -107,9 +107,7 @@ ...@@ -107,9 +107,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="padding-5"> <div class="alert alert-error ui-content-hidden"></div>
<span class="ui-text-error"></span>
</div>
<div class="ui-grid-b ui-responsive"> <div class="ui-grid-b ui-responsive">
<div class="ui-block-a"></div> <div class="ui-block-a"></div>
<div class="ui-block-b"> <div class="ui-block-b">
...@@ -164,6 +162,7 @@ ...@@ -164,6 +162,7 @@
</div> </div>
<div class="padding-5"> <div class="padding-5">
<a href="#page=hosting_overview">Access Applications</a> <a href="#page=hosting_overview">Access Applications</a>
<a href="#page=import_export">Export Settings</a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.53466.15484.25019</string> </value> <value> <string>950.54736.61765.9915</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>1461860815.17</float> <float>1461937944.7</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -83,10 +83,16 @@ ...@@ -83,10 +83,16 @@
} }
function loadUrlFromOPML(gadget, url) { function loadUrlFromOPML(gadget, url) {
var text_content = gadget.props.element.querySelector('form.opml button.show')
.textContent;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return $("article.configure-b").addClass("ui-content-hidden"); return $("article.configure-b").addClass("ui-content-hidden");
}) })
.push(function () {
gadget.props.element.querySelector('form.opml button.show')
.textContent = "Loading...";
})
.push(function () { .push(function () {
var listbox_configuration = { var listbox_configuration = {
enable_search: false, enable_search: false,
...@@ -121,6 +127,8 @@ ...@@ -121,6 +127,8 @@
return gadget.props.listbox.render(listbox_configuration); return gadget.props.listbox.render(listbox_configuration);
}) })
.push(function () { .push(function () {
gadget.props.element.querySelector('form.opml button.show')
.textContent = text_content;
if (gadget.props.listbox.property_dict.data_result.length > 0) { if (gadget.props.listbox.property_dict.data_result.length > 0) {
return $("article.configure-b").removeClass("ui-content-hidden"); return $("article.configure-b").removeClass("ui-content-hidden");
} else { } else {
...@@ -130,6 +138,8 @@ ...@@ -130,6 +138,8 @@
} }
//return $(gadget.props.element.querySelector(".configure-b")).show(); //return $(gadget.props.element.querySelector(".configure-b")).show();
}, function(error) { }, function(error) {
gadget.props.element.querySelector('form.opml button.show')
.textContent = text_content;
$(gadget.props.element.querySelector('.opml .ui-text-error')).fadeIn(400); $(gadget.props.element.querySelector('.opml .ui-text-error')).fadeIn(400);
gadget.props.element.querySelector('.opml .ui-text-error') gadget.props.element.querySelector('.opml .ui-text-error')
.innerHTML = "ERROR " + (error.target.status || '') + "Failed to load URL!"; .innerHTML = "ERROR " + (error.target.status || '') + "Failed to load URL!";
...@@ -151,7 +161,7 @@ ...@@ -151,7 +161,7 @@
return gadget.props.login_gadget.login(credential.url, credential.hash) return gadget.props.login_gadget.login(credential.url, credential.hash)
.then(function(result) { .then(function(result) {
if (result.status === 'OK') { if (result.status === 'OK') {
return credential.hash; return credential;
} else { } else {
return undefined; return undefined;
} }
...@@ -174,7 +184,11 @@ ...@@ -174,7 +184,11 @@
return loginFromLocalCredential(gadget, url) return loginFromLocalCredential(gadget, url)
.push(function (result) { .push(function (result) {
if (result) { if (result) {
return {status: 'OK', hash: result, url: url}; return {
status: 'OK',
hash: result.hash,
login: result.login,
url: url};
} }
return {status: 'KO', msg: error.msg + ' (' + url + ')'}; return {status: 'KO', msg: error.msg + ' (' + url + ')'};
}); });
...@@ -183,7 +197,11 @@ ...@@ -183,7 +197,11 @@
return loginFromLocalCredential(gadget, url) return loginFromLocalCredential(gadget, url)
.push(function (result) { .push(function (result) {
if (result) { if (result) {
return {status: 'OK', hash: result, url: url}; return {
status: 'OK',
hash: result.hash,
login: result.login,
url: url};
} }
return {status: 'KO', msg: error.msg + ' (' + url + ')'}; return {status: 'KO', msg: error.msg + ' (' + url + ')'};
}); });
...@@ -191,7 +209,7 @@ ...@@ -191,7 +209,7 @@
} }
function changeMonitorPassword(gadget, credential_dict, login, password) { function changeMonitorPassword(gadget, credential_dict, url_key, password) {
var url, var url,
jio_gadget, jio_gadget,
jio_options; jio_options;
...@@ -234,13 +252,10 @@ ...@@ -234,13 +252,10 @@
return new Error("Cannot get document at : " % url); return new Error("Cannot get document at : " % url);
}) })
.push(function (result) { .push(function (result) {
return gadget.props.login_gadget.updateUrlValue(credential_dict.url, login, password) return {status: 'OK', key: url_key};
.push(function() {
return {status: 'OK'};
});
}, function (error) { }, function (error) {
console.log(error); console.log(error);
return {status: 'ERROR', code: error.target.status}; return {status: 'ERROR', code: error.target.status, key: url_key};
}); });
} }
...@@ -360,14 +375,16 @@ ...@@ -360,14 +375,16 @@
return $(gadget.props.element.querySelector("a[href='#config-" + gadget.props.selected + "']")).trigger('click'); return $(gadget.props.element.querySelector("a[href='#config-" + gadget.props.selected + "']")).trigger('click');
}) })
.push(function () { .push(function () {
var text = "Give user name and password that you have.<br/>If required " + var text = "Give username and password that you have.<br/>For each Monitor, " +
"credentials will be updated from what you provided."; "credentials will be saved only if Login/password are valid.<br/> <br>" +
"For simple use, <strong>configure instances with the " +
"same password</strong>.";
return $('.tooltip').tooltipster({ return $('.tooltip').tooltipster({
animation: 'fade', animation: 'fade',
delay: 200, delay: 200,
theme: 'tooltipster-shadow', theme: 'tooltipster-shadow',
touchDevices: true, touchDevices: true,
content: $("<h2><strong>Configure Private Access</strong></h2><p>" + text + "</p>"), content: $("<h2><strong>Monitors Private Access</strong></h2><p>" + text + "</p>"),
interactive: true, interactive: true,
trigger: 'hover' trigger: 'hover'
}); });
...@@ -566,25 +583,28 @@ ...@@ -566,25 +583,28 @@
credential_dict = {}, credential_dict = {},
username = '', username = '',
password = '', password = '',
old_password,
new_password = '', new_password = '',
cnew_password = '', cnew_password = '',
reload = true, reload = true,
rows_list = gadget.props.listbox.property_dict.data_result, rows_list = gadget.props.listbox.property_dict.data_result,
instance_name_dict = {},
not_changed_dict = {}, not_changed_dict = {},
config_promise_list = []; config_promise_list = [];
if (rows_list.length > 0) { if (rows_list.length > 0) {
root_name = rows_list[0].opml_title; root_name = rows_list[0].opml_title;
} }
gadget.props.element.querySelector('.configure .ui-text-error')
.innerHTML = ''; $(gadget.props.element.querySelector('.configure .alert-error'))
.addClass('ui-content-hidden').html('');
if ($(gadget.props.element.querySelector("input[name='configure-newpwd']")).prop('checked')) { if ($(gadget.props.element.querySelector("input[name='configure-newpwd']")).prop('checked')) {
new_password = gadget.props.element.querySelector("input[name='new_password']").value; new_password = gadget.props.element.querySelector("input[name='new_password']").value;
cnew_password = gadget.props.element.querySelector("input[name='new_password_confirm']").value; cnew_password = gadget.props.element.querySelector("input[name='new_password_confirm']").value;
if (new_password !== cnew_password) { if (new_password !== cnew_password) {
gadget.props.element.querySelector('.configure .ui-text-error') $(gadget.props.element.querySelector('.configure .alert-error'))
.innerHTML = 'The new password and it confirmation are differents!'; .removeClass('ui-content-hidden')
.html('The new password and it confirmation are differents!');
return false; return false;
} }
} }
...@@ -592,6 +612,7 @@ ...@@ -592,6 +612,7 @@
.push(function () { .push(function () {
var promise_list = [], var promise_list = [],
i; i;
$(gadget.props.element.querySelector('.spinner')).removeClass('ui-content-hidden');
if ($(gadget.props.element.querySelector("input[name='configure-auth']")).prop('checked')) { if ($(gadget.props.element.querySelector("input[name='configure-auth']")).prop('checked')) {
username = gadget.props.element.querySelector("input[name='username']").value; username = gadget.props.element.querySelector("input[name='username']").value;
password = gadget.props.element.querySelector("input[name='password']").value; password = gadget.props.element.querySelector("input[name='password']").value;
...@@ -614,7 +635,10 @@ ...@@ -614,7 +635,10 @@
if (status_list[i].status !== 'OK') { if (status_list[i].status !== 'OK') {
error_msg += 'Login/password invalid for: ' + rows_list[i].title + '. ' + status_list[i].msg + '<br/>'; error_msg += 'Login/password invalid for: ' + rows_list[i].title + '. ' + status_list[i].msg + '<br/>';
} else if (status_list[i].hasOwnProperty('url')) { } else if (status_list[i].hasOwnProperty('url')) {
not_changed_dict[ hashCode( status_list[i].url ) ] = status_list[i].hash; not_changed_dict[ hashCode( status_list[i].url ) ] = {
hash: status_list[i].hash,
login: (status_list[i].login || username)
};
} }
} }
return error_msg; return error_msg;
...@@ -624,8 +648,9 @@ ...@@ -624,8 +648,9 @@
tmp_hash, tmp_hash,
i; i;
if (error_msg !== '') { if (error_msg !== '') {
gadget.props.element.querySelector('.configure .ui-text-error') $(gadget.props.element.querySelector('.configure .alert-error'))
.innerHTML = error_msg; .removeClass('ui-content-hidden')
.html(error_msg);
new_password = ''; new_password = '';
reload = false; reload = false;
return error_msg; return error_msg;
...@@ -636,15 +661,18 @@ ...@@ -636,15 +661,18 @@
if (validateHttpUrl(rows_list[i].url)) { if (validateHttpUrl(rows_list[i].url)) {
tmp = { tmp = {
hash: btoa(username + ':' + password), hash: btoa(username + ':' + password),
login: username,
url: rows_list[i].url.replace('public', 'private'), // XXX - Need to fix this (replace()) url: rows_list[i].url.replace('public', 'private'), // XXX - Need to fix this (replace())
parent_url: gadget.props.opml_url parent_url: gadget.props.opml_url
//parent_title: root_name //parent_title: root_name
}; };
tmp_hash = hashCode( tmp.url ); tmp_hash = hashCode( tmp.url );
if (not_changed_dict.hasOwnProperty(tmp_hash)) { if (not_changed_dict.hasOwnProperty(tmp_hash)) {
tmp.hash = not_changed_dict[tmp_hash]; tmp.hash = not_changed_dict[tmp_hash].hash;
tmp.login = not_changed_dict[tmp_hash].login;
} }
credential_dict[ tmp_hash ] = tmp; credential_dict[ tmp_hash ] = tmp;
instance_name_dict[ tmp_hash ] = {title: rows_list[i].title};
} }
} }
} }
...@@ -664,29 +692,42 @@ ...@@ -664,29 +692,42 @@
changeMonitorPassword( changeMonitorPassword(
gadget, gadget,
credential_dict[key], credential_dict[key],
username, key,
new_password) new_password)
); );
} }
return RSVP.all(promise_list);
} else {
// Only save provided credentials
return gadget.props.login_gadget.setUrlDict(credential_dict)
.push(function () {
return [];
});
} }
return RSVP.all(promise_list);
}) })
.push(function (result_list) { .push(function (result_list) {
var i, var i,
has_error = false; has_error = false;
for (i = 0; i < result_list.length; i += 1) { for (i = 0; i < result_list.length; i += 1) {
if (result_list[i].status === 'ERROR') { if (result_list[i].status === 'ERROR') {
gadget.props.element.querySelector('.configure .ui-text-error') $(gadget.props.element.querySelector('.configure .alert-error'))
.innerHTML += 'ERROR ' + result_list[i].code + ': Failed to save password! Please try again. <br/>'; .removeClass('ui-content-hidden')
.append('ERROR ' + result_list[i].code + '. [' +
instance_name_dict[result_list[i].key].title + '] Failed to save password, please try again<br/>');
has_error = true; has_error = true;
} else if (result_list[i].status === 'OK') {
// Update if we could change password
credential_dict[result_list[i].key].hash = btoa(
credential_dict[result_list[i].key].login + ':' +
new_password
);
} }
} }
if (credential_dict){
// Only save provided credentials
return gadget.props.login_gadget.setUrlDict(credential_dict)
.push(function () {
has_error;
});
}
return has_error;
})
.push(function (has_error) {
if (! has_error && reload) { if (! has_error && reload) {
if (gadget.props.selected !== "manage") { if (gadget.props.selected !== "manage") {
return gadget.redirect({ return gadget.redirect({
...@@ -696,6 +737,8 @@ ...@@ -696,6 +737,8 @@
} else { } else {
return gadget.reload(); return gadget.reload();
} }
} else {
$(gadget.props.element.querySelector('.spinner')).addClass('ui-content-hidden');
} }
}); });
} }
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.53470.24267.49032</string> </value> <value> <string>950.54797.54715.48554</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>1461861122.87</float> <float>1461942058.71</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