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 0A782987DB for ; Tue, 25 Apr 2023 12:21:55 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E2D8A3A663 for ; Tue, 25 Apr 2023 12:21:54 +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 ; Tue, 25 Apr 2023 12:21:53 +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 65197453AD for ; Tue, 25 Apr 2023 12:21:53 +0200 (CEST) From: Markus Frank To: pve-devel@lists.proxmox.com Date: Tue, 25 Apr 2023 12:21:34 +0200 Message-Id: <20230425102136.85334-5-m.frank@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230425102136.85334-1-m.frank@proxmox.com> References: <20230425102136.85334-1-m.frank@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.055 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 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 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [caps.map] Subject: [pve-devel] [PATCH manager v4 4/6] added Shared Files tab in Node Settings 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: Tue, 25 Apr 2023 10:21:55 -0000 to add/remove/show directories that are available for shared filesystems. and added /node/dir path to PermPathStore. Signed-off-by: Markus Frank --- www/manager6/Makefile | 1 + www/manager6/data/PermPathStore.js | 3 + www/manager6/node/Config.js | 12 ++ www/manager6/node/SharedFiles.js | 177 +++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 www/manager6/node/SharedFiles.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 2b577c8e..bce14fdb 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -199,6 +199,7 @@ JSSRC= \ node/CmdMenu.js \ node/Config.js \ node/Directory.js \ + node/SharedFiles.js \ node/LVM.js \ node/LVMThin.js \ node/StatusView.js \ diff --git a/www/manager6/data/PermPathStore.js b/www/manager6/data/PermPathStore.js index cf702c03..d83f9e12 100644 --- a/www/manager6/data/PermPathStore.js +++ b/www/manager6/data/PermPathStore.js @@ -13,6 +13,7 @@ Ext.define('PVE.data.PermPathStore', { { 'value': '/sdn/zones' }, { 'value': '/storage' }, { 'value': '/vms' }, + { 'value': '/map/dirs' }, ], constructor: function(config) { @@ -39,6 +40,8 @@ Ext.define('PVE.data.PermPathStore', { break; case 'pool': path = '/pool/' + record.get('pool'); break; + case 'dirs': path = '/map/dirs/' + record.get('dirs'); + break; } if (path !== undefined && !donePaths[path]) { me.add({ value: path }); diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index 0cc23fb4..b35d5abc 100644 --- a/www/manager6/node/Config.js +++ b/www/manager6/node/Config.js @@ -410,6 +410,18 @@ Ext.define('PVE.node.Config', { }); } + if (caps.map['Map.Modify']) { + me.items.push( + { + xtype: 'pveSharedFilesList', + title: gettext('Shared Files'), + iconCls: 'fa fa-folder', + onlineHelp: 'qm_sharedfiles', + itemId: 'sharedFiles', + }, + ); + } + me.items.push( { title: gettext('Task History'), diff --git a/www/manager6/node/SharedFiles.js b/www/manager6/node/SharedFiles.js new file mode 100644 index 00000000..4152de1b --- /dev/null +++ b/www/manager6/node/SharedFiles.js @@ -0,0 +1,177 @@ +Ext.define('PVE.node.CreateSharedFiles', { + extend: 'Proxmox.window.Edit', + xtype: 'pveCreateSharedFiles', + + subject: "Shared Directory", + + onlineHelp: 'qm_sharedfiles', + + initComponent: function() { + var me = this; + + if (!me.nodename) { + throw "no node name specified"; + } + + me.isCreate = true; + + Ext.applyIf(me, { + url: "/nodes/" + me.nodename + "/dirs", + method: 'POST', + items: [ + { + xtype: 'proxmoxtextfield', + name: 'dirid', + fieldLabel: gettext('Directory ID'), + allowBlank: false, + }, + { + xtype: 'proxmoxtextfield', + name: 'path', + fieldLabel: gettext('Directory Path'), + allowBlank: false, + }, + ], + }); + + me.callParent(); + }, +}); + +Ext.define('PVE.node.SharedFilesList', { + extend: 'Ext.grid.Panel', + xtype: 'pveSharedFilesList', + + viewModel: { + data: { + path: '', + }, + formulas: { + dirid: (get) => get('dirid'), + }, + }, + + controller: { + xclass: 'Ext.app.ViewController', + + removeDirectory: function() { + let me = this; + let vm = me.getViewModel(); + let view = me.getView(); + + const dirid = vm.get('dirid'); + + if (!view.nodename) { + throw "no node name specified"; + } + + if (!dirid) { + throw "no directory name specified"; + } + Ext.create('Proxmox.window.SafeDestroy', { + url: `/nodes/${view.nodename}/dirs`, + item: { id: dirid }, + params: { dirid: dirid }, + taskName: 'Remove Directory from Shared Files', + autoShow: true, + listeners: { + destroy: () => view.reload(), + }, + }).show(); + }, + }, + + stateful: true, + stateId: 'grid-node-directory', + columns: [ + { + text: gettext('Directory ID'), + dataIndex: 'dirid', + flex: 1, + }, + { + text: gettext('Directory Path'), + dataIndex: 'path', + flex: 1, + }, + ], + + rootVisible: false, + useArrows: true, + + tbar: [ + { + text: gettext('Reload'), + iconCls: 'fa fa-refresh', + handler: function() { + this.up('panel').reload(); + }, + }, + { + text: `${gettext('Create')}: ${gettext('Directory')}`, + handler: function() { + let view = this.up('panel'); + Ext.create('PVE.node.CreateSharedFiles', { + nodename: view.nodename, + listeners: { + destroy: () => view.reload(), + }, + autoShow: true, + }); + }, + }, + { + text: gettext('Remove'), + itemId: 'removeDir', + handler: 'removeDirectory', + disabled: true, + bind: { + disabled: '{!dirid}', + }, + }, + ], + + reload: function() { + let me = this; + me.store.load(); + me.store.sort(); + }, + + listeners: { + activate: function() { + this.reload(); + }, + selectionchange: function(model, selected) { + let me = this; + let vm = me.getViewModel(); + + vm.set('dirid', selected[0]?.data.dirid || ''); + }, + }, + + initComponent: function() { + let me = this; + + me.nodename = me.pveSelNode.data.node; + if (!me.nodename) { + throw "no node name specified"; + } + + Ext.apply(me, { + store: { + fields: ['dirid', 'path'], + proxy: { + type: 'proxmox', + url: `/api2/json/nodes/${me.nodename}/dirs`, + }, + sorters: 'dirid', + }, + }); + + me.callParent(); + + Proxmox.Utils.monStoreErrors(me, me.getStore(), true); + me.reload(); + }, +}); + -- 2.30.2