2020-03-26 10:17:15 +00:00
|
|
|
Ext.define('pbs-data-store-snapshots', {
|
2019-12-20 11:46:09 +00:00
|
|
|
extend: 'Ext.data.Model',
|
2019-12-20 16:04:45 +00:00
|
|
|
fields: [
|
|
|
|
'backup-type',
|
2019-12-22 09:43:57 +00:00
|
|
|
'backup-id',
|
|
|
|
{
|
2020-03-25 14:17:28 +00:00
|
|
|
name: 'backup-time',
|
2019-12-22 09:43:57 +00:00
|
|
|
type: 'date',
|
2020-09-02 07:15:53 +00:00
|
|
|
dateFormat: 'timestamp',
|
2019-12-22 09:43:57 +00:00
|
|
|
},
|
2020-10-28 17:25:47 +00:00
|
|
|
'comment',
|
2019-12-20 16:04:45 +00:00
|
|
|
'files',
|
2020-05-29 13:09:01 +00:00
|
|
|
'owner',
|
2020-08-25 15:30:28 +00:00
|
|
|
'verification',
|
2020-11-20 16:38:43 +00:00
|
|
|
'fingerprint',
|
2020-09-02 07:15:53 +00:00
|
|
|
{ name: 'size', type: 'int', allowNull: true },
|
2020-06-18 11:55:25 +00:00
|
|
|
{
|
2020-07-08 11:32:20 +00:00
|
|
|
name: 'crypt-mode',
|
2020-06-23 10:09:46 +00:00
|
|
|
type: 'boolean',
|
2020-06-18 11:55:25 +00:00
|
|
|
calculate: function(data) {
|
2020-07-08 11:32:20 +00:00
|
|
|
let crypt = {
|
|
|
|
none: 0,
|
|
|
|
mixed: 0,
|
|
|
|
'sign-only': 0,
|
|
|
|
encrypt: 0,
|
2020-07-09 14:50:24 +00:00
|
|
|
count: 0,
|
2020-07-08 11:32:20 +00:00
|
|
|
};
|
2020-06-18 11:55:25 +00:00
|
|
|
data.files.forEach(file => {
|
|
|
|
if (file.filename === 'index.json.blob') return; // is never encrypted
|
2020-07-08 11:32:20 +00:00
|
|
|
let mode = PBS.Utils.cryptmap.indexOf(file['crypt-mode']);
|
|
|
|
if (mode !== -1) {
|
|
|
|
crypt[file['crypt-mode']]++;
|
2020-09-01 09:05:20 +00:00
|
|
|
crypt.count++;
|
2020-06-18 11:55:25 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-07-09 14:50:24 +00:00
|
|
|
return PBS.Utils.calculateCryptMode(crypt);
|
2020-09-02 07:15:53 +00:00
|
|
|
},
|
2020-07-23 11:03:50 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'matchesFilter',
|
|
|
|
type: 'boolean',
|
|
|
|
defaultValue: true,
|
|
|
|
},
|
2020-09-02 07:15:53 +00:00
|
|
|
],
|
2019-12-20 11:46:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.DataStoreContent', {
|
2020-03-25 14:17:28 +00:00
|
|
|
extend: 'Ext.tree.Panel',
|
2019-12-20 11:46:09 +00:00
|
|
|
alias: 'widget.pbsDataStoreContent',
|
2022-05-06 07:27:11 +00:00
|
|
|
mixins: ['Proxmox.Mixin.CBind'],
|
2019-12-20 11:46:09 +00:00
|
|
|
|
2020-03-25 14:17:28 +00:00
|
|
|
rootVisible: false,
|
2019-12-22 09:43:57 +00:00
|
|
|
|
2020-05-20 10:15:38 +00:00
|
|
|
title: gettext('Content'),
|
|
|
|
|
2019-12-20 16:17:44 +00:00
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
|
|
|
init: function(view) {
|
|
|
|
if (!view.datastore) {
|
|
|
|
throw "no datastore specified";
|
|
|
|
}
|
|
|
|
|
2020-05-26 10:46:45 +00:00
|
|
|
this.store = Ext.create('Ext.data.Store', {
|
2020-03-26 10:17:15 +00:00
|
|
|
model: 'pbs-data-store-snapshots',
|
2020-03-25 14:17:28 +00:00
|
|
|
groupField: 'backup-group',
|
|
|
|
});
|
2020-05-26 10:46:45 +00:00
|
|
|
this.store.on('load', this.onLoad, this);
|
2020-03-25 14:17:28 +00:00
|
|
|
|
2020-06-23 10:09:47 +00:00
|
|
|
view.getStore().setSorters([
|
|
|
|
'backup-group',
|
|
|
|
'text',
|
2020-09-02 07:15:53 +00:00
|
|
|
'backup-time',
|
2020-06-23 10:09:47 +00:00
|
|
|
]);
|
2020-06-25 08:45:47 +00:00
|
|
|
Proxmox.Utils.monStoreErrors(view, this.store);
|
2019-12-20 16:17:44 +00:00
|
|
|
},
|
|
|
|
|
2022-05-06 07:27:11 +00:00
|
|
|
control: {
|
|
|
|
'pbsNamespaceSelector': {
|
|
|
|
change: 'nsChange',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
nsChange: function(field, value) {
|
|
|
|
let view = this.getView();
|
|
|
|
view.namespace = value;
|
|
|
|
this.reload();
|
|
|
|
},
|
|
|
|
|
2019-12-20 16:17:44 +00:00
|
|
|
reload: function() {
|
2020-05-26 10:46:45 +00:00
|
|
|
let view = this.getView();
|
|
|
|
|
|
|
|
if (!view.store || !this.store) {
|
|
|
|
console.warn('cannot reload, no store(s)');
|
|
|
|
return;
|
|
|
|
}
|
2019-12-20 16:17:44 +00:00
|
|
|
|
2020-03-25 14:17:28 +00:00
|
|
|
let url = `/api2/json/admin/datastore/${view.datastore}/snapshots`;
|
2022-05-06 07:27:11 +00:00
|
|
|
if (view.namespace && view.namespace !== '') {
|
|
|
|
url += `?backup-ns=${encodeURIComponent(view.namespace)}`;
|
|
|
|
}
|
2020-05-26 10:46:45 +00:00
|
|
|
this.store.setProxy({
|
2019-12-20 16:17:44 +00:00
|
|
|
type: 'proxmox',
|
2020-07-01 11:46:00 +00:00
|
|
|
timeout: 300*1000, // 5 minutes, we should make that api call faster
|
2020-09-02 07:15:53 +00:00
|
|
|
url: url,
|
2019-12-20 16:17:44 +00:00
|
|
|
});
|
2020-03-25 14:17:28 +00:00
|
|
|
|
2020-05-26 10:46:45 +00:00
|
|
|
this.store.load();
|
|
|
|
},
|
2020-03-25 14:17:28 +00:00
|
|
|
|
2020-05-26 10:46:45 +00:00
|
|
|
getRecordGroups: function(records) {
|
|
|
|
let groups = {};
|
|
|
|
|
|
|
|
for (const item of records) {
|
|
|
|
var btype = item.data["backup-type"];
|
|
|
|
let group = btype + "/" + item.data["backup-id"];
|
|
|
|
|
|
|
|
if (groups[group] !== undefined) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-02-02 13:00:35 +00:00
|
|
|
var cls = PBS.Utils.get_type_icon_cls(btype);
|
|
|
|
if (cls === "") {
|
2020-05-30 14:37:33 +00:00
|
|
|
console.warn(`got unknown backup-type '${btype}'`);
|
2020-05-26 10:46:45 +00:00
|
|
|
continue; // FIXME: auto render? what do?
|
|
|
|
}
|
|
|
|
|
|
|
|
groups[group] = {
|
|
|
|
text: group,
|
|
|
|
leaf: false,
|
|
|
|
iconCls: "fa " + cls,
|
|
|
|
expanded: false,
|
|
|
|
backup_type: item.data["backup-type"],
|
|
|
|
backup_id: item.data["backup-id"],
|
2020-09-02 07:15:53 +00:00
|
|
|
children: [],
|
2020-03-26 17:01:04 +00:00
|
|
|
};
|
2020-05-26 10:46:45 +00:00
|
|
|
}
|
2020-03-26 17:01:04 +00:00
|
|
|
|
2020-05-26 10:46:45 +00:00
|
|
|
return groups;
|
|
|
|
},
|
2020-03-25 14:17:28 +00:00
|
|
|
|
2021-07-12 05:54:41 +00:00
|
|
|
updateGroupNotes: async function(view) {
|
|
|
|
try {
|
|
|
|
let { result: { data: groups } } = await Proxmox.Async.api2({
|
|
|
|
url: `/api2/extjs/admin/datastore/${view.datastore}/groups`,
|
|
|
|
});
|
|
|
|
let map = {};
|
|
|
|
for (const group of groups) {
|
|
|
|
map[`${group["backup-type"]}/${group["backup-id"]}`] = group.comment;
|
|
|
|
}
|
|
|
|
view.getRootNode().cascade(node => {
|
|
|
|
if (node.parentNode && node.parentNode.id === 'root') {
|
|
|
|
let group = `${node.data.backup_type}/${node.data.backup_id}`;
|
|
|
|
node.set('comment', map[group], { dirty: false });
|
2021-07-08 14:45:28 +00:00
|
|
|
}
|
2021-07-12 05:54:41 +00:00
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
console.debug(err);
|
|
|
|
}
|
2021-07-08 14:45:28 +00:00
|
|
|
},
|
|
|
|
|
2020-06-25 08:45:47 +00:00
|
|
|
onLoad: function(store, records, success, operation) {
|
2020-07-23 11:03:50 +00:00
|
|
|
let me = this;
|
2020-05-26 10:46:45 +00:00
|
|
|
let view = this.getView();
|
|
|
|
|
|
|
|
if (!success) {
|
2020-06-25 08:45:47 +00:00
|
|
|
Proxmox.Utils.setErrorMask(view, Proxmox.Utils.getResponseErrorMessage(operation.getError()));
|
2020-05-26 10:46:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let groups = this.getRecordGroups(records);
|
2020-03-25 14:17:28 +00:00
|
|
|
|
2020-07-23 11:03:51 +00:00
|
|
|
let selected;
|
|
|
|
let expanded = {};
|
|
|
|
|
|
|
|
view.getSelection().some(function(item) {
|
|
|
|
let id = item.data.text;
|
|
|
|
if (item.data.leaf) {
|
|
|
|
id = item.parentNode.data.text + id;
|
|
|
|
}
|
|
|
|
selected = id;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
view.getRootNode().cascadeBy({
|
|
|
|
before: item => {
|
|
|
|
if (item.isExpanded() && !item.data.leaf) {
|
|
|
|
let id = item.data.text;
|
|
|
|
expanded[id] = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2020-09-02 07:15:53 +00:00
|
|
|
after: Ext.emptyFn,
|
2020-07-23 11:03:51 +00:00
|
|
|
});
|
|
|
|
|
2020-05-26 10:46:45 +00:00
|
|
|
for (const item of records) {
|
|
|
|
let group = item.data["backup-type"] + "/" + item.data["backup-id"];
|
|
|
|
let children = groups[group].children;
|
|
|
|
|
|
|
|
let data = item.data;
|
|
|
|
|
2020-05-26 16:16:38 +00:00
|
|
|
data.text = group + '/' + PBS.Utils.render_datetime_utc(data["backup-time"]);
|
2020-07-23 11:03:49 +00:00
|
|
|
data.leaf = false;
|
2020-05-26 10:46:45 +00:00
|
|
|
data.cls = 'no-leaf-icons';
|
2020-07-23 11:03:50 +00:00
|
|
|
data.matchesFilter = true;
|
2020-05-26 10:46:45 +00:00
|
|
|
|
2020-07-23 11:03:51 +00:00
|
|
|
data.expanded = !!expanded[data.text];
|
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
data.children = [];
|
|
|
|
for (const file of data.files) {
|
2020-09-01 09:05:21 +00:00
|
|
|
file.text = file.filename;
|
2020-07-23 11:03:49 +00:00
|
|
|
file['crypt-mode'] = PBS.Utils.cryptmap.indexOf(file['crypt-mode']);
|
2020-11-20 16:38:43 +00:00
|
|
|
file.fingerprint = data.fingerprint;
|
2020-07-23 11:03:49 +00:00
|
|
|
file.leaf = true;
|
2020-07-23 11:03:50 +00:00
|
|
|
file.matchesFilter = true;
|
2020-07-23 11:03:49 +00:00
|
|
|
|
|
|
|
data.children.push(file);
|
|
|
|
}
|
|
|
|
|
2020-05-26 10:46:45 +00:00
|
|
|
children.push(data);
|
|
|
|
}
|
|
|
|
|
2020-09-02 07:13:37 +00:00
|
|
|
let nowSeconds = Date.now() / 1000;
|
2020-05-26 10:46:45 +00:00
|
|
|
let children = [];
|
2020-07-23 11:03:51 +00:00
|
|
|
for (const [name, group] of Object.entries(groups)) {
|
2020-05-26 10:46:45 +00:00
|
|
|
let last_backup = 0;
|
2020-07-08 11:32:20 +00:00
|
|
|
let crypt = {
|
|
|
|
none: 0,
|
|
|
|
mixed: 0,
|
|
|
|
'sign-only': 0,
|
2020-07-09 14:50:24 +00:00
|
|
|
encrypt: 0,
|
2020-07-08 11:32:20 +00:00
|
|
|
};
|
2020-09-02 07:13:37 +00:00
|
|
|
let verify = {
|
|
|
|
outdated: 0,
|
|
|
|
none: 0,
|
|
|
|
failed: 0,
|
|
|
|
ok: 0,
|
|
|
|
};
|
|
|
|
for (let item of group.children) {
|
2020-07-08 11:32:20 +00:00
|
|
|
crypt[PBS.Utils.cryptmap[item['crypt-mode']]]++;
|
2020-07-08 10:09:09 +00:00
|
|
|
if (item["backup-time"] > last_backup && item.size !== null) {
|
2020-05-26 10:46:45 +00:00
|
|
|
last_backup = item["backup-time"];
|
|
|
|
group["backup-time"] = last_backup;
|
|
|
|
group.files = item.files;
|
|
|
|
group.size = item.size;
|
2020-05-29 13:09:01 +00:00
|
|
|
group.owner = item.owner;
|
2020-09-02 07:12:05 +00:00
|
|
|
verify.lastFailed = item.verification && item.verification.state !== 'ok';
|
2020-05-26 10:46:45 +00:00
|
|
|
}
|
2020-09-02 07:13:37 +00:00
|
|
|
if (!item.verification) {
|
|
|
|
verify.none++;
|
|
|
|
} else {
|
|
|
|
if (item.verification.state === 'ok') {
|
|
|
|
verify.ok++;
|
|
|
|
} else {
|
|
|
|
verify.failed++;
|
|
|
|
}
|
|
|
|
let task = Proxmox.Utils.parse_task_upid(item.verification.upid);
|
|
|
|
item.verification.lastTime = task.starttime;
|
|
|
|
if (nowSeconds - task.starttime > 30 * 24 * 60 * 60) {
|
|
|
|
verify.outdated++;
|
|
|
|
}
|
2020-08-25 15:30:28 +00:00
|
|
|
}
|
2020-05-26 10:46:45 +00:00
|
|
|
}
|
2020-09-02 07:13:37 +00:00
|
|
|
group.verification = verify;
|
2020-05-26 10:46:45 +00:00
|
|
|
group.count = group.children.length;
|
2020-07-23 11:03:50 +00:00
|
|
|
group.matchesFilter = true;
|
2020-07-09 14:50:24 +00:00
|
|
|
crypt.count = group.count;
|
|
|
|
group['crypt-mode'] = PBS.Utils.calculateCryptMode(crypt);
|
2020-07-23 11:03:51 +00:00
|
|
|
group.expanded = !!expanded[name];
|
2020-05-26 10:46:45 +00:00
|
|
|
children.push(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
view.setRootNode({
|
|
|
|
expanded: true,
|
2020-09-02 07:15:53 +00:00
|
|
|
children: children,
|
2020-05-26 10:46:45 +00:00
|
|
|
});
|
2020-07-23 11:03:51 +00:00
|
|
|
|
2021-10-01 09:56:55 +00:00
|
|
|
if (!children.length) {
|
|
|
|
view.setEmptyText(gettext('No Snapshots found'));
|
|
|
|
}
|
|
|
|
|
2021-07-08 14:45:28 +00:00
|
|
|
this.updateGroupNotes(view);
|
|
|
|
|
2020-07-23 11:03:51 +00:00
|
|
|
if (selected !== undefined) {
|
|
|
|
let selection = view.getRootNode().findChildBy(function(item) {
|
|
|
|
let id = item.data.text;
|
|
|
|
if (item.data.leaf) {
|
|
|
|
id = item.parentNode.data.text + id;
|
|
|
|
}
|
|
|
|
return selected === id;
|
|
|
|
}, undefined, true);
|
2020-07-28 12:32:10 +00:00
|
|
|
if (selection) {
|
|
|
|
view.setSelection(selection);
|
|
|
|
view.getView().focusRow(selection);
|
|
|
|
}
|
2020-07-23 11:03:51 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 08:45:47 +00:00
|
|
|
Proxmox.Utils.setErrorMask(view, false);
|
2020-07-23 11:03:50 +00:00
|
|
|
if (view.getStore().getFilters().length > 0) {
|
|
|
|
let searchBox = me.lookup("searchbox");
|
2020-09-02 07:15:53 +00:00
|
|
|
let searchvalue = searchBox.getValue();
|
2020-07-23 11:03:50 +00:00
|
|
|
me.search(searchBox, searchvalue);
|
|
|
|
}
|
2019-12-20 16:17:44 +00:00
|
|
|
},
|
2020-03-26 16:23:51 +00:00
|
|
|
|
2020-11-03 08:30:54 +00:00
|
|
|
onChangeOwner: function(view, rI, cI, item, e, rec) {
|
|
|
|
view = this.getView();
|
|
|
|
|
|
|
|
if (!rec || !rec.data || rec.parentNode.id !== 'root' || !view.datastore) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let data = rec.data;
|
|
|
|
|
|
|
|
let win = Ext.create('PBS.BackupGroupChangeOwner', {
|
|
|
|
datastore: view.datastore,
|
|
|
|
backup_type: data.backup_type,
|
|
|
|
backup_id: data.backup_id,
|
2020-11-06 06:40:09 +00:00
|
|
|
owner: data.owner,
|
2020-11-03 08:30:54 +00:00
|
|
|
autoShow: true,
|
|
|
|
});
|
|
|
|
win.on('destroy', this.reload, this);
|
|
|
|
},
|
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
onPrune: function(view, rI, cI, item, e, rec) {
|
2020-09-02 07:15:53 +00:00
|
|
|
view = this.getView();
|
2020-03-26 16:23:51 +00:00
|
|
|
|
|
|
|
if (!(rec && rec.data)) return;
|
|
|
|
let data = rec.data;
|
2020-07-23 11:03:49 +00:00
|
|
|
if (rec.parentNode.id !== 'root') return;
|
2020-03-26 16:23:51 +00:00
|
|
|
|
|
|
|
if (!view.datastore) return;
|
|
|
|
|
|
|
|
let win = Ext.create('PBS.DataStorePrune', {
|
|
|
|
datastore: view.datastore,
|
|
|
|
backup_type: data.backup_type,
|
|
|
|
backup_id: data.backup_id,
|
|
|
|
});
|
|
|
|
win.on('destroy', this.reload, this);
|
|
|
|
win.show();
|
2020-06-23 10:09:48 +00:00
|
|
|
},
|
|
|
|
|
2020-10-27 15:20:05 +00:00
|
|
|
verifyAll: function() {
|
|
|
|
var view = this.getView();
|
|
|
|
|
|
|
|
Proxmox.Utils.API2Request({
|
|
|
|
url: `/admin/datastore/${view.datastore}/verify`,
|
|
|
|
method: 'POST',
|
|
|
|
failure: function(response) {
|
|
|
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
|
|
|
},
|
|
|
|
success: function(response, options) {
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
upid: response.result.data,
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-07-16 08:53:27 +00:00
|
|
|
pruneAll: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
|
|
|
if (!view.datastore) return;
|
|
|
|
|
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
title: `Prune Datastore '${view.datastore}'`,
|
|
|
|
onlineHelp: 'maintenance_pruning',
|
|
|
|
|
|
|
|
method: 'POST',
|
|
|
|
submitText: "Prune",
|
|
|
|
autoShow: true,
|
|
|
|
isCreate: true,
|
|
|
|
showTaskViewer: true,
|
|
|
|
|
|
|
|
taskDone: () => me.reload(),
|
|
|
|
|
|
|
|
url: `/api2/extjs/admin/datastore/${view.datastore}/prune-datastore`,
|
|
|
|
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'pbsPruneInputPanel',
|
|
|
|
dryrun: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2022-05-06 09:02:59 +00:00
|
|
|
addNS: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
if (!view.datastore) return;
|
|
|
|
|
|
|
|
Ext.create('PBS.window.NamespaceEdit', {
|
|
|
|
autoShow: true,
|
|
|
|
datastore: view.datastore,
|
|
|
|
listeners: {
|
|
|
|
destroy: () => view.down('pbsNamespaceSelector').store?.load(),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
onVerify: function(view, rI, cI, item, e, rec) {
|
2020-09-01 16:27:30 +00:00
|
|
|
let me = this;
|
|
|
|
view = me.getView();
|
2020-06-30 11:22:02 +00:00
|
|
|
|
|
|
|
if (!view.datastore) return;
|
|
|
|
|
|
|
|
if (!(rec && rec.data)) return;
|
|
|
|
let data = rec.data;
|
|
|
|
|
|
|
|
let params;
|
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
if (rec.parentNode.id !== 'root') {
|
2020-06-30 11:22:02 +00:00
|
|
|
params = {
|
|
|
|
"backup-type": data["backup-type"],
|
|
|
|
"backup-id": data["backup-id"],
|
|
|
|
"backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
|
2022-01-27 14:13:20 +00:00
|
|
|
"outdated-after": 0, // always reverify single snapshots
|
2020-06-30 11:22:02 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
params = {
|
|
|
|
"backup-type": data.backup_type,
|
|
|
|
"backup-id": data.backup_id,
|
2022-01-27 14:13:20 +00:00
|
|
|
"outdated-after": 29, // reverify after 29 days so match with the "old" display
|
2020-06-30 11:22:02 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
Proxmox.Utils.API2Request({
|
|
|
|
params: params,
|
|
|
|
url: `/admin/datastore/${view.datastore}/verify`,
|
|
|
|
method: 'POST',
|
|
|
|
failure: function(response) {
|
|
|
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
|
|
|
},
|
|
|
|
success: function(response, options) {
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
upid: response.result.data,
|
2020-09-01 16:27:30 +00:00
|
|
|
taskDone: () => me.reload(),
|
2020-06-30 11:22:02 +00:00
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-07-08 14:45:28 +00:00
|
|
|
onNotesEdit: function(view, data, isGroup) {
|
2020-10-28 17:25:47 +00:00
|
|
|
let me = this;
|
|
|
|
|
2021-07-08 14:45:28 +00:00
|
|
|
let url = `/admin/datastore/${view.datastore}/`;
|
|
|
|
url += isGroup ? 'group-notes' : 'notes';
|
|
|
|
|
|
|
|
let params;
|
|
|
|
if (isGroup) {
|
|
|
|
params = {
|
|
|
|
"backup-type": data.backup_type,
|
|
|
|
"backup-id": data.backup_id,
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
params = {
|
|
|
|
"backup-type": data["backup-type"],
|
|
|
|
"backup-id": data["backup-id"],
|
|
|
|
"backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-28 17:25:47 +00:00
|
|
|
Ext.create('PBS.window.NotesEdit', {
|
|
|
|
url: url,
|
|
|
|
autoShow: true,
|
|
|
|
apiCallDone: () => me.reload(), // FIXME: do something more efficient?
|
2021-07-08 14:45:28 +00:00
|
|
|
extraRequestParams: params,
|
2020-10-28 17:25:47 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-05-17 07:03:15 +00:00
|
|
|
forgetGroup: function(data) {
|
2020-07-23 11:03:49 +00:00
|
|
|
let me = this;
|
2021-05-17 07:03:15 +00:00
|
|
|
let view = me.getView();
|
2020-06-26 13:58:06 +00:00
|
|
|
|
2021-05-17 07:03:15 +00:00
|
|
|
Ext.create('Proxmox.window.SafeDestroy', {
|
|
|
|
url: `/admin/datastore/${view.datastore}/groups`,
|
|
|
|
params: {
|
2021-05-14 14:36:03 +00:00
|
|
|
"backup-type": data.backup_type,
|
|
|
|
"backup-id": data.backup_id,
|
2021-05-17 07:03:15 +00:00
|
|
|
},
|
|
|
|
item: {
|
|
|
|
id: data.text,
|
|
|
|
},
|
|
|
|
autoShow: true,
|
|
|
|
taskName: 'forget-group',
|
|
|
|
listeners: {
|
|
|
|
destroy: () => me.reload(),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
forgetSnapshot: function(data) {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
2021-05-14 14:36:03 +00:00
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
Ext.Msg.show({
|
|
|
|
title: gettext('Confirm'),
|
|
|
|
icon: Ext.Msg.WARNING,
|
2021-05-17 07:03:15 +00:00
|
|
|
message: Ext.String.format(gettext('Are you sure you want to remove snapshot {0}'), `'${data.text}'`),
|
2020-07-23 11:03:49 +00:00
|
|
|
buttons: Ext.Msg.YESNO,
|
|
|
|
defaultFocus: 'no',
|
|
|
|
callback: function(btn) {
|
|
|
|
if (btn !== 'yes') {
|
|
|
|
return;
|
|
|
|
}
|
2020-06-26 13:58:06 +00:00
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
Proxmox.Utils.API2Request({
|
2021-05-17 07:03:15 +00:00
|
|
|
url: `/admin/datastore/${view.datastore}/snapshots`,
|
|
|
|
params: {
|
|
|
|
"backup-type": data["backup-type"],
|
|
|
|
"backup-id": data["backup-id"],
|
|
|
|
"backup-time": (data['backup-time'].getTime()/1000).toFixed(0),
|
|
|
|
},
|
2020-07-23 11:03:49 +00:00
|
|
|
method: 'DELETE',
|
|
|
|
waitMsgTarget: view,
|
|
|
|
failure: function(response, opts) {
|
|
|
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
|
|
|
},
|
|
|
|
callback: me.reload.bind(me),
|
|
|
|
});
|
2020-06-26 13:58:06 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-10-27 11:22:37 +00:00
|
|
|
onProtectionChange: function(view, rI, cI, item, e, rec) {
|
|
|
|
let me = this;
|
|
|
|
view = this.getView();
|
|
|
|
|
|
|
|
if (!(rec && rec.data)) return;
|
|
|
|
let data = rec.data;
|
|
|
|
if (!view.datastore) return;
|
|
|
|
|
|
|
|
let type = data["backup-type"];
|
|
|
|
let id = data["backup-id"];
|
|
|
|
let time = (data["backup-time"].getTime()/1000).toFixed(0);
|
|
|
|
|
|
|
|
let params = {
|
|
|
|
'backup-type': type,
|
|
|
|
'backup-id': id,
|
|
|
|
'backup-time': time,
|
|
|
|
};
|
|
|
|
|
|
|
|
let url = `/api2/extjs/admin/datastore/${view.datastore}/protected`;
|
|
|
|
|
|
|
|
Ext.create('Proxmox.window.Edit', {
|
|
|
|
subject: gettext('Protection') + ` - ${data.text}`,
|
|
|
|
width: 400,
|
|
|
|
|
|
|
|
method: 'PUT',
|
|
|
|
autoShow: true,
|
|
|
|
isCreate: false,
|
|
|
|
autoLoad: true,
|
|
|
|
|
|
|
|
loadUrl: `${url}?${Ext.Object.toQueryString(params)}`,
|
|
|
|
url,
|
|
|
|
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'hidden',
|
|
|
|
name: 'backup-type',
|
|
|
|
value: type,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'hidden',
|
|
|
|
name: 'backup-id',
|
|
|
|
value: id,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'hidden',
|
|
|
|
name: 'backup-time',
|
|
|
|
value: time,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxcheckbox',
|
|
|
|
fieldLabel: gettext('Protected'),
|
|
|
|
uncheckedValue: 0,
|
|
|
|
name: 'protected',
|
|
|
|
value: data.protected,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
listeners: {
|
|
|
|
destroy: () => me.reload(),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-05-17 07:03:15 +00:00
|
|
|
onForget: function(view, rI, cI, item, e, rec) {
|
|
|
|
let me = this;
|
|
|
|
view = this.getView();
|
|
|
|
|
|
|
|
if (!(rec && rec.data)) return;
|
|
|
|
let data = rec.data;
|
|
|
|
if (!view.datastore) return;
|
|
|
|
|
|
|
|
if (rec.parentNode.id !== 'root') {
|
|
|
|
me.forgetSnapshot(data);
|
|
|
|
} else {
|
|
|
|
me.forgetGroup(data);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
downloadFile: function(tV, rI, cI, item, e, rec) {
|
2020-06-23 10:09:48 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
|
|
|
if (!(rec && rec.data)) return;
|
2020-07-23 11:03:49 +00:00
|
|
|
let data = rec.parentNode.data;
|
|
|
|
|
|
|
|
let file = rec.data.filename;
|
|
|
|
let params = {
|
|
|
|
'backup-id': data['backup-id'],
|
|
|
|
'backup-type': data['backup-type'],
|
|
|
|
'backup-time': (data['backup-time'].getTime()/1000).toFixed(0),
|
|
|
|
'file-name': file,
|
|
|
|
};
|
|
|
|
|
|
|
|
let idx = file.lastIndexOf('.');
|
|
|
|
let filename = file.slice(0, idx);
|
|
|
|
let atag = document.createElement('a');
|
|
|
|
params['file-name'] = file;
|
|
|
|
atag.download = filename;
|
2020-09-02 07:15:53 +00:00
|
|
|
let url = new URL(`/api2/json/admin/datastore/${view.datastore}/download-decoded`,
|
|
|
|
window.location.origin);
|
2020-07-23 11:03:49 +00:00
|
|
|
for (const [key, value] of Object.entries(params)) {
|
|
|
|
url.searchParams.append(key, value);
|
|
|
|
}
|
|
|
|
atag.href = url.href;
|
|
|
|
atag.click();
|
2020-06-23 10:09:54 +00:00
|
|
|
},
|
|
|
|
|
2020-07-23 11:03:49 +00:00
|
|
|
openPxarBrowser: function(tv, rI, Ci, item, e, rec) {
|
2020-06-23 10:09:54 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
|
|
|
if (!(rec && rec.data)) return;
|
2020-07-23 11:03:49 +00:00
|
|
|
let data = rec.parentNode.data;
|
2020-06-23 10:09:54 +00:00
|
|
|
|
|
|
|
let id = data['backup-id'];
|
|
|
|
let time = data['backup-time'];
|
|
|
|
let type = data['backup-type'];
|
|
|
|
let timetext = PBS.Utils.render_datetime_utc(data["backup-time"]);
|
|
|
|
|
2021-04-01 15:34:44 +00:00
|
|
|
Ext.create('Proxmox.window.FileBrowser', {
|
2020-06-23 10:09:54 +00:00
|
|
|
title: `${type}/${id}/${timetext}`,
|
2021-04-13 07:06:30 +00:00
|
|
|
listURL: `/api2/json/admin/datastore/${view.datastore}/catalog`,
|
|
|
|
downloadURL: `/api2/json/admin/datastore/${view.datastore}/pxar-file-download`,
|
2022-04-12 11:04:18 +00:00
|
|
|
enableTar: true,
|
2021-04-01 15:34:44 +00:00
|
|
|
extraParams: {
|
|
|
|
'backup-id': id,
|
|
|
|
'backup-time': (time.getTime()/1000).toFixed(0),
|
|
|
|
'backup-type': type,
|
|
|
|
},
|
2020-07-23 11:03:49 +00:00
|
|
|
archive: rec.data.filename,
|
2020-06-23 10:09:54 +00:00
|
|
|
}).show();
|
2020-07-23 11:03:50 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
filter: function(item, value) {
|
|
|
|
if (item.data.text.indexOf(value) !== -1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.data.owner && item.data.owner.indexOf(value) !== -1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
search: function(tf, value) {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let store = view.getStore();
|
|
|
|
if (!value && value !== 0) {
|
|
|
|
store.clearFilter();
|
|
|
|
store.getRoot().collapseChildren(true);
|
|
|
|
tf.triggers.clear.setVisible(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tf.triggers.clear.setVisible(true);
|
|
|
|
if (value.length < 2) return;
|
|
|
|
Proxmox.Utils.setErrorMask(view, true);
|
|
|
|
// we do it a little bit later for the error mask to work
|
|
|
|
setTimeout(function() {
|
|
|
|
store.clearFilter();
|
|
|
|
store.getRoot().collapseChildren(true);
|
|
|
|
|
|
|
|
store.beginUpdate();
|
|
|
|
store.getRoot().cascadeBy({
|
|
|
|
before: function(item) {
|
2020-09-02 07:15:53 +00:00
|
|
|
if (me.filter(item, value)) {
|
2020-07-23 11:03:50 +00:00
|
|
|
item.set('matchesFilter', true);
|
|
|
|
if (item.parentNode && item.parentNode.id !== 'root') {
|
|
|
|
item.parentNode.childmatches = true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
after: function(item) {
|
|
|
|
if (me.filter(item, value) || item.id === 'root' || item.childmatches) {
|
|
|
|
item.set('matchesFilter', true);
|
|
|
|
if (item.parentNode && item.parentNode.id !== 'root') {
|
|
|
|
item.parentNode.childmatches = true;
|
|
|
|
}
|
|
|
|
if (item.childmatches) {
|
|
|
|
item.expand();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
item.set('matchesFilter', false);
|
|
|
|
}
|
|
|
|
delete item.childmatches;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
store.endUpdate();
|
|
|
|
|
|
|
|
store.filter((item) => !!item.get('matchesFilter'));
|
|
|
|
Proxmox.Utils.setErrorMask(view, false);
|
|
|
|
}, 10);
|
|
|
|
},
|
2019-12-20 16:17:44 +00:00
|
|
|
},
|
|
|
|
|
2021-10-01 09:56:54 +00:00
|
|
|
listeners: {
|
|
|
|
activate: function() {
|
|
|
|
let me = this;
|
|
|
|
// only load on first activate to not load every tab switch
|
|
|
|
if (!me.firstLoad) {
|
|
|
|
me.getController().reload();
|
|
|
|
me.firstLoad = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-09-02 07:12:05 +00:00
|
|
|
viewConfig: {
|
|
|
|
getRowClass: function(record, index) {
|
|
|
|
let verify = record.get('verification');
|
|
|
|
if (verify && verify.lastFailed) {
|
|
|
|
return 'proxmox-invalid-row';
|
|
|
|
}
|
2020-09-02 07:15:53 +00:00
|
|
|
return null;
|
2020-09-02 07:12:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-05-29 13:09:01 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
xtype: 'treecolumn',
|
|
|
|
header: gettext("Backup Group"),
|
|
|
|
dataIndex: 'text',
|
2021-10-27 11:22:36 +00:00
|
|
|
renderer: (value, meta, record) => {
|
|
|
|
if (record.data.protected) {
|
2021-11-22 10:21:23 +00:00
|
|
|
return `${value} (${gettext('protected')})`;
|
2021-10-27 11:22:36 +00:00
|
|
|
}
|
2021-11-22 10:21:23 +00:00
|
|
|
return value;
|
2021-10-27 11:22:36 +00:00
|
|
|
},
|
2020-09-02 07:15:53 +00:00
|
|
|
flex: 1,
|
2020-05-29 13:09:01 +00:00
|
|
|
},
|
2020-10-28 17:25:47 +00:00
|
|
|
{
|
|
|
|
text: gettext('Comment'),
|
|
|
|
dataIndex: 'comment',
|
|
|
|
flex: 1,
|
|
|
|
renderer: (v, meta, record) => {
|
|
|
|
let data = record.data;
|
2021-07-08 14:45:28 +00:00
|
|
|
if (!data || data.leaf) {
|
2020-10-28 17:25:47 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (v === undefined || v === null) {
|
|
|
|
v = '';
|
|
|
|
}
|
|
|
|
v = Ext.String.htmlEncode(v);
|
2021-07-12 05:57:37 +00:00
|
|
|
let icon = 'x-action-col-icon fa fa-fw fa-pencil pointer';
|
2020-10-28 17:25:47 +00:00
|
|
|
|
|
|
|
return `<span class="snapshot-comment-column">${v}</span>
|
2021-07-12 05:57:37 +00:00
|
|
|
<i data-qtip="${gettext('Edit')}" style="float: right; margin: 0px;" class="${icon}"></i>`;
|
2020-10-28 17:25:47 +00:00
|
|
|
},
|
|
|
|
listeners: {
|
|
|
|
afterrender: function(component) {
|
|
|
|
// a bit of a hack, but relatively easy, cheap and works out well.
|
|
|
|
// more efficient to use one handler for the whole column than for each icon
|
|
|
|
component.on('click', function(tree, cell, rowI, colI, e, rec) {
|
|
|
|
let el = e.target;
|
|
|
|
if (el.tagName !== "I" || !el.classList.contains("fa-pencil")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let view = tree.up();
|
|
|
|
let controller = view.controller;
|
2021-07-08 14:45:28 +00:00
|
|
|
controller.onNotesEdit(view, rec.data, rec.parentNode.id === 'root');
|
2020-10-28 17:25:47 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
dblclick: function(tree, el, row, col, ev, rec) {
|
|
|
|
let data = rec.data || {};
|
2021-07-08 14:45:28 +00:00
|
|
|
if (data.leaf) {
|
2020-10-28 17:25:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
let view = tree.up();
|
|
|
|
let controller = view.controller;
|
2021-07-08 14:45:28 +00:00
|
|
|
controller.onNotesEdit(view, rec.data, rec.parentNode.id === 'root');
|
2020-10-28 17:25:47 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-07-23 11:03:49 +00:00
|
|
|
{
|
|
|
|
header: gettext('Actions'),
|
|
|
|
xtype: 'actioncolumn',
|
|
|
|
dataIndex: 'text',
|
2021-10-27 11:22:37 +00:00
|
|
|
width: 150,
|
2020-07-23 11:03:49 +00:00
|
|
|
items: [
|
|
|
|
{
|
|
|
|
handler: 'onVerify',
|
2020-10-28 17:24:29 +00:00
|
|
|
getTip: (v, m, rec) => Ext.String.format(gettext("Verify '{0}'"), v),
|
2020-10-28 17:22:20 +00:00
|
|
|
getClass: (v, m, rec) => rec.data.leaf ? 'pmx-hidden' : 'pve-icon-verify-lettering',
|
2021-05-26 09:12:05 +00:00
|
|
|
isActionDisabled: (v, r, c, i, rec) => !!rec.data.leaf,
|
2020-11-03 08:30:54 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
handler: 'onChangeOwner',
|
|
|
|
getClass: (v, m, rec) => rec.parentNode.id ==='root' ? 'fa fa-user' : 'pmx-hidden',
|
|
|
|
getTip: (v, m, rec) => Ext.String.format(gettext("Change owner of '{0}'"), v),
|
2021-05-26 09:12:05 +00:00
|
|
|
isActionDisabled: (v, r, c, i, rec) => rec.parentNode.id !=='root',
|
2020-11-03 08:30:54 +00:00
|
|
|
},
|
2020-07-23 11:03:49 +00:00
|
|
|
{
|
|
|
|
handler: 'onPrune',
|
2020-10-28 17:24:29 +00:00
|
|
|
getTip: (v, m, rec) => Ext.String.format(gettext("Prune '{0}'"), v),
|
2020-07-23 11:03:49 +00:00
|
|
|
getClass: (v, m, rec) => rec.parentNode.id ==='root' ? 'fa fa-scissors' : 'pmx-hidden',
|
2021-05-26 09:12:05 +00:00
|
|
|
isActionDisabled: (v, r, c, i, rec) => rec.parentNode.id !=='root',
|
2020-07-23 11:03:49 +00:00
|
|
|
},
|
2021-10-27 11:22:37 +00:00
|
|
|
{
|
|
|
|
handler: 'onProtectionChange',
|
|
|
|
getTip: (v, m, rec) => Ext.String.format(gettext("Change protection of '{0}'"), v),
|
2021-11-22 10:21:23 +00:00
|
|
|
getClass: (v, m, rec) => {
|
|
|
|
if (!rec.data.leaf && rec.parentNode.id !== 'root') {
|
|
|
|
let extraCls = rec.data.protected ? 'good' : 'faded';
|
|
|
|
return `fa fa-shield ${extraCls}`;
|
|
|
|
}
|
|
|
|
return 'pmx-hidden';
|
|
|
|
},
|
2021-10-27 11:22:37 +00:00
|
|
|
isActionDisabled: (v, r, c, i, rec) => !!rec.data.leaf || rec.parentNode.id === 'root',
|
|
|
|
},
|
2020-07-23 11:03:49 +00:00
|
|
|
{
|
|
|
|
handler: 'onForget',
|
2021-05-17 07:03:14 +00:00
|
|
|
getTip: (v, m, rec) => rec.parentNode.id !=='root'
|
|
|
|
? Ext.String.format(gettext("Permanently forget snapshot '{0}'"), v)
|
|
|
|
: Ext.String.format(gettext("Permanently forget group '{0}'"), v),
|
2021-05-14 14:36:03 +00:00
|
|
|
getClass: (v, m, rec) => !rec.data.leaf ? 'fa critical fa-trash-o' : 'pmx-hidden',
|
2021-05-26 09:12:05 +00:00
|
|
|
isActionDisabled: (v, r, c, i, rec) => !!rec.data.leaf,
|
2020-07-23 11:03:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
handler: 'downloadFile',
|
2020-10-28 17:24:29 +00:00
|
|
|
getTip: (v, m, rec) => Ext.String.format(gettext("Download '{0}'"), v),
|
2020-07-23 11:03:49 +00:00
|
|
|
getClass: (v, m, rec) => rec.data.leaf && rec.data.filename ? 'fa fa-download' : 'pmx-hidden',
|
2021-05-26 09:12:05 +00:00
|
|
|
isActionDisabled: (v, r, c, i, rec) => !rec.data.leaf || !rec.data.filename || rec.data['crypt-mode'] > 2,
|
2020-07-23 11:03:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
handler: 'openPxarBrowser',
|
|
|
|
tooltip: gettext('Browse'),
|
|
|
|
getClass: (v, m, rec) => {
|
|
|
|
let data = rec.data;
|
|
|
|
if (data.leaf && data.filename && data.filename.endsWith('pxar.didx')) {
|
|
|
|
return 'fa fa-folder-open-o';
|
|
|
|
}
|
|
|
|
return 'pmx-hidden';
|
|
|
|
},
|
2021-05-26 09:12:05 +00:00
|
|
|
isActionDisabled: (v, r, c, i, rec) => {
|
2020-07-23 11:03:49 +00:00
|
|
|
let data = rec.data;
|
|
|
|
return !(data.leaf &&
|
|
|
|
data.filename &&
|
|
|
|
data.filename.endsWith('pxar.didx') &&
|
2020-08-03 12:10:46 +00:00
|
|
|
data['crypt-mode'] < 3);
|
2020-09-02 07:15:53 +00:00
|
|
|
},
|
2020-07-23 11:03:49 +00:00
|
|
|
},
|
2020-09-02 07:15:53 +00:00
|
|
|
],
|
2020-07-23 11:03:49 +00:00
|
|
|
},
|
2020-05-29 13:09:01 +00:00
|
|
|
{
|
|
|
|
xtype: 'datecolumn',
|
|
|
|
header: gettext('Backup Time'),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'backup-time',
|
|
|
|
format: 'Y-m-d H:i:s',
|
2020-09-02 07:15:53 +00:00
|
|
|
width: 150,
|
2020-05-29 13:09:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext("Size"),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'size',
|
2020-07-08 10:08:02 +00:00
|
|
|
renderer: (v, meta, record) => {
|
2020-07-23 11:03:49 +00:00
|
|
|
if (record.data.text === 'client.log.blob' && v === undefined) {
|
|
|
|
return '';
|
|
|
|
}
|
2020-07-08 10:08:02 +00:00
|
|
|
if (v === undefined || v === null) {
|
|
|
|
meta.tdCls = "x-grid-row-loading";
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return Proxmox.Utils.format_size(v);
|
|
|
|
},
|
2020-05-29 13:09:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'numbercolumn',
|
|
|
|
format: '0',
|
|
|
|
header: gettext("Count"),
|
|
|
|
sortable: true,
|
2020-09-01 16:28:12 +00:00
|
|
|
width: 75,
|
|
|
|
align: 'right',
|
2020-05-29 13:09:01 +00:00
|
|
|
dataIndex: 'count',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext("Owner"),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'owner',
|
|
|
|
},
|
2020-06-18 11:55:25 +00:00
|
|
|
{
|
|
|
|
header: gettext('Encrypted'),
|
2020-07-08 11:32:20 +00:00
|
|
|
dataIndex: 'crypt-mode',
|
2020-07-23 11:03:49 +00:00
|
|
|
renderer: (v, meta, record) => {
|
2020-07-28 12:32:11 +00:00
|
|
|
if (record.data.size === undefined || record.data.size === null) {
|
|
|
|
return '';
|
|
|
|
}
|
2020-07-23 11:03:49 +00:00
|
|
|
if (v === -1) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
let iconCls = PBS.Utils.cryptIconCls[v] || '';
|
|
|
|
let iconTxt = "";
|
|
|
|
if (iconCls) {
|
|
|
|
iconTxt = `<i class="fa fa-fw fa-${iconCls}"></i> `;
|
|
|
|
}
|
2020-11-20 16:38:43 +00:00
|
|
|
let tip;
|
|
|
|
if (v !== PBS.Utils.cryptmap.indexOf('none') && record.data.fingerprint !== undefined) {
|
|
|
|
tip = "Key: " + PBS.Utils.renderKeyID(record.data.fingerprint);
|
|
|
|
}
|
|
|
|
let txt = (iconTxt + PBS.Utils.cryptText[v]) || Proxmox.Utils.unknownText;
|
|
|
|
if (record.parentNode.id === 'root' || tip === undefined) {
|
|
|
|
return txt;
|
|
|
|
} else {
|
|
|
|
return `<span data-qtip="${tip}">${txt}</span>`;
|
|
|
|
}
|
2020-09-02 07:15:53 +00:00
|
|
|
},
|
2020-05-29 13:09:01 +00:00
|
|
|
},
|
2020-08-25 15:30:28 +00:00
|
|
|
{
|
|
|
|
header: gettext('Verify State'),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'verification',
|
2020-09-02 07:13:37 +00:00
|
|
|
width: 120,
|
2021-10-27 12:58:43 +00:00
|
|
|
sorter: (arec, brec) => {
|
|
|
|
let a = arec.data.verification || { ok: 0, outdated: 0, failed: 0 };
|
|
|
|
let b = brec.data.verification || { ok: 0, outdated: 0, failed: 0 };
|
|
|
|
if (a.failed === b.failed) {
|
|
|
|
if (a.none === b.none) {
|
|
|
|
if (a.outdated === b.outdated) {
|
|
|
|
return b.ok - a.ok;
|
|
|
|
} else {
|
|
|
|
return b.outdated - a.outdated;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return b.none - a.none;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return b.failed - a.failed;
|
|
|
|
}
|
|
|
|
},
|
2020-08-25 15:30:28 +00:00
|
|
|
renderer: (v, meta, record) => {
|
2020-09-02 07:13:37 +00:00
|
|
|
let i = (cls, txt) => `<i class="fa fa-fw fa-${cls}"></i> ${txt}`;
|
|
|
|
if (v === undefined || v === null) {
|
|
|
|
return record.data.leaf ? '' : i('question-circle-o warning', gettext('None'));
|
2020-08-25 15:30:28 +00:00
|
|
|
}
|
2020-09-02 07:13:37 +00:00
|
|
|
let tip, iconCls, txt;
|
2020-08-25 15:30:28 +00:00
|
|
|
if (record.parentNode.id === 'root') {
|
2020-09-02 07:13:37 +00:00
|
|
|
if (v.failed === 0) {
|
|
|
|
if (v.none === 0) {
|
|
|
|
if (v.outdated > 0) {
|
|
|
|
tip = 'All OK, but some snapshots were not verified in last 30 days';
|
|
|
|
iconCls = 'check warning';
|
|
|
|
txt = gettext('All OK (old)');
|
|
|
|
} else {
|
|
|
|
tip = 'All snapshots verified at least once in last 30 days';
|
|
|
|
iconCls = 'check good';
|
|
|
|
txt = gettext('All OK');
|
|
|
|
}
|
|
|
|
} else if (v.ok === 0) {
|
|
|
|
tip = `${v.none} not verified yet`;
|
|
|
|
iconCls = 'question-circle-o warning';
|
|
|
|
txt = gettext('None');
|
|
|
|
} else {
|
|
|
|
tip = `${v.ok} OK, ${v.none} not verified yet`;
|
|
|
|
iconCls = 'check faded';
|
|
|
|
txt = `${v.ok} OK`;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tip = `${v.ok} OK, ${v.failed} failed, ${v.none} not verified yet`;
|
|
|
|
iconCls = 'times critical';
|
|
|
|
txt = v.ok === 0 && v.none === 0
|
|
|
|
? gettext('All failed')
|
|
|
|
: `${v.failed} failed`;
|
|
|
|
}
|
|
|
|
} else if (!v.state) {
|
|
|
|
return record.data.leaf ? '' : gettext('None');
|
|
|
|
} else {
|
|
|
|
let verify_time = Proxmox.Utils.render_timestamp(v.lastTime);
|
|
|
|
tip = `Last verify task started on ${verify_time}`;
|
|
|
|
txt = v.state;
|
|
|
|
iconCls = 'times critical';
|
|
|
|
if (v.state === 'ok') {
|
|
|
|
iconCls = 'check good';
|
|
|
|
let now = Date.now() / 1000;
|
|
|
|
if (now - v.lastTime > 30 * 24 * 60 * 60) {
|
|
|
|
tip = `Last verify task over 30 days ago: ${verify_time}`;
|
|
|
|
iconCls = 'check warning';
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 15:30:28 +00:00
|
|
|
}
|
|
|
|
return `<span data-qtip="${tip}">
|
2020-09-02 07:13:37 +00:00
|
|
|
<i class="fa fa-fw fa-${iconCls}"></i> ${txt}
|
2020-08-25 15:30:28 +00:00
|
|
|
</span>`;
|
|
|
|
},
|
|
|
|
listeners: {
|
|
|
|
dblclick: function(view, el, row, col, ev, rec) {
|
|
|
|
let data = rec.data || {};
|
|
|
|
let verify = data.verification;
|
|
|
|
if (verify && verify.upid && rec.parentNode.id !== 'root') {
|
|
|
|
let win = Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
upid: verify.upid,
|
|
|
|
});
|
|
|
|
win.show();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-05-29 13:09:01 +00:00
|
|
|
],
|
2020-03-26 12:23:28 +00:00
|
|
|
|
2020-05-29 13:09:01 +00:00
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
text: gettext('Reload'),
|
|
|
|
iconCls: 'fa fa-refresh',
|
|
|
|
handler: 'reload',
|
|
|
|
},
|
2020-10-27 15:20:05 +00:00
|
|
|
'-',
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Verify All'),
|
2020-10-27 16:41:55 +00:00
|
|
|
confirmMsg: gettext('Do you want to verify all snapshots now?'),
|
2020-10-27 15:20:05 +00:00
|
|
|
handler: 'verifyAll',
|
|
|
|
},
|
2021-07-16 08:53:27 +00:00
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Prune All'),
|
|
|
|
handler: 'pruneAll',
|
|
|
|
},
|
2020-07-23 11:03:50 +00:00
|
|
|
'->',
|
2022-05-06 07:27:11 +00:00
|
|
|
{
|
|
|
|
xtype: 'tbtext',
|
|
|
|
html: gettext('Namespace') + ':',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'pbsNamespaceSelector',
|
2022-05-06 09:02:59 +00:00
|
|
|
width: 200,
|
2022-05-06 07:27:11 +00:00
|
|
|
cbind: {
|
|
|
|
datastore: '{datastore}',
|
|
|
|
},
|
|
|
|
},
|
2022-05-06 09:02:59 +00:00
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Add NS'),
|
|
|
|
iconCls: 'fa fa-plus-square',
|
|
|
|
handler: 'addNS',
|
|
|
|
},
|
2022-05-06 07:27:11 +00:00
|
|
|
'-',
|
2020-07-23 11:03:50 +00:00
|
|
|
{
|
|
|
|
xtype: 'tbtext',
|
|
|
|
html: gettext('Search'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'textfield',
|
|
|
|
reference: 'searchbox',
|
2020-09-01 16:30:20 +00:00
|
|
|
emptyText: gettext('group, date or owner'),
|
2020-07-23 11:03:50 +00:00
|
|
|
triggers: {
|
|
|
|
clear: {
|
|
|
|
cls: 'pmx-clear-trigger',
|
|
|
|
weight: -1,
|
|
|
|
hidden: true,
|
|
|
|
handler: function() {
|
|
|
|
this.triggers.clear.setVisible(false);
|
|
|
|
this.setValue('');
|
|
|
|
},
|
2020-09-02 07:15:53 +00:00
|
|
|
},
|
2020-07-23 11:03:50 +00:00
|
|
|
},
|
|
|
|
listeners: {
|
|
|
|
change: {
|
|
|
|
fn: 'search',
|
|
|
|
buffer: 500,
|
|
|
|
},
|
|
|
|
},
|
2020-09-02 07:15:53 +00:00
|
|
|
},
|
2020-05-29 13:09:01 +00:00
|
|
|
],
|
2019-12-20 11:46:09 +00:00
|
|
|
});
|