2018-12-05 14:39:40 +03:00
/*global Proxmox */
Ext . ns ( 'PBS' ) ;
console . log ( "Starting Backup Server GUI" ) ;
Ext . define ( 'PBS.Utils' , {
singleton : true ,
2019-01-30 17:14:20 +03:00
updateLoginData : function ( data ) {
2020-05-29 17:22:14 +03:00
Proxmox . Utils . setAuthData ( data ) ;
2019-01-30 17:14:20 +03:00
} ,
2020-05-20 13:15:38 +03:00
dataStorePrefix : 'DataStore-' ,
getDataStoreFromPath : function ( path ) {
return path . slice ( PBS . Utils . dataStorePrefix . length ) ;
} ,
isDataStorePath : function ( path ) {
return path . indexOf ( PBS . Utils . dataStorePrefix ) === 0 ;
} ,
2020-05-26 19:16:38 +03: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 14:37:57 +03:00
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 what ;
} ,
2020-05-26 19:17:01 +03:00
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 ;
} ,
2020-05-26 14:37:57 +03:00
2018-12-05 14:39:40 +03:00
constructor : function ( ) {
var me = this ;
// do whatever you want here
2020-05-25 20:06:47 +03:00
Proxmox . Utils . override _task _descriptions ( {
garbage _collection : [ 'Datastore' , gettext ( 'Garbage collect' ) ] ,
2020-05-26 19:35:50 +03:00
sync : [ 'Datastore' , gettext ( 'Remote Sync' ) ] ,
2020-05-29 11:53:37 +03:00
syncjob : [ gettext ( 'Sync Job' ) , gettext ( 'Remote Sync' ) ] ,
2020-05-26 14:37:57 +03:00
prune : ( type , id ) => {
return PBS . Utils . render _datastore _worker _id ( id , gettext ( 'Prune' ) ) ;
} ,
backup : ( type , id ) => {
return PBS . Utils . render _datastore _worker _id ( id , gettext ( 'Backup' ) ) ;
} ,
2020-05-26 19:17:01 +03:00
reader : ( type , id ) => {
return PBS . Utils . render _datastore _time _worker _id ( id , gettext ( 'Read objects' ) ) ;
} ,
2020-05-25 20:06:47 +03:00
} ) ;
2018-12-05 14:39:40 +03:00
}
} ) ;