-
Notifications
You must be signed in to change notification settings - Fork 275
/
eventhistory.phtml
129 lines (126 loc) · 4.6 KB
/
eventhistory.phtml
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
<?php
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;
$url = $this->url();
$limit = (int) $url->getParam('limit', 25);
if (! $url->hasParam('page') || ($page = (int) $url->getParam('page')) < 1) {
$page = 1;
}
$history->limit($limit * $page);
if (! $this->compact): ?>
<div class="controls dont-print separated">
<?= $this->tabs ?>
<div class="grid">
<?= $this->limiter ?>
<?= $this->sortBox ?>
</div>
<?= $this->filterEditor ?>
</div>
<?php endif ?>
<div class="content">
<table data-base-target="_next" class="action action-table">
<tbody>
<?php foreach ($history->peekAhead() as $event):
$icon = 'help';
$msg = $event->output;
$title = $event->type;
$stateName = 'invalid';
$isService = isset($event->service_description);
switch ($event->type) {
case 'notify':
$icon = 'bell';
$title = $this->translate('Notification');
$msg = $msg ?: $this->translate('This notification was not sent out to any contact.');
break;
case 'comment':
$icon = 'comment';
$title = $this->translate('Comment');
break;
case 'ack':
$icon = 'ok';
$title = $this->translate('Acknowledgement');
break;
case 'dt_comment':
$icon = 'plug';
$title = $this->translate('In Downtime');
break;
case 'flapping':
$icon = 'flapping';
$title = $this->translate('Flapping');
break;
case 'flapping_deleted':
$icon = 'ok';
$title = $this->translate('Flapping Stopped');
break;
case 'hard_state':
$icon = $isService ? 'service' : 'host';
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
$title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
break;
case 'soft_state':
$icon = 'lightbulb';
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
$title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
break;
case 'dt_start':
$icon = 'starttime';
$title = $this->translate('Downtime Start');
break;
case 'dt_end':
$icon = 'endtime';
$title = $this->translate('Downtime End');
break;
} ?>
<tr>
<td class="state-col state-<?= $stateName ?>">
<?php if ($history->getIteratorPosition() % $limit === 0): ?>
<a id="page-<?= $history->getIteratorPosition() / $limit + 1 ?>"></a>
<?php endif ?>
<strong><?= $this->escape($title) ?></strong>
<p><?= $this->timeAgo($event->timestamp, $this->compact) ?></p>
</td>
<td>
<?= $this->icon($icon, $title) ?>
<?php if ($isService): ?>
<?= $this->link()->service(
$event->service_description, $event->service_display_name, $event->host_name, $event->host_display_name, 'rowaction'
) ?>
<?php else: ?>
<?= $this->link()->host($event->host_name, $event->host_display_name) ?>
<?php endif ?>
<p class="plugin-output">
<?= empty($msg) ? '' : $this->escape($msg) ?>
</p>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php if (! $history->hasResult()): ?>
<?= $this->translate('No history events found matching the filter') ?>
<?php elseif ($history->hasMore()): ?>
<?php if ($this->compact): ?>
<?= $this->qlink(
$this->translate('Show More'),
$url->without(array('view', 'limit')),
null,
array(
'data-base-target' => '_next',
'class' => 'pull-right action-link'
)
) ?>
<?php else: ?>
<?= $this->qlink(
$this->translate('Load More'),
$url->setAnchor('page-' . ($page + 1)),
array(
'page' => $page + 1,
),
array(
'id' => 'load-more',
'class' => 'pull-right action-link'
)
) ?>
<?php endif ?>
<?php endif ?>
</div>