diff --git a/library/Icinga/Model/DashboardOwner.php b/library/Icinga/Model/DashboardOwner.php new file mode 100644 index 000000000..878329b58 --- /dev/null +++ b/library/Icinga/Model/DashboardOwner.php @@ -0,0 +1,32 @@ +hasMany(DashboardHome::TABLE, Home::class); + } +} diff --git a/library/Icinga/Model/Home.php b/library/Icinga/Model/Home.php index a55ae8979..bf85a3653 100644 --- a/library/Icinga/Model/Home.php +++ b/library/Icinga/Model/Home.php @@ -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); } } diff --git a/library/Icinga/Model/ModuleDashlet.php b/library/Icinga/Model/ModuleDashlet.php index 92950f975..374f6a64c 100644 --- a/library/Icinga/Model/ModuleDashlet.php +++ b/library/Icinga/Model/ModuleDashlet.php @@ -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) diff --git a/library/Icinga/Model/Pane.php b/library/Icinga/Model/Pane.php index 3712aebc8..fd2152bd3 100644 --- a/library/Icinga/Model/Pane.php +++ b/library/Icinga/Model/Pane.php @@ -26,7 +26,6 @@ class Pane extends Model 'home_id', 'name', 'label', - 'username', 'priority' ]; }