[pve-devel] [PATCH widget-toolkit 2/2] notification matcher: improve wording for mode
Dominik Csapak
d.csapak at proxmox.com
Thu Nov 16 12:57:53 CET 2023
by removing the 'invert' checkbox and instead show the 4 modes possible,
we still assemble/parse the invert for the backend
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/window/NotificationMatcherEdit.js | 54 +++++++++------------------
1 file changed, 18 insertions(+), 36 deletions(-)
diff --git a/src/window/NotificationMatcherEdit.js b/src/window/NotificationMatcherEdit.js
index 0f29203..5a88288 100644
--- a/src/window/NotificationMatcherEdit.js
+++ b/src/window/NotificationMatcherEdit.js
@@ -516,35 +516,22 @@ Ext.define('Proxmox.panel.NotificationRulesEditPanel', {
let me = this;
let record = me.get('selectedRecord');
let currentData = record.get('data');
+ let invert = false;
+ if (value.startsWith('not')) {
+ value = value.substring(3);
+ invert = true;
+ }
record.set({
data: {
...currentData,
value,
+ invert,
},
});
},
get: function(record) {
- return record?.get('data')?.value;
- },
- },
- invertMatch: {
- bind: {
- bindTo: '{selectedRecord}',
- deep: true,
- },
- set: function(value) {
- let me = this;
- let record = me.get('selectedRecord');
- let currentData = record.get('data');
- record.set({
- data: {
- ...currentData,
- invert: value,
- },
- });
- },
- get: function(record) {
- return record?.get('data')?.invert;
+ let prefix = record?.get('data').invert ? 'not' : '';
+ return prefix + record?.get('data')?.value;
},
},
},
@@ -791,8 +778,12 @@ Ext.define('Proxmox.panel.NotificationMatchRuleTree', {
matchCalendarStmts.push(data.value);
break;
case 'mode':
- modeStmt = data.value;
- invertMatchStmt = data.invert;
+ if (data.value.startsWith('not')) {
+ modeStmt = data.value.substring(3); // after 'not''
+ invertMatchStmt = true;
+ } else {
+ modeStmt = data.value;
+ }
break;
}
@@ -1004,9 +995,13 @@ Ext.define('Proxmox.panel.NotificationMatchRuleSettings', {
allowBlank: false,
isFormField: false,
+ matchFieldWidth: false,
+
comboItems: [
['all', gettext('All rules match')],
['any', gettext('Any rule matches')],
+ ['notall', gettext('At least one rule does not match')],
+ ['notany', gettext('No rule matches')],
],
bind: {
hidden: '{!showMatchingMode}',
@@ -1014,19 +1009,6 @@ Ext.define('Proxmox.panel.NotificationMatchRuleSettings', {
value: '{rootMode}',
},
},
- {
- xtype: 'proxmoxcheckbox',
- fieldLabel: gettext('Invert match'),
- isFormField: false,
- uncheckedValue: 0,
- defaultValue: 0,
- bind: {
- hidden: '{!showMatchingMode}',
- disabled: '{!showMatchingMode}',
- value: '{invertMatch}',
- },
-
- },
{
xtype: 'proxmoxKVComboBox',
fieldLabel: gettext('Node type'),
--
2.30.2
More information about the pve-devel
mailing list