From 8b9d63556d26d5c5ce7d95d02352441c5ce04a58 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 11 Mar 2022 16:18:08 +0100 Subject: [PATCH] Introduce some database model for the new dashboards --- library/Icinga/Model/DashboardOverride.php | 53 ++++++++++++++++++ library/Icinga/Model/Dashlet.php | 61 +++++++++++++++++++++ library/Icinga/Model/Home.php | 58 ++++++++++++++++++++ library/Icinga/Model/ModuleDashlet.php | 56 +++++++++++++++++++ library/Icinga/Model/Pane.php | 64 ++++++++++++++++++++++ 5 files changed, 292 insertions(+) create mode 100644 library/Icinga/Model/DashboardOverride.php create mode 100644 library/Icinga/Model/Dashlet.php create mode 100644 library/Icinga/Model/Home.php create mode 100644 library/Icinga/Model/ModuleDashlet.php create mode 100644 library/Icinga/Model/Pane.php diff --git a/library/Icinga/Model/DashboardOverride.php b/library/Icinga/Model/DashboardOverride.php new file mode 100644 index 000000000..8582da344 --- /dev/null +++ b/library/Icinga/Model/DashboardOverride.php @@ -0,0 +1,53 @@ + new Expression('COALESCE(COUNT(dashboard_subscribable_dashboard_dashboard_override.dashboard_id), 0)') + ]; + } + + public function getMetaData() + { + return ['priority' => t('Dashboard Priority Order')]; + } + + public function getSearchColumns() + { + return ['name']; + } + + public function getDefaultSort() + { + return 'dashboard.name'; + } + + public function createRelations(Relations $relations) + { + $relations->belongsTo('dashboard', Pane::class); + } +} diff --git a/library/Icinga/Model/Dashlet.php b/library/Icinga/Model/Dashlet.php new file mode 100644 index 000000000..ac7efb63a --- /dev/null +++ b/library/Icinga/Model/Dashlet.php @@ -0,0 +1,61 @@ + t('Dashboard Id'), + 'name' => t('Dashlet Name'), + 'label' => t('Dashlet Title'), + 'url' => t('Dashlet Url'), + 'priority' => t('Dashlet Priority Order'), + 'description' => t('Dashlet Description') + ]; + } + + public function getSearchColumns() + { + return ['name']; + } + + public function getDefaultSort() + { + return 'priority'; + } + + public function createRelations(Relations $relations) + { + $relations->belongsTo('dashboard', Pane::class); + //$relations->belongsTo('home', Home::class); + } +} diff --git a/library/Icinga/Model/Home.php b/library/Icinga/Model/Home.php new file mode 100644 index 000000000..a3dbb2689 --- /dev/null +++ b/library/Icinga/Model/Home.php @@ -0,0 +1,58 @@ + t('Dashboard Home Name'), + 'label' => t('Dashboard Home Title'), + 'priority' => t('Dashboard Priority Order') + ]; + } + + public function getSearchColumns() + { + return ['name']; + } + + public function getDefaultSort() + { + return 'dashboard_home.name'; + } + + public function createRelations(Relations $relations) + { + $relations->hasMany('dashboard', Pane::class); + + //$relations->hasMany('dashlet', Dashlet::class); + } +} diff --git a/library/Icinga/Model/ModuleDashlet.php b/library/Icinga/Model/ModuleDashlet.php new file mode 100644 index 000000000..f18abcb81 --- /dev/null +++ b/library/Icinga/Model/ModuleDashlet.php @@ -0,0 +1,56 @@ + t('Dashlet Name'), + 'label' => t('Dashlet Title'), + 'module' => t('Module Name'), + 'pane' => t('Pane Name'), + 'url' => t('Dashlet Url'), + 'description' => t('Dashlet Description'), + 'priority' => t('Dashlet Priority Order') + ]; + } + + public function getSearchColumns() + { + return ['name']; + } + + public function getDefaultSort() + { + return ['module_dashlet.name', 'module_dashlet.priority']; + } +} diff --git a/library/Icinga/Model/Pane.php b/library/Icinga/Model/Pane.php new file mode 100644 index 000000000..ce1e98c15 --- /dev/null +++ b/library/Icinga/Model/Pane.php @@ -0,0 +1,64 @@ + t('Dashboard Home Id'), + 'name' => t('Dashboard Name'), + 'label' => t('Dashboard Title'), + 'username' => t('Username'), + ]; + } + + public function getSearchColumns() + { + return ['name']; + } + + public function getDefaultSort() + { + return 'dashboard.name'; + } + + public function createRelations(Relations $relations) + { + $relations->belongsTo('home', Home::class) + ->setCandidateKey('home_id'); + + $relations->hasMany('dashboard_override', DashboardOverride::class) + ->setJoinType('LEFT'); + $relations->hasMany('dashlet', Dashlet::class) + ->setJoinType('LEFT'); + } +}