mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-27 20:48:46 +02:00
Read custom dashboards with grid format
This commit is contained in:
52
sources/Application/Dashboard/Layout/DashboardLayoutGrid.php
Normal file
52
sources/Application/Dashboard/Layout/DashboardLayoutGrid.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\Dashboard\Layout;
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\Layout\Dashboard\DashboardGrid;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\Dashboard\DashboardLayout as DashboardLayoutUIBlock;
|
||||
|
||||
class DashboardLayoutGrid extends \DashboardLayout
|
||||
{
|
||||
public function Render($oPage, $aDashlets, $bEditMode = false, array $aExtraParams = [])
|
||||
{
|
||||
$oDashboardLayout = new DashboardLayoutUIBlock($aExtraParams['dashboard_div_id']);
|
||||
|
||||
$oDashboardGrid = new DashboardGrid();
|
||||
$oDashboardLayout->SetGrid($oDashboardGrid);
|
||||
foreach ($aDashlets as $sDashletId => $aPosDashlet) {
|
||||
/** @var \Dashlet $oDashlet */
|
||||
$oDashlet = $aPosDashlet['dashlet'];
|
||||
if ($oDashlet::IsVisible()) {
|
||||
$oDashlet->SetID($sDashletId);
|
||||
$sDashletClass = get_class($oDashlet);
|
||||
$aDashletDenormalizedProperties = $oDashlet->GetDenormalizedProperties();
|
||||
$aDashletsInfo = $sDashletClass::GetInfo();
|
||||
|
||||
// Also set minimal height/width
|
||||
$iPositionX = $aPosDashlet['position_x'];
|
||||
$iPositionY = $aPosDashlet['position_y'];
|
||||
$iWidth = max($aPosDashlet['width'], array_key_exists('min_width', $aDashletsInfo) ? $aDashletsInfo['min_width'] : 1);
|
||||
$iHeight = max($aPosDashlet['height'], array_key_exists('min_height', $aDashletsInfo) ? $aDashletsInfo['min_height'] : 1);
|
||||
$oDashboardGrid->AddDashlet($oDashlet->DoRender($oPage, $bEditMode, true /* bEnclosingDiv */, $aExtraParams), $sDashletId, $sDashletClass, $aDashletDenormalizedProperties, $iPositionX, $iPositionY, $iWidth, $iHeight);
|
||||
}
|
||||
}
|
||||
|
||||
return $oDashboardLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function GetDashletCoordinates($iCellIdx)
|
||||
{
|
||||
$iColNumber = $iCellIdx % 12;
|
||||
$iRowNumber = (int)floor($iCellIdx / 12);
|
||||
|
||||
return [$iColNumber, $iRowNumber];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user