Browse Source

Merge master

gabriel 8 years ago
parent
commit
3f7045913f
4 changed files with 92 additions and 21 deletions
  1. 1 1
      Dockerfile
  2. 14 14
      composer.lock
  3. 67 5
      src/FTTHBundle/Form/ONUType.php
  4. 10 1
      src/FTTHBundle/Resources/config/services.yml

+ 1 - 1
Dockerfile

@@ -17,7 +17,7 @@ RUN mkdir ~/.ssh
 RUN ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts
 RUN ssh-keyscan -H -p 222 infra.flowdat.com >> ~/.ssh/known_hosts
 RUN ssh-keyscan -H -p 222 200.50.168.30 >> ~/.ssh/known_hosts
-RUN ssh-keyscan -H -p 222 infra.flowdat.com >> ~/.ssh/known_hosts
+RUN ssh-keyscan -H -p 222 gogs.infra.flowdat.com >> ~/.ssh/known_hosts
 
 WORKDIR /opt/ftth
 

+ 14 - 14
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "61f657115e760d8790a22461779c9167",
+    "content-hash": "0c8123307b80636aa5779938b5b4c04a",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1412,7 +1412,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2017-08-25 12:53:50"
+            "time": "2017-08-24 15:21:23"
         },
         {
             "name": "ik/device-bundle",
@@ -1420,7 +1420,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/DeviceBundle.git",
-                "reference": "f6b8fdcefdf517a0a28f4c8abd79940228e6ac7c"
+                "reference": "f801d9002000c0804b5e8436dc1f4ac6a0143514"
             },
             "type": "library",
             "autoload": {
@@ -1435,7 +1435,7 @@
                 "bundle",
                 "validators"
             ],
-            "time": "2017-08-15 13:45:08"
+            "time": "2017-08-01 18:49:14"
         },
         {
             "name": "ik/extra-data-bundle",
@@ -1533,7 +1533,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
-                "reference": "f08457f1022b672abc8a588dfa23ad4c12df694c"
+                "reference": "a03727651ff9722db1ad639d422f55d76fe8ad96"
             },
             "require": {
                 "ext-curl": "*",
@@ -1552,7 +1552,7 @@
                 "bundle",
                 "oauth"
             ],
-            "time": "2017-08-24 15:50:04"
+            "time": "2017-08-23 14:24:43"
         },
         {
             "name": "ik/owner-voter-bundle",
@@ -1622,7 +1622,7 @@
                 }
             },
             "description": "The Flowdat3 Webservice Rest",
-            "time": "2017-08-25 14:28:21"
+            "time": "2017-08-15 13:48:13"
         },
         {
             "name": "ik/workflow-bundle",
@@ -2054,7 +2054,7 @@
                     "email": "stof@notk.org"
                 },
                 {
-                    "name": "KnpLabs",
+                    "name": "Knplabs",
                     "homepage": "http://knplabs.com"
                 },
                 {
@@ -2113,7 +2113,7 @@
                     "email": "stof@notk.org"
                 },
                 {
-                    "name": "KnpLabs",
+                    "name": "Knplabs",
                     "homepage": "http://knplabs.com"
                 },
                 {
@@ -3959,16 +3959,16 @@
         },
         {
             "name": "sensio/distribution-bundle",
-            "version": "v5.0.21",
+            "version": "v5.0.20",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sensiolabs/SensioDistributionBundle.git",
-                "reference": "eb6266b3b472e4002538610b28a0a04bcf94891a"
+                "reference": "4b019d4c0bd64438c42e4b6b0726085b409be8d9"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/eb6266b3b472e4002538610b28a0a04bcf94891a",
-                "reference": "eb6266b3b472e4002538610b28a0a04bcf94891a",
+                "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/4b019d4c0bd64438c42e4b6b0726085b409be8d9",
+                "reference": "4b019d4c0bd64438c42e4b6b0726085b409be8d9",
                 "shasum": ""
             },
             "require": {
@@ -4007,7 +4007,7 @@
                 "configuration",
                 "distribution"
             ],
-            "time": "2017-08-25T16:55:44+00:00"
+            "time": "2017-05-11T16:21:03+00:00"
         },
         {
             "name": "sensio/framework-extra-bundle",

+ 67 - 5
src/FTTHBundle/Form/ONUType.php

@@ -6,8 +6,24 @@ use Symfony\Component\Form\AbstractType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\OptionsResolver\OptionsResolver;
 
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+
+use Symfony\Component\Form\FormEvent;
+use Symfony\Component\Form\FormEvents;
+
 class ONUType extends AbstractType
 {
+
+    protected $webservice = null;
+    public function setWebService($ws){
+	$this->webservice = $ws;
+    }
+
+    protected $em = null;
+    public function setEntityManager($em){
+	$this->em = $em;
+    }
+
     /**
      * {@inheritdoc}
      */
@@ -16,13 +32,61 @@ class ONUType extends AbstractType
         $builder->add('ip')
                 ->add('mac')
                 ->add('serialNumber')
+                ->add('profile')
+                ->add('model')
+                ->add('nap')
                 ->add('ponSerialNumber')
                 ->add('clientId')
-                ->add('administrativeState')
-                ->add('currentState')
-                ->add('transitionState')
                 ->add('tenancyId')
                 ;
+
+	$builder->addEventListener(
+            FormEvents::PRE_SUBMIT,
+            function (FormEvent $event) {
+                $form = $event->getForm();
+
+                $data = $event->getData();
+
+		$clientID = $data['clientId'];
+
+		if(is_array($clientID) and $this->webservice){
+		$clientID["disableTenancy"] = 1;
+			$remote_data = $this->webservice->getData("client", $clientID);
+			if(count($remote_data) === 1){
+				$data["clientId"] = $remote_data[0]["id"];
+			}else{
+				unset($data["clientId"]);
+			}
+		}
+
+		if(isset($data["profile"]) and is_array($data["profile"]) and $this->em){
+			$profile = $this->em->getRepository("FTTHBundle\Entity\Profile")->findOneBy($data["profile"]);
+			unset($data["profile"]);
+			if($profile){
+				$data["profile"] = $profile->getId();
+			}
+		}
+
+		if(isset($data["model"]) and is_array($data["model"]) and $this->em){
+			$model = $this->em->getRepository("FTTHBundle\Entity\ONUModel")->findOneBy($data["model"]);
+			unset($data["model"]);
+			if($model){
+				$data["model"] = $model->getId();
+			}
+		}
+
+		if(isset($data["nap"]) and is_array($data["nap"]) and $this->em){
+			$nap= $this->em->getRepository("FTTHBundle\Entity\NAP")->findOneBy($data["nap"]);
+			unset($data["nap"]);
+			if($nap){
+				$data["nap"] = $nap->getId();
+			}
+		}
+
+		$event->setData($data);
+
+            }
+        );
     }
     
     /**
@@ -42,6 +106,4 @@ class ONUType extends AbstractType
     {
         return 'ftthbundle_onu';
     }
-
-
 }

+ 10 - 1
src/FTTHBundle/Resources/config/services.yml

@@ -50,4 +50,13 @@ services:
     ftth.onu_position.subscriber:
         class: FTTHBundle\EventListener\ONUPositionSubscriber
         tags:
-            - { name: doctrine.event_subscriber, connection: default }
+            - { name: doctrine.event_subscriber, connection: default }
+
+    ftth.onu.form:
+        class: FTTHBundle\Form\ONUType
+        calls:
+            - ["setWebService", ["@webservice"]]
+            - ["setEntityManager", ["@doctrine.orm.entity_manager"]]
+        tags:
+            - { name: form.type }
+