Merge branch 'feature/lists-linking-to-details-12973'
This commit is contained in:
commit
8449bd2f84
|
@ -99,6 +99,13 @@ class ServiceController extends ObjectController
|
|||
}
|
||||
}
|
||||
|
||||
public function futureoverviewIndexAction()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
$title = $this->view->title = $object->object_name;
|
||||
$this->singleTab($this->translate('Icinga Service Template'));
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$object = $this->object;
|
||||
|
|
|
@ -67,7 +67,7 @@ class IcingaHostServiceTable extends QuickTable
|
|||
}
|
||||
}
|
||||
|
||||
return $this->url('director/service', $params);
|
||||
return $this->url('director/service/edit', $params);
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
|
|
|
@ -2,34 +2,29 @@
|
|||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Data\Limitable;
|
||||
use Icinga\Module\Director\Web\Table\IcingaObjectTable;
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaHostTable extends IcingaObjectTable
|
||||
class IcingaHostTable extends QuickTable
|
||||
{
|
||||
protected $searchColumns = array(
|
||||
'host',
|
||||
'address',
|
||||
'display_name'
|
||||
);
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
if ($this->connection()->isPgsql()) {
|
||||
$parents = "ARRAY_TO_STRING(ARRAY_AGG(ih.object_name ORDER BY hi.weight), ', ')";
|
||||
} else {
|
||||
$parents = "GROUP_CONCAT(ih.object_name ORDER BY hi.weight SEPARATOR ', ')";
|
||||
}
|
||||
|
||||
return array(
|
||||
'id' => 'h.id',
|
||||
'host' => 'h.object_name',
|
||||
'object_type' => 'h.object_type',
|
||||
'address' => 'h.address',
|
||||
'zone' => 'z.object_name',
|
||||
'parents' => $parents,
|
||||
'id' => 'h.id',
|
||||
'host' => 'h.object_name',
|
||||
'object_type' => 'h.object_type',
|
||||
'address' => 'h.address',
|
||||
'disabled' => 'h.disabled',
|
||||
'display_name' => 'h.address',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return $this->url('director/host', array('name' => $row->host));
|
||||
}
|
||||
|
@ -43,12 +38,21 @@ class IcingaHostTable extends IcingaObjectTable
|
|||
);
|
||||
}
|
||||
|
||||
protected function getRowClasses($row)
|
||||
{
|
||||
if ($row->disabled === 'y') {
|
||||
return 'disabled';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'host' => $view->translate('Hostname'),
|
||||
'parents' => $view->translate('Imports'),
|
||||
'address' => $view->translate('Address'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -57,35 +61,7 @@ class IcingaHostTable extends IcingaObjectTable
|
|||
return $this->db()->select()->from(
|
||||
array('h' => 'icinga_host'),
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('z' => 'icinga_zone'),
|
||||
'h.zone_id = z.id',
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('hi' => 'icinga_host_inheritance'),
|
||||
'hi.host_id = h.id',
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('ih' => 'icinga_host'),
|
||||
'hi.parent_host_id = ih.id',
|
||||
array()
|
||||
)->group('h.id')
|
||||
->group('z.id')
|
||||
->order('h.object_name');
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
$db = $this->db();
|
||||
$sub = clone($this->getBaseQuery());
|
||||
$sub->columns($this->getColumns());
|
||||
$this->applyFiltersToQuery($sub);
|
||||
$query = $db->select()->from(
|
||||
array('sub' => $sub),
|
||||
'COUNT(*)'
|
||||
);
|
||||
|
||||
return $db->fetchOne($query);
|
||||
)->order('h.object_name');
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
|
|
|
@ -6,6 +6,88 @@ use Icinga\Module\Director\Tables\IcingaHostTable;
|
|||
|
||||
class IcingaHostTemplateTable extends IcingaHostTable
|
||||
{
|
||||
protected $searchColumns = array(
|
||||
'host',
|
||||
'display_name'
|
||||
);
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'host' => $view->translate('Template name'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderAdditionalActions($row)
|
||||
{
|
||||
$htm = '';
|
||||
$view = $this->view();
|
||||
|
||||
if ($row->object_type === 'template') {
|
||||
$htm .= $view->qlink(
|
||||
'',
|
||||
'director/host/add?type=object',
|
||||
array('imports' => $row->host),
|
||||
array(
|
||||
'class' => 'icon-plus',
|
||||
'title' => $view->translate(
|
||||
'Create a new host based on this template'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
// TODO: Not yet
|
||||
if ($cnt = $row->cnt_child_templates) {
|
||||
if ((int) $cnt === 1) {
|
||||
$title = $view->translate('Show one host template using this template');
|
||||
} else {
|
||||
$title = sprintf(
|
||||
$view->translate('Show %d host templates using this template'),
|
||||
$cnt
|
||||
);
|
||||
}
|
||||
|
||||
$htm .= $view->qlink(
|
||||
'',
|
||||
'director/hosts/bytemplate',
|
||||
array('name' => $row->host),
|
||||
array(
|
||||
'class' => 'icon-sitemap',
|
||||
'title' => $title
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if ($cnt = $row->cnt_child_hosts) {
|
||||
if ((int) $cnt === 1) {
|
||||
$title = $view->translate('Show one host using this template');
|
||||
} else {
|
||||
$title = sprintf(
|
||||
$view->translate('Show %d hosts using this template'),
|
||||
$cnt
|
||||
);
|
||||
}
|
||||
|
||||
$htm .= $view->qlink(
|
||||
'',
|
||||
'director/hosts/bytemplate',
|
||||
array('name' => $row->host),
|
||||
array(
|
||||
'class' => 'icon-host',
|
||||
'title' => $title
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return $htm;
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
{
|
||||
return $this->getUnfilteredQuery()->where('h.object_type = ?', 'template');
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<h1><?= $this->escape($this->title) ?></h1>
|
||||
<span class="action-links">
|
||||
<?= $this->actionLinks ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
This is a service template. [As it has no command You might want to assign it:
|
||||
|
||||
<ul>
|
||||
<li>Assign it to one or more single hosts</li>
|
||||
<li>Assign it to all hosts inheriting a specific template</li>
|
||||
<li>Assign it base on rule/rule definitions
|
||||
|
||||
Admin tasks:
|
||||
<ul>
|
||||
<li>Control which fields (custom vars) can be filled by your users
|
||||
<li>Provide sets of services
|
||||
</ul>
|
||||
</div>
|
|
@ -9,6 +9,7 @@ use Icinga\Exception\NotFoundError;
|
|||
use Icinga\Module\Director\Exception\NestingError;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
abstract class ObjectController extends ActionController
|
||||
|
@ -186,8 +187,10 @@ abstract class ObjectController extends ActionController
|
|||
$ltype = strtolower($type);
|
||||
|
||||
$url = sprintf('director/%ss', $ltype);
|
||||
/** @var DirectorObjectForm $form */
|
||||
$form = $this->view->form = $this->loadForm('icinga' . ucfirst($type))
|
||||
->setDb($this->db())
|
||||
->presetImports($this->params->shift('imports'))
|
||||
->setApi($this->getApiIfAvailable())
|
||||
->setSuccessUrl($url);
|
||||
|
||||
|
|
|
@ -112,7 +112,10 @@ abstract class ObjectsController extends ActionController
|
|||
$table = 'icinga' . ucfirst($type);
|
||||
} elseif ($dummy->isTemplate()) {
|
||||
$this->getTabs()->activate('templates');
|
||||
// Trick the autoloader
|
||||
$table = 'icinga' . ucfirst($type);
|
||||
$this->loadTable($table);
|
||||
$table .= 'Template';
|
||||
} else {
|
||||
$this->getTabs()->activate('objects');
|
||||
$table = 'icinga' . ucfirst($type);
|
||||
|
|
|
@ -45,12 +45,27 @@ abstract class DirectorObjectForm extends QuickForm
|
|||
/** @var CoreApi */
|
||||
private $api;
|
||||
|
||||
private $presetImports;
|
||||
|
||||
public function setPreferredObjectType($type)
|
||||
{
|
||||
$this->preferredObjectType = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function presetImports($imports)
|
||||
{
|
||||
if (! empty($imports)) {
|
||||
if (is_array($imports)) {
|
||||
$this->presetImports = $imports;
|
||||
} else {
|
||||
$this->presetImports = array($imports);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
*
|
||||
|
@ -248,7 +263,7 @@ abstract class DirectorObjectForm extends QuickForm
|
|||
unset($props['vars']);
|
||||
}
|
||||
|
||||
$this->setDefaults($this->removeNullProperties($props));
|
||||
$this->setDefaults($this->removeEmptyProperties($props));
|
||||
|
||||
if ($resolve) {
|
||||
$this->showInheritedProperties($object);
|
||||
|
@ -270,11 +285,11 @@ abstract class DirectorObjectForm extends QuickForm
|
|||
}
|
||||
}
|
||||
|
||||
protected function removeNullProperties($props)
|
||||
protected function removeEmptyProperties($props)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($props as $k => $v) {
|
||||
if ($v !== null && $v !== '') {
|
||||
if ($v !== null && $v !== '' && $v !== array()) {
|
||||
$result[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
@ -913,6 +928,7 @@ abstract class DirectorObjectForm extends QuickForm
|
|||
'required' => ($required !== null ? $required : !$this->isTemplate()),
|
||||
'multiOptions' => $this->optionallyAddFromEnum($enum),
|
||||
'sorted' => true,
|
||||
'value' => $this->presetImports,
|
||||
'class' => 'autosubmit'
|
||||
));
|
||||
|
||||
|
|
|
@ -791,6 +791,11 @@ table th.actions, table td.actions {
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
table tr.disabled td {
|
||||
color: @gray-light;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* Simple table, test */
|
||||
table.syncstate {
|
||||
tr td:first-child {
|
||||
|
|
Loading…
Reference in New Issue