icingadb-web/library/Icingadb/Widget/DependencyNodeStatistics.php
Eric Lippmann 272e791390 License source files as GPL-3.0-or-later
Add SPDX license headers and mark source files as GPL-3.0-or-later to
preserve the option to relicense under later GPL versions.
2026-03-11 14:03:05 +01:00

50 lines
1.7 KiB
PHP

<?php
// SPDX-FileCopyrightText: 2024 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Icinga\Module\Icingadb\Widget;
use Icinga\Chart\Donut;
use Icinga\Module\Icingadb\Widget\Detail\ObjectStatistics;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\Html\HtmlString;
/**
* Dependency node statistics
*/
class DependencyNodeStatistics extends ObjectStatistics
{
protected $summary;
public function __construct($summary)
{
$this->summary = $summary;
}
protected function createDonut(): ValidHtml
{
$donut = (new Donut())
->addSlice($this->summary->nodes_ok, ['class' => 'slice-state-ok'])
->addSlice($this->summary->nodes_warning_handled, ['class' => 'slice-state-warning-handled'])
->addSlice($this->summary->nodes_warning_unhandled, ['class' => 'slice-state-warning'])
->addSlice($this->summary->nodes_problem_handled, ['class' => 'slice-state-critical-handled'])
->addSlice($this->summary->nodes_problem_unhandled, ['class' => 'slice-state-critical'])
->addSlice($this->summary->nodes_unknown_handled, ['class' => 'slice-state-unknown-handled'])
->addSlice($this->summary->nodes_unknown_unhandled, ['class' => 'slice-state-unknown'])
->addSlice($this->summary->nodes_pending, ['class' => 'slice-state-pending']);
return HtmlString::create($donut->render());
}
protected function createTotal(): ValidHtml
{
return Text::create($this->shortenAmount($this->summary->nodes_total));
}
protected function createBadges(): ValidHtml
{
return new DependencyNodeStateBadges($this->summary);
}
}