Introduce DashboardOwner model & adjust other models accordingly

This commit is contained in:
Yonas Habteab 2022-05-19 17:32:06 +02:00
parent 97b009c39f
commit ee706860c9
4 changed files with 51 additions and 3 deletions

View 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);
}
}

View File

@ -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);
}
}

View File

@ -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)

View File

@ -26,7 +26,6 @@ class Pane extends Model
'home_id',
'name',
'label',
'username',
'priority'
];
}