2020-05-29 11:53:41 +03:00
Ext . define ( 'PBS.window.SyncJobEdit' , {
extend : 'Proxmox.window.Edit' ,
alias : 'widget.pbsSyncJobEdit' ,
mixins : [ 'Proxmox.Mixin.CBind' ] ,
userid : undefined ,
2020-09-11 11:35:28 +03:00
onlineHelp : 'syncjobs' ,
2020-05-29 11:53:41 +03:00
isAdd : true ,
2022-05-11 19:00:15 +03:00
subject : gettext ( 'Sync Job' ) ,
2020-05-29 11:53:41 +03:00
2021-11-29 17:39:43 +03:00
bodyPadding : 0 ,
2020-05-29 11:53:41 +03:00
fieldDefaults : { labelWidth : 120 } ,
2020-11-04 21:05:46 +03:00
defaultFocus : 'proxmoxtextfield[name=comment]' ,
2020-05-29 11:53:41 +03:00
cbindData : function ( initialConfig ) {
let me = this ;
let baseurl = '/api2/extjs/config/sync' ;
let id = initialConfig . id ;
me . isCreate = ! id ;
me . url = id ? ` ${ baseurl } / ${ id } ` : baseurl ;
me . method = id ? 'PUT' : 'POST' ;
me . autoLoad = ! ! id ;
2020-11-04 21:04:06 +03:00
me . scheduleValue = id ? null : 'hourly' ;
2020-11-06 15:01:57 +03:00
me . authid = id ? null : Proxmox . UserName ;
2020-11-09 18:01:25 +03:00
me . editDatastore = me . datastore === undefined && me . isCreate ;
2020-05-29 11:53:41 +03:00
return { } ;
} ,
2022-05-11 18:44:58 +03:00
controller : {
xclass : 'Ext.app.ViewController' ,
control : {
'pbsDataStoreSelector[name=store]' : {
change : 'storeChange' ,
} ,
} ,
storeChange : function ( field , value ) {
let view = this . getView ( ) ;
let nsSelector = view . down ( 'pbsNamespaceSelector[name=ns]' ) ;
nsSelector . setDatastore ( value ) ;
} ,
} ,
2020-05-29 11:53:41 +03:00
items : {
2021-11-29 17:39:43 +03:00
xtype : 'tabpanel' ,
bodyPadding : 10 ,
border : 0 ,
items : [
2020-05-29 11:53:41 +03:00
{
2021-11-29 17:39:43 +03:00
title : 'Options' ,
xtype : 'inputpanel' ,
onGetValues : function ( values ) {
let me = this ;
if ( ! values . id && me . up ( 'pbsSyncJobEdit' ) . isCreate ) {
values . id = 's-' + Ext . data . identifier . Uuid . Global . generate ( ) . slice ( 0 , 13 ) ;
}
if ( ! me . isCreate ) {
PBS . Utils . delete _if _default ( values , 'rate-in' ) ;
if ( typeof values . delete === 'string' ) {
values . delete = values . delete . split ( ',' ) ;
}
}
return values ;
2020-11-04 21:07:07 +03:00
} ,
2021-11-29 17:39:43 +03:00
column1 : [
{
xtype : 'pmxDisplayEditField' ,
fieldLabel : gettext ( 'Local Datastore' ) ,
name : 'store' ,
submitValue : true ,
cbind : {
editable : '{editDatastore}' ,
value : '{datastore}' ,
} ,
editConfig : {
xtype : 'pbsDataStoreSelector' ,
allowBlank : false ,
} ,
} ,
2022-05-10 16:02:23 +03:00
{
2022-05-11 18:44:58 +03:00
xtype : 'pbsNamespaceSelector' ,
2022-05-10 16:02:23 +03:00
fieldLabel : gettext ( 'Local Namespace' ) ,
name : 'ns' ,
cbind : {
datastore : '{datastore}' ,
} ,
2022-05-13 12:55:54 +03:00
listeners : {
2022-05-13 14:14:53 +03:00
change : function ( field , localNs ) {
2022-05-13 12:55:54 +03:00
let me = this ;
2022-05-13 14:14:53 +03:00
let view = me . up ( 'pbsSyncJobEdit' ) ;
let remoteNs = view . down ( 'pbsRemoteNamespaceSelector[name=remote-ns]' ) . getValue ( ) ;
let maxDepthField = view . down ( 'field[name=max-depth]' ) ;
maxDepthField . setLimit ( localNs , remoteNs ) ;
2022-05-13 12:55:54 +03:00
maxDepthField . validate ( ) ;
} ,
} ,
2022-05-10 16:02:23 +03:00
} ,
2021-11-29 17:39:43 +03:00
{
fieldLabel : gettext ( 'Local Owner' ) ,
xtype : 'pbsAuthidSelector' ,
name : 'owner' ,
cbind : {
value : '{authid}' ,
deleteEmpty : '{!isCreate}' ,
} ,
} ,
{
2022-05-10 16:02:23 +03:00
fieldLabel : gettext ( 'Sync Schedule' ) ,
xtype : 'pbsCalendarEvent' ,
name : 'schedule' ,
emptyText : gettext ( 'none (disabled)' ) ,
cbind : {
deleteEmpty : '{!isCreate}' ,
value : '{scheduleValue}' ,
2021-11-29 17:39:43 +03:00
} ,
2022-05-10 16:02:23 +03:00
} ,
{
xtype : 'pmxBandwidthField' ,
name : 'rate-in' ,
fieldLabel : gettext ( 'Rate Limit' ) ,
emptyText : gettext ( 'Unlimited' ) ,
submitAutoScaledSizeUnit : true ,
// NOTE: handle deleteEmpty in onGetValues due to bandwidth field having a cbind too
2021-11-29 17:39:43 +03:00
} ,
] ,
2020-11-04 21:05:46 +03:00
2021-11-29 17:39:43 +03:00
column2 : [
{
fieldLabel : gettext ( 'Source Remote' ) ,
xtype : 'pbsRemoteSelector' ,
allowBlank : false ,
name : 'remote' ,
listeners : {
change : function ( f , value ) {
let me = this ;
let remoteStoreField = me . up ( 'pbsSyncJobEdit' ) . down ( 'field[name=remote-store]' ) ;
remoteStoreField . setRemote ( value ) ;
2022-05-10 16:02:23 +03:00
let remoteNamespaceField = me . up ( 'pbsSyncJobEdit' ) . down ( 'field[name=remote-ns]' ) ;
remoteNamespaceField . setRemote ( value ) ;
2021-11-29 17:39:43 +03:00
} ,
} ,
2020-11-05 14:12:24 +03:00
} ,
2021-11-29 17:39:43 +03:00
{
fieldLabel : gettext ( 'Source Datastore' ) ,
xtype : 'pbsRemoteStoreSelector' ,
allowBlank : false ,
autoSelect : false ,
name : 'remote-store' ,
disabled : true ,
listeners : {
change : function ( field , value ) {
let me = this ;
let remoteField = me . up ( 'pbsSyncJobEdit' ) . down ( 'field[name=remote]' ) ;
let remote = remoteField . getValue ( ) ;
2022-05-10 16:02:23 +03:00
let remoteNamespaceField = me . up ( 'pbsSyncJobEdit' ) . down ( 'field[name=remote-ns]' ) ;
remoteNamespaceField . setRemote ( remote ) ;
remoteNamespaceField . setRemoteStore ( value ) ;
2021-11-29 17:39:43 +03:00
me . up ( 'tabpanel' ) . down ( 'pbsGroupFilter' ) . setRemoteDatastore ( remote , value ) ;
} ,
} ,
} ,
{
2022-05-10 16:02:23 +03:00
fieldLabel : gettext ( 'Source Namespace' ) ,
xtype : 'pbsRemoteNamespaceSelector' ,
allowBlank : true ,
autoSelect : false ,
name : 'remote-ns' ,
disabled : true ,
listeners : {
2022-05-13 14:14:53 +03:00
change : function ( field , remoteNs ) {
2022-05-10 16:02:23 +03:00
let me = this ;
2022-05-13 14:14:53 +03:00
let view = me . up ( 'pbsSyncJobEdit' ) ;
let remote = view . down ( 'field[name=remote]' ) . getValue ( ) ;
let remoteStore = view . down ( 'field[name=remote-store]' ) . getValue ( ) ;
me . up ( 'tabpanel' ) . down ( 'pbsGroupFilter' ) . setRemoteNamespace ( remote , remoteStore , remoteNs ) ;
let localNs = view . down ( 'pbsNamespaceSelector[name=ns]' ) . getValue ( ) ;
let maxDepthField = view . down ( 'field[name=max-depth]' ) ;
maxDepthField . setLimit ( localNs , remoteNs ) ;
2022-05-13 12:55:54 +03:00
maxDepthField . validate ( ) ;
2022-05-10 16:02:23 +03:00
} ,
2021-11-29 17:39:43 +03:00
} ,
} ,
{
2022-05-13 12:55:54 +03:00
xtype : 'pbsNamespaceMaxDepthReduced' ,
2022-05-10 16:02:23 +03:00
name : 'max-depth' ,
fieldLabel : gettext ( 'Max. Depth' ) ,
deleteEmpty : true ,
} ,
{
fieldLabel : gettext ( 'Remove vanished' ) ,
xtype : 'proxmoxcheckbox' ,
name : 'remove-vanished' ,
autoEl : {
tag : 'div' ,
'data-qtip' : gettext ( 'Remove snapshots from local datastore if they vanished from source datastore?' ) ,
} ,
uncheckedValue : false ,
value : false ,
2021-11-29 17:39:43 +03:00
} ,
] ,
2020-05-29 11:53:41 +03:00
2021-11-29 17:39:43 +03:00
columnB : [
{
fieldLabel : gettext ( 'Comment' ) ,
xtype : 'proxmoxtextfield' ,
name : 'comment' ,
cbind : {
deleteEmpty : '{!isCreate}' ,
} ,
} ,
] ,
2022-05-16 19:48:44 +03:00
advancedColumn1 : [
{
2022-05-17 10:47:15 +03:00
xtype : 'pmxDisplayEditField' ,
2022-05-16 19:48:44 +03:00
fieldLabel : gettext ( 'Job ID' ) ,
emptyText : gettext ( 'Autogenerate' ) ,
name : 'id' ,
allowBlank : true ,
regex : PBS . Utils . SAFE _ID _RE ,
2022-05-17 10:05:22 +03:00
cbind : {
2022-05-17 10:47:15 +03:00
editable : '{isCreate}' ,
2022-05-17 10:05:22 +03:00
} ,
2022-05-16 19:48:44 +03:00
} ,
] ,
2021-10-28 16:00:54 +03:00
} ,
2020-05-29 11:53:41 +03:00
{
2021-11-29 17:39:43 +03:00
xtype : 'inputpanel' ,
onGetValues : function ( values ) {
PBS . Utils . delete _if _default ( values , 'group-filter' ) ;
2021-12-01 16:30:38 +03:00
if ( Ext . isArray ( values [ 'group-filter' ] ) ) {
if ( values [ 'group-filter' ] . length === 0 ) {
delete values [ 'group-filter' ] ;
values . delete = 'group-filter' ;
} else {
// merge duplicates
values [ 'group-filter' ] = [ ... new Set ( values [ 'group-filter' ] ) ] ;
}
2021-11-29 17:39:43 +03:00
}
return values ;
2020-06-23 16:29:57 +03:00
} ,
2021-11-29 17:39:43 +03:00
title : gettext ( 'Group Filter' ) ,
items : [
{
xtype : 'pbsGroupFilter' ,
name : 'group-filter' ,
} ,
] ,
2020-05-29 11:53:41 +03:00
} ,
] ,
} ,
} ) ;