mirror of
https://github.com/Karaka-Management/oms-Dashboard.git
synced 2026-01-28 01:18:42 +00:00
Draft dashboard panels/boards/components per user
This commit is contained in:
parent
9638acb2aa
commit
53a07fd4da
65
Admin/Install/db.json
Normal file
65
Admin/Install/db.json
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"dashboard_board": {
|
||||
"name": "dashboard_board",
|
||||
"fields": {
|
||||
"dashboard_board_id": {
|
||||
"name": "dashboard_board_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"dashboard_board_title": {
|
||||
"name": "dashboard_board_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"dashboard_board_status": {
|
||||
"name": "dashboard_board_status",
|
||||
"type": "TINYINT",
|
||||
"null": false
|
||||
},
|
||||
"dashboard_board_account": {
|
||||
"name": "dashboard_board_account",
|
||||
"type": "INT",
|
||||
"null": true,
|
||||
"foreignTable": "account",
|
||||
"foreignKey": "account_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dashboard_component": {
|
||||
"name": "dashboard_component",
|
||||
"fields": {
|
||||
"dashboard_component_id": {
|
||||
"name": "dashboard_component_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"dashboard_component_order": {
|
||||
"name": "dashboard_component_order",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
"dashboard_component_module": {
|
||||
"name": "dashboard_component_module",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"dashboard_component_component": {
|
||||
"name": "dashboard_component_component",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"dashboard_component_board": {
|
||||
"name": "dashboard_component_board",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "dashboard_board",
|
||||
"foreignKey": "dashboard_board_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Dashboard\Admin;
|
||||
|
||||
use Modules\Dashboard\Models\DashboardBoard;
|
||||
use Modules\Dashboard\Models\DashboardBoardMapper;
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
|
||||
use phpOMS\Module\InfoManager;
|
||||
use phpOMS\Module\InstallerAbstract;
|
||||
|
||||
/**
|
||||
|
|
@ -26,4 +31,14 @@ use phpOMS\Module\InstallerAbstract;
|
|||
*/
|
||||
class Installer extends InstallerAbstract
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function install(DatabasePool $dbPool, InfoManager $info) : void
|
||||
{
|
||||
parent::install($dbPool, $info);
|
||||
|
||||
$board = new DashboardBoard();
|
||||
DashboardBoardMapper::create($board);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
31
Admin/Routes/Web/Api.php
Normal file
31
Admin/Routes/Web/Api.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Modules\Dashboard\Controller\ApiController;
|
||||
use Modules\Dashboard\Models\PermissionState;
|
||||
use phpOMS\Account\PermissionType;
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/dashboard/board(\?.*|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\Dashboard\Controller\ApiController:apiBoardCreate',
|
||||
'verb' => RouteVerb::PUT,
|
||||
'permission' => [
|
||||
'module' => ApiController::MODULE_NAME,
|
||||
'type' => PermissionType::CREATE,
|
||||
'state' => PermissionState::BOARD,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/dashboard/board/component(\?.*|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\Dashboard\Controller\ApiController:apiComponentAdd',
|
||||
'verb' => RouteVerb::PUT,
|
||||
'permission' => [
|
||||
'module' => ApiController::MODULE_NAME,
|
||||
'type' => PermissionType::CREATE,
|
||||
'state' => PermissionState::COMPONENT,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
168
Controller/ApiController.php
Normal file
168
Controller/ApiController.php
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Controller;
|
||||
|
||||
use Modules\Dashboard\Models\DashboardBoard;
|
||||
use Modules\Dashboard\Models\DashboardBoardMapper;
|
||||
use Modules\Dashboard\Models\DashboardBoardStatus;
|
||||
use Modules\Dashboard\Models\DashboardComponent;
|
||||
use Modules\Dashboard\Models\DashboardComponentMapper;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
|
||||
/**
|
||||
* Api controller for the dashboard module.
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Validate board create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool> Returns the validation array of the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateBoardCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = empty($request->getData('title')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create a board
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiBoardCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateBoardCreate($request))) {
|
||||
$response->set($request->getUri()->__toString(), new FormValidation($val));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$board = $this->createBoardFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $board, DashboardBoardMapper::class, 'board');
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Board', 'Board successfully created.', $board);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create board from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return DashboardBoard Returns the created board from the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createBoardFromRequest(RequestAbstract $request) : DashboardBoard
|
||||
{
|
||||
$board = new DashboardBoard();
|
||||
$board->setTitle((string) ($request->getData('title') ?? ''));
|
||||
$board->setAccount($request->getHeader()->getAccount());
|
||||
$board->setStatus(DashboardBoardStatus::ACTIVE);
|
||||
|
||||
return $board;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate component create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool> Returns the validation array of the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateComponentCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['board'] = empty($request->getData('board')))
|
||||
|| ($val['module'] = empty($request->getData('module')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create a component
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiComponentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateComponentCreate($request))) {
|
||||
$response->set($request->getUri()->__toString(), new FormValidation($val));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$component = $this->createComponentFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $component, DashboardComponentMapper::class, 'component');
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Component', 'Component successfully created.', $component);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create board from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return DashboardComponent Returns the created board from the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createComponentFromRequest(RequestAbstract $request) : DashboardComponent
|
||||
{
|
||||
$component = new DashboardComponent();
|
||||
$component->setBoard((int) ($request->getData('board') ?? 0));
|
||||
$component->setOrder((int) ($request->getData('order') ?? 0));
|
||||
$component->setModule((string) ($request->getData('module') ?? ''));
|
||||
|
||||
return $component;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,8 +14,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Dashboard\Controller;
|
||||
|
||||
use Modules\Dashboard\Models\DashboardBoardMapper;
|
||||
use Modules\Dashboard\Models\NullDashboardBoard;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Views\View;
|
||||
|
||||
|
|
@ -45,11 +48,22 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/Dashboard/Theme/Backend/dashboard');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000301001, $request, $response));
|
||||
|
||||
$view->addData('panels', [
|
||||
//$this->app->moduleManager->get('News')->viewDashboard($request, $response, $data),
|
||||
//$this->app->moduleManager->get('Tasks')->viewDashboard($request, $response, $data),
|
||||
//$this->app->moduleManager->get('Calendar')->viewDashboard($request, $response, $data),
|
||||
]);
|
||||
$board = DashboardBoardMapper::getFor($request->getHeader()->getAccount(), 'account');
|
||||
|
||||
if ($board instanceof NullDashboardBoard) {
|
||||
$board = DashboardBoardMapper::get(1);
|
||||
}
|
||||
|
||||
$panels = [];
|
||||
$boardComponents = $board->getComponents();
|
||||
|
||||
foreach ($boardComponents as $component) {
|
||||
$panels[] = $this->app->moduleManager
|
||||
->get($component->getModule())
|
||||
->viewDashboard($request, $response, $data);
|
||||
}
|
||||
|
||||
$view->addData('panels', $panels);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
252
Models/DashboardBoard.php
Normal file
252
Models/DashboardBoard.php
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||
|
||||
/**
|
||||
* DashboardBoard class.
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class DashboardBoard implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $id = 0;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $title = '';
|
||||
|
||||
/**
|
||||
* Account.
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $account = null;
|
||||
|
||||
/**
|
||||
* Status.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $status = DashboardBoardStatus::ACTIVE;
|
||||
|
||||
/**
|
||||
* Dashboard component.
|
||||
*
|
||||
* @var DashboardComponent[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $components = [];
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account
|
||||
*
|
||||
* @return null|int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set account
|
||||
*
|
||||
* @param mixed $id Account
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setAccount($id) : void
|
||||
{
|
||||
$this->account = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTitle() : string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string $title Title
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setTitle(string $title) : void
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getStatus() : int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set status
|
||||
*
|
||||
* @param int $status Task status
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidEnumValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStatus(int $status) : void
|
||||
{
|
||||
if (!DashboardBoardStatus::isValidValue($status)) {
|
||||
throw new InvalidEnumValue((string) $status);
|
||||
}
|
||||
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding board component.
|
||||
*
|
||||
* @param DashboardComponent $element Task element
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addComponent(DashboardComponent $element) : int
|
||||
{
|
||||
$this->components[] = $element;
|
||||
|
||||
\end($this->components);
|
||||
$key = (int) \key($this->components);
|
||||
\reset($this->components);
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove component from list.
|
||||
*
|
||||
* @param int $id Board component
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function removeComponent($id) : bool
|
||||
{
|
||||
if (isset($this->components[$id])) {
|
||||
unset($this->components[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get board components.
|
||||
*
|
||||
* @return DashboardComponent[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getComponents() : array
|
||||
{
|
||||
return $this->components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get board component.
|
||||
*
|
||||
* @param int $id Component id
|
||||
*
|
||||
* @return DashboardComponent
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getComponent(int $id) : DashboardComponent
|
||||
{
|
||||
return $this->components[$id] ?? new NullDashboardComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'account' => $this->account,
|
||||
'title' => $this->title,
|
||||
'status' => $this->status,
|
||||
'components' => $this->components,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
86
Models/DashboardBoardMapper.php
Normal file
86
Models/DashboardBoardMapper.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class DashboardBoardMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array<string, bool|string>>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $columns = [
|
||||
'dashboard_board_id' => ['name' => 'dashboard_board_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'dashboard_board_title' => ['name' => 'dashboard_board_title', 'type' => 'string', 'internal' => 'title'],
|
||||
'dashboard_board_status' => ['name' => 'dashboard_board_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'dashboard_board_account' => ['name' => 'dashboard_board_account', 'type' => 'int', 'internal' => 'account'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array<string, null|string>>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $hasMany = [
|
||||
'components' => [
|
||||
'mapper' => DashboardComponentMapper::class,
|
||||
'table' => 'dashboard_component',
|
||||
'dst' => 'dashboard_component_board',
|
||||
'src' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array<string, string>>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $belongsTo = [
|
||||
'account' => [
|
||||
'mapper' => AccountMapper::class,
|
||||
'src' => 'dashboard_board_account',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $table = 'dashboard_board';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $primaryField = 'dashboard_board_id';
|
||||
}
|
||||
31
Models/DashboardBoardStatus.php
Normal file
31
Models/DashboardBoardStatus.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* DashboardBoard status enum.
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class DashboardBoardStatus extends Enum
|
||||
{
|
||||
public const ACTIVE = 1;
|
||||
public const INACTIVE = 2;
|
||||
}
|
||||
204
Models/DashboardComponent.php
Normal file
204
Models/DashboardComponent.php
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Models;
|
||||
|
||||
/**
|
||||
* DashboardBoard class.
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class DashboardComponent implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $id = 0;
|
||||
|
||||
/**
|
||||
* Order.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $order = 0;
|
||||
|
||||
/**
|
||||
* Board.
|
||||
*
|
||||
* @var int|DashboardBoard
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $board = 0;
|
||||
|
||||
/**
|
||||
* Module.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $module = '';
|
||||
|
||||
/**
|
||||
* Component.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $component = '';
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getOrder() : int
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order
|
||||
*
|
||||
* @param int $order Order
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setOrder(int $order) : void
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get component
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getComponent() : string
|
||||
{
|
||||
return $this->component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set component
|
||||
*
|
||||
* @param string $component Component
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setComponent(string $component) : void
|
||||
{
|
||||
$this->component = $component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getModule() : string
|
||||
{
|
||||
return $this->module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set module
|
||||
*
|
||||
* @param string $module Module
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setModule(string $module) : void
|
||||
{
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get board
|
||||
*
|
||||
* @return int|DashboardBoard
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getBoard()
|
||||
{
|
||||
return $this->board;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set board
|
||||
*
|
||||
* @param mixed $id Board
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setBoard($id) : void
|
||||
{
|
||||
$this->board = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'board' => $this->board,
|
||||
'order' => $this->order,
|
||||
'module' => $this->module,
|
||||
'component' => $this->component,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
73
Models/DashboardComponentMapper.php
Normal file
73
Models/DashboardComponentMapper.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class DashboardComponentMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array<string, bool|string>>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $columns = [
|
||||
'dashboard_component_id' => ['name' => 'dashboard_component_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'dashboard_component_order' => ['name' => 'dashboard_component_order', 'type' => 'int', 'internal' => 'order'],
|
||||
'dashboard_component_module' => ['name' => 'dashboard_component_module', 'type' => 'string', 'internal' => 'module'],
|
||||
'dashboard_component_component' => ['name' => 'dashboard_component_component', 'type' => 'string', 'internal' => 'component'],
|
||||
'dashboard_component_board' => ['name' => 'dashboard_component_board', 'type' => 'int', 'internal' => 'board'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array<string, string>>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $belongsTo = [
|
||||
'board' => [
|
||||
'mapper' => DashboardBoardMapper::class,
|
||||
'src' => 'dashboard_component_board',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $table = 'dashboard_component';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $primaryField = 'dashboard_component_id';
|
||||
}
|
||||
28
Models/NullDashboardBoard.php
Normal file
28
Models/NullDashboardBoard.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullDashboardBoard extends DashboardBoard
|
||||
{
|
||||
|
||||
}
|
||||
28
Models/NullDashboardComponent.php
Normal file
28
Models/NullDashboardComponent.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Dashboard\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Dashboard
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullDashboardComponent extends DashboardComponent
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -27,4 +27,6 @@ use phpOMS\Stdlib\Base\Enum;
|
|||
abstract class PermissionState extends Enum
|
||||
{
|
||||
public const DASHBOARD = 1;
|
||||
public const BOARD = 2;
|
||||
public const COMPONENT = 3;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user