From f4fb8496dae724451de893ea055da8aa493395fc Mon Sep 17 00:00:00 2001
From: Lionel Assepo <lassepo@merethis.com>
Date: Fri, 27 Mar 2015 17:45:52 +0100
Subject: [PATCH]     * Improve Widget Selection dashboard creation

---
 core/internal/Controller.php                  |   2 +-
 core/internal/Form/Generator/Web/Wizard.php   |   3 -
 .../controllers/ConnectorController.php       |   3 +-
 .../controllers/DashboardController.php       |  74 +++++++-
 .../controllers/LayoutController.php          |  59 +++++++
 .../install/datas/centreon.json               |   5 +
 .../datas/centreon/cfg_dashboards.json        |  10 ++
 .../centreon/cfg_dashboards_containers.json   |   3 +-
 .../centreon/cfg_dashboards_layouts.json      |   8 +
 .../install/db/centreon/cfg_dashboards.xml    |   4 +
 .../install/forms/Dashboard.xml               |  27 +++
 .../internal/Dashboard.php                    |  18 ++
 .../internal/Dashboard/Layout.php             |   6 +
 .../internal/DashboardContainer.php           | 158 ++++++++++++++++++
 .../models/Dashboardcontainer.php             |  51 ++++++
 .../repositories/LayoutRepository.php         |  26 +++
 .../static/centreon-dashboard/css/block.css   |  18 ++
 .../static/centreon-dashboard/css/geoGrid.css |  11 ++
 .../js/centreon-dashboard.js                  |  76 ++++++++-
 .../views/container-full.tpl                  |  41 +++++
 .../views/container-light.tpl                 |   2 +
 .../views/dashboardLayouts/geoGrid.tpl        |   5 +
 .../views/dashboardLayouts/quarterGrid.tpl    |  48 +++---
 .../views/dashboardLayouts/top-grid.tpl       |   8 +
 .../views/mainDashboard.tpl                   |  11 +-
 .../controllers/MenuController.php            |  11 ++
 26 files changed, 636 insertions(+), 52 deletions(-)
 create mode 100644 modules/CentreonDashboardModule/controllers/LayoutController.php
 create mode 100644 modules/CentreonDashboardModule/install/datas/centreon.json
 create mode 100644 modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards.json
 create mode 100644 modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_layouts.json
 create mode 100644 modules/CentreonDashboardModule/install/forms/Dashboard.xml
 create mode 100644 modules/CentreonDashboardModule/internal/DashboardContainer.php
 create mode 100644 modules/CentreonDashboardModule/models/Dashboardcontainer.php
 create mode 100644 modules/CentreonDashboardModule/static/centreon-dashboard/css/block.css
 create mode 100644 modules/CentreonDashboardModule/static/centreon-dashboard/css/geoGrid.css
 create mode 100644 modules/CentreonDashboardModule/views/container-full.tpl
 create mode 100644 modules/CentreonDashboardModule/views/container-light.tpl
 create mode 100644 modules/CentreonDashboardModule/views/dashboardLayouts/geoGrid.tpl
 create mode 100644 modules/CentreonDashboardModule/views/dashboardLayouts/top-grid.tpl

diff --git a/core/internal/Controller.php b/core/internal/Controller.php
index 3c18b8a2b2..65911c70e8 100644
--- a/core/internal/Controller.php
+++ b/core/internal/Controller.php
@@ -95,7 +95,7 @@ abstract class Controller extends HttpCore
         $tplDirectory = 'file:['. static::$moduleName . 'Module]';
         $this->tpl->display($tplDirectory . $tplFile);
     }
-    
+
     /**
      *
      */
diff --git a/core/internal/Form/Generator/Web/Wizard.php b/core/internal/Form/Generator/Web/Wizard.php
index c410a73c29..50fc41e848 100644
--- a/core/internal/Form/Generator/Web/Wizard.php
+++ b/core/internal/Form/Generator/Web/Wizard.php
@@ -65,8 +65,6 @@ class Wizard extends Full
         $di = Di::getDefault();
         $dbconn = $di->get('db_centreon');
         $route = $this->formRoute;
-        /*$baseUrl = rtrim($di->get('config')->get('global', 'base_url'), '/');
-        $route = str_replace($baseUrl, '', $route);*/
 
         $query = "SELECT f.field_id as field_id, w.name as wizard_name, s.name as step_name, 
             s.rank as step_rank, f.mandatory as mandatory,
@@ -77,7 +75,6 @@ class Wizard extends Full
                 AND s.step_id = sf.step_id
                 AND sf.field_id = f.field_id
             ORDER BY s.rank, sf.rank";
-        //echo $query . '<br />' . $route;
         $stmt = $dbconn->prepare($query);
         $stmt->bindParam(':route', $route);
         $stmt->execute();
diff --git a/modules/CentreonConfigurationModule/controllers/ConnectorController.php b/modules/CentreonConfigurationModule/controllers/ConnectorController.php
index 57441032ce..fc406bbad8 100644
--- a/modules/CentreonConfigurationModule/controllers/ConnectorController.php
+++ b/modules/CentreonConfigurationModule/controllers/ConnectorController.php
@@ -60,6 +60,7 @@ class ConnectorController extends FormController
      */
     public function commandsForConnectorAction()
     {
-        parent::getSimpleRelation('connector_id', '\CentreonConfiguration\Models\Command', true);
+        $params = $this->getParams('named');
+        parent::getSimpleRelation('connector_id', '\CentreonConfiguration\Models\Command', $params['id'], true);
     }
 }
diff --git a/modules/CentreonDashboardModule/controllers/DashboardController.php b/modules/CentreonDashboardModule/controllers/DashboardController.php
index 0d19cd986b..63449c2b4f 100644
--- a/modules/CentreonDashboardModule/controllers/DashboardController.php
+++ b/modules/CentreonDashboardModule/controllers/DashboardController.php
@@ -37,6 +37,9 @@ namespace CentreonDashboard\Controllers;
 
 use Centreon\Internal\Controller;
 use CentreonDashboard\Internal\Dashboard;
+use CentreonDashboard\Internal\DashboardContainer;
+use Centreon\Internal\Form\Generator\Web\Wizard;
+use Centreon\Internal\Di;
 
 /**
  * Description of DashboardController
@@ -54,23 +57,58 @@ class DashboardController extends Controller
     /**
      * 
      * @method get
-     * @route /[i:id]?
+     * @route /[i:dashboard]?
      */
     public function mainDashboardAction()
     {
-        $this->tpl->addJs('centreon-dashboard.js', 'bottom', 'centreon-dashboard');
+        $params = $this->getParams();
+        $this->tpl->addCss('block.css', 'centreon-dashboard')
+                    ->addCss('select2.css')
+                    ->addCss('select2-bootstrap.css');
+        $this->tpl->addJs('centreon-dashboard.js', 'bottom', 'centreon-dashboard')
+                    ->addJs('jquery.select2/select2.min.js', 'bottom')
+                    ->addJs('centreon-wizard.js', 'bottom');
+        $this->tpl->assign('baseUrl', Di::getDefault()->get('config')->get('global', 'base_url'));
+        
+        $currentDashboard = 0;
+        if (isset($params['dashboard'])) {
+            $currentDashboard = $params['dashboard'];
+        }
+        
+        $this->tpl->assign('currentDashboard', $currentDashboard);
         $this->display('mainDashboard.tpl');
     }
     
     /**
      * 
      * @method get
-     * @route /container/[a:container]
+     * @route /container/[a:container]/[i:dashboard]?
      */
     public function getContainerAction()
     {
-        $params = $this->getParams('named');
-        var_dump($params);
+        $params = $this->getParams();
+        $container = DashboardContainer::getContainerByName($params['container']);
+        $container->loadDashboards();
+        
+        $dashboardList = $container->getDashboardList(true);
+        if (isset($params['dashboard'])) {
+            $currentDashboard = $params['dashboard'];
+        } else {
+            if (count($dashboardList) > 0) {
+            $currentDashboard = $dashboardList[0]['id'];
+            } else {
+                $currentDashboard = 0;
+            }
+        }
+        
+        $containerParams = array(
+            'template' => $container->render(),
+            'dashboardList' => $dashboardList,
+            'currentDashboard' => $currentDashboard
+        );
+        
+        $this->router->response()->json($containerParams);
+        
     }
 
 
@@ -88,9 +126,29 @@ class DashboardController extends Controller
         }
         
         $myDashboard = new Dashboard($params['id'], false);
-        $this->assignVarToTpl('dashboardLayout', $myDashboard->render());
-        $this->tpl->addJs('centreon-dashboard.js', 'bottom', 'centreon-dashboard');
+        echo $myDashboard->render();
+        /*$this->tpl->addJs('centreon-dashboard.js', 'bottom', 'centreon-dashboard');
         
-        $this->display('dashboardPanel.tpl');
+        $this->display('dashboardPanel.tpl');*/
+    }
+    
+    /**
+     * 
+     */
+    public function displayWidgetSelectionAction()
+    {
+        
+    }
+    
+    /**
+     * 
+     * @method get
+     * @route /dashboard/updatedashboard
+     */
+    public function getDashboardWizardAction()
+    {
+        $myWizard = new Wizard('/centreon-dashboard/dashboard/updatedashboard');
+        $myWizard->getFormFromDatabase();
+        echo $myWizard->generate();
     }
 }
diff --git a/modules/CentreonDashboardModule/controllers/LayoutController.php b/modules/CentreonDashboardModule/controllers/LayoutController.php
new file mode 100644
index 0000000000..c744f71dbb
--- /dev/null
+++ b/modules/CentreonDashboardModule/controllers/LayoutController.php
@@ -0,0 +1,59 @@
+<?php
+
+/*
+ * Copyright 2005-2014 CENTREON
+ * Centreon is developped by : Julien Mathis and Romain Le Merlus under
+ * GPL Licence 2.0.
+ * 
+ * This program is free software; you can redistribute it and/or modify it under 
+ * the terms of the GNU General Public License as published by the Free Software 
+ * Foundation ; either version 2 of the License.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with 
+ * this program; if not, see <http://www.gnu.org/licenses>.
+ * 
+ * Linking this program statically or dynamically with other modules is making a 
+ * combined work based on this program. Thus, the terms and conditions of the GNU 
+ * General Public License cover the whole combination.
+ * 
+ * As a special exception, the copyright holders of this program give CENTREON 
+ * permission to link this program with independent modules to produce an executable, 
+ * regardless of the license terms of these independent modules, and to copy and 
+ * distribute the resulting executable under terms of CENTREON choice, provided that 
+ * CENTREON also meet, for each linked independent module, the terms  and conditions 
+ * of the license of that module. An independent module is a module which is not 
+ * derived from this program. If you modify this program, you may extend this 
+ * exception to your version of the program, but you are not obliged to do so. If you
+ * do not wish to do so, delete this exception statement from your version.
+ * 
+ * For more information : contact@centreon.com
+ * 
+ */
+namespace CentreonDashboard\Controllers;
+
+use Centreon\Internal\Controller;
+use CentreonDashboard\Repository\LayoutRepository;
+
+/**
+ * Description of LayoutController
+ *
+ * @author lionel
+ */
+class LayoutController extends Controller
+{
+    
+    /**
+     * 
+     * @method get
+     * @route /layout/formlist
+     */
+    public function formlistAction()
+    {
+        $requestParams = $this->getParams('get');
+        $this->router->response()->json(LayoutRepository::getFormList($requestParams['q']));
+    }
+}
diff --git a/modules/CentreonDashboardModule/install/datas/centreon.json b/modules/CentreonDashboardModule/install/datas/centreon.json
new file mode 100644
index 0000000000..684a61e513
--- /dev/null
+++ b/modules/CentreonDashboardModule/install/datas/centreon.json
@@ -0,0 +1,5 @@
+[
+    "cfg_dashboards_layouts",
+    "cfg_dashboards_containers",
+    "cfg_dashboards"
+]
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards.json b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards.json
new file mode 100644
index 0000000000..68f88beab3
--- /dev/null
+++ b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards.json
@@ -0,0 +1,10 @@
+[
+    {
+        "dashboard_id": 1,
+        "name": "Default Dashboard",
+        "description": "full",
+        "layout_id": 1,
+        "container_id": 1,
+        "user_id": 1
+    }
+]
diff --git a/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_containers.json b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_containers.json
index f29acaf793..5c495f14c1 100644
--- a/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_containers.json
+++ b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_containers.json
@@ -1,6 +1,7 @@
 [
     {
-        "name": "main-dashboard",
+        "dashboard_container_id": 1,
+        "name": "mainDashboard",
         "mode": "full"
     }
 ]
diff --git a/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_layouts.json b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_layouts.json
new file mode 100644
index 0000000000..78c20f8251
--- /dev/null
+++ b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_layouts.json
@@ -0,0 +1,8 @@
+[
+    {
+        "dashboard_layout_id": 1,
+        "name": "quarter-grid",
+        "description": "Quarter Grid layout",
+        "template": "quarterGrid"
+    }
+]
diff --git a/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards.xml b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards.xml
index dd12c55d77..702943b6f3 100644
--- a/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards.xml
+++ b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards.xml
@@ -6,6 +6,7 @@
         <column name="description" phpName="Description" type="VARCHAR" size="255" required="false"/>
         <column name="user_id" phpName="UserId" type="INTEGER" size="10" sqlType="int(10) unsigned" required="true"/>
         <column name="layout_id" phpName="LayoutId" type="INTEGER" size="10" sqlType="int(10) unsigned" required="false"/>
+        <column name="container_id" phpName="LayoutId" type="INTEGER" size="10" sqlType="int(10) unsigned" required="false"/>
         <unique name="dashboard_name">
             <unique-column name="name"/>
         </unique>
@@ -15,6 +16,9 @@
         <foreign-key foreignTable="cfg_dashboards_layouts" name="dashboard_ibfk_2" onDelete="CASCADE" onUpdate="RESTRICT">
             <reference local="layout_id" foreign="dashboard_layout_id"/>
         </foreign-key>
+        <foreign-key foreignTable="cfg_dashboards_containers" name="dashboard_ibfk_3" onDelete="CASCADE" onUpdate="RESTRICT">
+            <reference local="layout_id" foreign="dashboard_container_id"/>
+        </foreign-key>
         <vendor type="mysql">
             <parameter name="Engine" value="InnoDB"/>
         </vendor>
diff --git a/modules/CentreonDashboardModule/install/forms/Dashboard.xml b/modules/CentreonDashboardModule/install/forms/Dashboard.xml
new file mode 100644
index 0000000000..dfc8fec928
--- /dev/null
+++ b/modules/CentreonDashboardModule/install/forms/Dashboard.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<forms>
+    <form name="dashboard_form">
+        <route>/centreon-dashboard/dashboard/updatedashboard</route>
+        <section name="General">
+            <block name="General information">
+                <field advanced="0" default_value="" label="Name" mandatory="1" name="name" type="text"></field>
+                <field advanced="0" default_value="" label="Description" mandatory="0" name="description" type="text"></field>
+                <field advanced="0" default_value="" label="Layout" mandatory="1" name="layout" type="select">
+                    <attributes>
+						<defaultValuesRoute>/centreon-dashboard/layout/formlist</defaultValuesRoute>
+						<multiple>false</multiple>
+                        <help></help>
+                    </attributes>
+                </field>
+            </block>
+        </section>
+    </form>
+    <wizard name="add_dashboard">
+        <route>/centreon-dashboard/dashboard/updatedashboard</route>
+        <step name="General">
+            <field name="name" mandatory="1"></field>
+            <field name="description" mandatory="0"></field>
+            <field name="layout" mandatory="1"></field>
+        </step>
+    </wizard>
+</forms>
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/internal/Dashboard.php b/modules/CentreonDashboardModule/internal/Dashboard.php
index 9d0cff448c..2907c44898 100644
--- a/modules/CentreonDashboardModule/internal/Dashboard.php
+++ b/modules/CentreonDashboardModule/internal/Dashboard.php
@@ -120,6 +120,24 @@ class Dashboard
         }
     }
     
+    /**
+     * 
+     * @return type
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+    
+    /**
+     * 
+     * @return type
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+    
     /**
      * 
      */
diff --git a/modules/CentreonDashboardModule/internal/Dashboard/Layout.php b/modules/CentreonDashboardModule/internal/Dashboard/Layout.php
index 252e6ab06e..cf29f32f15 100644
--- a/modules/CentreonDashboardModule/internal/Dashboard/Layout.php
+++ b/modules/CentreonDashboardModule/internal/Dashboard/Layout.php
@@ -135,4 +135,10 @@ class Layout
             BlockRepository::add($layoutId, $block);
         }
     }
+    
+    
+    public static function getLayoutList()
+    {
+        
+    }
 }
diff --git a/modules/CentreonDashboardModule/internal/DashboardContainer.php b/modules/CentreonDashboardModule/internal/DashboardContainer.php
new file mode 100644
index 0000000000..7c1964f08e
--- /dev/null
+++ b/modules/CentreonDashboardModule/internal/DashboardContainer.php
@@ -0,0 +1,158 @@
+<?php
+
+/*
+ * Copyright 2005-2014 CENTREON
+ * Centreon is developped by : Julien Mathis and Romain Le Merlus under
+ * GPL Licence 2.0.
+ * 
+ * This program is free software; you can redistribute it and/or modify it under 
+ * the terms of the GNU General Public License as published by the Free Software 
+ * Foundation ; either version 2 of the License.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with 
+ * this program; if not, see <http://www.gnu.org/licenses>.
+ * 
+ * Linking this program statically or dynamically with other modules is making a 
+ * combined work based on this program. Thus, the terms and conditions of the GNU 
+ * General Public License cover the whole combination.
+ * 
+ * As a special exception, the copyright holders of this program give CENTREON 
+ * permission to link this program with independent modules to produce an executable, 
+ * regardless of the license terms of these independent modules, and to copy and 
+ * distribute the resulting executable under terms of CENTREON choice, provided that 
+ * CENTREON also meet, for each linked independent module, the terms  and conditions 
+ * of the license of that module. An independent module is a module which is not 
+ * derived from this program. If you modify this program, you may extend this 
+ * exception to your version of the program, but you are not obliged to do so. If you
+ * do not wish to do so, delete this exception statement from your version.
+ * 
+ * For more information : contact@centreon.com
+ * 
+ */
+
+namespace CentreonDashboard\Internal;
+
+use CentreonDashboard\Models\Dashboard as DashboardModel;
+use CentreonDashboard\Models\Dashboardcontainer as DashboardContainerModel;
+use Centreon\Internal\Template;
+
+/**
+ * Description of DashboardContainer
+ *
+ * @author lionel
+ */
+class DashboardContainer
+{
+    /**
+     *
+     * @var type 
+     */
+    private $id;
+    
+    /**
+     *
+     * @var type 
+     */
+    private $name;
+    
+    /**
+     *
+     * @var type 
+     */
+    private $mode;
+    
+    /**
+     *
+     * @var type 
+     */
+    private $dashboards;
+    
+    /**
+     * 
+     * @param type $id
+     * @param type $name
+     * @param type $mode
+     */
+    public function __construct($id, $name, $mode = 'full')
+    {
+        $this->id = $id;
+        $this->name = $name;
+        $this->mode = $mode;
+        $this->dashboards = array();
+    }
+    
+    /**
+     * 
+     */
+    public function loadDashboards()
+    {
+        $dashboardList = DashboardModel::getList('dashboard_id', -1, 0, null, 'ASC', array('container_id' => $this->id));
+        foreach ($dashboardList as $dashboard) {
+            $this->dashboards[] = new Dashboard($dashboard['dashboard_id'], false);
+        }
+    }
+    
+    /**
+     * 
+     * @param boolean $onlyName
+     */
+    public function getDashboardList($onlyName = false)
+    {
+        $finalList = array();
+        if ($onlyName) {
+            foreach ($this->dashboards as $myDashboard) {
+                $finalList[] = array(
+                    'id' => $myDashboard->getId(),
+                    'name' => $myDashboard->getName()
+                );
+            }
+        } else {
+            $finalList = $this->dashboards;
+        }
+        
+        return $finalList;
+    }
+    
+    /**
+     * 
+     * @return type
+     */
+    public function render()
+    {
+        $origin = 'file:[CentreonDashboardModule]';
+        if ($this->mode == 'light') {
+            $origin .= 'container-light.tpl/';
+        } elseif ($this->mode == 'full') {
+            $origin .= 'container-full.tpl/';
+        }
+        $containerTpl = new Template($origin);
+        
+        return $containerTpl->fetch($origin);
+    }
+    
+    /**
+     * 
+     * @param string $containerName
+     * @return \CentreonDashboard\Internal\DashboardContainer
+     */
+    public static function getContainerByName($containerName)
+    {
+        $id = DashboardContainerModel::getIdByParameter('name', $containerName);
+        return self::getContainerById($id[0]);
+    }
+    
+    /**
+     * 
+     * @param integer $id
+     * @return \CentreonDashboard\Internal\DashboardContainer
+     */
+    public static function getContainerById($id)
+    {
+        $containerDatas = DashboardContainerModel::get($id);
+        return new DashboardContainer($id, $containerDatas['name'], $containerDatas['mode']);
+    }
+}
diff --git a/modules/CentreonDashboardModule/models/Dashboardcontainer.php b/modules/CentreonDashboardModule/models/Dashboardcontainer.php
new file mode 100644
index 0000000000..08de5b575c
--- /dev/null
+++ b/modules/CentreonDashboardModule/models/Dashboardcontainer.php
@@ -0,0 +1,51 @@
+<?php
+
+/*
+ * Copyright 2005-2014 CENTREON
+ * Centreon is developped by : Julien Mathis and Romain Le Merlus under
+ * GPL Licence 2.0.
+ * 
+ * This program is free software; you can redistribute it and/or modify it under 
+ * the terms of the GNU General Public License as published by the Free Software 
+ * Foundation ; either version 2 of the License.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with 
+ * this program; if not, see <http://www.gnu.org/licenses>.
+ * 
+ * Linking this program statically or dynamically with other modules is making a 
+ * combined work based on this program. Thus, the terms and conditions of the GNU 
+ * General Public License cover the whole combination.
+ * 
+ * As a special exception, the copyright holders of this program give CENTREON 
+ * permission to link this program with independent modules to produce an executable, 
+ * regardless of the license terms of these independent modules, and to copy and 
+ * distribute the resulting executable under terms of CENTREON choice, provided that 
+ * CENTREON also meet, for each linked independent module, the terms  and conditions 
+ * of the license of that module. An independent module is a module which is not 
+ * derived from this program. If you modify this program, you may extend this 
+ * exception to your version of the program, but you are not obliged to do so. If you
+ * do not wish to do so, delete this exception statement from your version.
+ * 
+ * For more information : contact@centreon.com
+ * 
+ */
+
+namespace CentreonDashboard\Models;
+
+use Centreon\Models\CentreonBaseModel;
+
+/**
+ * Model for Dasboard
+ *
+ * @author Lionel Assepo <lassepo@centreon.com>
+ */
+class Dashboardcontainer extends CentreonBaseModel
+{
+    protected static $table = "cfg_dashboards_containers";
+    protected static $primaryKey = "dashboard_container_id";
+    protected static $uniqueLabelField = "name";
+}
diff --git a/modules/CentreonDashboardModule/repositories/LayoutRepository.php b/modules/CentreonDashboardModule/repositories/LayoutRepository.php
index 13a98fe977..3e3fb90209 100644
--- a/modules/CentreonDashboardModule/repositories/LayoutRepository.php
+++ b/modules/CentreonDashboardModule/repositories/LayoutRepository.php
@@ -54,4 +54,30 @@ class LayoutRepository
         $layoutId = Layout::insert($layoutParams);
         return $layoutId;
     }
+    
+    /**
+     * Get list of objects
+     *
+     * @param string $searchStr
+     * @return array
+     */
+    public static function getFormList($searchStr = "")
+    {
+
+        $idField = Layout::getPrimaryKey();
+        $uniqueField = Layout::getUniqueLabelField();
+        $filters = array(
+            $uniqueField => '%'.$searchStr.'%'
+        );
+
+        $list = Layout::getList(array($idField, $uniqueField), -1, 0, null, "ASC", $filters, "AND");
+        $finalList = array();
+        foreach ($list as $obj) {
+            $finalList[] = array(
+                "id" => $obj[$idField],
+                "text" => $obj[$uniqueField]
+            );
+        }
+        return $finalList;
+    }
 }
diff --git a/modules/CentreonDashboardModule/static/centreon-dashboard/css/block.css b/modules/CentreonDashboardModule/static/centreon-dashboard/css/block.css
new file mode 100644
index 0000000000..d5c779c507
--- /dev/null
+++ b/modules/CentreonDashboardModule/static/centreon-dashboard/css/block.css
@@ -0,0 +1,18 @@
+.centreon-dashboard-block {
+    border-style: solid;
+    border-width: 1px;
+    border-color: black;
+    height: 25%;
+}
+
+#dashboardList {
+    height: 20%;
+}
+
+#dashboardBody {
+    height: 80%;
+}
+
+#mainDashboard {
+    height: 100%;
+}
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/static/centreon-dashboard/css/geoGrid.css b/modules/CentreonDashboardModule/static/centreon-dashboard/css/geoGrid.css
new file mode 100644
index 0000000000..bcdcf71ac4
--- /dev/null
+++ b/modules/CentreonDashboardModule/static/centreon-dashboard/css/geoGrid.css
@@ -0,0 +1,11 @@
+.geo-grid-left-block {
+    
+}
+
+.geo-grid-right-section {
+    
+}
+
+.geo-grid-right-block {
+    
+}
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/static/centreon-dashboard/js/centreon-dashboard.js b/modules/CentreonDashboardModule/static/centreon-dashboard/js/centreon-dashboard.js
index b5373c3336..7695ae38cc 100644
--- a/modules/CentreonDashboardModule/static/centreon-dashboard/js/centreon-dashboard.js
+++ b/modules/CentreonDashboardModule/static/centreon-dashboard/js/centreon-dashboard.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2014 CENTREON
+ * Copyright 2005-2015 CENTREON
  * Centreon is developped by : Julien Mathis and Romain Le Merlus under
  * GPL Licence 2.0.
  * 
@@ -35,20 +35,84 @@
     
     $.fn.centreonDashboard = function(options) {
         
+        var $dashboardContainer = $(this);
+        
         // Define defaults settings for the dashboard
         var settings = $.extend({
-            mode: "full"
+            mode: "full",
+            currentDashboard: 0
         }, options );
         
-        
-        
         // Get Dashboard Container
         $.ajax({
-            url: encodeURI('/centreon-dashboard/container/' + options.container)
+            url: encodeURI(settings.baseUrl + '/centreon-dashboard/container/' + options.container)
+        }).done(function(data) {
+            loadContainer(this, settings, $dashboardContainer, data);
         });
         
-        
         return this;
     };
     
+    function loadContainer(obj, settings, dashboardContainer, data) {
+        dashboardContainer.html(data.template);
+        
+        $('#dashboard_add').on('click', function(event) {
+            console.log('detected');
+            $('#modal').removeData('bs.modal');
+            $('#modal').removeData('centreonWizard');
+            $('#modal .modal-content').text('');
+            $('#modal').one('loaded.bs.modal', function(e) {
+                $(this).centreonWizard();
+            });
+            $('#modal').modal({
+                remote: encodeURI(settings.baseUrl + '/centreon-dashboard/dashboard/updatedashboard')
+            });
+        });
+        
+        $('#dashboard_settings').on('click', function(event) {
+            console.log('Display Dashboard Settings');
+        });
+        
+        $('#dashboard_delete').on('click', function(event) {
+            console.log('Delete Dashboard');
+        });
+        
+        $('#dashboard_default').on('click', function(event) {
+            console.log('Set Dashboard As Default');
+        });
+        
+        $('#dashboard_default').on('click', function(event) {
+            console.log('Set Dashboard As Default');
+        });
+        
+        buildDashboardSelector(obj, settings, data.dashboardList);
+        
+        var currentDashboard;
+        if (settings.currentDashboard > 0) {
+            currentDashboard = settings.currentDashboard;
+        } else if (data.currentDashboard > 0) {
+            currentDashboard = data.currentDashboard;
+        }
+        loadDashboard(obj, settings, currentDashboard);
+    };
+    
+    function loadDashboard(obj, settings, dashboardId) {
+        var $dashboardBody = $('#dashboardBody');
+        $dashboardBody.empty();
+        
+        // Get Dashboard
+        $.ajax({
+            url: encodeURI(settings.baseUrl + '/centreon-dashboard/dashboard/' + dashboardId)
+        }).done(function(data) {
+            $dashboardBody.html(data);
+        });
+    };
+    
+    function buildDashboardSelector(obj, settings, dashboardList) {
+        var $dashboardSelector = $('#dashboardSelector');
+        $.each(dashboardList, function(key, value) {
+            $dashboardSelector.append('<option value="'+ value.id +'">' + value.name + '</option>');
+        });
+    };
+        
 }(jQuery));
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/views/container-full.tpl b/modules/CentreonDashboardModule/views/container-full.tpl
new file mode 100644
index 0000000000..b007cf2595
--- /dev/null
+++ b/modules/CentreonDashboardModule/views/container-full.tpl
@@ -0,0 +1,41 @@
+<div class="first-content">
+    <div class="btn-group custom-view-actions">
+        <select id="dashboardSelector" name="aa">
+            <option value="none">Select Dashboard</option>
+        </select>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_add">
+            <span class="fa fa-plus"> {t}New{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_settings">
+            <span class="fa fa-gears"> {t}Settings{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_delete">
+            <span class="fa fa-trash-o"> {t}Delete{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_default">
+            <span class="fa fa-star"> {t}Set default{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_bookmark">
+            <span class="fa fa-tag"> {t}Bookmark{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_widget">
+            <span class="fa fa-plus"> {t}Add widget{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_rotation">
+            <span class="fa fa-play"> {t}Rotation{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_filters">
+            <span class="fa fa-search"> {t}Filters{/t}</span>
+        </button>
+        <button type="button" class="btn btn-default btn-sm" id="dashboard_save">
+            <span class="fa fa-save"> {t}Save{/t}</span>
+        </button>
+    </div>
+</div>
+<div id="dashboardBody"></div>
+<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="wizard" aria-hidden="true">
+  <div class="modal-dialog modal-lg">
+    <div class="modal-content">
+    </div>
+  </div>
+</div>
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/views/container-light.tpl b/modules/CentreonDashboardModule/views/container-light.tpl
new file mode 100644
index 0000000000..f93b4e18b5
--- /dev/null
+++ b/modules/CentreonDashboardModule/views/container-light.tpl
@@ -0,0 +1,2 @@
+<div id="dashboardList"></div>
+<div id="dashboardBody"></div>
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/views/dashboardLayouts/geoGrid.tpl b/modules/CentreonDashboardModule/views/dashboardLayouts/geoGrid.tpl
new file mode 100644
index 0000000000..35509a1358
--- /dev/null
+++ b/modules/CentreonDashboardModule/views/dashboardLayouts/geoGrid.tpl
@@ -0,0 +1,5 @@
+<iframe class="geo-grid-left-block col-md-6"></iframe>
+<div class="geo-grid-right-section col-md-6">
+    <iframe class="geo-grid-right-block col-md-12"></iframe>
+    <iframe class="geo-grid-right-block col-md-12"></iframe>
+</div>
diff --git a/modules/CentreonDashboardModule/views/dashboardLayouts/quarterGrid.tpl b/modules/CentreonDashboardModule/views/dashboardLayouts/quarterGrid.tpl
index 4d87475950..9f54251d4d 100644
--- a/modules/CentreonDashboardModule/views/dashboardLayouts/quarterGrid.tpl
+++ b/modules/CentreonDashboardModule/views/dashboardLayouts/quarterGrid.tpl
@@ -1,26 +1,24 @@
-<div id="quarter-grid-layout">
-    <div data-row-index="1">
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-1"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-2"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-3"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-4"></div>
-    </div>
-    <div data-row-index="2">
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-5"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-6"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-7"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-8"></div>
-    </div>
-    <div data-row-index="3">
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-9"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-10"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-11"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-12"></div>
-    </div>
-    <div data-row-index="4">
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-13"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-14"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-15"></div>
-        <div class="centreon-dashboard-block col-md-3" data-block-slug="qg-block-16"></div>
-    </div>
+<div class="row" data-row-index="1">
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-1" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-2" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-3" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-4" src=""></iframe>
+</div>
+<div class="row" data-row-index="2">
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-5" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-6" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-7" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-8" src=""></iframe>
+</div>
+<div class="row" data-row-index="3">
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-9" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-10" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-11" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-12" src=""></iframe>
+</div>
+<div class="row" data-row-index="4">
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-13" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-14" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-15" src=""></iframe>
+    <iframe class="centreon-dashboard-block col-md-3 col-lg-3" data-block-slug="qg-block-16" src=""></iframe>
 </div>
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/views/dashboardLayouts/top-grid.tpl b/modules/CentreonDashboardModule/views/dashboardLayouts/top-grid.tpl
new file mode 100644
index 0000000000..cb63dbbc51
--- /dev/null
+++ b/modules/CentreonDashboardModule/views/dashboardLayouts/top-grid.tpl
@@ -0,0 +1,8 @@
+<div id="top-grid-layout">
+    <div data-row-index="1">
+        <div class="centreon-dashboard-block col-md-3" data-block-slug="tg-block-1"></div>
+        <div class="centreon-dashboard-block col-md-3" data-block-slug="tg-block-2"></div>
+        <div class="centreon-dashboard-block col-md-3" data-block-slug="tg-block-3"></div>
+        <div class="centreon-dashboard-block col-md-3" data-block-slug="tg-block-4"></div>
+    </div>
+</div>
\ No newline at end of file
diff --git a/modules/CentreonDashboardModule/views/mainDashboard.tpl b/modules/CentreonDashboardModule/views/mainDashboard.tpl
index fee3db200a..1c3f216a48 100644
--- a/modules/CentreonDashboardModule/views/mainDashboard.tpl
+++ b/modules/CentreonDashboardModule/views/mainDashboard.tpl
@@ -3,19 +3,16 @@
 {block name="title"}Centreon Dashboard{/block}
 
 {block name="content"}
-    
     <div id="mainDashboard"></div>
-    
-    {*<div id="dashboardToolbar">Dashboard Toolbar</div>
-    <div id="widgetList">Widget List Here</div>
-    <div id="blocks">{$dashboardLayout}</div>*}
 {/block}
 
-{block name="javascript-bottom"}
+{block name="javascript-bottom" append}
     <script>
         $("#mainDashboard").centreonDashboard({
             mode: 'full',
-            container: 'main-dashboard'
+            container: 'mainDashboard',
+            baseUrl: '{$baseUrl}',
+            currentDashboard: '{$currentDashboard}'
         });
     </script>
 {/block}
\ No newline at end of file
diff --git a/modules/CentreonMainModule/controllers/MenuController.php b/modules/CentreonMainModule/controllers/MenuController.php
index e1b31117aa..9d78875de2 100644
--- a/modules/CentreonMainModule/controllers/MenuController.php
+++ b/modules/CentreonMainModule/controllers/MenuController.php
@@ -41,6 +41,17 @@ use Centreon\Internal\Controller;
 
 class MenuController extends Controller
 {
+    /**
+     * Get menu
+     *
+     * @method get
+     * @route /menu/loadmenu
+     */
+    public function menuAction()
+    {
+        $this->loadFullMenu();
+    }
+    
     /**
      * Get menu
      *
-- 
GitLab