From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8C61BC227 for ; Thu, 6 Jul 2023 12:55:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 502621D9E4 for ; Thu, 6 Jul 2023 12:54:39 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 6 Jul 2023 12:54:37 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6288546BEE for ; Thu, 6 Jul 2023 12:54:37 +0200 (CEST) From: Markus Frank To: pve-devel@lists.proxmox.com Date: Thu, 6 Jul 2023 12:54:18 +0200 Message-Id: <20230706105421.54949-9-m.frank@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230706105421.54949-1-m.frank@proxmox.com> References: <20230706105421.54949-1-m.frank@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.104 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL_4 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH manager v6 2/5] ui: add edit window for dir mappings X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jul 2023 10:55:05 -0000 Signed-off-by: Markus Frank --- www/manager6/Makefile | 1 + www/manager6/window/DIRMapEdit.js | 186 ++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 www/manager6/window/DIRMapEdit.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 5b455c80..6c7b2211 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -128,6 +128,7 @@ JSSRC= \ window/TreeSettingsEdit.js \ window/PCIMapEdit.js \ window/USBMapEdit.js \ + window/DIRMapEdit.js \ ha/Fencing.js \ ha/GroupEdit.js \ ha/GroupSelector.js \ diff --git a/www/manager6/window/DIRMapEdit.js b/www/manager6/window/DIRMapEdit.js new file mode 100644 index 00000000..7d810dcf --- /dev/null +++ b/www/manager6/window/DIRMapEdit.js @@ -0,0 +1,186 @@ +Ext.define('PVE.window.DIRMapEditWindow', { + extend: 'Proxmox.window.Edit', + + mixins: ['Proxmox.Mixin.CBind'], + + cbindData: function(initialConfig) { + let me = this; + me.isCreate = !me.name; + me.method = me.isCreate ? 'POST' : 'PUT'; + me.hideMapping = !!me.entryOnly; + me.hideComment = me.name && !me.entryOnly; + me.hideNodeSelector = me.nodename || me.entryOnly; + me.hideNode = !me.nodename || !me.hideNodeSelector; + return { + name: me.name, + nodename: me.nodename, + }; + }, + + submitUrl: function(_url, data) { + let me = this; + let name = me.isCreate ? '' : me.name; + return `/cluster/mapping/dir/${name}`; + }, + + title: gettext('Add DIR mapping'), + + onlineHelp: 'resource_mapping', + + method: 'POST', + + controller: { + xclass: 'Ext.app.ViewController', + + onGetValues: function(values) { + let me = this; + let view = me.getView(); + values.node ??= view.nodename; + + let name = values.name; + let description = values.description; + delete values.description; + delete values.name; + + let map = []; + if (me.originalMap) { + map = PVE.Parser.filterPropertyStringList(me.originalMap, (e) => e.node !== values.node); + } + if (values.path) { + map.push(PVE.Parser.printPropertyString(values)); + } + + values = { map }; + if (description) { + values.description = description; + } + + if (view.isCreate) { + values.id = name; + } + return values; + }, + + onSetValues: function(values) { + let me = this; + let view = me.getView(); + me.originalMap = [...values.map]; + let configuredNodes = []; + PVE.Parser.filterPropertyStringList(values.map, (e) => { + configuredNodes.push(e.node); + if (e.node === view.nodename) { + values = e; + } + return false; + }); + + me.lookup('nodeselector').disallowedNodes = configuredNodes; + if (values.path) { + values.usb = 'path'; + } + + return values; + }, + + init: function(view) { + let me = this; + + if (!view.nodename) { + //throw "no nodename given"; + } + }, + }, + + items: [ + { + xtype: 'inputpanel', + onGetValues: function(values) { + return this.up('window').getController().onGetValues(values); + }, + + onSetValues: function(values) { + return this.up('window').getController().onSetValues(values); + }, + + column1: [ + { + xtype: 'pmxDisplayEditField', + fieldLabel: gettext('Name'), + cbind: { + editable: '{!name}', + value: '{name}', + submitValue: '{isCreate}', + }, + name: 'name', + allowBlank: false, + }, + { + xtype: 'pveNodeSelector', + reference: 'nodeselector', + fieldLabel: gettext('Node'), + name: 'node', + cbind: { + disabled: '{hideNodeSelector}', + hidden: '{hideNodeSelector}', + }, + allowBlank: false, + }, + ], + + column2: [ + { + xtype: 'fieldcontainer', + defaultType: 'radiofield', + layout: 'fit', + cbind: { + disabled: '{hideMapping}', + hidden: '{hideMapping}', + }, + items: [ + { + xtype: 'textfield', + name: 'path', + reference: 'path', + value: '', + emptyText: gettext('/some/path'), + cbind: { + nodename: '{nodename}', + disabled: '{hideMapping}', + }, + allowBlank: false, + fieldLabel: gettext('Path'), + }, + { + xtype: 'proxmoxcheckbox', + name: 'xattr', + fieldLabel: gettext('xattr'), + }, + { + xtype: 'proxmoxcheckbox', + name: 'acl', + fieldLabel: gettext('acl'), + }, + { + xtype: 'proxmoxcheckbox', + name: 'submounts', + fieldLabel: gettext('submounts'), + }, + ], + } + ], + + columnB: [ + { + xtype: 'proxmoxtextfield', + fieldLabel: gettext('Comment'), + submitValue: true, + name: 'description', + cbind: { + disabled: '{hideComment}', + hidden: '{hideComment}', + }, + }, + ], + }, + ], +}); -- 2.39.2