Sfoglia il codice sorgente

Action update devices para estadísticas

Guillermo Espinoza 8 anni fa
parent
commit
aa6ef272ef

+ 16 - 0
src/StatsBundle/Admin/StatsDeviceAdmin.php

@@ -72,4 +72,20 @@ class StatsDeviceAdmin extends BaseAdmin
         ;
     }
 
+    /**
+     * @param string $action
+     * @param Object $object
+     * 
+     * @return array
+     */
+    public function configureActionButtons($action, $object = null)
+    {
+        $actions = parent::configureActionButtons($action, $object);
+        $actions['update_devices'] = array(
+            'template' => 'StatsBundle:StatsDevice:update_devices.html.twig',
+        );
+
+        return $actions;
+    }
+
 }

+ 1 - 0
src/StatsBundle/Command/StatsDevicesCommand.php

@@ -29,6 +29,7 @@ class StatsDevicesCommand extends ContainerAwareCommand
         $statsDeviceManager = $this->getContainer()->get('stats.device.manager');
         $devices = $statsDeviceManager->getDevices();
         if (count($devices)) {
+            $output->writeln('Nuevos StatsDevice:');
             foreach ($devices as $device) {
                 $output->writeln(sprintf('<info>DeviceType:</info> %s <info>DeviceIp:</info> %s', $device->getDeviceType(), $device->getIp()));
             }

+ 17 - 2
src/StatsBundle/Controller/StatsController.php

@@ -2,10 +2,25 @@
 
 namespace StatsBundle\Controller;
 
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use StatsBundle\Services\DeviceManager;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 
 class StatsController extends Controller
 {
-    
+
+    /**
+     * @Route("/admin/stats/statsdevice/update", name="stats_update_devices")
+     * 
+     * @return string
+     */
+    public function updateDevicesAction()
+    {
+        /* @var $statsDeviceManager DeviceManager */
+        $statsDeviceManager = $this->get('stats.device.manager');
+        $statsDeviceManager->getDevices();
+
+        return $this->redirect($this->generateUrl('admin_stats_statsdevice_list'));
+    }
+
 }

+ 2 - 0
src/StatsBundle/Resources/translations/StatsBundle.es.yml

@@ -43,3 +43,5 @@ help:
 Stats: Estadísticas
 DeviceServer: Servidor Dispositivos
 StatsDevice: Dispositivo
+
+link_action_update_devices: Actualizar dispositivos

+ 6 - 0
src/StatsBundle/Resources/views/StatsDevice/update_devices.html.twig

@@ -0,0 +1,6 @@
+<li>
+    <a class="sonata-action-element" href="{{ path('stats_update_devices') }}">
+        <i class="fa fa-plus-circle" aria-hidden="true"></i>
+        {{ 'link_action_update_devices'|trans({}, 'StatsBundle') }}
+    </a>
+</li>