Skip to content

Commit

Permalink
Merge branch 'bugfix/make-all-views-dashboard-compliant-7876'
Browse files Browse the repository at this point in the history
fixes #7876
  • Loading branch information
Johannes Meyer committed Apr 20, 2015
2 parents e812bed + da7aa23 commit cc573c1
Show file tree
Hide file tree
Showing 59 changed files with 545 additions and 459 deletions.
12 changes: 10 additions & 2 deletions application/controllers/ConfigController.php
Expand Up @@ -11,14 +11,14 @@
use Icinga\Forms\Config\ResourceConfigForm;
use Icinga\Forms\ConfirmRemovalForm;
use Icinga\Security\SecurityException;
use Icinga\Web\Controller\ActionController;
use Icinga\Web\Controller;
use Icinga\Web\Notification;
use Icinga\Web\Widget;

/**
* Application and module configuration
*/
class ConfigController extends ActionController
class ConfigController extends Controller
{
/**
* The first allowed config action according to the user's permissions
Expand Down Expand Up @@ -130,6 +130,14 @@ public function modulesAction()
->order('enabled', 'desc')
->order('name')
->paginate();
$this->setupLimitControl();
$this->setupPaginationControl($this->view->modules);
// TODO: Not working
/*$this->setupSortControl(array(
'name' => $this->translate('Modulename'),
'path' => $this->translate('Installation Path'),
'enabled' => $this->translate('State')
));*/
}

public function moduleAction()
Expand Down
7 changes: 6 additions & 1 deletion application/controllers/ListController.php
Expand Up @@ -3,6 +3,8 @@

use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction;
use Icinga\Web\Widget\Tabextension\OutputFormat;
use Icinga\Application\Config;
use Icinga\Application\Logger;
use Icinga\Data\ConfigObject;
Expand All @@ -29,7 +31,7 @@ protected function addTitleTab($action)
'list/'
. str_replace(' ', '', $action)
)
))->activate($action);
))->extend(new OutputFormat())->extend(new DashboardAction())->activate($action);
}

/**
Expand All @@ -52,5 +54,8 @@ public function applicationlogAction()
'fields' => $pattern
)));
$this->view->logData = $resource->select()->order('DESC')->paginate();

$this->setupLimitControl();
$this->setupPaginationControl($this->view->logData);
}
}
10 changes: 7 additions & 3 deletions application/views/scripts/config/modules.phtml
@@ -1,8 +1,12 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs ?>
<?= $this->paginationControl($modules) ?>
<?= $this->tabs; ?>
<?= $this->sortBox; ?>
<?= $this->limiter; ?>
<?= $this->paginator; ?>
<?= $this->filterEditor; ?>
</div>

<?php endif ?>
<div class="content">
<table class="action" data-base-target="_next">
<tbody>
Expand Down
11 changes: 7 additions & 4 deletions application/views/scripts/list/applicationlog.phtml
@@ -1,9 +1,12 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs->render($this) ?>
<div style="margin-top: 1em"></div>
<?= $this->logData ?>
<?= $this->tabs; ?>
<?= $this->sortBox; ?>
<?= $this->limiter; ?>
<?= $this->paginator; ?>
<?= $this->filterEditor; ?>
</div>

<?php endif ?>
<div class="content">
<?php if ($this->logData !== null): ?>
<table class="action">
Expand Down
78 changes: 70 additions & 8 deletions library/Icinga/Web/Controller.php
Expand Up @@ -3,8 +3,10 @@

namespace Icinga\Web;

use Zend_Paginator;
use Icinga\Web\Controller\ModuleActionController;
use Icinga\Web\Widget\SortBox;
use Icinga\Web\Widget\Limiter;

/**
* This is the controller all modules should inherit from
Expand All @@ -14,17 +16,77 @@
class Controller extends ModuleActionController
{
/**
* Create a sort control box at the 'sortControl' view parameter
* Create a SortBox widget at the `sortBox' view property
*
* @param array $columns An array containing the sort columns, with the
* submit value as the key and the label as the value
* In case the current view has been requested as compact this method does nothing.
*
* @param array $columns An array containing the sort columns, with the
* submit value as the key and the label as the value
*
* @return $this
*/
protected function setupSortControl(array $columns)
{
$req = $this->getRequest();
$this->view->sortControl = SortBox::create(
'sortbox-' . $req->getActionName(),
$columns
)->applyRequest($req);
if (! $this->view->compact) {
$req = $this->getRequest();
$this->view->sortBox = SortBox::create(
'sortbox-' . $req->getActionName(),
$columns
)->applyRequest($req);
}

return $this;
}

/**
* Create a Limiter widget at the `limiter' view property
*
* In case the current view has been requested as compact this method does nothing.
*
* @return $this
*/
protected function setupLimitControl()
{
if (! $this->view->compact) {
$this->view->limiter = new Limiter();
}

return $this;
}

/**
* Set the view property `paginator' to the given Zend_Paginator
*
* In case the current view has been requested as compact this method does nothing.
*
* @param Zend_Paginator $paginator The Zend_Paginator for which to show a pagination control
*
* @return $this
*/
protected function setupPaginationControl(Zend_Paginator $paginator)
{
if (! $this->view->compact) {
$this->view->paginator = $paginator;
}

return $this;
}

/**
* Set the view property `filterEditor' to the given FilterEditor
*
* In case the current view has been requested as compact this method does nothing.
*
* @param Form $editor The FilterEditor
*
* @return $this
*/
protected function setupFilterControl($editor)
{
if (! $this->view->compact) {
$this->view->filterEditor = $editor;
}

return $this;
}
}
1 change: 1 addition & 0 deletions library/Icinga/Web/Controller/ActionController.php
Expand Up @@ -87,6 +87,7 @@ public function __construct(
$this->_helper->layout()->isIframe = $request->getUrl()->shift('isIframe');
$this->_helper->layout()->moduleName = false;

$this->view->compact = $request->getParam('view') === 'compact';
if ($this->rerenderLayout = $request->getUrl()->shift('renderLayout')) {
$this->xhrLayout = 'body';
}
Expand Down
3 changes: 2 additions & 1 deletion library/Icinga/Web/StyleSheet.php
Expand Up @@ -26,7 +26,8 @@ class StyleSheet
'css/icinga/pagination.less',
'css/icinga/monitoring-colors.less',
'css/icinga/selection-toolbar.less',
'css/icinga/login.less'
'css/icinga/login.less',
'css/icinga/controls.less'
);

public static function compileForPdf()
Expand Down
32 changes: 17 additions & 15 deletions library/Icinga/Web/Widget/FilterEditor.php
Expand Up @@ -649,7 +649,7 @@ protected function applyChanges($changes)

public function renderSearch()
{
$html = ' <form method="post" class="inline dontprint" action="'
$html = ' <form method="post" class="search inline dontprint" action="'
. $this->preservedUrl()
. '"><input type="text" name="q" style="width: 8em" class="search" value="" placeholder="'
. t('Search...')
Expand Down Expand Up @@ -678,20 +678,22 @@ public function renderSearch()
public function render()
{
if (! $this->preservedUrl()->getParam('modifyFilter')) {
return $this->renderSearch() . $this->shorten($this->filter, 50);
}
return $this->renderSearch()
. '<form action="'
. Url::fromRequest()
. '" class="filterEditor" method="POST">'
. '<ul class="tree widgetFilter"><li>'
. $this->renderFilter($this->filter)
. '</li></ul>'
. '<div style="float: right">'
. '<input type="submit" name="submit" value="Apply" />'
. '<input type="submit" name="cancel" value="Cancel" />'
. '</div>'
. '</form>';
return '<div class="filter">' . $this->renderSearch() . $this->shorten($this->filter, 50) . '</div>';
}
return '<div class="filter">'
. $this->renderSearch()
. '<form action="'
. Url::fromRequest()
. '" class="editor" method="POST">'
. '<ul class="tree"><li>'
. $this->renderFilter($this->filter)
. '</li></ul>'
. '<div class="buttons">'
. '<input type="submit" name="submit" value="Apply" />'
. '<input type="submit" name="cancel" value="Cancel" />'
. '</div>'
. '</form>'
. '</div>';
}

protected function shorten($string, $length)
Expand Down

0 comments on commit cc573c1

Please sign in to comment.