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 0CE0A9372 for ; Thu, 31 Mar 2022 12:47:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 782A71A1F0 for ; Thu, 31 Mar 2022 12:47:33 +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 id 666691A1E7 for ; Thu, 31 Mar 2022 12:47:31 +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 3FA244298E for ; Thu, 31 Mar 2022 12:47:31 +0200 (CEST) From: Matthias Heiserer To: pve-devel@lists.proxmox.com Date: Thu, 31 Mar 2022 12:47:19 +0200 Message-Id: <20220331104720.4005157-4-m.heiserer@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220331104720.4005157-1-m.heiserer@proxmox.com> References: <20220331104720.4005157-1-m.heiserer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.006 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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. [me.store] Subject: [pve-devel] [PATCH v3 manager 3/4] ui: delete BackupView and replace it with the new Tree BackupView 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, 31 Mar 2022 10:47:34 -0000 Signed-off-by: Matthias Heiserer --- www/manager6/Makefile | 1 - www/manager6/grid/BackupView.js | 388 -------------------------------- www/manager6/lxc/Config.js | 2 +- www/manager6/qemu/Config.js | 2 +- 4 files changed, 2 insertions(+), 391 deletions(-) delete mode 100644 www/manager6/grid/BackupView.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index e6e01bd1..0575f550 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -73,7 +73,6 @@ JSSRC= \ form/VNCKeyboardSelector.js \ form/ViewSelector.js \ form/iScsiProviderSelector.js \ - grid/BackupView.js \ grid/FirewallAliases.js \ grid/FirewallOptions.js \ grid/FirewallRules.js \ diff --git a/www/manager6/grid/BackupView.js b/www/manager6/grid/BackupView.js deleted file mode 100644 index 7f7e1b62..00000000 --- a/www/manager6/grid/BackupView.js +++ /dev/null @@ -1,388 +0,0 @@ -Ext.define('PVE.grid.BackupView', { - extend: 'Ext.grid.GridPanel', - - alias: ['widget.pveBackupView'], - - onlineHelp: 'chapter_vzdump', - - stateful: true, - stateId: 'grid-guest-backup', - - initComponent: function() { - var me = this; - - var nodename = me.pveSelNode.data.node; - if (!nodename) { - throw "no node name specified"; - } - - var vmid = me.pveSelNode.data.vmid; - if (!vmid) { - throw "no VM ID specified"; - } - - var vmtype = me.pveSelNode.data.type; - if (!vmtype) { - throw "no VM type specified"; - } - - var vmtypeFilter; - if (vmtype === 'lxc' || vmtype === 'openvz') { - vmtypeFilter = function(item) { - return PVE.Utils.volume_is_lxc_backup(item.data.volid, item.data.format); - }; - } else if (vmtype === 'qemu') { - vmtypeFilter = function(item) { - return PVE.Utils.volume_is_qemu_backup(item.data.volid, item.data.format); - }; - } else { - throw "unsupported VM type '" + vmtype + "'"; - } - - var searchFilter = { - property: 'volid', - value: '', - anyMatch: true, - caseSensitive: false, - }; - - var vmidFilter = { - property: 'vmid', - value: vmid, - exactMatch: true, - }; - - me.store = Ext.create('Ext.data.Store', { - model: 'pve-storage-content', - sorters: [ - { - property: 'vmid', - direction: 'ASC', - }, - { - property: 'vdate', - direction: 'DESC', - }, - ], - filters: [ - vmtypeFilter, - searchFilter, - vmidFilter, - ], - }); - - let updateFilter = function() { - me.store.filter([ - vmtypeFilter, - searchFilter, - vmidFilter, - ]); - }; - - var reload = Ext.Function.createBuffered(function() { - if (me.store) { - me.store.load(); - } - }, 100); - - let isPBS = false; - var setStorage = function(storage) { - var url = '/api2/json/nodes/' + nodename + '/storage/' + storage + '/content'; - url += '?content=backup'; - - me.store.setProxy({ - type: 'proxmox', - url: url, - }); - - Proxmox.Utils.monStoreErrors(me.view, me.store, true); - - reload(); - }; - - let file_restore_btn; - - var storagesel = Ext.create('PVE.form.StorageSelector', { - nodename: nodename, - fieldLabel: gettext('Storage'), - labelAlign: 'right', - storageContent: 'backup', - allowBlank: false, - listeners: { - change: function(f, value) { - let storage = f.getStore().findRecord('storage', value, 0, false, true, true); - if (storage) { - isPBS = storage.data.type === 'pbs'; - me.getColumns().forEach((column) => { - let id = column.dataIndex; - if (id === 'verification' || id === 'encrypted') { - column.setHidden(!isPBS); - } - }); - } else { - isPBS = false; - } - setStorage(value); - if (file_restore_btn) { - file_restore_btn.setHidden(!isPBS); - } - }, - }, - }); - - var storagefilter = Ext.create('Ext.form.field.Text', { - fieldLabel: gettext('Search'), - labelWidth: 50, - labelAlign: 'right', - enableKeyEvents: true, - value: searchFilter.value, - listeners: { - buffer: 500, - keyup: function(field) { - me.store.clearFilter(true); - searchFilter.value = field.getValue(); - updateFilter(); - }, - }, - }); - - var vmidfilterCB = Ext.create('Ext.form.field.Checkbox', { - boxLabel: gettext('Filter VMID'), - value: '1', - listeners: { - change: function(cb, value) { - vmidFilter.value = value ? vmid : ''; - vmidFilter.exactMatch = !!value; - updateFilter(); - }, - }, - }); - - var sm = Ext.create('Ext.selection.RowModel', {}); - - var backup_btn = Ext.create('Ext.button.Button', { - text: gettext('Backup now'), - handler: function() { - var win = Ext.create('PVE.window.Backup', { - nodename: nodename, - vmid: vmid, - vmtype: vmtype, - storage: storagesel.getValue(), - listeners: { - close: function() { - reload(); - }, - }, - }); - win.show(); - }, - }); - - var restore_btn = Ext.create('Proxmox.button.Button', { - text: gettext('Restore'), - disabled: true, - selModel: sm, - enableFn: function(rec) { - return !!rec; - }, - handler: function(b, e, rec) { - let win = Ext.create('PVE.window.Restore', { - nodename: nodename, - vmid: vmid, - volid: rec.data.volid, - volidText: PVE.Utils.render_storage_content(rec.data.volid, {}, rec), - vmtype: vmtype, - isPBS: isPBS, - }); - win.show(); - win.on('destroy', reload); - }, - }); - - let delete_btn = Ext.create('Proxmox.button.StdRemoveButton', { - selModel: sm, - dangerous: true, - delay: 5, - enableFn: rec => !rec?.data?.protected, - confirmMsg: ({ data }) => { - let msg = Ext.String.format( - gettext('Are you sure you want to remove entry {0}'), `'${data.volid}'`); - return msg + " " + gettext('This will permanently erase all data.'); - }, - getUrl: ({ data }) => `/nodes/${nodename}/storage/${storagesel.getValue()}/content/${data.volid}`, - callback: () => reload(), - }); - - let config_btn = Ext.create('Proxmox.button.Button', { - text: gettext('Show Configuration'), - disabled: true, - selModel: sm, - enableFn: rec => !!rec, - handler: function(b, e, rec) { - let storage = storagesel.getValue(); - if (!storage) { - return; - } - Ext.create('PVE.window.BackupConfig', { - volume: rec.data.volid, - pveSelNode: me.pveSelNode, - autoShow: true, - }); - }, - }); - - // declared above so that the storage selector can change this buttons hidden state - file_restore_btn = Ext.create('Proxmox.button.Button', { - text: gettext('File Restore'), - disabled: true, - selModel: sm, - enableFn: rec => !!rec && isPBS, - hidden: !isPBS, - handler: function(b, e, rec) { - let storage = storagesel.getValue(); - let isVMArchive = PVE.Utils.volume_is_qemu_backup(rec.data.volid, rec.data.format); - Ext.create('Proxmox.window.FileBrowser', { - title: gettext('File Restore') + " - " + rec.data.text, - listURL: `/api2/json/nodes/localhost/storage/${storage}/file-restore/list`, - downloadURL: `/api2/json/nodes/localhost/storage/${storage}/file-restore/download`, - extraParams: { - volume: rec.data.volid, - }, - archive: isVMArchive ? 'all' : undefined, - autoShow: true, - }); - }, - }); - - Ext.apply(me, { - selModel: sm, - tbar: { - overflowHandler: 'scroller', - items: [ - backup_btn, - '-', - restore_btn, - file_restore_btn, - config_btn, - { - xtype: 'proxmoxButton', - text: gettext('Edit Notes'), - disabled: true, - handler: function() { - let volid = sm.getSelection()[0].data.volid; - var storage = storagesel.getValue(); - Ext.create('Proxmox.window.Edit', { - autoLoad: true, - width: 600, - height: 400, - resizable: true, - title: gettext('Notes'), - url: `/api2/extjs/nodes/${nodename}/storage/${storage}/content/${volid}`, - layout: 'fit', - items: [ - { - xtype: 'textarea', - layout: 'fit', - name: 'notes', - height: '100%', - }, - ], - listeners: { - destroy: () => reload(), - }, - }).show(); - }, - }, - { - xtype: 'proxmoxButton', - text: gettext('Change Protection'), - disabled: true, - handler: function(button, event, record) { - let volid = record.data.volid, storage = storagesel.getValue(); - let url = `/api2/extjs/nodes/${nodename}/storage/${storage}/content/${volid}`; - let newProtection = record.data.protected ? 0 : 1; - Proxmox.Utils.API2Request({ - url: url, - method: 'PUT', - waitMsgTarget: me, - params: { - 'protected': newProtection, - }, - failure: (response) => Ext.Msg.alert('Error', response.htmlStatus), - success: (response) => { - reload(); - // propagate to remove button, fake for event as reload is to slow - record.data.protected = newProtection; // TODO: check if writing is OK! - sm.fireEvent('selectionchange', sm, [record]); - }, - }); - }, - }, - '-', - delete_btn, - '->', - storagesel, - '-', - vmidfilterCB, - storagefilter, - ], - }, - columns: [ - { - header: gettext('Name'), - flex: 2, - sortable: true, - renderer: PVE.Utils.render_storage_content, - dataIndex: 'volid', - }, - { - header: gettext('Notes'), - dataIndex: 'notes', - flex: 1, - renderer: Ext.htmlEncode, - }, - { - header: ``, - tooltip: gettext('Protected'), - width: 30, - renderer: v => v ? `` : '', - sorter: (a, b) => (b.data.protected || 0) - (a.data.protected || 0), - dataIndex: 'protected', - }, - { - header: gettext('Date'), - width: 150, - dataIndex: 'vdate', - }, - { - header: gettext('Format'), - width: 100, - dataIndex: 'format', - }, - { - header: gettext('Size'), - width: 100, - renderer: Proxmox.Utils.format_size, - dataIndex: 'size', - }, - { - header: gettext('VMID'), - dataIndex: 'vmid', - hidden: true, - }, - { - header: gettext('Encrypted'), - dataIndex: 'encrypted', - renderer: PVE.Utils.render_backup_encryption, - }, - { - header: gettext('Verify State'), - dataIndex: 'verification', - renderer: PVE.Utils.render_backup_verification, - }, - ], - }); - - me.callParent(); - }, -}); diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js index 89b59c9b..242780c8 100644 --- a/www/manager6/lxc/Config.js +++ b/www/manager6/lxc/Config.js @@ -256,7 +256,7 @@ Ext.define('PVE.lxc.Config', { me.items.push({ title: gettext('Backup'), iconCls: 'fa fa-floppy-o', - xtype: 'pveBackupView', + xtype: 'pveStorageBackupView', itemId: 'backup', }, { diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js index 9fe933df..3ed2427a 100644 --- a/www/manager6/qemu/Config.js +++ b/www/manager6/qemu/Config.js @@ -291,7 +291,7 @@ Ext.define('PVE.qemu.Config', { me.items.push({ title: gettext('Backup'), iconCls: 'fa fa-floppy-o', - xtype: 'pveBackupView', + xtype: 'pveStorageBackupView', itemId: 'backup', }, { -- 2.30.2