2021-02-02 13:00:39 +00:00
|
|
|
Ext.define('pbs-model-tapes', {
|
|
|
|
extend: 'Ext.data.Model',
|
|
|
|
fields: [
|
2021-02-26 06:48:13 +00:00
|
|
|
{ name: 'catalog', type: 'boolean' },
|
2021-02-02 13:00:39 +00:00
|
|
|
'ctime',
|
2021-02-26 06:48:13 +00:00
|
|
|
{ name: 'expired', type: 'boolean' },
|
2021-02-02 13:00:39 +00:00
|
|
|
'label-text',
|
|
|
|
'location',
|
|
|
|
'media-set-ctime',
|
|
|
|
'media-set-name',
|
|
|
|
'media-set-uuid',
|
2021-02-18 08:26:44 +00:00
|
|
|
{
|
|
|
|
name: 'pool',
|
|
|
|
defaultValue: '',
|
|
|
|
},
|
2021-02-02 13:00:39 +00:00
|
|
|
'seq-nr',
|
|
|
|
'status',
|
|
|
|
'uuid',
|
|
|
|
],
|
|
|
|
idProperty: 'label-text',
|
|
|
|
proxy: {
|
|
|
|
type: 'proxmox',
|
|
|
|
url: '/api2/json/tape/media/list',
|
2021-02-15 14:22:21 +00:00
|
|
|
timeout: 5*60*1000,
|
2021-02-02 13:00:39 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.TapeManagement.TapeInventory', {
|
|
|
|
extend: 'Ext.grid.Panel',
|
|
|
|
alias: 'widget.pbsTapeInventory',
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
2021-02-15 14:22:22 +00:00
|
|
|
addTape: function() {
|
|
|
|
Ext.create('PBS.TapeManagement.LabelMediaWindow').show();
|
|
|
|
},
|
|
|
|
|
2021-04-14 10:21:37 +00:00
|
|
|
format: function() {
|
2021-02-16 08:35:25 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (!selection || selection.length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let label = selection[0].data['label-text'];
|
2021-02-16 11:48:10 +00:00
|
|
|
let inChanger = selection[0].data.location.startsWith('online-');
|
|
|
|
let changer;
|
|
|
|
if (inChanger) {
|
|
|
|
changer = selection[0].data.location.slice("online-".length);
|
|
|
|
}
|
|
|
|
Ext.create('PBS.TapeManagement.EraseWindow', {
|
|
|
|
label,
|
|
|
|
changer,
|
2021-02-16 08:35:25 +00:00
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-02-11 13:11:20 +00:00
|
|
|
moveToVault: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (!selection || selection.length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let label = selection[0].data['label-text'];
|
|
|
|
let inVault = selection[0].data.location.startsWith('vault-');
|
|
|
|
let vault = "";
|
|
|
|
if (inVault) {
|
|
|
|
vault = selection[0].data.location.slice("vault-".length);
|
|
|
|
}
|
|
|
|
Ext.create('Proxmox.window.Edit', {
|
2021-02-26 10:06:11 +00:00
|
|
|
title: gettext('Set Media Location'),
|
2021-02-11 13:11:20 +00:00
|
|
|
url: `/api2/extjs/tape/media/move`,
|
|
|
|
method: 'POST',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'displayfield',
|
|
|
|
name: 'label-text',
|
|
|
|
value: label,
|
|
|
|
submitValue: true,
|
|
|
|
fieldLabel: gettext('Media'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
fieldLabel: gettext('Vault'),
|
|
|
|
name: 'vault-name',
|
|
|
|
value: vault,
|
|
|
|
emptyText: gettext('On-site'),
|
|
|
|
skipEmpty: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-02-26 10:06:11 +00:00
|
|
|
setStatus: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (!selection || selection.length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let data = selection[0].data;
|
|
|
|
|
|
|
|
let uuid = data.uuid;
|
|
|
|
let label = data['label-text'];
|
|
|
|
let status = data.status;
|
|
|
|
|
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
title: gettext('Set Media Status'),
|
|
|
|
url: `/api2/extjs/tape/media/list/${uuid}/status`,
|
|
|
|
method: 'POST',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'displayfield',
|
|
|
|
name: 'label-text',
|
|
|
|
value: label,
|
|
|
|
fieldLabel: gettext('Media'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxKVComboBox',
|
|
|
|
fieldLabel: gettext('Status'),
|
|
|
|
name: 'status',
|
|
|
|
value: status,
|
|
|
|
emptyText: gettext('Clear Status'),
|
|
|
|
comboItems: [
|
|
|
|
['__default__', gettext('Clear Status')],
|
|
|
|
['full', gettext('Full')],
|
|
|
|
['damaged', gettext('Damaged')],
|
|
|
|
['retired', gettext('Retired')],
|
|
|
|
],
|
|
|
|
deleteEmpty: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-02-02 13:00:39 +00:00
|
|
|
reload: function() {
|
2021-02-18 09:10:51 +00:00
|
|
|
this.getView().getStore().load({
|
2021-02-26 06:48:13 +00:00
|
|
|
params: { 'update-status': false },
|
2021-02-18 09:10:51 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
reload_update_status: function() {
|
|
|
|
this.getView().getStore().load({
|
2021-02-26 06:48:13 +00:00
|
|
|
params: { 'update-status': true },
|
2021-02-18 09:10:51 +00:00
|
|
|
});
|
2021-02-02 13:00:39 +00:00
|
|
|
},
|
2021-03-03 14:00:53 +00:00
|
|
|
|
|
|
|
init: function(view) {
|
|
|
|
Proxmox.Utils.monStoreErrors(view, view.getStore());
|
|
|
|
},
|
2021-02-02 13:00:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
listeners: {
|
2021-02-15 14:22:21 +00:00
|
|
|
activate: 'reload',
|
2021-02-02 13:00:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
2021-02-15 14:22:21 +00:00
|
|
|
storeid: 'proxmox-tape-tapes',
|
|
|
|
model: 'pbs-model-tapes',
|
2021-02-02 13:00:39 +00:00
|
|
|
sorters: 'label-text',
|
2021-02-18 06:30:37 +00:00
|
|
|
groupField: 'pool',
|
2021-02-02 13:00:39 +00:00
|
|
|
},
|
|
|
|
|
2021-02-11 13:11:20 +00:00
|
|
|
tbar: [
|
2021-02-15 14:22:21 +00:00
|
|
|
{
|
|
|
|
text: gettext('Reload'),
|
2021-02-18 09:10:51 +00:00
|
|
|
handler: 'reload_update_status',
|
2021-02-15 14:22:21 +00:00
|
|
|
},
|
|
|
|
'-',
|
2021-02-15 14:22:22 +00:00
|
|
|
{
|
|
|
|
text: gettext('Add Tape'),
|
|
|
|
handler: 'addTape',
|
|
|
|
},
|
2021-02-11 13:11:20 +00:00
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
2021-02-26 10:06:11 +00:00
|
|
|
text: gettext('Set Location'),
|
2021-02-11 13:11:20 +00:00
|
|
|
disabled: true,
|
|
|
|
handler: 'moveToVault',
|
|
|
|
enableFn: (rec) => !rec.data.location.startsWith('online-'),
|
|
|
|
},
|
2021-02-26 10:06:11 +00:00
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Set Status'),
|
|
|
|
disabled: true,
|
|
|
|
handler: 'setStatus',
|
|
|
|
},
|
2021-02-16 08:35:25 +00:00
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
2021-04-14 10:21:37 +00:00
|
|
|
text: gettext('Format'),
|
2021-02-16 08:35:25 +00:00
|
|
|
disabled: true,
|
2021-04-14 10:21:37 +00:00
|
|
|
handler: 'format',
|
2021-02-16 08:35:25 +00:00
|
|
|
},
|
2021-02-11 13:11:20 +00:00
|
|
|
],
|
|
|
|
|
2021-02-18 06:30:37 +00:00
|
|
|
features: [
|
|
|
|
{
|
|
|
|
ftype: 'grouping',
|
|
|
|
groupHeaderTpl: [
|
|
|
|
'{name:this.formatName} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})',
|
|
|
|
{
|
|
|
|
formatName: function(pool) {
|
|
|
|
if (pool === "") {
|
|
|
|
return "Free (no pool assignment)";
|
|
|
|
} else {
|
|
|
|
return pool;
|
|
|
|
}
|
2021-02-26 06:48:13 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-02-18 06:30:37 +00:00
|
|
|
],
|
|
|
|
|
2021-02-26 06:48:13 +00:00
|
|
|
viewConfig: {
|
|
|
|
stripeRows: false, // does not work with getRowClass()
|
|
|
|
|
|
|
|
getRowClass: function(record, index) {
|
2021-02-26 10:06:11 +00:00
|
|
|
let status = record.get('status');
|
|
|
|
if (status === 'damaged') {
|
|
|
|
return "proxmox-invalid-row";
|
|
|
|
}
|
2021-02-26 06:48:13 +00:00
|
|
|
let catalog = record.get('catalog');
|
2021-02-26 10:06:11 +00:00
|
|
|
return catalog ? '' : "proxmox-warning-row";
|
2021-02-26 06:48:13 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2021-02-02 13:00:39 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
text: gettext('Label'),
|
|
|
|
dataIndex: 'label-text',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
{
|
2021-05-21 13:53:50 +00:00
|
|
|
text: gettext('Media-Set'),
|
2021-02-02 13:00:39 +00:00
|
|
|
dataIndex: 'media-set-name',
|
|
|
|
flex: 2,
|
|
|
|
sorter: function(a, b) {
|
|
|
|
return (a.data['media-set-ctime'] || 0) - (b.data['media-set-ctime'] || 0);
|
|
|
|
},
|
2021-02-18 06:30:37 +00:00
|
|
|
renderer: function(value) {
|
|
|
|
if (value === undefined) {
|
|
|
|
return "-- empty --";
|
|
|
|
} else {
|
|
|
|
return value;
|
|
|
|
}
|
2021-02-26 06:48:13 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Catalog'),
|
|
|
|
dataIndex: 'catalog',
|
|
|
|
renderer: function(value, metaData, record) {
|
|
|
|
return value ? Proxmox.Utils.yesText : PBS.Utils.missingText;
|
|
|
|
},
|
2021-02-02 13:00:39 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Location'),
|
|
|
|
dataIndex: 'location',
|
|
|
|
flex: 1,
|
|
|
|
renderer: function(value) {
|
|
|
|
if (value === 'offline') {
|
2021-02-11 13:11:20 +00:00
|
|
|
return `<i class="fa fa-circle-o"></i> ${gettext("Offline")} (${gettext('On-site')})`;
|
2021-02-02 13:00:39 +00:00
|
|
|
} else if (value.startsWith('online-')) {
|
|
|
|
let location = value.substring(value.indexOf('-') + 1);
|
|
|
|
return `<i class="fa fa-dot-circle-o"></i> ${gettext("Online")} - ${location}`;
|
|
|
|
} else if (value.startsWith('vault-')) {
|
|
|
|
let location = value.substring(value.indexOf('-') + 1);
|
|
|
|
return `<i class="fa fa-archive"></i> ${gettext("Vault")} - ${location}`;
|
|
|
|
} else {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Status'),
|
|
|
|
dataIndex: 'status',
|
2021-02-09 14:40:43 +00:00
|
|
|
renderer: function(value, mD, record) {
|
|
|
|
return record.data.expired ? 'expired' : value;
|
|
|
|
},
|
2021-02-02 13:00:39 +00:00
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|