|
@@ -0,0 +1,101 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace StatsBundle\Admin;
|
|
|
|
+
|
|
|
|
+use Base\AdminBundle\Admin\BaseAdmin;
|
|
|
|
+use Sonata\AdminBundle\Datagrid\DatagridMapper;
|
|
|
|
+use Sonata\AdminBundle\Datagrid\ListMapper;
|
|
|
|
+use Sonata\AdminBundle\Form\FormMapper;
|
|
|
|
+use Sonata\AdminBundle\Show\ShowMapper;
|
|
|
|
+use DeviceBundle\Utils\DeviceTypes;
|
|
|
|
+use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
|
|
+use Sonata\AdminBundle\Route\RouteCollection;
|
|
|
|
+
|
|
|
|
+class OltAdmin extends BaseAdmin
|
|
|
|
+{
|
|
|
|
+ protected $baseRouteName = 'admin_stats_olt';
|
|
|
|
+ protected $baseRoutePattern = 'stats/olt';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param DatagridMapper $datagridMapper
|
|
|
|
+ */
|
|
|
|
+ protected function configureDatagridFilters(DatagridMapper $datagridMapper)
|
|
|
|
+ {
|
|
|
|
+ $datagridMapper
|
|
|
|
+ ->add('deviceServer')
|
|
|
|
+ ->add('deviceId')
|
|
|
|
+ ->add('ip')
|
|
|
|
+ ->add('tenancyId')
|
|
|
|
+ ;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param ListMapper $listMapper
|
|
|
|
+ */
|
|
|
|
+ protected function configureListFields(ListMapper $listMapper)
|
|
|
|
+ {
|
|
|
|
+ $listMapper
|
|
|
|
+ ->add('deviceServer')
|
|
|
|
+ ->add('deviceId')
|
|
|
|
+ ->add('ip')
|
|
|
|
+ ->add('extraData.name', 'string', array('template' => 'StatsBundle:Device:extra_data_text_field.html.twig', 'column' => 'name', 'label' => 'list.label_olt_device_id'))
|
|
|
|
+ ->add('extraData.mark', 'string', array('template' => 'StatsBundle:Device:extra_data_text_field.html.twig', 'column' => 'mark', 'label' => 'list.label_olt_mark'))
|
|
|
|
+ ->add('extraData.library', 'string', array('template' => 'StatsBundle:Device:extra_data_text_field.html.twig', 'column' => 'library', 'label' => 'list.label_olt_library'))
|
|
|
|
+ ->add('extraData.executeSnmp', 'string', array('template' => 'StatsBundle:Device:extra_data_boolean_field.html.twig', 'column' => 'executeSnmp', 'label' => 'list.label_olt_executeSnmp'))
|
|
|
|
+ ->add('_action', null, array(
|
|
|
|
+ 'actions' => array(
|
|
|
|
+ 'onus' => array('template' => 'StatsBundle:Device:action_olt_show_onu.html.twig'),
|
|
|
|
+ 'ponports' => array('template' => 'StatsBundle:Device:action_olt_show_ponport.html.twig'),
|
|
|
|
+ 'report' => array('template' => 'StatsBundle:Device:action_olt_show_report.html.twig')
|
|
|
|
+ )))
|
|
|
|
+
|
|
|
|
+ ;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param FormMapper $formMapper
|
|
|
|
+ */
|
|
|
|
+ protected function configureFormFields(FormMapper $formMapper)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param ShowMapper $showMapper
|
|
|
|
+ */
|
|
|
|
+ protected function configureShowFields(ShowMapper $showMapper)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param string $action
|
|
|
|
+ * @param Object $object
|
|
|
|
+ *
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function configureActionButtons($action, $object = null)
|
|
|
|
+ {
|
|
|
|
+ $actions = parent::configureActionButtons($action, $object);
|
|
|
|
+
|
|
|
|
+ return $actions;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected function configureRoutes(RouteCollection $collection)
|
|
|
|
+ {
|
|
|
|
+ $collection->remove('delete');
|
|
|
|
+ $collection->remove('create');
|
|
|
|
+ $collection->remove('edit');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function createQuery($context = 'list')
|
|
|
|
+ {
|
|
|
|
+ $query = parent::createQuery($context);
|
|
|
|
+ $query->andWhere(
|
|
|
|
+ $query->expr()->eq($query->getRootAliases()[0] . '.deviceType', ':my_type')
|
|
|
|
+ );
|
|
|
|
+ $query->setParameter('my_type', 'FTTHBundle\Entity\OLT');
|
|
|
|
+ return $query;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|