Merge pull request #3857 from Icinga/fix/wrong-window-title-on-some-pages-3851

Fix wrong window title on some pages
This commit is contained in:
Johannes Meyer 2019-07-15 08:37:29 +02:00 committed by GitHub
commit 8ad3754c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 94 additions and 6 deletions

View File

@ -13,6 +13,7 @@ class AboutController extends Controller
{ {
$this->view->version = Version::get(); $this->view->version = Version::get();
$this->view->modules = Icinga::app()->getModuleManager()->getLoadedModules(); $this->view->modules = Icinga::app()->getModuleManager()->getLoadedModules();
$this->view->title = $this->translate('About');
$this->view->tabs = $this->getTabs()->add( $this->view->tabs = $this->getTabs()->add(
'about', 'about',
array( array(

View File

@ -68,6 +68,7 @@ class AccountController extends Controller
$form->handleRequest(); $form->handleRequest();
$this->view->form = $form; $this->view->form = $form;
$this->view->title = $this->translate('My Account');
$this->getTabs()->activate('account'); $this->getTabs()->activate('account');
} }
} }

View File

@ -12,6 +12,13 @@ use Icinga\Web\Url;
class AnnouncementsController extends Controller class AnnouncementsController extends Controller
{ {
public function init()
{
$this->view->title = $this->translate('Announcements');
parent::init();
}
/** /**
* List all announcements * List all announcements
*/ */

View File

@ -54,7 +54,7 @@ class AuthenticationController extends Controller
$form->handleRequest(); $form->handleRequest();
} }
$this->view->form = $form; $this->view->form = $form;
$this->view->title = $this->translate('Icinga Web 2 Login'); $this->view->defaultTitle = $this->translate('Icinga Web 2 Login');
$this->view->requiresSetup = $requiresSetup; $this->view->requiresSetup = $requiresSetup;
} }

View File

@ -82,6 +82,7 @@ class ConfigController extends Controller
$form->handleRequest(); $form->handleRequest();
$this->view->form = $form; $this->view->form = $form;
$this->view->title = $this->translate('General');
$this->createApplicationTabs()->activate('general'); $this->createApplicationTabs()->activate('general');
} }
@ -107,6 +108,7 @@ class ConfigController extends Controller
->order('name'); ->order('name');
$this->setupLimitControl(); $this->setupLimitControl();
$this->setupPaginationControl($this->view->modules); $this->setupPaginationControl($this->view->modules);
$this->view->title = $this->translate('Modules');
} }
public function moduleAction() public function moduleAction()
@ -137,6 +139,7 @@ class ConfigController extends Controller
$this->view->module = $module; $this->view->module = $module;
$this->view->toggleForm = $toggleForm; $this->view->toggleForm = $toggleForm;
$this->view->title = $module->getName();
$this->view->tabs = $module->getConfigTabs()->activate('info'); $this->view->tabs = $module->getConfigTabs()->activate('info');
$this->view->moduleGitCommitId = Version::getGitHead($module->getBaseDir()); $this->view->moduleGitCommitId = Version::getGitHead($module->getBaseDir());
} else { } else {
@ -209,6 +212,7 @@ class ConfigController extends Controller
$this->view->form = $form; $this->view->form = $form;
$this->view->backendNames = Config::app('groups'); $this->view->backendNames = Config::app('groups');
$this->createApplicationTabs()->activate('authentication'); $this->createApplicationTabs()->activate('authentication');
$this->view->title = $this->translate('Authentication');
$this->render('userbackend/reorder'); $this->render('userbackend/reorder');
} }
@ -255,6 +259,7 @@ class ConfigController extends Controller
}); });
$form->handleRequest(); $form->handleRequest();
$this->view->title = $this->translate('Authentication');
$this->renderForm($form, $this->translate('New User Backend')); $this->renderForm($form, $this->translate('New User Backend'));
} }
@ -293,6 +298,7 @@ class ConfigController extends Controller
$this->httpNotFound(sprintf($this->translate('User backend "%s" not found'), $backendName)); $this->httpNotFound(sprintf($this->translate('User backend "%s" not found'), $backendName));
} }
$this->view->title = $this->translate('Authentication');
$this->renderForm($form, $this->translate('Update User Backend')); $this->renderForm($form, $this->translate('Update User Backend'));
} }
@ -325,6 +331,7 @@ class ConfigController extends Controller
}); });
$form->handleRequest(); $form->handleRequest();
$this->view->title = $this->translate('Authentication');
$this->renderForm($form, $this->translate('Remove User Backend')); $this->renderForm($form, $this->translate('Remove User Backend'));
} }
@ -338,6 +345,7 @@ class ConfigController extends Controller
->setKeyColumn('name') ->setKeyColumn('name')
->select() ->select()
->order('name'); ->order('name');
$this->view->title = $this->translate('Resources');
$this->createApplicationTabs()->activate('resource'); $this->createApplicationTabs()->activate('resource');
} }
@ -358,6 +366,7 @@ class ConfigController extends Controller
$form->handleRequest(); $form->handleRequest();
$this->view->form = $form; $this->view->form = $form;
$this->view->title = $this->translate('Resources');
$this->render('resource/create'); $this->render('resource/create');
} }
@ -377,6 +386,7 @@ class ConfigController extends Controller
$form->handleRequest(); $form->handleRequest();
$this->view->form = $form; $this->view->form = $form;
$this->view->title = $this->translate('Resources');
$this->render('resource/modify'); $this->render('resource/modify');
} }
@ -441,6 +451,7 @@ class ConfigController extends Controller
} }
$this->view->form = $form; $this->view->form = $form;
$this->view->title = $this->translate('Resources');
$this->render('resource/remove'); $this->render('resource/remove');
} }
} }

View File

@ -21,6 +21,13 @@ use Icinga\Web\Widget;
class GroupController extends AuthBackendController class GroupController extends AuthBackendController
{ {
public function init()
{
$this->view->title = $this->translate('User Groups');
parent::init();
}
/** /**
* List all user groups of a single backend * List all user groups of a single backend
*/ */

View File

@ -54,5 +54,6 @@ class ListController extends Controller
$this->setupLimitControl(); $this->setupLimitControl();
$this->setupPaginationControl($this->view->logData); $this->setupPaginationControl($this->view->logData);
$this->view->title = $this->translate('Application Log');
} }
} }

View File

@ -127,6 +127,7 @@ class NavigationController extends Controller
$this->view->types = $this->listItemTypes(); $this->view->types = $this->listItemTypes();
$this->view->items = $query; $this->view->items = $query;
$this->view->title = $this->translate('Navigation');
$this->getTabs() $this->getTabs()
->add( ->add(
'account', 'account',
@ -187,6 +188,7 @@ class NavigationController extends Controller
$this->view->types = $this->listItemTypes(); $this->view->types = $this->listItemTypes();
$this->view->items = $query; $this->view->items = $query;
$this->view->title = $this->translate('Shared Navigation');
$this->getTabs()->add( $this->getTabs()->add(
'navigation/shared', 'navigation/shared',
array( array(
@ -242,6 +244,7 @@ class NavigationController extends Controller
}); });
$form->handleRequest(); $form->handleRequest();
$this->view->title = $this->translate('Navigation');
$this->renderForm($form, $this->translate('New Navigation Item')); $this->renderForm($form, $this->translate('New Navigation Item'));
} }
@ -297,6 +300,7 @@ class NavigationController extends Controller
$this->httpNotFound(sprintf($this->translate('Navigation item "%s" not found'), $itemName)); $this->httpNotFound(sprintf($this->translate('Navigation item "%s" not found'), $itemName));
} }
$this->view->title = $this->translate('Navigation');
$this->renderForm($form, $this->translate('Update Navigation Item')); $this->renderForm($form, $this->translate('Update Navigation Item'));
} }
@ -340,6 +344,7 @@ class NavigationController extends Controller
}); });
$form->handleRequest(); $form->handleRequest();
$this->view->title = $this->translate('Navigation');
$this->renderForm($form, $this->translate('Remove Navigation Item')); $this->renderForm($form, $this->translate('Remove Navigation Item'));
} }
@ -428,5 +433,6 @@ class NavigationController extends Controller
} }
$this->view->navigation = $navigation; $this->view->navigation = $navigation;
$this->view->title = $navigation->getLabel();
} }
} }

View File

@ -18,6 +18,13 @@ use Icinga\Web\Notification;
*/ */
class RoleController extends AuthBackendController class RoleController extends AuthBackendController
{ {
public function init()
{
$this->view->title = $this->translate('Roles');
parent::init();
}
/** /**
* List roles * List roles
* *

View File

@ -20,6 +20,13 @@ use Icinga\Web\Widget;
class UserController extends AuthBackendController class UserController extends AuthBackendController
{ {
public function init()
{
$this->view->title = $this->translate('Users');
parent::init();
}
/** /**
* List all users of a single backend * List all users of a single backend
*/ */

View File

@ -58,6 +58,7 @@ class UsergroupbackendController extends Controller
}); });
$form->handleRequest(); $form->handleRequest();
$this->view->title = $this->translate('Authentication');
$this->renderForm($form, $this->translate('New User Group Backend')); $this->renderForm($form, $this->translate('New User Group Backend'));
} }
@ -94,6 +95,7 @@ class UsergroupbackendController extends Controller
$this->httpNotFound(sprintf($this->translate('User group backend "%s" not found'), $backendName)); $this->httpNotFound(sprintf($this->translate('User group backend "%s" not found'), $backendName));
} }
$this->view->title = $this->translate('Authentication');
$this->renderForm($form, $this->translate('Update User Group Backend')); $this->renderForm($form, $this->translate('Update User Group Backend'));
} }
@ -125,6 +127,7 @@ class UsergroupbackendController extends Controller
}); });
$form->handleRequest(); $form->handleRequest();
$this->view->title = $this->translate('Authentication');
$this->renderForm($form, $this->translate('Remove User Group Backend')); $this->renderForm($form, $this->translate('Remove User Group Backend'));
} }
} }

View File

@ -46,7 +46,13 @@ if ($this->layout()->inlineLayout) {
</div> </div>
<?php endif ?> <?php endif ?>
<div id="main" role="main"> <div id="main" role="main">
<div id="col1" class="container<?= $moduleClass ?>"<?php if ($moduleName): ?> data-icinga-module="<?= $moduleName ?>" <?php endif ?> data-icinga-url="<?= $this->escape(Url::fromRequest()->without('renderLayout')->getAbsoluteUrl()); ?>"<?= $refresh; ?> style="display: block"> <div id="col1"
class="container<?= $moduleClass ?>"
<?php if ($moduleName): ?>data-icinga-module="<?= $moduleName ?>"<?php endif ?>
data-icinga-title="<?= ! empty($this->title) ? $this->escape($this->title) . ' :: ' : '' ?><?= $this->defaultTitle ?>"
data-icinga-url="<?= $this->escape(Url::fromRequest()->without('renderLayout')->getAbsoluteUrl()); ?>"
<?= $refresh; ?>
style="display: block">
<?= $this->render($inlineLayoutScript) ?> <?= $this->render($inlineLayoutScript) ?>
</div> </div>
<div id="col2" class="container"> <div id="col2" class="container">

View File

@ -27,7 +27,7 @@ $innerLayoutScript = $this->layout()->innerLayout . '.phtml';
<meta name="google" value="notranslate"> <meta name="google" value="notranslate">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="cleartype" content="on"> <meta http-equiv="cleartype" content="on">
<title><?= $this->title ? $this->escape($this->title) : $this->defaultTitle ?></title> <title><?= $this->title ? $this->escape($this->title) . ' :: ' : '' ?><?= $this->defaultTitle ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="application-name" content="Icinga Web 2"> <meta name="application-name" content="Icinga Web 2">

View File

@ -511,11 +511,11 @@ class ActionController extends Zend_Controller_Action
} }
$resp->setHeader( $resp->setHeader(
'X-Icinga-Title', 'X-Icinga-Title',
rawurlencode($this->view->title . ' :: ' . static::DEFAULT_TITLE), rawurlencode($this->view->title . ' :: ' . $this->view->defaultTitle),
true true
); );
} else { } else {
$resp->setHeader('X-Icinga-Title', rawurlencode(static::DEFAULT_TITLE), true); $resp->setHeader('X-Icinga-Title', rawurlencode($this->view->defaultTitle), true);
} }
$layout = $this->_helper->layout(); $layout = $this->_helper->layout();

View File

@ -66,6 +66,7 @@ class CommentController extends Controller
public function showAction() public function showAction()
{ {
$this->view->comment = $this->comment; $this->view->comment = $this->comment;
$this->view->title = $this->translate('Comments');
if ($this->hasPermission('monitoring/command/comment/delete')) { if ($this->hasPermission('monitoring/command/comment/delete')) {
$listUrl = Url::fromPath('monitoring/list/comments') $listUrl = Url::fromPath('monitoring/list/comments')

View File

@ -56,6 +56,7 @@ class CommentsController extends Controller
$this->comments = $query; $this->comments = $query;
$this->view->title = $this->translate('Comments');
$this->getTabs()->add( $this->getTabs()->add(
'comments', 'comments',
array( array(

View File

@ -27,6 +27,8 @@ class ConfigController extends Controller
public function init() public function init()
{ {
$this->assertPermission('config/modules'); $this->assertPermission('config/modules');
$this->view->title = $this->translate('Backends');
$this->view->defaultTitle = 'monitoring :: ' . $this->view->defaultTitle;
parent::init(); parent::init();
} }
@ -290,6 +292,7 @@ class ConfigController extends Controller
$form->handleRequest(); $form->handleRequest();
$this->view->form = $form; $this->view->form = $form;
$this->view->title = $this->translate('Security');
$this->view->tabs = $this->Module()->getConfigTabs()->activate('security'); $this->view->tabs = $this->Module()->getConfigTabs()->activate('security');
} }
} }

View File

@ -86,6 +86,7 @@ class DowntimeController extends Controller
$this->view->stateName = $isService ? Service::getStateText($this->downtime->service_state) $this->view->stateName = $isService ? Service::getStateText($this->downtime->service_state)
: Host::getStateText($this->downtime->host_state); : Host::getStateText($this->downtime->host_state);
$this->view->title = $this->translate('Downtimes');
if ($this->hasPermission('monitoring/command/downtime/delete')) { if ($this->hasPermission('monitoring/command/downtime/delete')) {
$form = new DeleteDowntimeCommandForm(); $form = new DeleteDowntimeCommandForm();
$form $form

View File

@ -63,6 +63,7 @@ class DowntimesController extends Controller
$this->downtimes = $query; $this->downtimes = $query;
$this->view->title = $this->translate('Downtimes');
$this->getTabs()->add( $this->getTabs()->add(
'downtimes', 'downtimes',
array( array(

View File

@ -70,6 +70,7 @@ class EventController extends Controller
$this->getDetails($type, $event) $this->getDetails($type, $event)
); );
$this->view->title = $this->translate('Event Overview');
$this->getTabs() $this->getTabs()
->add('event', array( ->add('event', array(
'title' => $label, 'title' => $label,

View File

@ -113,6 +113,7 @@ class HealthController extends Controller
*/ */
public function statsAction() public function statsAction()
{ {
$this->view->title = $this->translate('Stats');
$this->getTabs()->activate('stats'); $this->getTabs()->activate('stats');
$servicestats = $this->backend->select()->from('servicestatussummary', array( $servicestats = $this->backend->select()->from('servicestatussummary', array(

View File

@ -35,6 +35,8 @@ class HostController extends MonitoredObjectController
$this->object = $host; $this->object = $host;
$this->createTabs(); $this->createTabs();
$this->getTabs()->activate('host'); $this->getTabs()->activate('host');
$this->view->title = $host->host_display_name;
$this->view->defaultTitle = $this->translate('Hosts') . ' :: ' . $this->view->defaultTitle;
} }
/** /**

View File

@ -68,6 +68,7 @@ class HostsController extends Controller
) )
)->extend(new DashboardAction())->extend(new MenuAction())->activate('show'); )->extend(new DashboardAction())->extend(new MenuAction())->activate('show');
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts'); $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts');
$this->view->title = $this->translate('Hosts');
} }
protected function handleCommandForm(ObjectsCommandForm $form) protected function handleCommandForm(ObjectsCommandForm $form)

View File

@ -40,6 +40,12 @@ class ServiceController extends MonitoredObjectController
$this->object = $service; $this->object = $service;
$this->createTabs(); $this->createTabs();
$this->getTabs()->activate('service'); $this->getTabs()->activate('service');
$this->view->title = $service->service_display_name;
$this->view->defaultTitle = join(' :: ', [
$service->host_display_name,
$this->translate('Services'),
$this->view->defaultTitle
]);
} }
/** /**

View File

@ -74,6 +74,7 @@ class ServicesController extends Controller
'url' => Url::fromRequest() 'url' => Url::fromRequest()
) )
)->extend(new DashboardAction())->extend(new MenuAction())->activate('show'); )->extend(new DashboardAction())->extend(new MenuAction())->activate('show');
$this->view->title = $this->translate('Services');
} }
protected function handleCommandForm(ObjectsCommandForm $form) protected function handleCommandForm(ObjectsCommandForm $form)

View File

@ -19,6 +19,13 @@ class ShowController extends Controller
*/ */
protected $backend; protected $backend;
public function init()
{
$this->view->defaultTitle = $this->translate('Contacts') . ' :: ' . $this->view->defaultTitle;
parent::init();
}
public function contactAction() public function contactAction()
{ {
$contactName = $this->params->getRequired('contact_name'); $contactName = $this->params->getRequired('contact_name');
@ -71,6 +78,7 @@ class ShowController extends Controller
$this->view->notifications = $notifications; $this->view->notifications = $notifications;
$this->setupLimitControl(); $this->setupLimitControl();
$this->setupPaginationControl($this->view->notifications); $this->setupPaginationControl($this->view->notifications);
$this->view->title = $contact->contact_name;
} }
$this->view->contact = $contact; $this->view->contact = $contact;

View File

@ -15,6 +15,7 @@ class TacticalController extends Controller
{ {
$this->setAutorefreshInterval(15); $this->setAutorefreshInterval(15);
$this->view->title = $this->translate('Tactical Overview');
$this->getTabs()->add( $this->getTabs()->add(
'tactical_overview', 'tactical_overview',
array( array(

View File

@ -67,6 +67,7 @@ class IndexController extends Controller
} }
$this->view->wizard = $wizard; $this->view->wizard = $wizard;
$this->view->title = $this->translate('Setup') . ' :: ' . $this->view->defaultTitle;
} }
/** /**

View File

@ -543,7 +543,9 @@
} }
var title = req.getResponseHeader('X-Icinga-Title'); var title = req.getResponseHeader('X-Icinga-Title');
if (title && ! req.autorefresh && req.$target.closest('.dashboard').length === 0) { if (title && target === 'layout') {
this.icinga.ui.setTitle(decodeURIComponent(title));
} else if (title && ! req.autorefresh && req.$target.closest('.dashboard').length === 0) {
req.$target.data('icingaTitle', decodeURIComponent(title)); req.$target.data('icingaTitle', decodeURIComponent(title));
} }