78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
/*global Proxmox */
|
|
Ext.ns('PBS');
|
|
|
|
console.log("Starting Backup Server GUI");
|
|
|
|
Ext.define('PBS.Utils', {
|
|
singleton: true,
|
|
|
|
updateLoginData: function(data) {
|
|
|
|
Proxmox.Utils.setAuthData(data);
|
|
},
|
|
|
|
dataStorePrefix: 'DataStore-',
|
|
|
|
getDataStoreFromPath: function(path) {
|
|
return path.slice(PBS.Utils.dataStorePrefix.length);
|
|
},
|
|
|
|
isDataStorePath: function(path) {
|
|
return path.indexOf(PBS.Utils.dataStorePrefix) === 0;
|
|
},
|
|
|
|
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';
|
|
},
|
|
|
|
render_datastore_worker_id: function(id, what) {
|
|
const result = id.match(/^(\S+)_([^_\s]+)_([^_\s]+)$/);
|
|
if (result) {
|
|
let datastore = result[1], type = result[2], id = result[3];
|
|
return `Datastore ${datastore} - ${what} ${type}/${id}`;
|
|
}
|
|
return `Datastore ${id} - ${what}`;
|
|
},
|
|
|
|
render_datastore_time_worker_id: function(id, what) {
|
|
const res = id.match(/^(\S+)_([^_\s]+)_([^_\s]+)_([^_\s]+)$/);
|
|
if (res) {
|
|
let datastore = res[1], type = res[2], id = res[3];
|
|
let datetime = Ext.Date.parse(parseInt(res[4], 16), 'U');
|
|
let utctime = PBS.Utils.render_datetime_utc(datetime);
|
|
return `Datastore ${datastore} - ${what} ${type}/${id}/${utctime}`;
|
|
}
|
|
return what;
|
|
},
|
|
|
|
constructor: function() {
|
|
var me = this;
|
|
|
|
// do whatever you want here
|
|
Proxmox.Utils.override_task_descriptions({
|
|
garbage_collection: ['Datastore', gettext('Garbage collect') ],
|
|
sync: ['Datastore', gettext('Remote Sync') ],
|
|
syncjob: [gettext('Sync Job'), gettext('Remote Sync') ],
|
|
prune: (type, id) => {
|
|
return PBS.Utils.render_datastore_worker_id(id, gettext('Prune'));
|
|
},
|
|
verify: (type, id) => {
|
|
return PBS.Utils.render_datastore_worker_id(id, gettext('Verify'));
|
|
},
|
|
backup: (type, id) => {
|
|
return PBS.Utils.render_datastore_worker_id(id, gettext('Backup'));
|
|
},
|
|
reader: (type, id) => {
|
|
return PBS.Utils.render_datastore_time_worker_id(id, gettext('Read objects'));
|
|
},
|
|
});
|
|
}
|
|
});
|