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();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
restore: function(button, record) {
|
2021-01-28 11:59:47 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
2021-02-02 13:00:36 +00:00
|
|
|
let selection = view.getSelection();
|
|
|
|
if (!selection || selection.length < 1) {
|
|
|
|
return;
|
|
|
|
}
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
let mediaset = selection[0].data.text;
|
|
|
|
let uuid = selection[0].data.uuid;
|
|
|
|
Ext.create('PBS.TapeManagement.TapeRestoreWindow', {
|
|
|
|
mediaset,
|
|
|
|
uuid,
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
loadContent: async function() {
|
|
|
|
let content_response = await PBS.Async.api2({
|
|
|
|
url: '/api2/extjs/tape/media/content',
|
|
|
|
});
|
|
|
|
let data = {};
|
|
|
|
|
|
|
|
for (const entry of content_response.result.data) {
|
|
|
|
let pool = entry.pool;
|
|
|
|
let [type, group_id, id] = PBS.Utils.parse_snapshot_id(entry.snapshot);
|
|
|
|
let group = `${type}/${group_id}`;
|
|
|
|
let media_set = entry['media-set-name'];
|
|
|
|
let uuid = entry['media-set-uuid'];
|
|
|
|
let ctime = entry['media-set-ctime'];
|
|
|
|
if (data[pool] === undefined) {
|
|
|
|
data[pool] = {};
|
|
|
|
}
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
if (data[pool][group] === undefined) {
|
|
|
|
data[pool][group] = {};
|
|
|
|
}
|
2021-01-28 11:59:47 +00:00
|
|
|
|
2021-02-02 13:00:36 +00:00
|
|
|
if (data[pool][group][id] === undefined) {
|
|
|
|
data[pool][group][id] = [];
|
|
|
|
}
|
|
|
|
data[pool][group][id].push({
|
|
|
|
text: media_set,
|
|
|
|
uuid,
|
|
|
|
ctime,
|
|
|
|
leaf: true,
|
2021-01-28 11:59:47 +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
|
|
|
let list = [];
|
|
|
|
|
|
|
|
for (const [pool, groups] of Object.entries(data)) {
|
|
|
|
let pool_entry = {
|
|
|
|
text: pool,
|
|
|
|
leaf: false,
|
|
|
|
children: [],
|
|
|
|
};
|
|
|
|
for (const [group, ids] of Object.entries(groups)) {
|
|
|
|
let group_entry = {
|
|
|
|
text: group,
|
|
|
|
iconCls: "fa " + PBS.Utils.get_type_icon_cls(group),
|
|
|
|
leaf: false,
|
|
|
|
children: [],
|
|
|
|
};
|
|
|
|
for (const [id, media_sets] of Object.entries(ids)) {
|
|
|
|
let id_entry = {
|
|
|
|
text: `${group}/${id}`,
|
|
|
|
leaf: false,
|
|
|
|
children: media_sets,
|
|
|
|
};
|
|
|
|
group_entry.children.push(id_entry);
|
2021-01-28 11:59:47 +00:00
|
|
|
}
|
2021-02-02 13:00:36 +00:00
|
|
|
pool_entry.children.push(group_entry);
|
2021-01-28 11:59:47 +00:00
|
|
|
}
|
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());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
listeners: {
|
|
|
|
activate: 'reload',
|
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
|
|
|
data: [],
|
2021-02-02 13:00:36 +00:00
|
|
|
sorters: function(a, b) {
|
|
|
|
if (a.data.leaf && b.data.leaf) {
|
|
|
|
return a.data.ctime - b.data.ctime;
|
|
|
|
} 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',
|
|
|
|
},
|
2021-02-02 13:00:38 +00:00
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
disabled: true,
|
|
|
|
text: gettext('Restore Media Set'),
|
|
|
|
handler: 'restore',
|
|
|
|
parentXType: 'treepanel',
|
|
|
|
enableFn: (rec) => !!rec.data.uuid,
|
|
|
|
},
|
2021-01-28 11:59:47 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
xtype: 'treecolumn',
|
2021-02-02 13:00:36 +00:00
|
|
|
text: gettext('Pool/Group/Snapshot/Media Set'),
|
|
|
|
dataIndex: 'text',
|
|
|
|
sortable: false,
|
2021-01-28 11:59:47 +00:00
|
|
|
flex: 3,
|
|
|
|
},
|
|
|
|
{
|
2021-02-02 13:00:36 +00:00
|
|
|
text: gettext('Media Set UUID'),
|
|
|
|
dataIndex: 'uuid',
|
|
|
|
sortable: false,
|
2021-01-28 11:59:47 +00:00
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|