Menu: Move request handling to complete
If a failure occur the menu is still working.
This commit is contained in:
parent
bfb2f710a1
commit
6555a2ec0a
|
@ -342,42 +342,11 @@
|
||||||
var rendered = false;
|
var rendered = false;
|
||||||
var classes;
|
var classes;
|
||||||
|
|
||||||
if (! req.autorefresh) {
|
if (req.autorefresh) {
|
||||||
// TODO: Hook for response/url?
|
|
||||||
var $forms = $('[action="' + this.icinga.utils.parseUrl(url).path + '"]');
|
|
||||||
var $matches = $.merge($('[href="' + url + '"]'), $forms);
|
|
||||||
$matches.each(function (idx, el) {
|
|
||||||
if ($(el).closest('#menu').length) {
|
|
||||||
if (req.$target[0].id === 'col1') {
|
|
||||||
self.icinga.behaviors.navigation.resetActive();
|
|
||||||
}
|
|
||||||
} else if ($(el).closest('table.action').length) {
|
|
||||||
$(el).closest('table.action').find('.active').removeClass('active');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$matches.each(function (idx, el) {
|
|
||||||
var $el = $(el);
|
|
||||||
if ($el.closest('#menu').length) {
|
|
||||||
if ($el.is('form')) {
|
|
||||||
$('input', $el).addClass('active');
|
|
||||||
} else {
|
|
||||||
if (req.$target[0].id === 'col1') {
|
|
||||||
self.icinga.behaviors.navigation.setActive($el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Interrupt .each, only on menu item shall be active
|
|
||||||
return false;
|
|
||||||
} else if ($(el).closest('table.action').length) {
|
|
||||||
$el.addClass('active');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// TODO: next container url
|
// TODO: next container url
|
||||||
active = $('[href].active', req.$target).attr('href');
|
active = $('[href].active', req.$target).attr('href');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var target = req.getResponseHeader('X-Icinga-Container');
|
var target = req.getResponseHeader('X-Icinga-Container');
|
||||||
var newBody = false;
|
var newBody = false;
|
||||||
var oldNotifications = false;
|
var oldNotifications = false;
|
||||||
|
@ -551,6 +520,39 @@
|
||||||
* Regardless of whether a request succeeded of failed, clean up
|
* Regardless of whether a request succeeded of failed, clean up
|
||||||
*/
|
*/
|
||||||
onComplete: function (req, textStatus) {
|
onComplete: function (req, textStatus) {
|
||||||
|
if (! req.autorefresh) {
|
||||||
|
// TODO: Hook for response/url?
|
||||||
|
var url = req.url;
|
||||||
|
var $forms = $('[action="' + this.icinga.utils.parseUrl(url).path + '"]');
|
||||||
|
var $matches = $.merge($('[href="' + url + '"]'), $forms);
|
||||||
|
$matches.each(function (idx, el) {
|
||||||
|
if ($(el).closest('#menu').length) {
|
||||||
|
if (req.$target[0].id === 'col1') {
|
||||||
|
self.icinga.behaviors.navigation.resetActive();
|
||||||
|
}
|
||||||
|
} else if ($(el).closest('table.action').length) {
|
||||||
|
$(el).closest('table.action').find('.active').removeClass('active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$matches.each(function (idx, el) {
|
||||||
|
var $el = $(el);
|
||||||
|
if ($el.closest('#menu').length) {
|
||||||
|
if ($el.is('form')) {
|
||||||
|
$('input', $el).addClass('active');
|
||||||
|
} else {
|
||||||
|
if (req.$target[0].id === 'col1') {
|
||||||
|
self.icinga.behaviors.navigation.setActive($el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Interrupt .each, only on menu item shall be active
|
||||||
|
return false;
|
||||||
|
} else if ($(el).closest('table.action').length) {
|
||||||
|
$el.addClass('active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
|
|
Loading…
Reference in New Issue