mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +02:00
Remove some unused interfaces/attrs
This commit is contained in:
parent
8b73811fa7
commit
e0ee07fc39
@ -1,53 +0,0 @@
|
|||||||
<?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('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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
|
||||||
|
|
||||||
namespace Icinga\Web\Dashboard\Common;
|
|
||||||
|
|
||||||
interface OverridingWidget
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Set whether this widget overrides another widget
|
|
||||||
*
|
|
||||||
* @param bool $override
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function override(bool $override);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get whether this widget overrides another widget
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isOverriding();
|
|
||||||
}
|
|
@ -122,14 +122,12 @@ class DashboardHome extends BaseDashboard implements Sortable
|
|||||||
}
|
}
|
||||||
|
|
||||||
$pane = $pane instanceof Pane ? $pane : $this->getEntry($pane);
|
$pane = $pane instanceof Pane ? $pane : $this->getEntry($pane);
|
||||||
if (! $pane->isOverriding()) {
|
$pane->removeEntries();
|
||||||
$pane->removeEntries();
|
|
||||||
|
|
||||||
Dashboard::getConn()->delete(Pane::TABLE, [
|
Dashboard::getConn()->delete(Pane::TABLE, [
|
||||||
'id = ?' => $pane->getUuid(),
|
'id = ?' => $pane->getUuid(),
|
||||||
'home_id = ?' => $this->getUuid()
|
'home_id = ?' => $this->getUuid()
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -192,44 +190,42 @@ class DashboardHome extends BaseDashboard implements Sortable
|
|||||||
/** @var Pane $pane */
|
/** @var Pane $pane */
|
||||||
foreach ($panes as $pane) {
|
foreach ($panes as $pane) {
|
||||||
$uuid = Dashboard::getSHA1($user->getUsername() . $this->getName() . $pane->getName());
|
$uuid = Dashboard::getSHA1($user->getUsername() . $this->getName() . $pane->getName());
|
||||||
if (! $pane->isOverriding()) {
|
if (! $this->hasEntry($pane->getName()) && (! $origin || ! $origin->hasEntry($pane->getName()))) {
|
||||||
if (! $this->hasEntry($pane->getName()) && (! $origin || ! $origin->hasEntry($pane->getName()))) {
|
$conn->insert(Pane::TABLE, [
|
||||||
$conn->insert(Pane::TABLE, [
|
'id' => $uuid,
|
||||||
'id' => $uuid,
|
'home_id' => $this->getUuid(),
|
||||||
'home_id' => $this->getUuid(),
|
'name' => $pane->getName(),
|
||||||
'name' => $pane->getName(),
|
'label' => $pane->getTitle(),
|
||||||
'label' => $pane->getTitle(),
|
'username' => $user->getUsername(),
|
||||||
'username' => $user->getUsername(),
|
'priority' => $order++
|
||||||
'priority' => $order++
|
]);
|
||||||
]);
|
} elseif (! $this->hasEntry($pane->getName()) || ! $origin || ! $origin->hasEntry($pane->getName())) {
|
||||||
} elseif (! $this->hasEntry($pane->getName()) || ! $origin || ! $origin->hasEntry($pane->getName())) {
|
$filterCondition = [
|
||||||
|
'id = ?' => $pane->getUuid(),
|
||||||
|
'home_id = ?' => $this->getUuid()
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($origin && $origin->hasEntry($pane->getName())) {
|
||||||
$filterCondition = [
|
$filterCondition = [
|
||||||
'id = ?' => $pane->getUuid(),
|
'id = ?' => $origin->getEntry($pane->getName())->getUuid(),
|
||||||
'home_id = ?' => $this->getUuid()
|
'home_id = ?' => $origin->getUuid()
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($origin && $origin->hasEntry($pane->getName())) {
|
|
||||||
$filterCondition = [
|
|
||||||
'id = ?' => $origin->getEntry($pane->getName())->getUuid(),
|
|
||||||
'home_id = ?' => $origin->getUuid()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->update(Pane::TABLE, [
|
|
||||||
'id' => $uuid,
|
|
||||||
'home_id' => $this->getUuid(),
|
|
||||||
'label' => $pane->getTitle(),
|
|
||||||
'priority' => $pane->getPriority()
|
|
||||||
], $filterCondition);
|
|
||||||
} else {
|
|
||||||
// Failed to move the pane! Should have been handled already by the caller
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pane->setHome($this);
|
$conn->update(Pane::TABLE, [
|
||||||
$pane->setUuid($uuid);
|
'id' => $uuid,
|
||||||
|
'home_id' => $this->getUuid(),
|
||||||
|
'label' => $pane->getTitle(),
|
||||||
|
'priority' => $pane->getPriority()
|
||||||
|
], $filterCondition);
|
||||||
|
} else {
|
||||||
|
// Failed to move the pane! Should have been handled already by the caller
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pane->setHome($this);
|
||||||
|
$pane->setUuid($uuid);
|
||||||
|
|
||||||
if ($manageRecursive) {
|
if ($manageRecursive) {
|
||||||
// Those dashboard panes are usually system defaults and go up when
|
// Those dashboard panes are usually system defaults and go up when
|
||||||
// the user is clicking on the "Use System Defaults" button
|
// the user is clicking on the "Use System Defaults" button
|
||||||
|
@ -9,7 +9,6 @@ use Icinga\Exception\ProgrammingError;
|
|||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Model;
|
use Icinga\Model;
|
||||||
use Icinga\Web\Dashboard\Common\DashboardControls;
|
use Icinga\Web\Dashboard\Common\DashboardControls;
|
||||||
use Icinga\Web\Dashboard\Common\OverridingWidget;
|
|
||||||
use Icinga\Web\Dashboard\Common\Sortable;
|
use Icinga\Web\Dashboard\Common\Sortable;
|
||||||
use ipl\Stdlib\Filter;
|
use ipl\Stdlib\Filter;
|
||||||
use ipl\Web\Url;
|
use ipl\Web\Url;
|
||||||
@ -19,26 +18,12 @@ use function ipl\Stdlib\get_php_type;
|
|||||||
/**
|
/**
|
||||||
* A pane, displaying different Dashboard dashlets
|
* A pane, displaying different Dashboard dashlets
|
||||||
*/
|
*/
|
||||||
class Pane extends BaseDashboard implements Sortable, OverridingWidget
|
class Pane extends BaseDashboard implements Sortable
|
||||||
{
|
{
|
||||||
use DashboardControls;
|
use DashboardControls;
|
||||||
|
|
||||||
const TABLE = 'dashboard';
|
const TABLE = 'dashboard';
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this widget overrides another widget
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of users who have subscribed to this pane if (public)
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $acceptance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dashboard home this pane is a part of
|
* A dashboard home this pane is a part of
|
||||||
*
|
*
|
||||||
@ -46,40 +31,6 @@ class Pane extends BaseDashboard implements Sortable, OverridingWidget
|
|||||||
*/
|
*/
|
||||||
protected $home;
|
protected $home;
|
||||||
|
|
||||||
public function override(bool $override)
|
|
||||||
{
|
|
||||||
$this->override = $override;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isOverriding()
|
|
||||||
{
|
|
||||||
return $this->override;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the number of users who have subscribed to this pane if (public)
|
|
||||||
*
|
|
||||||
* @param int $acceptance
|
|
||||||
*/
|
|
||||||
public function setAcceptance($acceptance)
|
|
||||||
{
|
|
||||||
$this->acceptance = $acceptance;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of users who have subscribed to this pane if (public)
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getAcceptance()
|
|
||||||
{
|
|
||||||
return $this->acceptance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the dashboard home this pane is a part of
|
* Get the dashboard home this pane is a part of
|
||||||
*
|
*
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
|
||||||
|
|
||||||
namespace Icinga\Web;
|
|
||||||
|
|
||||||
use Icinga\Model\Home;
|
|
||||||
use Icinga\Web\Dashboard\Dashboard;
|
|
||||||
use Icinga\Web\Dashboard\DashboardHome;
|
|
||||||
use Icinga\Web\Navigation\DashboardHomeItem;
|
|
||||||
use ipl\Stdlib\Filter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entrypoint of the dashboard homes
|
|
||||||
*/
|
|
||||||
class HomeMenu extends Menu
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
$this->initHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function initHome()
|
|
||||||
{
|
|
||||||
$user = Dashboard::getUser();
|
|
||||||
$dashboardItem = $this->getItem('dashboard');
|
|
||||||
|
|
||||||
$homes = Home::on(Dashboard::getConn());
|
|
||||||
$homes->filter(Filter::equal('username', $user->getUsername()));
|
|
||||||
|
|
||||||
foreach ($homes as $home) {
|
|
||||||
$dashboardHome = new DashboardHomeItem($home->name, [
|
|
||||||
'uuid' => $home->id,
|
|
||||||
'label' => t($home->label),
|
|
||||||
'priority' => $home->priority,
|
|
||||||
'type' => $home->type,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$dashboardItem->addChild($dashboardHome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load dashboard homes form the navigation menu
|
|
||||||
*
|
|
||||||
* @return DashboardHome[]
|
|
||||||
*/
|
|
||||||
public function loadHomes()
|
|
||||||
{
|
|
||||||
$homes = [];
|
|
||||||
foreach ($this->getItem('dashboard')->getChildren() as $child) {
|
|
||||||
if (! $child instanceof DashboardHomeItem) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$homes[$child->getName()] = DashboardHome::create($child);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $homes;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user