Object detail component cleanup, less HTML

This commit is contained in:
Thomas Gelf 2014-03-06 18:57:21 +00:00
parent 2dcc029e91
commit 4961bbd8d1
5 changed files with 87 additions and 148 deletions

View File

@ -1,30 +1,16 @@
<div>
<div class="panel-heading">
<div class="panel-hostname">
Check Command
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<table>
<tr>
<td>Command</td>
<td>
<?php
$explodedCommand = explode('!', $this->object->check_command, 2);
$command = array_shift($explodedCommand);
echo $command;
?>
</td>
$parts = explode('!', $object->check_command);
$command = array_shift($parts);
?><tr>
<th><?= $this->translate('Command') ?></th>
<td><?= $this->escape($command) ?>
</tr>
<tr>
<td>Arguments</td>
<td>
<?= $this->commandArguments($this->object->check_command); ?>
</td>
</tr>
</table>
</div>
</div>
<?php
$row = "<tr>\n <th>%s</th>\n <td>%s</td>\n</tr>\n";
for ($i = 0; $i < count($parts); $i++) {
printf($row, '$ARG' . ($i + 1) . '$', $this->escape($parts[$i]));
}

View File

@ -1,65 +1,39 @@
<?php
$contacts = array();
if (! empty($object->contacts)) {
$list = array();
foreach ($object->contacts as $contact) {
$contacts[] = '<a href="'
. $this->href(
'monitoring/show/contact',
array(
$list[] = $this->qlink($contact->contact_alias, 'monitoring/show/contact', array(
'contact_name' => $contact->contact_name
)
)
. '">'
. $contact->contact_alias
. '</a>';
));
}
?>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Contacts
</div>
</div>
<hr class="separator" />
printf(
"<tr><th>%s</th><td>%s %s</td></tr>\n",
$this->translate('Contacts'),
$this->img('img/icons/user_petrol.png'),
implode(', ', $list)
);
<div class="panel-body">
<?php if (!count($contacts)): ?>
No Contacts
<?php else: ?>
<?= implode(', ', $contacts); ?>
<?php endif; ?>
</div>
</div>
}
<?php
$contactgroups = array();
if (! empty($object->contactgroups)) {
$list = array();
foreach ($object->contactgroups as $contactgroup) {
$contactgroups[] = '<a href="'
. $this->href(
$list[] = $this->qlink(
$contactgroup->contactgroup_alias,
'monitoring/show/contactgroup',
array(
'contactgroup_name' => $contactgroup->contactgroup_name
)
)
. '">'
. $contactgroup->contactgroup_alias
. '</a>';
array('contactgroup_name' => $contactgroup->contactgroup_name)
);
}
?>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Contactgroups
</div>
</div>
<hr class="separator" />
printf(
"<tr><th>%s</th><td>%s %s</td></tr>\n",
$this->translate('Contactgroups'),
$this->img('img/icons/user_petrol.png'),
implode(', ', $list)
);
}
<div class="panel-body">
<?php if (!count($contactgroups)): ?>
No Contactgroups
<?php else: ?>
<?= implode(', ', $contactgroups); ?>
<?php endif; ?>
</div>
</div>

View File

@ -1,22 +1,16 @@
<div>
<div class="panel-heading">
<div class="panel-hostname">
Custom Variables
</div>
</div>
<?php
<hr class="separator" />
if (! $object->customvars) { return; }
foreach ($object->customvars as $name => $value) {
$name = ucwords(str_replace('_', ' ', strtolower($name)));
if (preg_match('~(?:pw|pass|community)~', strtolower($name))) {
$value = '***';
}
printf(
"<tr><th>%s</th><td>%s</td></tr>\n",
$this->escape($name),
$this->escape($value)
);
}
<div class="panel-body">
<?php if (empty($this->object->customvars)): ?>
No customvars
<?php else: ?>
<dl class="dl-horizontal">
<?php foreach ($this->object->customvars as $varname => $varvalue): ?>
<dt><?= $varname; ?></dt>
<dd><?= $varvalue; ?></dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
</div>
</div>

View File

@ -1,25 +1,17 @@
<?php
$hostgroups = array();
if (empty($object->hostgroups)) return;
$list = array();
foreach ($object->hostgroups as $name => $alias) {
$hostgroups[] = '<a href="' . $this->href('monitoring/list/hosts', array('hostgroup' => $name)) . '">'
. $alias
. '</a>';
$list[] = $this->qlink($alias, 'monitoring/list/services', array(
'hostgroup' => $name
));
}
?>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Hostgroups
</div>
</div>
printf(
"<tr><th>%s</th><td>%s %s</td></tr>\n",
$this->translate('Hostgroups'),
$this->img('img/icons/hostgroup_petrol.png'),
implode(', ', $list)
);
<hr class="separator" />
<div class="panel-body">
<?php if (!count($hostgroups)): ?>
No Hostgroups
<?php else: ?>
<?= implode(', ', $hostgroups); ?>
<?php endif; ?>
</div>
</div>

View File

@ -1,25 +1,18 @@
<?php
$servicegroups = array();
if (empty($object->servicegroups)) return;
$list = array();
foreach ($object->servicegroups as $name => $alias) {
$servicegroups[] = '<a href="' . $this->href('monitoring/list/services', array('servicegroup' => $name)) . '">'
. $alias
. '</a>';
$list[] = $this->qlink($alias, 'monitoring/list/services', array(
'servicegroup' => $name
));
}
?>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Servicegroups
</div>
</div>
<hr class="separator" />
printf(
"<tr><th>%s</th><td>%s %s</td></tr>\n",
$this->translate('Servicegroups'),
$this->img('img/icons/servicegroup_petrol.png'),
implode(', ', $list)
);
<div class="panel-body">
<?php if (!count($servicegroups)): ?>
No Servicegroups
<?php else: ?>
<?= implode(', ', $servicegroups); ?>
<?php endif; ?>
</div>
</div>