New contactgroups overview layout prototype

This commit is contained in:
Thomas Gelf 2014-02-21 10:46:57 +00:00
parent 0bc65d97cb
commit 1634fcd662
2 changed files with 50 additions and 48 deletions

View File

@ -287,19 +287,20 @@ class Monitoring_ListController extends MonitoringController
public function contactgroupsAction() public function contactgroupsAction()
{ {
$this->addTitleTab('contactgroups');
$query = ContactgroupView::fromRequest( $query = ContactgroupView::fromRequest(
$this->_request, $this->_request,
array( array(
'contactgroup_name', 'contactgroup_name',
'contactgroup_alias', 'contactgroup_alias',
'contact_name' 'contact_name',
'contact_alias',
'contact_email',
'contact_pager',
) )
)->getQuery(); )->getQuery()->order('contactgroup_alias');
$this->view->contactgroups = $query->paginate(); $this->view->contactgroups = $query->fetchAll();
$this->setupSortControl(array(
'contactgroup_name' => 'Group Name',
'contactgroup_alias' => 'Group Alias'
));
$this->handleFormatRequest($query); $this->handleFormatRequest($query);
} }

View File

@ -1,51 +1,52 @@
<?php <?php
$viewHelper = $this->getHelper('MonitoringState'); $viewHelper = $this->getHelper('MonitoringState');
$knownGroups = array() $knownGroups = array();
$contactgroups;
?> ?>
<div class="row"> <div class="controls">
<div class="pull-left"> <?= $this->tabs ?>
<h1>Contact Groups</h1>
</div>
<div class="pull-right">
<?= $this->tabs->render($this); ?>
</div>
</div> </div>
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="none"> <div class="content">
<?= $this->sortControl->render($this); ?> <div class="summary">
<?= $this->paginationControl($contactgroups, null, null, array('preserve' => $this->preserve)); ?> <?php
<table class="table table-condensed">
<thead>
<tr>
<th> Group Name </th>
<th> Description </th>
<th> Member Name </th>
</tr>
</thead>
<tbody>
foreach($contactgroups as $c):
<?php foreach($contactgroups as $contact): ?> $group = $c->contactgroup_name;
<?php $periodLink = $this->href('monitoring/show/contacts', array('contact' => $contact->contact_name)); ?> $periodLink = $this->href('monitoring/show/contacts', array('contact' => $c->contact_name));
<tr> if (! array_key_exists($group, $knownGroups)) {
<?php $knownGroups[$group] = true;
$groupName = $contact->contactgroup_name; $newRow = true;
if (!array_key_exists($groupName, $knownGroups)) { if (! empty($knownGroups)) {
echo '<td>' . $groupName . '</td><td>' . $contact->contactgroup_alias . '</td>'; echo '</span>';
$knownGroups[$groupName] = True;
} else {
echo '<td></td><td></td>';
} }
?> echo '<span class="state" style="background: #555; color: white">' . $this->escape($c->contactgroup_alias) . '<br />';
<td> if ($c->contactgroup_alias !== $group) {
<a href="<?= $periodLink ?>"> echo '(' . $this->escape($group) . ')';
<?= $contact->contact_name ?> } else {
</a> echo '&nbsp;';
</td> }
</tr> }
$methods = array();
foreach (array('email', 'pager') as $method) {
$prop = 'contact_' . $method;
if (isset($c->$prop) && ! empty($c->$prop)) {
$methods[] = $c->$prop;
}
}
?>
<span class="state" style="display:block; width: 90%; height: 80px; text-align: left; background: #eee; color: black; margin: 1em;">
<img style="border: 3px solid white; margin: 0.5em;" src="<?= $this->href('/static/gravatar', array('email' => $c->contact_email )) ?>" width="60" height="60" align="left" />
<a style="color: black; font-size: 1.1em; font-weight: bold;" href="<?= $periodLink ?>"><?= $this->escape($c->contact_alias) ?></a>
<p class="pluginoutput"><?= implode('<br />', $methods) ?></p>
</span>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> <?php if (! empty($knownGroups)): ?>
</table> </span>
<?= $this->paginationControl($contactgroups, null, null, array('preserve' => $this->preserve)); ?> <? endif ?>
</div>
</div> </div>