浏览代码

FD3-660 se agregan select con ip fijas dependiendo del tipo de host

Espinoza Guillermo 7 年之前
父节点
当前提交
3d48059199

+ 2 - 1
composer.json

@@ -181,7 +181,8 @@
             "chown -Rf www-data:www-data app/Resources/workflows",
             "cp -n app/Resources/workflows/workflow_list.yml.dist app/Resources/workflows/workflow_list.yml",
             "chown -Rf www-data:www-data app/Resources/workflows/workflow_list.yml",
-            "chown -Rf www-data:www-data web/workflows_png"
+            "chown -Rf www-data:www-data web/workflows_png",
+            "php bin/console workflow:default --class=CablemodemBundle\\\\Entity\\\\Cablemodem --all"
         ],
         "symfony-scripts": [
             "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",

+ 22 - 1
src/CablemodemBundle/Admin/CablemodemAdmin.php

@@ -2,10 +2,14 @@
 
 namespace CablemodemBundle\Admin;
 
+use CablemodemBundle\Form\FixedIPSubscriber;
+use Symfony\Component\Form\FormEvent;
+use Symfony\Component\Form\FormEvents;
 use Sonata\AdminBundle\Datagrid\DatagridMapper;
 use Sonata\AdminBundle\Datagrid\ListMapper;
 use Sonata\AdminBundle\Form\FormMapper;
 use Sonata\AdminBundle\Show\ShowMapper;
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
 use WorkflowBundle\Admin\WorkflowBaseAdmin;
 
 class CablemodemAdmin extends WorkflowBaseAdmin
@@ -65,7 +69,13 @@ class CablemodemAdmin extends WorkflowBaseAdmin
                     ->with('')
                         ->add('clientId')
                         ->add('model')
-                        ->add('mac','text',array('attr' => array('pattern' => '[a-zA-Z0-9]+','title' => 'Only accept [0-9a-zA-Z]', 'maxlength' => '12', 'minlength' => '12')))
+                        ->add('mac', 'text', array(
+                            'attr' => array(
+                                'pattern' => '[a-zA-Z0-9]+',
+                                'title' => $this->trans('Only accept [0-9a-zA-Z]', [], 'CablemodemBundle'),
+                                'maxlength' => '12',
+                                'minlength' => '12'
+                            )))
                         ->add('activationCode')
                         ->add('node')
                         ->add('profile')
@@ -82,12 +92,20 @@ class CablemodemAdmin extends WorkflowBaseAdmin
                                 'allow_delete' => true))
                     ->end()
                     ->with('DHCP')
+                        ->add('checkFixedIP', CheckboxType::class)
                         ->add('fixedIP')
+                        ->add('checkCpeFixedIP', CheckboxType::class)
                         ->add('cpeFixedIP')
+                        ->add('checkMtaFixedIP', CheckboxType::class)
                         ->add('mtaFixedIP')
                     ->end()
                 ->end()
         ;
+                
+        // Actualizo los campos fixedIP dependiendo si hay valores cargados en el Cablemodem
+        $subject = $this->getSubject();
+        $formMapper->getFormBuilder()->addEventSubscriber(new FixedIPSubscriber($subject));
+        
     }
 
     /**
@@ -104,6 +122,9 @@ class CablemodemAdmin extends WorkflowBaseAdmin
             ->add('profile')
             ->add('comments')
             ->add('mtaEnabled')
+            ->add('fixedIP')
+            ->add('cpeFixedIP')
+            ->add('mtaFixedIP')
         ;
         
         $this->addDHCPTab($showMapper);

+ 17 - 2
src/CablemodemBundle/Command/DHCPHostCRUDCommand.php

@@ -123,16 +123,31 @@ EOT
             $method = HttpRequestInterface::METHOD_PUT;
         }
         
+        $fixedIP = $this->cablemodem->getFixedIP();
+        $mtaFixedIP = $this->cablemodem->getMtaFixedIP();
+        $cpeFixedIP = $this->cablemodem->getCpeFixedIP();
+        
+        $options = isset($host['options']) ? $host['options'] : [];
+        
         $data = [
             'mac' => $this->mac,
             'hostType' => isset($host['hostType']) ? $host['hostType']['id'] : $this->getIdHostType($type),
             'state' => 'active',
-            'fixedIP' => $this->cablemodem->getFixedIP(),
+            'options.fixed_address' => $fixedIP ?: null,
+            'fixedIP' => $fixedIP ? true : false,
         ];
         if ($type == 'MTA' || $type == 'CPE') {
             unset($data['mac']);
             $data['host'] = $hostId;
-            $data['fixedIP'] = $type == 'MTA' ? $this->cablemodem->getMtaFixedIP() : $this->cablemodem->getCpeFixedIP();
+            
+            if ($type == 'MTA') {
+                $data['options.fixed_address'] = $mtaFixedIP ?: null;
+                $data['fixedIP'] = $mtaFixedIP ? true : false;
+            }
+            if ($type == 'CPE') {
+                $data['options.fixed_address'] = $cpeFixedIP ?: null;
+                $data['fixedIP'] = $cpeFixedIP ? true : false;
+            }
         }
         $dhcpOptions = $this->cablemodem->getDHCPOptions();
         $data = array_merge($data, $dhcpOptions);

+ 23 - 17
src/CablemodemBundle/Entity/Cablemodem.php

@@ -155,23 +155,29 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     protected $voip = null;
     
     /**
-    * @ORM\Column(type="boolean", nullable=true)
-    */
-    protected $fixedIP = false;
+     * @ORM\Column(type="string", nullable=true)
+     */
+    protected $fixedIP;
     
     /**
-    * @ORM\Column(type="boolean", nullable=true)
-    */
-    protected $cpeFixedIP = false;
+     * @ORM\Column(type="string", nullable=true)
+     *
+     * @Assert\Ip()
+     */
+    protected $cpeFixedIP;
     
     /**
-    * @ORM\Column(type="boolean", nullable=true)
-    */
-    protected $mtaFixedIP = false;
+     * @ORM\Column(type="string", nullable=true)
+     *
+     * @Assert\Ip()
+     */
+    protected $mtaFixedIP;
     
     /**
-    * @ORM\Column(type="text", nullable=true)
-    */
+     * @ORM\Column(type="text", nullable=true)
+     *
+     * @Assert\Ip()
+     */
     protected $comments;
 
 
@@ -458,7 +464,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     }
     
     /**
-     * @return boolean
+     * @return string
      */
     public function getFixedIP()
     {
@@ -466,7 +472,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     }
     
     /**
-     * @param boolean $fixedIP
+     * @param string $fixedIP
      *
      * @return Cablemodem
      */
@@ -478,7 +484,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     }
     
     /**
-     * @return boolean
+     * @return string
      */
     public function getCpeFixedIP()
     {
@@ -486,7 +492,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     }
     
     /**
-     * @param boolean $cpeFixedIP
+     * @param string $cpeFixedIP
      *
      * @return Cablemodem
      */
@@ -498,7 +504,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     }
     
     /**
-     * @return boolean
+     * @return string
      */
     public function getMtaFixedIP()
     {
@@ -506,7 +512,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     }
     
     /**
-     * @param boolean $mtaFixedIP
+     * @param string $mtaFixedIP
      *
      * @return Cablemodem
      */

+ 1 - 0
src/CablemodemBundle/Resources/config/services.yml

@@ -7,6 +7,7 @@ services:
             - { name: sonata.admin, manager_type: orm, group: Cablemodem, label: Cablemodem, label_catalogue: CablemodemBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
         calls:
             - [setTranslationDomain, [CablemodemBundle]]
+            - [setTemplate, [edit, "CablemodemBundle:CRUD:edit.html.twig"]]
         public: true
 
     sonata.admin.profile:

+ 15 - 0
src/CablemodemBundle/Resources/translations/CablemodemBundle.es.yml

@@ -77,6 +77,9 @@ form:
     label_mta_fixed_i_p:  IP fija MTA
     label_comments: Comentarios
     label_time_cm_stats: Estadísticas y SLA de CMs
+    label_check_fixed_i_p: IP fija
+    label_check_cpe_fixed_i_p: IP fija CPE
+    label_check_mta_fixed_i_p: IP fija MTA
     
 list:
     label_id: Id
@@ -109,6 +112,9 @@ list:
     label_docs_version: Versión DOCSIS
     label_mta_enabled: MTA Enabled
     label_comments: Comentarios
+    label_fixed_i_p: IP fija
+    label_cpe_fixed_i_p: IP fija CPE
+    label_mta_fixed_i_p: IP fija MTA 
     
 show:
     label_id: Id
@@ -141,6 +147,9 @@ show:
     label_docs_version: Versión DOCSIS
     label_mta_enabled: MTA Enabled
     label_comments: Comentarios
+    label_fixed_i_p: IP fija
+    label_cpe_fixed_i_p: IP fija CPE
+    label_mta_fixed_i_p: IP fija MTA 
 
 Mac: Mac
 Options: Opciones
@@ -159,3 +168,9 @@ voip.technology: Tecnología
 help:
     profile_downstream: Expresado en bits
     profile_value_default: Al deja en blanco el valor, se asignará un valor por defecto!
+
+'Only accept [0-9a-zA-Z]': Utilice solo [0-9a-zA-Z]
+'Check fixed i p':  IP fija
+'Check cpe fixed i p':  IP fija CPE
+'Check mta fixed i p':  IP fija MTA
+dhcp_host_error: No hay información del Host desde DHCP

+ 2 - 0
src/CablemodemBundle/Resources/views/CRUD/host_show_field.html.twig

@@ -33,6 +33,8 @@
     </tbody>
 </table>
 </td>
+{% else %}
+{{ 'dhcp_host_error'|trans({}, 'CablemodemBundle') }}
 {% endif %}
 
 {% endblock %}