Skip to content

Commit

Permalink
GroupController: Add showAction
Browse files Browse the repository at this point in the history
refs #8826
  • Loading branch information
Johannes Meyer committed May 20, 2015
1 parent 94cd4b9 commit ed166d6
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
25 changes: 25 additions & 0 deletions application/controllers/GroupController.php
Expand Up @@ -96,6 +96,28 @@ function ($b) { return $b->getName(); },
);
}

/**
* Show a group
*/
public function showAction()
{
$groupName = $this->params->getRequired('group');
$backend = $this->getUserGroupBackend($this->params->getRequired('backend'));

$group = $backend->select(array(
'group_name',
'parent_name',
'created_at',
'last_modified'
))->where('group_name', $groupName)->fetchRow();
if ($group === false) {
$this->httpNotFound(sprintf($this->translate('Group "%s" not found'), $groupName));
}

$this->view->group = $group;
$this->view->backend = $backend;
}

/**
* Add a group
*/
Expand Down Expand Up @@ -125,6 +147,9 @@ public function editAction()
}

$form = new UserGroupForm();
$form->setRedirectUrl(
Url::fromPath('group/show', array('backend' => $backend->getName(), 'group' => $groupName))
);
$form->setRepository($backend);
$form->edit($groupName, get_object_vars($row))->handleRequest();

Expand Down
7 changes: 6 additions & 1 deletion application/views/scripts/group/list.phtml
Expand Up @@ -44,7 +44,12 @@ if (count($groups) > 0): ?>
<tbody>
<?php foreach ($groups as $group): ?>
<tr>
<td clas="group-name"><?= $this->escape($group->group_name); ?></td>
<td class="group-name"><?= $this->qlink($group->group_name, 'group/show', array(
'backend' => $backend->getName(),
'group' => $group->group_name
), array(
'title' => sprintf($this->translate('Show detailed information for group %s'), $group->group_name)
)); ?></td>
<?php if ($reducible): ?>
<td class="group-remove">
<?= $this->qlink(
Expand Down
45 changes: 45 additions & 0 deletions application/views/scripts/group/show.phtml
@@ -0,0 +1,45 @@
<?php

use Icinga\Data\Updatable;

$editLink = null;
if ($backend instanceof Updatable) {
$editLink = $this->qlink(
null,
'group/edit',
array(
'backend' => $backend->getName(),
'group' => $group->group_name
),
array(
'title' => sprintf($this->translate('Edit group %s'), $group->group_name),
'class' => 'group-edit',
'icon' => 'edit'
)
);
}

?>
<div class="controls">
<?php if (! $this->compact): ?>
<?= $tabs->showOnlyCloseButton(); ?>
<?php endif ?>
<div class="group-header">
<p class="group-name"><strong><?= $this->escape($group->group_name); ?></strong></p> <?= $editLink; ?>
<p class="group-parent"><strong><?= $this->translate('Parent'); ?>:</strong> <?= $group->parent_name === null ? '-' : $this->qlink(
$group->parent_name,
'group/show',
array(
'backend' => $backend->getName(),
'group' => $group->parent_name
),
array(
'title' => sprintf($this->translate('Show detailed information for group %s'), $group->parent_name)
)
); ?></p>
<p class="group-created"><strong><?= $this->translate('Created at'); ?>:</strong> <?= $group->created_at === null ? '-' : $this->formatDateTime($group->created_at); ?></p>
<p class="group-modified"><strong><?= $this->translate('Last modified'); ?>:</strong> <?= $group->last_modified === null ? '-' : $this->formatDateTime($group->last_modified); ?></p>
</div>
</div>
<div class="content" data-base-target="_next">
</div>
15 changes: 15 additions & 0 deletions public/css/icinga/main-content.less
Expand Up @@ -264,6 +264,21 @@ div.content.groups {
}
}

div.controls div.group-header {
border-bottom: 2px solid @colorPetrol;

.group-name {
display: inline-block;
margin: 0 0 0.3em;
font-size: 2em;
}

.group-parent, .group-created, .group-modified {
margin: 0 0 0.2em;
font-size: 0.8em;
}
}

form.backend-selection {
float: right;

Expand Down

0 comments on commit ed166d6

Please sign in to comment.