Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resize dashboard to match GLPI's core #3306

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ public static function showMiniDashboard(): void {

if (PluginFormcreatorEntityconfig::getUsedConfig('is_dashboard_visible', Session::getActiveEntity()) == PluginFormcreatorEntityconfig::CONFIG_DASHBOARD_VISIBLE) {
if (version_compare(GLPI_VERSION, '10.0.3') > 0) {
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 1, 'mini_core');
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 2, 'mini_core');
} else {
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 0, 'mini_core');
}
Expand Down
37 changes: 37 additions & 0 deletions install/upgrade_to_2.13.7.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* ---------------------------------------------------------------------
*/

use Glpi\Dashboard\Dashboard;
use Glpi\Dashboard\Item;
use Glpi\Toolbox\Sanitizer;

class PluginFormcreatorUpgradeTo2_13_7 {
Expand All @@ -45,6 +47,7 @@ public function isResyncIssuesRequired() {
public function upgrade(Migration $migration) {
$this->migration = $migration;
$this->fixEncodingInQuestions();
$this->resizeWidgets();
}

/**
Expand Down Expand Up @@ -83,4 +86,38 @@ public function fixEncodingInQuestions() {
);
}
}

/**
* Resize widgets of the `plugin_formcreator_issue_counters` dashboard to match
* the mini_tickets core dashboard style
*
* @return void
*/
public function resizeWidgets() {
// Get container
$dashboard = new Dashboard();
$found = $dashboard->getFromDB("plugin_formcreator_issue_counters");

if (!$found) {
// Unable to fetch dashboard
return;
};

$di = new Item();
$cards = $di->find(['dashboards_dashboards_id' => $dashboard->fields['id']]);
$x = 0;

foreach ($cards as $card) {
$di = new Item();
$di->update([
'id' => $card['id'],
'width' => 4,
'height' => 2,
'x' => $x,
'y' => 0,
]);

$x +=4;
}
}
}