From 2b4676c1e8242301fbec74111fb5c91ddf6c0147 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 22 Jun 2026 10:06:51 +0200 Subject: [PATCH] WIP --- .../Notifications/SourceIntegrationSetup.php | 36 +++++++++++++++++++ run.php | 1 + 2 files changed, 37 insertions(+) create mode 100644 library/Icingadb/ProvidedHook/Notifications/SourceIntegrationSetup.php diff --git a/library/Icingadb/ProvidedHook/Notifications/SourceIntegrationSetup.php b/library/Icingadb/ProvidedHook/Notifications/SourceIntegrationSetup.php new file mode 100644 index 000000000..7e0ed4e29 --- /dev/null +++ b/library/Icingadb/ProvidedHook/Notifications/SourceIntegrationSetup.php @@ -0,0 +1,36 @@ + +// SPDX-License-Identifier: GPL-3.0-or-later + +namespace Icinga\Module\Icingadb\ProvidedHook\Notifications; + +use GuzzleHttp\Psr7\ServerRequest; +use Icinga\Module\Notifications\Common\Database; +use Icinga\Module\Notifications\Hook\SourceIntegrationSetupHook; +use Icinga\Web\Notification; +use ipl\Html\Form; +use ipl\Html\ValidHtml; +use ipl\I18n\Translation; +use ipl\Web\Compat\CompatForm; +use ipl\Web\Url; + +class SourceIntegrationSetup extends SourceIntegrationSetupHook +{ + use Translation; + + public function getIntegration(): ValidHtml + { + return (new CompatForm()) + ->addAttributes(['class' => 'inline']) + ->setAction((string) Url::fromRequest()) + ->addElement('submit', 'submit', ['label' => $this->translate('Icinga2 Integration')]) + ->on(Form::ON_SUBMIT, function (): void { + // Database::get()->update('source', ['listener_username' => 'test', 'deleted' => 'n'], ['id = ?' => 1]); + Notification::success($this->translate('Icinga2 source integration setup completed')); + + $this->setFinished(); + }) + ->handleRequest(ServerRequest::fromGlobals()); + } +} diff --git a/run.php b/run.php index d37a89187..64b184dca 100644 --- a/run.php +++ b/run.php @@ -17,6 +17,7 @@ if ($this::exists('notifications')) { $this->provideHook('Notifications/v1/Source'); $this->provideHook('Notifications/v2/Icinga2Source'); + $this->provideHook('Notifications/SourceIntegrationSetup'); } if ($this::exists('reporting')) {