mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-23 18:07:42 +02:00
Introduce DashboardOwner model & adjust other models accordingly
This commit is contained in:
parent
97b009c39f
commit
ee706860c9
32
library/Icinga/Model/DashboardOwner.php
Normal file
32
library/Icinga/Model/DashboardOwner.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use Icinga\Web\Dashboard\DashboardHome;
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
class DashboardOwner extends Model
|
||||
{
|
||||
public function getTableName()
|
||||
{
|
||||
return 'icingaweb_dashboard_owner';
|
||||
}
|
||||
|
||||
public function getKeyName()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return ['username'];
|
||||
}
|
||||
|
||||
public function createRelations(Relations $relations)
|
||||
{
|
||||
$relations->hasMany(DashboardHome::TABLE, Home::class);
|
||||
}
|
||||
}
|
@ -4,8 +4,10 @@
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use Icinga\Model\Behavior\BoolCast;
|
||||
use Icinga\Web\Dashboard\DashboardHome;
|
||||
use Icinga\Web\Dashboard;
|
||||
use ipl\Orm\Behaviors;
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
@ -24,9 +26,9 @@ class Home extends Model
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'user_id',
|
||||
'name',
|
||||
'label',
|
||||
'username',
|
||||
'type',
|
||||
'priority',
|
||||
'disabled',
|
||||
@ -52,10 +54,17 @@ class Home extends Model
|
||||
return 'priority';
|
||||
}
|
||||
|
||||
public function createBehaviors(Behaviors $behaviors)
|
||||
{
|
||||
$behaviors->add(new BoolCast(['disabled']));
|
||||
}
|
||||
|
||||
public function createRelations(Relations $relations)
|
||||
{
|
||||
$relations->hasMany(Dashboard\Pane::TABLE, Pane::class);
|
||||
$relations->belongsTo('icingaweb_dashboard_owner', DashboardOwner::class)
|
||||
->setCandidateKey('user_id');
|
||||
|
||||
$relations->hasMany(Dashboard\Pane::TABLE, Pane::class);
|
||||
//$relations->hasMany(Dashboard\Dashlet::TABLE, Dashlet::class);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use Icinga\Model\Behavior\BoolCast;
|
||||
use Icinga\Web\Dashboard;
|
||||
use ipl\Orm\Behaviors;
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
@ -29,6 +31,7 @@ class ModuleDashlet extends Model
|
||||
'pane',
|
||||
'url',
|
||||
'description',
|
||||
'disabled',
|
||||
'priority'
|
||||
];
|
||||
}
|
||||
@ -56,6 +59,11 @@ class ModuleDashlet extends Model
|
||||
return ['name', 'priority'];
|
||||
}
|
||||
|
||||
public function createBehaviors(Behaviors $behaviors)
|
||||
{
|
||||
$behaviors->add(new BoolCast(['disabled']));
|
||||
}
|
||||
|
||||
public function createRelations(Relations $relations)
|
||||
{
|
||||
$relations->belongsToMany(Dashboard\Dashlet::TABLE, Dashlet::class)
|
||||
|
@ -26,7 +26,6 @@ class Pane extends Model
|
||||
'home_id',
|
||||
'name',
|
||||
'label',
|
||||
'username',
|
||||
'priority'
|
||||
];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user