History: Do not write abort requests to browser history

Remove req.historyTriggered and introduce req.addToHistory.
This commit is contained in:
Marius Hein 2015-02-16 15:56:50 +01:00
parent 6cc428d0e1
commit ea57e7a786
2 changed files with 8 additions and 6 deletions

View File

@ -106,7 +106,6 @@
push: function (url) { push: function (url) {
url = url.replace(/[\?&]?_(render|reload)=[a-z0-9]+/g, ''); url = url.replace(/[\?&]?_(render|reload)=[a-z0-9]+/g, '');
console.log("URL:", url);
if (this.lastPushUrl === url) { if (this.lastPushUrl === url) {
return; return;
} }
@ -159,7 +158,7 @@
icinga.loader.loadUrl( icinga.loader.loadUrl(
main, main,
$('#col1') $('#col1')
).historyTriggered = true; ).addToHistory = false;
} }
if (document.location.hash && document.location.hash.match(/^#!/)) { if (document.location.hash && document.location.hash.match(/^#!/)) {
@ -176,7 +175,7 @@
icinga.loader.loadUrl( icinga.loader.loadUrl(
parts[1], parts[1],
$('#col2') $('#col2')
).historyTriggered = true; ).addToHistory = false;
} }
} }

View File

@ -114,10 +114,10 @@
req.done(this.onResponse); req.done(this.onResponse);
req.fail(this.onFailure); req.fail(this.onFailure);
req.complete(this.onComplete); req.complete(this.onComplete);
req.historyTriggered = false;
req.autorefresh = autorefresh; req.autorefresh = autorefresh;
req.action = action; req.action = action;
req.failure = false; req.failure = false;
req.addToHistory = true;
if (id) { if (id) {
this.requests[id] = req; this.requests[id] = req;
@ -553,7 +553,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.autorefresh && req.addToHistory) {
if (req.$target.hasClass('container') && ! req.failure) { if (req.$target.hasClass('container') && ! req.failure) {
// 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) {
@ -597,7 +597,7 @@
/* /*
* Test if a manual actions comes in and autorefresh is active: Stop refreshing * Test if a manual actions comes in and autorefresh is active: Stop refreshing
*/ */
if (! req.historyTriggered && ! req.autorefresh && req.$target.data('icingaRefresh') > 0 if (req.addToHistory && ! req.autorefresh && req.$target.data('icingaRefresh') > 0
&& req.$target.data('icingaUrl') !== url) { && req.$target.data('icingaUrl') !== url) {
req.$target.data('icingaRefresh', 0); req.$target.data('icingaRefresh', 0);
req.$target.data('icingaUrl', url); req.$target.data('icingaUrl', url);
@ -621,6 +621,9 @@
'Request to ' + url + ' has been aborted for ', 'Request to ' + url + ' has been aborted for ',
req.$target req.$target
); );
// Aborted requests should not be added to browser history
req.addToHistory = false;
} else { } else {
if (this.failureNotice === null) { if (this.failureNotice === null) {
this.failureNotice = this.createNotice( this.failureNotice = this.createNotice(