]>
git.proxmox.com Git - proxmox-backup.git/blob - www/Utils.js
4 console
.log("Starting Backup Server GUI");
6 Ext
.define('PBS.Utils', {
9 updateLoginData: function(data
) {
11 Proxmox
.Utils
.setAuthData(data
);
14 dataStorePrefix
: 'DataStore-',
37 calculateCryptMode: function(data
) {
38 let mixed
= data
.mixed
;
39 let encrypted
= data
.encrypt
;
40 let signed
= data
['sign-only'];
41 let files
= data
.count
;
43 return PBS
.Utils
.cryptmap
.indexOf('mixed');
44 } else if (files
=== encrypted
&& encrypted
> 0) {
45 return PBS
.Utils
.cryptmap
.indexOf('encrypt');
46 } else if (files
=== signed
&& signed
> 0) {
47 return PBS
.Utils
.cryptmap
.indexOf('sign-only');
48 } else if ((signed
+encrypted
) === 0) {
49 return PBS
.Utils
.cryptmap
.indexOf('none');
51 return PBS
.Utils
.cryptmap
.indexOf('mixed');
55 getDataStoreFromPath: function(path
) {
56 return path
.slice(PBS
.Utils
.dataStorePrefix
.length
);
59 isDataStorePath: function(path
) {
60 return path
.indexOf(PBS
.Utils
.dataStorePrefix
) === 0;
63 render_datetime_utc: function(datetime
) {
64 let pad
= (number
) => number
< 10 ? '0' + number
: number
;
65 return datetime
.getUTCFullYear() +
66 '-' + pad(datetime
.getUTCMonth() + 1) +
67 '-' + pad(datetime
.getUTCDate()) +
68 'T' + pad(datetime
.getUTCHours()) +
69 ':' + pad(datetime
.getUTCMinutes()) +
70 ':' + pad(datetime
.getUTCSeconds()) +
74 render_datastore_worker_id: function(id
, what
) {
75 const res
= id
.match(/^(\S+?)_(\S+?)_(\S+?)(_(.+))?$/);
77 let datastore
= res
[1], type
= res
[2], id
= res
[3];
78 if (res
[4] !== undefined) {
79 let datetime
= Ext
.Date
.parse(parseInt(res
[5], 16), 'U');
80 let utctime
= PBS
.Utils
.render_datetime_utc(datetime
);
81 return `Datastore ${datastore} ${what} ${type}/${id}/${utctime}`;
83 return `Datastore ${datastore} ${what} ${type}/${id}`;
86 return `Datastore ${what} ${id}`;
89 constructor: function() {
92 // do whatever you want here
93 Proxmox
.Utils
.override_task_descriptions({
94 garbage_collection
: ['Datastore', gettext('Garbage collect') ],
95 sync
: ['Datastore', gettext('Remote Sync') ],
96 syncjob
: [gettext('Sync Job'), gettext('Remote Sync') ],
97 prune
: (type
, id
) => {
98 return PBS
.Utils
.render_datastore_worker_id(id
, gettext('Prune'));
100 verify
: (type
, id
) => {
101 return PBS
.Utils
.render_datastore_worker_id(id
, gettext('Verify'));
103 backup
: (type
, id
) => {
104 return PBS
.Utils
.render_datastore_worker_id(id
, gettext('Backup'));
106 reader
: (type
, id
) => {
107 return PBS
.Utils
.render_datastore_worker_id(id
, gettext('Read objects'));