/**
  * Display side bar information of a business activity
  *
  * @method get
  * @route /business-activity/snapshotslide/[i:id]
  */
 public function snapshotslideAction()
 {
     $params = $this->getParams();
     $data['configurationData'] = BusinessActivity::get($params['id'], array('ba_id', 'name', 'activate', 'icon_id', 'id_reporting_period'));
     $data['configurationData']['icon'] = BusinessActivityRepository::getIconImage($data['configurationData']['name']);
     $data['configurationData']['reporting_period'] = !empty($data['configurationData']['id_reporting_period']) ? Timeperiod::get($data['configurationData']['id_reporting_period'], 'tp_name') : "";
     $data['configurationData']['activate'] = YesNoDefault::toString($data['configurationData']['activate']);
     $data['realtimeData'] = BusinessActivityRealtime::get($params['id']);
     $informations = array_merge($data['configurationData'], $data['realtimeData']);
     $edit_url = $this->router->getPathFor("/centreon-bam/businessactivity/" . $params['id']);
     $this->router->response()->json(array('informations' => $informations, 'edit_url' => $edit_url, 'success' => true));
 }
Example #2
0
 /**
  * Format data so that it can be displayed in tooltip
  *
  * @param array $data
  * @return array $checkdata
  */
 public static function formatDataForTooltip($data)
 {
     /* Check data */
     $checkdata = array();
     $checkdata[] = array('label' => _('Name'), 'value' => $data['host_name']);
     $checkdata[] = array('label' => _('Command'), 'value' => static::getObjectName('\\CentreonConfiguration\\Models\\Command', $data['command_command_id']));
     $checkdata[] = array('label' => _('Time period'), 'value' => static::getObjectName('\\CentreonConfiguration\\Models\\Timeperiod', $data['timeperiod_tp_id']));
     $checkdata[] = array('label' => _('Max check attempts'), 'value' => $data['host_max_check_attempts']);
     $checkdata[] = array('label' => _('Check interval'), 'value' => $data['host_check_interval']);
     $checkdata[] = array('label' => _('Retry check interval'), 'value' => $data['host_retry_check_interval']);
     $checkdata[] = array('label' => _('Active checks enabled'), 'value' => YesNoDefault::toString($data['host_active_checks_enabled']));
     $checkdata[] = array('label' => _('Passive checks enabled'), 'value' => YesNoDefault::toString($data['host_passive_checks_enabled']));
     return $checkdata;
 }
 /**
  * Format data so that it can be displayed in slider
  *
  * @param array $data
  * @return array $checkdata
  */
 public static function formatDataForSlider($data)
 {
     /* Check data */
     $checkdata = array();
     $checkdata[_('id')] = $data['configurationData']['host_id'];
     $checkdata[_('name')] = $data['configurationData']['host_name'];
     $checkdata[_('command')] = "";
     if (isset($data['configurationData']['command_command_id']) && !is_null($data['configurationData']['command_command_id'])) {
         $command = Command::getParameters($data['configurationData']['command_command_id'], 'command_name');
         $checkdata[_('command')] = $command['command_name'];
     }
     $checkdata[_('time_period')] = "";
     if (isset($data['configurationData']['timeperiod_tp_id']) && !is_null($data['configurationData']['timeperiod_tp_id'])) {
         $timeperiod = Timeperiod::getParameters($data['configurationData']['timeperiod_tp_id'], 'tp_name');
         $checkdata[_('time_period')] = $timeperiod['tp_name'];
     }
     $checkdata[_('max_check attempts')] = "";
     if (isset($data['configurationData']['host_max_check_attempts'])) {
         $checkdata[_('max_check_attempts')] = $data['configurationData']['host_max_check_attempts'];
     }
     $checkdata[_('check_interval')] = "";
     if (isset($data['configurationData']['host_check_interval'])) {
         $checkdata[_('check_interval')] = $data['configurationData']['host_check_interval'];
     }
     $checkdata[_('retry_check_interval')] = "";
     if (isset($data['configurationData']['host_retry_check_interval'])) {
         $checkdata[_('retry_check_interval')] = $data['configurationData']['host_retry_check_interval'];
     }
     $checkdata[_('active_checks_enabled')] = "";
     if (isset($data['configurationData']['host_active_checks_enabled'])) {
         $checkdata[_('active_checks_enabled')] = YesNoDefault::toString($data['configurationData']['host_active_checks_enabled']);
     }
     $checkdata[_('passive_checks_enabled')] = "";
     if (isset($data['configurationData']['host_passive_checks_enabled'])) {
         $checkdata[_('passive_checks_enabled')] = YesNoDefault::toString($data['configurationData']['host_passive_checks_enabled']);
     }
     if (!empty($data['configurationData']['icon'])) {
         $checkdata[_('icon')] = $data['configurationData']['icon'];
     }
     $checkdata[_('status')] = "";
     if (!empty($data['realtimeData']['status'])) {
         $checkdata[_('status')] = $data['realtimeData']['status'];
     }
     $checkdata[_('state')] = "";
     if (!empty($data['realtimeData']['state_type'])) {
         $checkdata[_('state')] = $data['realtimeData']['state_type'];
     }
     $checkdata[_('last_check')] = "";
     if (!empty($data['realtimeData']['last_check'])) {
         $checkdata[_('last_check')] = Datetime::humanReadable(time() - $data['realtimeData']['last_check'], Datetime::PRECISION_FORMAT, 2);
     }
     $checkdata[_('next_check')] = "";
     if (!empty($data['realtimeData']['next_check'])) {
         $checkdata[_('next_check')] = Datetime::humanReadable(time() - $data['realtimeData']['next_check'], Datetime::PRECISION_FORMAT, 2);
     }
     $checkdata[_('acknowledged')] = "";
     if (!empty($data['realtimeData']['acknowledged'])) {
         $checkdata[_('acknowledged')] = $data['realtimeData']['acknowledged'];
     }
     $checkdata[_('downtime')] = "";
     if (!empty($data['realtimeData']['scheduled_downtime_depth'])) {
         $checkdata[_('downtime')] = $data['realtimeData']['scheduled_downtime_depth'];
     }
     return $checkdata;
 }
 public function testToString()
 {
     $this->assertEquals('No', YesNoDefault::toString(0));
     $this->assertEquals('Yes', YesNoDefault::toString(1));
     $this->assertEquals('', YesNoDefault::toString(42));
 }