1<?php
2use Icinga\Date\DateFormatter;
3use Icinga\Module\Monitoring\Object\Host;
4
5if (! $this->compact): ?>
6<div class="controls">
7    <?= $this->tabs ?>
8    <?= $this->paginator ?>
9    <div class="sort-controls-container">
10        <?= $this->limiter ?>
11        <?= $this->sortBox ?>
12    </div>
13    <?= $this->filterEditor ?>
14</div>
15<?php endif ?>
16<div class="content">
17<?php if (! $hosts->hasResult()): ?>
18    <p><?= $this->translate('No hosts found matching the filter.') ?></p>
19</div>
20<?php return; endif ?>
21    <table data-base-target="_next"
22           class="table-row-selectable state-table multiselect"
23           data-icinga-multiselect-url="<?= $this->href('monitoring/hosts/show') ?>"
24           data-icinga-multiselect-controllers="<?= $this->href("monitoring/hosts") ?>"
25           data-icinga-multiselect-data="host">
26    <tbody>
27    <?php foreach($hosts->peekAhead($this->compact) as $host):
28        $hostStateName = Host::getStateText($host->host_state);
29        $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name));
30        $hostCheckOverdue = $host->host_next_update < time();?>
31        <tr<?= $hostCheckOverdue ? ' class="state-outdated"' : '' ?>>
32            <td class="state-col state-<?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
33                <div class="state-label">
34                <?php if ($hostCheckOverdue): ?>
35                    <?= $this->icon('clock', sprintf($this->translate('Overdue %s'), DateFormatter::timeSince($host->host_next_update))) ?>
36                <?php endif ?>
37                    <?= Host::getStateText($host->host_state, true) ?>
38                </div>
39                <?php if ((int) $host->host_state !== 99): ?>
40                    <div class="state-meta">
41                        <?= $this->timeSince($host->host_last_state_change, $this->compact) ?>
42                    <?php if ((int) $host->host_state > 0 && (int) $host->host_state_type === 0): ?>
43                        <div><?= $this->translate('Soft', 'Soft state') ?> <?= $host->host_attempt ?></div>
44                    <?php endif ?>
45                    </div>
46                <?php endif ?>
47            </td>
48            <td>
49                <div class="state-header">
50                    <?= $this->iconImage()->host($host) ?>
51                    <?= $this->qlink(
52                        $host->host_display_name,
53                        $hostLink,
54                        null,
55                        array(
56                            'title' => sprintf(
57                                $this->translate('Show detailed information for host %s'),
58                                $host->host_display_name
59                            ),
60                            'class' => 'rowaction'
61                        )
62                    ) ?>
63                <?php if (isset($summary[$host->host_name])): ?>
64                    <span class="host-services-incidents"> &#40;<?= $this->qlink(
65                          sprintf(
66                              $this->translatePlural(
67                                  '%u unhandled service', '%u unhandled services', $summary[$host->host_name]
68                              ),
69                              $summary[$host->host_name]
70                          ),
71                          'monitoring/list/services',
72                          array(
73                              'host'               => $host->host_name,
74                              'service_problem'    => 1,
75                              'service_handled'    => 0
76                          ),
77                          array(
78                              'title' => sprintf(
79                                  $this->translatePlural(
80                                      'List %s unhandled service problem on host %s',
81                                      'List %s unhandled service problems on host %s',
82                                      $summary[$host->host_name]
83                                  ),
84                                  $summary[$host->host_name],
85                                  $host->host_name
86                              )
87                          )
88                    ) ?>&#41;</span>
89                <?php endif ?>
90                    <span class="state-icons"><?= $this->hostFlags($host) ?></span>
91                </div>
92                <p class="overview-plugin-output"><?= $this->pluginOutput($this->ellipsis($host->host_output, 10000), true, $host->host_check_command) ?></p>
93            </td>
94        <?php foreach($this->addColumns as $col): ?>
95            <td><?= $this->escape($host->$col) ?></td>
96        <?php endforeach ?>
97        </tr>
98    <?php endforeach ?>
99    </tbody>
100    </table>
101<?php if ($hosts->hasMore()): ?>
102    <div class="action-links">
103        <?= $this->qlink(
104            $this->translate('Show More'),
105            $this->url()->without(array('showCompact', 'limit')),
106            null,
107            array(
108                'class'             => 'action-link',
109                'data-base-target'  => '_next'
110            )
111        ) ?>
112    </div>
113<?php endif ?>
114</div>
115<?php if (! $this->compact): ?>
116<div class="monitoring-statusbar dont-print">
117    <?= $this->render('list/components/hostssummary.phtml') ?>
118    <?= $this->render('list/components/selectioninfo.phtml') ?>
119</div>
120<?php endif ?>
121