From 1000b4661f70f65986a1798805f232dc089ed041 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Nov 2014 11:51:18 +0100 Subject: [PATCH 01/31] AddToDashboard: Remove controller logic refs #4537 --- .../controllers/DashboardController.php | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index d357231ca..fb8da0f5a 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -80,30 +80,8 @@ class DashboardController extends ActionController 'url' => Url::fromRequest() ) )->activate('addurl'); - $form = new AddUrlForm(); - $request = $this->getRequest(); - if ($request->isPost()) { - if ($form->isValid($request->getPost()) && $form->isSubmitted()) { - $dashboard = $this->getDashboard(); - $dashboard->setComponentUrl( - $form->getValue('pane'), - $form->getValue('component'), - ltrim($form->getValue('url'), '/') - ); - - $configFile = Config::app('dashboard/dashboard')->getConfigFile(); - if ($this->writeConfiguration(new Config($dashboard->toArray()), $configFile)) { - $this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane')))); - } else { - $this->render('showConfiguration'); - return; - } - } - } else { - $form->create()->setDefault('url', htmlspecialchars_decode($request->getParam('url', ''))); - } - + $form->handleRequest(); $this->view->form = $form; } From 5f9d394bbef0fd74fcf50148ff1c9dd0b33edae7 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Nov 2014 11:51:58 +0100 Subject: [PATCH 02/31] AddToDashboard: Form layout and template refa #4537 --- application/forms/Dashboard/AddUrlForm.php | 108 +++++++++++++----- .../views/scripts/dashboard/addurl.phtml | 8 +- 2 files changed, 82 insertions(+), 34 deletions(-) diff --git a/application/forms/Dashboard/AddUrlForm.php b/application/forms/Dashboard/AddUrlForm.php index 7f5a217d1..6ca5c23dd 100644 --- a/application/forms/Dashboard/AddUrlForm.php +++ b/application/forms/Dashboard/AddUrlForm.php @@ -7,6 +7,7 @@ namespace Icinga\Forms\Dashboard; use Icinga\Application\Config; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Form; +use Icinga\Web\Request; /** * Form to add an url a dashboard pane @@ -23,35 +24,49 @@ class AddUrlForm extends Form } /** + * Build AddUrl form elements + * * @see Form::createElements() */ public function createElements(array $formData) { + $paneSelectionValues = $this->getDashboardPaneSelectionValues(); + $groupElements = array(); + $this->addElement( 'text', 'url', array( - 'required' => true, - 'label' => t('Url'), - 'helptext' => t('The url being loaded in the dashlet') + 'required' => true, + 'label' => t('Url'), + 'description' => + t('Enter url being loaded in the dashlet. You can paste the full URL, including filters.') + ) + ); + $this->addElement( + 'text', + 'component', + array( + 'required' => true, + 'label' => t('Dashlet Title'), + 'description' => t('Enter a title for the dashlet.') ) ); - - $paneSelectionValues = $this->getDashboardPaneSelectionValues(); if (empty($paneSelectionValues) || ((isset($formData['create_new_pane']) && $formData['create_new_pane'] != false) && (false === isset($formData['use_existing_dashboard']) || $formData['use_existing_dashboard'] != true)) ) { - $this->addElement( + $groupElements[] = $this->createElement( 'text', 'pane', array( - 'required' => true, - 'label' => t("The New Pane's Title"), - 'style' => 'display: inline-block' + 'required' => true, + 'label' => t("New Pane Title"), + 'description' => + t('Enter a title for the new pane.') ) ); - $this->addElement( // Prevent the button from being displayed again on validation errors + $groupElements[] = $this->createElement( // Prevent the button from being displayed again on validation errors 'hidden', 'create_new_pane', array( @@ -59,45 +74,62 @@ class AddUrlForm extends Form ) ); if (false === empty($paneSelectionValues)) { - $this->addElement( + $buttonExistingPane = $this->createElement( 'submit', 'use_existing_dashboard', array( - 'ignore' => true, - 'label' => t('Use An Existing Pane'), - 'style' => 'display: inline-block' + 'ignore' => true, + 'label' => t('Use An Existing Pane'), + 'description' => + t('Click on the button to add the dashlet to an existing pane on your dashboard.') ) ); + $buttonExistingPane->removeDecorator('Label'); + $groupElements[] = $buttonExistingPane; } } else { - $this->addElement( + $groupElements[] = $this->createElement( 'select', 'pane', array( 'required' => true, 'label' => t('Pane'), - 'style' => 'display: inline-block;', - 'multiOptions' => $paneSelectionValues + 'multiOptions' => $paneSelectionValues, + 'description' => + t('Select a pane you want to add the dashlet.') ) ); - $this->addElement( + $buttonNewPane = $this->createElement( 'submit', 'create_new_pane', array( - 'ignore' => true, - 'label' => t('Create A New Pane'), - 'style' => 'display: inline-block' + 'ignore' => true, + 'label' => t('Create A New Pane'), + 'description' => + t('Click on the button if you want to add the dashlet to a new pane on the dashboard.') ) ); + $buttonNewPane->removeDecorator('Label'); + $groupElements[] = $buttonNewPane; } - - $this->addElement( - 'text', - 'component', + $this->addDisplayGroup( + $groupElements, + 'pane_group', array( - 'required' => true, - 'label' => t('Title'), - 'helptext' => t('The title for the dashlet') + 'legend' => t('Pane'), + 'description' => t( + 'Decide if you want add the dashlet to an existing pane' + . ' or create a new pane. Have a look on the button below.' + ), + 'decorators' => array( + 'FormElements', + array('HtmlTag', array('tag' => 'div', 'class' => 'control-group')), + array( + 'Description', + array('tag' => 'span', 'class' => 'description', 'placement' => 'prepend') + ), + 'Fieldset' + ) ) ); } @@ -113,4 +145,24 @@ class AddUrlForm extends Form $dashboard->readConfig(Config::app('dashboard/dashboard')); return $dashboard->getPaneKeyTitleArray(); } + + /** + * Adjust preferences and persist them + * + * @see Form::onSuccess() + */ + public function onSuccess(Request $request) + { + return false; + } + + /** + * Populate data if any + * + * @see Form::onRequest() + */ + public function onRequest(Request $request) + { + + } } diff --git a/application/views/scripts/dashboard/addurl.phtml b/application/views/scripts/dashboard/addurl.phtml index c2d3f7e6c..9c41a7713 100644 --- a/application/views/scripts/dashboard/addurl.phtml +++ b/application/views/scripts/dashboard/addurl.phtml @@ -3,10 +3,6 @@
-

escape($this->translate('This feature is deactivated at the moment.')); ?>

-

- escape($this->translate('Please have a little patience, we are hard working on it, take a look at icingaweb2 issues.')); - ?> -

+

+ form; ?>
\ No newline at end of file From af799d42dc28bbce5989fbbaf134c2142d31bf42 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Nov 2014 14:44:38 +0100 Subject: [PATCH 03/31] Widget/Dashboard: Cleanup object and remove unused stuff refs #4537 --- .../controllers/DashboardController.php | 79 +------ application/forms/Dashboard/AddUrlForm.php | 63 +++++- .../dashboard/show-configuration.phtml | 28 --- library/Icinga/Web/Widget/Dashboard.php | 199 +++++++----------- 4 files changed, 133 insertions(+), 236 deletions(-) delete mode 100644 application/views/scripts/dashboard/show-configuration.phtml diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index fb8da0f5a..bf94e26af 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -20,54 +20,6 @@ use Icinga\Web\Widget\Dashboard; */ class DashboardController extends ActionController { - /** - * Default configuration - */ - const DEFAULT_CONFIG = 'dashboard/dashboard'; - - /** - * Retrieve a dashboard from the provided config - * - * @param string $config The config to read the dashboard from, or 'dashboard/dashboard' if none is given - * - * @return \Icinga\Web\Widget\Dashboard - */ - private function getDashboard($config = self::DEFAULT_CONFIG) - { - $dashboard = new Dashboard(); - try { - $dashboardConfig = Config::app($config); - if (count($dashboardConfig) === 0) { - return null; - } - $dashboard->readConfig($dashboardConfig); - } catch (NotReadableError $e) { - Logger::error(new IcingaException('Cannot load dashboard configuration. An exception was thrown:', $e)); - return null; - } - return $dashboard; - } - - /** - * Remove a component from the pane identified by the 'pane' parameter - */ - public function removecomponentAction() - { - $pane = $this->_getParam('pane'); - $dashboard = $this->getDashboard(); - try { - $dashboard->removeComponent( - $pane, - $this->_getParam('component') - )->store(); - $this->redirectNow(Url::fromPath('dashboard', array('pane' => $pane))); - } catch (ConfigurationError $exc ) { - $this->_helper->viewRenderer('show_configuration'); - $this->view->exceptionMessage = $exc->getMessage(); - $this->view->iniConfigurationString = $dashboard->toIni(); - } - } - /** * Display the form for adding new components or add the new component if submitted */ @@ -93,7 +45,9 @@ class DashboardController extends ActionController */ public function indexAction() { - $dashboard = Dashboard::load(); + $dashboard = new Dashboard(); + $dashboard->setUser($this->getRequest()->getUser()); + $dashboard->load(); if (! $dashboard->hasPanes()) { $this->view->title = 'Dashboard'; @@ -103,8 +57,6 @@ class DashboardController extends ActionController $dashboard->activate($pane); } - $this->view->configPath = Config::resolvePath(self::DEFAULT_CONFIG); - if ($dashboard === null) { $this->view->title = 'Dashboard'; } else { @@ -125,29 +77,4 @@ class DashboardController extends ActionController } } } - - /** - * Store the given configuration as INI file - * - * @param Config $config The configuration to store - * @param string $target The path where to store the configuration - * - * @return bool Whether the configuartion has been successfully stored - */ - protected function writeConfiguration(Config $config, $target) - { - $writer = new IniWriter(array('config' => $config, 'filename' => $target)); - - try { - $writer->write(); - } catch (Exception $e) { - Logger::error(new ConfiguationError("Cannot write dashboard to $target", 0, $e)); - $this->view->configString = $writer->render(); - $this->view->errorMessage = $e->getMessage(); - $this->view->filePath = $target; - return false; - } - - return true; - } } diff --git a/application/forms/Dashboard/AddUrlForm.php b/application/forms/Dashboard/AddUrlForm.php index 6ca5c23dd..b881ad237 100644 --- a/application/forms/Dashboard/AddUrlForm.php +++ b/application/forms/Dashboard/AddUrlForm.php @@ -5,6 +5,7 @@ namespace Icinga\Forms\Dashboard; use Icinga\Application\Config; +use Icinga\File\Ini\IniWriter; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Form; use Icinga\Web\Request; @@ -14,6 +15,13 @@ use Icinga\Web\Request; */ class AddUrlForm extends Form { + /** + * Config file name + * + * @var string + */ + private $configFile = 'dashboard/dashboard'; + /** * Initialize this form */ @@ -134,16 +142,42 @@ class AddUrlForm extends Form ); } + /** + * Create a dashboard object + * + * @return Dashboard + */ + private function createDashboard() + { + $dashboard = new Dashboard(); + $dashboard->readConfig(Config::app($this->getConfigFile())); + return $dashboard; + } + /** * Return the names and titles of the available dashboard panes as key-value array * * @return array */ - protected function getDashboardPaneSelectionValues() + private function getDashboardPaneSelectionValues() { - $dashboard = new Dashboard(); - $dashboard->readConfig(Config::app('dashboard/dashboard')); - return $dashboard->getPaneKeyTitleArray(); + return $this->createDashboard()->getPaneKeyTitleArray(); + } + + /** + * @param string $configFile + */ + public function setConfigFile($configFile) + { + $this->configFile = $configFile; + } + + /** + * @return string + */ + public function getConfigFile() + { + return $this->configFile; } /** @@ -153,6 +187,22 @@ class AddUrlForm extends Form */ public function onSuccess(Request $request) { + $dashboard = $this->createDashboard(); + $dashboard->setComponentUrl( + $this->getValue('pane'), + $this->getValue('component'), + ltrim($this->getValue('url'), '/') + ); + /* + $writer = new IniWriter( + array( + 'config' => new Config($dashboard->toArray()), + 'filename' => $dashboard->getConfig()->getConfigFile() + ) + ); + + $writer->write(); + */ return false; } @@ -163,6 +213,9 @@ class AddUrlForm extends Form */ public function onRequest(Request $request) { - + $data = array( + 'url' => $request->getParam('url') + ); + $this->populate($data); } } diff --git a/application/views/scripts/dashboard/show-configuration.phtml b/application/views/scripts/dashboard/show-configuration.phtml deleted file mode 100644 index 7cdce496c..000000000 --- a/application/views/scripts/dashboard/show-configuration.phtml +++ /dev/null @@ -1,28 +0,0 @@ -
-
-

{{WARNING_ICON}}Saving Dashboard Failed

-
-

- Your dashboard couldn't be stored (error: "exceptionMessage; ?>"). This could have one or more - of the following reasons: -

-
    -
  • You don't have permissions to write to the dashboard file
  • -
  • Something went wrong while writing the file
  • -
  • There's an application error preventing you from persisting the configuration
  • -
-
- -

- Details can be seen in your application log (if you don't have access to this file, call your administrator in this case). -
- In case you can access the configuration file (config/dashboard/dashboard.ini) by yourself, you can open it and - insert the config manually: -

-

-

-        
-escape($this->iniConfigurationString); ?>
-        
-    
-

\ No newline at end of file diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 0221e4744..0fdb61d33 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -8,6 +8,7 @@ use Icinga\Application\Icinga; use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; use Icinga\Exception\ProgrammingError; +use Icinga\User; use Icinga\Web\Widget\Dashboard\Pane; use Icinga\Web\Widget\Dashboard\Component as DashboardComponent; use Icinga\Web\Url; @@ -23,13 +24,6 @@ use Icinga\Web\Url; */ class Dashboard extends AbstractWidget { - /** - * The configuration containing information about this dashboard - * - * @var Config; - */ - private $config; - /** * An array containing all panes of this dashboard * @@ -51,6 +45,11 @@ class Dashboard extends AbstractWidget */ private $tabParam = 'pane'; + /** + * @var User + */ + private $user; + /** * Set the given tab name as active. * @@ -67,24 +66,72 @@ class Dashboard extends AbstractWidget * * @return self */ - public static function load() + public function load() { - /** @var $dashboard Dashboard */ - $dashboard = new static('dashboard'); $manager = Icinga::app()->getModuleManager(); foreach ($manager->getLoadedModules() as $module) { /** @var $module \Icinga\Application\Modules\Module */ - $dashboard->mergePanes($module->getPaneItems()); + $this->mergePanes($module->getPaneItems()); } - return $dashboard; + if ($this->user !== null) { + $this->loadUserDashboards(); + } + return $this; + } + + /** + * @return bool + */ + private function loadUserDashboards() + { + $configFile = '/var/lib/icingaweb/' . $this->user->getUsername() . '/dashboard.ini'; + $config = Config::fromIni($configFile); + if (! count($config)) { + return false; + } + $panes = array(); + $components = array(); + foreach ($config as $key => $part) { + if (strpos($key, '.') === false) { + $panes[$key] = new Pane($key); + $panes[$key]->setTitle($part->title); + + } else { + list($paneName, $componentName) = explode('.', $key, 2); + $part->pane = $paneName; + $part->component = $componentName; + $components[] = $part; + } + } + foreach ($components as $componentData) { + $pane = null; + + if (array_key_exists($componentData->pane, $panes) === true) { + $pane = $panes[$componentData->pane]; + } elseif (array_key_exists($componentData->pane, $this->panes) === true) { + $pane = $this->panes[$componentData->pane]; + } else { + continue; + } + $pane->addComponent( + new DashboardComponent( + $componentData->title, + $componentData->url, + $pane + ) + ); + } + $this->mergePanes($panes); + return true; } /** * Merge panes with existing panes * - * @param array $panes - * @return $this + * @param array $panes + * + * @return $this */ public function mergePanes(array $panes) { @@ -134,23 +181,10 @@ class Dashboard extends AbstractWidget */ public function getPanes() { + return ''; return $this->panes; } - /** - * Populate this dashboard via the given configuration file - * - * @param Config $config The configuration file to populate this dashboard with - * - * @return self - */ - public function readConfig(Config $config) - { - $this->config = $config; - $this->panes = array(); - $this->loadConfigPanes(); - return $this; - } /** * Creates a new empty pane with the given title @@ -168,34 +202,6 @@ class Dashboard extends AbstractWidget return $this; } - /** - * Update or adds a new component with the given url to a pane - * - * @TODO: Should only allow component objects to be added directly as soon as we store more information - * - * @param string $pane The pane to add the component to - * @param Component|string $component The component to add or the title of the newly created component - * @param string|null $url The url to use for the component - * - * @return self - */ - public function setComponentUrl($pane, $component, $url) - { - if ($component === null && strpos($pane, '.')) { - list($pane, $component) = preg_split('~\.~', $pane, 2); - } - if (!isset($this->panes[$pane])) { - $this->createPane($pane); - } - $pane = $this->getPane($pane); - if ($pane->hasComponent($component)) { - $pane->getComponent($component)->setUrl($url); - } else { - $pane->addComponent($component, $url); - } - return $this; - } - /** * Checks if the current dashboard has any panes * @@ -206,52 +212,6 @@ class Dashboard extends AbstractWidget return ! empty($this->panes); } - /** - * Check if this dashboard has a specific pane - * - * @param $pane string The name of the pane - * @return bool - */ - public function hasPane($pane) - { - return array_key_exists($pane, $this->panes); - } - - /** - * Remove a component $component from the given pane - * - * @param string $pane The pane to remove the component from - * @param Component|string $component The component to remove or it's name - * - * @return self - */ - public function removeComponent($pane, $component) - { - if ($component === null && strpos($pane, '.')) { - list($pane, $component) = preg_split('~\.~', $pane, 2); - } - $pane = $this->getPane($pane); - if ($pane !== null) { - $pane->removeComponent($component); - } - - return $this; - } - - /** - * Return an array with pane name=>title format used for comboboxes - * - * @return array - */ - public function getPaneKeyTitleArray() - { - $list = array(); - foreach ($this->panes as $name => $pane) { - $list[$name] = $pane->getTitle(); - } - return $list; - } - /** * Add a pane object to this dashboard * @@ -319,7 +279,10 @@ class Dashboard extends AbstractWidget /** * Determine the active pane either by the selected tab or the current request * - * @return Pane The currently active pane + * @throws \Icinga\Exception\ConfigurationError + * @throws \Icinga\Exception\ProgrammingError + * + * @return Pane The currently active pane */ public function determineActivePane() { @@ -346,36 +309,18 @@ class Dashboard extends AbstractWidget } /** - * Return this dashboard's structure as array - * - * @return array + * @param \Icinga\User $user */ - public function toArray() + public function setUser($user) { - $array = array(); - foreach ($this->panes as $pane) { - $array += $pane->toArray(); - } - - return $array; + $this->user = $user; } /** - * Load all config panes from @see Dashboard::$config - * + * @return \Icinga\User */ - private function loadConfigPanes() + public function getUser() { - $items = $this->config; - foreach ($items->keys() as $key) { - $item = $this->config->get($key, false); - if (false === strstr($key, '.')) { - $this->addPane(Pane::fromIni($key, $item)); - } else { - list($paneName, $title) = explode('.', $key, 2); - $pane = $this->getPane($paneName); - $pane->addComponent(DashboardComponent::fromIni($title, $item, $pane)); - } - } + return $this->user; } } From f6a2f6515dff0a4ce5f32e299c9ce21ff8bbe0ad Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Nov 2014 15:38:51 +0100 Subject: [PATCH 04/31] Dashboard: Introduce user flag widget Fix: Do not render disabled components. refs #4537 --- library/Icinga/Web/Widget/Dashboard.php | 31 ++++++++++++---- .../Icinga/Web/Widget/Dashboard/Component.php | 2 +- library/Icinga/Web/Widget/Dashboard/Pane.php | 10 ++++- .../Web/Widget/Dashboard/UserWidget.php | 37 +++++++++++++++++++ 4 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 library/Icinga/Web/Widget/Dashboard/UserWidget.php diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 0fdb61d33..866dfe3ca 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -85,8 +85,7 @@ class Dashboard extends AbstractWidget */ private function loadUserDashboards() { - $configFile = '/var/lib/icingaweb/' . $this->user->getUsername() . '/dashboard.ini'; - $config = Config::fromIni($configFile); + $config = Config::fromIni($this->getConfigFile()); if (! count($config)) { return false; } @@ -96,6 +95,7 @@ class Dashboard extends AbstractWidget if (strpos($key, '.') === false) { $panes[$key] = new Pane($key); $panes[$key]->setTitle($part->title); + $panes[$key]->setUserWidget(); } else { list($paneName, $componentName) = explode('.', $key, 2); @@ -114,15 +114,22 @@ class Dashboard extends AbstractWidget } else { continue; } - $pane->addComponent( - new DashboardComponent( - $componentData->title, - $componentData->url, - $pane - ) + $component = new DashboardComponent( + $componentData->title, + $componentData->url, + $pane ); + + if ((bool) $componentData->get('disabled', false) === true) { + $component->setDisabled(true); + } + + $component->setUserWidget(); + $pane->addComponent($component); } + $this->mergePanes($panes); + return true; } @@ -323,4 +330,12 @@ class Dashboard extends AbstractWidget { return $this->user; } + + public function getConfigFile() + { + if ($this->user === null) { + return ''; + } + return '/var/lib/icingaweb/' . $this->user->getUsername() . '/dashboard.ini'; + } } diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 6edf140f5..0017ce9e3 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -17,7 +17,7 @@ use Icinga\Exception\IcingaException; * This is the element displaying a specific view in icinga2web * */ -class Component extends AbstractWidget +class Component extends UserWidget { /** * The url of this Component diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 3b0e97c73..04073411a 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -12,7 +12,7 @@ use Icinga\Exception\ConfigurationError; /** * A pane, displaying different Dashboard components */ -class Pane extends AbstractWidget +class Pane extends UserWidget { /** * The name of this pane, as defined in the ini file @@ -168,7 +168,13 @@ class Pane extends AbstractWidget */ public function render() { - return implode("\n", $this->components) . "\n"; + $components = array_filter( + $this->components, + function ($e) { + return ! $e->getDisabled(); + } + ); + return implode("\n", $components) . "\n"; } /** diff --git a/library/Icinga/Web/Widget/Dashboard/UserWidget.php b/library/Icinga/Web/Widget/Dashboard/UserWidget.php new file mode 100644 index 000000000..0b171964e --- /dev/null +++ b/library/Icinga/Web/Widget/Dashboard/UserWidget.php @@ -0,0 +1,37 @@ +userWidget = (bool) $userWidget; + } + + /** + * Getter for user widget flag + * + * @return boolean + */ + public function isUserWidget() + { + return $this->userWidget; + } +} From 979bec24a555b2e7b387fd0dd0a3ec72a168bf3e Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Nov 2014 15:59:59 +0100 Subject: [PATCH 05/31] Dashboard: Write user dashboards to disk refs #4537 --- library/Icinga/Web/Widget/Dashboard.php | 39 +++++++++++++++++-- .../Icinga/Web/Widget/Dashboard/Component.php | 8 +++- library/Icinga/Web/Widget/Dashboard/Pane.php | 9 ++--- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 866dfe3ca..f8cc54625 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -8,6 +8,7 @@ use Icinga\Application\Icinga; use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; use Icinga\Exception\ProgrammingError; +use Icinga\File\Ini\IniWriter; use Icinga\User; use Icinga\Web\Widget\Dashboard\Pane; use Icinga\Web\Widget\Dashboard\Component as DashboardComponent; @@ -80,6 +81,29 @@ class Dashboard extends AbstractWidget 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 */ @@ -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; } /** - * @return \Icinga\User + * Getter for user object + * + * @return User */ public function getUser() { return $this->user; } + /** + * Get config file + * + * @return string + */ public function getConfigFile() { if ($this->user === null) { diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 0017ce9e3..17734478c 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -147,7 +147,13 @@ EOD; */ 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) { $array[$param[0]] = $param[1]; } diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 04073411a..8119eaf66 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -247,12 +247,9 @@ class Pane extends UserWidget */ public function toArray() { - $array = array($this->getName() => array('title' => $this->getTitle())); - foreach ($this->components as $title => $component) { - $array[$this->getName() . ".$title"] = $component->toArray(); - } - - return $array; + return array( + 'title' => $this->getTitle() + ); } /** From b679c1e7701fddfe803e364917d0e3070c43c790 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Nov 2014 16:04:51 +0100 Subject: [PATCH 06/31] Dashboard: Refactor search/replace implementation refs #4537 --- .../Icinga/Web/Widget/Dashboard/Component.php | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 17734478c..46b49ebec 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -175,13 +175,25 @@ EOD; $iframeUrl = clone($url); $iframeUrl->setParam('isIframe'); - $html = str_replace('{URL}', $url, $this->template); - $html = str_replace('{IFRAME_URL}', $iframeUrl, $html); - $html = str_replace('{FULL_URL}', $url->getUrlWithout(array('view', 'limit')), $html); - $html = str_replace('{REMOVE_BTN}', $this->getRemoveForm($view), $html); - $html = str_replace('{TITLE}', $view->escape($this->getTitle()), $html); - $html = str_replace('{REMOVE}', $this->getRemoveForm(), $html); - return $html; + $searchTokens = array( + '{URL}', + '{IFRAME_URL}', + '{FULL_URL}', + '{REMOVE_BTN}', + '{TITLE}', + '{REMOVE}' + ); + + $replaceTokens = array( + $url, + $iframeUrl, + $url->getUrlWithout(array('view', 'limit')), + $this->getRemoveForm($view), + $view->escape($this->getTitle()), + $this->getRemoveForm() + ); + + return str_replace($searchTokens, $replaceTokens, $this->template); } /** From 769e8f263617d3c2930414fc0b1226f527c6b2e6 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 11 Nov 2014 16:35:35 +0100 Subject: [PATCH 07/31] Dashboard/Component: Add remove link refs #4537 --- .../controllers/DashboardController.php | 6 ++++ .../Icinga/Web/Widget/Dashboard/Component.php | 35 ++++--------------- library/Icinga/Web/Widget/Dashboard/Pane.php | 8 ++++- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index bf94e26af..fd06e62ea 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -63,6 +63,12 @@ class DashboardController extends ActionController $this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard'; $this->view->tabs = $dashboard->getTabs(); + if ($this->hasParam('remove')) { + $dashboard->getActivePane()->removeComponent($this->getParam('remove')); + $dashboard->write(); + $this->redirectNow(URL::fromRequest()->remove('remove')); + } + /* Temporarily removed $this->view->tabs->add( 'Add', diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 46b49ebec..693f60bfe 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -53,7 +53,7 @@ class Component extends UserWidget private $template =<<<'EOD'
-

{REMOVE}{TITLE}

+

{TITLE} ({REMOVE})

@@ -179,7 +179,6 @@ EOD; '{URL}', '{IFRAME_URL}', '{FULL_URL}', - '{REMOVE_BTN}', '{TITLE}', '{REMOVE}' ); @@ -188,9 +187,8 @@ EOD; $url, $iframeUrl, $url->getUrlWithout(array('view', 'limit')), - $this->getRemoveForm($view), $view->escape($this->getTitle()), - $this->getRemoveForm() + $this->getRemoveLink() ); return str_replace($searchTokens, $replaceTokens, $this->template); @@ -201,32 +199,13 @@ EOD; * * @return string The html representation of the form */ - protected function getRemoveForm() + protected function getRemoveLink() { - // TODO: temporarily disabled, should point to a form asking for confirmal - return ''; - $removeUrl = Url::fromPath( - '/dashboard/removecomponent', - array( - 'pane' => $this->pane->getName(), - 'component' => $this->getTitle() - ) + return sprintf( + '%s', + Url::fromRequest(array('remove' => $this->getTitle())), + t('Remove') ); - $form = new Form(); - $form->setMethod('POST'); - $form->setAttrib('class', 'inline'); - $form->setAction($removeUrl); - $form->addElement( - new Zend_Form_Element_Button( - 'remove_pane_btn', - array( - 'class'=> 'link-like pull-right', - 'type' => 'submit', - 'label' => 'x' - ) - ) - ); - return $form; } /** diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 8119eaf66..26cd46e44 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -130,7 +130,13 @@ class Pane extends UserWidget public function removeComponent($title) { if ($this->hasComponent($title)) { - unset($this->components[$title]); + $component = $this->getComponent($title); + if ($component->isUserWidget() === true) { + unset($this->components[$title]); + } else { + $component->setUserWidget(); + $component->setDisabled(true); + } } return $this; } From bec0085683558b569316218a8a49b764b2fdabb3 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 12 Nov 2014 09:22:39 +0100 Subject: [PATCH 08/31] Dashboard: Add urls to any dashboard (form) refs #4537 --- .../controllers/DashboardController.php | 7 + application/forms/Dashboard/AddUrlForm.php | 120 ++++++++++-------- library/Icinga/Web/Widget/Dashboard.php | 14 ++ 3 files changed, 87 insertions(+), 54 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index fd06e62ea..6e4dd8cc2 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -32,7 +32,14 @@ class DashboardController extends ActionController 'url' => Url::fromRequest() ) )->activate('addurl'); + $form = new AddUrlForm(); + + $dashboard = new Dashboard(); + $dashboard->setUser($this->getRequest()->getUser()); + $dashboard->load(); + $form->setDashboard($dashboard); + $form->setRedirectUrl($this->getParam('url')); $form->handleRequest(); $this->view->form = $form; } diff --git a/application/forms/Dashboard/AddUrlForm.php b/application/forms/Dashboard/AddUrlForm.php index b881ad237..f67c92a42 100644 --- a/application/forms/Dashboard/AddUrlForm.php +++ b/application/forms/Dashboard/AddUrlForm.php @@ -5,7 +5,9 @@ namespace Icinga\Forms\Dashboard; use Icinga\Application\Config; +use Icinga\Exception\ProgrammingError; use Icinga\File\Ini\IniWriter; +use Icinga\Web\Url; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Form; use Icinga\Web\Request; @@ -22,6 +24,11 @@ class AddUrlForm extends Form */ private $configFile = 'dashboard/dashboard'; + /** + * @var Dashboard + */ + private $dashboard; + /** * Initialize this form */ @@ -38,7 +45,12 @@ class AddUrlForm extends Form */ public function createElements(array $formData) { - $paneSelectionValues = $this->getDashboardPaneSelectionValues(); + $paneSelectionValues = array(); + + if ($this->dashboard !== null) { + $paneSelectionValues = $this->dashboard->getPaneKeyTitleArray(); + } + $groupElements = array(); $this->addElement( @@ -142,44 +154,6 @@ class AddUrlForm extends Form ); } - /** - * Create a dashboard object - * - * @return Dashboard - */ - private function createDashboard() - { - $dashboard = new Dashboard(); - $dashboard->readConfig(Config::app($this->getConfigFile())); - return $dashboard; - } - - /** - * Return the names and titles of the available dashboard panes as key-value array - * - * @return array - */ - private function getDashboardPaneSelectionValues() - { - return $this->createDashboard()->getPaneKeyTitleArray(); - } - - /** - * @param string $configFile - */ - public function setConfigFile($configFile) - { - $this->configFile = $configFile; - } - - /** - * @return string - */ - public function getConfigFile() - { - return $this->configFile; - } - /** * Adjust preferences and persist them * @@ -187,23 +161,34 @@ class AddUrlForm extends Form */ public function onSuccess(Request $request) { - $dashboard = $this->createDashboard(); - $dashboard->setComponentUrl( - $this->getValue('pane'), + $pane = null; + + if ($this->dashboard === null) { + throw new ProgrammingError('Dashboard is not set, can not write values'); + } + + try { + $pane = $this->dashboard->getPane($this->getValue('pane')); + } catch (ProgrammingError $e) { + $pane = new Dashboard\Pane($this->getValue('pane')); + $pane->setUserWidget(); + $this->dashboard->addPane($pane); + } + + $component = new Dashboard\Component( $this->getValue('component'), - ltrim($this->getValue('url'), '/') - ); - /* - $writer = new IniWriter( - array( - 'config' => new Config($dashboard->toArray()), - 'filename' => $dashboard->getConfig()->getConfigFile() - ) + $this->getValue('url'), + $pane ); - $writer->write(); - */ - return false; + $component->setUserWidget(); + + $pane->addComponent($component); + + $this->dashboard->write(); + + + return true; } /** @@ -213,9 +198,36 @@ class AddUrlForm extends Form */ public function onRequest(Request $request) { + // TODO(mh): Im not sure if this is the right place for that + $url = $this->getValue('url'); + if (! $url) { + $url = $request->getParam('url'); + } + + if (! $url) { + return; + } + $data = array( - 'url' => $request->getParam('url') + 'url' => urldecode(Url::fromPath($url)->getPath()) ); + $this->populate($data); } + + /** + * @param Dashboard $dashboard + */ + public function setDashboard(Dashboard $dashboard) + { + $this->dashboard = $dashboard; + } + + /** + * @return Dashboard + */ + public function getDashboard() + { + return $this->dashboard; + } } diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index f8cc54625..1a049ef59 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -275,6 +275,20 @@ class Dashboard extends AbstractWidget return $this->panes[$name]; } + /** + * Return an array with pane name=>title format used for comboboxes + * + * @return array + */ + public function getPaneKeyTitleArray() + { + $list = array(); + foreach ($this->panes as $name => $pane) { + $list[$name] = $pane->getTitle(); + } + return $list; + } + /** * @see Icinga\Web\Widget::render */ From 89b36f79b2e5ab48761ce3f6fc5a292538405465 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 12 Nov 2014 12:02:05 +0100 Subject: [PATCH 09/31] Dashboard: Reenable generic add link in tab bar refs #4537 --- application/controllers/DashboardController.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 6e4dd8cc2..2c2b7d2fd 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -63,20 +63,16 @@ class DashboardController extends ActionController $pane = $this->_getParam('pane'); $dashboard->activate($pane); } - if ($dashboard === null) { $this->view->title = 'Dashboard'; } else { $this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard'; $this->view->tabs = $dashboard->getTabs(); - if ($this->hasParam('remove')) { $dashboard->getActivePane()->removeComponent($this->getParam('remove')); $dashboard->write(); $this->redirectNow(URL::fromRequest()->remove('remove')); } - - /* Temporarily removed $this->view->tabs->add( 'Add', array( @@ -84,8 +80,6 @@ class DashboardController extends ActionController 'url' => Url::fromPath('dashboard/addurl') ) ); - */ - $this->view->dashboard = $dashboard; } } From 47414f352839b2cfcd34042fbdb0e885da692694 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 4 Nov 2014 16:15:06 +0100 Subject: [PATCH 10/31] Introduce Form::setOnSuccess() in favor of overriding the constructor Zend_Form uses setters for options if a respective setter method exists. It is not necessary to override the constructor for introducing new options. --- library/Icinga/Web/Form.php | 140 ++++++++++++------------------------ 1 file changed, 47 insertions(+), 93 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 20484c33e..787e8dc27 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -11,7 +11,6 @@ use Zend_View_Interface; use Icinga\Application\Icinga; use Icinga\Web\Form\Decorator\NoScriptApply; use Icinga\Web\Form\Element\CsrfCounterMeasure; -use Icinga\Web\Form\FormElement; /** * Base class for forms providing CSRF protection, confirmation logic and auto submission @@ -37,13 +36,6 @@ class Form extends Zend_Form */ protected $created = false; - /** - * The request associated with this form - * - * @var Request - */ - protected $request; - /** * The callback to call instead of Form::onSuccess() * @@ -108,38 +100,31 @@ class Form extends Zend_Form * @var array */ public static $defaultElementDecorators = array( - array('ViewHelper', array('separator' => '')), - array('Errors', array('separator' => '')), - array('Description', array('tag' => 'span', 'class' => 'description', 'separator' => '')), - array('Label', array('separator' => '')), - array('HtmlTag', array('tag' => 'div', 'class' => 'element')) + 'ViewHelper', + 'Errors', + array('Description', array('tag' => 'span', 'class' => 'description')), + 'Label', + array('HtmlTag', array('tag' => 'div')) ); /** - * Create a new form + * Set a callback that is called instead of this form's onSuccess method * - * Accepts an additional option `onSuccess' which is a callback that is called instead of this - * form's method. It is called using the following signature: (Form $form). + * It is called using the following signature: (Request $request, Form $form). * - * @see Zend_Form::__construct() + * @param callable $onSuccess Callback * - * @throws LogicException In case `onSuccess' is not callable + * @return $this + * + * @throws LogicException If the callback is not callable */ - public function __construct($options = null) + public function setOnSuccess($onSuccess) { - if (is_array($options) && isset($options['onSuccess'])) { - $this->onSuccess = $options['onSuccess']; - unset($options['onSuccess']); - } elseif (isset($options->onSuccess)) { - $this->onSuccess = $options->onSuccess; - unset($options->onSuccess); - } - - if ($this->onSuccess !== null && false === is_callable($this->onSuccess)) { + if (! is_callable($onSuccess)) { throw new LogicException('The option `onSuccess\' is not callable'); } - - parent::__construct($options); + $this->onSuccess = $onSuccess; + return $this; } /** @@ -363,9 +348,11 @@ class Form extends Zend_Form * * Intended to be implemented by concrete form classes. The base implementation returns always FALSE. * + * @param Request $request The valid request used to process this form + * * @return null|bool Return FALSE in case no redirect should take place */ - public function onSuccess() + public function onSuccess(Request $request) { return false; } @@ -374,8 +361,10 @@ class Form extends Zend_Form * Perform actions when no form dependent data was sent * * Intended to be implemented by concrete form classes. + * + * @param Request $request The current request */ - public function onRequest() + public function onRequest(Request $request) { } @@ -441,8 +430,8 @@ class Form extends Zend_Form * `disableLoadDefaultDecorators' option to any other value than `true'. For loading custom element decorators use * the 'decorators' option. * - * @param string $type The type of the element - * @param string $name The name of the element + * @param string $type String element type + * @param string $name The name of the element to add * @param mixed $options The options for the element * * @return Zend_Form_Element @@ -464,20 +453,10 @@ class Form extends Zend_Form $options = array('decorators' => static::$defaultElementDecorators); } - if (($el = $this->createIcingaFormElement($type, $name, $options)) === null) { - $el = parent::createElement($type, $name, $options); - } + $el = parent::createElement($type, $name, $options); if ($el && $el->getAttrib('autosubmit')) { - $noScript = new NoScriptApply(); // Non-JS environments - $decorators = $el->getDecorators(); - $pos = array_search('Zend_Form_Decorator_ViewHelper', array_keys($decorators)) + 1; - $el->setDecorators( - array_slice($decorators, 0, $pos, true) - + array(get_class($noScript) => $noScript) - + array_slice($decorators, $pos, count($decorators) - $pos, true) - ); - + $el->addDecorator(new NoScriptApply()); // Non-JS environments $class = $el->getAttrib('class'); if (is_array($class)) { $class[] = 'autosubmit'; @@ -487,7 +466,6 @@ class Form extends Zend_Form $class .= ' autosubmit'; } $el->setAttrib('class', $class); // JS environments - unset($el->autosubmit); } @@ -555,17 +533,15 @@ class Form extends Zend_Form { if ($request === null) { $request = $this->getRequest(); - } else { - $this->request = $request; } - $formData = $this->getRequestData(); + $formData = $this->getRequestData($request); if ($this->getUidDisabled() || $this->wasSent($formData)) { $this->populate($formData); // Necessary to get isSubmitted() to work if (! $this->getSubmitLabel() || $this->isSubmitted()) { if ($this->isValid($formData) - && (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this)) - || ($this->onSuccess === null && false !== $this->onSuccess()))) { + && (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $request, $this)) + || ($this->onSuccess === null && false !== $this->onSuccess($request)))) { $this->getResponse()->redirectAndExit($this->getRedirectUrl()); } } else { @@ -573,7 +549,7 @@ class Form extends Zend_Form $this->isValidPartial($formData); } } else { - $this->onRequest(); + $this->onRequest($request); } return $request; @@ -699,19 +675,29 @@ class Form extends Zend_Form } /** - * Return the request associated with this form + * Return the request data based on this form's request method * - * Returns the global request if none has been set for this form yet. + * @param Request $request The request to fetch the data from + * + * @return array + */ + public function getRequestData(Request $request) + { + if (strtolower($request->getMethod()) === $this->getMethod()) { + return $request->{'get' . ($request->isPost() ? 'Post' : 'Query')}(); + } + + return array(); + } + + /** + * Return the current request * * @return Request */ public function getRequest() { - if ($this->request === null) { - $this->request = Icinga::app()->getFrontController()->getRequest(); - } - - return $this->request; + return Icinga::app()->getFrontController()->getRequest(); } /** @@ -724,39 +710,6 @@ class Form extends Zend_Form return Icinga::app()->getFrontController()->getResponse(); } - /** - * Return the request data based on this form's request method - * - * @return array - */ - protected function getRequestData() - { - if (strtolower($this->request->getMethod()) === $this->getMethod()) { - return $this->request->{'get' . ($this->request->isPost() ? 'Post' : 'Query')}(); - } - - return array(); - } - - /** - * Create a new element located in the Icinga Web 2 library - * - * @param string $type The type of the element - * @param string $name The name of the element - * @param mixed $options The options for the element - * - * @return NULL|FormElement NULL in case the element is not found in the Icinga Web 2 library - * - * @see Form::$defaultElementDecorators For Icinga Web 2's default element decorators. - */ - protected function createIcingaFormElement($type, $name, $options = null) - { - $className = 'Icinga\\Web\\Form\\Element\\' . ucfirst($type); - if (class_exists($className)) { - return new $className($name, $options); - } - } - /** * Render this form * @@ -770,3 +723,4 @@ class Form extends Zend_Form return parent::render($view); } } + From cbcd276b44f437c24df69c36298fcea46743cf9f Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 18 Nov 2014 09:50:10 +0100 Subject: [PATCH 11/31] Dashboard: Rewrite forms and controller [WIP] refs #4537 --- .../controllers/DashboardController.php | 143 ++++++++++++++---- .../{AddUrlForm.php => ComponentForm.php} | 104 ++++++------- .../scripts/dashboard/new-component.phtml | 8 + .../scripts/dashboard/remove-component.phtml | 8 + .../views/scripts/dashboard/settings.phtml | 47 ++++++ .../scripts/dashboard/update-component.phtml | 8 + library/Icinga/Web/Widget/Dashboard.php | 3 +- .../Icinga/Web/Widget/Dashboard/Component.php | 24 +++ .../Widget/Tabextension/DashboardSettings.php | 40 +++++ 9 files changed, 294 insertions(+), 91 deletions(-) rename application/forms/Dashboard/{AddUrlForm.php => ComponentForm.php} (75%) create mode 100644 application/views/scripts/dashboard/new-component.phtml create mode 100644 application/views/scripts/dashboard/remove-component.phtml create mode 100644 application/views/scripts/dashboard/settings.phtml create mode 100644 application/views/scripts/dashboard/update-component.phtml create mode 100644 library/Icinga/Web/Widget/Tabextension/DashboardSettings.php diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 2c2b7d2fd..14252ce22 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -2,16 +2,13 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -use Icinga\Application\Config; use Icinga\Application\Logger; -use Icinga\Exception\ConfigurationError; -use Icinga\Exception\IcingaException; -use Icinga\Exception\NotReadableError; -use Icinga\File\Ini\IniWriter; -use Icinga\Forms\Dashboard\AddUrlForm; +use Icinga\Form\Dashboard\ComponentForm; +use Icinga\Web\Notification; use Icinga\Web\Controller\ActionController; use Icinga\Web\Url; use Icinga\Web\Widget\Dashboard; +use Icinga\Web\Widget\Tabextension\DashboardSettings; /** * Handle creation, removal and displaying of dashboards, panes and components @@ -20,26 +17,100 @@ use Icinga\Web\Widget\Dashboard; */ class DashboardController extends ActionController { + /** + * @var Dashboard; + */ + private $dashboard; + + public function init() + { + $this->dashboard = new Dashboard(); + $this->dashboard->setUser($this->getRequest()->getUser()); + $this->dashboard->load(); + } + + public function newComponentAction() + { + $form = new ComponentForm(); + $this->createTabs(); + $dashboard = new Dashboard(); + $dashboard->setUser($this->getRequest()->getUser()); + $dashboard->load(); + $form->setDashboard($dashboard); + $form->handleRequest(); + $this->view->form = $form; + } + + public function updateComponentAction() + { + $this->createTabs(); + $dashboard = $this->dashboard; + $form = new ComponentForm(); + $form->setDashboard($dashboard); + $form->setSubmitLabel(t('Update Component')); + if (! $this->_request->getParam('pane')) { + throw new Zend_Controller_Action_Exception( + 'Missing parameter "pane"', + 400 + ); + } + if (! $this->_request->getParam('component')) { + throw new Zend_Controller_Action_Exception( + 'Missing parameter "component"', + 400 + ); + } + $form->setOnSuccess(function (\Icinga\Web\Request $request, \Icinga\Web\Form $form) use ($dashboard) { + $pane = $dashboard->getPane($form->getValue('pane')); + try { + $component = $pane->getComponent($form->getValue('component')); + $component->setUrl($form->getValue('url')); + } catch (\Icinga\Exception\ProgrammingError $e) { + $component = new Dashboard\Component($form->getValue('component'), $form->getValue('url'), $pane); + $pane->addComponent($component); + } + $component->setUserWidget(); + // Rename component + if ($form->getValue('org_component') && $form->getValue('org_component') !== $component->getTitle()) { + $pane->removeComponent($form->getValue('org_component')); + } + $dashboard->write(); + Notification::success(t('Component updated')); + return true; + }); + $form->setRedirectUrl('dashboard/settings'); + $form->handleRequest(); + $pane = $dashboard->getPane($this->getParam('pane')); + $component = $pane->getComponent($this->getParam('component')); + $form->load($component); + + $this->view->form = $form; + } + + public function deleteComponentAction() + { + $form = new ComponentForm(); + + $this->createTabs(); + $dashboard = new Dashboard(); + $dashboard->setUser($this->getRequest()->getUser()); + $dashboard->load(); + $form->setDashboard($dashboard); + $form->handleRequest(); + $this->view->form = $form; + } + /** * Display the form for adding new components or add the new component if submitted */ public function addurlAction() { - $this->getTabs()->add( - 'addurl', - array( - 'title' => 'Add Dashboard URL', - 'url' => Url::fromRequest() - ) - )->activate('addurl'); - $form = new AddUrlForm(); $dashboard = new Dashboard(); $dashboard->setUser($this->getRequest()->getUser()); $dashboard->load(); $form->setDashboard($dashboard); - $form->setRedirectUrl($this->getParam('url')); $form->handleRequest(); $this->view->form = $form; } @@ -52,36 +123,50 @@ class DashboardController extends ActionController */ public function indexAction() { - $dashboard = new Dashboard(); - $dashboard->setUser($this->getRequest()->getUser()); - $dashboard->load(); - - if (! $dashboard->hasPanes()) { + $this->createTabs(); + if (! $this->dashboard->hasPanes()) { $this->view->title = 'Dashboard'; } else { if ($this->_getParam('pane')) { $pane = $this->_getParam('pane'); - $dashboard->activate($pane); + $this->dashboard->activate($pane); } - if ($dashboard === null) { + if ($this->dashboard === null) { $this->view->title = 'Dashboard'; } else { - $this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard'; - $this->view->tabs = $dashboard->getTabs(); + $this->view->title = $this->dashboard->getActivePane()->getTitle() . ' :: Dashboard'; if ($this->hasParam('remove')) { - $dashboard->getActivePane()->removeComponent($this->getParam('remove')); - $dashboard->write(); + $this->dashboard->getActivePane()->removeComponent($this->getParam('remove')); + $this->dashboard->write(); $this->redirectNow(URL::fromRequest()->remove('remove')); } - $this->view->tabs->add( + + /* $this->view->tabs->add( 'Add', array( 'title' => '+', 'url' => Url::fromPath('dashboard/addurl') ) - ); - $this->view->dashboard = $dashboard; + ); */ + $this->view->dashboard = $this->dashboard; } } } + + /** + * Setting dialog + */ + public function settingsAction() + { + $this->createTabs(); + $this->view->dashboard = $this->dashboard; + } + + /** + * Create tab aggregation + */ + private function createTabs() + { + $this->view->tabs = $this->dashboard->getTabs()->extend(new DashboardSettings()); + } } diff --git a/application/forms/Dashboard/AddUrlForm.php b/application/forms/Dashboard/ComponentForm.php similarity index 75% rename from application/forms/Dashboard/AddUrlForm.php rename to application/forms/Dashboard/ComponentForm.php index f67c92a42..d3bcb22f2 100644 --- a/application/forms/Dashboard/AddUrlForm.php +++ b/application/forms/Dashboard/ComponentForm.php @@ -11,19 +11,13 @@ use Icinga\Web\Url; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Form; use Icinga\Web\Request; +use Icinga\Web\Widget\Dashboard\Component; /** * Form to add an url a dashboard pane */ -class AddUrlForm extends Form +class ComponentForm extends Form { - /** - * Config file name - * - * @var string - */ - private $configFile = 'dashboard/dashboard'; - /** * @var Dashboard */ @@ -35,7 +29,9 @@ class AddUrlForm extends Form public function init() { $this->setName('form_dashboard_addurl'); - $this->setSubmitLabel(t('Add To Dashboard')); + if (! $this->getSubmitLabel()) { + $this->setSubmitLabel(t('Add To Dashboard')); + } } /** @@ -45,13 +41,28 @@ class AddUrlForm extends Form */ public function createElements(array $formData) { - $paneSelectionValues = array(); + $groupElements = array(); + $panes = array(); - if ($this->dashboard !== null) { - $paneSelectionValues = $this->dashboard->getPaneKeyTitleArray(); + if ($this->dashboard) { + $panes = $this->dashboard->getPaneKeyTitleArray(); } - $groupElements = array(); + $this->addElement( + 'hidden', + 'org_pane', + array( + 'required' => false + ) + ); + + $this->addElement( + 'hidden', + 'org_component', + array( + 'required' => false + ) + ); $this->addElement( 'text', @@ -72,7 +83,7 @@ class AddUrlForm extends Form 'description' => t('Enter a title for the dashlet.') ) ); - if (empty($paneSelectionValues) || + if (empty($panes) || ((isset($formData['create_new_pane']) && $formData['create_new_pane'] != false) && (false === isset($formData['use_existing_dashboard']) || $formData['use_existing_dashboard'] != true)) ) { @@ -93,7 +104,7 @@ class AddUrlForm extends Form 'value' => 1 ) ); - if (false === empty($paneSelectionValues)) { + if (false === empty($panes)) { $buttonExistingPane = $this->createElement( 'submit', 'use_existing_dashboard', @@ -114,7 +125,7 @@ class AddUrlForm extends Form array( 'required' => true, 'label' => t('Pane'), - 'multiOptions' => $paneSelectionValues, + 'multiOptions' => $panes, 'description' => t('Select a pane you want to add the dashlet.') ) @@ -161,33 +172,6 @@ class AddUrlForm extends Form */ public function onSuccess(Request $request) { - $pane = null; - - if ($this->dashboard === null) { - throw new ProgrammingError('Dashboard is not set, can not write values'); - } - - try { - $pane = $this->dashboard->getPane($this->getValue('pane')); - } catch (ProgrammingError $e) { - $pane = new Dashboard\Pane($this->getValue('pane')); - $pane->setUserWidget(); - $this->dashboard->addPane($pane); - } - - $component = new Dashboard\Component( - $this->getValue('component'), - $this->getValue('url'), - $pane - ); - - $component->setUserWidget(); - - $pane->addComponent($component); - - $this->dashboard->write(); - - return true; } @@ -198,25 +182,11 @@ class AddUrlForm extends Form */ public function onRequest(Request $request) { - // TODO(mh): Im not sure if this is the right place for that - $url = $this->getValue('url'); - if (! $url) { - $url = $request->getParam('url'); - } - - if (! $url) { - return; - } - - $data = array( - 'url' => urldecode(Url::fromPath($url)->getPath()) - ); - - $this->populate($data); + return true; } /** - * @param Dashboard $dashboard + * @param \Icinga\Web\Widget\Dashboard $dashboard */ public function setDashboard(Dashboard $dashboard) { @@ -224,10 +194,24 @@ class AddUrlForm extends Form } /** - * @return Dashboard + * @return \Icinga\Web\Widget\Dashboard */ public function getDashboard() { return $this->dashboard; } + + /** + * @param Component $component + */ + public function load(Component $component) + { + $this->populate(array( + 'pane' => $component->getPane()->getName(), + 'org_pane' => $component->getPane()->getName(), + 'component' => $component->getTitle(), + 'org_component' => $component->getTitle(), + 'url' => $component->getUrl() + )); + } } diff --git a/application/views/scripts/dashboard/new-component.phtml b/application/views/scripts/dashboard/new-component.phtml new file mode 100644 index 000000000..456d14a65 --- /dev/null +++ b/application/views/scripts/dashboard/new-component.phtml @@ -0,0 +1,8 @@ +
+ tabs ?> +
+ +
+

+ form; ?> +
\ No newline at end of file diff --git a/application/views/scripts/dashboard/remove-component.phtml b/application/views/scripts/dashboard/remove-component.phtml new file mode 100644 index 000000000..9138b95b1 --- /dev/null +++ b/application/views/scripts/dashboard/remove-component.phtml @@ -0,0 +1,8 @@ +
+ tabs ?> +
+ +
+

+ form; ?> +
\ No newline at end of file diff --git a/application/views/scripts/dashboard/settings.phtml b/application/views/scripts/dashboard/settings.phtml new file mode 100644 index 000000000..7a2e8f390 --- /dev/null +++ b/application/views/scripts/dashboard/settings.phtml @@ -0,0 +1,47 @@ + +
+ tabs ?> +
+
+

+ + + + + + + + + + dashboard->getPanes() as $pane): ?> + + + + getComponents() as $component): ?> + + + + + + + + +
+ + + +
+ getName(); ?> +
+ + getTitle(); ?> + + + getUrl(); ?> + + + icon('remove.png'); ?> + +
+
\ No newline at end of file diff --git a/application/views/scripts/dashboard/update-component.phtml b/application/views/scripts/dashboard/update-component.phtml new file mode 100644 index 000000000..0493f5613 --- /dev/null +++ b/application/views/scripts/dashboard/update-component.phtml @@ -0,0 +1,8 @@ +
+ tabs ?> +
+ +
+

+ form; ?> +
\ No newline at end of file diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 1a049ef59..1764e5cea 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -187,7 +187,7 @@ class Dashboard extends AbstractWidget */ public function getTabs() { - $url = Url::fromRequest()->getUrlWithout($this->tabParam); + $url = Url::fromPath('dashboard')->getUrlWithout($this->tabParam); if ($this->tabs === null) { $this->tabs = new Tabs(); @@ -212,7 +212,6 @@ class Dashboard extends AbstractWidget */ public function getPanes() { - return ''; return $this->panes; } diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 693f60bfe..0ab210057 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -93,6 +93,14 @@ EOD; return $this->title; } + /** + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + } + /** * Retrieve the components url * @@ -228,4 +236,20 @@ EOD; $cmp = new Component($title, Url::fromPath($url, $parameters), $pane); return $cmp; } + + /** + * @param \Icinga\Web\Widget\Dashboard\Pane $pane + */ + public function setPane(Panel $pane) + { + $this->pane = $pane; + } + + /** + * @return \Icinga\Web\Widget\Dashboard\Pane + */ + public function getPane() + { + return $this->pane; + } } diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php new file mode 100644 index 000000000..4242f864d --- /dev/null +++ b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php @@ -0,0 +1,40 @@ +addAsDropdown( + 'dashboard_add', + array( + 'icon' => 'img/icons/dashboard.png', + 'title' => t('Add To Dashboard'), + 'url' => Url::fromPath('dashboard/addurl') + ) + ); + + $tabs->addAsDropdown( + 'dashboard_settings', + array( + 'icon' => 'img/icons/dashboard.png', + 'title' => t('Settings'), + 'url' => Url::fromPath('dashboard/settings') + ) + ); + } +} \ No newline at end of file From 3e58ec253030838dac328e674bd631b6d5d9fb05 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 18 Nov 2014 12:51:28 +0100 Subject: [PATCH 12/31] Dashboard: Use new controller actions refs #4537 --- .../controllers/DashboardController.php | 98 +++++++++++++------ application/forms/Dashboard/ComponentForm.php | 4 - .../scripts/dashboard/remove-component.phtml | 6 ++ .../views/scripts/dashboard/settings.phtml | 37 ++++--- .../Icinga/Web/Widget/Dashboard/Component.php | 5 +- .../Widget/Tabextension/DashboardAction.php | 2 +- .../Widget/Tabextension/DashboardSettings.php | 2 +- 7 files changed, 101 insertions(+), 53 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 14252ce22..a28e1485a 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -3,9 +3,13 @@ // {{{ICINGA_LICENSE_HEADER}}} use Icinga\Application\Logger; -use Icinga\Form\Dashboard\ComponentForm; +use Icinga\Exception\ProgrammingError; +use Icinga\Forms\ConfirmRemovalForm; +use Icinga\Forms\Dashboard\ComponentForm; +use Icinga\Web\Form; use Icinga\Web\Notification; use Icinga\Web\Controller\ActionController; +use Icinga\Web\Request; use Icinga\Web\Url; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Widget\Tabextension\DashboardSettings; @@ -33,10 +37,29 @@ class DashboardController extends ActionController { $form = new ComponentForm(); $this->createTabs(); - $dashboard = new Dashboard(); - $dashboard->setUser($this->getRequest()->getUser()); - $dashboard->load(); + $dashboard = $this->dashboard; $form->setDashboard($dashboard); + if ($this->_request->getParam('url')) { + $params = $this->_request->getParams(); + $params['url'] = rawurldecode($this->_request->getParam('url')); + $form->populate($params); + } + $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard) { + try { + $pane = $dashboard->getPane($form->getValue('pane')); + } catch (ProgrammingError $e) { + $pane = new Dashboard\Pane($form->getValue('pane')); + $pane->setUserWidget(); + $dashboard->addPane($pane); + } + $component = new Dashboard\Component($form->getValue('component'), $form->getValue('url'), $pane); + $component->setUserWidget(); + $pane->addComponent($component); + $dashboard->write(); + Notification::success(t('Component created')); + return true; + }); + $form->setRedirectUrl('dashboard'); $form->handleRequest(); $this->view->form = $form; } @@ -60,12 +83,12 @@ class DashboardController extends ActionController 400 ); } - $form->setOnSuccess(function (\Icinga\Web\Request $request, \Icinga\Web\Form $form) use ($dashboard) { + $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard) { $pane = $dashboard->getPane($form->getValue('pane')); try { $component = $pane->getComponent($form->getValue('component')); $component->setUrl($form->getValue('url')); - } catch (\Icinga\Exception\ProgrammingError $e) { + } catch (ProgrammingError $e) { $component = new Dashboard\Component($form->getValue('component'), $form->getValue('url'), $pane); $pane->addComponent($component); } @@ -75,6 +98,7 @@ class DashboardController extends ActionController $pane->removeComponent($form->getValue('org_component')); } $dashboard->write(); + $dashboard->write(); Notification::success(t('Component updated')); return true; }); @@ -87,31 +111,42 @@ class DashboardController extends ActionController $this->view->form = $form; } - public function deleteComponentAction() + public function removeComponentAction() { - $form = new ComponentForm(); - + $form = new ConfirmRemovalForm(); $this->createTabs(); - $dashboard = new Dashboard(); - $dashboard->setUser($this->getRequest()->getUser()); - $dashboard->load(); - $form->setDashboard($dashboard); - $form->handleRequest(); - $this->view->form = $form; - } - - /** - * Display the form for adding new components or add the new component if submitted - */ - public function addurlAction() - { - $form = new AddUrlForm(); - - $dashboard = new Dashboard(); - $dashboard->setUser($this->getRequest()->getUser()); - $dashboard->load(); - $form->setDashboard($dashboard); + $dashboard = $this->dashboard; + if (! $this->_request->getParam('pane')) { + throw new Zend_Controller_Action_Exception( + 'Missing parameter "pane"', + 400 + ); + } + if (! $this->_request->getParam('component')) { + throw new Zend_Controller_Action_Exception( + 'Missing parameter "component"', + 400 + ); + } + $pane = $this->_request->getParam('pane'); + $component = $this->_request->getParam('component'); + $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard, $component, $pane) { + try { + $pane = $dashboard->getPane($pane); + $pane->removeComponent($component); + $dashboard->write(); + Notification::success(t('Component has been removed from') . ' ' . $pane->getTitle()); + return true; + } catch (ProgrammingError $e) { + Notification::error($e->getMessage()); + return false; + } + return false; + }); + $form->setRedirectUrl('dashboard/settings'); $form->handleRequest(); + $this->view->pane = $pane; + $this->view->component = $component; $this->view->form = $form; } @@ -140,14 +175,13 @@ class DashboardController extends ActionController $this->dashboard->write(); $this->redirectNow(URL::fromRequest()->remove('remove')); } - - /* $this->view->tabs->add( + $this->view->tabs->add( 'Add', array( 'title' => '+', - 'url' => Url::fromPath('dashboard/addurl') + 'url' => Url::fromPath('dashboard/new-component') ) - ); */ + ); $this->view->dashboard = $this->dashboard; } } diff --git a/application/forms/Dashboard/ComponentForm.php b/application/forms/Dashboard/ComponentForm.php index d3bcb22f2..c62bf82fe 100644 --- a/application/forms/Dashboard/ComponentForm.php +++ b/application/forms/Dashboard/ComponentForm.php @@ -4,10 +4,6 @@ namespace Icinga\Forms\Dashboard; -use Icinga\Application\Config; -use Icinga\Exception\ProgrammingError; -use Icinga\File\Ini\IniWriter; -use Icinga\Web\Url; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Form; use Icinga\Web\Request; diff --git a/application/views/scripts/dashboard/remove-component.phtml b/application/views/scripts/dashboard/remove-component.phtml index 9138b95b1..c39472771 100644 --- a/application/views/scripts/dashboard/remove-component.phtml +++ b/application/views/scripts/dashboard/remove-component.phtml @@ -4,5 +4,11 @@

+ +

+ translate('Please confirm the removal'); ?>: + pane; ?>/component; ?> +

+ form; ?>
\ No newline at end of file diff --git a/application/views/scripts/dashboard/settings.phtml b/application/views/scripts/dashboard/settings.phtml index 7a2e8f390..76a66a0d2 100644 --- a/application/views/scripts/dashboard/settings.phtml +++ b/application/views/scripts/dashboard/settings.phtml @@ -24,23 +24,32 @@ getName(); ?> - getComponents() as $component): ?> + getComponents(); ?> + - - - getTitle(); ?> - - - - getUrl(); ?> - - - - icon('remove.png'); ?> - + + translate('No compoments added to dashboard') ?>. - + + + + + + getTitle(); ?> + + + + getUrl(); ?> + + + + icon('remove.png'); ?> + + + + + diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 0ab210057..5b6376d32 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -211,7 +211,10 @@ EOD; { return sprintf( '%s', - Url::fromRequest(array('remove' => $this->getTitle())), + Url::fromPath('dashboard/remove-component', array( + 'component' => $this->getTitle(), + 'pane' => $this->pane->getTitle() + )), t('Remove') ); } diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php index a8cce1cc0..9ed5f34ef 100644 --- a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php +++ b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php @@ -26,7 +26,7 @@ class DashboardAction implements Tabextension array( 'icon' => 'dashboard', 'title' => 'Add To Dashboard', - 'url' => Url::fromPath('dashboard/addurl'), + 'url' => Url::fromPath('dashboard/new-component'), 'urlParams' => array( 'url' => rawurlencode(Url::fromRequest()->getRelativeUrl()) ) diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php index 4242f864d..c30db4235 100644 --- a/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php +++ b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php @@ -24,7 +24,7 @@ class DashboardSettings implements Tabextension array( 'icon' => 'img/icons/dashboard.png', 'title' => t('Add To Dashboard'), - 'url' => Url::fromPath('dashboard/addurl') + 'url' => Url::fromPath('dashboard/new-component') ) ); From 80871313e4e9609b687c93a9f98a0da0c68d2a94 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 18 Nov 2014 16:28:04 +0100 Subject: [PATCH 13/31] Dashboard: Remove actions refs #4537 --- .../controllers/DashboardController.php | 31 ++++++++ .../views/scripts/dashboard/index.phtml | 10 +-- .../views/scripts/dashboard/remove-pane.phtml | 14 ++++ .../views/scripts/dashboard/settings.phtml | 5 ++ library/Icinga/Web/Widget/Dashboard.php | 71 +++++++++++++++++-- .../Icinga/Web/Widget/Dashboard/Component.php | 2 +- library/Icinga/Web/Widget/Dashboard/Pane.php | 39 +++++++++- 7 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 application/views/scripts/dashboard/remove-pane.phtml diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index a28e1485a..896cb6c19 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -150,6 +150,37 @@ class DashboardController extends ActionController $this->view->form = $form; } + public function removePaneAction() + { + $form = new ConfirmRemovalForm(); + $this->createTabs(); + $dashboard = $this->dashboard; + if (! $this->_request->getParam('pane')) { + throw new Zend_Controller_Action_Exception( + 'Missing parameter "pane"', + 400 + ); + } + $pane = $this->_request->getParam('pane'); + $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard, $pane) { + try { + $pane = $dashboard->getPane($pane); + $dashboard->removePane($pane->getTitle()); + $dashboard->write(); + Notification::success(t('Pane has been removed') . ': ' . $pane->getTitle()); + return true; + } catch (ProgrammingError $e) { + Notification::error($e->getMessage()); + return false; + } + return false; + }); + $form->setRedirectUrl('dashboard/settings'); + $form->handleRequest(); + $this->view->pane = $pane; + $this->view->form = $form; + } + /** * Display the dashboard with the pane set in the 'pane' request parameter * diff --git a/application/views/scripts/dashboard/index.phtml b/application/views/scripts/dashboard/index.phtml index 4adad7b66..7c3724dc6 100644 --- a/application/views/scripts/dashboard/index.phtml +++ b/application/views/scripts/dashboard/index.phtml @@ -8,9 +8,11 @@

escape($this->translate('Welcome to Icinga Web!')) ?>

-

escape($this->translate('Currently there is no dashlet available. This might change once you enabled some of the available %s.')), - $this->qlink($this->translate('modules'), 'config/modules') - ) ?>

+

+ escape($this->translate('Currently there is no dashlet available. This might change once you enabled some of the available %s.')), + $this->qlink($this->translate('modules'), 'config/modules') + ) ?> +

\ No newline at end of file diff --git a/application/views/scripts/dashboard/remove-pane.phtml b/application/views/scripts/dashboard/remove-pane.phtml new file mode 100644 index 000000000..637774cab --- /dev/null +++ b/application/views/scripts/dashboard/remove-pane.phtml @@ -0,0 +1,14 @@ +
+ tabs ?> +
+ +
+

+ +

+ translate('Please confirm the removal of'); ?>: + pane; ?> +

+ + form; ?> +
\ No newline at end of file diff --git a/application/views/scripts/dashboard/settings.phtml b/application/views/scripts/dashboard/settings.phtml index 76a66a0d2..ebe0188c4 100644 --- a/application/views/scripts/dashboard/settings.phtml +++ b/application/views/scripts/dashboard/settings.phtml @@ -23,6 +23,11 @@ getName(); ?> + + + icon('remove.png'); ?> + + getComponents(); ?> diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 1764e5cea..1dc7cf4fd 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -7,7 +7,9 @@ namespace Icinga\Web\Widget; use Icinga\Application\Icinga; use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; +use Icinga\Exception\NotReadableError; use Icinga\Exception\ProgrammingError; +use Icinga\Exception\SystemPermissionException; use Icinga\File\Ini\IniWriter; use Icinga\User; use Icinga\Web\Widget\Dashboard\Pane; @@ -78,6 +80,7 @@ class Dashboard extends AbstractWidget if ($this->user !== null) { $this->loadUserDashboards(); } + return $this; } @@ -117,9 +120,16 @@ class Dashboard extends AbstractWidget $components = array(); foreach ($config as $key => $part) { if (strpos($key, '.') === false) { - $panes[$key] = new Pane($key); - $panes[$key]->setTitle($part->title); + if ($this->hasPane($part->title)) { + $panes[$key] = $this->getPane($part->title); + } else { + $panes[$key] = new Pane($key); + $panes[$key]->setTitle($part->title); + } $panes[$key]->setUserWidget(); + if ((bool) $part->get('disabled', false) === true) { + $panes[$key]->setDisabled(); + } } else { list($paneName, $componentName) = explode('.', $key, 2); @@ -168,7 +178,13 @@ class Dashboard extends AbstractWidget { /** @var $pane Pane */ foreach ($panes as $pane) { - if (array_key_exists($pane->getName(), $this->panes)) { + if ($pane->getDisabled()) { + if ($this->hasPane($pane->getTitle()) === true) { + $this->removePane($pane->getTitle()); + } + continue; + } + if ($this->hasPane($pane->getTitle()) === true) { /** @var $current Pane */ $current = $this->panes[$pane->getName()]; $current->addComponents($pane->getComponents()); @@ -242,6 +258,17 @@ class Dashboard extends AbstractWidget return ! empty($this->panes); } + /** + * Check if a panel exist + * + * @param string $pane + * @return bool + */ + public function hasPane($pane) + { + return $pane && array_key_exists($pane, $this->panes); + } + /** * Add a pane object to this dashboard * @@ -255,6 +282,21 @@ class Dashboard extends AbstractWidget return $this; } + public function removePane($title) + { + if ($this->hasPane($title) === true) { + $pane = $this->getPane($title); + if ($pane->isUserWidget() === true) { + unset($this->panes[$pane->getName()]); + } else { + $pane->setDisabled(); + $pane->setUserWidget(); + } + } else { + throw new ProgrammingError('Pane not found: ' . $title); + } + } + /** * Return the pane with the provided name * @@ -296,6 +338,7 @@ class Dashboard extends AbstractWidget if (empty($this->panes)) { return ''; } + return $this->determineActivePane()->render(); } @@ -382,6 +425,26 @@ class Dashboard extends AbstractWidget if ($this->user === null) { return ''; } - return '/var/lib/icingaweb/' . $this->user->getUsername() . '/dashboard.ini'; + + $baseDir = '/var/lib/icingaweb'; + + if (! file_exists($baseDir)) { + throw new NotReadableError('Could not read: ' . $baseDir); + } + + $userDir = $baseDir . '/' . $this->user->getUsername(); + + if (! file_exists($userDir)) { + $success = @mkdir($userDir); + if (!$success) { + throw new SystemPermissionException('Could not create: ' . $userDir); + } + } + + if (! file_exists($userDir)) { + throw new NotReadableError('Could not read: ' . $userDir); + } + + return $userDir . '/dashboard.ini'; } } diff --git a/library/Icinga/Web/Widget/Dashboard/Component.php b/library/Icinga/Web/Widget/Dashboard/Component.php index 5b6376d32..ed382756b 100644 --- a/library/Icinga/Web/Widget/Dashboard/Component.php +++ b/library/Icinga/Web/Widget/Dashboard/Component.php @@ -53,7 +53,7 @@ class Component extends UserWidget private $template =<<<'EOD'
-

{TITLE} ({REMOVE})

+

{TITLE}

diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 26cd46e44..97b8c1031 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -36,6 +36,13 @@ class Pane extends UserWidget */ private $components = array(); + /** + * Disabled flag of a pane + * + * @var bool + */ + private $disabled; + /** * Create a new pane * @@ -253,9 +260,15 @@ class Pane extends UserWidget */ public function toArray() { - return array( - 'title' => $this->getTitle() + $pane = array( + 'title' => $this->getTitle(), ); + + if ($this->getDisabled() === true) { + $pane['disabled'] = 1; + } + + return $pane; } /** @@ -274,4 +287,26 @@ class Pane extends UserWidget } return $pane; } + + /** + * Setter for disabled + * + * @param boolean $disabled + */ + public function setDisabled($disabled = true) + { + $this->disabled = (bool) $disabled; + } + + /** + * Getter for disabled + * + * @return boolean + */ + public function getDisabled() + { + return $this->disabled; + } + + } From f2717b6d2661d262b0db78123a1fb8f479925922 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 4 Nov 2014 16:15:06 +0100 Subject: [PATCH 14/31] Introduce Form::setOnSuccess() in favor of overriding the constructor Zend_Form uses setters for options if a respective setter method exists. It is not necessary to override the constructor for introducing new options. Conflicts: library/Icinga/Web/Form.php --- .../controllers/DashboardController.php | 22 ++++++++++++++----- application/forms/Dashboard/ComponentForm.php | 20 ----------------- library/Icinga/Web/Form.php | 20 +++++++++++++++++ library/Icinga/Web/Widget/Dashboard.php | 4 +++- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 896cb6c19..105b40762 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -44,7 +44,7 @@ class DashboardController extends ActionController $params['url'] = rawurldecode($this->_request->getParam('url')); $form->populate($params); } - $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard) { + $form->setOnSuccess(function (Form $form) use ($dashboard) { try { $pane = $dashboard->getPane($form->getValue('pane')); } catch (ProgrammingError $e) { @@ -83,8 +83,14 @@ class DashboardController extends ActionController 400 ); } - $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard) { - $pane = $dashboard->getPane($form->getValue('pane')); + $form->setOnSuccess(function (Form $form) use ($dashboard) { + try { + $pane = $dashboard->getPane($form->getValue('pane')); + } catch (ProgrammingError $e) { + $pane = new Dashboard\Pane($form->getValue('pane')); + $pane->setUserWidget(); + $dashboard->addPane($pane); + } try { $component = $pane->getComponent($form->getValue('component')); $component->setUrl($form->getValue('url')); @@ -97,7 +103,11 @@ class DashboardController extends ActionController if ($form->getValue('org_component') && $form->getValue('org_component') !== $component->getTitle()) { $pane->removeComponent($form->getValue('org_component')); } - $dashboard->write(); + // Move + if ($form->getValue('org_pane') && $form->getValue('org_pane') !== $pane->getTitle()) { + $oldPane = $dashboard->getPane($form->getValue('org_pane')); + $oldPane->removeComponent($component->getTitle()); + } $dashboard->write(); Notification::success(t('Component updated')); return true; @@ -130,7 +140,7 @@ class DashboardController extends ActionController } $pane = $this->_request->getParam('pane'); $component = $this->_request->getParam('component'); - $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard, $component, $pane) { + $form->setOnSuccess(function (Form $form) use ($dashboard, $component, $pane) { try { $pane = $dashboard->getPane($pane); $pane->removeComponent($component); @@ -162,7 +172,7 @@ class DashboardController extends ActionController ); } $pane = $this->_request->getParam('pane'); - $form->setOnSuccess(function (Request $request, Form $form) use ($dashboard, $pane) { + $form->setOnSuccess(function (Form $form) use ($dashboard, $pane) { try { $pane = $dashboard->getPane($pane); $dashboard->removePane($pane->getTitle()); diff --git a/application/forms/Dashboard/ComponentForm.php b/application/forms/Dashboard/ComponentForm.php index c62bf82fe..54aa4c33d 100644 --- a/application/forms/Dashboard/ComponentForm.php +++ b/application/forms/Dashboard/ComponentForm.php @@ -161,26 +161,6 @@ class ComponentForm extends Form ); } - /** - * Adjust preferences and persist them - * - * @see Form::onSuccess() - */ - public function onSuccess(Request $request) - { - return true; - } - - /** - * Populate data if any - * - * @see Form::onRequest() - */ - public function onRequest(Request $request) - { - return true; - } - /** * @param \Icinga\Web\Widget\Dashboard $dashboard */ diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 8d75a9df3..863d4f1c1 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -163,6 +163,26 @@ class Form extends Zend_Form parent::__construct($options); } + /** + * Set a callback that is called instead of this form's onSuccess method + * + * It is called using the following signature: (Request $request, Form $form). + * + * @param callable $onSuccess Callback + * + * @return $this + * + * @throws LogicException If the callback is not callable + */ + public function setOnSuccess($onSuccess) + { + if (! is_callable($onSuccess)) { + throw new LogicException('The option `onSuccess\' is not callable'); + } + $this->onSuccess = $onSuccess; + return $this; + } + /** * Set the label to use for the standard submit button * diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 1dc7cf4fd..ccc8cf279 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -6,6 +6,7 @@ namespace Icinga\Web\Widget; use Icinga\Application\Icinga; use Icinga\Application\Config; +use Icinga\Data\ConfigObject; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; use Icinga\Exception\ProgrammingError; @@ -102,7 +103,8 @@ class Dashboard extends AbstractWidget } } - $config = new Config($output); + $co = new ConfigObject($output); + $config = new Config($co); $writer = new IniWriter(array('config' => $config, 'filename' => $configFile)); $writer->write(); } From 8c3dbb2b45b758f214752819a02c07ea785f6f71 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 18 Nov 2014 17:26:28 +0100 Subject: [PATCH 15/31] Dashbosrd: Fix tests refs #4537 --- .../Icinga/Web/Widget/DashboardTest.php | 107 +----------------- 1 file changed, 5 insertions(+), 102 deletions(-) diff --git a/test/php/library/Icinga/Web/Widget/DashboardTest.php b/test/php/library/Icinga/Web/Widget/DashboardTest.php index be11c42fe..21727480b 100644 --- a/test/php/library/Icinga/Web/Widget/DashboardTest.php +++ b/test/php/library/Icinga/Web/Widget/DashboardTest.php @@ -131,7 +131,8 @@ class DashboardTest extends BaseTestCase */ public function testLoadPaneItemsProvidedByEnabledModules() { - $dashboard = Dashboard::load(); + $dashboard = new Dashboard(); + $dashboard->load(); $this->assertCount( 1, @@ -270,71 +271,15 @@ class DashboardTest extends BaseTestCase $component2 = new Component('test2', 'test2', $pane); $pane->addComponent($component2); - $dashboard->removeComponent('test1', 'test'); - + $dashboard->getPane('test1')->removeComponent('test'); $result = $dashboard->getPane('test1')->hasComponent('test'); - $this->assertFalse( + $this->assertTrue( $result, 'Dashboard::removeComponent() could not remove component from the pane' ); } - /** - * @depends testWhetherGetPaneReturnsAPaneByName - */ - public function testWhetherRemoveComponentRemovesComponentByConcatenation() - { - $dashboard = new Dashboard(); - $dashboard->createPane('test1'); - $pane = $dashboard->getPane('test1'); - - $component = new Component('test', 'test', $pane); - $pane->addComponent($component); - - $component2 = new Component('test2', 'test2', $pane); - $pane->addComponent($component2); - - $dashboard->removeComponent('test1.test', null); - - $result = $dashboard->getPane('test1')->hasComponent('test'); - - $this->assertFalse( - $result, - 'Dashboard::removeComponent() could not remove component from the pane' - ); - } - - /** - * @depends testWhetherGetPaneReturnsAPaneByName - */ - public function testWhetherToArrayReturnsDashboardStructureAsArray() - { - $dashboard = new Dashboard(); - $dashboard->createPane('test1'); - $pane = $dashboard->getPane('test1'); - - $component = new Component('test', 'test', $pane); - $pane->addComponent($component); - - $result = $dashboard->toArray(); - - $expected = array( - 'test1' => array( - 'title' => 'test1' - ), - 'test1.test' => array( - 'url' => 'test' - ) - ); - - $this->assertEquals( - $expected, - $result, - 'Dashboard::toArray() could not return valid expectation' - ); - } - /** * @depends testWhetherGetPaneReturnsAPaneByName */ @@ -346,7 +291,7 @@ class DashboardTest extends BaseTestCase $component = new Component('test', 'test', $pane); $pane->addComponent($component); - $dashboard->setComponentUrl('test1', 'test', 'new'); + $dashboard->getPane('test1')->getComponent('test')->setUrl('new'); $this->assertEquals( 'new', @@ -355,48 +300,6 @@ class DashboardTest extends BaseTestCase ); } - /** - * @depends testWhetherGetPaneReturnsAPaneByName - */ - public function testWhetherSetComponentUrlUpdatesTheComponentUrlConcatenation() - { - $dashboard = new Dashboard(); - $dashboard->createPane('test1'); - $pane = $dashboard->getPane('test1'); - $component = new Component('test', 'test', $pane); - $pane->addComponent($component); - - $dashboard->setComponentUrl('test1.test', null, 'new'); - - $this->assertEquals( - 'new', - $component->getUrl()->getPath(), - 'Dashboard::setComponentUrl() could not return valid expectation' - ); - } - - /** - * @depends testWhetherGetPaneReturnsAPaneByName - */ - public function testWhetherSetComponentUrlUpdatesTheComponentUrlNotExistentPane() - { - $dashboard = new Dashboard(); - $dashboard->createPane('test1'); - $pane = $dashboard->getPane('test1'); - $component = new Component('test', 'test', $pane); - $pane->addComponent($component); - - $dashboard->setComponentUrl('test3.test', null, 'new'); - - $result = $dashboard->getPane('test3')->getComponent('test'); - - $this->assertEquals( - 'new', - $result->getUrl()->getPath(), - 'Dashboard::setComponentUrl() could not return valid expectation' - ); - } - /** * @expectedException \Icinga\Exception\ConfigurationError */ From 5ace5fd2dc3379a60a8c771eba00dd3aea155bd9 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 18 Nov 2014 17:47:57 +0100 Subject: [PATCH 16/31] Dashboard: Change icons refs #4537 --- application/views/scripts/dashboard/settings.phtml | 4 ++-- library/Icinga/Web/Widget/Dashboard/Pane.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/application/views/scripts/dashboard/settings.phtml b/application/views/scripts/dashboard/settings.phtml index ebe0188c4..b14c236df 100644 --- a/application/views/scripts/dashboard/settings.phtml +++ b/application/views/scripts/dashboard/settings.phtml @@ -25,7 +25,7 @@ - icon('remove.png'); ?> + icon('cancel'); ?> @@ -49,7 +49,7 @@ - icon('remove.png'); ?> + icon('cancel'); ?> diff --git a/library/Icinga/Web/Widget/Dashboard/Pane.php b/library/Icinga/Web/Widget/Dashboard/Pane.php index 4773d69b7..4ba9f27dc 100644 --- a/library/Icinga/Web/Widget/Dashboard/Pane.php +++ b/library/Icinga/Web/Widget/Dashboard/Pane.php @@ -141,9 +141,11 @@ class Pane extends UserWidget if ($component->isUserWidget() === true) { unset($this->components[$title]); } else { - $component->setUserWidget(); $component->setDisabled(true); + $component->setUserWidget(); } + } else { + throw new ProgrammingError('Component does not exist: ' . $title); } return $this; } From a5411c7a1c447fe7488866fbc12f7a05b79d146b Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 19 Nov 2014 10:33:41 +0100 Subject: [PATCH 17/31] Dashboard: Fix reading and disabled system dashboards refs #4537 --- application/views/scripts/dashboard/settings.phtml | 1 + library/Icinga/Web/Widget/Dashboard.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/application/views/scripts/dashboard/settings.phtml b/application/views/scripts/dashboard/settings.phtml index b14c236df..83fba6588 100644 --- a/application/views/scripts/dashboard/settings.phtml +++ b/application/views/scripts/dashboard/settings.phtml @@ -38,6 +38,7 @@ + getDisabled() === true) continue; ?> diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index ccc8cf279..e663ddf44 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -114,7 +114,11 @@ class Dashboard extends AbstractWidget */ private function loadUserDashboards() { - $config = Config::fromIni($this->getConfigFile()); + try { + $config = Config::fromIni($this->getConfigFile()); + } catch (NotReadableError $e) { + return; + } if (! count($config)) { return false; } From a40f357f3cf5abf5671f66c5d509d2db3e9736db Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 19 Nov 2014 11:47:31 +0100 Subject: [PATCH 18/31] Dashboard: Show error message when can not write to file refs #4537 --- .../controllers/DashboardController.php | 40 ++++++++++++++++--- .../views/scripts/dashboard/error.phtml | 13 ++++++ .../scripts/dashboard/new-component.phtml | 1 - library/Icinga/File/Ini/IniWriter.php | 10 +++++ library/Icinga/Web/Widget/Dashboard.php | 17 ++++++-- 5 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 application/views/scripts/dashboard/error.phtml diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 105b40762..94a6b383c 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -44,7 +44,8 @@ class DashboardController extends ActionController $params['url'] = rawurldecode($this->_request->getParam('url')); $form->populate($params); } - $form->setOnSuccess(function (Form $form) use ($dashboard) { + $action = $this; + $form->setOnSuccess(function (Form $form) use ($dashboard, $action) { try { $pane = $dashboard->getPane($form->getValue('pane')); } catch (ProgrammingError $e) { @@ -55,7 +56,14 @@ class DashboardController extends ActionController $component = new Dashboard\Component($form->getValue('component'), $form->getValue('url'), $pane); $component->setUserWidget(); $pane->addComponent($component); - $dashboard->write(); + try { + $dashboard->write(); + } catch (\Zend_Config_Exception $e) { + $action->view->error = $e; + $action->view->config = $dashboard->createWriter(); + $action->render('error'); + return false; + } Notification::success(t('Component created')); return true; }); @@ -83,7 +91,8 @@ class DashboardController extends ActionController 400 ); } - $form->setOnSuccess(function (Form $form) use ($dashboard) { + $action = $this; + $form->setOnSuccess(function (Form $form) use ($dashboard, $action) { try { $pane = $dashboard->getPane($form->getValue('pane')); } catch (ProgrammingError $e) { @@ -108,7 +117,14 @@ class DashboardController extends ActionController $oldPane = $dashboard->getPane($form->getValue('org_pane')); $oldPane->removeComponent($component->getTitle()); } - $dashboard->write(); + try { + $dashboard->write(); + } catch (\Zend_Config_Exception $e) { + $action->view->error = $e; + $action->view->config = $dashboard->createWriter(); + $action->render('error'); + return false; + } Notification::success(t('Component updated')); return true; }); @@ -140,13 +156,19 @@ class DashboardController extends ActionController } $pane = $this->_request->getParam('pane'); $component = $this->_request->getParam('component'); - $form->setOnSuccess(function (Form $form) use ($dashboard, $component, $pane) { + $action = $this; + $form->setOnSuccess(function (Form $form) use ($dashboard, $component, $pane, $action) { try { $pane = $dashboard->getPane($pane); $pane->removeComponent($component); $dashboard->write(); Notification::success(t('Component has been removed from') . ' ' . $pane->getTitle()); return true; + } catch (\Zend_Config_Exception $e) { + $action->view->error = $e; + $action->view->config = $dashboard->createWriter(); + $action->render('error'); + return false; } catch (ProgrammingError $e) { Notification::error($e->getMessage()); return false; @@ -172,13 +194,19 @@ class DashboardController extends ActionController ); } $pane = $this->_request->getParam('pane'); - $form->setOnSuccess(function (Form $form) use ($dashboard, $pane) { + $action = $this; + $form->setOnSuccess(function (Form $form) use ($dashboard, $pane, $action) { try { $pane = $dashboard->getPane($pane); $dashboard->removePane($pane->getTitle()); $dashboard->write(); Notification::success(t('Pane has been removed') . ': ' . $pane->getTitle()); return true; + } catch (\Zend_Config_Exception $e) { + $action->view->error = $e; + $action->view->config = $dashboard->createWriter(); + $action->render('error'); + return false; } catch (ProgrammingError $e) { Notification::error($e->getMessage()); return false; diff --git a/application/views/scripts/dashboard/error.phtml b/application/views/scripts/dashboard/error.phtml new file mode 100644 index 000000000..e5a0f3939 --- /dev/null +++ b/application/views/scripts/dashboard/error.phtml @@ -0,0 +1,13 @@ +
+

+

+ + config->getFilename(); ?>;. +
+ +

+
config->render(); ?>
+
+

+

error->getMessage(); ?>

+
diff --git a/application/views/scripts/dashboard/new-component.phtml b/application/views/scripts/dashboard/new-component.phtml index 456d14a65..46c8b2255 100644 --- a/application/views/scripts/dashboard/new-component.phtml +++ b/application/views/scripts/dashboard/new-component.phtml @@ -1,7 +1,6 @@
tabs ?>
-

form; ?> diff --git a/library/Icinga/File/Ini/IniWriter.php b/library/Icinga/File/Ini/IniWriter.php index cf9355b56..e3b757b78 100644 --- a/library/Icinga/File/Ini/IniWriter.php +++ b/library/Icinga/File/Ini/IniWriter.php @@ -229,4 +229,14 @@ class IniWriter extends Zend_Config_Writer_FileAbstract return $combinations; } + + /** + * Getter for filename + * + * @return string + */ + public function getFilename() + { + return $this->_filename; + } } diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index e663ddf44..c97bdf578 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -86,9 +86,11 @@ class Dashboard extends AbstractWidget } /** - * Write user specific dashboards to disk + * Create a writer object + * + * @return IniWriter */ - public function write() + public function createWriter() { $configFile = $this->getConfigFile(); $output = array(); @@ -105,8 +107,15 @@ class Dashboard extends AbstractWidget $co = new ConfigObject($output); $config = new Config($co); - $writer = new IniWriter(array('config' => $config, 'filename' => $configFile)); - $writer->write(); + return new IniWriter(array('config' => $config, 'filename' => $configFile)); + } + + /** + * Write user specific dashboards to disk + */ + public function write() + { + $this->createWriter()->write(); } /** From 91ed348a471c136f5eef078bc31a51f3342e4238 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 19 Nov 2014 13:25:11 +0100 Subject: [PATCH 19/31] css/login: center form --- public/css/icinga/login.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/icinga/login.less b/public/css/icinga/login.less index 8eb4e2258..1c3148360 100644 --- a/public/css/icinga/login.less +++ b/public/css/icinga/login.less @@ -75,7 +75,7 @@ form { margin-left: auto; margin-right: auto; - width: 40em; + width: 35em; } form input { From fecdb34388b87477068f66b446ea756d342a74e0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 19 Nov 2014 13:35:14 +0100 Subject: [PATCH 20/31] Packages: Update paths in icingacli --- packages/files/bin/icingacli | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/files/bin/icingacli b/packages/files/bin/icingacli index 1e9b0ef12..10b4857aa 100755 --- a/packages/files/bin/icingacli +++ b/packages/files/bin/icingacli @@ -1,6 +1,6 @@ #!/usr/bin/php dispatch(); +require_once '/usr/share/php/Icinga/Application/Cli.php'; + +Icinga\Application\Cli::start('/usr/share/icingaweb')->dispatch(); From 91233b0d6c59d91888e922d4deabf1571ccaca8c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 19 Nov 2014 13:36:02 +0100 Subject: [PATCH 21/31] Packages: Add files/apache/icingaweb.conf in favor of files/icingaweb-apache2.conf --- packages/files/apache/icingaweb.conf | 38 +++++++++++++++++++++++++++ packages/files/icingaweb-apache2.conf | 19 -------------- 2 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 packages/files/apache/icingaweb.conf delete mode 100644 packages/files/icingaweb-apache2.conf diff --git a/packages/files/apache/icingaweb.conf b/packages/files/apache/icingaweb.conf new file mode 100644 index 000000000..e8c0c8f00 --- /dev/null +++ b/packages/files/apache/icingaweb.conf @@ -0,0 +1,38 @@ +Alias /icingaweb "/usr/share/icingaweb/public" + + + Options SymLinksIfOwnerMatch + AllowOverride None + + + # Apache 2.4 + + Require all granted + + + + + # Apache 2.2 + Order allow,deny + Allow from all + + + SetEnv ICINGAWEB_CONFIGDIR "/etc/icingaweb" + + EnableSendfile Off + + + RewriteEngine on + RewriteBase /icingaweb/ + RewriteCond %{REQUEST_FILENAME} -s [OR] + RewriteCond %{REQUEST_FILENAME} -l [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^.*$ - [NC,L] + RewriteRule ^.*$ index.php [NC,L] + + + + DirectoryIndex error_norewrite.html + ErrorDocument 404 /error_norewrite.html + + diff --git a/packages/files/icingaweb-apache2.conf b/packages/files/icingaweb-apache2.conf deleted file mode 100644 index cde9aeec3..000000000 --- a/packages/files/icingaweb-apache2.conf +++ /dev/null @@ -1,19 +0,0 @@ -Alias /icingaweb "/usr/share/icingaweb/public" - - - Options SymLinksIfOwnerMatch - AllowOverride None - Order allow,deny - Allow from all - - # SetEnv ICINGAWEB_CONFIGDIR /etc/icingaweb - - RewriteEngine on - RewriteBase /icingaweb/ - RewriteCond %{REQUEST_FILENAME} -s [OR] - RewriteCond %{REQUEST_FILENAME} -l [OR] - RewriteCond %{REQUEST_FILENAME} -d - RewriteRule ^.*$ - [NC,L] - RewriteRule ^.*$ index.php [NC,L] - - From 6cb914af354babdbd33919c36851b70ad05810e3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 19 Nov 2014 13:42:49 +0100 Subject: [PATCH 22/31] Packages: Update library path in index.php --- packages/files/public/index.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/files/public/index.php b/packages/files/public/index.php index 1acee9445..ebd223c03 100644 --- a/packages/files/public/index.php +++ b/packages/files/public/index.php @@ -1,6 +1,3 @@ Date: Wed, 19 Nov 2014 13:42:59 +0100 Subject: [PATCH 23/31] Changes login screen and added header --- .../views/scripts/authentication/login.phtml | 1 + public/css/icinga/login.less | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index e931d0448..584d8ad16 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -5,6 +5,7 @@
+

Welcome to Icinga Web 2

errorInfo)): ?> diff --git a/public/css/icinga/login.less b/public/css/icinga/login.less index 1c3148360..cfae3c478 100644 --- a/public/css/icinga/login.less +++ b/public/css/icinga/login.less @@ -39,18 +39,17 @@ .form { position: absolute; font-size: 0.9em; - top: 50%; + top: 45%; left: 0; bottom: 0; right: 0; } .form h1 { - text-align: left; + text-align: center; font-size: 1.5em; - margin-left: auto; - margin-right: auto; - width: 12em; + margin-left: 2.3em; + border: none; color: @colorTextDefault; } @@ -108,9 +107,10 @@ } .footer { - margin-top: 2em; + margin-top: 7em; font-size: 0.9em; - text-align: center; + text-align: center; + margin-left: 5em; } div.config-note { From 968ede12df4dfb0cb5d583cd8aa9e5908bc6f905 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 19 Nov 2014 13:43:58 +0100 Subject: [PATCH 24/31] Packages: Remove files from rpm subdirectory Those files are superseded by those beneath files. --- packages/rpm/etc/httpd/conf.d/icingaweb.conf | 32 ------------------- .../rpm/etc/icingaweb2/authentication.ini | 6 ---- .../modules/monitoring/backends.ini | 8 ----- .../modules/monitoring/instances.ini | 2 -- packages/rpm/etc/icingaweb2/resources.ini | 28 ---------------- packages/rpm/usr/bin/icingacli | 6 ---- 6 files changed, 82 deletions(-) delete mode 100644 packages/rpm/etc/httpd/conf.d/icingaweb.conf delete mode 100644 packages/rpm/etc/icingaweb2/authentication.ini delete mode 100644 packages/rpm/etc/icingaweb2/modules/monitoring/backends.ini delete mode 100644 packages/rpm/etc/icingaweb2/modules/monitoring/instances.ini delete mode 100644 packages/rpm/etc/icingaweb2/resources.ini delete mode 100755 packages/rpm/usr/bin/icingacli diff --git a/packages/rpm/etc/httpd/conf.d/icingaweb.conf b/packages/rpm/etc/httpd/conf.d/icingaweb.conf deleted file mode 100644 index 1db9f20f2..000000000 --- a/packages/rpm/etc/httpd/conf.d/icingaweb.conf +++ /dev/null @@ -1,32 +0,0 @@ -Alias /icingaweb "/usr/share/icingaweb2/public" - - - Options SymLinksIfOwnerMatch - AllowOverride None - - - # Apache 2.4 - - Require all granted - - - - - # Apache 2.2 - Order allow,deny - Allow from all - - - SetEnv ICINGAWEB_CONFIGDIR /etc/icingaweb2 - - EnableSendfile Off - - RewriteEngine on - RewriteBase /icingaweb/ - RewriteCond %{REQUEST_FILENAME} -s [OR] - RewriteCond %{REQUEST_FILENAME} -l [OR] - RewriteCond %{REQUEST_FILENAME} -d - RewriteRule ^.*$ - [NC,L] - RewriteRule ^.*$ index.php [NC,L] - - diff --git a/packages/rpm/etc/icingaweb2/authentication.ini b/packages/rpm/etc/icingaweb2/authentication.ini deleted file mode 100644 index 3ec9c033a..000000000 --- a/packages/rpm/etc/icingaweb2/authentication.ini +++ /dev/null @@ -1,6 +0,0 @@ -[autologin] -backend = autologin - -[internal_db_authentication] -backend = db -resource = internal_db diff --git a/packages/rpm/etc/icingaweb2/modules/monitoring/backends.ini b/packages/rpm/etc/icingaweb2/modules/monitoring/backends.ini deleted file mode 100644 index 6dd67d4b5..000000000 --- a/packages/rpm/etc/icingaweb2/modules/monitoring/backends.ini +++ /dev/null @@ -1,8 +0,0 @@ -[localdb] -type = ido -resource = "ido" - -[locallive] -disabled = "1" -type = livestatus -resource = livestatus diff --git a/packages/rpm/etc/icingaweb2/modules/monitoring/instances.ini b/packages/rpm/etc/icingaweb2/modules/monitoring/instances.ini deleted file mode 100644 index 037baa8b9..000000000 --- a/packages/rpm/etc/icingaweb2/modules/monitoring/instances.ini +++ /dev/null @@ -1,2 +0,0 @@ -[icinga] -path = "/var/run/icinga2/cmd/icinga2.cmd" diff --git a/packages/rpm/etc/icingaweb2/resources.ini b/packages/rpm/etc/icingaweb2/resources.ini deleted file mode 100644 index 833f84ba8..000000000 --- a/packages/rpm/etc/icingaweb2/resources.ini +++ /dev/null @@ -1,28 +0,0 @@ -[internal_db] -type = db -db = mysql -host = localhost -port = 3306 -password = icingaweb -username = icingaweb -dbname = icingaweb - -[ido] -type = db -db = mysql -host = localhost -port = 3306 -password = icinga -username = icinga -dbname = icinga - -[livestatus] -type = livestatus -socket = /var/run/icinga2/cmd/livestatus - -[logfile] -type = file -filename = "/var/log/icingaweb2/icingaweb2.log" -fields = "/^(?[0-9]{4}(-[0-9]{2}){2}T[0-9]{2}(:[0-9]{2}){2}(\\+[0-9]{2}:[0-9]{2})?) - (?[A-Za-z]+) - (?.*)$/" -; format: PCRE -; diff --git a/packages/rpm/usr/bin/icingacli b/packages/rpm/usr/bin/icingacli deleted file mode 100755 index d6c4010b6..000000000 --- a/packages/rpm/usr/bin/icingacli +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/php -dispatch(); From 1d4f7f8806748a7f16682fe28008ebbcebd924d2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 19 Nov 2014 13:45:02 +0100 Subject: [PATCH 25/31] Packages: Rename rpm/README.md to RPM.d --- packages/rpm/{README.md => RPM.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/rpm/{README.md => RPM.md} (100%) diff --git a/packages/rpm/README.md b/packages/rpm/RPM.md similarity index 100% rename from packages/rpm/README.md rename to packages/rpm/RPM.md From a0ec7c2396d84be39fa2b67b755cb5f95ec29e64 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 19 Nov 2014 13:45:24 +0100 Subject: [PATCH 26/31] Packages: Move rpm/RPM.md one directory up --- packages/{rpm => }/RPM.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/{rpm => }/RPM.md (100%) diff --git a/packages/rpm/RPM.md b/packages/RPM.md similarity index 100% rename from packages/rpm/RPM.md rename to packages/RPM.md From 066ea782aaee7501b830df4b45d3b112c30cbb79 Mon Sep 17 00:00:00 2001 From: Bernd Erk Date: Wed, 19 Nov 2014 13:48:56 +0100 Subject: [PATCH 27/31] Fixes Check now button --- .../application/forms/Command/Object/CheckNowCommandForm.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php index 477624bb6..01006683f 100644 --- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php @@ -28,8 +28,6 @@ class CheckNowCommandForm extends ObjectsCommandForm */ public function addSubmitButton() { - $iconUrl = $this->getView()->href('img/icons/refresh_petrol.png'); - $this->addElements(array( array( 'button', @@ -38,7 +36,7 @@ class CheckNowCommandForm extends ObjectsCommandForm 'ignore' => true, 'type' => 'submit', 'value' => mt('monitoring', 'Check now'), - 'label' => ' ' . mt('monitoring', 'Check now'), + 'label' => ' ' . mt('monitoring', 'Check now'), 'decorators' => array('ViewHelper'), 'escape' => false, 'class' => 'link-like' From e63fc466cd21d0edc0e2b498b007df50af60173e Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 19 Nov 2014 13:38:57 +0100 Subject: [PATCH 28/31] packaging/debian: enforce stricter permissions --- packages/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/debian/rules b/packages/debian/rules index c91eb8230..fbe100736 100755 --- a/packages/debian/rules +++ b/packages/debian/rules @@ -23,7 +23,7 @@ binary: dh_installdebconf dh_installinfo dh_installinit - dpkg-statoverride --force --add root www-data 2775 /etc/icingaweb + dpkg-statoverride --force --add root www-data 2770 /etc/icingaweb dh_compress dh_fixperms dh_strip From 58634ad2b719e66edb267f41d49c872c322868a1 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 19 Nov 2014 14:03:21 +0100 Subject: [PATCH 29/31] README.first: removed, we're going stable --- packages/debian/README.first | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 packages/debian/README.first diff --git a/packages/debian/README.first b/packages/debian/README.first deleted file mode 100644 index 00799671f..000000000 --- a/packages/debian/README.first +++ /dev/null @@ -1,2 +0,0 @@ -PLEASE DO NOT USE THIS YET. Still preparing basic stuff, should be ready -with 2.0.0-beta1 From 6d28fbbfecf7e4a61de595019ad29cb36f22025c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 19 Nov 2014 14:04:56 +0100 Subject: [PATCH 30/31] packaging/debian: preparing release --- packages/debian/icingacli.install | 1 + packages/debian/icingaweb.install | 7 ++++++- packages/debian/libicinga-common-php.dirs | 1 - packages/debian/libicinga-common-php.install | 2 -- packages/debian/libicinga-vendor-php.install | 1 - 5 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 packages/debian/libicinga-common-php.dirs delete mode 100644 packages/debian/libicinga-common-php.install delete mode 100644 packages/debian/libicinga-vendor-php.install diff --git a/packages/debian/icingacli.install b/packages/debian/icingacli.install index de1bccf4c..be3db5e1c 100644 --- a/packages/debian/icingacli.install +++ b/packages/debian/icingacli.install @@ -1,2 +1,3 @@ packages/files/bin/icingacli usr/bin etc/bash_completion.d etc/bash_completion.d +application/clicommands usr/share/icingaweb/application diff --git a/packages/debian/icingaweb.install b/packages/debian/icingaweb.install index 8642199b1..8e7ba892a 100644 --- a/packages/debian/icingaweb.install +++ b/packages/debian/icingaweb.install @@ -1,5 +1,10 @@ public/css usr/share/icingaweb/public public/img usr/share/icingaweb/public -public/js usr/share/icingaweb/public +public/js usr/share/icingaweb/public +public/error_norewrite.html usr/share/icingaweb/public +application/controllers usr/share/icingaweb/application +application/fonts usr/share/icingaweb/application +application/layouts usr/share/icingaweb/application +application/views usr/share/icingaweb/application packages/files/public/index.php usr/share/icingaweb/public packages/files/icingaweb-apache2.conf etc/apache2/conf.d diff --git a/packages/debian/libicinga-common-php.dirs b/packages/debian/libicinga-common-php.dirs deleted file mode 100644 index 00ec00632..000000000 --- a/packages/debian/libicinga-common-php.dirs +++ /dev/null @@ -1 +0,0 @@ -etc/icingaweb diff --git a/packages/debian/libicinga-common-php.install b/packages/debian/libicinga-common-php.install deleted file mode 100644 index 65bd2f999..000000000 --- a/packages/debian/libicinga-common-php.install +++ /dev/null @@ -1,2 +0,0 @@ -application usr/share/icingaweb -modules usr/share/icingaweb diff --git a/packages/debian/libicinga-vendor-php.install b/packages/debian/libicinga-vendor-php.install deleted file mode 100644 index c2dd6e0e6..000000000 --- a/packages/debian/libicinga-vendor-php.install +++ /dev/null @@ -1 +0,0 @@ -library/IcingaVendor usr/share/php From c36c8be98c7de4c5da952571283ae1ded08c96dc Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 19 Nov 2014 14:16:36 +0100 Subject: [PATCH 31/31] packaging/debian: prepare release --- packages/debian/icingaweb-common.dirs | 1 + packages/debian/icingaweb-common.install | 2 ++ packages/debian/icingaweb-module-doc.install | 1 + packages/debian/icingaweb-module-monitoring.install | 1 + packages/debian/icingaweb-module-setup.install | 1 + packages/debian/icingaweb-module-test.install | 1 + packages/debian/icingaweb-module-translation.install | 1 + packages/debian/icingaweb-vendor-htmlpurifier.install | 1 + packages/debian/icingaweb-vendor-jshrink.install | 1 + packages/debian/icingaweb-vendor-lessphp.install | 1 + packages/debian/icingaweb-vendor-parsedown.install | 1 + packages/debian/icingaweb-vendor-zend.install | 1 + packages/debian/icingaweb.install | 2 +- 13 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 packages/debian/icingaweb-common.dirs create mode 100644 packages/debian/icingaweb-common.install create mode 100644 packages/debian/icingaweb-module-doc.install create mode 100644 packages/debian/icingaweb-module-monitoring.install create mode 100644 packages/debian/icingaweb-module-setup.install create mode 100644 packages/debian/icingaweb-module-test.install create mode 100644 packages/debian/icingaweb-module-translation.install create mode 100644 packages/debian/icingaweb-vendor-htmlpurifier.install create mode 100644 packages/debian/icingaweb-vendor-jshrink.install create mode 100644 packages/debian/icingaweb-vendor-lessphp.install create mode 100644 packages/debian/icingaweb-vendor-parsedown.install create mode 100644 packages/debian/icingaweb-vendor-zend.install diff --git a/packages/debian/icingaweb-common.dirs b/packages/debian/icingaweb-common.dirs new file mode 100644 index 000000000..00ec00632 --- /dev/null +++ b/packages/debian/icingaweb-common.dirs @@ -0,0 +1 @@ +etc/icingaweb diff --git a/packages/debian/icingaweb-common.install b/packages/debian/icingaweb-common.install new file mode 100644 index 000000000..91a34bcee --- /dev/null +++ b/packages/debian/icingaweb-common.install @@ -0,0 +1,2 @@ +application/locales usr/share/icingaweb/application +modules usr/share/icingaweb diff --git a/packages/debian/icingaweb-module-doc.install b/packages/debian/icingaweb-module-doc.install new file mode 100644 index 000000000..1482e8c66 --- /dev/null +++ b/packages/debian/icingaweb-module-doc.install @@ -0,0 +1 @@ +modules/doc usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-monitoring.install b/packages/debian/icingaweb-module-monitoring.install new file mode 100644 index 000000000..1482e8c66 --- /dev/null +++ b/packages/debian/icingaweb-module-monitoring.install @@ -0,0 +1 @@ +modules/doc usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-setup.install b/packages/debian/icingaweb-module-setup.install new file mode 100644 index 000000000..4fdd070d2 --- /dev/null +++ b/packages/debian/icingaweb-module-setup.install @@ -0,0 +1 @@ +modules/setup usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-test.install b/packages/debian/icingaweb-module-test.install new file mode 100644 index 000000000..e0db79bca --- /dev/null +++ b/packages/debian/icingaweb-module-test.install @@ -0,0 +1 @@ +modules/test usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-translation.install b/packages/debian/icingaweb-module-translation.install new file mode 100644 index 000000000..5a89d3d4d --- /dev/null +++ b/packages/debian/icingaweb-module-translation.install @@ -0,0 +1 @@ +modules/translation usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-vendor-htmlpurifier.install b/packages/debian/icingaweb-vendor-htmlpurifier.install new file mode 100644 index 000000000..298284f29 --- /dev/null +++ b/packages/debian/icingaweb-vendor-htmlpurifier.install @@ -0,0 +1 @@ +library/vendor/HTMLPurifier usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-jshrink.install b/packages/debian/icingaweb-vendor-jshrink.install new file mode 100644 index 000000000..0db6b408b --- /dev/null +++ b/packages/debian/icingaweb-vendor-jshrink.install @@ -0,0 +1 @@ +library/vendor/JShrink usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-lessphp.install b/packages/debian/icingaweb-vendor-lessphp.install new file mode 100644 index 000000000..1ace5481e --- /dev/null +++ b/packages/debian/icingaweb-vendor-lessphp.install @@ -0,0 +1 @@ +library/vendor/Zend usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-parsedown.install b/packages/debian/icingaweb-vendor-parsedown.install new file mode 100644 index 000000000..13954e16b --- /dev/null +++ b/packages/debian/icingaweb-vendor-parsedown.install @@ -0,0 +1 @@ +library/vendor/Parsedown usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-zend.install b/packages/debian/icingaweb-vendor-zend.install new file mode 100644 index 000000000..1ace5481e --- /dev/null +++ b/packages/debian/icingaweb-vendor-zend.install @@ -0,0 +1 @@ +library/vendor/Zend usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb.install b/packages/debian/icingaweb.install index 8e7ba892a..0fdee4dc0 100644 --- a/packages/debian/icingaweb.install +++ b/packages/debian/icingaweb.install @@ -7,4 +7,4 @@ application/fonts usr/share/icingaweb/application application/layouts usr/share/icingaweb/application application/views usr/share/icingaweb/application packages/files/public/index.php usr/share/icingaweb/public -packages/files/icingaweb-apache2.conf etc/apache2/conf.d +packages/files/apache/icingaweb.conf etc/apache2/conf.d