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 7542D7A8E6 for ; Tue, 5 Jul 2022 15:09:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B1F272F55E for ; Tue, 5 Jul 2022 15:08:58 +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, 5 Jul 2022 15:08: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 36E8743CB3 for ; Tue, 5 Jul 2022 15:08:50 +0200 (CEST) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Tue, 5 Jul 2022 13:08:23 +0000 Message-Id: <20220705130834.14285-18-h.laimer@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220705130834.14285-1-h.laimer@proxmox.com> References: <20220705130834.14285-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.009 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 PROLO_LEO1 0.1 Meta Catches all Leo drug variations so far 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. [data.store, data.name, params.store] Subject: [pbs-devel] [PATCH proxmox-backup 15/26] ui: config: add RemovableDeviceView X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2022 13:09:17 -0000 Signed-off-by: Hannes Laimer --- www/Makefile | 1 + www/config/RemovableDeviceView.js | 211 ++++++++++++++++++++++++++++++ www/datastore/DataStoreList.js | 5 + www/datastore/Panel.js | 9 ++ 4 files changed, 226 insertions(+) create mode 100644 www/config/RemovableDeviceView.js diff --git a/www/Makefile b/www/Makefile index 4aa2b026..4d29f1b4 100644 --- a/www/Makefile +++ b/www/Makefile @@ -55,6 +55,7 @@ JSSRC= \ config/UserView.js \ config/TokenView.js \ config/RemoteView.js \ + config/RemovableDeviceView.js \ config/TrafficControlView.js \ config/ACLView.js \ config/SyncView.js \ diff --git a/www/config/RemovableDeviceView.js b/www/config/RemovableDeviceView.js new file mode 100644 index 00000000..7c0894b5 --- /dev/null +++ b/www/config/RemovableDeviceView.js @@ -0,0 +1,211 @@ +Ext.define('pbs-removable-device-status', { + extend: 'Ext.data.Model', + fields: ['name', 'uuid', 'store', 'mounted', 'initialized'], + idProperty: 'name', + proxy: { + type: 'proxmox', + url: '/api2/json/admin/removable-device', + }, +}); + +Ext.define('PBS.config.RemovableDeviceView', { + extend: 'Ext.grid.GridPanel', + alias: 'widget.pbsRemovableDeviceView', + + stateful: true, + stateId: 'grid-devices', + + title: gettext('Removable Devices'), + + tools: [PBS.Utils.get_help_tool("backup-remote")], + + controller: { + xclass: 'Ext.app.ViewController', + + addRemovableDevice: function() { + let me = this; + let view = me.getView(); + Ext.create('PBS.window.RemovableDeviceEdit', { + datastore: view.datastore, + listeners: { + destroy: function() { + me.reload(); + }, + }, + }).show(); + }, + + editRemovableDevice: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (selection.length < 1) return; + + Ext.create('PBS.window.RemovableDeviceEdit', { + name: selection[0].data.name, + datastore: view.datastore, + listeners: { + destroy: function() { + me.reload(); + }, + }, + }).show(); + }, + + mountDevice: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (!selection || selection.length < 1) return; + let rec = selection[0]; + view.setSelection(null); + Proxmox.Utils.API2Request({ + url: `/api2/extjs/admin/removable-device/${rec.data.name}/mount`, + waitMsgTarget: view, + method: 'POST', + failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + success: function(response, options) { + Ext.create('Proxmox.window.TaskProgress', { + upid: response.result.data, + taskDone: function() { + me.reload(); + }, + autoShow: true, + }); + }, + }); + }, + + unmountDevice: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (!selection || selection.length < 1) return; + let rec = selection[0]; + view.setSelection(null); + Proxmox.Utils.API2Request({ + url: `/api2/extjs/admin/datastore/${rec.data.store}/unmount-device`, + waitMsgTarget: view, + method: 'POST', + failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + success: function(response, options) { + Ext.create('Proxmox.window.TaskProgress', { + upid: response.result.data, + taskDone: function() { + me.reload(); + }, + autoShow: true, + }); + }, + }); + }, + + startStore: function() { this.getView().getStore().rstore.startUpdate(); }, + stopStore: function() { this.getView().getStore().rstore.stopUpdate(); }, + reload: function() { this.getView().getStore().rstore.load(); }, + + init: function(view) { + let params = {}; + if (view.datastore !== undefined) { + params.store = view.datastore; + } + view.getStore().rstore.getProxy().setExtraParams(params); + Proxmox.Utils.monStoreErrors(view, view.getStore().rstore); + }, + }, + + listeners: { + activate: 'reload', + itemdblclick: 'editRemovableDevice', + }, + + store: { + type: 'diff', + autoDestroy: true, + autoDestroyRstore: true, + sorters: 'name', + rstore: { + type: 'update', + storeid: 'pbs-removable-device-status', + model: 'pbs-removable-device-status', + autoStart: true, + interval: 5000, + }, + }, + + tbar: [ + { + xtype: 'proxmoxButton', + text: gettext('Add'), + handler: 'addRemovableDevice', + selModel: false, + }, + { + xtype: 'proxmoxButton', + text: gettext('Edit'), + handler: 'editRemovableDevice', + disabled: true, + }, + { + xtype: 'proxmoxStdRemoveButton', + baseurl: '/config/removable-device', + confirmMsg: gettext('Remove device?'), + callback: 'reload', + }, + '-', + { + xtype: 'proxmoxButton', + text: gettext('Mount'), + handler: 'mountDevice', + enableFn: (rec) => !rec.data.mounted, + disabled: true, + }, + { + xtype: 'proxmoxButton', + text: gettext('Unmount'), + handler: 'unmountDevice', + enableFn: (rec) => !!rec.data.mounted, + disabled: true, + }, + ], + + viewConfig: { + trackOver: false, + }, + + columns: [ + { + header: gettext('Name'), + width: 200, + sortable: true, + renderer: Ext.String.htmlEncode, + dataIndex: 'name', + }, + { + header: gettext('Datastore'), + width: 200, + sortable: true, + dataIndex: 'store', + }, + { + header: gettext('UUID'), + width: 200, + sortable: true, + dataIndex: 'uuid', + }, + { + header: gettext('Initialized'), + sortable: false, + renderer: Proxmox.Utils.format_boolean, + dataIndex: 'initialized', + width: 60, + }, + { + header: gettext('Mounted'), + sortable: false, + renderer: Proxmox.Utils.format_boolean, + dataIndex: 'mounted', + width: 60, + }, + ], +}); diff --git a/www/datastore/DataStoreList.js b/www/datastore/DataStoreList.js index b496bcbc..20362d6e 100644 --- a/www/datastore/DataStoreList.js +++ b/www/datastore/DataStoreList.js @@ -242,6 +242,11 @@ Ext.define('PBS.datastore.DataStores', { itemId: 'prunejobs', xtype: 'pbsPruneJobView', }, + { + iconCls: 'fa fa-hdd-o', + itemId: 'removabledevices', + xtype: 'pbsRemovableDeviceView', + }, { iconCls: 'fa fa-check-circle', itemId: 'verifyjobs', diff --git a/www/datastore/Panel.js b/www/datastore/Panel.js index fd1b4611..3c32badd 100644 --- a/www/datastore/Panel.js +++ b/www/datastore/Panel.js @@ -82,6 +82,15 @@ Ext.define('PBS.DataStorePanel', { datastore: '{datastore}', }, }, + { + xtype: 'pbsRemovableDeviceView', + itemId: 'devices', + title: gettext('Removable devices'), + iconCls: 'fa fa-hdd-o', + cbind: { + datastore: '{datastore}', + }, + }, { xtype: 'pbsDatastoreOptionView', itemId: 'options', -- 2.30.2