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
1 changed files with 25 additions and 48 deletions

View File

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