mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
parent
f6a2f6515d
commit
979bec24a5
@ -8,6 +8,7 @@ use Icinga\Application\Icinga;
|
|||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Icinga\File\Ini\IniWriter;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
use Icinga\Web\Widget\Dashboard\Pane;
|
use Icinga\Web\Widget\Dashboard\Pane;
|
||||||
use Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
use Icinga\Web\Widget\Dashboard\Component as DashboardComponent;
|
||||||
@ -80,6 +81,29 @@ class Dashboard extends AbstractWidget
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write user specific dashboards to disk
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$configFile = $this->getConfigFile();
|
||||||
|
$output = array();
|
||||||
|
foreach ($this->panes as $pane) {
|
||||||
|
if ($pane->isUserWidget() === true) {
|
||||||
|
$output[$pane->getName()] = $pane->toArray();
|
||||||
|
}
|
||||||
|
foreach ($pane->getComponents() as $component) {
|
||||||
|
if ($component->isUserWidget() === true) {
|
||||||
|
$output[$pane->getName() . '.' . $component->getTitle()] = $component->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = new Config($output);
|
||||||
|
$writer = new IniWriter(array('config' => $config, 'filename' => $configFile));
|
||||||
|
$writer->write();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -316,21 +340,30 @@ class Dashboard extends AbstractWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Icinga\User $user
|
* Setter for user object
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
public function setUser($user)
|
public function setUser(User $user)
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Icinga\User
|
* Getter for user object
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function getUser()
|
public function getUser()
|
||||||
{
|
{
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get config file
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getConfigFile()
|
public function getConfigFile()
|
||||||
{
|
{
|
||||||
if ($this->user === null) {
|
if ($this->user === null) {
|
||||||
|
@ -147,7 +147,13 @@ EOD;
|
|||||||
*/
|
*/
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
$array = array('url' => $this->url->getPath());
|
$array = array(
|
||||||
|
'url' => $this->url->getPath(),
|
||||||
|
'title' => $this->getTitle()
|
||||||
|
);
|
||||||
|
if ($this->getDisabled() === true) {
|
||||||
|
$array['disabled'] = 1;
|
||||||
|
}
|
||||||
foreach ($this->url->getParams()->toArray() as $param) {
|
foreach ($this->url->getParams()->toArray() as $param) {
|
||||||
$array[$param[0]] = $param[1];
|
$array[$param[0]] = $param[1];
|
||||||
}
|
}
|
||||||
|
@ -247,12 +247,9 @@ class Pane extends UserWidget
|
|||||||
*/
|
*/
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
$array = array($this->getName() => array('title' => $this->getTitle()));
|
return array(
|
||||||
foreach ($this->components as $title => $component) {
|
'title' => $this->getTitle()
|
||||||
$array[$this->getName() . ".$title"] = $component->toArray();
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return $array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user