2021-01-28 11:59:47 +00:00
|
|
|
Ext.define('PBS.TapeManagement.BackupOverview', {
|
|
|
|
extend: 'Ext.tree.Panel',
|
|
|
|
alias: 'widget.pbsBackupOverview',
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
|
|
|
backup: function() {
|
|
|
|
let me = this;
|
|
|
|
Ext.create('PBS.TapeManagement.TapeBackupWindow', {
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
2021-05-21 13:18:54 +00:00
|
|
|
autoShow: true,
|
|
|
|
});
|
2021-01-28 11:59:47 +00:00
|
|
|
},
|
|
|
|
|
2021-05-21 13:18:54 +00:00
|
|
|
restoreBackups: function(view, rI, cI, item, e, rec) {
|
2021-05-11 10:50:07 +00:00
|
|
|
let me = this;
|
|
|
|
|
2021-05-21 10:20:20 +00:00
|
|
|
let mediaset = rec.data.is_media_set ? rec.data.text : rec.data['media-set'];
|
2021-02-02 13:00:36 +00:00
|
|
|
Ext.create('PBS.TapeManagement.TapeRestoreWindow', {
|
2021-05-21 10:20:22 +00:00
|
|
|
autoShow: true,
|
2021-05-21 13:18:54 +00:00
|
|
|
uuid: rec.data['media-set-uuid'],
|
|
|
|
prefilter: rec.data.prefilter,
|
2021-02-02 13:00:36 +00:00
|
|
|
mediaset,
|
2021-05-21 10:20:22 +00:00
|
|
|
});
|
2021-02-02 13:00:36 +00:00
|
|
|
},
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
loadContent: async function() {
|
2021-02-08 09:17:59 +00:00
|
|
|
let me = this;
|
2021-02-02 13:00:36 +00:00
|
|
|
let content_response = await PBS.Async.api2({
|
2021-02-15 11:17:36 +00:00
|
|
|
url: '/api2/extjs/tape/media/list?update-status=false',
|
2021-02-02 13:00:36 +00:00
|
|
|
});
|
|
|
|
let data = {};
|
|
|
|
|
|
|
|
for (const entry of content_response.result.data) {
|
|
|
|
let pool = entry.pool;
|
2021-02-09 14:40:42 +00:00
|
|
|
if (pool === undefined) {
|
|
|
|
continue; // pools not belonging to a pool cannot contain data
|
|
|
|
}
|
2021-02-02 13:00:36 +00:00
|
|
|
let media_set = entry['media-set-name'];
|
2021-02-11 15:02:19 +00:00
|
|
|
if (media_set === undefined) {
|
|
|
|
continue; // tape does not belong to media-set (yet))
|
|
|
|
}
|
2021-02-02 13:00:36 +00:00
|
|
|
if (data[pool] === undefined) {
|
|
|
|
data[pool] = {};
|
|
|
|
}
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-08 09:17:59 +00:00
|
|
|
if (data[pool][media_set] === undefined) {
|
|
|
|
data[pool][media_set] = entry;
|
|
|
|
data[pool][media_set].text = media_set;
|
2021-05-14 12:59:20 +00:00
|
|
|
data[pool][media_set].restore =true;
|
2021-02-08 09:17:59 +00:00
|
|
|
data[pool][media_set].tapes = 1;
|
|
|
|
data[pool][media_set]['seq-nr'] = undefined;
|
|
|
|
data[pool][media_set].is_media_set = true;
|
|
|
|
} else {
|
|
|
|
data[pool][media_set].tapes++;
|
2021-02-02 13:00:36 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
let list = [];
|
|
|
|
|
2021-02-08 09:17:59 +00:00
|
|
|
for (const [pool, media_sets] of Object.entries(data)) {
|
|
|
|
let pool_entry = Ext.create('Ext.data.TreeModel', {
|
2021-02-02 13:00:36 +00:00
|
|
|
text: pool,
|
|
|
|
leaf: false,
|
2021-02-08 09:17:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
let children = [];
|
|
|
|
|
|
|
|
for (const media_set of Object.values(media_sets)) {
|
|
|
|
let entry = Ext.create('Ext.data.TreeModel', media_set);
|
|
|
|
entry.on('beforeexpand', (node) => me.beforeExpand(node));
|
|
|
|
children.push(entry);
|
2021-01-28 11:59:47 +00:00
|
|
|
}
|
2021-02-08 09:17:59 +00:00
|
|
|
|
|
|
|
pool_entry.set('children', children);
|
2021-02-02 13:00:36 +00:00
|
|
|
list.push(pool_entry);
|
|
|
|
}
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
|
|
|
reload: async function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
|
|
|
Proxmox.Utils.setErrorMask(view, true);
|
|
|
|
|
|
|
|
try {
|
|
|
|
let list = await me.loadContent();
|
2021-01-28 11:59:47 +00:00
|
|
|
|
|
|
|
view.setRootNode({
|
|
|
|
expanded: true,
|
|
|
|
children: list,
|
|
|
|
});
|
|
|
|
|
|
|
|
Proxmox.Utils.setErrorMask(view, false);
|
|
|
|
} catch (error) {
|
|
|
|
Proxmox.Utils.setErrorMask(view, error.toString());
|
|
|
|
}
|
|
|
|
},
|
2021-02-08 09:17:59 +00:00
|
|
|
|
|
|
|
loadMediaSet: async function(node) {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
|
|
|
Proxmox.Utils.setErrorMask(view, true);
|
2021-05-14 12:59:19 +00:00
|
|
|
const media_set_uuid = node.data['media-set-uuid'];
|
|
|
|
const media_set = node.data.text;
|
2021-02-08 09:17:59 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
let list = await PBS.Async.api2({
|
|
|
|
method: 'GET',
|
|
|
|
url: `/api2/extjs/tape/media/content`,
|
|
|
|
params: {
|
2021-05-14 12:59:19 +00:00
|
|
|
'media-set': media_set_uuid,
|
2021-02-08 09:17:59 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-03-17 12:18:40 +00:00
|
|
|
list.result.data.sort(function(a, b) {
|
|
|
|
let storeRes = a.store.localeCompare(b.store);
|
|
|
|
if (storeRes === 0) {
|
|
|
|
return a.snapshot.localeCompare(b.snapshot);
|
|
|
|
} else {
|
|
|
|
return storeRes;
|
|
|
|
}
|
|
|
|
});
|
2021-02-08 09:17:59 +00:00
|
|
|
|
2021-03-17 12:18:40 +00:00
|
|
|
let stores = {};
|
2021-02-16 11:48:12 +00:00
|
|
|
|
2021-02-08 09:17:59 +00:00
|
|
|
for (let entry of list.result.data) {
|
|
|
|
entry.text = entry.snapshot;
|
2021-05-14 12:59:20 +00:00
|
|
|
entry.restore = true;
|
2021-02-08 09:17:59 +00:00
|
|
|
entry.leaf = true;
|
|
|
|
entry.children = [];
|
2021-05-14 12:59:19 +00:00
|
|
|
entry['media-set'] = media_set;
|
2021-05-21 10:20:20 +00:00
|
|
|
entry.prefilter = {
|
|
|
|
store: entry.store,
|
|
|
|
snapshot: entry.snapshot,
|
|
|
|
};
|
2021-02-08 09:17:59 +00:00
|
|
|
let iconCls = PBS.Utils.get_type_icon_cls(entry.snapshot);
|
|
|
|
if (iconCls !== '') {
|
|
|
|
entry.iconCls = `fa ${iconCls}`;
|
|
|
|
}
|
2021-02-16 11:48:12 +00:00
|
|
|
|
2021-03-17 12:18:40 +00:00
|
|
|
let store = entry.store;
|
2021-02-16 11:48:12 +00:00
|
|
|
let tape = entry['label-text'];
|
2021-03-17 12:18:40 +00:00
|
|
|
if (stores[store] === undefined) {
|
|
|
|
stores[store] = {
|
|
|
|
text: store,
|
|
|
|
'media-set-uuid': entry['media-set-uuid'],
|
|
|
|
iconCls: 'fa fa-database',
|
|
|
|
tapes: {},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stores[store].tapes[tape] === undefined) {
|
|
|
|
stores[store].tapes[tape] = {
|
2021-02-16 11:48:12 +00:00
|
|
|
text: tape,
|
|
|
|
'media-set-uuid': entry['media-set-uuid'],
|
|
|
|
'seq-nr': entry['seq-nr'],
|
|
|
|
iconCls: 'pbs-icon-tape',
|
|
|
|
expanded: true,
|
|
|
|
children: [],
|
|
|
|
};
|
|
|
|
}
|
2021-03-01 13:10:31 +00:00
|
|
|
let [type, group, _id] = PBS.Utils.parse_snapshot_id(entry.snapshot);
|
|
|
|
|
2021-03-17 12:18:40 +00:00
|
|
|
let children = stores[store].tapes[tape].children;
|
2021-03-01 13:10:31 +00:00
|
|
|
let text = `${type}/${group}`;
|
|
|
|
if (children.length < 1 || children[children.length - 1].text !== text) {
|
|
|
|
children.push({
|
|
|
|
text,
|
|
|
|
'media-set-uuid': entry['media-set-uuid'],
|
|
|
|
leaf: false,
|
2021-05-21 10:20:21 +00:00
|
|
|
restore: true,
|
|
|
|
prefilter: {
|
|
|
|
store,
|
|
|
|
snapshot: `${type}/${group}/`,
|
|
|
|
},
|
|
|
|
'media-set': media_set,
|
2021-03-01 13:10:31 +00:00
|
|
|
iconCls: `fa ${iconCls}`,
|
|
|
|
children: [],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
children[children.length - 1].children.push(entry);
|
2021-02-16 11:48:12 +00:00
|
|
|
}
|
|
|
|
|
2021-03-17 12:18:40 +00:00
|
|
|
let storeList = Object.values(stores);
|
2021-03-25 10:04:40 +00:00
|
|
|
let storeNameList = Object.keys(stores);
|
2021-03-17 12:18:40 +00:00
|
|
|
let expand = storeList.length === 1;
|
|
|
|
for (const store of storeList) {
|
|
|
|
store.children = Object.values(store.tapes);
|
|
|
|
store.expanded = expand;
|
|
|
|
delete store.tapes;
|
|
|
|
node.appendChild(store);
|
2021-02-08 09:17:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (list.result.data.length === 0) {
|
|
|
|
node.set('leaf', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
node.set('loaded', true);
|
2021-03-25 10:04:40 +00:00
|
|
|
node.set('datastores', storeNameList);
|
2021-02-08 09:17:59 +00:00
|
|
|
Proxmox.Utils.setErrorMask(view, false);
|
|
|
|
node.expand();
|
|
|
|
} catch (error) {
|
2021-02-16 08:35:26 +00:00
|
|
|
Proxmox.Utils.setErrorMask(view, false);
|
|
|
|
Ext.Msg.alert('Error', error.toString());
|
2021-02-08 09:17:59 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeExpand: function(node, e) {
|
|
|
|
let me = this;
|
|
|
|
if (node.isLoaded()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
me.loadMediaSet(node);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
2021-01-28 11:59:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
listeners: {
|
|
|
|
activate: 'reload',
|
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
|
|
|
data: [],
|
2021-02-02 13:00:36 +00:00
|
|
|
sorters: function(a, b) {
|
2021-02-08 09:17:59 +00:00
|
|
|
if (a.data.is_media_set && b.data.is_media_set) {
|
|
|
|
return a.data['media-set-ctime'] - b.data['media-set-ctime'];
|
2021-02-02 13:00:36 +00:00
|
|
|
} else {
|
|
|
|
return a.data.text.localeCompare(b.data.text);
|
|
|
|
}
|
|
|
|
},
|
2021-01-28 11:59:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
rootVisible: false,
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
text: gettext('Reload'),
|
|
|
|
handler: 'reload',
|
|
|
|
},
|
|
|
|
'-',
|
|
|
|
{
|
|
|
|
text: gettext('New Backup'),
|
|
|
|
handler: 'backup',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
xtype: 'treecolumn',
|
2021-02-08 09:17:59 +00:00
|
|
|
text: gettext('Pool/Media Set/Snapshot'),
|
2021-02-02 13:00:36 +00:00
|
|
|
dataIndex: 'text',
|
|
|
|
sortable: false,
|
2021-01-28 11:59:47 +00:00
|
|
|
flex: 3,
|
|
|
|
},
|
2021-05-14 12:59:20 +00:00
|
|
|
{
|
|
|
|
header: gettext('Actions'),
|
|
|
|
xtype: 'actioncolumn',
|
|
|
|
items: [
|
|
|
|
{
|
2021-05-21 13:18:54 +00:00
|
|
|
handler: 'restoreBackups',
|
2021-05-14 12:59:20 +00:00
|
|
|
tooltip: gettext('Restore'),
|
|
|
|
getClass: (v, m, rec) => rec.data.restore ? 'fa fa-fw fa-undo' : 'pmx-hidden',
|
|
|
|
isDisabled: (v, r, c, i, rec) => !rec.data.restore,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-02-08 09:17:59 +00:00
|
|
|
{
|
2021-03-04 16:09:57 +00:00
|
|
|
text: gettext('Tapes'),
|
2021-02-08 09:17:59 +00:00
|
|
|
dataIndex: 'tapes',
|
|
|
|
sortable: false,
|
|
|
|
},
|
|
|
|
{
|
2021-03-04 16:09:57 +00:00
|
|
|
text: gettext('Seq. Nr.'),
|
2021-02-08 09:17:59 +00:00
|
|
|
dataIndex: 'seq-nr',
|
|
|
|
sortable: false,
|
|
|
|
},
|
2021-01-28 11:59:47 +00:00
|
|
|
{
|
2021-02-02 13:00:36 +00:00
|
|
|
text: gettext('Media Set UUID'),
|
2021-02-08 09:17:59 +00:00
|
|
|
dataIndex: 'media-set-uuid',
|
2021-03-04 16:09:57 +00:00
|
|
|
hidden: true,
|
2021-02-02 13:00:36 +00:00
|
|
|
sortable: false,
|
2021-03-04 16:09:57 +00:00
|
|
|
width: 280,
|
2021-01-28 11:59:47 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|