Pārlūkot izejas kodu

Merge branch 'FD3-607' of bitbucket.org:ikflowdat/dhcp into FD3-607

Espinoza Guillermo 6 gadi atpakaļ
vecāks
revīzija
2f5c33ccb2

+ 1 - 3
app/Resources/workflows/workflow_list.yml.dist

@@ -7,11 +7,9 @@ framework:
         arguments:
           - currentState
       supports:
-        - HostBundle\Entity\Host
+        - IPv4Bundle\Entity\Host
         - IPv4Bundle\Entity\Pool
         - IPv4Bundle\Entity\SubNet
-        - IPv6Bundle\Entity\Pool
-        - IPv6Bundle\Entity\SubNet
       initial_place: active
       places:
         - active

+ 17 - 10
src/KeaBundle/Admin/ConfigAdmin.php

@@ -16,20 +16,24 @@ class ConfigAdmin extends BaseAdmin
     {
         switch ($name) {
             case 'edit':
-                return 'TemplateBundle:Template:template_edit.html.twig';
+            case 'create':
+                return 'KeaBundle:Config:get.html.twig';
                 break;
-
+    
             default:
                 return parent::getTemplate($name);
                 break;
         }
     }
 
+    /**
+     * @param RouteCollection $collection
+     */
     protected function configureRoutes(RouteCollection $collection)
     {
-        $collection->remove('history')->remove('create');
+        $collection->remove('history');
     }
-
+    
     /**
      * @param string $action
      * @param Object $object
@@ -39,10 +43,10 @@ class ConfigAdmin extends BaseAdmin
     public function configureActionButtons($action, $object = null)
     {
         $actions = parent::configureActionButtons($action, $object);
-        $actions['config_manager'] = array(
+        $actions['create'] = array(
             'template' => 'KeaBundle:Config:config_manager_button.html.twig',
         );
-
+    
         return $actions;
     }
 
@@ -66,7 +70,6 @@ class ConfigAdmin extends BaseAdmin
         $listMapper
             ->add('dhcp')
             ->add('description')
-            //->add('template')
             ->add('created')
             ->add('_action', null, array(
                 'actions' => array(
@@ -85,8 +88,9 @@ class ConfigAdmin extends BaseAdmin
     {
         $formMapper
             ->add('dhcp')
-            ->add('description')
-            ->add('template')
+            ->add('template', null, [
+                'label' => false,
+            ])
         ;
     }
 
@@ -99,7 +103,10 @@ class ConfigAdmin extends BaseAdmin
             ->add('dhcp')
             ->add('description')
             ->add('created')
-            ->add('template', 'string', array('template' => 'TemplateBundle:CRUD:content_field.html.twig','data' => 'show'))
+            ->add('template', 'string', array(
+                'template' => 'TemplateBundle:CRUD:content_field.html.twig',
+                'data' => 'show',
+            ))
         ;
     }
 }

+ 11 - 19
src/KeaBundle/Controller/ConfigController.php

@@ -26,19 +26,14 @@ use FOS\RestBundle\Controller\Annotations\RouteResource;
 class ConfigController extends Controller
 {
 
+    /**
+     * @param Request $request
+     *
+     * @return Response
+     */
     public function getAction(Request $request) 
     {
-        $adminPool = $this->get('sonata.admin.pool');
         $translator = $this->get('translator');
-        $flashbag = $this->get('session')->getFlashBag();
-
-        $form = $this->createFormBuilder()
-            ->add('dhcpId', EntityType::class, array(
-                'class' => 'DHCPBundle\Entity\DHCP', 
-                'choice_label' => 'name', 
-                'label' => $translator->trans("form.label_dhcp", array(), "KeaBundle")
-            ))
-            ->getForm();
 
         if ($dhcpId = $request->get('dhcpId')) {
             $action = $request->get('action');
@@ -74,18 +69,15 @@ class ConfigController extends Controller
 
             return $response;
         }
-
-        return $this->render('KeaBundle:Config:get.html.twig', array(
-            'base_template' => $adminPool->getTemplate('layout'),
-            'admin_pool' => $adminPool,
-            'admin' => $adminPool->getAdminByClass("KeaBundle\Entity\Config"),
-            'form' => $form->createView()
-        ));
+        
+        return $this->redirect($this->generateUrl('admin_kea_config_create'));
     }
 
     /**
-     * @param DHCP
-     * @param json
+     * @param DHCP $dhcp
+     * @param string $template
+     *
+     * @return boolean
      */
     private function saveConfig(DHCP $dhcp, $template)
     {

+ 4 - 1
src/KeaBundle/Resources/translations/KeaBundle.es.yml

@@ -15,6 +15,7 @@ breadcrumb:
     link_d_h_c_p_delete: Eliminar Configuración
     link_config_list: Listado de Configuraciones
     link_config_delete: Eliminar Configuración
+    link_config_create: Configurar KEA
     link_lease4_list: Listado Leases
     
 list:
@@ -76,4 +77,6 @@ api:
     generate_config_help: Genera la configuración para el KEA del DHCP partiendo de los datos cargados en el sistema de Flowdat(host, dhcp, subred y pool).
     set_config_help: Genera configuración KEA y la envía hacia el KEA del DHCP seleccionado.
     reload_config_help: Genera configuración KEA y la envía hacia el KEA del DHCP seleccionado.
-    reload_hooks_help: Carga nuevamente las librerías de Hooks.
+    reload_hooks_help: Carga nuevamente las librerías de Hooks.
+    
+alert_select_dhcp: Seleccione un DHCP de KEA    

+ 1 - 1
src/KeaBundle/Resources/views/Config/config_manager_button.html.twig

@@ -1,5 +1,5 @@
 <li>
-    <a class="sonata-action-element" href="{{ path('kea_get_config') }}">
+    <a class="sonata-action-element" href="{{ path('admin_kea_config_create') }}">
         <i class="fa fa-cog" aria-hidden="true"></i>
         {{ 'kea_get_config'|trans({}, 'KeaBundle') }}
     </a>

+ 3 - 11
src/KeaBundle/Resources/views/Config/get.html.twig

@@ -15,15 +15,6 @@
 
 {% block actions %}{% endblock %}
 
-{% block tab_menu %}
-<ol class="nav navbar-top-links breadcrumb">
-    <li>
-        <a href="{{url('sonata_admin_dashboard')}}"><i class="fa fa-home"></i></a>
-    </li>
-    <li class="active"><span>{{ 'msg_import_kea_config'|trans({}, 'KeaBundle') }}</span></li>
-</ol>
-{% endblock %}
-
 {% block title %}
 {% endblock %}
 
@@ -63,11 +54,12 @@
                     <div class="box-body">  
                         <div class="sonata-ba-collapsed-fields">
                             <div class="form-group clearfix">
-                                {{ form_widget(form) }}
+                                {{ form_widget(form.dhcp, { id: 'form_dhcpId' }) }}
                                 <br />
                                 <div class="clearfix">
+                                    <br />
                                     <div style="width:55%; float: left">
-                                        <textarea id="textarea_ace_editor"></textarea>
+                                    {{ form_widget(form.template, { id: 'textarea_ace_editor' }) }}
                                     </div>
                                     <div style="width:40%; float: left">
                                         <br />