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 D2BFC692D9 for ; Tue, 23 Feb 2021 11:58:33 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CA0CF1CBFD for ; Tue, 23 Feb 2021 11:58:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 19CBE1CBF4 for ; Tue, 23 Feb 2021 11:58:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DAC7843EA6 for ; Tue, 23 Feb 2021 11:58:02 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 23 Feb 2021 11:58:01 +0100 Message-Id: <20210223105801.13615-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210223105801.13615-1-d.csapak@proxmox.com> References: <20210223105801.13615-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.208 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [rec.data, values.id] Subject: [pbs-devel] [PATCH proxmox-backup 2/2] ui: tape/BackupJobs: add CRUD functions 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, 23 Feb 2021 10:58:33 -0000 similar to the other jobs grids (add/edit/remove etc.) Signed-off-by: Dominik Csapak --- www/Makefile | 1 + www/tape/BackupJobs.js | 106 ++++++++++++++++++++++++++++++- www/tape/window/TapeBackupJob.js | 82 ++++++++++++++++++++++++ 3 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 www/tape/window/TapeBackupJob.js diff --git a/www/Makefile b/www/Makefile index 9f9b46aa..11858f98 100644 --- a/www/Makefile +++ b/www/Makefile @@ -23,6 +23,7 @@ TAPE_UI_FILES= \ tape/window/LabelMedia.js \ tape/window/PoolEdit.js \ tape/window/TapeBackup.js \ + tape/window/TapeBackupJob.js \ tape/window/TapeRestore.js \ tape/BackupOverview.js \ tape/ChangerConfig.js \ diff --git a/www/tape/BackupJobs.js b/www/tape/BackupJobs.js index 7c23864f..2532fb38 100644 --- a/www/tape/BackupJobs.js +++ b/www/tape/BackupJobs.js @@ -34,6 +34,75 @@ Ext.define('PBS.config.TapeBackupJobView', { controller: { xclass: 'Ext.app.ViewController', + addJob: function() { + let me = this; + Ext.create('PBS.TapeManagement.BackupJobEdit', { + autoShow: true, + listeners: { + destroy: function() { + me.reload(); + }, + }, + }).show(); + }, + + editJob: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (!selection || selection.length < 1) { + return; + } + + Ext.create('PBS.TapeManagement.BackupJobEdit', { + id: selection[0].data.id, + autoShow: true, + listeners: { + destroy: function() { + me.reload(); + }, + }, + }).show(); + }, + + openTaskLog: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (selection.length < 1) return; + + let upid = selection[0].data['last-run-upid']; + if (!upid) return; + + Ext.create('Proxmox.window.TaskViewer', { + upid, + }).show(); + }, + + runJob: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (selection.length < 1) return; + + let id = selection[0].data.id; + Proxmox.Utils.API2Request({ + method: 'POST', + url: `/tape/backup/${id}`, + success: function(response, opt) { + Ext.create('Proxmox.window.TaskViewer', { + upid: response.result.data, + taskDone: function(success) { + me.reload(); + }, + }).show(); + }, + failure: function(response, opt) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + }); + }, + startStore: function() { this.getView().getStore().rstore.startUpdate(); }, stopStore: function() { this.getView().getStore().rstore.stopUpdate(); }, @@ -48,7 +117,7 @@ Ext.define('PBS.config.TapeBackupJobView', { listeners: { activate: 'startStore', deactivate: 'stopStore', - //itemdblclick: 'editSyncJob', + itemdblclick: 'editJob', }, store: { @@ -68,6 +137,41 @@ Ext.define('PBS.config.TapeBackupJobView', { trackOver: false, }, + tbar: [ + { + xtype: 'proxmoxButton', + text: gettext('Add'), + selModel: false, + handler: 'addJob', + }, + { + xtype: 'proxmoxButton', + text: gettext('Edit'), + handler: 'editJob', + disabled: true, + }, + { + xtype: 'proxmoxStdRemoveButton', + baseurl: '/config/tape-backup-job/', + confirmMsg: gettext('Remove entry?'), + callback: 'reload', + }, + '-', + { + xtype: 'proxmoxButton', + text: gettext('Show Log'), + handler: 'openTaskLog', + enableFn: (rec) => !!rec.data['last-run-upid'], + disabled: true, + }, + { + xtype: 'proxmoxButton', + text: gettext('Run now'), + handler: 'runJob', + disabled: true, + }, + ], + columns: [ { header: gettext('Job ID'), diff --git a/www/tape/window/TapeBackupJob.js b/www/tape/window/TapeBackupJob.js new file mode 100644 index 00000000..9902a454 --- /dev/null +++ b/www/tape/window/TapeBackupJob.js @@ -0,0 +1,82 @@ +Ext.define('PBS.TapeManagement.BackupJobEdit', { + extend: 'Proxmox.window.Edit', + alias: 'widget.pbsTapeBackupJobEdit', + mixins: ['Proxmox.Mixin.CBind'], + + userid: undefined, + + isAdd: true, + + subject: gettext('Tape Backup Job'), + + fieldDefaults: { labelWidth: 120 }, + + cbindData: function(initialConfig) { + let me = this; + + let baseurl = '/api2/extjs/config/tape-backup-job'; + let id = initialConfig.id; + + me.isCreate = !id; + me.url = id ? `${baseurl}/${id}` : baseurl; + me.method = id ? 'PUT' : 'POST'; + me.autoLoad = !!id; + me.scheduleValue = id ? null : 'daily'; + me.authid = id ? null : Proxmox.UserName; + me.editDatastore = me.datastore === undefined && me.isCreate; + return { }; + }, + + items: { + xtype: 'inputpanel', + onGetValues: function(values) { + let me = this; + + if (!values.id && me.up('pbsTapeBackupJobEdit').isCreate) { + values.id = 's-' + Ext.data.identifier.Uuid.Global.generate().slice(0, 13); + } + return values; + }, + column1: [ + { + xtype: 'pbsDataStoreSelector', + fieldLabel: gettext('Local Datastore'), + name: 'store', + }, + { + xtype: 'pbsMediaPoolSelector', + fieldLabel: gettext('Media Pool'), + name: 'pool', + }, + { + xtype: 'pbsDriveSelector', + fieldLabel: gettext('Drive'), + name: 'drive', + }, + ], + + column2: [ + { + fieldLabel: gettext('Schedule'), + xtype: 'pbsCalendarEvent', + name: 'schedule', + emptyText: gettext('none (disabled)'), + cbind: { + deleteEmpty: '{!isCreate}', + value: '{scheduleValue}', + }, + }, + ], + + columnB: [ + { + fieldLabel: gettext('Comment'), + xtype: 'proxmoxtextfield', + name: 'comment', + cbind: { + deleteEmpty: '{!isCreate}', + }, + }, + ], + }, +}); -- 2.20.1