mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
ObjectInspectionDetail: Render invalid states
This commit is contained in:
parent
c503f14382
commit
e8d43313b9
1 changed files with 13 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ use Icinga\Module\Icingadb\Model\Service;
|
|||
use Icinga\Module\Icingadb\Widget\Detail\CustomVarTable;
|
||||
use Icinga\Util\Format;
|
||||
use Icinga\Util\Json;
|
||||
use InvalidArgumentException;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\FormattedString;
|
||||
use ipl\Html\HtmlElement;
|
||||
|
|
@ -298,13 +299,18 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement
|
|||
|
||||
private function formatState(int $state)
|
||||
{
|
||||
switch (true) {
|
||||
case $this->object instanceof Host:
|
||||
return HostStates::text($state);
|
||||
case $this->object instanceof Service:
|
||||
return ServiceStates::text($state);
|
||||
default:
|
||||
return $state;
|
||||
try {
|
||||
switch (true) {
|
||||
case $this->object instanceof Host:
|
||||
return HostStates::text($state);
|
||||
case $this->object instanceof Service:
|
||||
return ServiceStates::text($state);
|
||||
default:
|
||||
return $state;
|
||||
}
|
||||
} catch (InvalidArgumentException $_) {
|
||||
// The Icinga 2 API sometimes delivers strange details
|
||||
return (string) $state;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue