-
Notifications
You must be signed in to change notification settings - Fork 1
Move Rule evaluation to Source #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5706b44 to
e948c8f
Compare
|
Likewise to the Icinga DB PR, I've changed quite a few things as well, so I'll summarize the changes here for you:
After applying the extra tags and Icinga 2 removal changes, Icinga Notifications Web will be broken, so you've to work around this with a temporary fix, by removing and commenting out some code parts: Diffdiff --git a/application/controllers/EventRuleController.php b/application/controllers/EventRuleController.php
index c96c88b..3e0d7c2 100644
--- a/application/controllers/EventRuleController.php
+++ b/application/controllers/EventRuleController.php
@@ -10,7 +10,6 @@ use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Forms\EventRuleForm;
use Icinga\Module\Notifications\Forms\SaveEventRuleForm;
use Icinga\Module\Notifications\Model\Rule;
-use Icinga\Module\Notifications\Web\Control\SearchBar\ExtraTagSuggestions;
use Icinga\Module\Notifications\Widget\EventRuleConfig;
use Icinga\Web\Notification;
use Icinga\Web\Session;
@@ -177,9 +176,6 @@ class EventRuleController extends CompatController
*/
public function completeAction(): void
{
- $suggestions = new ExtraTagSuggestions();
- $suggestions->forRequest($this->getServerRequest());
- $this->getDocument()->add($suggestions);
}
diff --git a/application/forms/SourceForm.php b/application/forms/SourceForm.php
index dcfbc63..b5f4523 100644
--- a/application/forms/SourceForm.php
+++ b/application/forms/SourceForm.php
@@ -71,7 +71,7 @@ class SourceForm extends CompatForm
|| ($chosenType === null && $configuredType === null)
|| ($chosenType === null && $configuredType === Source::ICINGA_TYPE_NAME);
- if ($showIcingaApiConfig) {
+ if (false && $showIcingaApiConfig) {
// TODO: Shouldn't be necessary: https://github.com/Icinga/ipl-html/issues/131
$this->clearPopulatedValue('type');
@@ -203,11 +203,11 @@ class SourceForm extends CompatForm
);
// Preserves (some) entered data even if the user switches between types
- $this->addElement('hidden', 'icinga2_base_url');
- $this->addElement('hidden', 'icinga2_auth_user');
- $this->addElement('hidden', 'icinga2_insecure_tls');
- $this->addElement('hidden', 'icinga2_common_name');
- $this->addElement('hidden', 'icinga2_ca_pem');
+ //$this->addElement('hidden', 'icinga2_base_url');
+ //$this->addElement('hidden', 'icinga2_auth_user');
+ //$this->addElement('hidden', 'icinga2_insecure_tls');
+ //$this->addElement('hidden', 'icinga2_common_name');
+ //$this->addElement('hidden', 'icinga2_ca_pem');
}
$this->addElement(
@@ -376,12 +376,12 @@ class SourceForm extends CompatForm
return [
'name' => $source->name,
'type' => $source->type,
- 'icinga2_base_url' => $source->icinga2_base_url,
- 'icinga2_auth_user' => $source->icinga2_auth_user,
- 'icinga2_auth_pass' => $source->icinga2_auth_pass,
- 'icinga2_ca_pem' => $source->icinga2_ca_pem,
- 'icinga2_common_name' => $source->icinga2_common_name,
- 'icinga2_insecure_tls' => $source->icinga2_insecure_tls
+ //'icinga2_base_url' => $source->icinga2_base_url,
+ //'icinga2_auth_user' => $source->icinga2_auth_user,
+ //'icinga2_auth_pass' => $source->icinga2_auth_pass,
+ //'icinga2_ca_pem' => $source->icinga2_ca_pem,
+ //'icinga2_common_name' => $source->icinga2_common_name,
+ //'icinga2_insecure_tls' => $source->icinga2_insecure_tls
];
}
}
diff --git a/library/Notifications/Model/ExtraTag.php b/library/Notifications/Model/ExtraTag.php
deleted file mode 100644
index 07a27f8..0000000
--- a/library/Notifications/Model/ExtraTag.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */
-
-namespace Icinga\Module\Notifications\Model;
-
-use Icinga\Module\Notifications\Model\Behavior\ObjectTags;
-use ipl\Orm\Behaviors;
-use ipl\Sql\Connection;
-
-class ExtraTag extends ObjectExtraTag
-{
- /**
- * @internal Don't use. This model acts only as relation target and is not supposed to be directly used as query
- * target. Use {@see ObjectExtraTag} instead.
- */
- public static function on(Connection $_)
- {
- throw new \LogicException('Documentation says: DO NOT USE. Can\'t you read?');
- }
-
- public function createBehaviors(Behaviors $behaviors): void
- {
- parent::createBehaviors($behaviors);
-
- $behaviors->add(new ObjectTags());
- }
-}
diff --git a/library/Notifications/Model/ObjectExtraTag.php b/library/Notifications/Model/ObjectExtraTag.php
deleted file mode 100644
index df7beb7..0000000
--- a/library/Notifications/Model/ObjectExtraTag.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */
-
-namespace Icinga\Module\Notifications\Model;
-
-use ipl\Orm\Behavior\Binary;
-use ipl\Orm\Behaviors;
-use ipl\Orm\Model;
-use ipl\Orm\Query;
-use ipl\Orm\Relations;
-
-/**
- * ObjectExtraTag database model
- *
- * @property string $object_id
- * @property string $tag
- * @property string $value
- *
- * @property Query|Objects $object
- */
-class ObjectExtraTag extends Model
-{
- public function getTableName(): string
- {
- return 'object_extra_tag';
- }
-
- public function getKeyName(): array
- {
- return ['object_id', 'tag'];
- }
-
- public function getColumns(): array
- {
- return [
- 'object_id',
- 'tag',
- 'value'
- ];
- }
-
- public function createBehaviors(Behaviors $behaviors): void
- {
- $behaviors->add(new Binary(['object_id']));
- }
-
- public function createRelations(Relations $relations): void
- {
- $relations->belongsTo('object', Objects::class);
- }
-}
diff --git a/library/Notifications/Model/Objects.php b/library/Notifications/Model/Objects.php
index c621056..3f37a27 100644
--- a/library/Notifications/Model/Objects.php
+++ b/library/Notifications/Model/Objects.php
@@ -25,8 +25,6 @@ use ipl\Orm\Relations;
* @property Query|Event $event
* @property Query|Incident $incident
* @property Query|Tag $tag
- * @property Query|ObjectExtraTag $object_extra_tag
- * @property Query|ExtraTag $extra_tag
* @property Query|Source $source
* @property array<string, string> $id_tags
*/
@@ -81,10 +79,6 @@ class Objects extends Model
$relations->hasMany('object_id_tag', ObjectIdTag::class);
$relations->hasMany('tag', Tag::class);
- $relations->hasMany('object_extra_tag', ObjectExtraTag::class)
- ->setJoinType('LEFT');
- $relations->hasMany('extra_tag', ExtraTag::class)
- ->setJoinType('LEFT');
$relations->belongsTo('source', Source::class)->setJoinType('LEFT');
}
diff --git a/library/Notifications/Model/Source.php b/library/Notifications/Model/Source.php
index 973bbb7..e8059fc 100644
--- a/library/Notifications/Model/Source.php
+++ b/library/Notifications/Model/Source.php
@@ -19,12 +19,6 @@ use ipl\Web\Widget\Icon;
* @property string $type Type identifier
* @property string $name The user-defined name
* @property ?string $listener_password_hash
- * @property ?string $icinga2_base_url
- * @property ?string $icinga2_auth_user
- * @property ?string $icinga2_auth_pass
- * @property ?string $icinga2_ca_pem
- * @property ?string $icinga2_common_name
- * @property string $icinga2_insecure_tls
* @property DateTime $changed_at
* @property bool $deleted
*
@@ -51,12 +45,6 @@ class Source extends Model
'type',
'name',
'listener_password_hash',
- 'icinga2_base_url',
- 'icinga2_auth_user',
- 'icinga2_auth_pass',
- 'icinga2_ca_pem',
- 'icinga2_common_name',
- 'icinga2_insecure_tls',
'changed_at',
'deleted'
];
diff --git a/library/Notifications/Web/Control/SearchBar/ExtraTagSuggestions.php b/library/Notifications/Web/Control/SearchBar/ExtraTagSuggestions.php
deleted file mode 100644
index 88f52c2..0000000
--- a/library/Notifications/Web/Control/SearchBar/ExtraTagSuggestions.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */
-
-namespace Icinga\Module\Notifications\Web\Control\SearchBar;
-
-use Icinga\Module\Notifications\Common\Database;
-use Icinga\Module\Notifications\Model\ObjectExtraTag;
-use Icinga\Module\Notifications\Util\ObjectSuggestionsCursor;
-use ipl\Web\Control\SearchBar\Suggestions;
-use ipl\Stdlib\Filter;
-use Traversable;
-
-class ExtraTagSuggestions extends Suggestions
-{
- protected function fetchValueSuggestions($column, $searchTerm, Filter\Chain $searchFilter)
- {
- yield;
- }
-
- protected function createQuickSearchFilter($searchTerm)
- {
- return Filter::any();
- }
-
- protected function fetchColumnSuggestions($searchTerm)
- {
- $searchColumns = (new ObjectSuggestionsCursor(
- Database::get(),
- (new ObjectExtraTag())::on(Database::get())
- ->columns(['tag'])
- ->assembleSelect()
- ->distinct()
- ));
-
- // Object Extra Tags
- foreach ($searchColumns as $column) {
- yield $column->tag => $column->tag;
- }
- }
-}
diff --git a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php
index 2a4d674..2bd1b82 100644
--- a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php
+++ b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php
@@ -6,7 +6,6 @@ namespace Icinga\Module\Notifications\Web\Control\SearchBar;
use Icinga\Module\Notifications\Common\Auth;
use Icinga\Module\Notifications\Common\Database;
-use Icinga\Module\Notifications\Model\ObjectExtraTag;
use Icinga\Module\Notifications\Model\ObjectIdTag;
use Icinga\Module\Notifications\Util\ObjectSuggestionsCursor;
use ipl\Html\HtmlElement;
@@ -184,9 +183,9 @@ class ObjectSuggestions extends Suggestions
}
// Custom variables only after the columns are exhausted and there's actually a chance the user sees them
- foreach ([new ObjectIdTag(), new ObjectExtraTag()] as $model) {
+ foreach ([new ObjectIdTag()] as $model) {
$titleAdded = false;
- /** @var ObjectIdTag|ObjectExtraTag $tag */
+ /** @var ObjectIdTag $tag */
foreach ($this->queryTags($model, $searchTerm) as $tag) {
$isIdTag = $tag instanceof ObjectIdTag;
diff --git a/library/Notifications/Widget/Detail/IncidentDetail.php b/library/Notifications/Widget/Detail/IncidentDetail.php
index 46e6bed..a9c370b 100644
--- a/library/Notifications/Widget/Detail/IncidentDetail.php
+++ b/library/Notifications/Widget/Detail/IncidentDetail.php
@@ -105,19 +105,10 @@ class IncidentDetail extends BaseHtmlElement
protected function createObjectTag(): array
{
- $tags = [];
- foreach ($this->incident->object->object_extra_tag as $extraTag) {
- $tags[] = Table::row([$extraTag->tag, $extraTag->value]);
- }
-
- if (! $tags) {
- return $tags;
- }
-
return [
new HtmlElement('h2', null, new Text(t('Object Tags'))),
(new Table())
- ->addHtml(...$tags)
+ ->addHtml()
->addAttributes(['class' => 'object-tags-table'])
];
}Also, all the individual commits are self-contained, and includes the relevant commit message with some details about |
193fb86 to
de9b824
Compare
|
The following diff against Icinga Notification Web "works" if your source has the ID 1. It is based on @yhabteab's diff from above. It should apply on top of today's CLICK HERE FOR A FREE DOWNLOAD
diff --git a/application/controllers/EventRuleController.php b/application/controllers/EventRuleController.php
index 9d07d6b..6ffdf3c 100644
--- a/application/controllers/EventRuleController.php
+++ b/application/controllers/EventRuleController.php
@@ -12,7 +12,6 @@ use Icinga\Module\Notifications\Forms\EventRuleConfigElements\NotificationConfig
use Icinga\Module\Notifications\Forms\EventRuleConfigForm;
use Icinga\Module\Notifications\Forms\EventRuleForm;
use Icinga\Module\Notifications\Model\Rule;
-use Icinga\Module\Notifications\Web\Control\SearchBar\ExtraTagSuggestions;
use Icinga\Web\Notification;
use Icinga\Web\Session;
use ipl\Html\Form;
@@ -157,9 +156,6 @@ class EventRuleController extends CompatController
*/
public function completeAction(): void
{
- $suggestions = new ExtraTagSuggestions();
- $suggestions->forRequest($this->getServerRequest());
- $this->getDocument()->add($suggestions);
}
/**
diff --git a/application/forms/EventRuleConfigForm.php b/application/forms/EventRuleConfigForm.php
index 34da1ac..2652535 100644
--- a/application/forms/EventRuleConfigForm.php
+++ b/application/forms/EventRuleConfigForm.php
@@ -291,6 +291,7 @@ class EventRuleConfigForm extends Form
$db->insert('rule', [
'name' => $this->getValue('name'),
'timeperiod_id' => null,
+ 'source_id' => 1, // TODO :^)
'object_filter' => $this->getValue('object_filter'),
'changed_at' => (int) (new DateTime())->format("Uv"),
'deleted' => 'n'
diff --git a/application/forms/SourceForm.php b/application/forms/SourceForm.php
index dcfbc63..a57f626 100644
--- a/application/forms/SourceForm.php
+++ b/application/forms/SourceForm.php
@@ -71,144 +71,48 @@ class SourceForm extends CompatForm
|| ($chosenType === null && $configuredType === null)
|| ($chosenType === null && $configuredType === Source::ICINGA_TYPE_NAME);
- if ($showIcingaApiConfig) {
- // TODO: Shouldn't be necessary: https://github.com/Icinga/ipl-html/issues/131
- $this->clearPopulatedValue('type');
+ $this->getElement('icinga_or_other')->setValue('other');
- $this->addElement(
- 'hidden',
- 'type',
- [
- 'required' => true,
- 'disabled' => true,
- 'value' => Source::ICINGA_TYPE_NAME
- ]
- );
- $this->addElement(
- 'text',
- 'icinga2_base_url',
- [
- 'required' => true,
- 'label' => $this->translate('API URL')
- ]
- );
- $this->addElement(
- 'text',
- 'icinga2_auth_user',
- [
- 'required' => true,
- 'label' => $this->translate('API Username'),
- 'autocomplete' => 'off'
- ]
- );
- $this->addElement(
- 'password',
- 'icinga2_auth_pass',
- [
- 'required' => true,
- 'label' => $this->translate('API Password'),
- 'autocomplete' => 'new-password'
- ]
- );
- $this->addElement(
- 'checkbox',
- 'icinga2_insecure_tls',
- [
- 'class' => 'autosubmit',
- 'label' => $this->translate('Verify API Certificate'),
- 'checkedValue' => 'n',
- 'uncheckedValue' => 'y',
- 'value' => true
- ]
- );
-
- /** @var CheckboxElement $insecureBox */
- $insecureBox = $this->getElement('icinga2_insecure_tls');
- if ($insecureBox->isChecked()) {
- $this->addElement(
- 'text',
- 'icinga2_common_name',
- [
- 'label' => $this->translate('Common Name'),
- 'description' => $this->translate(
- 'The CN of the API certificate. Only required if it differs from the FQDN of the API URL'
- )
- ]
- );
-
- $this->addElement(
- 'textarea',
- 'icinga2_ca_pem',
- [
- 'cols' => 64,
- 'rows' => 28,
- 'required' => true,
- 'validators' => [new X509CertValidator()],
- 'label' => $this->translate('CA Certificate'),
- 'description' => $this->translate('The certificate of the Icinga CA')
- ]
- );
- }
- } else {
- $this->getElement('icinga_or_other')->setValue('other');
-
- $this->addElement(
- 'text',
- 'type',
- [
- 'required' => true,
- 'label' => $this->translate('Type Name'),
- 'validators' => [new CallbackValidator(function (string $value, CallbackValidator $validator) {
- if ($value === Source::ICINGA_TYPE_NAME) {
- $validator->addMessage($this->translate('This name is reserved and cannot be used'));
-
- return false;
- }
-
- return true;
- })]
- ]
- );
- $this->addElement(
- 'password',
- 'listener_password',
- [
- 'ignore' => true,
- 'required' => $this->sourceId === null,
- 'label' => $this->sourceId !== null
- ? $this->translate('New Password')
- : $this->translate('Password'),
- 'autocomplete' => 'new-password',
- 'validators' => [['name' => 'StringLength', 'options' => ['min' => 16]]]
- ]
- );
- $this->addElement(
- 'password',
- 'listener_password_dupe',
- [
- 'ignore' => true,
- 'required' => $this->sourceId === null,
- 'label' => $this->translate('Repeat Password'),
- 'autocomplete' => 'new-password',
- 'validators' => [new CallbackValidator(function (string $value, CallbackValidator $validator) {
- if ($value !== $this->getValue('listener_password')) {
- $validator->addMessage($this->translate('Passwords do not match'));
-
- return false;
- }
-
- return true;
- })]
- ]
- );
-
- // Preserves (some) entered data even if the user switches between types
- $this->addElement('hidden', 'icinga2_base_url');
- $this->addElement('hidden', 'icinga2_auth_user');
- $this->addElement('hidden', 'icinga2_insecure_tls');
- $this->addElement('hidden', 'icinga2_common_name');
- $this->addElement('hidden', 'icinga2_ca_pem');
- }
+ $this->addElement(
+ 'text',
+ 'type',
+ [
+ 'required' => true,
+ 'label' => $this->translate('Type Name'),
+ ]
+ );
+ $this->addElement(
+ 'password',
+ 'listener_password',
+ [
+ 'ignore' => true,
+ 'required' => $this->sourceId === null,
+ 'label' => $this->sourceId !== null
+ ? $this->translate('New Password')
+ : $this->translate('Password'),
+ 'autocomplete' => 'new-password',
+ 'validators' => [['name' => 'StringLength', 'options' => ['min' => 16]]]
+ ]
+ );
+ $this->addElement(
+ 'password',
+ 'listener_password_dupe',
+ [
+ 'ignore' => true,
+ 'required' => $this->sourceId === null,
+ 'label' => $this->translate('Repeat Password'),
+ 'autocomplete' => 'new-password',
+ 'validators' => [new CallbackValidator(function (string $value, CallbackValidator $validator) {
+ if ($value !== $this->getValue('listener_password')) {
+ $validator->addMessage($this->translate('Passwords do not match'));
+
+ return false;
+ }
+
+ return true;
+ })]
+ ]
+ );
$this->addElement(
'submit',
@@ -376,12 +280,6 @@ class SourceForm extends CompatForm
return [
'name' => $source->name,
'type' => $source->type,
- 'icinga2_base_url' => $source->icinga2_base_url,
- 'icinga2_auth_user' => $source->icinga2_auth_user,
- 'icinga2_auth_pass' => $source->icinga2_auth_pass,
- 'icinga2_ca_pem' => $source->icinga2_ca_pem,
- 'icinga2_common_name' => $source->icinga2_common_name,
- 'icinga2_insecure_tls' => $source->icinga2_insecure_tls
];
}
}
diff --git a/library/Notifications/Model/ExtraTag.php b/library/Notifications/Model/ExtraTag.php
deleted file mode 100644
index 07a27f8..0000000
--- a/library/Notifications/Model/ExtraTag.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */
-
-namespace Icinga\Module\Notifications\Model;
-
-use Icinga\Module\Notifications\Model\Behavior\ObjectTags;
-use ipl\Orm\Behaviors;
-use ipl\Sql\Connection;
-
-class ExtraTag extends ObjectExtraTag
-{
- /**
- * @internal Don't use. This model acts only as relation target and is not supposed to be directly used as query
- * target. Use {@see ObjectExtraTag} instead.
- */
- public static function on(Connection $_)
- {
- throw new \LogicException('Documentation says: DO NOT USE. Can\'t you read?');
- }
-
- public function createBehaviors(Behaviors $behaviors): void
- {
- parent::createBehaviors($behaviors);
-
- $behaviors->add(new ObjectTags());
- }
-}
diff --git a/library/Notifications/Model/ObjectExtraTag.php b/library/Notifications/Model/ObjectExtraTag.php
deleted file mode 100644
index df7beb7..0000000
--- a/library/Notifications/Model/ObjectExtraTag.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */
-
-namespace Icinga\Module\Notifications\Model;
-
-use ipl\Orm\Behavior\Binary;
-use ipl\Orm\Behaviors;
-use ipl\Orm\Model;
-use ipl\Orm\Query;
-use ipl\Orm\Relations;
-
-/**
- * ObjectExtraTag database model
- *
- * @property string $object_id
- * @property string $tag
- * @property string $value
- *
- * @property Query|Objects $object
- */
-class ObjectExtraTag extends Model
-{
- public function getTableName(): string
- {
- return 'object_extra_tag';
- }
-
- public function getKeyName(): array
- {
- return ['object_id', 'tag'];
- }
-
- public function getColumns(): array
- {
- return [
- 'object_id',
- 'tag',
- 'value'
- ];
- }
-
- public function createBehaviors(Behaviors $behaviors): void
- {
- $behaviors->add(new Binary(['object_id']));
- }
-
- public function createRelations(Relations $relations): void
- {
- $relations->belongsTo('object', Objects::class);
- }
-}
diff --git a/library/Notifications/Model/Objects.php b/library/Notifications/Model/Objects.php
index c621056..3f37a27 100644
--- a/library/Notifications/Model/Objects.php
+++ b/library/Notifications/Model/Objects.php
@@ -25,8 +25,6 @@ use ipl\Orm\Relations;
* @property Query|Event $event
* @property Query|Incident $incident
* @property Query|Tag $tag
- * @property Query|ObjectExtraTag $object_extra_tag
- * @property Query|ExtraTag $extra_tag
* @property Query|Source $source
* @property array<string, string> $id_tags
*/
@@ -81,10 +79,6 @@ class Objects extends Model
$relations->hasMany('object_id_tag', ObjectIdTag::class);
$relations->hasMany('tag', Tag::class);
- $relations->hasMany('object_extra_tag', ObjectExtraTag::class)
- ->setJoinType('LEFT');
- $relations->hasMany('extra_tag', ExtraTag::class)
- ->setJoinType('LEFT');
$relations->belongsTo('source', Source::class)->setJoinType('LEFT');
}
diff --git a/library/Notifications/Model/Rule.php b/library/Notifications/Model/Rule.php
index 8e69a01..00cd5f8 100644
--- a/library/Notifications/Model/Rule.php
+++ b/library/Notifications/Model/Rule.php
@@ -16,6 +16,7 @@ use ipl\Orm\Relations;
* @property int $id
* @property string $name
* @property ?int $timeperiod_id
+ * @property ?int $source_id
* @property ?string $object_filter
* @property DateTime $changed_at
* @property bool $deleted
@@ -41,6 +42,7 @@ class Rule extends Model
return [
'name',
'timeperiod_id',
+ 'source_id',
'object_filter',
'changed_at',
'deleted'
@@ -51,6 +53,7 @@ class Rule extends Model
{
return [
'name' => t('Name'),
+ 'source_id' => t('Source ID'),
'timeperiod_id' => t('Timeperiod ID'),
'object_filter' => t('Object Filter'),
'changed_at' => t('Changed At')
diff --git a/library/Notifications/Model/Source.php b/library/Notifications/Model/Source.php
index 973bbb7..8558ace 100644
--- a/library/Notifications/Model/Source.php
+++ b/library/Notifications/Model/Source.php
@@ -19,12 +19,6 @@ use ipl\Web\Widget\Icon;
* @property string $type Type identifier
* @property string $name The user-defined name
* @property ?string $listener_password_hash
- * @property ?string $icinga2_base_url
- * @property ?string $icinga2_auth_user
- * @property ?string $icinga2_auth_pass
- * @property ?string $icinga2_ca_pem
- * @property ?string $icinga2_common_name
- * @property string $icinga2_insecure_tls
* @property DateTime $changed_at
* @property bool $deleted
*
@@ -33,7 +27,7 @@ use ipl\Web\Widget\Icon;
class Source extends Model
{
/** @var string The type name used by Icinga sources */
- public const ICINGA_TYPE_NAME = 'icinga2';
+ public const ICINGA_TYPE_NAME = 'icingadb';
public function getTableName(): string
{
@@ -51,12 +45,6 @@ class Source extends Model
'type',
'name',
'listener_password_hash',
- 'icinga2_base_url',
- 'icinga2_auth_user',
- 'icinga2_auth_pass',
- 'icinga2_ca_pem',
- 'icinga2_common_name',
- 'icinga2_insecure_tls',
'changed_at',
'deleted'
];
diff --git a/library/Notifications/Web/Control/SearchBar/ExtraTagSuggestions.php b/library/Notifications/Web/Control/SearchBar/ExtraTagSuggestions.php
deleted file mode 100644
index 88f52c2..0000000
--- a/library/Notifications/Web/Control/SearchBar/ExtraTagSuggestions.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */
-
-namespace Icinga\Module\Notifications\Web\Control\SearchBar;
-
-use Icinga\Module\Notifications\Common\Database;
-use Icinga\Module\Notifications\Model\ObjectExtraTag;
-use Icinga\Module\Notifications\Util\ObjectSuggestionsCursor;
-use ipl\Web\Control\SearchBar\Suggestions;
-use ipl\Stdlib\Filter;
-use Traversable;
-
-class ExtraTagSuggestions extends Suggestions
-{
- protected function fetchValueSuggestions($column, $searchTerm, Filter\Chain $searchFilter)
- {
- yield;
- }
-
- protected function createQuickSearchFilter($searchTerm)
- {
- return Filter::any();
- }
-
- protected function fetchColumnSuggestions($searchTerm)
- {
- $searchColumns = (new ObjectSuggestionsCursor(
- Database::get(),
- (new ObjectExtraTag())::on(Database::get())
- ->columns(['tag'])
- ->assembleSelect()
- ->distinct()
- ));
-
- // Object Extra Tags
- foreach ($searchColumns as $column) {
- yield $column->tag => $column->tag;
- }
- }
-}
diff --git a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php
index 2a4d674..2bd1b82 100644
--- a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php
+++ b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php
@@ -6,7 +6,6 @@ namespace Icinga\Module\Notifications\Web\Control\SearchBar;
use Icinga\Module\Notifications\Common\Auth;
use Icinga\Module\Notifications\Common\Database;
-use Icinga\Module\Notifications\Model\ObjectExtraTag;
use Icinga\Module\Notifications\Model\ObjectIdTag;
use Icinga\Module\Notifications\Util\ObjectSuggestionsCursor;
use ipl\Html\HtmlElement;
@@ -184,9 +183,9 @@ class ObjectSuggestions extends Suggestions
}
// Custom variables only after the columns are exhausted and there's actually a chance the user sees them
- foreach ([new ObjectIdTag(), new ObjectExtraTag()] as $model) {
+ foreach ([new ObjectIdTag()] as $model) {
$titleAdded = false;
- /** @var ObjectIdTag|ObjectExtraTag $tag */
+ /** @var ObjectIdTag $tag */
foreach ($this->queryTags($model, $searchTerm) as $tag) {
$isIdTag = $tag instanceof ObjectIdTag;
diff --git a/library/Notifications/Widget/Detail/IncidentDetail.php b/library/Notifications/Widget/Detail/IncidentDetail.php
index 46e6bed..a9c370b 100644
--- a/library/Notifications/Widget/Detail/IncidentDetail.php
+++ b/library/Notifications/Widget/Detail/IncidentDetail.php
@@ -105,19 +105,10 @@ class IncidentDetail extends BaseHtmlElement
protected function createObjectTag(): array
{
- $tags = [];
- foreach ($this->incident->object->object_extra_tag as $extraTag) {
- $tags[] = Table::row([$extraTag->tag, $extraTag->value]);
- }
-
- if (! $tags) {
- return $tags;
- }
-
return [
new HtmlElement('h2', null, new Text(t('Object Tags'))),
(new Table())
- ->addHtml(...$tags)
+ ->addHtml()
->addAttributes(['class' => 'object-tags-table'])
];
} |
de9b824 to
508ea9c
Compare
Move version into own product type, holding an unique major value and an incrementable minor version. Also rework some other small things brought up in the review.
This reverts commit 79951c4.
- UnixMilli does not require UTC, UnixMilli() always returns UTC. - Don't reject event submissions when no rules exist. - Use strconv instead of fmt for a single number.
- Document new event fields in API and endpoints. - Inline RuleSet in ConfigSet. - Allow source.listener_password_hash to be NULL again. - Keep go imports in the same format.
The current Icinga Notifications Web state allows changing a Rule's source. This was, so far, not possible on our side.
Move the schema upgrades to a distinct schema upgrade file and readd the ck_source_bcrypt_listener_password_hash constraint to these files, initially added in dc4396a.
- incidents_test.go: Remove unnecessary listener_password_hash due to updated constraint. - rule.go: Update now outdated comment.
5378264 to
e2a1836
Compare
The "Process Event" section was a bit outdated, still referring the removed Icinga 2 source. Especially the added rules and rule version logic needed some explanation.
| github.com/google/uuid v1.6.0 | ||
| github.com/hashicorp/golang-lru/v2 v2.0.7 | ||
| github.com/icinga/icinga-go-library v0.7.2 | ||
| github.com/icinga/icinga-go-library v0.7.3-0.20251022120618-6600889adc38 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That commit (Icinga/icinga-go-library@6600889) is included in the main branch of that repo, so it'll be included in the next release. Pinning a commit should be fine for the meantime, but for a tagged version in this repo, a tagged version from that repo should be used (I'll create an issue so that we won't forget).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create an issue so that we won't forget
Done: #347
|
Since this drops the icinga2 source and Icinga DB only transmits customvars as extra tags, wouldn't it be a good idea to drop all extra tags during migration? Otherwise old extra tags remain and won't be deleted. Or is this a general limitation since it also means customvars aren't deleted? |
They should be updated with the next event received for each object. And update in that context also means removing those that are no longer sent. |
|
Ah, that might have been it, I have incidents for objects that no longer exist. Or aren't checked actively. |
This gives a single file that can be applied during the upgrade more easily, having it in individual files was mostly to avoid merge conflicts during development. The combined files were created with the following command: cat 0.2.0-external-uuid.sql <(echo) 0.2.0-source-rules.sql <(echo) 0.2.0-schedule-timezone.sql <(echo) 0.2.0-source-username.sql > 0.2.0.sql The order of files matches the order in which the PRs that added them were merged (though the order shouldn't really matter as there are no dependencies between the individual files): - #216 - #324 - #344 - #338
This gives a single file that can be applied during the upgrade more easily, having it in individual files was mostly to avoid merge conflicts during development. The combined files were created with the following command: cat 0.2.0-external-uuid.sql <(echo) 0.2.0-source-rules.sql <(echo) 0.2.0-schedule-timezone.sql <(echo) 0.2.0-source-username.sql > 0.2.0.sql The order of files matches the order in which the PRs that added them were merged (though the order shouldn't really matter as there are no dependencies between the individual files): - #216 - #324 - #344 - #338
This is a first version to move the rule evaluation from Icinga Notifications into the source, starting with Icinga DB.
For an end user or another computer, the /process-event API endpoint was slightly modified. Two new HTTP request headers were introduced to tell which rules match and to share the state.
Another new /event-rules API endpoint allows querying all rules.
Other PRs are
At the moment, there is no real support in Icinga Notifications Web. Thus, start by creating a rule through the current web interface and update the data in the relational database. Consider the following: