ConfigController: use all the shiny new components

New tables, Deployment info, tabs
This commit is contained in:
Thomas Gelf 2017-07-20 08:24:00 +02:00
parent cca4092151
commit fa955b0449

View File

@ -3,14 +3,20 @@
namespace Icinga\Module\Director\Controllers; namespace Icinga\Module\Director\Controllers;
use Icinga\Module\Director\ConfigDiff; use Icinga\Module\Director\ConfigDiff;
use Icinga\Module\Director\Forms\DeployConfigForm;
use Icinga\Module\Director\Forms\SettingsForm; use Icinga\Module\Director\Forms\SettingsForm;
use Icinga\Module\Director\IcingaConfig\IcingaConfig; use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\Objects\DirectorDeploymentLog;
use Icinga\Module\Director\Settings; use Icinga\Module\Director\Settings;
use Icinga\Module\Director\Web\Table\ActivityLogTable;
use Icinga\Module\Director\Web\Table\DeploymentLogTable;
use Icinga\Module\Director\Util; use Icinga\Module\Director\Util;
use Icinga\Module\Director\Web\Controller\ActionController; use Icinga\Module\Director\Web\Controller\ActionController;
use Icinga\Module\Director\Web\Tabs\InfraTabs;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Web\Url; use Icinga\Web\Url;
use Exception; use Exception;
use ipl\Html\Link;
class ConfigController extends ActionController class ConfigController extends ActionController
{ {
@ -23,8 +29,9 @@ class ConfigController extends ActionController
public function deploymentsAction() public function deploymentsAction()
{ {
$this->assertPermission('director/deploy'); $this->assertPermission('director/deploy');
$this->addTitle($this->translate('Deployments'));
try { try {
if ($this->db()->hasUncollectedDeployments()) { if (DirectorDeploymentLog::hasUncollected($this->db())) {
$this->setAutorefreshInterval(5); $this->setAutorefreshInterval(5);
$this->api()->collectLogFiles($this->db()); $this->api()->collectLogFiles($this->db());
} else { } else {
@ -33,26 +40,25 @@ class ConfigController extends ActionController
} catch (Exception $e) { } catch (Exception $e) {
// No problem, Icinga might be reloading // No problem, Icinga might be reloading
} }
$this->view->addLink = $this->view->qlink( $this->actions()->add(Link::create(
$this->translate('Render config'), $this->translate('Render config'),
'director/config/store', 'director/config/store',
null, null,
array('class' => 'icon-wrench') ['class' => 'icon-wrench']
); ));
$this->overviewTabs()->activate('deploymentlog'); $this->tabs(new InfraTabs($this->Auth()))->activate('deploymentlog');
$this->view->title = $this->translate('Deployments'); $table = new DeploymentLogTable($this->db());
$this->prepareTable('deploymentLog');
try { try {
// Move elsewhere // Move elsewhere
$this->view->table->setActiveStageName( $table->setActiveStageName(
$this->api()->getActiveStageName() $this->api()->getActiveStageName()
); );
} catch (Exception $e) { } catch (Exception $e) {
// Don't care // Don't care
} }
$this->render('objects/table', null, 'objects'); $table->renderTo($this);
} }
public function deployAction() public function deployAction()
@ -116,29 +122,27 @@ class ConfigController extends ActionController
$this->assertPermission('director/audit'); $this->assertPermission('director/audit');
$this->setAutorefreshInterval(10); $this->setAutorefreshInterval(10);
$this->overviewTabs()->activate('activitylog'); $this->tabs(new InfraTabs($this->Auth()))->activate('activitylog');
$this->view->title = $this->translate('Activity Log'); $this->addTitle($this->translate('Activity Log'));
$lastDeployedId = $this->db()->getLastDeploymentActivityLogId(); $lastDeployedId = $this->db()->getLastDeploymentActivityLogId();
$this->prepareTable('activityLog'); $table = new ActivityLogTable($this->db());
$this->view->table->setLastDeployedId($lastDeployedId); $table->setLastDeployedId($lastDeployedId);
$this->view->addLink = $this->view->qlink( $this->actions()->add(Link::create(
$this->translate('My changes'), $this->translate('My changes'),
$this->getRequest()->getUrl() $this->url()
->with('author', $this->Auth()->getUser()->getUsername()) ->with('author', $this->Auth()->getUser()->getUsername())
->without('page'), ->without('page'),
null, null,
array('class' => 'icon-user', 'data-base-target' => '_self') array('class' => 'icon-user', 'data-base-target' => '_self')
); ));
if ($this->hasPermission('director/deploy')) { if ($this->hasPermission('director/deploy')) {
$this->view->addLink .= $this $this->actions()->add(DeployConfigForm::load()
->loadForm('DeployConfig')
->setDb($this->db()) ->setDb($this->db())
->setApi($this->api()) ->setApi($this->api())
->handleRequest(); ->handleRequest());
} }
$this->provideFilterEditorForTable($this->view->table);
$this->setViewScript('list/table'); $table->renderTo($this);
} }
public function settingsAction() public function settingsAction()
@ -323,33 +327,6 @@ class ConfigController extends ActionController
$this->view->output = $d->renderHtml(); $this->view->output = $d->renderHtml();
} }
protected function overviewTabs()
{
$this->view->tabs = $tabs = $this->getTabs();
if ($this->hasPermission('director/audit')) {
$tabs->add(
'activitylog',
array(
'label' => $this->translate('Activity Log'),
'url' => 'director/config/activities'
)
);
}
if ($this->hasPermission('director/deploy')) {
$tabs->add(
'deploymentlog',
array(
'label' => $this->translate('Deployments'),
'url' => 'director/config/deployments'
)
);
}
return $this->view->tabs;
}
protected function configTabs() protected function configTabs()
{ {
$tabs = $this->getTabs(); $tabs = $this->getTabs();