mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°8641 - Dashboard editor front-end first commit for Form SDK integration.
* No dashlet edition * Dashboard are not persisted * Unable to load a dashboard from an endpoint (refresh) * Grid library need proper npm integration
This commit is contained in:
163
sources/Application/UI/Base/Layout/DashletPanel/DashletEntry.php
Normal file
163
sources/Application/UI/Base/Layout/DashletPanel/DashletEntry.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Layout\DashletPanel;
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\UIBlock;
|
||||
use utils;
|
||||
|
||||
class DashletEntry extends UIBlock {
|
||||
public const BLOCK_CODE = 'ibo-dashlet-entry';
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/dashlet-panel/dashlet-entry';
|
||||
|
||||
protected $sDashletLabel;
|
||||
protected $sDashletClass;
|
||||
protected $sDashletIcon;
|
||||
protected $sDashletDescription;
|
||||
protected $sDashletMinWidth;
|
||||
protected $sDashletMinHeight;
|
||||
protected $sDashletPreferredWidth;
|
||||
protected $sDashletPreferredHeight;
|
||||
|
||||
|
||||
public function __construct(string $sDashletClass, string $sDashletLabel, string $sDashletDescription, string $sDashletIconRelUrl, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
|
||||
$this->sDashletClass = $sDashletClass;
|
||||
$this->sDashletLabel = $sDashletLabel;
|
||||
$this->sDashletIcon = utils::GetAbsoluteUrlAppRoot().$sDashletIconRelUrl;
|
||||
$this->sDashletDescription = $sDashletDescription;
|
||||
|
||||
$this->AddDataAttribute('role', static::BLOCK_CODE);
|
||||
}
|
||||
|
||||
public function GetDashletLabel(): string
|
||||
{
|
||||
return $this->sDashletLabel;
|
||||
}
|
||||
|
||||
public function SetDashletLabel(string $sDashletLabel): DashletEntry
|
||||
{
|
||||
$this->sDashletLabel = $sDashletLabel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetDashletClass(): string
|
||||
{
|
||||
return $this->sDashletClass;
|
||||
}
|
||||
|
||||
public function SetDashletClass(string $sDashletClass): DashletEntry
|
||||
{
|
||||
$this->sDashletClass = $sDashletClass;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetDashletIcon(): string
|
||||
{
|
||||
return $this->sDashletIcon;
|
||||
}
|
||||
|
||||
public function SetDashletIcon(string $sDashletIcon): DashletEntry
|
||||
{
|
||||
$this->sDashletIcon = $sDashletIcon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetDashletDescription(): string
|
||||
{
|
||||
return $this->sDashletDescription;
|
||||
}
|
||||
|
||||
public function SetDashletDescription(string $sDashletDescription): DashletEntry
|
||||
{
|
||||
$this->sDashletDescription = $sDashletDescription;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetDashletPreferredHeight()
|
||||
{
|
||||
return $this->sDashletPreferredHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $sDashletPreferredHeight
|
||||
*
|
||||
* @return DashletEntry
|
||||
*/
|
||||
public function SetDashletPreferredHeight($sDashletPreferredHeight)
|
||||
{
|
||||
$this->sDashletPreferredHeight = $sDashletPreferredHeight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetDashletPreferredWidth()
|
||||
{
|
||||
return $this->sDashletPreferredWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $sDashletPreferredWidth
|
||||
*
|
||||
* @return DashletEntry
|
||||
*/
|
||||
public function SetDashletPreferredWidth($sDashletPreferredWidth)
|
||||
{
|
||||
$this->sDashletPreferredWidth = $sDashletPreferredWidth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetDashletMinHeight()
|
||||
{
|
||||
return $this->sDashletMinHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $sDashletMinHeight
|
||||
*
|
||||
* @return DashletEntry
|
||||
*/
|
||||
public function SetDashletMinHeight($sDashletMinHeight)
|
||||
{
|
||||
$this->sDashletMinHeight = $sDashletMinHeight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetDashletMinWidth()
|
||||
{
|
||||
return $this->sDashletMinWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $sDashletMinWidth
|
||||
*
|
||||
* @return DashletEntry
|
||||
*/
|
||||
public function SetDashletMinWidth($sDashletMinWidth)
|
||||
{
|
||||
$this->sDashletMinWidth = $sDashletMinWidth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Layout\DashletPanel;
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\UIBlock;
|
||||
use Dashlet;
|
||||
|
||||
class DashletPanel extends UIBlock {
|
||||
public const BLOCK_CODE = 'ibo-dashlet-panel';
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/dashlet-panel/layout';
|
||||
public const DEFAULT_JS_TEMPLATE_REL_PATH = 'base/layouts/dashlet-panel/layout';
|
||||
|
||||
protected $aDashletsEntries = [];
|
||||
|
||||
public function __construct(string $sId = null, array $aContainerClasses = [])
|
||||
{
|
||||
parent::__construct($sId, $aContainerClasses);
|
||||
|
||||
$this->AddDataAttribute('role', static::BLOCK_CODE);
|
||||
}
|
||||
|
||||
public function AddDashletEntry(DashletEntry $oDashletEntry) {
|
||||
$this->aDashletsEntries[] = $oDashletEntry;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetDashletEntries() : array {
|
||||
return $this->aDashletsEntries;
|
||||
}
|
||||
|
||||
public function SetDashletEntries(array $aDashletEntries) {
|
||||
$this->aDashletsEntries = $aDashletEntries;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetSubBlocks(): array
|
||||
{
|
||||
return $this->aDashletsEntries;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Layout\DashletPanel;
|
||||
|
||||
|
||||
use Combodo\iTop\Service\Dashboard\DashletService;
|
||||
|
||||
class DashletPanelFactory {
|
||||
public static function MakeForDashboardEditor(string $sId = null): DashletPanel
|
||||
{
|
||||
$oDashletPanel = new DashletPanel($sId);
|
||||
|
||||
$aAvailableDashlets = DashletService::GetAvailableDashlets();
|
||||
|
||||
foreach ($aAvailableDashlets as $sDashletClass => $aDashletInformation) {
|
||||
$oDashletEntry = new DashletEntry($sDashletClass, $aDashletInformation['label'], $aDashletInformation['description'], $aDashletInformation['icon']);
|
||||
|
||||
if(isset($aDashletInformation['min_width'])) {
|
||||
$oDashletEntry->SetDashletMinWidth($aDashletInformation['min_width']);
|
||||
}
|
||||
if(isset($aDashletInformation['min_height'])) {
|
||||
$oDashletEntry->SetDashletMinHeight($aDashletInformation['min_height']);
|
||||
}
|
||||
if(isset($aDashletInformation['preferred_width'])) {
|
||||
$oDashletEntry->SetDashletPreferredWidth($aDashletInformation['preferred_width']);
|
||||
}
|
||||
if(isset($aDashletInformation['preferred_height'])) {
|
||||
$oDashletEntry->SetDashletPreferredHeight($aDashletInformation['preferred_height']);
|
||||
}
|
||||
|
||||
$oDashletPanel->AddDashletEntry($oDashletEntry);
|
||||
}
|
||||
|
||||
return $oDashletPanel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user