فهرست منبع

Merged in FD3-643 (pull request #19)

FD3-643 Se puede asignar template a profile en cablemodem

Approved-by: Maximiliano Schvindt <maximiliano@interlink.com.ar>
Guillermo Espinoza 6 سال پیش
والد
کامیت
1966c7845c

+ 24 - 0
app/DoctrineMigrations/Version20180809154844.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+
+class Version20180809154844 extends AbstractMigration
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $this->addsql("UPDATE profile SET template = 'template_docsis.tpl' WHERE isnull(template)");
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+    }
+}

+ 45 - 0
app/DoctrineMigrations/Version20180809155041.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace Application\Migrations;
+
+use MigrationsBundle\Migrations\MigrationsBase;
+use Doctrine\DBAL\Schema\Schema;
+
+class Version20180809155041 extends MigrationsBase
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        // migrations a borrar
+        $migrationVersions = [
+            '20180124153518',
+            '20180606123455',
+        ];
+
+        foreach ($migrationVersions as $version) {
+            $this->addSql("DELETE FROM migration_versions WHERE version = {$version};");
+        }
+        
+        foreach ($migrationVersions as $version) {
+            $this->addSql("DELETE FROM migration_versions WHERE version = {$version};");
+        }
+
+        // cargo todos los archivos que esten en src/
+        // deben tener extensión yml
+        $directory = __DIR__ . DIRECTORY_SEPARATOR . 'src';
+        $migrations = scandir($directory);
+        foreach ($migrations as $migration) {
+            $this->executeYaml($directory, $migration);
+            $this->showResult();
+        }
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+    }
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 52 - 0
app/DoctrineMigrations/src/action.yml


+ 16 - 0
app/DoctrineMigrations/src/workflow.yml

@@ -0,0 +1,16 @@
+insertorupdate:
+    workflow:
+        -
+          id: 1
+          name: "cablemodem_workflow"
+          type: "state_machine"
+          marking_type: "single_state"
+          marking_name: "currentState"
+          description: "cablemodem workflow"
+          template: "initial_place: active\r\nplaces:\r\n  - active\r\n  - disable\r\ntransitions:\r\n  add_config:\r\n    from: active\r\n    to: active\r\n  disable:\r\n    from: active\r\n    to: disable\r\n  active:\r\n    from: disable\r\n    to: active"
+          created: "2017-04-27 11:35:07"
+          updated: "2017-04-27 20:01:43"
+          tenancy_id: 1
+          enable: 1
+          support: "a:1:{i:0;s:34:\"CablemodemBundle\\Entity\\Cablemodem\";}"
+          owner: 1

+ 1 - 0
app/config/import_data.yml

@@ -52,6 +52,7 @@ Profile:
         filtro_download: filtro_download
         max_cpe: max_cpe
         tenancy_id: tenancy_id
+        template: { value: "template_docsis.tpl" }
 
 Node:
     source_table: "Node"

+ 2 - 0
app/config/profile.yml

@@ -59,3 +59,5 @@ docsis_key          :   cmts-default
 #SnmpCfgAccess2_community     :       public          #sin default
 COPS:
    Upstream:
+
+template: "template_docsis.tpl"

+ 3 - 1
composer.json

@@ -194,7 +194,8 @@
         "mkdir-dir-cache-sessions-logs": "mkdir -p var/cache var/logs var/sessions",
         "chmod-dir-cache-sessions-logs": "chmod 777 -R var/cache var/logs var/sessions",
         "doctrine-update": "php bin/console doctrine:schema:update --force",
-        "doctrine-migrations": "php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration",
+        "doctrine-migrations-down": "php bin/console doctrine:migrations:migrate --no-interaction first -vvv",
+        "doctrine-migrations": "php bin/console doctrine:migrations:migrate --no-interaction -vvv",
         "auto-increment": "php bin/console baseadmin:autoincrement",
         "init-template-docsis": "php bin/console init:templates:docsis",
         "post-install-cmd": [
@@ -204,6 +205,7 @@
             "@chmod-dir-cache-sessions-logs",
             "@doctrine-update",
             "@auto-increment",
+            "@doctrine-migrations-down",
             "@doctrine-migrations",
             "@init-template-docsis"
         ],

+ 29 - 2
src/CablemodemBundle/Admin/ProfileAdmin.php

@@ -3,10 +3,12 @@
 namespace CablemodemBundle\Admin;
 
 use Base\AdminBundle\Admin\BaseAdmin;
+use TemplateBundle\Entity\Template;
 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\ChoiceType;
 
 class ProfileAdmin extends BaseAdmin
 {
@@ -37,6 +39,7 @@ class ProfileAdmin extends BaseAdmin
             ->add('filtroUpload')
             ->add('filtroDownload')
             ->add('maxCpe')
+            ->add('template')
             ->add('_action', null, array(
                 'actions' => array(
                     'show' => array(),
@@ -52,13 +55,36 @@ class ProfileAdmin extends BaseAdmin
      */
     protected function configureFormFields(FormMapper $formMapper)
     {
+        $templates = $this->getRepository(Template::class)->findAll();
+        if (count($templates)) {
+            $templates = array_map(function($template) {
+                return $template->getName();
+            }, $templates);
+        }
+        
         $formMapper
             ->add('name')
-            ->add('downstream',null,array('help' => $this->trans('help.profile_downstream'), 'attr' => array('placeholder' => $this->trans('help.profile_value_default'))))
-            ->add('upstream',null,array('help' => $this->trans('help.profile_downstream'), 'attr' => array('placeholder' => $this->trans('help.profile_value_default'))))
+            ->add('downstream',null,array(
+                'help' => $this->trans('help.profile_downstream'), 
+                'attr' => array(
+                    'placeholder' => $this->trans('help.profile_value_default')
+                )))
+            ->add('upstream', null, array(
+                'help' => $this->trans('help.profile_downstream'), 
+                'attr' => array(
+                    'placeholder' => $this->trans('help.profile_value_default')
+                )))
             ->add('filtroUpload')
             ->add('filtroDownload')
             ->add('maxCpe')
+            ->add('template', ChoiceType::class, [
+                'required' => false,
+                'choices' => array_combine($templates, $templates),
+                'preferred_choices' => [
+                    'template_docsis.tpl',
+                ],
+                'help' => $this->trans('help.profile_template')
+            ])
         ;
     }
 
@@ -74,6 +100,7 @@ class ProfileAdmin extends BaseAdmin
             ->add('filtroUpload')
             ->add('filtroDownload')
             ->add('maxCpe')
+            ->add('template')
         ;
     }
 }

+ 29 - 0
src/CablemodemBundle/Entity/Profile.php

@@ -81,11 +81,20 @@ class Profile  implements TenancyIdTraitInterface
      * @ORM\Column(type="bigint", nullable=true)
      */
     protected $maxCpe;
+    
+    /**
+     * @var string $template
+     *
+     * @ORM\Column(type="string", nullable=true)
+     */
+    protected $template;
+    
 
     public function __construct()
     {
         $this->downstream = $this->getDefault('downstream');
         $this->upstream = $this->getDefault('upstream');
+        $this->template = $this->getDefault('template');
     }
 
     /**
@@ -276,5 +285,25 @@ class Profile  implements TenancyIdTraitInterface
 
         return $value;
     }
+    
+    /**
+     * @return string
+     */
+    public function getTemplate()
+    {
+        return $this->template;
+    }
+    
+    /**
+     * @param string $template
+     * 
+     * @return Profile
+     */
+    public function setTemplate($template)
+    {
+        $this->template = $template;
+        
+        return $this;
+    }
 
 }

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

@@ -77,6 +77,7 @@ form:
     label_mta_fixed_i_p:  IP fija MTA
     label_comments: Comentarios
     label_time_cm_stats: Estadísticas y SLA de CMs
+    label_template: Template
     
 list:
     label_id: Id
@@ -109,6 +110,7 @@ list:
     label_docs_version: Versión DOCSIS
     label_mta_enabled: MTA Enabled
     label_comments: Comentarios
+    label_template: Template
     
 show:
     label_id: Id
@@ -141,6 +143,7 @@ show:
     label_docs_version: Versión DOCSIS
     label_mta_enabled: MTA Enabled
     label_comments: Comentarios
+    label_template: Template
 
 Mac: Mac
 Options: Opciones
@@ -159,3 +162,4 @@ 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!
+    profile_template: Template a utilizar para generar archivo docsis