Repository navigation
update 12.0/bugfixes branch - #378
Merged
Merged
Conversation
echarts is available in GLPI core, saving 1 library from the project
btry
commented
Oct 8, 2026
| @@ -1,3 +1,5 @@ | |||
| <?php | |||
Collaborator
Author
There was a problem hiding this comment.
This file has actually NOT been renamed. This is a false positive from renaming detection feature.
Rom1-B
reviewed
Oct 8, 2026
Rom1-B
left a comment
Contributor
There was a problem hiding this comment.
Some fixes on top of this port (they also apply to develop):
setup.php:echartsis not loaded when the environmental impact tab is opened from another tab (ReferenceError: echarts is not defined); use the core sector-based JS loading instead.src/Dashboard/Grid.php: the card still declaresapex_radar, soradaris hidden in the widget edit form.apex_radar.html.twigrenamed toradar.html.twig.- Migration test for the
apex_radartoradarcard conversion.
diff --git a/setup.php b/setup.php
index 01541e7..8e88770 100644
--- a/setup.php
+++ b/setup.php
@@ -108,13 +108,7 @@ function plugin_init_carbon()
$CFG_GLPI['javascript']['tools'][strtolower(Report::class)] = ['dashboard'];
foreach (PLUGIN_CARBON_TYPES as $itemtype) {
- $form_url = $itemtype::getFormURL();
- if (strpos($_SERVER['REQUEST_URI'] ?? '', $form_url) !== false) {
- continue;
- }
- if (($_SESSION['glpi_tabs'][strtolower($itemtype)] ?? '') == 'GlpiPlugin\Carbon\UsageInfo$1') {
- Html::requireJs('charts');
- }
+ $CFG_GLPI['javascript']['assets'][strtolower($itemtype)][] = 'charts';
}
$proxy_exclusions = $CFG_GLPI['possible_proxy_exclusions'];
$proxy_exclusions->addExclusion(new ProxyExclusion(
diff --git a/src/Dashboard/Grid.php b/src/Dashboard/Grid.php
index a4569e7..5180276 100644
--- a/src/Dashboard/Grid.php
+++ b/src/Dashboard/Grid.php
@@ -74,7 +74,7 @@ class Grid
$group = __('Carbon', 'carbon');
$cards += [
'plugin_carbon_assets_completeness_ratio' => [
- 'widgettype' => ['apex_radar', 'multipleNumber'],
+ 'widgettype' => ['radar', 'multipleNumber'],
'group' => $group,
'label' => __('Handled assets ratio', 'carbon'),
'provider' => Provider::class . '::getHandledAssetsRatio',
diff --git a/src/Dashboard/Widget.php b/src/Dashboard/Widget.php
index 32c0c19..7c03c95 100644
--- a/src/Dashboard/Widget.php
+++ b/src/Dashboard/Widget.php
@@ -827,7 +827,7 @@ class Widget extends GlpiDashboardWidget
],
];
- $output = TemplateRenderer::getInstance()->render('@carbon/dashboard/apex_radar.html.twig', [
+ $output = TemplateRenderer::getInstance()->render('@carbon/dashboard/radar.html.twig', [
'chart_id' => $chart_id,
'class' => $class,
'color' => $p['color'],
diff --git a/templates/dashboard/apex_radar.html.twig b/templates/dashboard/radar.html.twig
similarity index 100%
rename from templates/dashboard/apex_radar.html.twig
rename to templates/dashboard/radar.html.twig
diff --git a/tests/migration/migration_to_1_4_1_Test.php b/tests/migration/migration_to_1_4_1_Test.php
new file mode 100644
index 0000000..29c53dd
--- /dev/null
+++ b/tests/migration/migration_to_1_4_1_Test.php
@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * -------------------------------------------------------------------------
+ * Carbon plugin for GLPI
+ *
+ * @copyright Copyright (C) 2024-2025 Teclib' and contributors.
+ * @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
+ * @link https://github.com/pluginsGLPI/carbon
+ *
+ * -------------------------------------------------------------------------
+ *
+ * LICENSE
+ *
+ * This file is part of Carbon plugin for 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 <https://www.gnu.org/licenses/>.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+
+namespace GlpiPlugin\Carbon\Tests;
+
+use DBmysql;
+use GlpiPlugin\Carbon\Install;
+use Migration;
+
+use function Safe\json_decode;
+use function Safe\json_encode;
+
+class migration_to_1_4_1_Test extends CommonTestCase
+{
+ public function testUpdateHandledRatioCard()
+ {
+ /** @var DBmysql $DB */
+ global $DB;
+
+ require_once(__DIR__ . '/../../install/Install.php');
+
+ $DB->insert('glpi_dashboards_dashboards', [
+ 'key' => 'plugin_carbon_migration_test',
+ 'name' => 'plugin_carbon_migration_test',
+ ]);
+ $dashboard_id = $DB->insertId();
+ $cards = [
+ 'radar_card' => [
+ 'card_id' => 'plugin_carbon_assets_completeness_ratio',
+ 'widgettype' => 'apex_radar',
+ ],
+ 'number_card' => [
+ 'card_id' => 'plugin_carbon_assets_completeness_ratio',
+ 'widgettype' => 'multipleNumber',
+ ],
+ 'other_card' => [
+ 'card_id' => 'plugin_carbon_assets_completeness',
+ 'widgettype' => 'apex_radar',
+ ],
+ ];
+ $ids = [];
+ foreach ($cards as $key => $card) {
+ $DB->insert('glpi_dashboards_items', [
+ 'dashboards_dashboards_id' => $dashboard_id,
+ 'gridstack_id' => $card['card_id'] . '_' . $key,
+ 'card_id' => $card['card_id'],
+ 'card_options' => json_encode(['color' => '#FAFAFA', 'widgettype' => $card['widgettype']]),
+ ]);
+ $ids[$key] = $DB->insertId();
+ }
+
+ $install = new Install(new Migration('1.4.1'));
+ $migrations = $install->getMigrationsToDo('1.4.0');
+ $install->upgradeOneVersion(key($migrations), current($migrations));
+
+ $expected = [
+ 'radar_card' => 'radar',
+ 'number_card' => 'multipleNumber',
+ 'other_card' => 'apex_radar',
+ ];
+ foreach ($expected as $key => $widgettype) {
+ $row = $DB->request([
+ 'FROM' => 'glpi_dashboards_items',
+ 'WHERE' => ['id' => $ids[$key]],
+ ])->current();
+ $card_options = json_decode($row['card_options'], true);
+ $this->assertSame($widgettype, $card_options['widgettype']);
+ $this->assertSame('#FAFAFA', $card_options['color']);
+ }
+ }
+}
Rom1-B
approved these changes
Oct 9, 2026
btry
commented
Oct 9, 2026
| @@ -1,3 +1,5 @@ | |||
| <?php | |||
Collaborator
Author
There was a problem hiding this comment.
This file has actually NOT been renamed. This is a false positive from renaming detection feature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove ApexCharts library, and use eCharts instead.