]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
notification: allow to select filter for notification targets
authorLukas Wagner <l.wagner@proxmox.com>
Thu, 3 Aug 2023 12:17:17 +0000 (14:17 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 16 Aug 2023 08:37:40 +0000 (10:37 +0200)
This commit adds a new selector field for existing endpoint
configuration where one is able to select a notification filter.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
src/Makefile
src/form/NotificationFilterSelector.js [new file with mode: 0644]
src/panel/GotifyEditPanel.js
src/panel/NotificationConfigView.js
src/panel/NotificationGroupEditPanel.js
src/panel/SendmailEditPanel.js
src/window/EndpointEditBase.js

index 829081d7afb4651d3189322a599947716534a076..f661bb60856f52f38a39f9153f86805bce35299c 100644 (file)
@@ -44,6 +44,7 @@ JSSRC=                                        \
        form/RoleSelector.js            \
        form/DiskSelector.js            \
        form/MultiDiskSelector.js       \
+       form/NotificationFilterSelector.js      \
        form/TaskTypeSelector.js        \
        form/ACME.js                    \
        form/UserSelector.js            \
diff --git a/src/form/NotificationFilterSelector.js b/src/form/NotificationFilterSelector.js
new file mode 100644 (file)
index 0000000..d2ab8be
--- /dev/null
@@ -0,0 +1,58 @@
+Ext.define('Proxmox.form.NotificationFilterSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    alias: ['widget.pmxNotificationFilterSelector'],
+
+    // set default value to empty array, else it inits it with
+    // null and after the store load it is an empty array,
+    // triggering dirtychange
+    value: [],
+    valueField: 'name',
+    displayField: 'name',
+    deleteEmpty: true,
+    skipEmptyText: true,
+    allowBlank: true,
+    editable: false,
+    autoSelect: false,
+
+    listConfig: {
+       columns: [
+           {
+               header: gettext('Filter'),
+               dataIndex: 'name',
+               sortable: true,
+               hideable: false,
+               flex: 1,
+           },
+           {
+               header: gettext('Comment'),
+               dataIndex: 'comment',
+               sortable: true,
+               hideable: false,
+               flex: 2,
+           },
+       ],
+    },
+
+    initComponent: function() {
+       let me = this;
+
+       Ext.apply(me, {
+           store: {
+               fields: ['name', 'comment'],
+               proxy: {
+                   type: 'proxmox',
+                   url: `/api2/json/${me.baseUrl}/filters`,
+               },
+               sorters: [
+                   {
+                       property: 'name',
+                       direction: 'ASC',
+                   },
+               ],
+               autoLoad: true,
+           },
+       });
+
+       me.callParent();
+    },
+});
index 5d814e5afbda9748e20760ec63cc7c50ab102c50..3ddcc4dd0626bfd0583af4b2daefecd5b9c10a0e 100644 (file)
@@ -32,6 +32,15 @@ Ext.define('Proxmox.panel.GotifyEditPanel', {
                allowBlank: '{!isCreate}',
            },
        },
+       {
+           xtype: 'pmxNotificationFilterSelector',
+           name: 'filter',
+           fieldLabel: gettext('Filter'),
+           cbind: {
+               deleteEmpty: '{!isCreate}',
+               baseUrl: '{baseUrl}',
+           },
+       },
        {
            xtype: 'proxmoxtextfield',
            name: 'comment',
index 9282ccd9b19e48a6322a4c23b6b5752e51e5f4ff..80e38f1098e9becd64551d0aa7fb79e8e2137204 100644 (file)
@@ -145,6 +145,10 @@ Ext.define('Proxmox.panel.NotificationEndpointView', {
     initComponent: function() {
        let me = this;
 
+       if (!me.baseUrl) {
+           throw "baseUrl is not set!";
+       }
+
        let menuItems = [];
        for (const [endpointType, config] of Object.entries(
            Proxmox.Schema.notificationEndpointTypes).sort()) {
index 910d15ac7bfeb42968e1086e26b39d1384c4b025..aa768102480e91bcfb633fe1bcae52d625ca056a 100644 (file)
@@ -21,6 +21,15 @@ Ext.define('Proxmox.panel.NotificationGroupEditPanel', {
            name: 'endpoint',
            allowBlank: false,
        },
+       {
+           xtype: 'pmxNotificationFilterSelector',
+           name: 'filter',
+           fieldLabel: gettext('Filter'),
+           cbind: {
+               deleteEmpty: '{!isCreate}',
+               baseUrl: '{baseUrl}',
+           },
+       },
        {
            xtype: 'proxmoxtextfield',
            name: 'comment',
index 33ac48205d2d953f47c4cd06ac303246b9db2031..b814f39aa686bfd4063a1247b65ecff08c246a09 100644 (file)
@@ -88,6 +88,15 @@ Ext.define('Proxmox.panel.SendmailEditPanel', {
                return this.up('pmxSendmailEditPanel').mailValidator();
            },
        },
+       {
+           xtype: 'pmxNotificationFilterSelector',
+           name: 'filter',
+           fieldLabel: gettext('Filter'),
+           cbind: {
+               deleteEmpty: '{!isCreate}',
+               baseUrl: '{baseUrl}',
+           },
+       },
        {
            xtype: 'proxmoxtextfield',
            name: 'comment',
index 9230b99ff2d6efefba6716c2cd7597cf1060b916..f42d0ea9ed1e1f12f0f8a1c2f5a88cc713ad2afc 100644 (file)
@@ -43,6 +43,7 @@ Ext.define('Proxmox.window.EndpointEditBase', {
                name: me.name,
                xtype: endpointConfig.ipanel,
                isCreate: me.isCreate,
+               baseUrl: me.baseUrl,
                type: me.type,
            }],
        });