summaryrefslogtreecommitdiffstats
path: root/modules/monitoring/application/views/scripts/list/notifications.phtml
blob: 51ef4326b21658922abcc5fec03dbb26e81e3af2 (plain)
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
<?php
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;

if (! $this->compact): ?>
<div class="controls">
    <?= $this->tabs ?>
    <?= $this->paginator ?>
    <div class="sort-controls-container">
        <?= $this->limiter ?>
        <?= $this->sortBox ?>
    </div>
    <?= $this->filterEditor ?>
</div>
<?php endif ?>
<div class="content">
<?php if (! $notifications->hasResult()): ?>
    <p><?= $this->translate('No notifications found matching the filter.') ?></p>
</div>
<?php return; endif ?>
    <table data-base-target="_next" class="table-row-selectable state-table">
    <tbody>
    <?php foreach ($notifications->peekAhead($this->compact) as $notification):
        if (isset($notification->service_description)) {
            $isService = true;
            $stateLabel = Service::getStateText($notification->notification_state, true);
            $stateName = Service::getStateText($notification->notification_state);
        } else {
            $isService = false;
            $stateLabel = Host::getStateText($notification->notification_state, true);
            $stateName = Host::getStateText($notification->notification_state);
        }
    ?>
        <tr href="<?= $this->href('monitoring/event/show', ['id' => $notification->id, 'type' => 'notify']) ?>">
            <td class="state-col state-<?= $stateName ?>">
                <div class="state-label"><?= $stateLabel ?></div>
                <div class="state-meta">
                    <?= $this->formatDateTime($notification->notification_timestamp) ?>
                </div>
            </td>
            <td>
                <div class="state-header">
                <?php if ($isService) {
                    echo '<span class="service-on">';
                    echo sprintf(
                        $this->translate('%s on %s', 'service on host'),
                        $this->qlink(
                            $notification->service_display_name,
                            'monitoring/service/show',
                            [
                                'host' => $notification->host_name,
                                'service' => $notification->service_description
                            ],
                            [
                                'title' => sprintf(
                                    $this->translate('Show detailed information for service %s on host %s'),
                                    $notification->service_display_name,
                                    $notification->host_display_name
                                )
                            ]
                        ),
                        $this->qlink(
                            $notification->host_display_name,
                            'monitoring/host/show',
                            ['host' => $notification->host_name],
                            [
                                'title' => sprintf(
                                    $this->translate('Show detailed information for host %s'),
                                    $notification->host_display_name
                                )
                            ]
                        )
                    );
                    echo '</span>';
                } else {
                    echo $this->qlink(
                        $notification->host_display_name,
                        'monitoring/host/show',
                        ['host' => $notification->host_name],
                        [
                            'title' => sprintf(
                                $this->translate('Show detailed information for host %s'),
                                $notification->host_display_name
                            )
                        ]
                    );
                } ?>
                <?php if (! $this->contact): ?>
                    <div class="notification-recipient">
                    <?php if ($notification->notification_contact_name): ?>
                        <?= sprintf(
                            $this->translate('Sent to %s'),
                            $this->qlink(
                                $notification->notification_contact_name,
                                'monitoring/show/contact',
                                array('contact_name' => $notification->notification_contact_name)
                            )
                        ) ?>
                    <?php else: ?>
                        <?= $this->translate('Not sent out to any contact') ?>
                    <?php endif ?>
                    </div>
                <?php endif ?>
                </div>
                <p class="overview-plugin-output"><?= $this->pluginOutput($this->ellipsis($notification->notification_output, 10000), true) ?></p>
            </td>
        </tr>
    <?php endforeach ?>
    </tbody>
    </table>
<?php if ($notifications->hasMore()): ?>
    <div class="action-links">
        <?= $this->qlink(
            $this->translate('Show More'),
            $this->url(isset($notificationsUrl) ? $notificationsUrl : null)->without(array('showCompact', 'limit')),
            null,
            array(
                'class'             => 'action-link',
                'data-base-target'  => '_next'
            )
        ); ?>
    </div>
<?php endif ?>
</div>