2018-12-05 11:39:40 +00:00
|
|
|
Ext.ns('PBS');
|
|
|
|
|
|
|
|
console.log("Starting Backup Server GUI");
|
|
|
|
|
|
|
|
Ext.define('PBS.Utils', {
|
|
|
|
singleton: true,
|
|
|
|
|
2019-01-30 14:14:20 +00:00
|
|
|
updateLoginData: function(data) {
|
2020-05-29 14:22:14 +00:00
|
|
|
Proxmox.Utils.setAuthData(data);
|
2019-01-30 14:14:20 +00:00
|
|
|
},
|
|
|
|
|
2020-05-20 10:15:38 +00:00
|
|
|
dataStorePrefix: 'DataStore-',
|
|
|
|
|
2020-07-08 11:32:20 +00:00
|
|
|
cryptmap: [
|
|
|
|
'none',
|
|
|
|
'mixed',
|
|
|
|
'sign-only',
|
|
|
|
'encrypt',
|
|
|
|
],
|
|
|
|
|
|
|
|
cryptText: [
|
|
|
|
Proxmox.Utils.noText,
|
|
|
|
gettext('Mixed'),
|
|
|
|
gettext('Signed'),
|
|
|
|
gettext('Encrypted'),
|
|
|
|
],
|
|
|
|
|
|
|
|
cryptIconCls: [
|
|
|
|
'',
|
|
|
|
'',
|
2020-07-23 11:03:49 +00:00
|
|
|
'lock faded',
|
|
|
|
'lock good',
|
2020-07-08 11:32:20 +00:00
|
|
|
],
|
|
|
|
|
2020-07-09 14:50:24 +00:00
|
|
|
calculateCryptMode: function(data) {
|
|
|
|
let mixed = data.mixed;
|
|
|
|
let encrypted = data.encrypt;
|
|
|
|
let signed = data['sign-only'];
|
|
|
|
let files = data.count;
|
|
|
|
if (mixed > 0) {
|
|
|
|
return PBS.Utils.cryptmap.indexOf('mixed');
|
2020-09-09 14:18:11 +00:00
|
|
|
} else if (files === encrypted && encrypted > 0) {
|
2020-07-08 11:32:20 +00:00
|
|
|
return PBS.Utils.cryptmap.indexOf('encrypt');
|
2020-09-09 14:18:11 +00:00
|
|
|
} else if (files === signed && signed > 0) {
|
2020-07-08 11:32:20 +00:00
|
|
|
return PBS.Utils.cryptmap.indexOf('sign-only');
|
|
|
|
} else if ((signed+encrypted) === 0) {
|
|
|
|
return PBS.Utils.cryptmap.indexOf('none');
|
|
|
|
} else {
|
|
|
|
return PBS.Utils.cryptmap.indexOf('mixed');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-05-20 10:15:38 +00:00
|
|
|
getDataStoreFromPath: function(path) {
|
|
|
|
return path.slice(PBS.Utils.dataStorePrefix.length);
|
|
|
|
},
|
|
|
|
|
|
|
|
isDataStorePath: function(path) {
|
|
|
|
return path.indexOf(PBS.Utils.dataStorePrefix) === 0;
|
|
|
|
},
|
|
|
|
|
2020-05-26 16:16:38 +00:00
|
|
|
render_datetime_utc: function(datetime) {
|
|
|
|
let pad = (number) => number < 10 ? '0' + number : number;
|
|
|
|
return datetime.getUTCFullYear() +
|
|
|
|
'-' + pad(datetime.getUTCMonth() + 1) +
|
|
|
|
'-' + pad(datetime.getUTCDate()) +
|
|
|
|
'T' + pad(datetime.getUTCHours()) +
|
|
|
|
':' + pad(datetime.getUTCMinutes()) +
|
|
|
|
':' + pad(datetime.getUTCSeconds()) +
|
|
|
|
'Z';
|
|
|
|
},
|
|
|
|
|
2020-05-26 11:37:57 +00:00
|
|
|
render_datastore_worker_id: function(id, what) {
|
2020-06-30 11:11:22 +00:00
|
|
|
const res = id.match(/^(\S+?)_(\S+?)_(\S+?)(_(.+))?$/);
|
2020-05-26 16:17:01 +00:00
|
|
|
if (res) {
|
2020-09-25 16:40:03 +00:00
|
|
|
let datastore = res[1], backupGroup = `${res[2]}/${res[3]}`;
|
2020-06-30 11:11:22 +00:00
|
|
|
if (res[4] !== undefined) {
|
|
|
|
let datetime = Ext.Date.parse(parseInt(res[5], 16), 'U');
|
|
|
|
let utctime = PBS.Utils.render_datetime_utc(datetime);
|
2020-09-25 16:40:03 +00:00
|
|
|
return `Datastore ${datastore} ${what} ${backupGroup}/${utctime}`;
|
2020-06-30 11:11:22 +00:00
|
|
|
} else {
|
2020-09-25 16:40:03 +00:00
|
|
|
return `Datastore ${datastore} ${what} ${backupGroup}`;
|
2020-06-30 11:11:22 +00:00
|
|
|
}
|
2020-05-26 16:17:01 +00:00
|
|
|
}
|
2020-06-30 11:11:22 +00:00
|
|
|
return `Datastore ${what} ${id}`;
|
2020-05-26 16:17:01 +00:00
|
|
|
},
|
2020-05-26 11:37:57 +00:00
|
|
|
|
2018-12-05 11:39:40 +00:00
|
|
|
constructor: function() {
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
// do whatever you want here
|
2020-05-25 17:06:47 +00:00
|
|
|
Proxmox.Utils.override_task_descriptions({
|
2020-09-25 16:40:03 +00:00
|
|
|
garbage_collection: ['Datastore', gettext('Garbage collect')],
|
|
|
|
sync: ['Datastore', gettext('Remote Sync')],
|
2020-10-20 09:10:10 +00:00
|
|
|
verify: ['Datastore', gettext('Verification')],
|
|
|
|
verify_group: ['Group', gettext('Verification')],
|
|
|
|
verify_snapshot: ['Snapshot', gettext('Verification')],
|
2020-09-25 16:40:03 +00:00
|
|
|
syncjob: [gettext('Sync Job'), gettext('Remote Sync')],
|
2020-10-20 09:10:10 +00:00
|
|
|
verifyjob: [gettext('Verify Job'), gettext('Scheduled Verification')],
|
2020-09-25 16:40:03 +00:00
|
|
|
prune: (type, id) => PBS.Utils.render_datastore_worker_id(id, gettext('Prune')),
|
|
|
|
backup: (type, id) => PBS.Utils.render_datastore_worker_id(id, gettext('Backup')),
|
|
|
|
reader: (type, id) => PBS.Utils.render_datastore_worker_id(id, gettext('Read objects')),
|
2020-09-29 14:05:54 +00:00
|
|
|
logrotate: [gettext('Log'), gettext('Rotation')],
|
2020-05-25 17:06:47 +00:00
|
|
|
});
|
2020-09-25 16:40:03 +00:00
|
|
|
},
|
2018-12-05 11:39:40 +00:00
|
|
|
});
|