mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
notifications: improve client- and serverside
This is just a first step, trying to catch a few gotchas: * it doesn't send notifications to the browser when issueing a redirect as redirects can currently not be catched in jQuery response handlers * it tries to find a better notification handling place in the response handler (JS) - still imperfect * it explicitely stores sessions once modified by notifications. Still need to crosscheck whether this is really needed and how we can get rid of this. refs #6280
This commit is contained in:
parent
4f1b7f16e4
commit
70ba36aad6
@ -81,6 +81,8 @@ class ActionController extends Zend_Controller_Action
|
|||||||
|
|
||||||
private $windowId;
|
private $windowId;
|
||||||
|
|
||||||
|
protected $isRedirect = false;
|
||||||
|
|
||||||
// TODO: This would look better if we had a ModuleActionController
|
// TODO: This would look better if we had a ModuleActionController
|
||||||
public function Config($file = null)
|
public function Config($file = null)
|
||||||
{
|
{
|
||||||
@ -371,6 +373,7 @@ class ActionController extends Zend_Controller_Action
|
|||||||
$url = Url::fromPath($url)->getRelativeUrl();
|
$url = Url::fromPath($url)->getRelativeUrl();
|
||||||
}
|
}
|
||||||
$this->_helper->Redirector->gotoUrlAndExit(preg_replace('~&~', '&', $url));
|
$this->_helper->Redirector->gotoUrlAndExit(preg_replace('~&~', '&', $url));
|
||||||
|
$this->isRedirect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -412,7 +415,7 @@ class ActionController extends Zend_Controller_Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
$notifications = Notification::getInstance();
|
$notifications = Notification::getInstance();
|
||||||
if ($isXhr && $notifications->hasMessages()) {
|
if ($isXhr && ! $this->isRedirect && $notifications->hasMessages()) {
|
||||||
foreach ($notifications->getMessages() as $m) {
|
foreach ($notifications->getMessages() as $m) {
|
||||||
header('X-Icinga-Notification: ' . $m->type . ' ' . $m->message);
|
header('X-Icinga-Notification: ' . $m->type . ' ' . $m->message);
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,7 @@ class Notification
|
|||||||
$msgs = $session->messages;
|
$msgs = $session->messages;
|
||||||
$msgs[] = $mo;
|
$msgs[] = $mo;
|
||||||
$session->messages = $msgs;
|
$session->messages = $msgs;
|
||||||
|
$session->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasMessages()
|
public function hasMessages()
|
||||||
@ -125,6 +126,7 @@ class Notification
|
|||||||
$session = Session::getSession();
|
$session = Session::getSession();
|
||||||
$msgs = $session->messages;
|
$msgs = $session->messages;
|
||||||
$session->messages = array();
|
$session->messages = array();
|
||||||
|
$session->write();
|
||||||
return $msgs;
|
return $msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,13 +287,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var notifications = req.getResponseHeader('X-Icinga-Notification');
|
var notifications = req.getResponseHeader('X-Icinga-Notification');
|
||||||
if (notifications) {
|
|
||||||
var parts = notifications.split(' ');
|
|
||||||
this.createNotice(
|
|
||||||
parts.shift(),
|
|
||||||
parts.join(' ')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
var target = req.getResponseHeader('X-Icinga-Container');
|
var target = req.getResponseHeader('X-Icinga-Container');
|
||||||
@ -310,6 +303,14 @@
|
|||||||
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\-/)) {
|
||||||
@ -424,6 +425,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (rendered) {
|
if (rendered) {
|
||||||
|
|
||||||
|
if (newBody && notifications) {
|
||||||
|
var parts = notifications.split(' ');
|
||||||
|
this.createNotice(
|
||||||
|
parts.shift(),
|
||||||
|
parts.join(' ')
|
||||||
|
);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,6 +444,14 @@
|
|||||||
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