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>'; }
/** * Get the request URL * * @return Url */ public function getUrl() { if ($this->url === null) { $this->url = Url::fromRequest($this); } return $this->url; }
/** * 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); } }
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'); }
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'); }
/** * 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')); } }
/** * Creates a menu item link element * * @param Menu $menu * * @return string */ public function createLink(Menu $menu) { if ($menu->getIcon() && strpos($menu->getIcon(), '.') === false) { return sprintf('<a href="%s"%s><i aria-hidden="true" class="icon-%s"></i>%s</a>', $menu->getUrl() ?: '#', $this->getAttributes(), $menu->getIcon(), $this->getView()->escape($menu->getTitle())); } return sprintf('<a href="%s"%s>%s%s<span></span></a>', $menu->getUrl() ?: '#', $this->getAttributes(), $menu->getIcon() ? '<img aria-hidden="true" src="' . Url::fromPath($menu->getIcon()) . '" class="icon" /> ' : '', $this->getView()->escape($menu->getTitle())); }
/** * @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')); }
/** * 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'); }
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(); }
/** * Create a command form to delete a single comment * * @return DeleteCommentsCommandForm */ private function createDelCommentForm() { $this->assertPermission('monitoring/command/comment/delete'); $delCommentForm = new DeleteCommentCommandForm(); $delCommentForm->setAction(Url::fromPath('monitoring/comment/show')->setParam('comment_id', $this->comment->id)); $delCommentForm->handleRequest(); return $delCommentForm; }
public function __construct($options = null) { parent::__construct($this->handleOptions($options)); $this->setMethod('post'); $this->setAction(Url::fromRequest()); $this->createIdElement(); $this->regenerateCsrfToken(); }
/** * 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()); }
/** * Create a command form to delete a single comment * * @return DeleteDowntimeCommandForm */ private function createDelDowntimeForm() { $this->assertPermission('monitoring/command/downtime/delete'); $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm->setAction(Url::fromPath('monitoring/downtime/show')->setParam('downtime_id', $this->downtime->id)); $delDowntimeForm->handleRequest(); return $delDowntimeForm; }
/** * 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(); }
/** * {@inheritdoc} */ public function isValid($value) { if (Url::fromPath($value)->isExternal()) { $this->_error('IS_EXTERNAL'); return false; } return true; }
protected function getActionIcons($view) { $icons = array(); if (!$this->bp->isLocked()) { $url = Url::fromPath('businessprocess/node/simulate', array('config' => $this->bp->getName(), 'node' => $this->name)); $icons[] = $this->actionIcon($view, 'magic', $url, 'Simulation'); } return $icons; }
/** * Set the redirect URL * * Unlike {@link setRedirect()} this method only sets a redirect URL on the response for later usage. * {@link prepare()} will take care of the correct redirect handling and HTTP headers on XHR and "normal" browser * requests. * * @param string|Url $redirectUrl * * @return $this */ protected function setRedirectUrl($redirectUrl) { if (!$redirectUrl instanceof Url) { $redirectUrl = Url::fromPath((string) $redirectUrl); } $redirectUrl->getParams()->setSeparator('&'); $this->redirectUrl = $redirectUrl; return $this; }
/** * 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); } } }
/** * Create a new MenuRenderer * * @param Menu $menu The menu to render * @param string $url A relative url to identify "active" children with */ public function __construct(Menu $menu, $url = null) { if ($url instanceof Url) { $this->url = $url; } else { $this->url = Url::fromPath($url); } $this->defaultRenderer = new MenuItemRenderer(); parent::__construct(new PermittedMenuItemFilter($menu), RecursiveIteratorIterator::CHILD_FIRST); }
public function getActionsForService(Service $service) { if ($service->check_command == "logstash_events") { // TODO: add icon when Icingaweb2 supports it // <i class="icon-doc-text"></i> return array(mt('logstash', 'Logstash events') => Url::fromPath('elasticsearch/event/list', array('host' => $service->getHost()->getName(), 'service' => $service->getName()))); } else { return array(); } }
/** * Display comment detail view */ public function showAction() { $this->view->comment = $this->comment; if ($this->hasPermission('monitoring/command/comment/delete')) { $listUrl = Url::fromPath('monitoring/list/comments')->setQueryString('comment_type=(comment|ack)'); $form = new DeleteCommentCommandForm(); $form->populate(array('comment_id' => $this->comment->id, 'comment_is_service' => isset($this->comment->service_description), 'redirect' => $listUrl))->handleRequest(); $this->view->delCommentForm = $form; } }
/** * @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)); }
/** * 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); }
/** * 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; } } }
/** * {@inheritdoc} */ public function getRedirectUrl() { $redirect = null; if ($this->created) { $redirect = $this->getElement('redirect')->getValue(); } if (empty($redirect) || strpos($redirect, 'authentication/logout') !== 0) { $redirect = static::REDIRECT_URL; } return Url::fromPath($redirect); }
/** * {@inheritdoc} */ public function getValues($suppressArrayNotation = false) { $values = parent::getValues($suppressArrayNotation); if (isset($values['url']) && $values['url']) { $url = Url::fromPath($values['url']); if (!$url->isExternal() && ($relativePath = $url->getRelativeUrl())) { $values['url'] = $relativePath; } } return $values; }
/** * {@inheritdoc} */ public function getRedirectUrl() { $redirect = null; if ($this->created) { $redirect = $this->getElement('redirect')->getValue(); } if (empty($redirect)) { $redirect = static::REDIRECT_URL; } return Url::fromPath($redirect); }
/** * Return the url to redirect to upon success * * @return Url */ public function getRedirectUrl() { if ($this->redirectUrl === null) { $this->redirectUrl = $this->getRequest()->getUrl(); if ($this->getMethod() === 'get') { // Be sure to remove all form dependent params because we do not want to submit it again $this->redirectUrl = $this->redirectUrl->without(array_keys($this->getElements())); } } return $this->redirectUrl; }
/** * Display the form for removing a downtime list */ public function deleteAllAction() { $this->assertPermission('monitoring/command/downtime/delete'); $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')->setQueryString($this->filter->toQueryString()); $delDowntimeForm = new DeleteDowntimesCommandForm(); $delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes')); $delDowntimeForm->addDescription(sprintf($this->translate('Confirm removal of %d downtimes.'), $this->downtimes->count())); $delDowntimeForm->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')); $delDowntimeForm->setDowntimes($this->downtimes->fetchAll())->handleRequest(); $this->view->delAllDowntimeForm = $delDowntimeForm; }