Skip to content

Commit

Permalink
Classes: rename listing-table to common-table
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Gelf committed Nov 4, 2015
1 parent 0b46f93 commit 0c72b69
Show file tree
Hide file tree
Showing 19 changed files with 415 additions and 18 deletions.
2 changes: 1 addition & 1 deletion application/views/scripts/about/index.phtml
Expand Up @@ -101,7 +101,7 @@
) ?>
</div>
<h2><?= $this->translate('Loaded modules') ?></h2>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Name') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/config/modules.phtml
Expand Up @@ -8,7 +8,7 @@
</div>
<?php endif ?>
<div class="content">
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Module') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/config/resource.phtml
Expand Up @@ -13,7 +13,7 @@
'title' => $this->translate('Create a new resource')
)
) ?>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Resource') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/form/reorder-authbackend.phtml
@@ -1,5 +1,5 @@
<form id="<?= $form->getId() ?>" name="<?= $form->getName() ?>" enctype="<?= $form->getEncType() ?>" method="<?= $form->getMethod() ?>" action="<?= $form->getAction() ?>">
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<th><?= $this->translate('Backend') ?></th>
<th></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/group/list.phtml
Expand Up @@ -49,7 +49,7 @@ $firstRow = true;
foreach ($groups as $group): ?>
<?php if ($firstRow): ?>
<?php $firstRow = false; ?>
<table data-base-target="_next" class="action-table listing-table">
<table data-base-target="_next" class="action-table common-table">
<thead>
<tr>
<th class="group-name"><?= $this->translate('Group'); ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/group/show.phtml
Expand Up @@ -70,7 +70,7 @@ $firstRow = true;
foreach ($members as $member): ?>
<?php if ($firstRow): ?>
<?php $firstRow = false; ?>
<table data-base-target="_next" class="action-table listing-table">
<table data-base-target="_next" class="action-table common-table">
<thead>
<tr>
<th class="member-name"><?= $this->translate('Username'); ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/navigation/index.phtml
Expand Up @@ -23,7 +23,7 @@
<p><?= $this->translate('You did not create any navigation item yet.') ?></p>
</div>
<?php return; endif ?>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Navigation') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/navigation/shared.phtml
Expand Up @@ -14,7 +14,7 @@ if (! $this->compact): ?>
<?php if (count($items) === 0): ?>
<p><?= $this->translate('There are currently no navigation items being shared'); ?></p>
<?php else: ?>
<table class="action-table listing-table">
<table class="action-table common-table">
<thead>
<th><?= $this->translate('Shared Navigation'); ?></th>
<th style="width: 10em"><?= $this->translate('Type'); ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/role/list.phtml
Expand Up @@ -16,7 +16,7 @@
<?php /** @var \Icinga\Application\Config $roles */ if ($roles->isEmpty()): ?>
<p><?= $this->translate('No roles found.') ?></p>
<?php return; endif ?>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Name') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/user/list.phtml
Expand Up @@ -43,7 +43,7 @@ $reducible = $this->hasPermission('config/authentication/users/remove') && $back
)
) ?>
<?php endif ?>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Username') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/user/show.phtml
Expand Up @@ -71,7 +71,7 @@ $firstRow = true;
foreach ($memberships as $membership): ?>
<?php if ($firstRow): ?>
<?php $firstRow = false; ?>
<table data-base-target="_next" class="action-table listing-table">
<table data-base-target="_next" class="action-table common-table">
<thead>
<tr>
<th class="membership-group"><?= $this->translate('Group'); ?></th>
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/usergroupbackend/list.phtml
Expand Up @@ -14,7 +14,7 @@
)
) ?>
<?php if (! count($backendNames)) { return; } ?>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Backend') ?></th>
Expand Down
Expand Up @@ -15,7 +15,7 @@
'title' => $this->translate('Create a new monitoring backend')
)
) ?>
<table class="action-table listing-table">
<table class="action-table common-table">
<thead>
<tr>
<th><?= $this->translate('Monitoring Backend') ?></th>
Expand Down Expand Up @@ -70,7 +70,7 @@
'title' => $this->translate('Create a new command transport')
)
) ?>
<table class="action-table listing-table">
<table class="action-table common-table">
<thead>
<tr>
<th><?= $this->translate('Transport') ?></th>
Expand Down
Expand Up @@ -18,7 +18,7 @@ if (count($groupData) === 0) {
return;
}
?>
<table class="action action-table listing-table" data-base-target="_next">
<table class="action action-table common-table" data-base-target="_next">
<thead>
<tr>
<th></th>
Expand Down
Expand Up @@ -11,7 +11,7 @@
<?php endif ?>
<div class="content">
<?php if ($contacts->hasResult()): ?>
<table class="action action-table listing-table" data-base-target="_next">
<table class="action action-table common-table" data-base-target="_next">
<thead>
<tr>
<th><?= $this->translate('Name') ?></th>
Expand Down
Expand Up @@ -18,7 +18,7 @@ if (! $this->compact): ?>
<p><?= $this->translate('No host groups found matching the filter.') ?></p>
</div>
<?php return; endif ?>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<tr>
<th></th>
Expand Down
Expand Up @@ -16,7 +16,7 @@ if (! $this->compact): ?>
<p><?= $this->translate('No service groups found matching the filter.') ?></p>
</div>
<?php return; endif ?>
<table class="action-table listing-table" data-base-target="_next">
<table class="action-table common-table" data-base-target="_next">
<thead>
<th></th>
<th><?= $this->translate('Service Group') ?></th>
Expand Down
@@ -0,0 +1,239 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */

namespace Icinga\Module\Monitoring\Backend\Ido\Query;

use Zend_Db_Expr;

class HostobjectSubquery extends IdoQuery
{
/**
* {@inheritdoc}
*/
protected $allowCustomVars = true;

/**
* {@inheritdoc}
*/
protected $columnMap = array(
'hostgroups' => array(
'hostgroup' => 'hgo.name1',
),
'hosts' => array(
'host' => 'ho.name1',
),
'servicegroups' => array(
'servicegroup' => 'sgo.name1',
),
'services' => array(
'service' => 'so.name2',
)
);

/**
* Create a sub query to join comments into status query
*
* @param int $entryType
* @param string $alias
*
* @return Zend_Db_Expr
*/
protected function createLastCommentSubQuery($entryType, $alias)
{
$sql = <<<SQL
SELECT
c.object_id,
'[' || c.author_name || '] ' || c.comment_data AS $alias
FROM
icinga_comments c
INNER JOIN
(
SELECT
MAX(comment_id) AS comment_id,
object_id
FROM
icinga_comments
WHERE
entry_type = $entryType
GROUP BY object_id
) ec ON ec.comment_id = c.comment_id
SQL;
return new Zend_Db_Expr('(' . $sql . ')');
}

/**
* {@inheritdoc}
*/
protected function joinBaseTables()
{
$this->select->from(
array('h' => $this->prefix . 'hosts'),
array()
)->join(
array('ho' => $this->prefix . 'objects'),
'ho.object_id = h.host_object_id AND ho.is_active = 1 AND ho.objecttype_id = 1',
array()
);
$this->joinedVirtualTables['hosts'] = true;
}

/**
* Join host groups
*/
protected function joinHostgroups()
{
$this->select->joinLeft(
array('hgm' => $this->prefix . 'hostgroup_members'),
'hgm.host_object_id = ho.object_id',
array()
)->joinLeft(
array('hg' => $this->prefix . 'hostgroups'),
'hg.hostgroup_id = hgm.hostgroup_id',
array()
)->joinLeft(
array('hgo' => $this->prefix . 'objects'),
'hgo.object_id = hg.hostgroup_object_id AND hgo.is_active = 1 AND hgo.objecttype_id = 3',
array()
);
$this->group('ho.name1');
}

/**
* Join host status
*/
protected function joinHoststatus()
{
$this->select->join(
array('hs' => $this->prefix . 'hoststatus'),
'hs.host_object_id = ho.object_id',
array()
);
}

/**
* Join last host acknowledgement comment
*/
protected function joinLasthostackcomment()
{
$this->select->joinLeft(
array('hlac' => $this->createLastCommentSubQuery(4, 'last_ack_data')),
'hlac.object_id = ho.object_id',
array()
);
}

/**
* Join last host comment
*/
protected function joinLasthostcomment()
{
$this->select->joinLeft(
array('hlc' => $this->createLastCommentSubQuery(1, 'last_comment_data')),
'hlc.object_id = ho.object_id',
array()
);
}

/**
* Join last host downtime comment
*/
protected function joinLasthostdowntimeComment()
{
$this->select->joinLeft(
array('hldc' => $this->createLastCommentSubQuery(2, 'last_downtime_data')),
'hldc.object_id = ho.object_id',
array()
);
}

/**
* Join last host flapping comment
*/
protected function joinLasthostflappingcomment()
{
$this->select->joinLeft(
array('hlfc' => $this->createLastCommentSubQuery(3, 'last_flapping_data')),
'hlfc.object_id = ho.object_id',
array()
);
}

/**
* Join service groups
*/
protected function joinServicegroups()
{
$this->requireVirtualTable('services');
$this->select->joinLeft(
array('sgm' => $this->prefix . 'servicegroup_members'),
'sgm.service_object_id = s.service_object_id',
array()
)->joinLeft(
array('sg' => $this->prefix . 'servicegroups'),
'sgm.servicegroup_id = sg.' . $this->servicegroup_id,
array()
)->joinLeft(
array('sgo' => $this->prefix . 'objects'),
'sgo.object_id = sg.servicegroup_object_id AND sgo.is_active = 1 AND sgo.objecttype_id = 4',
array()
);
$this->group('ho.name1');
}

/**
* Join services
*/
protected function joinServices()
{
$this->requireVirtualTable('hosts');
$this->select->joinLeft(
array('s' => $this->prefix . 'services'),
's.host_object_id = h.host_object_id',
array()
)->joinLeft(
array('so' => $this->prefix . 'objects'),
'so.object_id = s.service_object_id AND so.is_active = 1 AND so.objecttype_id = 2',
array()
);
$this->group('ho.name1');
}

/**
* Join service problem summary
*/
protected function joinServiceproblemsummary()
{
$select = <<<'SQL'
SELECT
SUM(
CASE WHEN(ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0
THEN 0
ELSE 1
END
) AS unhandled_services_count,
SUM(
CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0) ) > 0
THEN 1
ELSE 0
END
) AS handled_services_count,
s.host_object_id
FROM
icinga_servicestatus ss
JOIN icinga_objects o ON o.object_id = ss.service_object_id
JOIN icinga_services s ON s.service_object_id = o.object_id
JOIN icinga_hoststatus hs ON hs.host_object_id = s.host_object_id
WHERE
o.is_active = 1
AND o.objecttype_id = 2
AND ss.current_state > 0
GROUP BY
s.host_object_id
SQL;
$this->select->joinLeft(
array('sps' => new Zend_Db_Expr('(' . $select . ')')),
'sps.host_object_id = ho.object_id',
array()
);
}
}

0 comments on commit 0c72b69

Please sign in to comment.