Переглянути джерело

FD3-407 RadiusBundle. Entidades y Admins NAS y NASModel

Guillermo Espinoza 7 роки тому
батько
коміт
c68d81fd9b

+ 2 - 1
app/AppKernel.php

@@ -44,7 +44,8 @@ class AppKernel extends Kernel
             new LeafletBundle\LeafletBundle(),
             new AuthBundle\AuthBundle(),
             new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
-            new AuditBundle\AuditBundle()
+            new AuditBundle\AuditBundle(),
+            new RadiusBundle\RadiusBundle(),
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {

+ 1 - 0
app/config/config.yml

@@ -24,6 +24,7 @@ imports:
     - { resource: "@AuthBundle/Resources/config/services.yml" }
     - { resource: "@AuditBundle/Resources/config/services.yml" }
     - { resource: '@BaseAdminBundle/Resources/config/sonata-config.yml' }
+    - { resource: "@RadiusBundle/Resources/config/services.yml" }
 
 
 parameters:

+ 5 - 0
app/config/routing.yml

@@ -1,3 +1,8 @@
+radius:
+    resource: "@RadiusBundle/Controller/"
+    type:     annotation
+    prefix:   /
+
 login:
     path: /admin/login
     defaults:

+ 83 - 0
src/RadiusBundle/Admin/NASAdmin.php

@@ -0,0 +1,83 @@
+<?php
+
+namespace RadiusBundle\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;
+
+class NASAdmin extends BaseAdmin
+{
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('description')
+            ->add('host')
+            ->add('snmp_comunity')
+            ->add('snmp_version')
+            ->add('radius_password')
+            ->add('model')
+            ->add('acct_enabled');
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('description')
+            ->add('host')
+            ->add('snmp_comunity')
+            ->add('snmp_version')
+            ->add('radius_password')
+            ->add('model')
+            ->add('acct_enabled')
+            ->add('extraData')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                )
+            ));
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+        $formMapper
+            ->add('description')
+            ->add('host')
+            ->add('snmp_comunity')
+            ->add('snmp_version')
+            ->add('radius_password')
+            ->add('model')
+            ->add('acct_enabled')
+            ->add('extraData');
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+        $showMapper
+            ->add('description')
+            ->add('host')
+            ->add('snmp_comunity')
+            ->add('snmp_version')
+            ->add('radius_password')
+            ->add('model')
+            ->add('acct_enabled')
+            ->add('extraData');
+    }
+
+}

+ 59 - 0
src/RadiusBundle/Admin/NASModelAdmin.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace RadiusBundle\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;
+
+class NASModelAdmin extends BaseAdmin
+{
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('name');
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('name')
+            ->add('extraData')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                )
+            ));
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+        $formMapper
+            ->add('name')
+            ->add('extraData');
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+        $showMapper
+            ->add('name')
+            ->add('extraData');
+    }
+
+}

+ 220 - 0
src/RadiusBundle/Entity/NAS.php

@@ -0,0 +1,220 @@
+<?php
+
+namespace RadiusBundle\Entity;
+
+use Base\AdminBundle\Traits\TenancyIdTrait;
+use Base\AdminBundle\Traits\TenancyIdTraitInterface;
+use Doctrine\ORM\Mapping as ORM;
+use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+use Symfony\Component\Validator\Constraints as Assert;
+
+/**
+ * @ORM\Table
+ * @ORM\Entity
+ */
+class NAS implements TenancyIdTraitInterface
+{
+
+    use ExtraDataTrait;
+    use TenancyIdTrait;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @ORM\Column(type="string", length=50, nullable=true)
+     */
+    private $description;
+
+    /**
+     * @ORM\Column(type="string", length=50, nullable=false, unique=TRUE)
+     */
+    private $host;
+
+    /**
+     * @ORM\Column(type="string", length=50, nullable=false)
+     */
+    private $snmp_comunity;
+
+    /**
+     * @ORM\Column(type="integer", nullable=false)
+     */
+    private $snmp_version;
+
+    /**
+     * @ORM\Column(type="string", length=50, nullable=false)
+     */
+    private $radius_password;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="NASModel", inversedBy="nass", fetch="EXTRA_LAZY")
+     * @ORM\JoinColumn(name="model_id", referencedColumnName="id", onDelete="SET NULL")
+     */
+    private $model;
+
+    /**
+     * @var boolean $acct_enabled
+     *
+     * @ORM\Column(type="boolean", nullable=true)
+     */
+    private $acct_enabled;
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return (string)$this->description;
+    }
+
+    /**
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @param int $id
+     * @return mixed Retorna el objeto.
+     */
+    public function setId($id)
+    {
+        $this->id = $id;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getDescription()
+    {
+        return $this->description;
+    }
+
+    /**
+     * @param mixed $description
+     * @return mixed Retorna el objeto.
+     */
+    public function setDescription($description)
+    {
+        $this->description = $description;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getHost()
+    {
+        return $this->host;
+    }
+
+    /**
+     * @param mixed $host
+     * @return mixed Retorna el objeto.
+     */
+    public function setHost($host)
+    {
+        $this->host = $host;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getSnmpComunity()
+    {
+        return $this->snmp_comunity;
+    }
+
+    /**
+     * @param mixed $snmp_comunity
+     * @return mixed Retorna el objeto.
+     */
+    public function setSnmpComunity($snmp_comunity)
+    {
+        $this->snmp_comunity = $snmp_comunity;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getSnmpVersion()
+    {
+        return $this->snmp_version;
+    }
+
+    /**
+     * @param mixed $snmp_version
+     * @return mixed Retorna el objeto.
+     */
+    public function setSnmpVersion($snmp_version)
+    {
+        $this->snmp_version = $snmp_version;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getRadiusPassword()
+    {
+        return $this->radius_password;
+    }
+
+    /**
+     * @param mixed $radius_password
+     * @return mixed Retorna el objeto.
+     */
+    public function setRadiusPassword($radius_password)
+    {
+        $this->radius_password = $radius_password;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getModel()
+    {
+        return $this->model;
+    }
+
+    /**
+     * @param mixed $model
+     * @return mixed Retorna el objeto.
+     */
+    public function setModel($model)
+    {
+        $this->model = $model;
+        return $this;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isAcctEnabled()
+    {
+        return $this->acct_enabled;
+    }
+
+    /**
+     * @param bool $acct_enabled
+     * @return mixed Retorna el objeto.
+     */
+    public function setAcctEnabled($acct_enabled)
+    {
+        $this->acct_enabled = $acct_enabled;
+        return $this;
+    }
+
+}

+ 104 - 0
src/RadiusBundle/Entity/NASModel.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace RadiusBundle\Entity;
+
+use Base\AdminBundle\Traits\TenancyIdTrait;
+use Base\AdminBundle\Traits\TenancyIdTraitInterface;
+use Doctrine\ORM\Mapping as ORM;
+use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+use Symfony\Component\Validator\Constraints as Assert;
+
+/**
+ * @ORM\Table
+ * @ORM\Entity
+ */
+class NASModel implements TenancyIdTraitInterface
+{
+
+    use ExtraDataTrait;
+    use TenancyIdTrait;
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255)
+     * @Assert\NotNull
+     */
+    private $name;
+
+    /**
+     * @ORM\OneToMany(targetEntity="NAS", mappedBy="model", fetch="EXTRA_LAZY")
+     */
+    protected $nass;
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return (string)$this->name;
+    }
+
+    /**
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @param int $id
+     * @return mixed Retorna el objeto.
+     */
+    public function setId($id)
+    {
+        $this->id = $id;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * @param string $name
+     * @return mixed Retorna el objeto.
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+        return $this;
+    }
+
+//    /**
+//     * @return mixed
+//     */
+//    public function getNass()
+//    {
+//        return $this->nass;
+//    }
+//
+//    /**
+//     * @param mixed $nass
+//     * @return mixed Retorna el objeto.
+//     */
+//    public function setNass($nass)
+//    {
+//        $this->nass = $nass;
+//        return $this;
+//    }
+
+}

+ 9 - 0
src/RadiusBundle/RadiusBundle.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace RadiusBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class RadiusBundle extends Bundle
+{
+}

+ 16 - 0
src/RadiusBundle/Resources/config/services.yml

@@ -0,0 +1,16 @@
+services:
+    radius.admin.nas.model:
+        class: RadiusBundle\Admin\NASModelAdmin
+        arguments: [~, RadiusBundle\Entity\NASModel, BaseAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: Radius, label: NAS Model, label_catalogue: RadiusBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
+        calls:
+            - [setTranslationDomain, [RadiusBundle]]
+
+    radius.admin.nas:
+        class: RadiusBundle\Admin\NASAdmin
+        arguments: [~, RadiusBundle\Entity\NAS, BaseAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: Radius, label: NAS, label_catalogue: RadiusBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
+        calls:
+            - [setTranslationDomain, [RadiusBundle]]

+ 101 - 0
src/RadiusBundle/Resources/translations/RadiusBundle.es.yml

@@ -0,0 +1,101 @@
+default: General
+configuration: Configuración
+stats: Estadísticas
+FTTH: FTTH
+Radius: Radius
+Profile: Perfil
+
+filter:
+    label__action: Acciones
+    label_id: Id
+    label_name: Nombre
+    label_download: Download
+    label_upload: Upload
+    label_profile: Perfil
+    label_client_id: Cliente
+    label_password: Contraseña
+    label_static_ip: Ip Estática
+    label_comments: Comentarios
+    label_description: Descripción
+    label_host: Host
+    label_snmp_comunity: SNMP Comunity
+    label_snmp_version: SNMP Versión
+    label_radius_password: Contraseña
+    label_model: modelo
+    label_acct_enabled: Cuenta Habilitada
+
+breadcrumb:
+    link_profile_list: Listado Perfiles
+    link_profile_create: Crear Perfil
+    link_profile_delete: Eliminar Perfil
+    link_access_list: Listado Acciones
+    link_access_create: Crear Acción
+    link_access_delete: Eliminar Acción
+    link_n_a_s_model_list: Listado Modelo de NAS
+    link_n_a_s_model_create: Crear Modelo de NAS
+    link_n_a_s_model_delete: Eliminar Modelo de NAS
+    link_n_a_s_list: Listado NAS
+    link_n_a_s_create: Crear NAS
+    link_n_a_s_delete: Eliminar NAS
+
+form:
+    label__action: Acciones
+    label_id: Id
+    label_name: Nombre
+    label_download: Download
+    label_upload: Upload
+    label_profile: Perfil
+    label_client_id: Cliente
+    label_password: Contraseña
+    label_static_ip: Ip Estática
+    label_comments: Comentarios
+    label_description: Descripción
+    label_host: Host
+    label_snmp_comunity: SNMP Comunity
+    label_snmp_version: SNMP Versión
+    label_radius_password: Contraseña
+    label_model: modelo
+    label_acct_enabled: Cuenta Habilitada
+
+list:
+    label__action: Acciones
+    label_id: Id
+    label_name: Nombre
+    label_download: Download
+    label_upload: Upload
+    label_profile: Perfil
+    label_client_id: Cliente
+    label_password: Contraseña
+    label_static_ip: Ip Estática
+    label_comments: Comentarios
+    label_description: Descripción
+    label_host: Host
+    label_snmp_comunity: SNMP Comunity
+    label_snmp_version: SNMP Versión
+    label_radius_password: Contraseña
+    label_model: modelo
+    label_acct_enabled: Cuenta Habilitada
+
+show:
+    label__action: Acciones
+    label_id: Id
+    label_name: Nombre
+    label_download: Download
+    label_upload: Upload
+    label_profile: Perfil
+    label_client_id: Cliente
+    label_password: Contraseña
+    label_static_ip: Ip Estática
+    label_comments: Comentarios
+    label_description: Descripción
+    label_host: Host
+    label_snmp_comunity: SNMP Comunity
+    label_snmp_version: SNMP Versión
+    label_radius_password: Contraseña
+    label_model: modelo
+    label_acct_enabled: Cuenta Habilitada
+
+error:
+    address_not_found: Dirección no encontrada.
+
+Distance: Distancia