diff --git a/src/Glpi/Dashboard/Grid.php b/src/Glpi/Dashboard/Grid.php index a850e7cfde1..120389378eb 100644 --- a/src/Glpi/Dashboard/Grid.php +++ b/src/Glpi/Dashboard/Grid.php @@ -421,64 +421,66 @@ public function show(bool $mini = false, ?string $token = null) TWIG, $params); } - // display the grid - $html = << - - $toolbars - $filters - $grid_guide -
- $gridstack_items -
- -HTML; - - if ($mini) { - $html = "
-
- $html -
-
"; - } - $ajax_cards = GLPI_AJAX_DASHBOARD; $cache_key = sha1($_SESSION['glpiactiveentities_string'] ?? ""); - $js_params = json_encode([ - 'current' => $this->current, - 'cols' => $this->grid_cols, - 'rows' => $this->grid_rows, - 'cell_margin' => $this->cell_margin, - 'rand' => $rand, - 'ajax_cards' => $ajax_cards, - 'all_cards' => $cards, - 'all_widgets' => $all_widgets, - 'context' => $this->context, - 'cache_key' => $cache_key, - 'embed' => self::$embed, - 'token' => $token, - 'entities_id' => $_SESSION['glpiactive_entity'], - 'is_recursive' => $_SESSION['glpiactive_entity_recursive'] ? 1 : 0 - ]); - $js = << $mini, + 'embed_class' => $embed_class, + 'mini_class' => $mini_class, + 'toolbars' => $toolbars, + 'filters' => $filters, + 'grid_guide' => $grid_guide, + 'gridstack_items' => $gridstack_items, + 'rand' => $rand, + 'grid_cols' => $this->grid_cols, + 'grid_rows' => $this->grid_rows, + 'js_params' => [ + 'current' => $this->current, + 'cols' => $this->grid_cols, + 'rows' => $this->grid_rows, + 'cell_margin' => $this->cell_margin, + 'rand' => $rand, + 'ajax_cards' => $ajax_cards, + 'all_cards' => $cards, + 'all_widgets' => $all_widgets, + 'context' => $this->context, + 'cache_key' => $cache_key, + 'embed' => self::$embed, + 'token' => $token, + 'entities_id' => $_SESSION['glpiactive_entity'], + 'is_recursive' => $_SESSION['glpiactive_entity_recursive'] ? 1 : 0 + ] + ]; + // language=Twig + echo TemplateRenderer::getInstance()->renderFromStringTemplate(<< +
+ {% endif %} +
+ + {{ toolbars|raw }} + {{ filters|raw }} + {{ grid_guide|raw }} +
+ {{ gridstack_items|raw }} +
+
+ {% if mini %} +
+ + {% endif %} + +TWIG, $twig_params); } diff --git a/src/Html.php b/src/Html.php index c25bbb08f44..e83e343759b 100644 --- a/src/Html.php +++ b/src/Html.php @@ -1111,7 +1111,6 @@ public static function includeHeader( if (in_array('dashboard', $jslibs)) { $tpl_vars['css_files'][] = ['path' => 'css/standalone/dashboard.scss']; - Html::requireJs('dashboard'); } if (in_array('marketplace', $jslibs)) { @@ -5949,9 +5948,6 @@ public static function requireJs($name) case 'fuzzy': $_SESSION['glpi_js_toload'][$name][] = 'lib/fuzzy.js'; break; - case 'dashboard': - $_SESSION['glpi_js_toload'][$name][] = 'js/dashboard.js'; - break; case 'marketplace': $_SESSION['glpi_js_toload'][$name][] = 'js/marketplace.js'; break; diff --git a/tests/cypress/e2e/dashboards.cy.js b/tests/cypress/e2e/dashboards.cy.js new file mode 100644 index 00000000000..4abd639ff0b --- /dev/null +++ b/tests/cypress/e2e/dashboards.cy.js @@ -0,0 +1,55 @@ +/** + * --------------------------------------------------------------------- + * + * GLPI - Gestionnaire Libre de Parc Informatique + * + * http://glpi-project.org + * + * @copyright 2015-2024 Teclib' and contributors. + * @copyright 2003-2014 by the INDEPNET Development Team. + * @licence https://www.gnu.org/licenses/gpl-3.0.html + * + * --------------------------------------------------------------------- + * + * LICENSE + * + * This file is part of GLPI. + * + * 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 3 of the License, or + * (at your option) any later version. + * + * 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 . + * + * --------------------------------------------------------------------- + */ +describe('Entities selector', () => { + beforeEach(() => { + cy.login(); + }); + + const dashboards = new Map([ + ['Asset', '/front/dashboard_assets.php'], + ['Assistance', '/front/dashboard_helpdesk.php'], + ['Central', '/front/central.php'], + ['Tickets Mini', '/front/ticket.php'], + ]); + + dashboards.forEach((value, key) => { + it(`${key} Dashboard Loads`, () => { + cy.visit(value); + cy.get('.grid-stack-item .g-chart, .grid-stack-item .big-number').should('be.visible'); + // grid-stack-items should have reasonable height + cy.get('.grid-stack-item:not(.lock-bottom)').each(($el) => { + cy.get($el).invoke('height').should('be.gt', 30); + }); + }); + }); +});