-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide reporting hook for single
host/service
- Loading branch information
1 parent
e0c3c8e
commit 08870a0
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Icingadb\ProvidedHook; | ||
|
||
use Icinga\Authentication\Auth; | ||
use Icinga\Module\Icingadb\Hook\HostActionsHook; | ||
use Icinga\Module\Icingadb\Model\Host; | ||
use ipl\I18n\Translation; | ||
use ipl\Stdlib\Filter; | ||
use ipl\Web\Filter\QueryString; | ||
use ipl\Web\Url; | ||
use ipl\Web\Widget\Link; | ||
|
||
class CreateHostSlaReport extends HostActionsHook | ||
{ | ||
use Translation; | ||
|
||
public function getActionsForObject(Host $host): array | ||
{ | ||
if (! Auth::getInstance()->hasPermission('reporting/reports')) { | ||
return []; | ||
} | ||
|
||
$filter = QueryString::render(Filter::equal('host.name', $host->name)); | ||
|
||
return [ | ||
new Link( | ||
$this->translate('Create Host SLA Report'), | ||
Url::fromPath('reporting/reports/new')->addParams(['filter' => $filter, 'report' => 'host']) | ||
) | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Icingadb\ProvidedHook; | ||
|
||
use Icinga\Authentication\Auth; | ||
use Icinga\Module\Icingadb\Hook\ServiceActionsHook; | ||
use Icinga\Module\Icingadb\Model\Service; | ||
use ipl\I18n\Translation; | ||
use ipl\Stdlib\Filter; | ||
use ipl\Web\Filter\QueryString; | ||
use ipl\Web\Url; | ||
use ipl\Web\Widget\Link; | ||
|
||
class CreateServiceSlaReport extends ServiceActionsHook | ||
{ | ||
use Translation; | ||
|
||
public function getActionsForObject(Service $service): array | ||
{ | ||
if (! Auth::getInstance()->hasPermission('reporting/reports')) { | ||
return []; | ||
} | ||
|
||
$filter = QueryString::render(Filter::all( | ||
Filter::equal('service.name', $service->name), | ||
Filter::equal('host.name', $service->host->name) | ||
)); | ||
|
||
return [ | ||
new Link( | ||
$this->translate('Create Service SLA Report'), | ||
Url::fromPath('reporting/reports/new')->addParams(['filter' => $filter, 'report' => 'service']) | ||
) | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters