Commit b992c34e authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_monitoring: fix monitor instance registration

parent 8d66b2e4
......@@ -107,7 +107,7 @@
<value> <string encoding="cdata"><![CDATA[
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
# images/ajax-loader.gif\n
CACHE:\n
......@@ -126,6 +126,7 @@ gadget_jio.html\n
gadget_jio.js\n
gadget_translate.html\n
gadget_translate.js\n
gadget_translation.html\n
handlebars.js\n
i18next.js\n
jiodev.js\n
......@@ -326,7 +327,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.53381.7699.19968</string> </value>
<value> <string>950.54525.37134.26453</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -344,7 +345,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1461861221.53</float>
<float>1461945469.4</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -691,6 +691,59 @@ html table.instance-overview td:first-child > a, html table.instance-overview td
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 all and (max-width: 62em) {
form.search .ui-block-a {
......
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>superalain</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.11464.24567.15445</string> </value>
<value> <string>950.54665.64561.63931</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1459341758.63</float>
<float>1461939565.36</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -60,9 +60,11 @@
if (doc.hasOwnProperty(key)) {
doc[key].hash = btoa(login + ':' + password);
doc[key].url = url;
doc[key].login = login;
} else {
doc[key] = {
hash: btoa(login + ':' + password),
login: login,
url: url,
parent_url: ''};
}
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.51968.20423.17902</string> </value>
<value> <string>950.54785.50611.22596</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1461832953.11</float>
<float>1461942642.99</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -107,9 +107,7 @@
</div>
</div>
</div>
<div class="padding-5">
<span class="ui-text-error"></span>
</div>
<div class="alert alert-error ui-content-hidden"></div>
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a"></div>
<div class="ui-block-b">
......@@ -164,6 +162,7 @@
</div>
<div class="padding-5">
<a href="#page=hosting_overview">Access Applications</a>
<a href="#page=import_export">Export Settings</a>
</div>
</div>
</div>
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.53466.15484.25019</string> </value>
<value> <string>950.54736.61765.9915</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1461860815.17</float>
<float>1461937944.7</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -83,10 +83,16 @@
}
function loadUrlFromOPML(gadget, url) {
var text_content = gadget.props.element.querySelector('form.opml button.show')
.textContent;
return new RSVP.Queue()
.push(function () {
return $("article.configure-b").addClass("ui-content-hidden");
})
.push(function () {
gadget.props.element.querySelector('form.opml button.show')
.textContent = "Loading...";
})
.push(function () {
var listbox_configuration = {
enable_search: false,
......@@ -121,6 +127,8 @@
return gadget.props.listbox.render(listbox_configuration);
})
.push(function () {
gadget.props.element.querySelector('form.opml button.show')
.textContent = text_content;
if (gadget.props.listbox.property_dict.data_result.length > 0) {
return $("article.configure-b").removeClass("ui-content-hidden");
} else {
......@@ -130,6 +138,8 @@
}
//return $(gadget.props.element.querySelector(".configure-b")).show();
}, 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')
.innerHTML = "ERROR " + (error.target.status || '') + "Failed to load URL!";
......@@ -151,7 +161,7 @@
return gadget.props.login_gadget.login(credential.url, credential.hash)
.then(function(result) {
if (result.status === 'OK') {
return credential.hash;
return credential;
} else {
return undefined;
}
......@@ -174,7 +184,11 @@
return loginFromLocalCredential(gadget, url)
.push(function (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 + ')'};
});
......@@ -183,7 +197,11 @@
return loginFromLocalCredential(gadget, url)
.push(function (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 + ')'};
});
......@@ -191,7 +209,7 @@
}
function changeMonitorPassword(gadget, credential_dict, login, password) {
function changeMonitorPassword(gadget, credential_dict, url_key, password) {
var url,
jio_gadget,
jio_options;
......@@ -234,13 +252,10 @@
return new Error("Cannot get document at : " % url);
})
.push(function (result) {
return gadget.props.login_gadget.updateUrlValue(credential_dict.url, login, password)
.push(function() {
return {status: 'OK'};
});
return {status: 'OK', key: url_key};
}, function (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 @@
return $(gadget.props.element.querySelector("a[href='#config-" + gadget.props.selected + "']")).trigger('click');
})
.push(function () {
var text = "Give user name and password that you have.<br/>If required " +
"credentials will be updated from what you provided.";
var text = "Give username and password that you have.<br/>For each Monitor, " +
"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({
animation: 'fade',
delay: 200,
theme: 'tooltipster-shadow',
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,
trigger: 'hover'
});
......@@ -566,25 +583,28 @@
credential_dict = {},
username = '',
password = '',
old_password,
new_password = '',
cnew_password = '',
reload = true,
rows_list = gadget.props.listbox.property_dict.data_result,
instance_name_dict = {},
not_changed_dict = {},
config_promise_list = [];
if (rows_list.length > 0) {
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')) {
new_password = gadget.props.element.querySelector("input[name='new_password']").value;
cnew_password = gadget.props.element.querySelector("input[name='new_password_confirm']").value;
if (new_password !== cnew_password) {
gadget.props.element.querySelector('.configure .ui-text-error')
.innerHTML = 'The new password and it confirmation are differents!';
$(gadget.props.element.querySelector('.configure .alert-error'))
.removeClass('ui-content-hidden')
.html('The new password and it confirmation are differents!');
return false;
}
}
......@@ -592,6 +612,7 @@
.push(function () {
var promise_list = [],
i;
$(gadget.props.element.querySelector('.spinner')).removeClass('ui-content-hidden');
if ($(gadget.props.element.querySelector("input[name='configure-auth']")).prop('checked')) {
username = gadget.props.element.querySelector("input[name='username']").value;
password = gadget.props.element.querySelector("input[name='password']").value;
......@@ -614,7 +635,10 @@
if (status_list[i].status !== 'OK') {
error_msg += 'Login/password invalid for: ' + rows_list[i].title + '. ' + status_list[i].msg + '<br/>';
} 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;
......@@ -624,8 +648,9 @@
tmp_hash,
i;
if (error_msg !== '') {
gadget.props.element.querySelector('.configure .ui-text-error')
.innerHTML = error_msg;
$(gadget.props.element.querySelector('.configure .alert-error'))
.removeClass('ui-content-hidden')
.html(error_msg);
new_password = '';
reload = false;
return error_msg;
......@@ -636,15 +661,18 @@
if (validateHttpUrl(rows_list[i].url)) {
tmp = {
hash: btoa(username + ':' + password),
login: username,
url: rows_list[i].url.replace('public', 'private'), // XXX - Need to fix this (replace())
parent_url: gadget.props.opml_url
//parent_title: root_name
};
tmp_hash = hashCode( tmp.url );
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;
instance_name_dict[ tmp_hash ] = {title: rows_list[i].title};
}
}
}
......@@ -664,29 +692,42 @@
changeMonitorPassword(
gadget,
credential_dict[key],
username,
key,
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) {
var i,
has_error = false;
for (i = 0; i < result_list.length; i += 1) {
if (result_list[i].status === 'ERROR') {
gadget.props.element.querySelector('.configure .ui-text-error')
.innerHTML += 'ERROR ' + result_list[i].code + ': Failed to save password! Please try again. <br/>';
$(gadget.props.element.querySelector('.configure .alert-error'))
.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;
} 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 (gadget.props.selected !== "manage") {
return gadget.redirect({
......@@ -696,6 +737,8 @@
} else {
return gadget.reload();
}
} else {
$(gadget.props.element.querySelector('.spinner')).addClass('ui-content-hidden');
}
});
}
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.53470.24267.49032</string> </value>
<value> <string>950.54797.54715.48554</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1461861122.87</float>
<float>1461942058.71</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