Skip to content

Commit 01e9c67

Browse files
authored
Add tooltips for state pictograms (#1262)
Refs #1043 Resolves #819
2 parents 458f278 + 91d71ad commit 01e9c67

2 files changed

Lines changed: 55 additions & 17 deletions

File tree

library/Icingadb/Model/State.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,30 @@ public function getIcon(): ?Icon
151151
$icon = null;
152152
switch (true) {
153153
case $this->is_acknowledged:
154-
$icon = new Icon(Icons::IS_ACKNOWLEDGED);
154+
$icon = new Icon(Icons::IS_ACKNOWLEDGED, [
155+
'title' => sprintf('%s (%s)', strtoupper($this->getStateTextTranslated()), t('is acknowledged'))
156+
]);
155157

156158
break;
157159
case $this->in_downtime:
158-
$icon = new Icon(
159-
Icons::IN_DOWNTIME,
160-
['title' => sprintf(
160+
$icon = new Icon(Icons::IN_DOWNTIME, [
161+
'title' => sprintf(
161162
'%s (%s)',
162163
strtoupper($this->getStateTextTranslated()),
163164
$this->is_handled ? t('handled by Downtime') : t('in Downtime')
164-
)]
165-
);
165+
)
166+
]);
166167

167168
break;
168169
case $this->is_flapping:
169-
$icon = new Icon(Icons::IS_FLAPPING);
170+
$icon = new Icon(Icons::IS_FLAPPING, [
171+
'title' => sprintf('%s (%s)', strtoupper($this->getStateTextTranslated()), t('is flapping'))
172+
]);
170173

171174
break;
172175
case ! $this->is_reachable:
173176
$icon = new Icon(Icons::HOST_DOWN, [
174-
'title' => sprintf(
175-
'%s (%s)',
176-
strtoupper($this->getStateTextTranslated()),
177-
t('is unreachable')
178-
)
177+
'title' => sprintf('%s (%s)', strtoupper($this->getStateTextTranslated()), t('is unreachable'))
179178
]);
180179

181180
break;

library/Icingadb/View/BaseHostAndServiceRenderer.php

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,58 @@ public function assembleFooter($item, HtmlDocument $footer, string $layout): voi
220220
);
221221
}
222222

223+
if ($item->state->is_acknowledged) {
224+
$title = $isService
225+
? sprintf(
226+
$this->translate('Service "%s" on "%s" is acknowledged'),
227+
$item->display_name,
228+
$item->host->display_name
229+
)
230+
: sprintf($this->translate('Host "%s" is acknowledged'), $item->display_name);
231+
232+
$statusIcons->addHtml(new Icon(Icons::IS_ACKNOWLEDGED, ['title' => $title]));
233+
}
234+
235+
if ($item->state->in_downtime) {
236+
if ($isService) {
237+
$message = $item->state->is_handled
238+
? $this->translate('Service "%s" on "%s" is handled by Downtime')
239+
: $this->translate('Service "%s" on "%s" is in Downtime');
240+
241+
$title = sprintf($message, $item->display_name, $item->host->display_name);
242+
} else {
243+
$message = $item->state->is_handled
244+
? $this->translate('Host "%s" is handled by Downtime')
245+
: $this->translate('Host "%s" is in Downtime');
246+
247+
$title = sprintf($message, $item->display_name);
248+
}
249+
250+
$statusIcons->addHtml(new Icon(Icons::IN_DOWNTIME, ['title' => $title]));
251+
}
252+
223253
if ($item->state->is_flapping) {
224254
$title = $isService
225255
? sprintf(
226256
$this->translate('Service "%s" on "%s" is in flapping state'),
227257
$item->display_name,
228258
$item->host->display_name
229259
)
230-
: sprintf(
231-
$this->translate('Host "%s" is in flapping state'),
232-
$item->display_name
233-
);
260+
: sprintf($this->translate('Host "%s" is in flapping state'), $item->display_name);
261+
262+
$statusIcons->addHtml(new Icon(Icons::IS_FLAPPING, ['title' => $title]));
263+
}
264+
265+
if (! $item->state->is_reachable) {
266+
$title = $isService
267+
? sprintf(
268+
$this->translate('Service "%s" on "%s" is unreachable'),
269+
$item->display_name,
270+
$item->host->display_name
271+
)
272+
: sprintf($this->translate('Host "%s" is unreachable'), $item->display_name);
234273

235-
$statusIcons->addHtml(new Icon('random', ['title' => $title]));
274+
$statusIcons->addHtml(new Icon(Icons::HOST_DOWN, ['title' => $title]));
236275
}
237276

238277
if (! $item->notifications_enabled) {

0 commit comments

Comments
 (0)