/**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     global $page;
     // rewrite page file
     $page['file'] = $this->pageFile;
     $item = new CUiWidget('hat_syssum', make_system_status(array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => null, 'extAck' => 0, 'screenid' => $this->screenid)));
     $item->setHeader(_('Status of Zabbix'), SPACE);
     $item->setFooter(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)));
     return $this->getOutput($item);
 }
 /**
  * Sets the header and adds a default expand-collapse icon.
  *
  * @param string|array|CTag $caption
  * @param string|array|CTag $icons
  */
 public function setHeader($caption = null, $icons = SPACE)
 {
     zbx_value2array($icons);
     $icon = new CIcon(_('Show') . '/' . _('Hide'), $this->open ? 'arrowup' : 'arrowdown', 'changeWidgetState(this, "' . $this->id . '");');
     $icon->setAttribute('id', $this->id . '_icon');
     array_unshift($icons, $icon);
     parent::setHeader($caption, $icons);
 }
 /**
  * Sets the header and adds a default expand-collapse icon.
  *
  * @param string	$caption
  * @param array		$controls
  */
 public function setHeader($caption, array $controls = [], $cursor_move = false, $url = '')
 {
     $icon = (new CRedirectButton(null, null))->setId($this->id . '_icon')->onClick('changeWidgetState(this, "' . $this->id . '", "' . $url . '");');
     if ($this->expanded) {
         $icon->addClass(ZBX_STYLE_BTN_WIDGET_COLLAPSE)->setTitle(_('Collapse'));
     } else {
         $icon->addClass(ZBX_STYLE_BTN_WIDGET_EXPAND)->setTitle(_('Expand'));
     }
     $controls[] = $icon;
     parent::setHeader($caption, $controls, $cursor_move);
     return $this;
 }
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $params = array('groupids' => null, 'hostids' => null, 'screenid' => $this->screenid, 'maintenance' => null, 'severity' => null, 'limit' => $this->screenitem['elements'], 'backUrl' => $this->pageFile);
     // by default triggers are sorted by date desc, do we need to override this?
     switch ($this->screenitem['sort_triggers']) {
         case SCREEN_SORT_TRIGGERS_DATE_DESC:
             $params['sortfield'] = 'lastchange';
             $params['sortorder'] = ZBX_SORT_DOWN;
             break;
         case SCREEN_SORT_TRIGGERS_SEVERITY_DESC:
             $params['sortfield'] = 'priority';
             $params['sortorder'] = ZBX_SORT_DOWN;
             break;
         case SCREEN_SORT_TRIGGERS_HOST_NAME_ASC:
             // a little black magic here - there is no such field 'hostname' in 'triggers',
             // but API has a special case for sorting by hostname
             $params['sortfield'] = 'hostname';
             $params['sortorder'] = ZBX_SORT_UP;
             break;
     }
     if ($this->screenitem['resourceid'] > 0) {
         $hosts = API::Host()->get(array('hostids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND));
         $host = reset($hosts);
         $item = new CSpan(_('Host') . NAME_DELIMITER . $host['host'], 'white');
         $params['hostids'] = $host['hostid'];
     } else {
         $groupid = getRequest('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
         $hostid = getRequest('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
         CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
         CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
         // get groups
         $groups = API::HostGroup()->get(array('monitored_hosts' => true, 'output' => API_OUTPUT_EXTEND));
         order_result($groups, 'name');
         // get hsots
         $options = array('monitored_hosts' => true, 'output' => API_OUTPUT_EXTEND);
         if ($groupid > 0) {
             $options['groupids'] = $groupid;
         }
         $hosts = API::Host()->get($options);
         $hosts = zbx_toHash($hosts, 'hostid');
         order_result($hosts, 'host');
         if (!isset($hosts[$hostid])) {
             $hostid = 0;
         }
         if ($groupid > 0) {
             $params['groupids'] = $groupid;
         }
         if ($hostid > 0) {
             $params['hostids'] = $hostid;
         }
         $item = new CForm(null, $this->pageFile);
         $groupComboBox = new CComboBox('tr_groupid', $groupid, 'submit()');
         $groupComboBox->addItem(0, _('all'));
         foreach ($groups as $group) {
             $groupComboBox->addItem($group['groupid'], $group['name']);
         }
         $hostsComboBox = new CComboBox('tr_hostid', $hostid, 'submit()');
         $hostsComboBox->addItem(0, _('all'));
         foreach ($hosts as $host) {
             $hostsComboBox->addItem($host['hostid'], $host['host']);
         }
         if ($this->mode == SCREEN_MODE_EDIT) {
             $groupComboBox->attr('disabled', 'disabled');
             $hostsComboBox->attr('disabled', 'disabled');
         }
         $item->addItem(array(_('Group') . SPACE, $groupComboBox));
         $item->addItem(array(SPACE . _('Host') . SPACE, $hostsComboBox));
     }
     $output = new CUiWidget('hat_trstatus', make_latest_issues($params));
     $output->setDoubleHeader(array(_('HOST ISSUES'), SPACE, '[' . zbx_date2str(TIME_FORMAT_SECONDS) . ']', SPACE), $item);
     return $this->getOutput($output);
 }
示例#5
0
$trigger = reset($triggers);
// events
$events = API::Event()->get(array('output' => API_OUTPUT_EXTEND, 'select_alerts' => API_OUTPUT_EXTEND, 'select_acknowledges' => API_OUTPUT_EXTEND, 'selectHosts' => API_OUTPUT_EXTEND, 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'eventids' => getRequest('eventid'), 'objectids' => getRequest('triggerid')));
$event = reset($events);
/*
 * Display
 */
$config = select_config();
$eventWidget = new CWidget();
$eventWidget->setClass('header');
$eventWidget->addHeader(array(_('EVENTS') . ': "' . CMacrosResolverHelper::resolveTriggerName($trigger) . '"'), get_icon('fullscreen', array('fullscreen' => getRequest('fullscreen'))));
// trigger details
$triggerDetailsWidget = new CUiWidget('hat_triggerdetails', make_trigger_details($trigger));
$triggerDetailsWidget->setHeader(_('Event source details'));
// event details
$eventDetailsWidget = new CUiWidget('hat_eventdetails', make_event_details($event, $trigger));
$eventDetailsWidget->setHeader(_('Event details'));
// if acknowledges are not disabled in configuration, let's show them
if ($config['event_ack_enable']) {
    $eventAcknowledgesWidget = new CCollapsibleUiWidget('hat_eventack', makeAckTab($event));
    $eventAcknowledgesWidget->open = (bool) CProfile::get('web.tr_events.hats.hat_eventack.state', true);
    $eventAcknowledgesWidget->setHeader(_('Acknowledges'));
} else {
    $eventAcknowledgesWidget = null;
}
// actions messages
$actionMessagesWidget = new CCollapsibleUiWidget('hat_eventactionmsgs', getActionMessages($event['alerts']));
$actionMessagesWidget->open = (bool) CProfile::get('web.tr_events.hats.hat_eventactionmsgs.state', true);
$actionMessagesWidget->setHeader(_('Message actions'));
// actions commands
$actionCommandWidget = new CCollapsibleUiWidget('hat_eventactionmcmds', getActionCommands($event['alerts']));