Пример #1
0
 /**
  * Convert type
  *
  * @param array $data
  * @return array
  */
 protected function convertType($data)
 {
     $db = Di::getDefault()->get('db_centreon');
     $attr = array();
     switch ($data['type']) {
         case 'list':
             $type = 'select';
             $res = WidgetRepository::getParameterOptions($data['parameter_id']);
             $options = array();
             $i = 0;
             $preferences = array();
             foreach ($res as $id => $name) {
                 $options[$i]['id'] = $id;
                 $options[$i]['text'] = $name;
                 if ($data['preference_value'] == $id) {
                     $preferences = $options[$i];
                 }
                 $i++;
             }
             $attr = json_encode(array('selectData' => json_encode($options), 'selectDefault' => json_encode($preferences)));
             break;
         case 'boolean':
             $type = 'checkbox';
             $attr = json_encode(array('choices' => array(null => 1)));
             break;
         case 'hidden':
             $type = 'text';
             break;
         case 'range':
             $type = 'text';
             break;
         case 'compare':
             $type = 'text';
             break;
         case 'sort':
             $type = 'text';
             break;
         case 'date':
             $type = 'text';
             break;
         case 'host':
             $type = 'select';
             $attr = json_encode(array('object_type' => 'object', 'defaultValuesRoute' => '/centreon-configuration/host/formlist'));
             break;
         case 'hostTemplate':
             $type = 'select';
             $attr = json_encode(array('object_type' => 'object', 'defaultValuesRoute' => '/centreon-configuration/hosttemplate/formlist'));
             break;
         case 'serviceTemplate':
             $type = 'select';
             $attr = json_encode(array('object_type' => 'object', 'defaultValuesRoute' => '/centreon-configuration/servicetemplate/formlist'));
             break;
         case 'hostgroup':
             $type = 'select';
             $attr = json_encode(array('object_type' => 'object', 'defaultValuesRoute' => '/centreon-configuration/hostgroup/formlist'));
             break;
         case 'servicegroup':
             $type = 'select';
             $attr = json_encode(array('object_type' => 'object', 'defaultValuesRoute' => '/centreon-configuration/servicegroup/formlist'));
             break;
         case 'service':
             $type = 'select';
             $attr = json_encode(array('object_type' => 'object', 'defaultValuesRoute' => '/centreon-configuration/service/formlist'));
             break;
         default:
             $type = 'text';
             break;
     }
     return array($type, $attr);
 }
 /**
  * 
  * @method get
  * @route /extensions/widgets/[i:id]/uninstall
  */
 public function uninstallWidgetAction()
 {
     $router = $this->di->get('router');
     $params = $this->getParams();
     WidgetRepository::uninstall($params['id']);
     $backUrl = $router->getPathFor('/centreon-customview/extensions/widgets');
     $router->response()->redirect($backUrl, 200);
 }
Пример #3
0
 /**
  * Get widget params
  *
  * @return array
  */
 protected function getWidgetParams()
 {
     return WidgetRepository::getWidgetPreferences($this->widgetId);
 }
 /**
  * Remove widget from view
  *
  * @method post
  * @route /removewidget
  */
 public function removeWidgetAction()
 {
     $givenParameters = $this->getParams('post');
     WidgetRepository::deleteWidgetFromView($givenParameters, $this->user->getId());
 }