Exemplo n.º 1
0
 /**
  * Use a default redirection rule to welcome page
  */
 public function preDispatch()
 {
     if ($this->getRequest()->getActionName() !== 'welcome') {
         // @TODO(el): Avoid landing page redirects: https://dev.icinga.org/issues/9656
         $this->redirectNow(Url::fromRequest()->setPath('dashboard'));
     }
 }
Exemplo n.º 2
0
 /**
  * @deprecated
  */
 public function historyAction()
 {
     if ($this->params->has('service')) {
         $this->redirectNow(Url::fromRequest()->setPath('monitoring/service/history'));
     }
     $this->redirectNow(Url::fromRequest()->setPath('monitoring/host/history'));
 }
Exemplo n.º 3
0
 /**
  * Get the request URL
  *
  * @return Url
  */
 public function getUrl()
 {
     if ($this->url === null) {
         $this->url = Url::fromRequest($this);
     }
     return $this->url;
 }
Exemplo n.º 4
0
 public function indexAction()
 {
     $this->getTabs()->add('tactical_overview', array('title' => $this->translate('Show an overview of all hosts and services, their current' . ' states and monitoring feature utilisation'), 'label' => $this->translate('Tactical Overview'), 'url' => Url::fromRequest()))->extend(new DashboardAction())->activate('tactical_overview');
     $stats = $this->backend->select()->from('statussummary', array('hosts_up', 'hosts_pending', 'hosts_down', 'hosts_down_unhandled', 'hosts_unreachable', 'hosts_unreachable_unhandled', 'services_ok_on_ok_hosts', 'services_ok_not_checked_on_ok_hosts', 'services_pending_on_ok_hosts', 'services_pending_not_checked_on_ok_hosts', 'services_warning_handled_on_ok_hosts', 'services_warning_unhandled_on_ok_hosts', 'services_warning_passive_on_ok_hosts', 'services_warning_not_checked_on_ok_hosts', 'services_critical_handled_on_ok_hosts', 'services_critical_unhandled_on_ok_hosts', 'services_critical_passive_on_ok_hosts', 'services_critical_not_checked_on_ok_hosts', 'services_unknown_handled_on_ok_hosts', 'services_unknown_unhandled_on_ok_hosts', 'services_unknown_passive_on_ok_hosts', 'services_unknown_not_checked_on_ok_hosts', 'services_ok_on_problem_hosts', 'services_ok_not_checked_on_problem_hosts', 'services_pending_on_problem_hosts', 'services_pending_not_checked_on_problem_hosts', 'services_warning_handled_on_problem_hosts', 'services_warning_unhandled_on_problem_hosts', 'services_warning_passive_on_problem_hosts', 'services_warning_not_checked_on_problem_hosts', 'services_critical_handled_on_problem_hosts', 'services_critical_unhandled_on_problem_hosts', 'services_critical_passive_on_problem_hosts', 'services_critical_not_checked_on_problem_hosts', 'services_unknown_handled_on_problem_hosts', 'services_unknown_unhandled_on_problem_hosts', 'services_unknown_passive_on_problem_hosts', 'services_unknown_not_checked_on_problem_hosts', 'hosts_active', 'hosts_passive', 'hosts_not_checked', 'services_active', 'services_passive', 'services_not_checked', 'hosts_not_processing_event_handlers', 'services_not_processing_event_handlers', 'hosts_not_triggering_notifications', 'services_not_triggering_notifications', 'hosts_without_flap_detection', 'services_without_flap_detection', 'hosts_flapping', 'services_flapping'));
     $this->applyRestriction('monitoring/filter/objects', $stats);
     $this->view->statusSummary = $stats->fetchRow();
 }
 /**
  * Edit an user group backend
  */
 public function editAction()
 {
     $backendName = $this->params->getRequired('backend');
     $form = new UserGroupBackendForm();
     $form->setAction(Url::fromRequest());
     $form->setRedirectUrl('usergroupbackend/list');
     $form->setTitle(sprintf($this->translate('Edit User Group Backend %s'), $backendName));
     $form->setIniConfig(Config::app('groups'));
     $form->setOnSuccess(function (UserGroupBackendForm $form) use($backendName) {
         try {
             $form->edit($backendName, array_map(function ($v) {
                 return $v !== '' ? $v : null;
             }, $form->getValues()));
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($form->save()) {
             Notification::success(sprintf(t('User group backend "%s" successfully updated'), $backendName));
             return true;
         }
         return false;
     });
     try {
         $form->load($backendName);
         $form->handleRequest();
     } catch (NotFoundError $_) {
         $this->httpNotFound(sprintf($this->translate('User group backend "%s" not found'), $backendName));
     }
     $this->view->form = $form;
     $this->render('form');
 }
Exemplo n.º 6
0
 public function showAction()
 {
     $this->setAutorefreshInterval(15);
     $checkNowForm = new CheckNowCommandForm();
     $checkNowForm->setObjects($this->serviceList)->handleRequest();
     $this->view->checkNowForm = $checkNowForm;
     $this->serviceList->setColumns(array('host_icon_image', 'host_icon_image_alt', 'host_name', 'host_address', 'host_output', 'host_state', 'host_problem', 'host_handled', 'service_icon_image', 'service_icon_image_alt', 'service_output', 'service_description', 'service_state', 'service_problem', 'service_handled', 'service_acknowledged', 'service_in_downtime', 'service_is_flapping', 'service_notifications_enabled', 'service_active_checks_enabled', 'service_passive_checks_enabled'));
     $acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
     if (!empty($acknowledgedObjects)) {
         $removeAckForm = new RemoveAcknowledgementCommandForm();
         $removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
         $this->view->removeAckForm = $removeAckForm;
     }
     $this->setAutorefreshInterval(15);
     $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
     $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
     $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/services/process-check-result');
     $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment');
     $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment');
     $this->view->stats = $this->serviceList->getServiceStateSummary();
     $this->view->objects = $this->serviceList;
     $this->view->unhandledObjects = $this->serviceList->getUnhandledObjects();
     $this->view->problemObjects = $this->serviceList->getProblemObjects();
     $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString());
     $this->view->acknowledgedObjects = $acknowledgedObjects;
     $this->view->acknowledgeLink = Url::fromPath('monitoring/services/acknowledge-problem')->setQueryString($this->serviceList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
     $this->view->unacknowledgedObjects = $this->serviceList->getUnacknowledgedObjects();
     $this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime();
     $this->view->inDowntimeLink = Url::fromPath('monitoring/list/services')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString());
     $this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter()->toQueryString());
     $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
     $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/services/send-custom-notification');
 }
Exemplo n.º 7
0
 /**
  * The constructor starts benchmarking, loads the configuration and sets
  * other useful controller properties
  *
  * @param Request  $request
  * @param Response $response
  * @param array    $invokeArgs Any additional invocation arguments
  */
 public function __construct(Request $request, Response $response, array $invokeArgs = array())
 {
     $this->params = UrlParams::fromQueryString();
     $this->setRequest($request)->setResponse($response)->_setInvokeArgs($invokeArgs);
     $this->_helper = new ActionHelperBroker($this);
     $this->handlerBrowserWindows();
     $this->view->translationDomain = 'icinga';
     $this->_helper->layout()->isIframe = $request->getUrl()->shift('isIframe');
     $this->_helper->layout()->showFullscreen = $request->getUrl()->shift('showFullscreen');
     $this->_helper->layout()->moduleName = false;
     $this->view->compact = $request->getParam('view') === 'compact';
     if ($request->getUrl()->shift('showCompact')) {
         $this->view->compact = true;
     }
     if ($this->rerenderLayout = $request->getUrl()->shift('renderLayout')) {
         $this->xhrLayout = 'body';
     }
     if ($request->getUrl()->shift('_disableLayout')) {
         $this->_helper->layout()->disableLayout();
     }
     if ($this->requiresLogin()) {
         $this->redirectToLogin(Url::fromRequest());
     }
     $this->view->tabs = new Tabs();
     $this->prepareInit();
     $this->init();
 }
 /**
  * Create full report
  */
 public function indexAction()
 {
     $this->getTabs()->add('alertsummary', array('title' => $this->translate('Show recent alerts and visualize notifications and problems' . ' based on their amount and chronological distribution'), 'label' => $this->translate('Alert Summary'), 'url' => Url::fromRequest()))->extend(new DashboardAction())->extend(new MenuAction())->activate('alertsummary');
     $this->view->title = $this->translate('Alert Summary');
     $this->view->intervalBox = $this->createIntervalBox();
     list($recentAlerts, $recentAlertsUrl) = $this->createRecentAlerts();
     $this->view->recentAlerts = $recentAlerts;
     $this->view->recentAlertsUrl = $recentAlertsUrl;
     $this->view->interval = $this->getInterval();
     $this->view->defectChart = $this->createDefectImage();
     $this->view->healingChart = $this->createHealingChart();
     $this->view->perf = $this->createNotificationPerfdata();
     $this->view->trend = $this->createTrendInformation();
     $this->setAutorefreshInterval(15);
     $query = $this->backend->select()->from('notification', array('host_name', 'host_display_name', 'service_description', 'service_display_name', 'notification_output', 'notification_contact_name', 'notification_start_time', 'notification_state'));
     $this->applyRestriction('monitoring/filter/objects', $query);
     $this->view->notifications = $query;
     $this->view->notificationsUrl = 'monitoring/list/notifications';
     $this->setupLimitControl();
     if ($limit = $this->params->get('limit')) {
         $query->limit($limit);
     } else {
         $query->limit(25);
     }
 }
Exemplo n.º 9
0
 public function showAction()
 {
     $this->setAutorefreshInterval(15);
     $checkNowForm = new CheckNowCommandForm();
     $checkNowForm->setObjects($this->hostList)->handleRequest();
     $this->view->checkNowForm = $checkNowForm;
     $this->hostList->setColumns(array('host_acknowledged', 'host_active_checks_enabled', 'host_display_name', 'host_handled', 'host_in_downtime', 'host_is_flapping', 'host_last_state_change', 'host_name', 'host_notifications_enabled', 'host_passive_checks_enabled', 'host_problem', 'host_state'));
     $acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
     if (!empty($acknowledgedObjects)) {
         $removeAckForm = new RemoveAcknowledgementCommandForm();
         $removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
         $this->view->removeAckForm = $removeAckForm;
     }
     $hostStates = $this->hostList->getStateSummary();
     $this->setAutorefreshInterval(15);
     $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
     $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime');
     $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result');
     $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment');
     $this->view->stats = $hostStates;
     $this->view->objects = $this->hostList;
     $this->view->unhandledObjects = $this->hostList->getUnhandledObjects();
     $this->view->problemObjects = $this->hostList->getProblemObjects();
     $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getProblemObjects()->objectsFilter()->toQueryString());
     $this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
     $this->view->acknowledgeLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
     $this->view->unacknowledgedObjects = $this->hostList->getUnacknowledgedObjects();
     $this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime();
     $this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts')->setQueryString($this->hostList->getObjectsInDowntime()->objectsFilter()->toQueryString());
     $this->view->showDowntimesLink = Url::fromPath('monitoring/list/downtimes')->setQueryString($this->hostList->objectsFilter()->andFilter(FilterEqual::where('object_type', 'host'))->toQueryString());
     $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
     $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification');
 }
Exemplo n.º 10
0
 public function render()
 {
     if ($this->url === null) {
         $this->url = Url::fromRequest();
     }
     $currentLimit = (int) $this->url->getParam('limit', $this->default);
     $availableLimits = array(10 => '10', 25 => '25', 50 => '50', 100 => '100', 500 => '500');
     if ($currentLimit === 0) {
         $availableLimits[0] = t('all');
     }
     // if ($this->pages === 1 && $currentLimit === 10) return '';
     $limits = array();
     $view = $this->view();
     $gotCurrent = false;
     foreach ($availableLimits as $limit => $caption) {
         if ($gotCurrent) {
             if ($this->pages === 1) {
                 //    break;
             }
         }
         if ($this->max !== null && ($limit === 0 || $limit > $this->max)) {
             //echo "$limit > $this->max"; break;
         }
         if ($limit === $currentLimit) {
             $gotCurrent = true;
             $limits[] = $caption;
         } else {
             $limits[] = $view->qlink($caption, $this->url->setParam('limit', $limit), null, array('title' => sprintf($view->translate('Limit each page to a maximum of %u rows'), $caption)));
         }
     }
     if (empty($limits)) {
         return '';
     }
     return '<span class="widgetLimiter">' . implode(' ', $limits) . '</span>';
 }
Exemplo n.º 11
0
 /**
  * Initialize this form
  */
 public function init()
 {
     $this->setName('form_dashboard_addurl');
     if (!$this->getSubmitLabel()) {
         $this->setSubmitLabel($this->translate('Add To Dashboard'));
     }
     $this->setAction(Url::fromRequest());
 }
Exemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function getTabs()
 {
     if ($this->tabs === null) {
         $this->tabs = new Tabs();
         $this->tabs->add('search', array('title' => t('Show Search', 'dashboard.pane.tooltip'), 'label' => t('Search'), 'url' => Url::fromRequest()));
     }
     return $this->tabs;
 }
 public function __construct($options = null)
 {
     parent::__construct($this->handleOptions($options));
     $this->setMethod('post');
     $this->setAction(Url::fromRequest());
     $this->createIdElement();
     $this->regenerateCsrfToken();
 }
Exemplo n.º 14
0
 /**
  * Render the menu
  */
 public function menuAction()
 {
     $this->setAutorefreshInterval(15);
     $this->_helper->layout()->disableLayout();
     $url = Url::fromRequest();
     $menu = new MenuRenderer(Menu::load(), $url->getRelativeUrl());
     $this->view->menuRenderer = $menu->useCustomRenderer();
 }
Exemplo n.º 15
0
 public function testWhetherFromRequestAcceptsAdditionalParameters()
 {
     $request = Mockery::mock('Icinga\\Web\\Request');
     $request->shouldReceive('getPathInfo')->andReturn('')->shouldReceive('getBaseUrl')->andReturn('/')->shouldReceive('getQuery')->andReturn(array('key1' => 'val1'));
     $url = Url::fromRequest(array('key1' => 'newval1', 'key2' => 'val2'), $request);
     $this->assertEquals('val2', $url->getParam('key2', 'wrongval'), 'Url::fromRequest does not accept additional parameters');
     $this->assertEquals('newval1', $url->getParam('key1', 'wrongval1'), 'Url::fromRequest does not overwrite existing parameters with additional ones');
 }
Exemplo n.º 16
0
 public function __construct($options = null)
 {
     parent::__construct($this->handleOptions($options));
     $this->setMethod('post');
     $this->setAction(Url::fromRequest());
     $this->createIdElement();
     $this->regenerateCsrfToken();
     $this->setDecorators(array('Description', array('FormErrors', array('onlyCustomFormErrors' => true)), 'FormElements', 'Form'));
 }
Exemplo n.º 17
0
 /**
  * @see Form::createElements()
  */
 public function createElements(array $formData)
 {
     $decorators = array(array('Label', array('class' => 'optional')), 'ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'hbox-item optionbox')));
     $url = Url::fromRequest()->getAbsoluteUrl();
     $this->addElement('checkbox', 'statechange', array('label' => $this->translate('State Changes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->stateChangeFilter()->toQueryString()) === false ? 0 : 1));
     $this->addElement('checkbox', 'downtime', array('label' => $this->translate('Downtimes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->downtimeFilter()->toQueryString()) === false ? 0 : 1));
     $this->addElement('checkbox', 'comment', array('label' => $this->translate('Comments'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->commentFilter()->toQueryString()) === false ? 0 : 1));
     $this->addElement('checkbox', 'notification', array('label' => $this->translate('Notifications'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->notificationFilter()->toQueryString()) === false ? 0 : 1));
     $this->addElement('checkbox', 'flapping', array('label' => $this->translate('Flapping'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->flappingFilter()->toQueryString()) === false ? 0 : 1));
 }
Exemplo n.º 18
0
 /**
  * Render a toc
  *
  * @param string    $path       Path to the documentation
  * @param string    $name       Name of the documentation
  * @param string    $url        URL to replace links with
  * @param array     $urlParams  Additional URL parameters
  */
 protected function renderToc($path, $name, $url, array $urlParams = array())
 {
     $parser = new DocParser($path);
     $toc = new DocTocRenderer($parser->getDocTree()->getIterator());
     $this->view->toc = $toc->setUrl($url)->setUrlParams($urlParams);
     $name = ucfirst($name);
     $this->view->title = sprintf($this->translate('%s Documentation'), $name);
     $this->getTabs()->add('toc', array('active' => true, 'title' => $name, 'url' => Url::fromRequest()));
     $this->render('toc', null, true);
 }
Exemplo n.º 19
0
 /**
  * Create a new OutputFormat extender
  *
  * In general, it's assumed that all types are supported when an outputFormat extension
  * is added, so this class offers to remove specific types instead of adding ones
  *
  * @param array $disabled An array of output types to <b>not</b> show.
  */
 public function __construct(array $disabled = array())
 {
     foreach ($this->supportedTypes as $type => $tabConfig) {
         if (!in_array($type, $disabled)) {
             $tabConfig['url'] = Url::fromRequest();
             $tabConfig['tagParams'] = array('target' => '_blank');
             $this->tabs[] = new Tab($tabConfig);
         }
     }
 }
Exemplo n.º 20
0
 /**
  * Create a new OutputFormat extender
  *
  * In general, it's assumed that all types are supported when an outputFormat extension
  * is added, so this class offers to remove specific types instead of adding ones
  *
  * @param array $disabled An array of output types to <b>not</b> show.
  */
 public function __construct(array $disabled = array())
 {
     foreach ($this->getSupportedTypes() as $type => $tabConfig) {
         if (!in_array($type, $disabled)) {
             $tabConfig['url'] = Url::fromRequest();
             $tab = new Tab($tabConfig);
             $tab->setTargetBlank();
             $this->tabs[] = $tab;
         }
     }
 }
Exemplo n.º 21
0
 /**
  * List modules which are enabled and having the 'doc' directory
  */
 public function indexAction()
 {
     $moduleManager = Icinga::app()->getModuleManager();
     $modules = array();
     foreach ($moduleManager->listInstalledModules() as $module) {
         $path = $this->getPath($module, $moduleManager->getModuleDir($module, '/doc'), true);
         if ($path !== null) {
             $modules[] = $moduleManager->getModule($module, false);
         }
     }
     $this->view->modules = $modules;
     $this->getTabs()->add('module-documentation', array('active' => true, 'title' => $this->translate('Module Documentation', 'Tab title'), 'url' => Url::fromRequest()));
 }
Exemplo n.º 22
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $url = Url::fromRequest();
     $activeLimit = (int) $url->getParam('limit', $this->getDefaultLimit());
     $navigation = new Navigation();
     $navigation->setLayout(Navigation::LAYOUT_TABS);
     foreach (static::$limits as $limit => $label) {
         $navigation->addItem('limit_' . $limit, array('priority' => $limit, 'label' => $label, 'active' => $activeLimit === $limit, 'url' => $url->with(array('limit' => $limit)), 'title' => sprintf(t('Show %u rows on this page'), $limit)));
     }
     if ($activeLimit === 0) {
         $navigation->addItem('limit_0', array('active' => true, 'label' => t('all'), 'title' => t('Show all items on this page'), 'priority' => max(array_keys(static::$limits)) + 1));
     }
     return $navigation->getRenderer()->setCssClass(static::CSS_CLASS_LIMITER)->setHeading(t('Limiter'))->render();
 }
Exemplo n.º 23
0
 /**
  * Check whether the sort control has been submitted and redirect using GET parameters
  */
 protected function handleSortControlSubmit()
 {
     $request = $this->getRequest();
     if (!$request->isPost()) {
         return;
     }
     if (($sort = $request->getPost('sort')) || ($direction = $request->getPost('dir'))) {
         $url = Url::fromRequest();
         if ($sort) {
             $url->setParam('sort', $sort);
             $url->remove('dir');
         } else {
             $url->setParam('dir', $direction);
         }
         $this->redirectNow($url);
     }
 }
Exemplo n.º 24
0
 /**
  * Adjust preferences and persist them
  *
  * @see Form::onSuccess()
  */
 public function onSuccess()
 {
     /** @var Preferences $preferences */
     $preferences = $this->getRequest()->getUser()->getPreferences();
     $icingaweb = $preferences->get('icingaweb');
     if ((bool) $preferences->getValue('icingaweb', 'auto_refresh', true) === false) {
         $icingaweb['auto_refresh'] = '1';
         $notification = $this->translate('Auto refresh successfully enabled');
     } else {
         $icingaweb['auto_refresh'] = '0';
         $notification = $this->translate('Auto refresh successfully disabled');
     }
     $preferences->icingaweb = $icingaweb;
     Session::getSession()->user->setPreferences($preferences);
     Notification::success($notification);
     $this->getResponse()->setHeader('X-Icinga-Rerender-Layout', 'yes');
     $this->setRedirectUrl(Url::fromRequest()->without('renderLayout'));
 }
Exemplo n.º 25
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $url = Url::fromRequest();
     $activeLimit = (int) $url->getParam('limit', $this->getDefaultLimit());
     $navigation = new Navigation();
     $navigation->setLayout(Navigation::LAYOUT_TABS);
     foreach (static::$limits as $limit => $label) {
         $navigationItem = new NavigationItem($limit);
         $navigationItem->setActive($activeLimit === $limit)->setAttribute('title', sprintf(t('Show %u rows on this page'), $limit))->setLabel($label)->setUrl($url->with(array('limit' => $limit)));
         $navigation->addItem($navigationItem);
     }
     if ($activeLimit === 0) {
         $navigationItem = new NavigationItem(0);
         $navigationItem->setActive(true)->setAttribute('title', t('Show all items on this page'))->setLabel(t('all'));
         $navigation->addItem($navigationItem);
     }
     return $navigation->getRenderer()->setCssClass(static::CSS_CLASS_LIMITER)->setHeading(t('Limiter'))->render();
 }
Exemplo n.º 26
0
 public function render()
 {
     $url = Url::fromRequest();
     $view = $this->view();
     $html = ' <form method="post" class="inline" action="' . $url . '"><input type="text" name="q" style="width: 8em" class="search" value="" placeholder="' . t('Add filter...') . '" /></form>';
     // $html .= $this->renderFilter($this->filter);
     $editorUrl = clone $url;
     $editorUrl->setParam('modifyFilter', true);
     if ($this->filter->isEmpty()) {
         $title = t('Filter this list');
         $txt = $view->icon('plus');
         $remove = '';
     } else {
         $txt = t('Filtered');
         $title = t('Modify this filter');
         $remove = ' <a href="' . Url::fromRequest()->setParams(array()) . '" title="' . t('Remove this filter') . '">' . $view->icon('cancel') . '</a>';
     }
     $filter = $this->filter->isEmpty() ? '' : ': ' . $this->filter;
     $html .= ($filter ? '<p>' : ' ') . '<a href="' . $editorUrl . '" title="' . $title . '">' . $txt . '</a>' . $this->shorten($filter, 72) . $remove . ($filter ? '</p>' : '');
     return $html;
 }
Exemplo n.º 27
0
 public function indexAction()
 {
     $this->getTabs()->add('timeline', array('title' => $this->translate('Show the number of historical event records grouped by time and type'), 'label' => $this->translate('Timeline'), 'url' => Url::fromRequest()))->extend(new DashboardAction())->extend(new MenuAction())->activate('timeline');
     $this->view->title = $this->translate('Timeline');
     // TODO: filter for hard_states (precedence adjustments necessary!)
     $this->setupIntervalBox();
     list($displayRange, $forecastRange) = $this->buildTimeRanges();
     $detailUrl = Url::fromPath('monitoring/list/eventhistory');
     $timeline = new TimeLine($this->applyRestriction('monitoring/filter/objects', $this->backend->select()->from('eventhistory', array('name' => 'type', 'time' => 'timestamp'))), array('notify' => array('class' => 'timeline-notification', 'detailUrl' => $detailUrl, 'label' => mt('monitoring', 'Notifications')), 'hard_state' => array('class' => 'timeline-hard-state', 'detailUrl' => $detailUrl, 'label' => mt('monitoring', 'Hard state changes')), 'comment' => array('class' => 'timeline-comment', 'detailUrl' => $detailUrl, 'label' => mt('monitoring', 'Comments')), 'ack' => array('class' => 'timeline-ack', 'label' => mt('monitoring', 'Acknowledgements')), 'dt_start' => array('class' => 'timeline-downtime-start', 'detailUrl' => $detailUrl, 'label' => mt('monitoring', 'Started downtimes')), 'dt_end' => array('class' => 'timeline-downtime-end', 'detailUrl' => $detailUrl, 'label' => mt('monitoring', 'Ended downtimes'))));
     $timeline->setMaximumCircleWidth('6em');
     $timeline->setMinimumCircleWidth('0.3em');
     $timeline->setDisplayRange($displayRange);
     $timeline->setForecastRange($forecastRange);
     $beingExtended = $this->getRequest()->getParam('extend') == 1;
     $timeline->setSession($this->Window()->getSessionNamespace('timeline', !$beingExtended));
     $this->view->timeline = $timeline;
     $this->view->nextRange = $forecastRange;
     $this->view->beingExtended = $beingExtended;
     $this->view->intervalFormat = $this->getIntervalFormat();
     $oldBase = $timeline->getCalculationBase(false);
     $this->view->switchedContext = $oldBase !== null && $oldBase !== $timeline->getCalculationBase(true);
 }
Exemplo n.º 28
0
 public function showAction()
 {
     $this->setAutorefreshInterval(15);
     if ($this->Auth()->hasPermission('monitoring/command/schedule-check')) {
         $checkNowForm = new CheckNowCommandForm();
         $checkNowForm->setObjects($this->serviceList)->handleRequest();
         $this->view->checkNowForm = $checkNowForm;
     }
     $acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
     if (!empty($acknowledgedObjects)) {
         $removeAckForm = new RemoveAcknowledgementCommandForm();
         $removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
         $this->view->removeAckForm = $removeAckForm;
     }
     $featureStatus = $this->serviceList->getFeatureStatus();
     $toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array('backend' => $this->backend, 'objects' => $this->serviceList));
     $toggleFeaturesForm->load((object) $featureStatus)->handleRequest();
     $this->view->toggleFeaturesForm = $toggleFeaturesForm;
     $this->setAutorefreshInterval(15);
     $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
     $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
     $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/services/process-check-result');
     $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment');
     $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment');
     $this->view->stats = $this->serviceList->getServiceStateSummary();
     $this->view->objects = $this->serviceList;
     $this->view->unhandledObjects = $this->serviceList->getUnhandledObjects();
     $this->view->problemObjects = $this->serviceList->getProblemObjects();
     $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString());
     $this->view->acknowledgedObjects = $acknowledgedObjects;
     $this->view->acknowledgeLink = Url::fromPath('monitoring/services/acknowledge-problem')->setQueryString($this->serviceList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
     $this->view->unacknowledgedObjects = $this->serviceList->getUnacknowledgedObjects();
     $this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime();
     $this->view->inDowntimeLink = Url::fromPath('monitoring/list/services')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString());
     $this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter()->andFilter(Filter::where('object_type', 'service'))->toQueryString());
     $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
     $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/services/send-custom-notification');
 }
Exemplo n.º 29
0
 /**
  * Display a confirmation form to remove a resource
  */
 public function removeresourceAction()
 {
     $this->assertPermission('config/application/resources');
     $this->getTabs()->add('resources/remove', array('label' => $this->translate('Remove Resource'), 'url' => Url::fromRequest()))->activate('resources/remove');
     $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) {
         $configForm = new ResourceConfigForm();
         $configForm->setIniConfig(Config::app('resources'));
         $resource = $form->getRequest()->getQuery('resource');
         try {
             $configForm->remove($resource);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($configForm->save()) {
             Notification::success(sprintf(t('Resource "%s" has been successfully removed'), $resource));
         } else {
             return false;
         }
     }));
     $form->setRedirectUrl('config/resource');
     $form->handleRequest();
     // Check if selected resource is currently used for authentication
     $resource = $this->getRequest()->getQuery('resource');
     $authConfig = Config::app('authentication');
     foreach ($authConfig as $backendName => $config) {
         if ($config->get('resource') === $resource) {
             $form->addDescription(sprintf($this->translate('The resource "%s" is currently utilized for authentication by user backend "%s". ' . 'Removing the resource can result in noone being able to log in any longer.'), $resource, $backendName));
         }
     }
     $this->view->form = $form;
     $this->render('resource/remove');
 }
Exemplo n.º 30
0
 public function render()
 {
     if (!$this->preservedUrl()->getParam('modifyFilter')) {
         return '<div class="filter">' . $this->renderSearch() . $this->shorten($this->filter, 50) . '</div>';
     }
     return '<div class="filter">' . $this->renderSearch() . '<form action="' . Url::fromRequest() . '" class="editor" method="POST">' . '<ul class="tree"><li>' . $this->renderFilter($this->filter) . '</li></ul>' . '<div class="buttons">' . '<input type="submit" name="submit" value="Apply" />' . '<input type="submit" name="cancel" value="Cancel" />' . '</div>' . '</form>' . '</div>';
 }