Merge branch 'maintenance' into devel
Conflicts: src/octoprint/static/js/app/viewmodels/loginstate.js
This commit is contained in:
commit
5cdf45d218
2 changed files with 17 additions and 9 deletions
|
|
@ -114,6 +114,8 @@
|
|||
urlToUse += "?" + postfix;
|
||||
}
|
||||
|
||||
console.log("Pinging " + url);
|
||||
|
||||
img.onload = function() {
|
||||
callback("load");
|
||||
calledBack = true;
|
||||
|
|
@ -124,6 +126,7 @@
|
|||
calledBack = true;
|
||||
}
|
||||
};
|
||||
|
||||
img.src = urlToUse;
|
||||
setTimeout(function() {
|
||||
if (!calledBack) {
|
||||
|
|
@ -138,8 +141,14 @@
|
|||
var timeout = 1500;
|
||||
|
||||
var baseUrl = window.location.href;
|
||||
if (baseUrl.indexOf("#") > -1) {
|
||||
baseUrl = baseUrl.substring(0, baseUrl.indexOf("#"));
|
||||
}
|
||||
if (baseUrl.indexOf("/static") > -1) {
|
||||
baseUrl = baseUrl.substring(0, baseUrl.indexOf("/static")) + "/";
|
||||
baseUrl = baseUrl.substring(0, baseUrl.indexOf("/static"));
|
||||
}
|
||||
if (baseUrl[baseUrl.length - 1] != "/") {
|
||||
baseUrl += "/";
|
||||
}
|
||||
var serverOnlineUrl = baseUrl + "online.gif";
|
||||
var backendOnlineUrl = baseUrl + "intermediary.gif";
|
||||
|
|
@ -163,7 +172,6 @@
|
|||
interval = intervals.shift();
|
||||
}
|
||||
serverTimeout = setTimeout(function() {
|
||||
console.log("Pinging " + serverOnlineUrl);
|
||||
ping(serverOnlineUrl, timeout, serverOnlineCallback);
|
||||
}, interval * 1000)
|
||||
}
|
||||
|
|
@ -183,7 +191,7 @@
|
|||
}
|
||||
|
||||
backendOfflineCounter++;
|
||||
if (backendOfflineCounter > 5) {
|
||||
if (backendOfflineCounter > 10) {
|
||||
if (serverTimeout) {
|
||||
window.clearTimeout(serverTimeout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ $(function() {
|
|||
function LoginStateViewModel() {
|
||||
var self = this;
|
||||
|
||||
self.loginUser = ko.observable();
|
||||
self.loginPass = ko.observable();
|
||||
self.loginUser = ko.observable("");
|
||||
self.loginPass = ko.observable("");
|
||||
self.loginRemember = ko.observable(false);
|
||||
|
||||
self.loggedIn = ko.observable(false);
|
||||
|
|
@ -68,14 +68,14 @@ $(function() {
|
|||
var password = p || self.loginPass();
|
||||
var remember = (r != undefined ? r : self.loginRemember());
|
||||
|
||||
self.loginUser("");
|
||||
self.loginPass("");
|
||||
self.loginRemember(false);
|
||||
|
||||
return OctoPrint.browser.login(username, password, remember)
|
||||
.done(function(response) {
|
||||
new PNotify({title: gettext("Login successful"), text: _.sprintf(gettext('You are now logged in as "%(username)s"'), {username: response.name}), type: "success"});
|
||||
self.fromResponse(response);
|
||||
|
||||
self.loginUser("");
|
||||
self.loginPass("");
|
||||
self.loginRemember(false);
|
||||
})
|
||||
.fail(function() {
|
||||
new PNotify({title: gettext("Login failed"), text: gettext("User unknown or wrong password"), type: "error"});
|
||||
|
|
|
|||
Loading…
Reference in a new issue