mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-23 18:07:42 +02:00
Introduce some database model for the new dashboards
This commit is contained in:
parent
ed94660839
commit
8b9d63556d
53
library/Icinga/Model/DashboardOverride.php
Normal file
53
library/Icinga/Model/DashboardOverride.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
use ipl\Sql\Expression;
|
||||
|
||||
class DashboardOverride extends Model
|
||||
{
|
||||
public function getTableName()
|
||||
{
|
||||
return 'dashboard_override';
|
||||
}
|
||||
|
||||
public function getKeyName()
|
||||
{
|
||||
return 'dashboard_id';
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'label',
|
||||
'username',
|
||||
'disabled',
|
||||
'priority',
|
||||
'acceptance' => 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);
|
||||
}
|
||||
}
|
61
library/Icinga/Model/Dashlet.php
Normal file
61
library/Icinga/Model/Dashlet.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
use ipl\Sql\Expression;
|
||||
|
||||
class Dashlet extends Model
|
||||
{
|
||||
public function getTableName()
|
||||
{
|
||||
return 'dashlet';
|
||||
}
|
||||
|
||||
public function getKeyName()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'dashboard_id',
|
||||
'name',
|
||||
'label',
|
||||
'url',
|
||||
'priority'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColumnDefinitions()
|
||||
{
|
||||
return [
|
||||
'dashboard_id' => 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);
|
||||
}
|
||||
}
|
58
library/Icinga/Model/Home.php
Normal file
58
library/Icinga/Model/Home.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
class Home extends Model
|
||||
{
|
||||
public function getTableName()
|
||||
{
|
||||
return 'dashboard_home';
|
||||
}
|
||||
|
||||
public function getKeyName()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'name',
|
||||
'label',
|
||||
'username',
|
||||
'type',
|
||||
'priority',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColumnDefinitions()
|
||||
{
|
||||
return [
|
||||
'name' => 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);
|
||||
}
|
||||
}
|
56
library/Icinga/Model/ModuleDashlet.php
Normal file
56
library/Icinga/Model/ModuleDashlet.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use ipl\Orm\Model;
|
||||
|
||||
class ModuleDashlet extends Model
|
||||
{
|
||||
public function getTableName()
|
||||
{
|
||||
return 'module_dashlet';
|
||||
}
|
||||
|
||||
public function getKeyName()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'name',
|
||||
'label',
|
||||
'module',
|
||||
'pane',
|
||||
'url',
|
||||
'description',
|
||||
'priority'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColumnDefinitions()
|
||||
{
|
||||
return [
|
||||
'name' => 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'];
|
||||
}
|
||||
}
|
64
library/Icinga/Model/Pane.php
Normal file
64
library/Icinga/Model/Pane.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Model;
|
||||
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Relations;
|
||||
use ipl\Sql\Expression;
|
||||
|
||||
class Pane extends Model
|
||||
{
|
||||
public function getTableName()
|
||||
{
|
||||
return 'dashboard';
|
||||
}
|
||||
|
||||
public function getKeyName()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'home_id',
|
||||
'name',
|
||||
'label',
|
||||
'username',
|
||||
'priority'
|
||||
];
|
||||
}
|
||||
|
||||
public function getMetaData()
|
||||
{
|
||||
return [
|
||||
'home_id' => 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');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user