mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
JS/cleanup: start to clean up response handling
First step: get rid of the messy workaround for the problem that notifications got lost once the whole body is re-rendered. This should be solved either on server side or by detaching and re- attaching existing notifications in such scenario.
This commit is contained in:
parent
2d228ce83d
commit
4646b74fbc
@ -220,6 +220,14 @@
|
|||||||
this.autorefreshEnabled = true;
|
this.autorefreshEnabled = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
processNotificationHeader: function(req) {
|
||||||
|
var header = req.getResponseHeader('X-Icinga-Notification');
|
||||||
|
if (typeof header === 'undefined' || ! header) return false;
|
||||||
|
var parts = decodeURIComponent(header).split(' ');
|
||||||
|
this.createNotice(parts.shift(), parts.join(' '));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle successful XHR response
|
* Handle successful XHR response
|
||||||
*/
|
*/
|
||||||
@ -244,6 +252,8 @@
|
|||||||
this.icinga.logger.debug(
|
this.icinga.logger.debug(
|
||||||
'Got response for ', req.$target, ', URL was ' + url
|
'Got response for ', req.$target, ', URL was ' + url
|
||||||
);
|
);
|
||||||
|
this.processNotificationHeader(req);
|
||||||
|
|
||||||
var redirect = req.getResponseHeader('X-Icinga-Redirect');
|
var redirect = req.getResponseHeader('X-Icinga-Redirect');
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
this.icinga.logger.debug(
|
this.icinga.logger.debug(
|
||||||
@ -295,20 +305,11 @@
|
|||||||
active = $('[href].active', req.$target).attr('href');
|
active = $('[href].active', req.$target).attr('href');
|
||||||
}
|
}
|
||||||
|
|
||||||
var notifications = req.getResponseHeader('X-Icinga-Notification');
|
|
||||||
if (notifications) {
|
|
||||||
notifications = decodeURIComponent(notifications);
|
|
||||||
}
|
|
||||||
|
|
||||||
var target = req.getResponseHeader('X-Icinga-Container');
|
var target = req.getResponseHeader('X-Icinga-Container');
|
||||||
var newBody = false;
|
var newBody = false;
|
||||||
if (target) {
|
if (target) {
|
||||||
if (target === 'ignore') {
|
if (target === 'ignore') {
|
||||||
var parts = notifications.split(' ');
|
|
||||||
this.createNotice(
|
|
||||||
parts.shift(),
|
|
||||||
parts.join(' ')
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If we change the target, oncomplete will fail to clean up
|
// If we change the target, oncomplete will fail to clean up
|
||||||
@ -319,14 +320,6 @@
|
|||||||
newBody = true;
|
newBody = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! newBody && notifications) {
|
|
||||||
var parts = notifications.split(' ');
|
|
||||||
this.createNotice(
|
|
||||||
parts.shift(),
|
|
||||||
parts.join(' ')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var moduleName = req.getResponseHeader('X-Icinga-Module');
|
var moduleName = req.getResponseHeader('X-Icinga-Module');
|
||||||
classes = $.grep(req.$target.classes(), function (el) {
|
classes = $.grep(req.$target.classes(), function (el) {
|
||||||
if (el === 'icinga-module' || el.match(/^module\-/)) {
|
if (el === 'icinga-module' || el.match(/^module\-/)) {
|
||||||
@ -438,17 +431,7 @@
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (rendered) {
|
if (rendered) return;
|
||||||
|
|
||||||
if (newBody && notifications) {
|
|
||||||
var parts = notifications.split(' ');
|
|
||||||
this.createNotice(
|
|
||||||
parts.shift(),
|
|
||||||
parts.join(' ')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// .html() removes outer div we added above
|
// .html() removes outer div we added above
|
||||||
this.renderContentToContainer($resp.html(), req.$target, req.action);
|
this.renderContentToContainer($resp.html(), req.$target, req.action);
|
||||||
@ -458,13 +441,6 @@
|
|||||||
if (newBody) {
|
if (newBody) {
|
||||||
this.icinga.ui.fixDebugVisibility().triggerWindowResize();
|
this.icinga.ui.fixDebugVisibility().triggerWindowResize();
|
||||||
}
|
}
|
||||||
if (newBody && notifications) {
|
|
||||||
var parts = notifications.split(' ');
|
|
||||||
this.createNotice(
|
|
||||||
parts.shift(),
|
|
||||||
parts.join(' ')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
var focusedUrl = this.icinga.ui.getFocusedContainerDataUrl();
|
var focusedUrl = this.icinga.ui.getFocusedContainerDataUrl();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user