2021-02-22 13:25:36 +00:00
|
|
|
Ext.define('pbs-slot-model', {
|
|
|
|
extend: 'Ext.data.Model',
|
2021-02-23 08:06:32 +00:00
|
|
|
fields: ['entry-id', 'label-text', 'is-labeled', ' model', 'name', 'vendor', 'serial', 'state', 'status', 'pool',
|
2021-02-22 13:25:36 +00:00
|
|
|
{
|
|
|
|
name: 'is-blocked',
|
|
|
|
calculate: function(data) {
|
|
|
|
return data.state !== undefined;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
idProperty: 'entry-id',
|
|
|
|
});
|
|
|
|
|
2021-03-12 15:06:27 +00:00
|
|
|
Ext.define('PBS.TapeManagement.FreeSlotSelector', {
|
|
|
|
extend: 'Proxmox.form.ComboGrid',
|
|
|
|
alias: 'widget.pbsFreeSlotSelector',
|
|
|
|
|
|
|
|
valueField: 'id',
|
|
|
|
displayField: 'id',
|
|
|
|
|
|
|
|
listConfig: {
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
dataIndex: 'id',
|
|
|
|
text: gettext('ID'),
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataIndex: 'type',
|
|
|
|
text: gettext('Type'),
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-01-28 11:59:48 +00:00
|
|
|
Ext.define('PBS.TapeManagement.ChangerStatus', {
|
|
|
|
extend: 'Ext.panel.Panel',
|
|
|
|
alias: 'widget.pbsChangerStatus',
|
|
|
|
|
2021-03-08 08:47:44 +00:00
|
|
|
tools: [PBS.Utils.get_help_tool("tape_backup")],
|
|
|
|
|
2021-01-28 11:59:48 +00:00
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
2021-03-01 11:22:42 +00:00
|
|
|
importTape: function(v, rI, cI, button, el, record) {
|
2021-01-28 11:59:48 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
2021-01-29 13:57:50 +00:00
|
|
|
let from = record.data['entry-id'];
|
2021-03-01 11:22:42 +00:00
|
|
|
let changer = encodeURIComponent(view.changer);
|
2021-01-29 13:57:50 +00:00
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
title: gettext('Import'),
|
|
|
|
isCreate: true,
|
|
|
|
submitText: gettext('OK'),
|
|
|
|
method: 'POST',
|
|
|
|
url: `/api2/extjs/tape/changer/${changer}/transfer`,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'displayfield',
|
|
|
|
name: 'from',
|
|
|
|
value: from,
|
|
|
|
submitValue: true,
|
|
|
|
fieldLabel: gettext('From Slot'),
|
|
|
|
},
|
|
|
|
{
|
2021-03-12 15:06:27 +00:00
|
|
|
xtype: 'pbsFreeSlotSelector',
|
2021-01-29 13:57:50 +00:00
|
|
|
name: 'to',
|
|
|
|
fieldLabel: gettext('To Slot'),
|
2021-03-12 15:06:27 +00:00
|
|
|
store: {
|
|
|
|
data: me.free_slots,
|
|
|
|
},
|
2021-01-29 13:57:50 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-03-01 11:22:42 +00:00
|
|
|
slotTransfer: function(v, rI, cI, button, el, record) {
|
2021-01-28 11:59:48 +00:00
|
|
|
let me = this;
|
2021-03-01 11:22:42 +00:00
|
|
|
let view = me.getView();
|
2021-01-28 11:59:48 +00:00
|
|
|
let from = record.data['entry-id'];
|
2021-03-01 11:22:42 +00:00
|
|
|
let changer = encodeURIComponent(view.changer);
|
2021-01-28 11:59:48 +00:00
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
title: gettext('Transfer'),
|
|
|
|
isCreate: true,
|
|
|
|
submitText: gettext('OK'),
|
|
|
|
method: 'POST',
|
|
|
|
url: `/api2/extjs/tape/changer/${changer}/transfer`,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'displayfield',
|
|
|
|
name: 'from',
|
|
|
|
value: from,
|
|
|
|
submitValue: true,
|
|
|
|
fieldLabel: gettext('From Slot'),
|
|
|
|
},
|
|
|
|
{
|
2021-03-12 15:06:27 +00:00
|
|
|
xtype: 'pbsFreeSlotSelector',
|
2021-01-28 11:59:48 +00:00
|
|
|
name: 'to',
|
|
|
|
fieldLabel: gettext('To Slot'),
|
2021-03-12 15:06:27 +00:00
|
|
|
store: {
|
|
|
|
data: me.free_slots.concat(me.free_ie_slots),
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-03-02 07:44:29 +00:00
|
|
|
labelMedia: function(button, event, record) {
|
|
|
|
let me = this;
|
|
|
|
Ext.create('PBS.TapeManagement.LabelMediaWindow', {
|
|
|
|
driveid: record.data.name,
|
2021-03-02 08:54:33 +00:00
|
|
|
label: record.data["label-text"],
|
2021-03-02 07:44:29 +00:00
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-03-02 07:53:18 +00:00
|
|
|
catalog: function(button, event, record) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
let view = me.getView();
|
|
|
|
PBS.Utils.driveCommand(record.data.name, 'catalog', {
|
|
|
|
waitMsgTarget: view,
|
|
|
|
method: 'POST',
|
|
|
|
success: function(response) {
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
upid: response.result.data,
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-03-01 11:22:42 +00:00
|
|
|
erase: function(v, rI, cI, button, el, record) {
|
2021-02-16 11:48:10 +00:00
|
|
|
let me = this;
|
2021-03-01 11:22:42 +00:00
|
|
|
let view = me.getView();
|
2021-02-16 11:48:10 +00:00
|
|
|
let label = record.data['label-text'];
|
|
|
|
|
2021-03-01 11:22:42 +00:00
|
|
|
let changer = encodeURIComponent(view.changer);
|
2021-04-08 11:39:16 +00:00
|
|
|
let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined;
|
2021-02-16 11:48:10 +00:00
|
|
|
Ext.create('PBS.TapeManagement.EraseWindow', {
|
|
|
|
label,
|
|
|
|
changer,
|
2021-04-08 11:39:16 +00:00
|
|
|
singleDrive,
|
2021-02-16 11:48:10 +00:00
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-03-01 11:22:42 +00:00
|
|
|
load: function(v, rI, cI, button, el, record) {
|
2021-01-28 11:59:48 +00:00
|
|
|
let me = this;
|
2021-03-01 11:22:42 +00:00
|
|
|
let view = me.getView();
|
2021-01-28 11:59:48 +00:00
|
|
|
let label = record.data['label-text'];
|
|
|
|
|
2021-03-01 11:22:42 +00:00
|
|
|
let changer = encodeURIComponent(view.changer);
|
2021-04-08 11:39:17 +00:00
|
|
|
let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined;
|
2021-01-28 11:59:48 +00:00
|
|
|
|
2021-04-08 11:39:17 +00:00
|
|
|
if (singleDrive !== undefined) {
|
|
|
|
Proxmox.Utils.API2Request({
|
|
|
|
method: 'POST',
|
|
|
|
params: {
|
|
|
|
'label-text': label,
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
2021-04-08 11:39:17 +00:00
|
|
|
url: `/api2/extjs/tape/drive/${singleDrive}/load-media`,
|
|
|
|
success: function(response, opt) {
|
|
|
|
Ext.create('Proxmox.window.TaskProgress', {
|
|
|
|
upid: response.result.data,
|
|
|
|
taskDone: function(success) {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
}).show();
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
2021-04-08 11:39:17 +00:00
|
|
|
failure: function(response, opt) {
|
|
|
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
2021-04-08 11:39:17 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
isCreate: true,
|
|
|
|
autoShow: true,
|
|
|
|
submitText: gettext('OK'),
|
|
|
|
title: gettext('Load Media into Drive'),
|
|
|
|
url: `/api2/extjs/tape/drive`,
|
|
|
|
method: 'POST',
|
|
|
|
submitUrl: function(url, values) {
|
|
|
|
let drive = values.drive;
|
|
|
|
delete values.drive;
|
|
|
|
return `${url}/${encodeURIComponent(drive)}/load-media`;
|
|
|
|
},
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'displayfield',
|
|
|
|
name: 'label-text',
|
|
|
|
value: label,
|
|
|
|
submitValue: true,
|
|
|
|
fieldLabel: gettext('Media'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'pbsDriveSelector',
|
|
|
|
fieldLabel: gettext('Drive'),
|
|
|
|
changer: changer,
|
|
|
|
name: 'drive',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
|
2021-03-01 11:22:42 +00:00
|
|
|
unload: async function(v, rI, cI, button, el, record) {
|
2021-01-28 11:59:48 +00:00
|
|
|
let me = this;
|
|
|
|
let drive = record.data.name;
|
|
|
|
try {
|
2021-02-23 08:06:33 +00:00
|
|
|
await PBS.Async.api2({
|
2021-02-18 08:18:09 +00:00
|
|
|
method: 'POST',
|
2021-02-15 11:18:19 +00:00
|
|
|
timeout: 5*60*1000,
|
2021-01-28 11:59:48 +00:00
|
|
|
url: `/api2/extjs/tape/drive/${encodeURIComponent(drive)}/unload`,
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
Ext.Msg.alert(gettext('Error'), error);
|
|
|
|
}
|
2021-02-23 08:06:33 +00:00
|
|
|
me.reload();
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
cartridgeMemory: function(view, rI, cI, button, el, record) {
|
|
|
|
let me = this;
|
|
|
|
let drive = record.data.name;
|
2021-02-25 10:52:42 +00:00
|
|
|
PBS.Utils.driveCommand(drive, 'cartridge-memory', {
|
|
|
|
waitMsgTarget: me.getView(),
|
|
|
|
success: PBS.Utils.showCartridgeMemoryWindow,
|
2021-01-28 11:59:48 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-03-02 07:59:00 +00:00
|
|
|
cleanDrive: function(button, event, record) {
|
2021-01-28 11:59:48 +00:00
|
|
|
let me = this;
|
2021-02-25 10:52:42 +00:00
|
|
|
PBS.Utils.driveCommand(record.data.name, 'clean', {
|
|
|
|
waitMsgTarget: me.getView(),
|
|
|
|
method: 'PUT',
|
2021-03-02 11:16:30 +00:00
|
|
|
success: function(response) {
|
|
|
|
Ext.create('Proxmox.window.TaskProgress', {
|
|
|
|
upid: response.result.data,
|
|
|
|
taskDone: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
2021-02-25 10:52:42 +00:00
|
|
|
});
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
volumeStatistics: function(view, rI, cI, button, el, record) {
|
|
|
|
let me = this;
|
|
|
|
let drive = record.data.name;
|
2021-02-25 10:52:42 +00:00
|
|
|
PBS.Utils.driveCommand(drive, 'volume-statistics', {
|
|
|
|
waitMsgTarget: me.getView(),
|
|
|
|
success: PBS.Utils.showVolumeStatisticsWindow,
|
2021-01-28 11:59:48 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
readLabel: function(view, rI, cI, button, el, record) {
|
|
|
|
let me = this;
|
|
|
|
let drive = record.data.name;
|
|
|
|
|
2021-02-25 10:52:42 +00:00
|
|
|
PBS.Utils.driveCommand(drive, 'read-label', {
|
|
|
|
waitMsgTarget: me.getView(),
|
|
|
|
success: PBS.Utils.showMediaLabelWindow,
|
2021-01-28 11:59:48 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
status: function(view, rI, cI, button, el, record) {
|
|
|
|
let me = this;
|
|
|
|
let drive = record.data.name;
|
2021-02-25 10:52:42 +00:00
|
|
|
PBS.Utils.driveCommand(drive, 'status', {
|
|
|
|
waitMsgTarget: me.getView(),
|
|
|
|
success: PBS.Utils.showDriveStatusWindow,
|
2021-01-28 11:59:48 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
reloadList: function() {
|
|
|
|
let me = this;
|
|
|
|
me.lookup('changerselector').getStore().load();
|
|
|
|
},
|
|
|
|
|
|
|
|
barcodeLabel: function() {
|
|
|
|
let me = this;
|
2021-03-01 11:22:42 +00:00
|
|
|
let view = me.getView();
|
|
|
|
let changer = view.changer;
|
2021-01-28 11:59:48 +00:00
|
|
|
if (changer === '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-08 11:39:19 +00:00
|
|
|
let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined;
|
|
|
|
|
2021-01-28 11:59:48 +00:00
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
title: gettext('Barcode Label'),
|
|
|
|
showTaskViewer: true,
|
2021-01-29 16:06:53 +00:00
|
|
|
method: 'POST',
|
2021-01-28 11:59:48 +00:00
|
|
|
url: '/api2/extjs/tape/drive',
|
|
|
|
submitUrl: function(url, values) {
|
|
|
|
let drive = values.drive;
|
|
|
|
delete values.drive;
|
|
|
|
return `${url}/${encodeURIComponent(drive)}/barcode-label-media`;
|
|
|
|
},
|
|
|
|
|
|
|
|
items: [
|
|
|
|
{
|
2021-04-08 11:39:19 +00:00
|
|
|
xtype: singleDrive === undefined ? 'pbsDriveSelector' : 'displayfield',
|
2021-01-28 11:59:48 +00:00
|
|
|
fieldLabel: gettext('Drive'),
|
2021-04-08 11:39:19 +00:00
|
|
|
submitValue: true,
|
2021-01-28 11:59:48 +00:00
|
|
|
name: 'drive',
|
2021-04-08 11:39:19 +00:00
|
|
|
value: singleDrive,
|
2021-01-28 11:59:48 +00:00
|
|
|
changer: changer,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'pbsMediaPoolSelector',
|
|
|
|
fieldLabel: gettext('Pool'),
|
|
|
|
name: 'pool',
|
|
|
|
skipEmptyText: true,
|
|
|
|
allowBlank: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-02-05 14:26:18 +00:00
|
|
|
inventory: function() {
|
|
|
|
let me = this;
|
2021-03-01 11:22:42 +00:00
|
|
|
let view = me.getView();
|
|
|
|
let changer = view.changer;
|
2021-02-05 14:26:18 +00:00
|
|
|
if (changer === '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-08 11:39:18 +00:00
|
|
|
let singleDrive = me.drives.length === 1 ? me.drives[0] : undefined;
|
2021-02-05 14:26:18 +00:00
|
|
|
|
2021-04-08 11:39:18 +00:00
|
|
|
if (singleDrive !== undefined) {
|
|
|
|
Proxmox.Utils.API2Request({
|
|
|
|
method: 'PUT',
|
|
|
|
url: `/api2/extjs/tape/drive/${singleDrive}/inventory`,
|
|
|
|
success: function(response, opt) {
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
upid: response.result.data,
|
|
|
|
taskDone: function(success) {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
}).show();
|
2021-02-05 14:26:18 +00:00
|
|
|
},
|
2021-04-08 11:39:18 +00:00
|
|
|
failure: function(response, opt) {
|
|
|
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
title: gettext('Inventory'),
|
|
|
|
showTaskViewer: true,
|
|
|
|
method: 'PUT',
|
|
|
|
url: '/api2/extjs/tape/drive',
|
|
|
|
submitUrl: function(url, values) {
|
|
|
|
let drive = values.drive;
|
|
|
|
delete values.drive;
|
|
|
|
return `${url}/${encodeURIComponent(drive)}/inventory`;
|
|
|
|
},
|
|
|
|
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'pbsDriveSelector',
|
|
|
|
fieldLabel: gettext('Drive'),
|
|
|
|
name: 'drive',
|
|
|
|
changer: changer,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}).show();
|
|
|
|
}
|
2021-02-05 14:26:18 +00:00
|
|
|
},
|
|
|
|
|
2021-02-22 13:25:35 +00:00
|
|
|
scheduleReload: function(time) {
|
|
|
|
let me = this;
|
|
|
|
if (me.reloadTimeout === undefined) {
|
|
|
|
me.reloadTimeout = setTimeout(function() {
|
|
|
|
me.reload();
|
|
|
|
}, time);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-03-01 11:22:43 +00:00
|
|
|
cancelReload: function() {
|
2021-02-22 13:25:35 +00:00
|
|
|
let me = this;
|
|
|
|
if (me.reloadTimeout !== undefined) {
|
|
|
|
clearTimeout(me.reloadTimeout);
|
|
|
|
me.reloadTimeout = undefined;
|
|
|
|
}
|
2021-03-01 11:22:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
reload: function() {
|
|
|
|
let me = this;
|
|
|
|
me.cancelReload();
|
2021-02-22 13:25:35 +00:00
|
|
|
me.reload_full(true);
|
2021-02-20 08:06:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
reload_no_cache: function() {
|
2021-02-22 13:25:35 +00:00
|
|
|
let me = this;
|
|
|
|
if (me.reloadTimeout !== undefined) {
|
|
|
|
clearTimeout(me.reloadTimeout);
|
|
|
|
me.reloadTimeout = undefined;
|
|
|
|
}
|
|
|
|
me.reload_full(false);
|
2021-02-20 08:06:17 +00:00
|
|
|
},
|
|
|
|
|
2021-04-08 11:39:15 +00:00
|
|
|
drives: [],
|
|
|
|
|
|
|
|
updateDrives: function(drives) {
|
|
|
|
let me = this;
|
|
|
|
me.drives = drives;
|
|
|
|
},
|
|
|
|
|
2021-03-12 15:06:27 +00:00
|
|
|
free_slots: [],
|
2021-04-08 11:39:14 +00:00
|
|
|
free_ie_slots: [],
|
2021-03-12 15:06:27 +00:00
|
|
|
|
|
|
|
updateFreeSlots: function(free_slots, free_ie_slots) {
|
|
|
|
let me = this;
|
|
|
|
me.free_slots = free_slots;
|
|
|
|
me.free_ie_slots = free_ie_slots;
|
|
|
|
},
|
|
|
|
|
2021-02-20 08:06:17 +00:00
|
|
|
reload_full: async function(use_cache) {
|
2021-01-28 11:59:48 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
2021-03-01 11:22:42 +00:00
|
|
|
let changer = view.changer;
|
2021-01-28 11:59:48 +00:00
|
|
|
if (changer === '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2021-02-22 13:25:34 +00:00
|
|
|
if (!use_cache) {
|
|
|
|
Proxmox.Utils.setErrorMask(view, true);
|
|
|
|
Proxmox.Utils.setErrorMask(me.lookup('content'));
|
|
|
|
}
|
2021-02-04 12:56:32 +00:00
|
|
|
let status_fut = PBS.Async.api2({
|
2021-02-15 11:18:19 +00:00
|
|
|
timeout: 5*60*1000,
|
2021-02-20 08:06:17 +00:00
|
|
|
method: 'GET',
|
2021-01-28 11:59:48 +00:00
|
|
|
url: `/api2/extjs/tape/changer/${encodeURIComponent(changer)}/status`,
|
2021-02-20 08:06:17 +00:00
|
|
|
params: {
|
|
|
|
cache: use_cache,
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
});
|
2021-02-04 12:56:32 +00:00
|
|
|
let drives_fut = PBS.Async.api2({
|
2021-02-15 11:18:19 +00:00
|
|
|
timeout: 5*60*1000,
|
2021-01-28 11:59:48 +00:00
|
|
|
url: `/api2/extjs/tape/drive?changer=${encodeURIComponent(changer)}`,
|
|
|
|
});
|
|
|
|
|
2021-02-04 12:56:32 +00:00
|
|
|
let tapes_fut = PBS.Async.api2({
|
2021-02-15 11:18:19 +00:00
|
|
|
timeout: 5*60*1000,
|
2021-02-04 12:56:32 +00:00
|
|
|
url: '/api2/extjs/tape/media/list',
|
2021-02-18 10:08:13 +00:00
|
|
|
method: 'GET',
|
|
|
|
params: {
|
2021-02-18 11:06:49 +00:00
|
|
|
"update-status": false,
|
2021-02-19 14:40:23 +00:00
|
|
|
},
|
2021-02-04 12:56:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
let [status, drives, tapes_list] = await Promise.all([status_fut, drives_fut, tapes_fut]);
|
|
|
|
|
2021-01-28 11:59:48 +00:00
|
|
|
let data = {
|
|
|
|
slot: [],
|
|
|
|
'import-export': [],
|
|
|
|
drive: [],
|
|
|
|
};
|
|
|
|
|
2021-02-04 12:56:32 +00:00
|
|
|
let tapes = {};
|
|
|
|
|
|
|
|
for (const tape of tapes_list.result.data) {
|
2021-02-09 14:40:44 +00:00
|
|
|
tapes[tape['label-text']] = {
|
|
|
|
labeled: true,
|
|
|
|
pool: tape.pool,
|
|
|
|
status: tape.expired ? 'expired' : tape.status,
|
|
|
|
};
|
2021-02-04 12:56:32 +00:00
|
|
|
}
|
|
|
|
|
2021-01-28 11:59:48 +00:00
|
|
|
let drive_entries = {};
|
|
|
|
|
|
|
|
for (const entry of drives.result.data) {
|
|
|
|
drive_entries[entry['changer-drivenum'] || 0] = entry;
|
|
|
|
}
|
|
|
|
|
2021-03-12 15:06:27 +00:00
|
|
|
let free_slots = [];
|
|
|
|
let free_ie_slots = [];
|
|
|
|
|
2021-04-08 11:39:15 +00:00
|
|
|
let valid_drives = [];
|
|
|
|
|
2021-01-28 11:59:48 +00:00
|
|
|
for (let entry of status.result.data) {
|
|
|
|
let type = entry['entry-kind'];
|
2021-04-08 11:39:15 +00:00
|
|
|
let id = entry['entry-id'];
|
2021-01-28 11:59:48 +00:00
|
|
|
|
2021-04-08 11:39:15 +00:00
|
|
|
if (type === 'drive' && drive_entries[id] !== undefined) {
|
|
|
|
entry = Ext.applyIf(entry, drive_entries[id]);
|
|
|
|
valid_drives.push(drive_entries[id].name);
|
2021-01-28 11:59:48 +00:00
|
|
|
}
|
|
|
|
|
2021-02-09 14:40:44 +00:00
|
|
|
if (tapes[entry['label-text']] !== undefined) {
|
|
|
|
entry['is-labeled'] = true;
|
|
|
|
entry.pool = tapes[entry['label-text']].pool;
|
|
|
|
entry.status = tapes[entry['label-text']].status;
|
|
|
|
} else {
|
|
|
|
entry['is-labeled'] = false;
|
|
|
|
}
|
2021-02-04 12:56:32 +00:00
|
|
|
|
2021-03-12 15:06:27 +00:00
|
|
|
if (!entry['label-text'] && type !== 'drive') {
|
|
|
|
if (type === 'slot') {
|
|
|
|
free_slots.push({
|
2021-04-08 11:39:15 +00:00
|
|
|
id,
|
2021-03-12 15:06:27 +00:00
|
|
|
type,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
free_ie_slots.push({
|
2021-04-08 11:39:15 +00:00
|
|
|
id,
|
2021-03-12 15:06:27 +00:00
|
|
|
type,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2021-01-28 11:59:48 +00:00
|
|
|
data[type].push(entry);
|
|
|
|
}
|
|
|
|
|
2021-02-22 13:25:36 +00:00
|
|
|
// the stores are diffstores and are only refreshed
|
|
|
|
// on a 'load' event, which does not trigger on 'setData'
|
|
|
|
// so we have to fire them ourselves
|
2021-01-28 11:59:48 +00:00
|
|
|
|
2021-02-22 13:25:36 +00:00
|
|
|
me.lookup('slots').getStore().rstore.setData(data.slot);
|
|
|
|
me.lookup('slots').getStore().rstore.fireEvent('load', me, [], true);
|
|
|
|
|
|
|
|
me.lookup('import_export').getStore().rstore.setData(data['import-export']);
|
|
|
|
me.lookup('import_export').getStore().rstore.fireEvent('load', me, [], true);
|
|
|
|
|
|
|
|
me.lookup('drives').getStore().rstore.setData(data.drive);
|
|
|
|
me.lookup('drives').getStore().rstore.fireEvent('load', me, [], true);
|
2021-01-28 11:59:48 +00:00
|
|
|
|
2021-03-02 08:54:33 +00:00
|
|
|
// manually fire selectionchange to update button status
|
|
|
|
me.lookup('drives').getSelectionModel().fireEvent('selectionchange', me);
|
|
|
|
|
2021-03-12 15:06:27 +00:00
|
|
|
me.updateFreeSlots(free_slots, free_ie_slots);
|
2021-04-08 11:39:15 +00:00
|
|
|
me.updateDrives(valid_drives);
|
2021-03-12 15:06:27 +00:00
|
|
|
|
2021-02-22 13:25:34 +00:00
|
|
|
if (!use_cache) {
|
|
|
|
Proxmox.Utils.setErrorMask(view);
|
|
|
|
}
|
|
|
|
Proxmox.Utils.setErrorMask(me.lookup('content'));
|
2021-01-28 11:59:48 +00:00
|
|
|
} catch (err) {
|
2021-03-01 11:22:43 +00:00
|
|
|
if (!view || view.isDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-22 13:25:34 +00:00
|
|
|
if (!use_cache) {
|
|
|
|
Proxmox.Utils.setErrorMask(view);
|
|
|
|
}
|
|
|
|
Proxmox.Utils.setErrorMask(me.lookup('content'), err.toString());
|
2021-01-28 11:59:48 +00:00
|
|
|
}
|
2021-02-22 13:25:35 +00:00
|
|
|
|
|
|
|
me.scheduleReload(5000);
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
2021-02-18 08:18:07 +00:00
|
|
|
|
|
|
|
renderIsLabeled: function(value, mD, record) {
|
|
|
|
if (!record.data['label-text']) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (record.data['label-text'].startsWith("CLN")) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!value) {
|
|
|
|
return gettext('Not Labeled');
|
|
|
|
}
|
|
|
|
|
|
|
|
let status = record.data.status;
|
|
|
|
if (record.data.pool) {
|
|
|
|
return `${status} (${record.data.pool})`;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
},
|
2021-02-18 14:40:30 +00:00
|
|
|
|
|
|
|
control: {
|
|
|
|
'grid[reference=drives]': {
|
|
|
|
cellclick: function(table, td, ci, rec, tr, ri, e) {
|
2021-02-19 14:40:24 +00:00
|
|
|
if (e.position.column.dataIndex !== 'state') {
|
2021-02-18 14:40:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let upid = rec.data.state;
|
|
|
|
if (!upid || !upid.startsWith("UPID")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
autoShow: true,
|
|
|
|
upid,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-03-01 11:22:42 +00:00
|
|
|
|
|
|
|
init: function(view) {
|
|
|
|
let me = this;
|
|
|
|
if (!view.changer) {
|
|
|
|
throw "no changer given";
|
|
|
|
}
|
|
|
|
|
|
|
|
view.title = `${gettext("Changer")}: ${view.changer}`;
|
2021-03-01 11:22:43 +00:00
|
|
|
me.reload();
|
2021-03-01 11:22:42 +00:00
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
listeners: {
|
2021-03-01 11:22:43 +00:00
|
|
|
deactivate: 'cancelReload',
|
|
|
|
destroy: 'cancelReload',
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
text: gettext('Reload'),
|
|
|
|
xtype: 'proxmoxButton',
|
2021-02-20 08:06:17 +00:00
|
|
|
handler: 'reload_no_cache',
|
2021-01-28 11:59:48 +00:00
|
|
|
selModel: false,
|
|
|
|
},
|
|
|
|
'-',
|
|
|
|
{
|
|
|
|
text: gettext('Barcode Label'),
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
handler: 'barcodeLabel',
|
|
|
|
iconCls: 'fa fa-barcode',
|
|
|
|
},
|
2021-02-05 14:26:18 +00:00
|
|
|
{
|
|
|
|
text: gettext('Inventory'),
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
handler: 'inventory',
|
|
|
|
iconCls: 'fa fa-book',
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
layout: 'auto',
|
|
|
|
bodyPadding: 5,
|
|
|
|
scrollable: true,
|
|
|
|
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'container',
|
|
|
|
reference: 'content',
|
|
|
|
layout: {
|
|
|
|
type: 'hbox',
|
|
|
|
aling: 'stretch',
|
|
|
|
},
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'grid',
|
|
|
|
reference: 'slots',
|
|
|
|
title: gettext('Slots'),
|
|
|
|
padding: 5,
|
|
|
|
flex: 1,
|
|
|
|
store: {
|
2021-02-22 13:25:36 +00:00
|
|
|
type: 'diff',
|
|
|
|
rstore: {
|
|
|
|
type: 'store',
|
|
|
|
model: 'pbs-slot-model',
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
columns: [
|
|
|
|
{
|
2021-02-18 08:18:08 +00:00
|
|
|
text: gettext('ID'),
|
2021-01-28 11:59:48 +00:00
|
|
|
dataIndex: 'entry-id',
|
|
|
|
width: 50,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext("Content"),
|
|
|
|
dataIndex: 'label-text',
|
|
|
|
flex: 1,
|
|
|
|
renderer: (value) => value || '',
|
|
|
|
},
|
2021-02-04 12:56:32 +00:00
|
|
|
{
|
2021-02-09 14:40:44 +00:00
|
|
|
text: gettext('Inventory'),
|
2021-02-04 12:56:32 +00:00
|
|
|
dataIndex: 'is-labeled',
|
2021-02-18 08:18:07 +00:00
|
|
|
renderer: 'renderIsLabeled',
|
2021-02-09 14:40:44 +00:00
|
|
|
flex: 1,
|
2021-02-04 12:56:32 +00:00
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
{
|
|
|
|
text: gettext('Actions'),
|
|
|
|
xtype: 'actioncolumn',
|
|
|
|
width: 100,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-rotate-90 fa-exchange',
|
|
|
|
handler: 'slotTransfer',
|
2021-01-29 13:57:52 +00:00
|
|
|
tooltip: gettext('Transfer'),
|
2021-01-28 11:59:48 +00:00
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
|
|
|
|
},
|
2021-02-16 11:48:10 +00:00
|
|
|
{
|
|
|
|
iconCls: 'fa fa-trash-o',
|
|
|
|
handler: 'erase',
|
|
|
|
tooltip: gettext('Erase'),
|
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
{
|
|
|
|
iconCls: 'fa fa-rotate-90 fa-upload',
|
|
|
|
handler: 'load',
|
2021-01-29 13:57:52 +00:00
|
|
|
tooltip: gettext('Load'),
|
2021-01-28 11:59:48 +00:00
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'container',
|
|
|
|
flex: 2,
|
|
|
|
defaults: {
|
|
|
|
padding: 5,
|
|
|
|
},
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'grid',
|
|
|
|
reference: 'drives',
|
|
|
|
title: gettext('Drives'),
|
|
|
|
store: {
|
2021-02-22 13:25:36 +00:00
|
|
|
type: 'diff',
|
|
|
|
rstore: {
|
|
|
|
type: 'store',
|
|
|
|
model: 'pbs-slot-model',
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
data: [],
|
|
|
|
},
|
2021-03-02 07:44:29 +00:00
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
text: gettext('Label Media'),
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
handler: 'labelMedia',
|
|
|
|
iconCls: 'fa fa-barcode',
|
|
|
|
disabled: true,
|
2021-03-02 08:54:33 +00:00
|
|
|
enableFn: (rec) => rec.data["label-text"] !== undefined,
|
2021-03-02 07:44:29 +00:00
|
|
|
},
|
2021-03-02 07:53:18 +00:00
|
|
|
{
|
|
|
|
text: gettext('Catalog'),
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
handler: 'catalog',
|
|
|
|
iconCls: 'fa fa-book',
|
|
|
|
disabled: true,
|
2021-03-02 08:54:33 +00:00
|
|
|
enableFn: (rec) => rec.data["label-text"] !== undefined,
|
2021-03-02 07:53:18 +00:00
|
|
|
},
|
2021-03-02 07:59:00 +00:00
|
|
|
{
|
|
|
|
text: gettext('Clean Drive'),
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
handler: 'cleanDrive',
|
|
|
|
iconCls: 'fa fa-shower',
|
|
|
|
disabled: true,
|
|
|
|
},
|
2021-03-02 07:44:29 +00:00
|
|
|
],
|
2021-01-28 11:59:48 +00:00
|
|
|
columns: [
|
|
|
|
{
|
2021-02-18 08:18:08 +00:00
|
|
|
text: gettext('ID'),
|
2021-01-28 11:59:48 +00:00
|
|
|
dataIndex: 'entry-id',
|
2021-02-18 08:18:08 +00:00
|
|
|
hidden: true,
|
2021-01-28 11:59:48 +00:00
|
|
|
width: 50,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext("Content"),
|
|
|
|
dataIndex: 'label-text',
|
|
|
|
flex: 1,
|
|
|
|
renderer: (value) => value || '',
|
|
|
|
},
|
2021-02-18 08:18:07 +00:00
|
|
|
{
|
|
|
|
text: gettext('Inventory'),
|
|
|
|
dataIndex: 'is-labeled',
|
|
|
|
renderer: 'renderIsLabeled',
|
2021-02-18 14:40:30 +00:00
|
|
|
flex: 1.5,
|
2021-02-18 08:18:07 +00:00
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
{
|
|
|
|
text: gettext("Name"),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'name',
|
|
|
|
flex: 1,
|
|
|
|
renderer: Ext.htmlEncode,
|
|
|
|
},
|
2021-02-18 14:40:30 +00:00
|
|
|
{
|
|
|
|
text: gettext('State'),
|
|
|
|
dataIndex: 'state',
|
|
|
|
flex: 3,
|
2021-03-02 11:19:37 +00:00
|
|
|
renderer: PBS.Utils.renderDriveState,
|
2021-02-18 14:40:30 +00:00
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
{
|
|
|
|
text: gettext("Vendor"),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'vendor',
|
2021-02-18 14:40:30 +00:00
|
|
|
hidden: true,
|
2021-01-28 11:59:48 +00:00
|
|
|
flex: 1,
|
|
|
|
renderer: Ext.htmlEncode,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext("Model"),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'model',
|
2021-02-18 14:40:30 +00:00
|
|
|
hidden: true,
|
2021-01-28 11:59:48 +00:00
|
|
|
flex: 1,
|
|
|
|
renderer: Ext.htmlEncode,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext("Serial"),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'serial',
|
2021-02-18 14:40:30 +00:00
|
|
|
hidden: true,
|
2021-01-28 11:59:48 +00:00
|
|
|
flex: 1,
|
|
|
|
renderer: Ext.htmlEncode,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'actioncolumn',
|
|
|
|
text: gettext('Actions'),
|
|
|
|
width: 140,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-rotate-270 fa-upload',
|
|
|
|
handler: 'unload',
|
2021-01-29 13:57:52 +00:00
|
|
|
tooltip: gettext('Unload'),
|
2021-02-22 13:25:37 +00:00
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-hdd-o',
|
|
|
|
handler: 'cartridgeMemory',
|
2021-01-29 13:57:52 +00:00
|
|
|
tooltip: gettext('Cartridge Memory'),
|
2021-02-22 13:25:37 +00:00
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-line-chart',
|
|
|
|
handler: 'volumeStatistics',
|
2021-01-29 13:57:52 +00:00
|
|
|
tooltip: gettext('Volume Statistics'),
|
2021-02-22 13:25:37 +00:00
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-tag',
|
|
|
|
handler: 'readLabel',
|
2021-01-29 13:57:52 +00:00
|
|
|
tooltip: gettext('Read Label'),
|
2021-02-22 13:25:37 +00:00
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-info-circle',
|
2021-01-29 13:57:52 +00:00
|
|
|
tooltip: gettext('Status'),
|
2021-01-28 11:59:48 +00:00
|
|
|
handler: 'status',
|
2021-02-22 13:25:37 +00:00
|
|
|
isDisabled: (v, r, c, i, rec) => rec.data['is-blocked'],
|
2021-01-28 11:59:48 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'grid',
|
|
|
|
reference: 'import_export',
|
|
|
|
store: {
|
2021-02-22 13:25:36 +00:00
|
|
|
type: 'diff',
|
|
|
|
rstore: {
|
|
|
|
type: 'store',
|
|
|
|
model: 'pbs-slot-model',
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
data: [],
|
|
|
|
},
|
2021-02-18 08:18:08 +00:00
|
|
|
title: gettext('Import-Export Slots'),
|
2021-01-28 11:59:48 +00:00
|
|
|
columns: [
|
|
|
|
{
|
2021-02-18 08:18:08 +00:00
|
|
|
text: gettext('ID'),
|
2021-01-28 11:59:48 +00:00
|
|
|
dataIndex: 'entry-id',
|
|
|
|
width: 50,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext("Content"),
|
|
|
|
dataIndex: 'label-text',
|
|
|
|
renderer: (value) => value || '',
|
|
|
|
flex: 1,
|
|
|
|
},
|
2021-02-18 08:18:07 +00:00
|
|
|
{
|
|
|
|
text: gettext('Inventory'),
|
|
|
|
dataIndex: 'is-labeled',
|
|
|
|
renderer: 'renderIsLabeled',
|
|
|
|
flex: 1,
|
|
|
|
},
|
2021-01-28 11:59:48 +00:00
|
|
|
{
|
|
|
|
text: gettext('Actions'),
|
2021-01-29 13:57:50 +00:00
|
|
|
xtype: 'actioncolumn',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-rotate-270 fa-upload',
|
|
|
|
handler: 'importTape',
|
|
|
|
tooltip: gettext('Import'),
|
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
|
|
|
|
},
|
|
|
|
],
|
2021-01-28 11:59:48 +00:00
|
|
|
width: 80,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|