Apply style to detail

refs #4869
This commit is contained in:
Marius Hein 2013-10-15 12:48:33 +02:00
parent a69c7498ec
commit d6fd3350e0
12 changed files with 426 additions and 166 deletions

View File

@ -1,8 +1,11 @@
<div class="panel panel-default"> <div>
<div class="panel-heading"> <div class="panel-heading">
{{CHECK_COMMAND_ICON}} <div class="panel-hostname">
<span>Check Command</span> Check Command
</div> </div>
</div>
<hr class="separator" />
<div class="panel-body"> <div class="panel-body">
<table> <table>

View File

@ -1,4 +1,3 @@
<?php if (!empty($object->contacts)): ?>
<?php <?php
$contacts = array(); $contacts = array();
foreach ($object->contacts as $contact) { foreach ($object->contacts as $contact) {
@ -14,17 +13,24 @@ foreach ($object->contacts as $contact) {
. '</a>'; . '</a>';
} }
?> ?>
<div class="panel panel-default"> <div>
<div class="panel-heading"> <div class="panel-heading">
{{CONTACT_ICON}} <span>Contacts</span> <div class="panel-hostname">
Contacts
</div> </div>
</div>
<hr class="separator" />
<div class="panel-body"> <div class="panel-body">
<?php if (!count($contacts)): ?>
No Contacts
<?php else: ?>
<?= implode(', ', $contacts); ?> <?= implode(', ', $contacts); ?>
<?php endif; ?>
</div> </div>
</div> </div>
<?php endif; ?>
<?php if (!empty($object->contactgroups)): ?>
<?php <?php
$contactgroups = array(); $contactgroups = array();
foreach ($object->contactgroups as $contactgroup) { foreach ($object->contactgroups as $contactgroup) {
@ -40,12 +46,20 @@ foreach ($object->contactgroups as $contactgroup) {
. '</a>'; . '</a>';
} }
?> ?>
<div class="panel panel-default"> <div>
<div class="panel-heading"> <div class="panel-heading">
{{CONTACTGROUP_ICON}} <span>Contactgroups</span> <div class="panel-hostname">
Contactgroups
</div> </div>
</div>
<hr class="separator" />
<div class="panel-body"> <div class="panel-body">
<?php if (!count($contactgroups)): ?>
No Contactgroups
<?php else: ?>
<?= implode(', ', $contactgroups); ?> <?= implode(', ', $contactgroups); ?>
<?php endif; ?>
</div> </div>
</div> </div>
<?php endif; ?>

View File

@ -8,6 +8,15 @@
<hr class="separator" /> <hr class="separator" />
<div class="panel-body"> <div class="panel-body">
<?php var_dump($this->object); ?> <?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>
</div> </div>

View File

@ -56,7 +56,7 @@
<tr> <tr>
<td>No Downtimes</td> <td>No Downtimes</td>
</tr> </tr>
<?php endif; ?> <?php else: ?>
<?php foreach ($this->object->downtimes as $downtime): ?> <?php foreach ($this->object->downtimes as $downtime): ?>
<tr> <tr>
<td> <td>
@ -89,6 +89,7 @@
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -1,4 +1,3 @@
<?php if (!empty($object->hostgroups)): ?>
<?php <?php
$hostgroups = array(); $hostgroups = array();
foreach ($object->hostgroups as $name => $alias) { foreach ($object->hostgroups as $name => $alias) {
@ -7,12 +6,20 @@ foreach ($object->hostgroups as $name => $alias) {
. '</a>'; . '</a>';
} }
?> ?>
<div class="panel panel-default"> <div>
<div class="panel-heading"> <div class="panel-heading">
{{HOSTGROUP_ICON}} <span>Hostgroups</span> <div class="panel-hostname">
Hostgroups
</div> </div>
</div>
<hr class="separator" />
<div class="panel-body"> <div class="panel-body">
<?php if (!count($hostgroups)): ?>
No Hostgroups
<?php else: ?>
<?= implode(', ', $hostgroups); ?> <?= implode(', ', $hostgroups); ?>
<?php endif; ?>
</div> </div>
</div> </div>
<?php endif; ?>

View File

@ -10,12 +10,8 @@
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Latency</dt> <dt>Latency</dt>
<dd><?= sprintf('%.2f', $this->object->check_execution_time); ?>s</dd> <dd><?= sprintf('%.2f', $this->object->check_execution_time); ?>s</dd>
</dl>
<dl class="dl-horizontal">
<dt>Duration</dt> <dt>Duration</dt>
<dd><?= sprintf('%.2f', $this->object->check_latency); ?>s</dd> <dd><?= sprintf('%.2f', $this->object->check_latency); ?>s</dd>
</dl>
<dl class="dl-horizontal">
<dt>Attempt</dt> <dt>Attempt</dt>
<dd> <dd>
<?= $this->object->current_check_attempt; ?>/<?= $this->object->max_check_attempts; ?> <?= $this->object->current_check_attempt; ?>/<?= $this->object->max_check_attempts; ?>

View File

@ -1,4 +1,3 @@
<?php if (!empty($object->servicegroups)): ?>
<?php <?php
$servicegroups = array(); $servicegroups = array();
foreach ($object->servicegroups as $name => $alias) { foreach ($object->servicegroups as $name => $alias) {
@ -7,12 +6,20 @@ foreach ($object->servicegroups as $name => $alias) {
. '</a>'; . '</a>';
} }
?> ?>
<div class="panel panel-default"> <div>
<div class="panel-heading"> <div class="panel-heading">
{{SERVICEGROUP_ICON}} <span>Servicegroups</span> <div class="panel-hostname">
Servicegroups
</div> </div>
</div>
<hr class="separator" />
<div class="panel-body"> <div class="panel-body">
<?php if (!count($servicegroups)): ?>
No Servicegroups
<?php else: ?>
<?= implode(', ', $servicegroups); ?> <?= implode(', ', $servicegroups); ?>
<?php endif; ?>
</div> </div>
</div> </div>
<?php endif; ?>

View File

@ -5,6 +5,6 @@
<?= $this->render('show/components/properties.phtml'); ?> <?= $this->render('show/components/properties.phtml'); ?>
<?= $this->render('show/components/flags.phtml'); ?> <?= $this->render('show/components/flags.phtml'); ?>
<?= $this->render('show/components/customvars.phtml'); ?> <?= $this->render('show/components/customvars.phtml'); ?>
<?= $this->render('show/components/servicegroups.phtml'); ?> <?= $this->render('show/components/hostgroups.phtml'); ?>
<?= $this->render('show/components/contacts.phtml'); ?> <?= $this->render('show/components/contacts.phtml'); ?>
<?= $this->render('show/components/command.phtml') ?> <?= $this->render('show/components/command.phtml') ?>

View File

@ -0,0 +1,65 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\DataView;
/**
* Represent customvar view
*/
class Customvar extends DataView
{
/**
* Retrieve columns provided by this view
*
* @return array
*/
public function getColumns()
{
return array(
'varname',
'varvalue',
'object_type'
);
}
/**
* Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort
*
* @return array
*/
public function getSortRules()
{
return array(
'varname' => array(
'varname' => self::SORT_ASC,
'varvalue' => self::SORT_ASC,
)
);
}
}

View File

@ -1,10 +1,40 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Object; namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\AbstractQuery as Query; use Icinga\Data\AbstractQuery as Query;
use \Icinga\Module\Monitoring\Backend; use \Icinga\Module\Monitoring\Backend;
/**
* Generic icinga object with belongings
*/
abstract class AbstractObject abstract class AbstractObject
{ {
protected $backend; protected $backend;
@ -17,14 +47,7 @@ abstract class AbstractObject
protected $properties; protected $properties;
protected $foreign = array( protected $foreign = array();
// 'hostgroups' => null,
// 'contacts' => null,
// 'contactgroups' => null,
// 'servicegroups' => null,
// 'customvars' => null,
// 'comments' => null,
);
public function __construct(Backend $backend, $name1, $name2 = null) public function __construct(Backend $backend, $name1, $name2 = null)
{ {
@ -81,10 +104,13 @@ abstract class AbstractObject
protected function fetchHostgroups() protected function fetchHostgroups()
{ {
$this->foreign['hostgroups'] = $this->applyObjectFilter( $this->foreign['hostgroups'] = $this->applyObjectFilter(
$this->backend->select()->from('hostgroup', array( $this->backend->select()->from(
'hostgroup',
array(
'hostgroup_name', 'hostgroup_name',
'hostgroup_alias' 'hostgroup_alias'
)) )
)
)->fetchPairs(); )->fetchPairs();
return $this; return $this;
} }
@ -92,10 +118,13 @@ abstract class AbstractObject
protected function fetchServicegroups() protected function fetchServicegroups()
{ {
$this->foreign['servicegroups'] = $this->applyObjectFilter( $this->foreign['servicegroups'] = $this->applyObjectFilter(
$this->backend->select()->from('servicegroup', array( $this->backend->select()->from(
'servicegroup',
array(
'servicegroup_name', 'servicegroup_name',
'servicegroup_alias' 'servicegroup_alias'
)) )
)
)->fetchPairs(); )->fetchPairs();
return $this; return $this;
} }
@ -103,12 +132,15 @@ abstract class AbstractObject
protected function fetchContacts() protected function fetchContacts()
{ {
$this->foreign['contacts'] = $this->applyObjectFilter( $this->foreign['contacts'] = $this->applyObjectFilter(
$this->backend->select()->from('contact', array( $this->backend->select()->from(
'contact',
array(
'contact_name', 'contact_name',
'contact_alias', 'contact_alias',
'contact_email', 'contact_email',
'contact_pager', 'contact_pager',
)) )
)
)->fetchAll(); )->fetchAll();
return $this; return $this;
} }
@ -116,10 +148,13 @@ abstract class AbstractObject
protected function fetchContactgroups() protected function fetchContactgroups()
{ {
$this->foreign['contactgroups'] = $this->applyObjectFilter( $this->foreign['contactgroups'] = $this->applyObjectFilter(
$this->backend->select()->from('contactgroup', array( $this->backend->select()->from(
'contactgroup',
array(
'contactgroup_name', 'contactgroup_name',
'contactgroup_alias', 'contactgroup_alias',
)) )
)
)->fetchAll(); )->fetchAll();
return $this; return $this;
} }
@ -127,12 +162,15 @@ abstract class AbstractObject
protected function fetchComments() protected function fetchComments()
{ {
$this->foreign['comments'] = $this->applyObjectFilter( $this->foreign['comments'] = $this->applyObjectFilter(
$this->backend->select()->from('comment', array( $this->backend->select()->from(
'comment',
array(
'comment_timestamp', 'comment_timestamp',
'comment_author', 'comment_author',
'comment_data', 'comment_data',
'comment_type', 'comment_type',
))->where('comment_objecttype_id', $this->type) )
)->where('comment_objecttype_id', $this->type)
)->fetchAll(); )->fetchAll();
return $this; return $this;
} }
@ -140,12 +178,13 @@ abstract class AbstractObject
protected function fetchCustomvars() protected function fetchCustomvars()
{ {
$this->foreign['customvars'] = $this->applyObjectFilter( $this->foreign['customvars'] = $this->applyObjectFilter(
$this->backend->select()->from('customvar', array( $this->backend->select()->from(
'customvar',
array(
'varname', 'varname',
'varvalue' 'varvalue'
)) )
->where('varname', '-*PW*,-*PASS*,-*COMMUNITY*') )->where('varname', '-*PW*,-*PASS*,-*COMMUNITY*')
->where('object_type', 'host')
)->fetchPairs(); )->fetchPairs();
return $this; return $this;
} }
@ -153,7 +192,9 @@ abstract class AbstractObject
public function fetchEventHistory() public function fetchEventHistory()
{ {
$this->foreign['eventHistory'] = $this->applyObjectFilter( $this->foreign['eventHistory'] = $this->applyObjectFilter(
$this->backend->select()->from('eventHistory', array( $this->backend->select()->from(
'eventHistory',
array(
'object_type', 'object_type',
'host_name', 'host_name',
'service_description', 'service_description',
@ -163,7 +204,8 @@ abstract class AbstractObject
'max_attempts', 'max_attempts',
'output', 'output',
'type' 'type'
)) )
)
); );
return $this; return $this;
} }
@ -171,7 +213,9 @@ abstract class AbstractObject
public function fetchDowtimes() public function fetchDowtimes()
{ {
$this->foreign['downtimes'] = $this->applyObjectFilter( $this->foreign['downtimes'] = $this->applyObjectFilter(
$this->backend->select()->from('downtime', array( $this->backend->select()->from(
'downtime',
array(
'host_name', 'host_name',
'object_type', 'object_type',
'service_host_name', 'service_host_name',

View File

@ -1,9 +1,39 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Object; namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\AbstractQuery as Query; use Icinga\Data\AbstractQuery as Query;
/**
* Represent a host object
*/
class Host extends AbstractObject class Host extends AbstractObject
{ {
protected $foreign = array( protected $foreign = array(
@ -12,19 +42,35 @@ class Host extends AbstractObject
'contactgroups' => null, 'contactgroups' => null,
'customvars' => null, 'customvars' => null,
'comments' => null, 'comments' => null,
'downtimes' => null 'downtimes' => null,
'customvars' => null
); );
/**
* Statename
*/
public function stateName() public function stateName()
{ {
// TODO // TODO
} }
/**
* Filter object belongings
*
* @param Query $query
*
* @return Query
*/
protected function applyObjectFilter(Query $query) protected function applyObjectFilter(Query $query)
{ {
return $query->where('host_name', $this->name1); return $query->where('host_name', $this->name1);
} }
/**
* Load foreign object data
*
* @return self
*/
public function prefetch() public function prefetch()
{ {
return $this->fetchHostgroups() return $this->fetchHostgroups()
@ -32,12 +78,19 @@ class Host extends AbstractObject
->fetchContactgroups() ->fetchContactgroups()
->fetchCustomvars() ->fetchCustomvars()
->fetchComments() ->fetchComments()
->fetchDowtimes(); ->fetchDowtimes()
->fetchCustomvars();
} }
/**
* Load object data
* @return object
*/
protected function fetchObject() protected function fetchObject()
{ {
return $this->backend->select()->from('status', array( return $this->backend->select()->from(
'status',
array(
'host_name', 'host_name',
'host_alias', 'host_alias',
'host_address', 'host_address',
@ -74,6 +127,7 @@ class Host extends AbstractObject
'action_url' => 'host_action_url', 'action_url' => 'host_action_url',
'notes_url' => 'host_notes_url', 'notes_url' => 'host_notes_url',
'percent_state_change' => 'host_percent_state_change' 'percent_state_change' => 'host_percent_state_change'
))->where('host_name', $this->name1)->fetchRow(); )
)->where('host_name', $this->name1)->fetchRow();
} }
} }

View File

@ -1,31 +1,82 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Object; namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\AbstractQuery as Query; use Icinga\Data\AbstractQuery as Query;
/**
* Represent a single service
*/
class Service extends AbstractObject class Service extends AbstractObject
{ {
/**
* Foreign references to objects
*
* @var array
*/
protected $foreign = array( protected $foreign = array(
'servicegroups' => null, 'servicegroups' => null,
'contacts' => null, 'contacts' => null,
'contactgroups' => null, 'contactgroups' => null,
'customvars' => null, 'customvars' => null,
'comments' => null, 'comments' => null,
'downtimes' => null 'downtimes' => null,
'customvars' => null
); );
/**
* Statename
*/
public function stateName() public function stateName()
{ {
// TODO // TODO
} }
/**
* Filter foreign object belongings
*
* @param Query $query
*
* @return Query
*/
protected function applyObjectFilter(Query $query) protected function applyObjectFilter(Query $query)
{ {
return $query->where('service_host_name', $this->name1) return $query->where('service_host_name', $this->name1)
->where('service_description', $this->name2); ->where('service_description', $this->name2);
} }
/**
* Collect foreign data
*
* @return self
*/
public function prefetch() public function prefetch()
{ {
return $this->fetchServicegroups() return $this->fetchServicegroups()
@ -33,12 +84,20 @@ class Service extends AbstractObject
->fetchContactgroups() ->fetchContactgroups()
->fetchCustomvars() ->fetchCustomvars()
->fetchComments() ->fetchComments()
->fetchDowtimes(); ->fetchDowtimes()
->fetchCustomvars();
} }
/**
* Load object data
*
* @return object
*/
protected function fetchObject() protected function fetchObject()
{ {
return $this->backend->select()->from('status', array( return $this->backend->select()->from(
'status',
array(
'host_name', 'host_name',
'host_alias', 'host_alias',
'host_address', 'host_address',
@ -80,7 +139,8 @@ class Service extends AbstractObject
'last_comment' => 'service_last_comment', 'last_comment' => 'service_last_comment',
'action_url' => 'service_action_url', 'action_url' => 'service_action_url',
'notes_url' => 'service_notes_url' 'notes_url' => 'service_notes_url'
)) )
)
->where('host_name', $this->name1) ->where('host_name', $this->name1)
->where('service_description', $this->name2) ->where('service_description', $this->name2)
->fetchRow(); ->fetchRow();