diff --git a/core/internal/Install/AbstractInstall.php b/core/internal/Install/AbstractInstall.php index b61ffef49634410400d7617d0e43129dd27fc86b..67dff5ab8c6792dc24e2d4854e311b6cd99c0b70 100644 --- a/core/internal/Install/AbstractInstall.php +++ b/core/internal/Install/AbstractInstall.php @@ -52,8 +52,7 @@ class AbstractInstall 'centreon-administration', 'centreon-configuration', 'centreon-realtime', - 'centreon-customview', - 'centreon-bam', + 'centreon-dashboard' ); /** diff --git a/modules/CentreonDashboardModule/commands/LayoutCommand.php b/modules/CentreonDashboardModule/commands/LayoutCommand.php new file mode 100644 index 0000000000000000000000000000000000000000..9f1c45fe42320ffe33dacb252d834cf429c8ef85 --- /dev/null +++ b/modules/CentreonDashboardModule/commands/LayoutCommand.php @@ -0,0 +1,56 @@ +<?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\Commands; + +use Centreon\Internal\Command\AbstractCommand; +use CentreonDashboard\Internal\Dashboard\Layout; + +/** + * Description of LayoutCommand + * + * @author lionel + */ +class LayoutCommand extends AbstractCommand +{ + /** + * + * @param string $file + */ + public function installAction($file) + { + Layout::installLayouts($file); + } +} diff --git a/modules/CentreonDashboardModule/config/delete.me b/modules/CentreonDashboardModule/config/delete.me new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/modules/CentreonDashboardModule/controllers/DashboardController.php b/modules/CentreonDashboardModule/controllers/DashboardController.php new file mode 100644 index 0000000000000000000000000000000000000000..0d19cd986b0c60b19842b953c0a6f2cdf4228f18 --- /dev/null +++ b/modules/CentreonDashboardModule/controllers/DashboardController.php @@ -0,0 +1,96 @@ +<?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\Internal\Dashboard; + +/** + * Description of DashboardController + * + * @author lionel + */ +class DashboardController extends Controller +{ + /** + * + * @var string + */ + public static $moduleName = 'CentreonDashboard'; + + /** + * + * @method get + * @route /[i:id]? + */ + public function mainDashboardAction() + { + $this->tpl->addJs('centreon-dashboard.js', 'bottom', 'centreon-dashboard'); + $this->display('mainDashboard.tpl'); + } + + /** + * + * @method get + * @route /container/[a:container] + */ + public function getContainerAction() + { + $params = $this->getParams('named'); + var_dump($params); + } + + + /** + * + * @method get + * @route /dashboard/[i:id] + */ + public function displayDashboardAction() + { + $params = $this->getParams('named'); + + if (is_null($params['id'])) { + $params['id'] = 1; + } + + $myDashboard = new Dashboard($params['id'], false); + $this->assignVarToTpl('dashboardLayout', $myDashboard->render()); + $this->tpl->addJs('centreon-dashboard.js', 'bottom', 'centreon-dashboard'); + + $this->display('dashboardPanel.tpl'); + } +} diff --git a/modules/CentreonDashboardModule/dashboard/quarterGrid.json b/modules/CentreonDashboardModule/dashboard/quarterGrid.json new file mode 100644 index 0000000000000000000000000000000000000000..d1eaededb1c2e9e6263b5f143f76510efa723c15 --- /dev/null +++ b/modules/CentreonDashboardModule/dashboard/quarterGrid.json @@ -0,0 +1,88 @@ +{ + "name": "Quarter Grid", + "description": "", + "module": "", + "template": "quarterGrid.json", + "blocks": [ + { + "name": "Block 1", + "description": "", + "slug" : "qg-block-1" + }, + { + "name": "Block 2", + "description": "", + "slug" : "qg-block-2" + }, + { + "name": "Block 3", + "description": "", + "slug" : "qg-block-3" + }, + { + "name": "Block 4", + "description": "", + "slug" : "qg-block-4" + }, + { + "name": "Block 5", + "description": "", + "slug" : "qg-block-5" + }, + { + "name": "Block 6", + "description": "", + "slug" : "qg-block-6" + }, + { + "name": "Block 7", + "description": "", + "slug" : "qg-block-7" + }, + { + "name": "Block 8", + "description": "", + "slug" : "qg-block-8" + }, + { + "name": "Block 9", + "description": "", + "slug" : "qg-block-9" + }, + { + "name": "Block 10", + "description": "", + "slug" : "qg-block-10" + }, + { + "name": "Block 11", + "description": "", + "slug" : "qg-block-11" + }, + { + "name": "Block 12", + "description": "", + "slug" : "qg-block-12" + }, + { + "name": "Block 13", + "description": "", + "slug" : "qg-block-13" + }, + { + "name": "Block 14", + "description": "", + "slug" : "qg-block-14" + }, + { + "name": "Block 15", + "description": "", + "slug" : "qg-block-15" + }, + { + "name": "Block 16", + "description": "", + "slug" : "qg-block-16" + } + ] +} diff --git a/modules/CentreonDashboardModule/dashboard/views/quarterGrid.tpl b/modules/CentreonDashboardModule/dashboard/views/quarterGrid.tpl new file mode 100644 index 0000000000000000000000000000000000000000..07da8dbd81fd72c087de7e382c93e2582bbff99a --- /dev/null +++ b/modules/CentreonDashboardModule/dashboard/views/quarterGrid.tpl @@ -0,0 +1,26 @@ +<div id="quarter-grid-layout"> + <div data-row-index="1"> + <div class="col-md-3" data-block-slug="qg-block-1"></div> + <div class="col-md-3" data-block-slug="qg-block-2"></div> + <div class="col-md-3" data-block-slug="qg-block-3"></div> + <div class="col-md-3" data-block-slug="qg-block-4"></div> + </div> + <div data-row-index="2"> + <div class="col-md-3" data-block-slug="qg-block-5"></div> + <div class="col-md-3" data-block-slug="qg-block-6"></div> + <div class="col-md-3" data-block-slug="qg-block-7"></div> + <div class="col-md-3" data-block-slug="qg-block-8"></div> + </div> + <div data-row-index="3"> + <div class="col-md-3" data-block-slug="qg-block-9"></div> + <div class="col-md-3" data-block-slug="qg-block-10"></div> + <div class="col-md-3" data-block-slug="qg-block-11"></div> + <div class="col-md-3" data-block-slug="qg-block-12"></div> + </div> + <div data-row-index="4"> + <div class="col-md-3" data-block-slug="qg-block-13"></div> + <div class="col-md-3" data-block-slug="qg-block-14"></div> + <div class="col-md-3" data-block-slug="qg-block-15"></div> + <div class="col-md-3" data-block-slug="qg-block-16"></div> + </div> +</div> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/install/Installer.php b/modules/CentreonDashboardModule/install/Installer.php new file mode 100644 index 0000000000000000000000000000000000000000..9eed1ec595486bd645ada26d8eeeebde499ef75d --- /dev/null +++ b/modules/CentreonDashboardModule/install/Installer.php @@ -0,0 +1,78 @@ +<?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\Install; + +use Centreon\Internal\Module\Installer as ModuleInstaller; + +/** + * + */ +class Installer extends ModuleInstaller +{ + /** + * + * @param type $moduleInfo + */ + public function __construct($moduleDirectory, $moduleInfo) + { + parent::__construct($moduleDirectory, $moduleInfo); + } + + /** + * + */ + public function customPreInstall() + { + + } + + /** + * + */ + public function customInstall() + { + + } + + /** + * + */ + public function customRemove() + { + + } +} diff --git a/modules/CentreonDashboardModule/install/config.json b/modules/CentreonDashboardModule/install/config.json new file mode 100644 index 0000000000000000000000000000000000000000..8ceaf266ec48caf05452ab515338b7d770cacd6c --- /dev/null +++ b/modules/CentreonDashboardModule/install/config.json @@ -0,0 +1,28 @@ +{ + "name": "Centreon Dashboard", + "shortname" : "centreon-dashboard", + "version": "3.0.0", + "author" : [ + "Centreon" + ], + "isuninstallable" : false, + "isdisableable" : true, + "url" : "", + "description" : "Centreon Dashboard Module", + "core version" : "3.0.0", + "dependencies" : [ + { + "name" : "centreon-administration", + "version" : "3.0.0" + } + ], + "optionnal dependencies" : [ + + ], + "php module dependencies" : [ + + ], + "program dependencies" : [ + + ] +} diff --git a/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_containers.json b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_containers.json new file mode 100644 index 0000000000000000000000000000000000000000..f29acaf7937eb7963112ab367d8bb6274696012f --- /dev/null +++ b/modules/CentreonDashboardModule/install/datas/centreon/cfg_dashboards_containers.json @@ -0,0 +1,6 @@ +[ + { + "name": "main-dashboard", + "mode": "full" + } +] diff --git a/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards.xml b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards.xml new file mode 100644 index 0000000000000000000000000000000000000000..dd12c55d77855050dba36f1429ca363a4dd2e9c6 --- /dev/null +++ b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<database name="centreon" package="centreon_dashboard" defaultIdMethod="native"> + <table name="cfg_dashboards" phpName="Dashboard" idMethod="native"> + <column name="dashboard_id" phpName="DashboardId" primaryKey="true" type="INTEGER" size="10" sqlType="int(10) unsigned" autoIncrement="true" required="true"/> + <column name="name" phpName="Name" type="VARCHAR" size="255" required="true"/> + <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"/> + <unique name="dashboard_name"> + <unique-column name="name"/> + </unique> + <foreign-key foreignTable="cfg_users" name="dashboard_ibfk_1" onDelete="CASCADE" onUpdate="RESTRICT"> + <reference local="user_id" foreign="user_id"/> + </foreign-key> + <foreign-key foreignTable="cfg_dashboards_layouts" name="dashboard_ibfk_2" onDelete="CASCADE" onUpdate="RESTRICT"> + <reference local="layout_id" foreign="dashboard_layout_id"/> + </foreign-key> + <vendor type="mysql"> + <parameter name="Engine" value="InnoDB"/> + </vendor> + </table> +</database> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_containers.xml b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_containers.xml new file mode 100644 index 0000000000000000000000000000000000000000..298b6dd51c11783dd3a24acc2565ecfbf7780700 --- /dev/null +++ b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_containers.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<database name="centreon" package="centreon_dashboard" defaultIdMethod="native"> + <table name="cfg_dashboards_containers" phpName="DashboardContainer" idMethod="native"> + <column name="dashboard_container_id" phpName="DashboardContainerId" primaryKey="true" type="INTEGER" size="10" sqlType="int(10) unsigned" autoIncrement="true" required="true"/> + <column name="name" phpName="Name" type="VARCHAR" size="255" required="true"/> + <column name="mode" phpName="Mode" type="VARCHAR" size="255" required="false"/> + <unique name="dashboard_name"> + <unique-column name="name"/> + </unique> + <vendor type="mysql"> + <parameter name="Engine" value="InnoDB"/> + </vendor> + </table> +</database> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_elements.xml b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_elements.xml new file mode 100644 index 0000000000000000000000000000000000000000..265f6f6b16fd742e3b5bf134be9989c416a27998 --- /dev/null +++ b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_elements.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<database name="centreon" package="centreon_dashboard" defaultIdMethod="native"> + <table name="cfg_dashboards_elements" phpName="DashboardWidget" idMethod="native"> + <column name="dashboard_element_id" primaryKey="true" phpName="DashboardWidgetId" type="INTEGER" size="10" sqlType="int(10) unsigned" autoIncrement="true" required="true"/> + <column name="dashboard_id" phpName="DashboardId" type="INTEGER" size="10" sqlType="int(10) unsigned" required="true"/> + <column name="widget_id" phpName="WidgetId" type="INTEGER" size="10" sqlType="int(10) unsigned" required="false"/> + <column name="route" phpName="Route" type="VARCHAR" size="255" required="true"/> + <column name="layout_slug" phpName="LayoutSlug" type="VARCHAR" size="255" required="true"/> + <foreign-key foreignTable="cfg_dashboards" name="dashboard_element_ibfk_1" onDelete="CASCADE" onUpdate="RESTRICT"> + <reference local="dashboard_id" foreign="dashboard_id"/> + </foreign-key> + <foreign-key foreignTable="cfg_widgets" name="dashboard_element_ibfk_2" onDelete="CASCADE" onUpdate="RESTRICT"> + <reference local="widget_id" foreign="widget_id"/> + </foreign-key> + <vendor type="mysql"> + <parameter name="Engine" value="InnoDB"/> + </vendor> + </table> +</database> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_layouts.xml b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_layouts.xml new file mode 100644 index 0000000000000000000000000000000000000000..5a6f7ce1c29734ffe3ca7f5b1f710c587e4873eb --- /dev/null +++ b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_layouts.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<database name="centreon" package="centreon_dashboard" defaultIdMethod="native"> + <table name="cfg_dashboards_layouts" phpName="DashboardLayout" idMethod="native"> + <column name="dashboard_layout_id" phpName="DashboardLayoutId" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" autoIncrement="true" required="true"/> + <column name="name" phpName="Name" type="VARCHAR" size="255" required="true"/> + <column name="description" phpName="Description" type="VARCHAR" size="255" required="false"/> + <column name="template" phpName="Template" type="VARCHAR" size="255" required="true"/> + <vendor type="mysql"> + <parameter name="Engine" value="InnoDB"/> + </vendor> + </table> +</database> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_layouts_blocks.xml b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_layouts_blocks.xml new file mode 100644 index 0000000000000000000000000000000000000000..bb9f4c74e26c3ca1e416b5f2d78302d33dc64e9b --- /dev/null +++ b/modules/CentreonDashboardModule/install/db/centreon/cfg_dashboards_layouts_blocks.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<database name="centreon" package="centreon_dashboard" defaultIdMethod="native"> + <table name="cfg_dashboards_layouts_blocks" phpName="DashboardLayoutBlock" idMethod="native"> + <column name="dashboard_layout_block_id" phpName="DashboardLayoutBlockId" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" autoIncrement="true" required="true"/> + <column name="name" phpName="Name" type="VARCHAR" size="255" required="true"/> + <column name="description" phpName="Description" type="VARCHAR" size="255" required="false"/> + <column name="slug" phpName="Slug" type="VARCHAR" size="255" required="true"/> + <vendor type="mysql"> + <parameter name="Engine" value="InnoDB"/> + </vendor> + </table> +</database> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/install/db/centreon/cfg_widgets.xml b/modules/CentreonDashboardModule/install/db/centreon/cfg_widgets.xml new file mode 100644 index 0000000000000000000000000000000000000000..bd549a195ec2c2d7b0b78c2aec52d8aff055fc51 --- /dev/null +++ b/modules/CentreonDashboardModule/install/db/centreon/cfg_widgets.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<database name="centreon" package="centreon_dashboard" defaultIdMethod="native"> + <table name="cfg_widgets" phpName="Widget" idMethod="native"> + <column name="widget_id" phpName="WidgetId" primaryKey="true" type="INTEGER" size="10" sqlType="int(10) unsigned" autoIncrement="true" required="true"/> + <column name="name" phpName="Name" type="VARCHAR" size="255" required="true"/> + <column name="description" phpName="Description" type="VARCHAR" size="255" required="false"/> + <unique name="widget_name"> + <unique-column name="name"/> + </unique> + <vendor type="mysql"> + <parameter name="Engine" value="InnoDB"/> + </vendor> + </table> +</database> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/install/menu.json b/modules/CentreonDashboardModule/install/menu.json new file mode 100644 index 0000000000000000000000000000000000000000..d3fbd91afae01da5d9cf75661afd3cf1d9e975d7 --- /dev/null +++ b/modules/CentreonDashboardModule/install/menu.json @@ -0,0 +1,27 @@ +[ + { + "name": "Home", + "short_name": "home", + "icon_class": "fa fa-home", + "bgcolor": "#CCC", + "menus": [ + { + "name": "Home page", + "short_name": "dashboards", + "icon_class": "fa fa-home", + "route": "/centreon-dashboard" + } + ] + }, + { + "name": "Extensions", + "short_name": "extensions", + "menus": [ + { + "name": "Widgets", + "short_name": "adminwidgets", + "route": "/centreon-dashboard/extensions/widgets" + } + ] + } +] diff --git a/modules/CentreonDashboardModule/internal/Dashboard.php b/modules/CentreonDashboardModule/internal/Dashboard.php new file mode 100644 index 0000000000000000000000000000000000000000..9d0cff448c43ac2eaad32bb77c5a3bde51e091ed --- /dev/null +++ b/modules/CentreonDashboardModule/internal/Dashboard.php @@ -0,0 +1,130 @@ +<?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 CentreonAdministration\Models\User; +use CentreonDashboard\Internal\Dashboard\Layout; +use CentreonDashboard\Internal\Dashboard\ElementCollection; +use CentreonDashboard\Internal\Dashboard\Renderer; + +/** + * Description of Dashboard + * + * @author lionel + */ +class Dashboard +{ + /** + * + * @var integer + */ + private $id; + + /** + * + * @var string + */ + private $name; + + /** + * + * @var string + */ + private $description; + + /** + * + * @var type + */ + private $user; + + /** + * + * @var type + */ + private $layout; + + /** + * + * @var type + */ + private $elements; + + /** + * + * @var type + */ + private $renderer; + + /** + * + * @param type $id + * @param type $lazy + */ + public function __construct($id, $lazy = true) + { + $this->id = $id; + $dashboardDatas = DashboardModel::get($this->id); + $this->name = $dashboardDatas['name']; + $this->description = $dashboardDatas['description']; + + if ($lazy) { + $this->user = $dashboardDatas['user_id']; + $this->layout = $dashboardDatas['user_id']; + } else { + $this->user = User::get($dashboardDatas['user_id']); + if (!is_null($dashboardDatas['layout_id'])) { + $this->layout = new Layout($dashboardDatas['layout_id']); + } + } + + $this->elements = new ElementCollection($id); + + if (!is_null($this->layout)) { + $this->renderer = new Renderer($this->layout->getTemplate()); + } + } + + /** + * + */ + public function render() + { + return $this->renderer->renderFinal(); + } +} diff --git a/modules/CentreonDashboardModule/internal/Dashboard/Element.php b/modules/CentreonDashboardModule/internal/Dashboard/Element.php new file mode 100644 index 0000000000000000000000000000000000000000..318ae4f6496e4d6efbeacab9ba02f9b25b5ab818 --- /dev/null +++ b/modules/CentreonDashboardModule/internal/Dashboard/Element.php @@ -0,0 +1,93 @@ +<?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\Dashboard; + +/** + * Description of Element + * + * @author lionel + */ +class Element +{ + /** + * + * @var type + */ + private $id; + + /** + * + * @var type + */ + private $dashboardId; + + /** + * + * @var type + */ + private $widgetId; + + /** + * + * @var type + */ + private $layoutSlug; + + /** + * + * @var type + */ + private $route; + + /** + * + * @param type $id + * @param type $layoutSlug + * @param type $route + * @param type $dashboardId + * @param type $widgetId + */ + public function __construct($id, $layoutSlug = '', $route = '', $dashboardId = null, $widgetId = null) + { + $this->id = $id; + $this->layoutSlug = $layoutSlug; + $this->dashboardId = $dashboardId; + $this->widgetId = $widgetId; + $this->route = $route; + } + + +} diff --git a/modules/CentreonDashboardModule/internal/Dashboard/ElementCollection.php b/modules/CentreonDashboardModule/internal/Dashboard/ElementCollection.php new file mode 100644 index 0000000000000000000000000000000000000000..457eb1014a53c438de8d1d415f2fde4c4ab79faa --- /dev/null +++ b/modules/CentreonDashboardModule/internal/Dashboard/ElementCollection.php @@ -0,0 +1,116 @@ +<?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\Dashboard; + +use CentreonDashboard\Internal\Dashboard\Element; +use CentreonDashboard\Models\Dashboardelement; + +/** + * Description of ElementCollection + * + * @author lionel + */ +class ElementCollection +{ + /** + * + * @var array + */ + private $items = array(); + + /** + * + * @param type $dashboardId + */ + public function __construct($dashboardId = null) + { + if (!is_null($dashboardId)) { + $this->load($dashboardId); + } + } + + /** + * + * @param Element $element + * @param type $key + */ + public function addItem(Element $element, $key = null) + { + if (is_null($key)) { + $this->items[] = $element; + } else { + $this->items[$key] = $element; + } + } + + /** + * + * @param integer $key + */ + public function deleteItem($key) + { + unset($this->items[$key]); + } + + /** + * + * @param integer $key + */ + public function getItem($key) + { + + return $this->items[$key]; + } + + /** + * + * @param type $dashboardId + */ + public function load($dashboardId) + { + $listOfElements = Dashboardelement::getList('*', -1, 0, null, 'ASC', array('dashboard_id' => $dashboardId)); + foreach ($listOfElements as $element) { + $newElement = new Element( + $element['dashboard_element_id'], + $element['layout_slug'], + $element['route'], + $dashboardId, + $element['widget_id'] + ); + $this->addItem($newElement); + } + } +} diff --git a/modules/CentreonDashboardModule/internal/Dashboard/Layout.php b/modules/CentreonDashboardModule/internal/Dashboard/Layout.php new file mode 100644 index 0000000000000000000000000000000000000000..252e6ab06ea43e1a77ffe07bdd3363d481ec20f6 --- /dev/null +++ b/modules/CentreonDashboardModule/internal/Dashboard/Layout.php @@ -0,0 +1,138 @@ +<?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\Dashboard; + +use CentreonDashboard\Models\Dashboardlayout; +use CentreonDashboard\Repository\LayoutRepository; +use CentreonDashboard\Repository\BlockRepository; + +/** + * Description of Layout + * + * @author lionel + */ +class Layout +{ + /** + * + * @var type + */ + private $id; + + /** + * + * @var type + */ + private $name; + + /** + * + * @var type + */ + private $description; + + /** + * + * @var type + */ + private $template; + + /** + * + * @var type + */ + private $blocks; + + /** + * + * @param type $id + */ + public function __construct($id) + { + $this->id = $id; + $layoutDatas = Dashboardlayout::get($id); + $this->name = $layoutDatas['name']; + $this->description = $layoutDatas['description']; + $this->template = $layoutDatas['template']; + } + + /** + * + * @return type + */ + public function getName() + { + return $this->name; + } + + /** + * + * @return type + */ + public function getTemplate() + { + return $this->template; + } + + + /** + * + */ + private function loadBlocks() + { + + } + + /** + * + * @param type $layoutFile + */ + public static function installLayouts($layoutFile) + { + $layoutContent = json_decode(file_get_contents($layoutFile), true); + $layoutParams = array( + 'name' => $layoutContent['name'], + 'description' => $layoutContent['description'], + 'template' => $layoutContent['template'], + ); + + $layoutId = LayoutRepository::add($layoutParams); + + foreach ($layoutContent['blocks'] as $block) { + BlockRepository::add($layoutId, $block); + } + } +} diff --git a/modules/CentreonDashboardModule/internal/Dashboard/Renderer.php b/modules/CentreonDashboardModule/internal/Dashboard/Renderer.php new file mode 100644 index 0000000000000000000000000000000000000000..b8550de75a77cdf5f06e37cb05a4a8d5d12bf392 --- /dev/null +++ b/modules/CentreonDashboardModule/internal/Dashboard/Renderer.php @@ -0,0 +1,87 @@ +<?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\Dashboard; + +use Centreon\Internal\Template; + +/** + * Description of Renderer + * + * @author lionel + */ +class Renderer +{ + /** + * + * @var type + */ + private $tplRenderer; + + /** + * + * @var type + */ + private $templateFile; + + /** + * + * @param string $templateFile + */ + public function __construct($templateFile = null) + { + if (!is_null($templateFile)) { + $origin = 'file:[CentreonDashboardModule]dashboardLayouts/'; + $this->templateFile = $origin . $templateFile; + $this->tplRenderer = new Template($this->templateFile); + } + } + + public function setTemplate($templateFile) + { + $origin = 'file:[CentreonDashboardModule]dashboardLayouts/'; + $this->templateFile = $origin . $templateFile; + $this->tplRenderer = new Template($this->templateFile); + } + + /** + * + * @return string + */ + public function renderFinal() + { + return $this->tplRenderer->fetch($this->templateFile); + } +} diff --git a/modules/CentreonDashboardModule/models/Dashboard.php b/modules/CentreonDashboardModule/models/Dashboard.php new file mode 100644 index 0000000000000000000000000000000000000000..9c59064026007fe71f2e6e81097253cb662f5146 --- /dev/null +++ b/modules/CentreonDashboardModule/models/Dashboard.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 Dashboard extends CentreonBaseModel +{ + protected static $table = "cfg_dashboards"; + protected static $primaryKey = "dashboard_id"; + protected static $uniqueLabelField = "name"; +} diff --git a/modules/CentreonDashboardModule/models/Dashboardelement.php b/modules/CentreonDashboardModule/models/Dashboardelement.php new file mode 100644 index 0000000000000000000000000000000000000000..371a2f55b658989961447f7d2151e2c7884b8e94 --- /dev/null +++ b/modules/CentreonDashboardModule/models/Dashboardelement.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 Element + * + * @author Lionel Assepo <lassepo@centreon.com> + */ +class Dashboardelement extends CentreonBaseModel +{ + protected static $table = "cfg_dashboards_elements"; + protected static $primaryKey = "dashboard_element_id"; + protected static $uniqueLabelField = "name"; +} diff --git a/modules/CentreonDashboardModule/models/Dashboardlayout.php b/modules/CentreonDashboardModule/models/Dashboardlayout.php new file mode 100644 index 0000000000000000000000000000000000000000..b4ef587a4841598517ff8dbb4174bb53583d480d --- /dev/null +++ b/modules/CentreonDashboardModule/models/Dashboardlayout.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 Layout + * + * @author Lionel Assepo <lassepo@centreon.com> + */ +class Dashboardlayout extends CentreonBaseModel +{ + protected static $table = "cfg_dashboards_layouts"; + protected static $primaryKey = "dashboard_layout_id"; + protected static $uniqueLabelField = "name"; +} diff --git a/modules/CentreonDashboardModule/models/Dashboardlayoutblock.php b/modules/CentreonDashboardModule/models/Dashboardlayoutblock.php new file mode 100644 index 0000000000000000000000000000000000000000..8cf6992d2b311f8703bc7b904588dc1a741e81cf --- /dev/null +++ b/modules/CentreonDashboardModule/models/Dashboardlayoutblock.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 Layout block + * + * @author Lionel Assepo <lassepo@centreon.com> + */ +class Dashboardlayoutblock extends CentreonBaseModel +{ + protected static $table = "cfg_dashboards_layouts_blocks"; + protected static $primaryKey = "dashboard_layout_block_id"; + protected static $uniqueLabelField = "name"; +} diff --git a/modules/CentreonDashboardModule/models/Widget.php b/modules/CentreonDashboardModule/models/Widget.php new file mode 100644 index 0000000000000000000000000000000000000000..b94bdff39490f15ce589820664a2a3b088c7be83 --- /dev/null +++ b/modules/CentreonDashboardModule/models/Widget.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 Widget extends CentreonBaseModel +{ + protected static $table = "cfg_widgets"; + protected static $primaryKey = "widget_id"; + protected static $uniqueLabelField = "name"; +} diff --git a/modules/CentreonDashboardModule/repositories/BlockRepository.php b/modules/CentreonDashboardModule/repositories/BlockRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..95b3adf407c3a2bc46bfbb62723f5e128a951c2f --- /dev/null +++ b/modules/CentreonDashboardModule/repositories/BlockRepository.php @@ -0,0 +1,57 @@ +<?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\Repository; + +use CentreonDashboard\Models\Dashboardlayoutblock as Block; + +/** + * Description of BlockRepository + * + * @author lionel + */ +class BlockRepository +{ + /** + * + * @param type $layoutId + * @param array $blockParams + */ + public static function add($layoutId, $blockParams) + { + $blockParams['dashboard_layout_block_id'] = $layoutId; + Block::insert($blockParams); + } +} diff --git a/modules/CentreonDashboardModule/repositories/LayoutRepository.php b/modules/CentreonDashboardModule/repositories/LayoutRepository.php new file mode 100644 index 0000000000000000000000000000000000000000..13a98fe97717eb2261689eb7961f9f8be26bd826 --- /dev/null +++ b/modules/CentreonDashboardModule/repositories/LayoutRepository.php @@ -0,0 +1,57 @@ +<?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\Repository; + +use CentreonDashboard\Models\Dashboardlayout as Layout; + +/** + * Description of LayoutRepository + * + * @author lionel + */ +class LayoutRepository +{ + /** + * + * @param array $layoutParams + * @return integer + */ + public static function add($layoutParams) + { + $layoutId = Layout::insert($layoutParams); + return $layoutId; + } +} diff --git a/modules/CentreonDashboardModule/static/centreon-dashboard/js/centreon-dashboard.js b/modules/CentreonDashboardModule/static/centreon-dashboard/js/centreon-dashboard.js new file mode 100644 index 0000000000000000000000000000000000000000..b5373c3336798430521740c01748322c715d57b9 --- /dev/null +++ b/modules/CentreonDashboardModule/static/centreon-dashboard/js/centreon-dashboard.js @@ -0,0 +1,54 @@ +/* + * 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 + * + */ +(function($){ + + $.fn.centreonDashboard = function(options) { + + // Define defaults settings for the dashboard + var settings = $.extend({ + mode: "full" + }, options ); + + + + // Get Dashboard Container + $.ajax({ + url: encodeURI('/centreon-dashboard/container/' + options.container) + }); + + + return this; + }; + +}(jQuery)); \ No newline at end of file diff --git a/modules/CentreonDashboardModule/views/dashboardLayouts/quarterGrid.tpl b/modules/CentreonDashboardModule/views/dashboardLayouts/quarterGrid.tpl new file mode 100644 index 0000000000000000000000000000000000000000..4d87475950c9cc01d4d739a571b1f76f9360209f --- /dev/null +++ b/modules/CentreonDashboardModule/views/dashboardLayouts/quarterGrid.tpl @@ -0,0 +1,26 @@ +<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> \ No newline at end of file diff --git a/modules/CentreonDashboardModule/views/dashboardPanel.tpl b/modules/CentreonDashboardModule/views/dashboardPanel.tpl new file mode 100644 index 0000000000000000000000000000000000000000..3c528282c973b5991d289bdfc0a99a7431b90d59 --- /dev/null +++ b/modules/CentreonDashboardModule/views/dashboardPanel.tpl @@ -0,0 +1,21 @@ +{extends file="file:[Core]viewLayout.tpl"} + +{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"} + <script> + $("#mainDashboard").centreonDashboard({ + mode: 'full', + containerId: 1 + }); + </script> +{/block} \ No newline at end of file diff --git a/modules/CentreonDashboardModule/views/mainDashboard.tpl b/modules/CentreonDashboardModule/views/mainDashboard.tpl new file mode 100644 index 0000000000000000000000000000000000000000..fee3db200a91120aebbfcc338d74c3dac45464f9 --- /dev/null +++ b/modules/CentreonDashboardModule/views/mainDashboard.tpl @@ -0,0 +1,21 @@ +{extends file="file:[Core]viewLayout.tpl"} + +{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"} + <script> + $("#mainDashboard").centreonDashboard({ + mode: 'full', + container: 'main-dashboard' + }); + </script> +{/block} \ No newline at end of file