Failure requests: Fix auto refresh and history

Allow to change url's in history and stop auto auto refresh if
the container URL is not up to date.
This commit is contained in:
Marius Hein 2015-02-02 13:32:40 +01:00
parent 8c24dde17b
commit 8c758a9f12
1 changed files with 14 additions and 2 deletions

View File

@ -107,7 +107,8 @@
url : url, url : url,
data : data, data : data,
headers: headers, headers: headers,
context: self context: self,
failure: false
}); });
req.$target = $target; req.$target = $target;
@ -553,7 +554,7 @@
// Update history when necessary. Don't do so for requests triggered // Update history when necessary. Don't do so for requests triggered
// by history or autorefresh events // by history or autorefresh events
if (! req.historyTriggered && ! req.autorefresh) { if (! req.historyTriggered && ! req.autorefresh) {
if (req.$target.hasClass('container')) { if (req.$target.hasClass('container') && req.failure === false) {
// We only want to care about top-level containers // We only want to care about top-level containers
if (req.$target.parent().closest('.container').length === 0) { if (req.$target.parent().closest('.container').length === 0) {
this.icinga.history.pushCurrentState(); this.icinga.history.pushCurrentState();
@ -589,6 +590,17 @@
onFailure: function (req, textStatus, errorThrown) { onFailure: function (req, textStatus, errorThrown) {
var url = req.url; var url = req.url;
req.failure = true;
/*
* Test if a manual actions comes in and autorefresh is active: Stop refreshing
*/
if (! req.historyTriggered && ! req.autorefresh && req.$target.data('icingaRefresh') > 0
&& req.$target.data('icingaUrl') !== url) {
req.$target.data('icingaRefresh', 0);
req.$target.data('icingaUrl', url);
}
if (req.status > 0) { if (req.status > 0) {
this.icinga.logger.error( this.icinga.logger.error(
req.status, req.status,