1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
<?php
use Icinga\Data\Filter\Filter;
use Icinga\Module\Icingadb\Common\ServiceStates;
use Icinga\Web\Url;
if (! $this->compact): ?>
<?= $this->controls ?>
<?php endif ?>
<div class="content" data-base-target="_next" id="<?= $this->protectId('content') ?>">
<?php if (empty($pivotData)): ?>
<div class="item-list">
<div class="empty-state"><?= $this->translate('No services found matching the filter.') ?></div>
</div>
</div>
<?php return; endif;
$serviceFilter = Filter::matchAny();
foreach ($pivotData as $serviceDescription => $_) {
$serviceFilter->orFilter(Filter::where('service.name', $serviceDescription));
}
?>
<table class="service-grid-table">
<thead>
<tr>
<th><?= $this->partial(
'joystickPagination-icingadb.phtml',
'default',
array(
'flippable' => true,
'baseUrl' => $baseUrl,
'xAxisPaginator' => $horizontalPaginator,
'yAxisPaginator' => $verticalPaginator
)
) ?></th>
<?php foreach ($pivotHeader['cols'] as $hostName => $hostAlias): ?>
<th class="rotate-45"><div><span><?= $this->qlink(
$this->ellipsis($hostAlias, 24),
Url::fromPath('icingadb/services')->addFilter(
Filter::matchAll($serviceFilter, Filter::where('host.name', $hostName))
),
null,
array('title' => sprintf($this->translate('List all reported services on host %s'), $hostAlias)),
false
) ?></span></div></th>
<?php endforeach ?>
</tr>
</thead>
<tbody>
<?php $i = 0 ?>
<?php foreach ($pivotHeader['rows'] as $serviceDescription => $serviceDisplayName): ?>
<tr>
<th><?php
$hostFilter = Filter::matchAny();
foreach ($pivotData[$serviceDescription] as $hostName => $_) {
$hostFilter->orFilter(Filter::where('host.name', $hostName));
}
echo $this->qlink(
$serviceDisplayName,
Url::fromPath('icingadb/services')->addFilter(
Filter::matchAll($hostFilter, Filter::where('service.name', $serviceDescription))
),
null,
array('title' => sprintf(
$this->translate('List all services with the name "%s" on all reported hosts'),
$serviceDisplayName
))
);
?></th>
<?php foreach (array_keys($pivotHeader['cols']) as $hostName): ?>
<td><?php
$service = $pivotData[$serviceDescription][$hostName];
if ($service === null): ?>
<span aria-hidden="true">·</span>
<?php continue; endif ?>
<?php $ariaDescribedById = $this->protectId($service->host_name . '_' . $service->name . '_desc') ?>
<span class="sr-only" id="<?= $ariaDescribedById ?>">
<?= $this->escape($service->state->output) ?>
</span>
<?= $this->qlink(
'',
'icingadb/services',
array(
'host.name' => $hostName,
'name' => $serviceDescription
),
array(
'aria-describedby' => $ariaDescribedById,
'aria-label' => sprintf(
$this->translate('Show detailed information for service %s on host %s'),
$service->display_name,
$service->host_display_name
),
'class' => 'service-grid-link state-' . $service->state->getStateText() . ($service->state->is_handled ? ' handled' : ''),
'title' => $service->state->output
)
) ?>
</td>
<?php endforeach ?>
<?php
$horizontalItemsPerPage = $this->horizontalPaginator->getLimit();
$horizontalTotalPages = ceil($this->horizontalPaginator->count() / $horizontalItemsPerPage);
$verticalItemsPerPage = $this->verticalPaginator->getLimit();
$verticalTotalPages = ceil($this->verticalPaginator->count() / $verticalItemsPerPage);
if (! $this->compact && $horizontalTotalPages > 1): ?>
<td>
<?php $expandLink = $this->qlink(
$this->translate('Load more'),
$baseUrl,
array(
'limit' => ($horizontalItemsPerPage + 20)
. ','
. $verticalItemsPerPage
),
array(
'class' => 'action-link',
'data-base-target' => '_self'
)
) ?>
<?= ++$i === (int) ceil(count($pivotHeader['rows']) / 2) ? $expandLink : '' ?>
</td>
<?php endif ?>
</tr>
<?php endforeach ?>
<?php if (! $this->compact && $verticalTotalPages > 1): ?>
<tr>
<td colspan="<?= count($pivotHeader['cols']) + 1?>" class="service-grid-table-more">
<?php echo $this->qlink(
$this->translate('Load more'),
$baseUrl,
array(
'limit' => $horizontalItemsPerPage
. ','
. ($verticalItemsPerPage + 20)
),
array(
'class' => 'action-link',
'data-base-target' => '_self'
)
) ?>
</td>
</tr>
<?php endif ?>
</tbody>
</table>
</div>
|