From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 B86D368F90
 for <pbs-devel@lists.proxmox.com>; Mon,  1 Mar 2021 12:22:46 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id B682C1E995
 for <pbs-devel@lists.proxmox.com>; Mon,  1 Mar 2021 12:22:46 +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 F35941E988
 for <pbs-devel@lists.proxmox.com>; Mon,  1 Mar 2021 12:22:44 +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 B966C45809
 for <pbs-devel@lists.proxmox.com>; Mon,  1 Mar 2021 12:22:44 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Mon,  1 Mar 2021 12:22:42 +0100
Message-Id: <20210301112243.15842-4-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20210301112243.15842-1-d.csapak@proxmox.com>
References: <20210301112243.15842-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.204 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
Subject: [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape: ChangerStatus:
 remove changerselector combobox
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 01 Mar 2021 11:22:46 -0000

because we now select it directly in the left-hand tree
so we have to adapt the changer to the one set by the router
and not by the drop down field

and remove it from the TapeManagement tabpanel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
NOTE: this patch and the last 2 are very interdependent, but i wanted
to split them as it is easier to review that way. If wanted, they could
be squashed into a single commit

 www/tape/ChangerStatus.js  | 80 +++++++++++++-------------------------
 www/tape/TapeManagement.js |  5 ---
 2 files changed, 26 insertions(+), 59 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 1a7bcf6a..dab34038 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -15,34 +15,14 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
     extend: 'Ext.panel.Panel',
     alias: 'widget.pbsChangerStatus',
 
-    viewModel: {
-	data: {
-	    changer: '',
-	},
-
-	formulas: {
-	    changerSelected: (get) => get('changer') !== '',
-	},
-    },
-
     controller: {
 	xclass: 'Ext.app.ViewController',
 
-	changerChange: function(field, value) {
+	importTape: function(v, rI, cI, button, el, record) {
 	    let me = this;
 	    let view = me.getView();
-	    let vm = me.getViewModel();
-	    vm.set('changer', value);
-	    if (view.rendered) {
-		me.reload();
-	    }
-	},
-
-	importTape: function(view, rI, cI, button, el, record) {
-	    let me = this;
-	    let vm = me.getViewModel();
 	    let from = record.data['entry-id'];
-	    let changer = encodeURIComponent(vm.get('changer'));
+	    let changer = encodeURIComponent(view.changer);
 	    Ext.create('Proxmox.window.Edit', {
 		title: gettext('Import'),
 		isCreate: true,
@@ -71,11 +51,11 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    }).show();
 	},
 
-	slotTransfer: function(view, rI, cI, button, el, record) {
+	slotTransfer: function(v, rI, cI, button, el, record) {
 	    let me = this;
-	    let vm = me.getViewModel();
+	    let view = me.getView();
 	    let from = record.data['entry-id'];
-	    let changer = encodeURIComponent(vm.get('changer'));
+	    let changer = encodeURIComponent(view.changer);
 	    Ext.create('Proxmox.window.Edit', {
 		title: gettext('Transfer'),
 		isCreate: true,
@@ -104,12 +84,12 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    }).show();
 	},
 
-	erase: function(view, rI, cI, button, el, record) {
+	erase: function(v, rI, cI, button, el, record) {
 	    let me = this;
-	    let vm = me.getViewModel();
+	    let view = me.getView();
 	    let label = record.data['label-text'];
 
-	    let changer = vm.get('changer');
+	    let changer = encodeURIComponent(view.changer);
 	    Ext.create('PBS.TapeManagement.EraseWindow', {
 		label,
 		changer,
@@ -121,12 +101,12 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    }).show();
 	},
 
-	load: function(view, rI, cI, button, el, record) {
+	load: function(v, rI, cI, button, el, record) {
 	    let me = this;
-	    let vm = me.getViewModel();
+	    let view = me.getView();
 	    let label = record.data['label-text'];
 
-	    let changer = vm.get('changer');
+	    let changer = encodeURIComponent(view.changer);
 
 	    Ext.create('Proxmox.window.Edit', {
 		isCreate: true,
@@ -163,7 +143,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    });
 	},
 
-	unload: async function(view, rI, cI, button, el, record) {
+	unload: async function(v, rI, cI, button, el, record) {
 	    let me = this;
 	    let drive = record.data.name;
 	    try {
@@ -231,8 +211,8 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 
 	barcodeLabel: function() {
 	    let me = this;
-	    let vm = me.getViewModel();
-	    let changer = vm.get('changer');
+	    let view = me.getView();
+	    let changer = view.changer;
 	    if (changer === '') {
 		return;
 	    }
@@ -268,8 +248,8 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 
 	inventory: function() {
 	    let me = this;
-	    let vm = me.getViewModel();
-	    let changer = vm.get('changer');
+	    let view = me.getView();
+	    let changer = view.changer;
 	    if (changer === '') {
 		return;
 	    }
@@ -326,8 +306,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	reload_full: async function(use_cache) {
 	    let me = this;
 	    let view = me.getView();
-	    let vm = me.getViewModel();
-	    let changer = vm.get('changer');
+	    let changer = view.changer;
 	    if (changer === '') {
 		return;
 	    }
@@ -483,6 +462,15 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		},
 	    },
 	},
+
+	init: function(view) {
+	    let me = this;
+	    if (!view.changer) {
+		throw "no changer given";
+	    }
+
+	    view.title = `${gettext("Changer")}: ${view.changer}`;
+	},
     },
 
     listeners: {
@@ -490,16 +478,6 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
     },
 
     tbar: [
-	{
-	    fieldLabel: gettext('Changer'),
-	    xtype: 'pbsChangerSelector',
-	    reference: 'changerselector',
-	    autoSelect: true,
-	    listeners: {
-		change: 'changerChange',
-	    },
-	},
-	'-',
 	{
 	    text: gettext('Reload'),
 	    xtype: 'proxmoxButton',
@@ -512,18 +490,12 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    xtype: 'proxmoxButton',
 	    handler: 'barcodeLabel',
 	    iconCls: 'fa fa-barcode',
-	    bind: {
-		disabled: '{!changerSelected}',
-	    },
 	},
 	{
 	    text: gettext('Inventory'),
 	    xtype: 'proxmoxButton',
 	    handler: 'inventory',
 	    iconCls: 'fa fa-book',
-	    bind: {
-		disabled: '{!changerSelected}',
-	    },
 	},
     ],
 
diff --git a/www/tape/TapeManagement.js b/www/tape/TapeManagement.js
index 265b2b77..bac37d9c 100644
--- a/www/tape/TapeManagement.js
+++ b/www/tape/TapeManagement.js
@@ -21,11 +21,6 @@ Ext.define('PBS.TapeManagement', {
 	    itemId: 'inventory',
 	    xtype: 'pbsTapeInventory',
 	},
-	{
-	    title: gettext('Library'),
-	    itemId: 'library',
-	    xtype: 'pbsChangerStatus',
-	},
 	{
 	    title: gettext('Changers'),
 	    itemId: 'changers',
-- 
2.20.1