HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: /volume1/@appstore/DNSServer/app/dns.js
/* Copyright (c) 2020 Synology Inc. All rights reserved. */

Ext.define("SYNO.SDS.DNS.AdvanceSetPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.settingField=this.createSettingFiled();this.statusField=this.createStatusField();var b={itemId:"panel_advance",border:false,trackResetOnLoad:true,items:[this.statusField,this.settingField],buttons:[{xtype:"syno_button",btnStyle:"blue",text:SYNO.SDS.DNS._V("common","commit"),handler:this.onSave,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{xtype:"syno_button",text:SYNO.SDS.DNS._V("common","reset"),handler:this.onCancle,scope:this}]};Ext.apply(b,a);return b},createSettingFiled:function(){var a={title:SYNO.SDS.DNS._V("dns","dns_advanced_set"),width:"570",height:"400",trackResetOnLoad:true,layout:"form",labelWidth:SYNO.SDS.DNS.DNS_TEXTLABEL_WIDTH,items:[{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_advanced_set_desc")},{xtype:"panel",layout:"hbox",border:false,fieldLabel:SYNO.SDS.DNS._V("dns","dns_storage_szie"),items:[{xtype:"syno_numberfield",name:"max_log_size",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:2147483647,minValue:1,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_displayfield",width:5},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("common","size_mb")}]},{xtype:"panel",layout:"hbox",border:false,fieldLabel:SYNO.SDS.DNS._V("dns","dns_max_cache_size"),items:[{xtype:"syno_numberfield",name:"max_cache_size",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:4095,maskRe:/[0-9]/,minValue:0,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_displayfield",width:5},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("common","size_mb")}]},{xtype:"panel",layout:"hbox",border:false,fieldLabel:SYNO.SDS.DNS._V("dns","dns_max_cache_ttl"),items:[{xtype:"syno_numberfield",name:"max_cache_time",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:4294967295,minValue:1,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_displayfield",width:5},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("common","time_seconds")}]},{xtype:"syno_numberfield",name:"max_recursion_client",allowBlank:false,allowDecimals:false,vtype:"digit",maxValue:2147483647,minValue:1,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,fieldLabel:SYNO.SDS.DNS._V("dns","dns_max_recursive_clients")},{xtype:"syno_numberfield",name:"max_tcp_client",allowBlank:false,allowDecimals:false,maxValue:2147483647,minValue:1,vtype:"digit",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,fieldLabel:SYNO.SDS.DNS._V("dns","dns_max_tcp_clients")},{xtype:"syno_button",text:SYNO.SDS.DNS._V("dns","dns_system_default"),handler:this.loadDefault,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""}]};return new SYNO.ux.FieldSet(a)},createStatusField:function(){var a={title:SYNO.SDS.DNS._V("dns","dns_status"),width:"570",height:"400",trackResetOnLoad:true,layout:"form",labelWidth:SYNO.SDS.DNS.DNS_TEXTLABEL_WIDTH,items:[{xtype:"panel",layout:"hbox",fieldLabel:SYNO.SDS.DNS._V("dns","dns_recursion_clients"),border:false,items:[{xtype:"syno_displayfield",name:"recursive_clients",width:300,value:0}]},{xtype:"panel",layout:"hbox",fieldLabel:SYNO.SDS.DNS._V("dns","dns_tcp_clients"),border:false,items:[{xtype:"syno_displayfield",name:"tcp_clients",width:300,value:0}]},{name:"memory_alert",xtype:"syno_displayfield",value:'<span class="red-status">'+_T("common","note")+_T("common","colon")+" </span>"+SYNO.SDS.DNS._V("dns","dns_memory_not_enough"),hidden:true}]};return new SYNO.ux.FieldSet(a)},onPageActivate:function(){if(!_S("demo_mode")){this.loadForm();this.loadStatus()}else{this.OriSetting={recursive_clients:"0",tcp_clients:"0",max_cache_size:"10",max_cache_time:"86400",max_recursion_client:"1000",max_tcp_client:"100",max_log_size:"10"};this.getForm().setValues(this.OriSetting);this.doLayout()}},loadStatus:function(){var a=this.getForm();this.pollingTaskId=this.owner.pollReg({webapi:{api:"SYNO.DNSServer.DaemonStatus",version:1,method:"get"},interval:3,status_callback:function(d,c,b){this.clearStatusBusy();if(d){a.findField("recursive_clients").setValue(c.recursive_clients);a.findField("tcp_clients").setValue(c.tcp_clients);if(true===c.memory_alert){a.findField("memory_alert").show()}else{a.findField("memory_alert").hide()}this.doLayout()}else{}},scope:this})},loadForm:function(){this.setStatusBusy({text:_T("common","loading")});this.owner.sendWebAPI({api:"SYNO.DNSServer.AdvanceConf",version:1,method:"get",callback:function(c,b,a){this.clearStatusBusy();if(c){this.OriSetting=b;this.getForm().setValues(this.OriSetting)}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.DNS._E(b.code))}},scope:this})},loadDefault:function(){this.owner.sendWebAPI({api:"SYNO.DNSServer.AdvanceConf",version:1,method:"get",params:{default_setting:true},callback:function(c,b,a){this.clearStatusBusy();if(c){this.getForm().findField("max_cache_size").setValue(b.max_cache_size);this.getForm().findField("max_cache_time").setValue(b.max_cache_time);this.getForm().findField("max_recursion_client").setValue(b.max_recursion_client);this.getForm().findField("max_tcp_client").setValue(b.max_tcp_client);this.getForm().findField("max_log_size").setValue(b.max_log_size)}else{this.clearStatusBusy();this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.DNS._E(b.code))}},scope:this})},onSave:function(){if(!this.checkDirty()){this.setStatusError({text:SYNO.SDS.DNS._V("error","nochange_subject"),clear:true});return}if(!this.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}this.applyForm()},checkDirty:function(){var a=this.getForm();if(a.findField("max_cache_size").isDirty()||a.findField("max_cache_time").isDirty()||a.findField("max_recursion_client").isDirty()||a.findField("max_tcp_client").isDirty()||a.findField("max_log_size").isDirty()){return true}return false},applyForm:function(){this.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});var a=this.getForm();var b={max_cache_size:a.findField("max_cache_size").getValue(),max_cache_time:a.findField("max_cache_time").getValue(),max_recursion_client:a.findField("max_recursion_client").getValue(),max_tcp_client:a.findField("max_tcp_client").getValue(),max_log_size:a.findField("max_log_size").getValue()};this.TmpSetting=b;this.owner.sendWebAPI({api:"SYNO.DNSServer.AdvanceConf",version:1,method:"set",params:b,callback:function(e,d,c){this.clearStatusBusy();if(e){this.setStatusOK();this.OriSetting=this.TmpSetting;this.getForm().setValues(this.OriSetting)}else{this.owner.getMsgBox().alert(this.settingField.title,SYNO.SDS.DNS._E(d.code))}},scope:this})},onLeavePage:function(){if(!_S("demo_mode")&&this.pollingTaskId){this.pollUnreg(this.pollingTaskId);this.pollingTaskId=null}},onCancle:function(){this.getForm().setValues(this.OriSetting)},onPageDeactivate:function(){if(this.checkDirty()){return false}if(!_S("demo_mode")&&this.pollingTaskId){this.pollUnreg(this.pollingTaskId);this.pollingTaskId=null}}});Ext.define("SYNO.SDS.DNS.KeyAddPanel",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.formPanel=this.createPanel();var b={title:SYNO.SDS.DNS._V("dns","dns_key_create"),layout:"form",border:false,width:525,autoHeight:true,labelwidth:SYNO.SDS.DNS.DNS_LABEL_WIDTH,trackResetOnLoad:true,items:this.formPanel,buttons:[{text:SYNO.SDS.DNS._V("common","apply"),handler:this.onSave,btnStyle:"blue",scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{text:SYNO.SDS.DNS._V("common","cancel"),handler:function(){this.close()},scope:this}]};Ext.apply(b,a);return b},createPanel:function(){var a={xtype:"fieldset",border:false,items:[{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_key_create_desc")},{xtype:"syno_textfield",vtype:"synodnsKeyName",name:"key_name",maxlength:63,fieldLabel:SYNO.SDS.DNS._V("dns","dns_key_name"),allowBlank:false,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,validator:function(b){if(b===SYNO.SDS.DNS.RESERVED_KEYNAME){return SYNO.SDS.DNS._V("dns","dns_reserved_keyname")}else{return true}}},{xtype:"syno_combobox",name:"key_algorithm",fieldLabel:SYNO.SDS.DNS._V("dns","dns_algorithm"),allowBlank:false,value:"HMAC-MD5",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,store:["HMAC-MD5","HMAC-SHA512"]}]};return new SYNO.ux.FormPanel(a)},onSave:function(){if(!this.formPanel.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}this.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});var a={key_name:this.formPanel.getForm().findField("key_name").getValue(),key_algorithm:this.formPanel.getForm().findField("key_algorithm").getValue()};this.sendWebAPI({api:"SYNO.DNSServer.Key",version:1,method:"create",params:a,callback:function(d,c,b){this.clearStatusBusy();if(d){this.creater.getStore().reload();this.close()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(c.code))}},scope:this})}});Ext.define("SYNO.SDS.DNS.KeyMngPanel",{extend:"SYNO.ux.EditorGridPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent(arguments);this.mon(this,"afterlayout",function(){this.mon(this.getSelectionModel(),"selectionchange",this.onChangeBtnStatus,this)},this)},fillConfig:function(b){this.panelName=SYNO.SDS.DNS._V("dns","dns_key");this.toolBar=this.createToolBar();this.exportBtn=this.toolBar.getComponent("btnExport");this.deleteBtn=this.toolBar.getComponent("btnDelete");var d=[{header:SYNO.SDS.DNS._V("dns","dns_key_name_header"),dataIndex:"key_name",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{header:SYNO.SDS.DNS._V("dns","dns_algorithm"),dataIndex:"key_algorithm",id:this.lastClumnId=Ext.id()}];var a=new Ext.grid.ColumnModel({columns:d});var e=new SYNO.API.JsonStore({appWindow:this.owner,api:"SYNO.DNSServer.Key",method:"list",version:1,root:"items",fields:["key_name","key_algorithm"],listeners:{exception:function(i,j,k,h,l,g){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(l.code))},scope:this}});var f=new SYNO.ux.PagingToolbar({store:e,pageSize:100,displayInfo:true});var c={itemId:"panel_keymng",border:false,tbar:this.toolBar,colModel:a,ds:e,bbar:f,sm:new Ext.grid.RowSelectionModel(),loadMask:true,autoExpandColumn:this.lastClumnId};Ext.apply(c,b);return c},createToolBar:function(){var a=new Ext.Toolbar({defaultType:"syno_button"});this.menuContent=new SYNO.ux.Menu({items:[{itemId:"btnAdd",text:SYNO.SDS.DNS._V("dns","dns_key_create"),handler:this.onCreateKey,scope:this},{text:SYNO.SDS.DNS._V("dns","dns_key_import"),handler:this.onUploadKey,scope:this}]});var b=new Ext.Action({text:SYNO.SDS.DNS._V("common","create"),scope:this,menu:this.menuContent});a.add(b);a.add({itemId:"btnDelete",text:SYNO.SDS.DNS._V("common","delete"),handler:this.onDelete,disabled:true,scope:this,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});a.add({text:SYNO.SDS.DNS._V("dns","dns_key_export"),handler:this.onExport,itemId:"btnExport",disabled:true,scope:this,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});return a},onCreateKey:function(){var a=new SYNO.SDS.DNS.KeyAddPanel({owner:this.owner,creater:this});a.open()},onUploadKey:function(){var a=new SYNO.SDS.DNS.UploadKey({owner:this.owner,creater:this});a.open()},onDelete:function(){this.owner.getMsgBox().confirmDelete(this.panelName,SYNO.SDS.DNS._V("dns","dns_key_delete"),function(a){if("yes"===a){var b=this.getSelectionModel().getSelections();this.deleteKey(b)}},this)},deleteKey:function(c){var a=[];for(var b=0;b<c.length;b++){a.push(c[b].get("key_name"))}this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.Key",version:1,method:"delete",params:{delete_list:a},callback:function(f,e,d){this.owner.clearStatusBusy();if(f){this.getStore().reload()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}},scope:this})},onPageActivate:function(){this.getStore().load();this.doLayout()},onExport:function(){var b=this.getSelectionModel().getSelected();var a=b.get("key_name");this.owner.downloadWebAPI({webapi:{api:"SYNO.DNSServer.Key",method:"export",version:1,params:{key_name:a}}})},onChangeBtnStatus:function(){var a=this.getSelectionModel();var b=a.getCount();if(1==b){if(_S("demo_mode")){this.exportBtn.disable()}else{this.exportBtn.enable()}}else{this.exportBtn.disable()}if(0<b){if(_S("demo_mode")){this.deleteBtn.disable()}else{this.deleteBtn.enable()}}else{this.deleteBtn.disable()}}});Ext.define("SYNO.SDS.DNS.UploadKey",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){this.owner=a.owner;var b={title:SYNO.SDS.DNS._V("dns","dns_key_import"),resizable:false,width:500,height:250,layout:"fit",buttons:[{text:SYNO.SDS.DNS._V("common","apply"),scope:this,btnStyle:"blue",handler:this.onUpload,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{text:SYNO.SDS.DNS._V("common","cancel"),scope:this,handler:this.close}],items:[new SYNO.SDS.Utils.FormPanel({itemId:"panelKey",webapi:{api:"SYNO.DNSServer.Key",method:"import",version:1},onApiSuccess:function(){this.ownerCt.clearStatusBusy();this.ownerCt.creater.getStore().reload();this.ownerCt.close()},onApiFailure:function(e,d,c){this.ownerCt.clearStatusBusy();this.ownerCt.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(d.code))},fileUpload:true,trackResetOnLoad:true,frame:false,border:false,labelWidth:120,items:[{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_key_import_desc")},{htmlEncode:false,xtype:"syno_displayfield",value:"&nbsp;"},{xtype:"syno_filebutton",inputType:"file",width:200,fieldLabel:SYNO.SDS.DNS._V("dns","dns_key"),name:"file"}]})]};Ext.apply(b,a);this.callParent([b]);this.formKey=this.getComponent("panelKey").getForm()},onUpload:function(){if(!this.formKey.findField("file").getValue()){this.setStatusError({text:SYNO.SDS.DNS._V("service","service_ssl_no_file")});return}this.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});this.getComponent("panelKey").upload()}});Ext.define("SYNO.SDS.DNS.ListenIfaceDialog",{extend:"SYNO.SDS.ModalWindow",POSTFIX_IPV4:"_ipv4",POSTFIX_IPV6:"_ipv6",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.isCreate=a.isCreate;this.zoneName=a.name;this.ifaceStatus=a.ifaceStatus;this.formPanel=this.createFormPanel();var b={title:SYNO.SDS.DNS._V("dns","dns_interface_listener_list"),layout:"fit",resizable:false,height:SYNO.SDS.DNS.DNS_DIALOG_HEIGHT,width:SYNO.SDS.DNS.DNS_DIALOG_WIDTH,items:this.formPanel,buttons:[{text:SYNO.SDS.DNS._V("common","alt_finish"),btnStyle:"blue",itemId:"apply",handler:this.onSave,scope:this},{text:SYNO.SDS.DNS._V("common","cancel"),itemId:"cancel",handler:this.onCancel,scope:this}]};Ext.apply(b,a);return b},createFormPanel:function(){var a={xtype:"syno_formpanel",items:this.createIfaceItems()};return new SYNO.ux.FormPanel(a)},createIfaceItems:function(){var a=[];Ext.each(this.ifaceStatus,function(b){a.push({xtype:"syno_checkbox",name:b.iface_name,boxLabel:b.iface_name,checked:b.ipv4_enable||b.ipv6_enable,handler:this.ifaceCheckboxListener.bind(this)},{xtype:"syno_checkbox",name:b.iface_name+this.POSTFIX_IPV4,indent:1,checked:b.ipv4_enable,handler:this.ipCheckboxListener.bind(this,b.iface_name),boxLabel:String.format(SYNO.SDS.DNS._V("dns","dns_ipv4_addr"),b.ipv4||SYNO.SDS.DNS._V("dns","dns_ip_not_available"))},{xtype:"syno_checkbox",name:b.iface_name+this.POSTFIX_IPV6,indent:1,checked:b.ipv6_enable,handler:this.ipCheckboxListener.bind(this,b.iface_name),boxLabel:String.format(SYNO.SDS.DNS._V("dns","dns_ipv6_addr"),b.ipv6||SYNO.SDS.DNS._V("dns","dns_ip_not_available"))})},this);return a},ifaceCheckboxListener:function(a,c){var b=this.formPanel.getForm();b.findField(a.name+this.POSTFIX_IPV4).setValue(c);b.findField(a.name+this.POSTFIX_IPV6).setValue(c)},ipCheckboxListener:function(a,b,d){var c=this.formPanel.getForm();var f=c.findField(a+this.POSTFIX_IPV4).checked;var e=c.findField(a+this.POSTFIX_IPV6).checked;if(!f&&!e){c.findField(a).setValue(false)}},onInitial:function(){var a;Ext.each(this.ifaceStatus,function(b){a=new SYNO.SDS.Utils.EnableCheckGroup(this.formPanel.getForm(),b.iface_name,[b.iface_name+this.POSTFIX_IPV4,b.iface_name+this.POSTFIX_IPV6])},this)},getCompoundParams:function(c){var b=c.name;var a={api:"SYNO.DNSServer.ListenIface",version:1,method:"set",params:{zone_name:b,items:this.getListenIfaceResult()}};return[a]},onSave:function(){if(this.isCreate){this.hide();return}this.setStatusBusy();this.sendWebAPI({api:"SYNO.DNSServer.ListenIface",version:1,method:"set",params:{zone_name:this.zoneName,items:this.getListenIfaceResult()},callback:function(c,b,a){this.clearStatusBusy();if(!c){this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(b.code));return}this.close()},scope:this})},getListenIfaceResult:function(){var b=[];var a=this.formPanel.getForm();Ext.each(this.ifaceStatus,function(c){b.push({iface_name:c.iface_name,ipv4_enable:a.findField(c.iface_name+this.POSTFIX_IPV4).getValue(),ipv6_enable:a.findField(c.iface_name+this.POSTFIX_IPV6).getValue()})},this);return b},onCancel:function(){var a=(true===this.isCreate)?this.hide.bind(this):this.close.bind(this);if(this.formPanel.getForm().isDirty()){this.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("common","confirm_lostchange"),function(b){if("yes"===b){a()}},this)}else{a()}}});Ext.define("SYNO.SDS.DNS.LogSetPanel",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent([arguments]);this.mon(this,"activate",this.onActivate,this)},fillConfig:function(a){this.formPanel=this.createFormPanel();var b={title:SYNO.SDS.DNS._V("dns","dns_log_setting"),layout:"form",border:false,width:400,height:350,trackResetOnLoad:true,items:this.formPanel,buttons:[{xtype:"syno_button",text:SYNO.SDS.DNS._V("common","apply"),btnStyle:"blue",handler:this.onApply,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{xtype:"syno_button",text:SYNO.SDS.DNS._V("common","cancel"),handler:this.onCancle,scope:this}]};Ext.apply(b,a);return b},createFormPanel:function(){var b=[];b.push({xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_event_type")});b.push({xtype:"panel",layout:"hbox",width:300,border:false,items:[{xtype:"syno_checkbox",indent:1,boxLabel:"General",width:200,name:"enable_general"},{xtype:"syno_checkbox",boxLabel:"Transfer",width:150,name:"enable_transfer"}]});b.push({xtype:"panel",layout:"hbox",width:300,border:false,items:[{xtype:"syno_checkbox",indent:1,boxLabel:"Queries",width:200,name:"enable_queries"},{xtype:"syno_checkbox",boxLabel:"Security",width:150,name:"enable_security"}]});b.push({xtype:"panel",layout:"hbox",width:300,border:false,items:[{xtype:"syno_checkbox",indent:1,boxLabel:"Resolver",width:200,name:"enable_resolver"},{xtype:"syno_checkbox",boxLabel:"Default",width:150,name:"enable_default"}]});b.push({xtype:"syno_displayfield",value:" "},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_log_severity")});b.push({xtype:"syno_combobox",hideLabel:true,indent:1,name:"severity",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,store:["Critical","Error","Warning","Notice","Info"],value:"Warning"});var a={layout:"form",border:false,height:350,labelWidth:220,trackResetOnLoad:true,items:b};return new SYNO.ux.FormPanel(a)},onInitial:function(){this.loadForm()},loadForm:function(){this.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.Log.Conf",version:1,method:"get",callback:function(c,b,a){this.clearStatusBusy();if(c){this.OriSetting=b;this.formPanel.getForm().setValues(this.OriSetting)}else{this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(b.code))}},scope:this})},onApply:function(){if(!this.formPanel.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("error","forminvalid"),clear:true});return}if(!this.formPanel.getForm().isDirty()){this.close();return}this.applyForm()},applyForm:function(){this.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});var a=this.getParameter();this.TmpSetting=a;this.owner.sendWebAPI({api:"SYNO.DNSServer.Log.Conf",version:1,method:"set",params:a,callback:function(d,c,b){this.clearStatusBusy();if(d){this.setStatusOK();this.creater.getStore().reload();this.close()}else{this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(c.code))}},scope:this})},getParameter:function(){var a=this.formPanel.getForm();var b={enable_default:a.findField("enable_default").getValue(),enable_general:a.findField("enable_general").getValue(),enable_security:a.findField("enable_security").getValue(),enable_resolver:a.findField("enable_resolver").getValue(),enable_queries:a.findField("enable_queries").getValue(),enable_transfer:a.findField("enable_transfer").getValue(),severity:a.findField("severity").getValue()};return b},onCancle:function(){if(this.formPanel.getForm().isDirty()){this.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("common","confirm_lostchange"),function(a){if("yes"===a){this.close()}},this)}else{this.close()}}});Ext.define("SYNO.SDS.DNS.LogSearchField",{extend:"SYNO.ux.SearchField",iconStyle:"filter",additionFilter:[],emptyText:"",constructor:function(a){this.searchPanel=a.searchPanel;this.callParent([a])},initEvents:function(){this.callParent(arguments);this.mon(Ext.getDoc(),"mousedown",this.onMouseDown,this);this.mon(Ext.getDoc(),"keydown",function(a){if(a.button==12){this.onSearch()}},this)},isInnerComponent:function(c,b){var a=false;b.items.each(function(d){if(d instanceof Ext.form.ComboBox){if(d.view&&c.within(d.view.getEl())){a=true;return false}}else{if(d instanceof Ext.form.DateField){if(d.menu&&c.within(d.menu.getEl())){a=true;return false}}else{if(d instanceof Ext.form.CompositeField){if(this.isInnerComponent(c,d)){a=true;return false}}}}},this);return a},onMouseDown:function(b){var a=this.searchPanel;if(a&&a.isVisible()&&!a.isDestroyed&&!b.within(a.getEl())&&!b.within(this.searchtrigger)&&!this.isInnerComponent(b,this.searchPanel.getForm())&&!a.inEl){a.hide()}},onSearchTriggerClick:function(){if(this.searchPanel.isVisible()){this.searchPanel.hide();return}if(!this.searchPanel.ownerCt){this.searchPanel.ownerCt=this}if(!this.searchPanel.rendered){this.searchPanel.render()}this.searchPanel.getEl().alignTo(this.wrap,"tr-br?",[6,0]);this.searchPanel.show()},filter:function(){},onSearch:function(){this.applyFun()},setApplyFun:function(a){this.applyFun=a}});Ext.define("SYNO.SDS.DNS.LogSearchPanel",{extend:"SYNO.ux.FormPanel",width:220,height:390,cls:"syno-dns-search-panel",bodyStyle:"padding: 10px; padding-left: 18px; font-size: 24px;",renderTo:Ext.getBody(),floating:true,border:true,hidden:true,checkedStatusObj:{},applyHandler:Ext.emptyFn,cancelHandler:Ext.emptyFn,constructor:function(b){var a={items:[{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_event_type")+":"},{xtype:"syno_checkbox",name:"general",boxLabel:"General",checked:true},{xtype:"syno_checkbox",name:"network",boxLabel:"Network",checked:true},{xtype:"syno_checkbox",name:"transfer",boxLabel:"Transfer",checked:true},{xtype:"syno_checkbox",name:"queries",boxLabel:"Queries",checked:true},{xtype:"syno_checkbox",name:"security",boxLabel:"Security",checked:true},{xtype:"syno_checkbox",name:"resolver",boxLabel:"Resolver",checked:true},{xtype:"syno_checkbox",name:"default",boxLabel:"Default",checked:true},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_log_severity")+":"},{xtype:"syno_combobox",hideLabel:true,indent:0,name:"severity",width:150,store:new Ext.data.ArrayStore({fields:["value","displayText"],data:[[-5,"Critical"],[-4,"Error"],[-3,"Warning"],[-2,"Notice"],[-1,"Info"],[0,"Debug"]]}),valueField:"value",displayField:"displayText",value:0}],bbar:{xtype:"syno_compositefield",style:"padding: 10px; padding-left: 40px; font-size: 24px",hideLabel:true,width:220,items:[{xtype:"syno_button",text:_T("common","apply"),btnStyle:"blue",handler:function(){this.applyFun();this.hide()},scope:this},{xtype:"syno_button",text:_T("common","reset"),btnStyle:"grey",handler:function(){this.getForm().setValues(this.originValues)},scope:this}]}};this.callParent([a]);this.originValues=this.getForm().getValues()},hide:function(){SYNO.SDS.DNS.LogSearchPanel.superclass.hide.call(this)},show:function(){SYNO.SDS.DNS.LogSearchPanel.superclass.show.call(this)},setApplyFun:function(a){this.applyFun=a}});Ext.define("SYNO.SDS.DNS.LogShowPanel",{extend:"SYNO.ux.EditorGridPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(d){var e=this.createStore();this.searchPanel=new SYNO.SDS.DNS.LogSearchPanel();this.searchField=new SYNO.SDS.DNS.LogSearchField({itemId:"search",searchPanel:this.searchPanel});var c=this.searchPanel;var h=this.searchField;var b=function(){Ext.apply(e.baseParams,{findOptions:c.getForm().getFieldValues(true)});Ext.apply(e.baseParams,{findString:h.getValue()});e.setBaseParam("start",0);e.load()};this.searchPanel.setApplyFun(b);this.searchField.setApplyFun(b);this.pageSize=100;this.toolBar=this.createToolBar();var g=[{header:SYNO.SDS.DNS._V("time","time_time"),width:210,renderer:function(j){var i=Date.parseDate(j,"Y/m/d H:i:s.u");if(!i){return j}if(!SYNO.SDS.DateTimeFormatter){return i.format("m/d/Y G:i:s")}return SYNO.SDS.DateTimeFormatter(i,{type:"datetimesec"})}},{header:SYNO.SDS.DNS._V("dns","dns_event_type_header"),dataIndex:"catagory",width:120},{header:SYNO.SDS.DNS._V("dns","dns_log_severity"),dataIndex:"severity",width:120,renderer:function(m){var k="";var i="";if(m==parseInt(m,10)&&((-5<=parseInt(m,10))&&0>=parseInt(m,10))){var l={"0":["Debug","black"],"-1":["Info","green"],"-2":["Notice","blue"],"-3":["Warning","orange"],"-4":["Error","red"],"-5":["Critical","red"]};k=l[m][0];i=l[m][1]}else{k=m;i="grey"}var j=function(o,n){return'<span style="color:'+n+';">'+o+"</span>"};return'<div ext:qtip="'+k+'">'+j(k,i)+"</div>"}},{header:SYNO.SDS.DNS._V("dns","dns_event_info"),dataIndex:"content",id:this.lastClumnId=Ext.id(),renderer:function(i){return'<div ext:qtip="'+i+'">'+i+"</div>"},editor:new Ext.grid.GridEditor(new SYNO.ux.TextField({allowBlank:true,selectOnFocus:true,listeners:{change:function(l,k,i,j){if(k!==i){this.onReset()}},specialkey:function(j,i){if(i.type=="keydown"&&i.button==12){this.onReset()}},scope:this}}))}];var a=new Ext.grid.ColumnModel({defaultWidth:100,columns:g});this.pagingBar=new SYNO.ux.PagingToolbar({store:e,pageSize:this.pageSize,displayInfo:true});var f={itemId:"panel_logshow",colModel:a,ds:e,bbar:this.pagingBar,sm:new Ext.grid.RowSelectionModel({singleSelect:true}),loadMask:true,autoExpandColumn:this.lastClumnId,viewConfig:{forceFit:false},border:false,trackResetOnLoad:true,tbar:this.toolBar};Ext.apply(f,d);return f},createToolBar:function(){var a=new Ext.Toolbar({defaultType:"syno_button"});a.add({itemId:"btnClear",text:SYNO.SDS.DNS._V("common","clean"),handler:this.onClear,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});a.add({itemId:"btnExport",text:SYNO.SDS.DNS._V("dns","dns_export"),handler:this.onExport,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});a.add({itemId:"btnReSetting",text:SYNO.SDS.DNS._V("dns","dns_set"),handler:this.createLogSetDialog,scope:this});a.add({itemId:"btnRefresh",text:SYNO.SDS.DNS._V("common","refresh"),handler:this.onRefresh,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});a.add("->");a.add(this.searchField);return a},createStore:function(){var a=["time","catagory","severity","content","index"];var b=new SYNO.API.JsonStore({appWindow:this,api:"SYNO.DNSServer.Log",method:"list",version:1,root:"items",fields:a,sortInfo:{field:"index",direction:"DESC"},listeners:{load:function(f,c,d,e){this.loadValues=this.getValues()},exception:function(e,f,g,d,h,c){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(h.code))},scope:this}});this.addManagedComponent(b);return b},onPageActivate:function(){this.getStore().setBaseParam("start",0);this.getStore().setBaseParam("limit",this.pageSize);this.getStore().reload()},onClear:function(){this.owner.getMsgBox().confirmDelete(SYNO.SDS.DNS._V("dns","dns_msglog"),SYNO.SDS.DNS._V("dns","dns_log_delete"),function(a){if("yes"===a){this.clearLog()}},this)},clearLog:function(){this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.Log",version:1,method:"delete",callback:function(c,b,a){this.owner.clearStatusBusy();if(c){this.pagingBar.changePage(1);this.getStore().reload()}else{this.owner.getMsgBox().alert(SYNO.SDS.DNS._V("dns","dns_msglog"),SYNO.SDS.DNS._E(b.code))}},scope:this})},createLogSetDialog:function(){var a=new SYNO.SDS.DNS.LogSetPanel({owner:this.owner,creater:this});a.onInitial();a.open()},onExport:function(){this.owner.downloadWebAPI({webapi:{api:"SYNO.DNSServer.Log",method:"export",version:1}})},onRefresh:function(){this.getStore().reload()},onReset:function(){this.setValues(this.loadValues)}});Ext.define("SYNO.SDS.DNS.Instance",{extend:"SYNO.SDS.AppInstance",appWindowName:"SYNO.SDS.DNS.DNSMainWindow"});Ext.define("SYNO.SDS.DNS.DNSMainWindow",{extend:"SYNO.SDS.PageListAppWindow",width:SYNO.SDS.DNS.DNS_APP_WIDTH,height:SYNO.SDS.DNS.DNS_APP_HEIGHT,activePage:"SYNO.SDS.DNS.ZoneMngPanel",constructor:function(a){var b=[{iconCls:"icon-zones",text:SYNO.SDS.DNS._V("dns","dns_zone_management"),fn:"SYNO.SDS.DNS.ZoneMngPanel",help:"dns_server_zone_mng.html"},{iconCls:"icon-resolution",text:SYNO.SDS.DNS._V("dns","dns_resolution_services"),fn:"SYNO.SDS.DNS.ResolutionSetPanel",help:"dns_server_resolve_mng.html"},{iconCls:"icon-log",text:SYNO.SDS.DNS._V("dns","dns_msglog"),fn:"SYNO.SDS.DNS.LogShowPanel",help:"dns_server_log.html"},{iconCls:"icon-key",text:SYNO.SDS.DNS._V("dns","dns_key_management"),fn:"SYNO.SDS.DNS.KeyMngPanel",help:"dns_server_key_mng.html"},{iconCls:"icon-view",text:SYNO.SDS.DNS._V("dns","dns_view_management"),fn:"SYNO.SDS.DNS.ViewMngPanel",help:"dns_server_view_mng.html"},{iconCls:"icon-gerneral",text:SYNO.SDS.DNS._V("dns","dns_advanced_set"),fn:"SYNO.SDS.DNS.AdvanceSetPanel",help:"dns_server_adv_set.html"}];var c={cls:"syno-app-dnsserver",width:990,height:560,minWidth:990,minHeight:560,listItems:b};Ext.apply(c,a);this.callParent([c])},onBeforeSelect:function(b,c,e){var a,d=true;d=this.callParent(arguments);if(e&&e.leaf&&true===d){a=this.pageCt.getComponent(e.attributes.fn);if(a&&Ext.isFunction(a.onLeavePage)){a.onLeavePage()}}return d}});Ext.define("SYNO.SDS.DNS.ResolutionSetPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent(arguments);this.mon(this,"afterrender",function(){this.mon(this.getForm().findField("resolve_enable"),"check",this.dependencySet,this);this.mon(this.getForm().findField("limit_enable"),"check",this.dependencySet,this);this.mon(this.getForm().findField("forward_enable"),"check",this.dependencySet,this)},this)},fillConfig:function(a){var b={title:SYNO.SDS.DNS._V("dns","dns_resolution_services"),itemId:"panel_resolve",trackResetOnLoad:true,items:[{xtype:"syno_fieldset",title:SYNO.SDS.DNS._V("dns","dns_resolution_services"),autoHeight:true,items:[{xtype:"syno_checkbox",name:"resolve_enable",boxLabel:SYNO.SDS.DNS._V("dns","dns_resolution_enable"),width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_checkbox",name:"limit_enable",boxLabel:SYNO.SDS.DNS._V("dns","dns_service_client_limit"),indent:1},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_recursion_limit_desc"),indent:2},{xtype:"syno_button",name:"match_clients_btn",id:this.conditionBtnId=Ext.id(),text:SYNO.SDS.DNS._V("dns","dns_match_address"),indent:2,handler:this.onAllowRecursion,scope:this},{xtype:"syno_checkbox",name:"forward_enable",boxLabel:SYNO.SDS.DNS._V("dns","dns_forward_service_enable"),width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,indent:1},{xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_forwarder")+" 1",labelWidth:260,allowBlank:false,name:"forwarder1",vtype:"looseip",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,indent:2},{xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_forwarder")+" 2",labelWidth:260,name:"forwarder2",vtype:"looseip",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,indent:2},{xtype:"syno_combobox",name:"forward_type",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,fieldLabel:SYNO.SDS.DNS._V("dns","dns_forward_type"),labelWidth:260,store:new Ext.data.ArrayStore({fields:["abbr","display"],data:[["Forward First",SYNO.SDS.DNS._V("dns","dns_forward_first")],["Forward Only",SYNO.SDS.DNS._V("dns","dns_forward_only")]]}),displayField:"display",valueField:"abbr",value:"first",indent:2}]}],buttons:[{xtype:"syno_button",btnStyle:"blue",text:SYNO.SDS.DNS._V("common","commit"),scope:this,handler:this.onApply,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{xtype:"syno_button",text:SYNO.SDS.DNS._V("common","reset"),handler:this.onCancle,scope:this}]};Ext.apply(b,a);return b},onAllowRecursion:function(){this.ConditionDialog=new SYNO.SDS.DNS.ConditionDialog({service:SYNO.SDS.DNS.RECURSION_SERVICE,name:SYNO.SDS.DNS.RESOLUTION_NAME,owner:this.owner,isCreate:false});this.ConditionDialog.onInitial();this.ConditionDialog.open()},onPageActivate:function(){this.loadForm()},loadForm:function(){this.setStatusBusy({text:_T("common","loading")});this.owner.sendWebAPI({api:"SYNO.DNSServer.ResolutionConf",version:1,method:"get",callback:function(c,b,a){this.clearStatusBusy();if(c){this.OriSetting=b;this.getForm().setValues(this.OriSetting);this.dependencySet()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(b.code))}},scope:this})},dependencySet:function(){var b=this.getForm().findField("resolve_enable").getValue();var a=this.getForm().findField("forward_enable").getValue();var c=this.getForm().findField("limit_enable").getValue();if(b){this.setFieldEnable("forward_enable",true);this.setFieldEnable("limit_enable",true);this.setFieldEnable("forward_type",a);this.setFieldEnable("forwarder1",a);this.setFieldEnable("forwarder2",a);Ext.getCmp(this.conditionBtnId).setDisabled(!c)}else{this.setFieldEnable("forward_enable",false);this.setFieldEnable("limit_enable",false);this.setFieldEnable("forward_type",false);this.setFieldEnable("forwarder1",false);this.setFieldEnable("forwarder2",false);Ext.getCmp(this.conditionBtnId).disable()}},setFieldEnable:function(b,a){this.getForm().findField(b).setDisabled(!a)},onApply:function(){if(!this.checkDirty()){this.setStatusError({text:SYNO.SDS.DNS._V("error","nochange_subject"),clear:true});return}if(!this.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}if((true===this.OriSetting.resolve_enable)&&(false===this.getForm().findField("resolve_enable").getValue())&&(true===this.OriSetting.forward_zone_enabled)){this.owner.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("dns","dns_resolution_disable_confirm_desc"),function(a){if("yes"===a){this.applyForm()}else{this.getForm().findField("resolve_enable").setValue(true)}},this)}else{this.applyForm()}},checkDirty:function(){if(this.getForm().isDirty()){return true}return false},applyForm:function(){this.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});var a=this.getForm();var b={resolve_enable:a.findField("resolve_enable").getValue(),limit_enable:a.findField("limit_enable").getValue(),forward_enable:a.findField("forward_enable").getValue(),forward_type:a.findField("forward_type").getValue(),forwarder1:a.findField("forwarder1").getValue(),forwarder2:a.findField("forwarder2").getValue()};this.TmpSetting=b;this.TmpSetting.forward_zone_enabled=this.OriSetting.forward_zone_enabled;this.owner.sendWebAPI({api:"SYNO.DNSServer.ResolutionConf",version:1,method:"set",params:b,callback:function(e,d,c){this.clearStatusBusy();if(e){this.setStatusOK();this.OriSetting=this.TmpSetting;this.getForm().setValues(this.OriSetting)}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(d.code))}},scope:this})},onCancle:function(){this.getForm().setValues(this.OriSetting)},onPageDeactivate:function(){if(this.checkDirty()){this.owner.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("common","confirm_lostchange"),function(a){if("yes"===a){return true}},this);return false}}});Ext.define("SYNO.SDS.DNS.RRPanel",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){this.RRtype=a.RRtype;this.memoryAlert=a.memoryAlert;var b=this.fillConfig(a);this.callParent([b]);this.on("afterlayout",function(c,e){if(SYNO.SDS.DNS.TXT===this.RRtype||SYNO.SDS.DNS.SPF===this.RRtype){var d=Ext.get(this.help_input_txt_id);if(d){this.mon(d,"click",this.launchHelp.bind(this,null))}}if(this.caaTypeField){this.mon(this.caaTypeField,"select",this.updateCAAField,this)}},this,{single:true})},launchHelp:function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.DNS.Instance:dns_server_zone_mng.html"},false)},getCAAIssueInfo:function(c,a,b){return"0 "+c.getValue()+" "+a.getValue()+";"+b.getValue()},getCAAIodefInfo:function(c,a){var b=c.getValue();if("mailto"==b){return"0 "+SYNO.SDS.DNS.CAA.IODEF+" "+b+":"+a.getValue()}return"0 "+SYNO.SDS.DNS.CAA.IODEF+" "+b+"://"+a.getValue()},getCAACustomInfo:function(b,a){return"128 "+b.getValue()+' "'+a.getValue()+'"'},setCAAName:function(){this.caaTypeField=this.formPanel.getForm().findField("rr_caa_type");this.caaIssueInfo=this.formPanel.getForm().findField("rr_caa_issue_info");this.caaIodefUrl=this.formPanel.getForm().findField("rr_caa_url");this.caaIodefDomainType=this.formPanel.getForm().findField("rr_caa_iodef_domain_type");this.caaIodef=this.formPanel.getForm().findField("rr_caa_iodef_info");this.caaCustomType=this.formPanel.getForm().findField("rr_caa_custom_type");this.caaCustomInfo=this.formPanel.getForm().findField("rr_caa_custom_info");this.caaInfoParams=this.formPanel.getForm().findField("rr_caa_info_params");this.newCAACfg=function(c){var b="";var a={};a[SYNO.SDS.DNS.CAA.ISSUEWILD]=a[SYNO.SDS.DNS.CAA.ISSUE]=[{item:this.caaIssueInfo,allowBlank:false},{item:this.caaInfoParams,allowBlank:true}];a[SYNO.SDS.DNS.CAA.IODEF]=[{item:this.caaIodefDomainType,allowBlank:false},{item:this.caaIodef,allowBlank:false},{item:this.caaIodefUrl,allowBlank:false}];a[SYNO.SDS.DNS.CAA.CUSTOM]=[{item:this.caaCustomType,allowBlank:false},{item:this.caaCustomInfo,allowBlank:false}];switch(c){case SYNO.SDS.DNS.CAA.ISSUE:case SYNO.SDS.DNS.CAA.ISSUEWILD:b=this.getCAAIssueInfo.bind(null,this.caaTypeField,this.caaIssueInfo,this.caaInfoParams);break;case SYNO.SDS.DNS.CAA.IODEF:b=this.getCAAIodefInfo.bind(null,this.caaIodefDomainType,this.caaIodef);break;case SYNO.SDS.DNS.CAA.CUSTOM:b=this.getCAACustomInfo.bind(null,this.caaCustomType,this.caaCustomInfo);break;default:break}return{type:c,ui:a,infoFunc:b}}.bind(this)},fillConfig:function(a){this.formPanel=this.createFormPanel(a);this.setCAAName();var b={layout:"form",autoHeight:true,width:SYNO.SDS.DNS.DNS_RESOURCE_RECORD_WIDTH,labelwidth:SYNO.SDS.DNS.DNS_LABEL_WIDTH,border:false,items:this.formPanel,buttons:[{text:SYNO.SDS.DNS._V("common","apply"),btnStyle:"blue",handler:this.onSave,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{text:SYNO.SDS.DNS._V("common","cancel"),handler:function(){this.close()},scope:this}]};Ext.apply(b,a);return b},isFieldNeedToDisable:function(b,a){var c={};if(SYNO.SDS.DNS.BATCH_EDIT===b.mode){c={rr_owner:true,rr_ttl:true};return !!c[a]}else{if(SYNO.SDS.DNS.IsDLZZone(b.zoneName)){c={rr_ttl:true};if(SYNO.SDS.DNS.EDIT===b.mode){c=Ext.apply(c,{rr_owner:true})}return !!c[a]}}return false},isFieldNeedToHide:function(b,a){if(SYNO.SDS.DNS.BATCH_EDIT===b.mode){var c={rr_ttl:true};return !!c[a]}return false},genInputRuleLinkStr:function(){this.help_input_txt_id=Ext.id();return"<div style=padding-left:108px>"+String.format(SYNO.SDS.DNS._V("dns","dns_txt_rr_info_input_rule"),'<a id="'+this.help_input_txt_id+'" class="link-font" style="cursor:pointer">',"</a>")+"</div>"},createFormPanel:function(a){var d=[];var c;switch(a.RRtype){case SYNO.SDS.DNS.SPF:case SYNO.SDS.DNS.TXT:c="synodnsTXT";break;case SYNO.SDS.DNS.NS:c="synodnsHostname";break;default:c="synodnsRROwner"}d.push({xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_owner_desc"),hidden:this.isFieldNeedToDisable(a,"rr_owner")||this.isFieldNeedToHide(a,"rr_owner")},{xtype:"panel",layout:"hbox",fieldLabel:SYNO.SDS.DNS._V("dns","dns_owner"),border:false,items:[{xtype:"syno_textfield",name:"rr_owner",vtype:c,autoScroll:true,allowBlank:true,disabled:this.isFieldNeedToDisable(a,"rr_owner"),renderer:function(f,e){e.attr='ext:qtip="'+Ext.util.Format.htmlEncode(f)+'"';return Ext.util.Format.htmlEncode(f)}},{xtype:"syno_displayfield",htmlEncode:false,name:"domain_name"}]},{xtype:"panel",layout:"hbox",border:false,fieldLabel:"TTL",hidden:this.isFieldNeedToHide(a,"rr_ttl"),items:[{xtype:"syno_numberfield",allowBlank:false,allowDecimals:false,name:"rr_ttl",value:SYNO.SDS.DNS.IsDLZZone(a.zoneName)?SYNO.SDS.DNS.DEFAULT_DLZ_RR_TTL:SYNO.SDS.DNS.DEFAULT_RR_TTL,vtype:"digit",maxValue:2147483647,minValue:1,width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,disabled:this.isFieldNeedToDisable(a,"rr_ttl")},{xtype:"syno_displayfield",width:5},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("common","time_seconds")}]});switch(a.RRtype){case SYNO.SDS.DNS.A:d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_address"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsv4ip",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});break;case SYNO.SDS.DNS.AAAA:d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_address"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"v6ip",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});break;case SYNO.SDS.DNS.CNAME:d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_cname"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsRROwner",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});break;case SYNO.SDS.DNS.MX:d.push({xtype:"syno_numberfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_priority"),name:"mx_preference",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"digit",maxValue:65535,minValue:0,allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_host_or_domain"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsHostname",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});break;case SYNO.SDS.DNS.NS:d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_host_or_domain"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsHostname",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});break;case SYNO.SDS.DNS.SRV:d.push({xtype:"syno_numberfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_priority"),name:"rr_priority",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"digit",maxValue:65535,minValue:0,allowDecimals:false,allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")},{xtype:"syno_numberfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_weight"),name:"rr_weight",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"digit",maxValue:65535,minValue:0,allowDecimals:false,allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")},{xtype:"syno_numberfield",fieldLabel:SYNO.SDS.DNS._V("common","port"),name:"rr_port",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"port",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")},{xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_host_or_domain"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsHostname",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});break;case SYNO.SDS.DNS.TXT:d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_event_info"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsTxt",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});d.push({xtype:"syno_displayfield",htmlEncode:false,value:this.genInputRuleLinkStr()});break;case SYNO.SDS.DNS.SPF:d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_event_info"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsTxt",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});d.push({xtype:"syno_displayfield",htmlEncode:false,value:this.genInputRuleLinkStr()});break;case SYNO.SDS.DNS.PTR:d.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_host_or_domain"),name:"rr_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsHostname",allowBlank:false,disabled:this.isFieldNeedToDisable(a,"rr_info")});break;case SYNO.SDS.DNS.CAA.CAA:this.pushCAAUIComponents(d);break}var b={layout:"form",border:false,labelwidth:SYNO.SDS.DNS.DNS_LABEL_WIDTH,trackResetOnLoad:true,items:d};return new Ext.form.FormPanel(b)},pushCAAType:function(a){a.push({xtype:"syno_combobox",fieldLabel:SYNO.SDS.DNS._V("dns","dns_rr_type"),name:"rr_caa_type",indent:0,width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,store:["issue","issuewild","iodef","CA custom"],value:"issue"})},pushCAADomain:function(a){var b=this;a.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_host_or_domain"),name:"rr_caa_issue_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsHostname",allowBlank:false});a.push({xtype:"syno_compositefield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_host_or_domain"),name:"rr_caa_url",hidden:true,items:[{xtype:"syno_combobox",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH_SHORT,name:"rr_caa_iodef_domain_type",store:["http","https","mailto"],value:"http",hidden:true,allowBlank:false},{xtype:"syno_textfield",name:"rr_caa_iodef_info",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH-SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH_SHORT-5,maskRe:/[0-9A-Za-z!#$%&'*+\-\/=?^_`{|}~@\.]/,hidden:true,allowBlank:false,validator:function(c){var d=b.caaIodefDomainType.getValue();if(c.length<1||c===null){if(this.allowBlank){return true}return this.blankText}if("mailto"==d){if(Ext.form.VTypes.emailVal.test(c)){return true}return _JSLIBSTR("vtype","bad_email")}else{if(Ext.form.VTypes.hostnameVal1.test(c)&&Ext.form.VTypes.hostnameVal2.test(c)){return true}return _JSLIBSTR("vtype","bad_hostname")}}}]});a.push({xtype:"syno_textfield",fieldLabel:_T("common","properties"),name:"rr_caa_custom_type",vtype:"synodnsCAACustomType",hidden:true,width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,allowBlank:true});a.push({xtype:"syno_textfield",fieldLabel:_T("common","desc"),name:"rr_caa_custom_info",vtype:"synodnsCAACustomInfo",hidden:true,width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,allowBlank:true})},pushCAAParams:function(a){a.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","params"),name:"rr_caa_info_params",width:SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH,vtype:"synodnsCAAParams",emptyText:"e.g. X=Y Y=Z ...",allowBlank:true})},pushCAAUIComponents:function(a){this.pushCAAType(a);this.pushCAADomain(a);this.pushCAAParams(a)},caaHandler:function(b){var d=b.type;var a=b.ui;var c=b.infoFunc;return{show:function(){var e=function(f){var h=function(i){f(g,i)};for(var g in a){if(a.hasOwnProperty(g)){Ext.each(a[g],h)}}};e(function(g,f){f.item.hide();f.item.allowBlank=true});e(function(g,f){if(g===d){f.item.show();if(!f.allowBlank){f.item.allowBlank=false}}})},getInfo:function(){return c()}}},updateCAAField:function(){if(!this.caaTypeField){return}var a=this.newCAACfg(this.caaTypeField.getValue());this.caaObj=this.caaHandler(a);this.caaObj.show()},onInitial:function(){var e={};if(SYNO.SDS.DNS.CREATE===this.mode){e=SYNO.SDS.DNS._V("dns","dns_zone_resource_record_create")+" "+this.RRtype}else{if(SYNO.SDS.DNS.EDIT==this.mode){e=SYNO.SDS.DNS._V("dns","dns_zone_resource_record_edit")+" "+this.RRtype;this.formPanel.getForm().setValues(this.resourceRecord)}else{e=SYNO.SDS.DNS._V("dns","dns_zone_resource_record_edit")+" "+this.RRtype;var c=function(){var h=[];Ext.each(this.orgRecord,function(j,i){h.push(j.rr_owner)});this.formPanel.getForm().findField("rr_owner").setValue(h.join(", "));if(!this.rr_owner_tips){Ext.QuickTips.init();this.rr_owner_tips=h.join("<br>")}Ext.QuickTips.register({target:this.formPanel.getForm().findField("rr_owner").getEl(),text:this.rr_owner_tips})}.bind(this);var f=function(){var h=[];Ext.each(this.orgRecord,function(j,i){if(0>h.indexOf(j.rr_info)){h.push(j.rr_info)}});h=h.sort();this.formPanel.getForm().findField("rr_info").setValue(h.join(", "))}.bind(this);c();f()}}this.formPanel.getForm().setValues([{id:"domain_name",value:String.format('<div ext:qtip="{0}">.{1}</div>',this.domainName,this.domainName)}]);this.setTitle(e);var g=this.domainName.lastIndexOf(SYNO.SDS.DNS.V6REVERSDOMAIN);var b=0;var a=0;var d=0;if(0>g){b=185;a=SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH}else{b=this.domainName.length*6;d=SYNO.SDS.DNS.DNS_RESOURCE_RECORD_WIDTH-b-SYNO.SDS.DNS.DNS_LABEL_WIDTH-20;a=(d>20)?d:20}this.formPanel.getForm().findField("rr_owner").setWidth(a);this.formPanel.getForm().findField("domain_name").setWidth(b);this.initCAAObj()},initCAAObj:function(){if(this.caaTypeField){if(!this.caaTypeField.getValue()){this.caaTypeField.setValue(SYNO.SDS.DNS.CAA.ISSUE)}this.updateCAAField()}},onSave:function(){if(!this.formPanel.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}if(!this.formPanel.getForm().isDirty()){this.close();return}if(this.memoryAlert){this.getMsgBox().alert(this.title,SYNO.SDS.DNS._V("dns","dns_memory_not_enough"),this.saveRRrecord,this)}else{this.saveRRrecord()}},saveRRrecord:function(){var b="";var a=this.getParams();if(SYNO.SDS.DNS.CREATE===this.mode){b="create"}else{b="set";a={items:a}}this.setStatusBusy();this.sendWebAPI({api:"SYNO.DNSServer.Zone.Record",version:1,method:b,params:a,callback:function(f,e,d){this.clearStatusBusy();if(f){this.owner.zonePanel.getStore().reload();this.close()}else{if(10045===e.code){var c=function(g){return(0===g.rr_owner.length)?g.domain_name:g.rr_owner+"."+g.domain_name};this.setStatusError({text:String.format(SYNO.SDS.DNS._E(e.code),c(e.errors.key),e.errors.key.rr_info,e.errors.value.rr_info),clear:true})}else{this.setStatusError({text:SYNO.SDS.DNS._E(e.code),clear:true})}}},scope:this})},getParams:function(){var c={};var a={};var b={};if(SYNO.SDS.DNS.CREATE===this.mode){c.zone_name=this.zoneName;c.domain_name=this.domainName;c.rr_owner=this.getOwner();c.rr_ttl=this.formPanel.getForm().findField("rr_ttl").getValue().toString();c.rr_type=this.RRtype;c.rr_info=this.getInfo()}else{if(SYNO.SDS.DNS.EDIT===this.mode){a={zone_name:this.zoneName,domain_name:this.domainName,rr_owner:this.orgRecord.rr_owner,rr_type:this.orgRecord.rr_type,rr_ttl:this.orgRecord.rr_ttl,rr_info:this.orgRecord.rr_info,full_record:this.orgRecord.full_record};b={rr_owner:this.getOwner(),rr_type:this.RRtype,rr_ttl:this.formPanel.getForm().findField("rr_ttl").getValue().toString(),rr_info:this.getInfo()};c=[{key:a,value:b}]}else{c=[];Ext.each(this.orgRecord,function(e,d){a={zone_name:this.zoneName,domain_name:this.domainName,rr_owner:e.rr_owner,rr_type:e.rr_type,rr_ttl:e.rr_ttl,rr_info:e.rr_info,full_record:e.full_record};b={rr_owner:e.rr_owner,rr_type:e.rr_type,rr_ttl:e.rr_ttl,rr_info:this.getInfo()};c.push({key:a,value:b})},this)}}return c},getOwner:function(){if(""===this.formPanel.getForm().findField("rr_owner").getValue()){return this.domainName+"."}else{return this.formPanel.getForm().findField("rr_owner").getValue()+"."+this.domainName+"."}},getInfo:function(){var a=function(){return this.formPanel.getForm().findField("rr_info").getValue()}.bind(this);if(SYNO.SDS.DNS.MX==this.RRtype){return this.formPanel.getForm().findField("mx_preference").getValue()+" "+a()+"."}else{if(SYNO.SDS.DNS.NS==this.RRtype||SYNO.SDS.DNS.CNAME==this.RRtype||SYNO.SDS.DNS.PTR==this.RRtype){return a()+"."}else{if(SYNO.SDS.DNS.SRV==this.RRtype){return this.getSRVInfo(a())}else{if(SYNO.SDS.DNS.CAA.CAA===this.RRtype){return this.getCAAInfo()}else{return a()}}}}},getSRVInfo:function(b){var a=this.formPanel.getForm();return a.findField("rr_priority").getValue()+" "+a.findField("rr_weight").getValue()+" "+a.findField("rr_port").getValue()+" "+b+"."},getCAAInfo:function(){return this.caaObj.getInfo()},checkDoubleQuote:function(c){var a=0;for(var b=0;b<c.length;b++){if('"'==c[b]){a=a+1}else{if("\\"==c[b]){b=b+1}}}if(0===a%2){return c}else{return c+'"'}}});SYNO.SDS.DNS.GetConditionDialogTitle=function(a){var b="";switch(a){case SYNO.SDS.DNS.RECURSION_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_match_address");break;case SYNO.SDS.DNS.VIEW_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_view_match");break;case SYNO.SDS.DNS.TRANSFER_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_transfer_rule");break;case SYNO.SDS.DNS.UPDATE_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_update_rule");break;case SYNO.SDS.DNS.QUERY_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_match_address");break;case SYNO.SDS.DNS.NOTIFY_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_slave_ip_list");break}return b};SYNO.SDS.DNS.GetEditConditionDialogTitle=function(a,c){var b="";if(SYNO.SDS.DNS.EDIT===c){switch(a){case SYNO.SDS.DNS.RECURSION_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_match_address_edit");break;case SYNO.SDS.DNS.VIEW_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_match_edit");break;case SYNO.SDS.DNS.TRANSFER_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_transfer_edit");break;case SYNO.SDS.DNS.UPDATE_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_update_edit_rule");break;case SYNO.SDS.DNS.QUERY_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_match_address_edit");break;case SYNO.SDS.DNS.NOTIFY_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_notify_rule_edit");break}}else{switch(a){case SYNO.SDS.DNS.RECURSION_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_match_address");break;case SYNO.SDS.DNS.VIEW_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_view_match");break;case SYNO.SDS.DNS.TRANSFER_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_transfer_rule");break;case SYNO.SDS.DNS.UPDATE_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_update_create_rule");break;case SYNO.SDS.DNS.QUERY_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_match_address");break;case SYNO.SDS.DNS.NOTIFY_SERVICE:b=SYNO.SDS.DNS._V("dns","dns_notify_rule_add");break}}return b};Ext.define("SYNO.SDS.DNS.ConditionDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent(arguments);this.mon(this,"afterlayout",function(){this.mon(this.formPanel.getSelectionModel(),"selectionchange",this.onChangeBtnStatus,this);this.mon(this.formPanel,"rowdblclick",this.onEdit,this);this.mon(this.formPanel,"show",this.onShow,this)},this)},onShow:function(){if(this.isCreate&&SYNO.SDS.DNS.TRANSFER_SERVICE===this.service&&0<this.formPanel.getStore().getCount()){this.formPanel.getView().refresh()}},fillConfig:function(a){this.toolBar=this.createToolBar();this.formPanel=this.createformPanel(a);this.btnDel=this.toolBar.getComponent("btnDelete");this.btnEdit=this.toolBar.getComponent("btnModify");var b={title:SYNO.SDS.DNS._V("dns","dns_match_address_edit"),resizable:false,height:SYNO.SDS.DNS.DNS_DIALOG_HEIGHT,width:SYNO.SDS.DNS.DNS_DIALOG_WIDTH+20,items:[this.formPanel],buttons:[{text:SYNO.SDS.DNS._V("common","alt_finish"),handler:function(){this.hide()},scope:this}]};Ext.apply(b,a);return b},createToolBar:function(){var a=new Ext.Toolbar({defaultType:"syno_button"});a.add({itemId:"btnCreate",text:SYNO.SDS.DNS._V("common","create"),handler:this.onCreate,scope:this});a.add({itemId:"btnModify",text:SYNO.SDS.DNS._V("common","alt_edit"),handler:this.onEdit,disabled:true,scope:this});a.add({itemId:"btnDelete",text:SYNO.SDS.DNS._V("common","delete"),handler:this.onDelete,disabled:true,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this});return a},renderConditionType:function(d,b,a){var c;if(this.isCreate&&SYNO.SDS.DNS.AD_REVERSE===this.getDomainType()){if(SYNO.SDS.DNS.SUBNET===d){c='<font class="red-status">'+SYNO.SDS.DNS._V("firewall","firewall_source_network")+"</font>"}else{if(SYNO.SDS.DNS.KEY===d){c='<font class="red-status">'+SYNO.SDS.DNS._V("dns","dns_key")+"</font>"}}}if(c){b.attr='ext:qtip="'+Ext.util.Format.htmlEncode(SYNO.SDS.DNS._V("app_port_alias","err_invalid_header_value"))+'"';return c}return SYNO.SDS.DNS.RenderConditionType(d,b)},renderConditionVal:function(d,b,a){var c;if(this.isCreate&&SYNO.SDS.DNS.AD_REVERSE===this.getDomainType()){if(SYNO.SDS.DNS.SUBNET===a.data.condition_type||SYNO.SDS.DNS.KEY===a.data.condition_type){c='<font class="red-status">'+d+"</font>"}}if(c){b.attr='ext:qtip="'+Ext.util.Format.htmlEncode(SYNO.SDS.DNS._V("app_port_alias","err_invalid_header_value"))+'"';return c}return d},createformPanel:function(b){var c=[{header:SYNO.SDS.DNS._V("mediaservice","type"),dataIndex:"condition_type",id:"address",width:150,renderer:this.renderConditionType.bind(this)},{header:SYNO.SDS.DNS._V("dns","dns_match_address"),dataIndex:"condition_info",renderer:this.renderConditionVal.bind(this),id:this.expendColumeId=Ext.id()}];var a=new Ext.grid.ColumnModel({columns:c});var d=new SYNO.API.JsonStore({appWindow:b.owner,api:"SYNO.DNSServer.Condition",method:"list",version:1,root:"items",fields:["condition_type","condition_info"],listeners:{exception:function(h,i,j,g,k,f){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(k.code))},scope:this}});var e={layout:"fit",height:375,width:SYNO.SDS.DNS.DNS_DIALOG_WIDTH,loadMask:true,tbar:this.toolBar,enableColLock:false,enableHdMenu:false,enableColumnMove:false,autoExpandColumn:this.expendColumeId,colModel:a,ds:d};return new SYNO.ux.GridPanel(e)},onInitial:function(){if(!this.isCreate&&this.service&&this.name){this.formPanel.getStore().setBaseParam("service",this.service);this.formPanel.getStore().setBaseParam("name",this.name);this.formPanel.getStore().reload()}this.setTitle(SYNO.SDS.DNS.GetConditionDialogTitle(this.service))},isDirty:function(){return(this.isCreate&&this.formPanel.getStore().getCount()>0)?true:false},isValid:function(){var a=true;var b=function(c,d){return(SYNO.SDS.DNS.ADDRESS!==c.data.condition_type)?true:false};if(this.isCreate&&SYNO.SDS.DNS.AD_REVERSE===this.getDomainType()){if(-1!=this.formPanel.getStore().findBy(b)){a=false}}return a},getCompoundParams:function(h){var c=[];var a=this.service;var d=h.name;var b=this.formPanel.getStore();var f=(this.isCreate&&SYNO.SDS.DNS.AD_REVERSE===this.getDomainType())?true:false;for(var e=0;e<b.getCount();e++){var g=b.getAt(e).data;if(f&&SYNO.SDS.DNS.ADDRESS!==g.condition_type){continue}c.push({api:"SYNO.DNSServer.Condition",version:1,method:"create",params:{service:a,name:d,condition_type:g.condition_type,condition_info:g.condition_info}})}return c},getDomainType:function(){return(this.domainTypeField)?this.domainTypeField.getValue():undefined},onCreate:function(){var b={owner:this,mode:SYNO.SDS.DNS.CREATE,service:this.service,name:this.name,domain_type:this.getDomainType(),isCreate:this.isCreate};var a=new SYNO.SDS.DNS.EditConditionDialog(b);a.onInitial();a.open()},onEdit:function(){var c=this.formPanel.getSelectionModel().getSelected();var a=c.get("condition_type");var b=c.get("condition_info");var e={owner:this,mode:SYNO.SDS.DNS.EDIT,service:this.service,name:this.name,domain_type:this.getDomainType(),isCreate:this.isCreate,selection:c,org_condition_type:a,org_condition_info:b};var d=new SYNO.SDS.DNS.EditConditionDialog(e);d.onInitial();d.open()},onChangeBtnStatus:function(){var a=this.formPanel.getSelectionModel();var b=a.getCount();if(0<b){if(_S("demo_mode")){this.btnDel.disable()}else{this.btnDel.enable()}}else{this.btnDel.disable()}if(1==b){this.btnEdit.enable()}else{this.btnEdit.disable()}},onDelete:function(){this.getMsgBox().confirmDelete(this.title,SYNO.SDS.DNS._V("dns","dns_delete_sure"),function(a){if("yes"===a){var b=this.formPanel.getSelectionModel().getSelections();if(!this.isCreate){this.deleteData(b)}else{this.formPanel.getStore().remove(b)}}},this)},deleteData:function(b){var d=[];var c={};for(var a=0;a<b.length;a++){d.push({condition_info:b[a].get("condition_info"),condition_type:b[a].get("condition_type")})}c.items=d;c.name=this.name;c.service=this.service;this.setStatusBusy();this.sendWebAPI({api:"SYNO.DNSServer.Condition",version:1,method:"delete",params:c,callback:function(g,f,e){this.clearStatusBusy();if(g){this.formPanel.getStore().reload()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(f.code))}},scope:this})}});Ext.define("SYNO.SDS.DNS.EditConditionDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){this.config=this.fillConfig(a);SYNO.SDS.DNS.EditConditionDialog.superclass.constructor.call(this,this.config);this.DefineBehaviors()},initEvents:function(){this.callParent(arguments);this.mon(this,"afterlayout",function(){this.mon(this.editPanel.getForm().findField("source"),"checked",this.OnSourceRadioClick,this)},this)},fillConfig:function(a){this.store=this.createStore();this.editPanel=this.createPanel();var b={title:SYNO.SDS.DNS._V("dns","dns_match_address")+" - "+SYNO.SDS.DNS._V("common","create"),width:525,height:300,trackResetOnLoad:true,items:this.editPanel,buttons:[{text:SYNO.SDS.DNS._V("common","apply"),btnStyle:"blue",disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"apply",handler:this.onSave,scope:this},{text:SYNO.SDS.DNS._V("common","cancel"),itemId:"cancel",handler:this.onCancel,scope:this}]};Ext.apply(b,a);return b},DefineBehaviors:function(){this.OnSourceRadioClick(this.editPanel.getForm().findField("source"),true)},createPanel:function(){var c=new SYNO.ux.CompositeField({hideLabel:true,items:[{xtype:"syno_radio",name:"source",itemId:"dns_xfer_byip",boxLabel:SYNO.SDS.DNS._V("nfs","nfs_fieldtitle_host"),inputValue:SYNO.SDS.DNS.ADDRESS,id:this.hostRadioId=Ext.id(),scope:this,checked:true,handler:this.OnSourceRadioClick},{xtype:"syno_radio",name:"source",itemId:"dns_xfer_bynetmask",boxLabel:SYNO.SDS.DNS._V("firewall","firewall_source_network"),inputValue:SYNO.SDS.DNS.SUBNET,id:this.subnetRadioId=Ext.id(),scope:this,handler:this.OnSourceRadioClick},{xtype:"syno_radio",name:"source",itemId:"dns_xfer_bykey",boxLabel:SYNO.SDS.DNS._V("dns","dns_key"),inputValue:SYNO.SDS.DNS.KEY,scope:this,id:this.keyNameRadioId=Ext.id(),hidden:true,handler:this.OnSourceRadioClick}]});var b={xtype:"fieldset",border:false,trackResetOnLoad:true,title:SYNO.SDS.DNS._V("dns","dns_slave_rule"),itemId:"dns_slave_rule",items:[c,{xtype:"syno_displayfield"},{xtype:"syno_textfield",width:SYNO.SDS.DNS.DNS_LABEL_WIDTH,fieldLabel:SYNO.SDS.DNS._V("tcpip","tcpip_ipaddr"),name:SYNO.SDS.DNS.ADDRESS,itemId:"tcpip_ipaddr",vtype:"synodnslooseip",validator:function(e){var f=e;var d="";if(Ext.form.VTypes.loosev4ipVal.test(f)){d="netmask, e.g., 255.255.255.0"}else{if(Ext.form.VTypes.loosev6ipVal.test(f)){d="CIDR number, e.g., 64"}}this.nextSibling().emptyText=d;this.nextSibling().applyEmptyText();if(Ext.form.VTypes.synodnslooseip(f)){this.nextSibling().validate();return true}else{return false}}},{xtype:"syno_textfield",width:SYNO.SDS.DNS.DNS_LABEL_WIDTH,fieldLabel:SYNO.SDS.DNS._V("tcpip","tcpip_mask"),name:SYNO.SDS.DNS.SUBNET,itemId:"tcpip_mask",maskRe:/[.0-9]/,invalidText:_JSLIBSTR("vtype","bad_mask"),allowBlank:false,validator:function(d){var e=this.previousSibling().getValue();if(Ext.form.VTypes.loosev6ipVal.test(e)){if(d>=0&&d<=128){return true}else{return _JSLIBSTR("vtype","bad_ipv6prefixLeng")}}else{if(Ext.form.VTypes.netmaskVal.test(d)){return true}}return false}},{xtype:"syno_textfield",width:SYNO.SDS.DNS.DNS_LABEL_WIDTH,fieldLabel:SYNO.SDS.DNS._V("common","port"),name:SYNO.SDS.DNS.PORT,itemId:"tcpip_port",maskRe:/[0-9]/,invalidText:_JSLIBSTR("vtype","bad_port"),allowBlank:false,value:"53",hidden:true,id:this.tcpipPortFieldId=Ext.id(),validator:function(e){var d=this.getValue();if(0>=d||65535<d){return _JSLIBSTR("vtype","bad_port")}return true}},{xtype:"syno_combobox",width:SYNO.SDS.DNS.DNS_LABEL_WIDTH,fieldLabel:SYNO.SDS.DNS._V("dns","dns_key_name"),name:SYNO.SDS.DNS.KEY,triggerAction:"all",displayField:"key_name",valueField:"key_name",forceSelection:true,allowBlank:false,disabled:true,editable:false,hidden:true,id:this.keyNameComboId=Ext.id(),store:this.store,scope:this}]};var a={trackResetOnLoad:true,border:false,height:300,items:b};return new SYNO.ux.FormPanel(a)},createStore:function(){var a=new SYNO.API.JsonStore({appWindow:this,api:"SYNO.DNSServer.Key",method:"list",version:1,root:"items",fields:["key_name"],listeners:{exception:function(d,e,f,c,g,b){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(g.code))},scope:this}});this.addManagedComponent(a);return a},OnSourceRadioClick:function(a,b){this.conditionType=this.editPanel.getForm().findField("source").getGroupValue();switch(this.conditionType){case SYNO.SDS.DNS.ADDRESS:this.editPanel.getForm().findField(SYNO.SDS.DNS.ADDRESS).enable();this.editPanel.getForm().findField(SYNO.SDS.DNS.SUBNET).disable();this.editPanel.getForm().findField(SYNO.SDS.DNS.KEY).disable();break;case SYNO.SDS.DNS.SUBNET:this.editPanel.getForm().findField(SYNO.SDS.DNS.ADDRESS).enable();this.editPanel.getForm().findField(SYNO.SDS.DNS.SUBNET).enable();this.editPanel.getForm().findField(SYNO.SDS.DNS.KEY).disable();break;case SYNO.SDS.DNS.KEY:this.editPanel.getForm().findField(SYNO.SDS.DNS.ADDRESS).disable();this.editPanel.getForm().findField(SYNO.SDS.DNS.SUBNET).disable();this.editPanel.getForm().findField(SYNO.SDS.DNS.KEY).enable();break;default:break}},onInitial:function(){var b="";if(!_S("demo_mode")){this.store.reload()}if(SYNO.SDS.DNS.IsDLZZone(this.name)||(this.isCreate&&SYNO.SDS.DNS.AD_REVERSE===this.domain_type)){Ext.getCmp(this.subnetRadioId).setDisabled(true);Ext.getCmp(this.keyNameRadioId).setDisabled(true)}Ext.getCmp(this.keyNameRadioId).hide();Ext.getCmp(this.keyNameComboId).hide();SYNO.SDS.Utils.DisplayField(this.editPanel.getForm(),SYNO.SDS.DNS.KEY,false);Ext.getCmp(this.tcpipPortFieldId).hide();Ext.getCmp(this.hostRadioId).show();Ext.getCmp(this.subnetRadioId).show();if(SYNO.SDS.DNS.TRANSFER_SERVICE==this.service||SYNO.SDS.DNS.UPDATE_SERVICE==this.service){Ext.getCmp(this.keyNameComboId).show();Ext.getCmp(this.keyNameRadioId).show();SYNO.SDS.Utils.DisplayField(this.editPanel.getForm(),SYNO.SDS.DNS.KEY,true)}else{if(SYNO.SDS.DNS.NOTIFY_SERVICE==this.service){Ext.getCmp(this.hostRadioId).hide();Ext.getCmp(this.subnetRadioId).hide();SYNO.SDS.Utils.DisplayField(this.editPanel.getForm(),SYNO.SDS.DNS.SUBNET,false);Ext.getCmp(this.tcpipPortFieldId).show()}}if(SYNO.SDS.DNS.EDIT==this.mode){if(SYNO.SDS.DNS.KEY==this.org_condition_type){this.editPanel.getForm().findField("source").setValue(SYNO.SDS.DNS.KEY);this.editPanel.getForm().setValues([{id:"source",value:SYNO.SDS.DNS.KEY},{id:SYNO.SDS.DNS.KEY,value:this.org_condition_info}])}else{if(SYNO.SDS.DNS.ADDRESS==this.org_condition_type){if(SYNO.SDS.DNS.NOTIFY_SERVICE===this.service){var a=this.org_condition_info.indexOf("port");this.editPanel.getForm().setValues([{id:"source",value:SYNO.SDS.DNS.ADDRESS},{id:SYNO.SDS.DNS.ADDRESS,value:this.org_condition_info.substring(0,a-1)},{id:SYNO.SDS.DNS.PORT,value:this.org_condition_info.substring(a+1+"port".length)}])}else{this.editPanel.getForm().setValues([{id:"source",value:SYNO.SDS.DNS.ADDRESS},{id:SYNO.SDS.DNS.ADDRESS,value:this.org_condition_info}])}}else{if(SYNO.SDS.DNS.SUBNET==this.org_condition_type){this.editPanel.getForm().findField("source").setValue(SYNO.SDS.DNS.SUBNET);var c=this.org_condition_info;var d=c.split("/");this.editPanel.getForm().setValues([{id:"source",value:SYNO.SDS.DNS.SUBNET},{id:SYNO.SDS.DNS.ADDRESS,value:d[0]},{id:SYNO.SDS.DNS.SUBNET,value:d[1]}])}}}}b=SYNO.SDS.DNS.GetEditConditionDialogTitle(this.service,this.mode);this.setTitle(b)},onSave:function(){if(!this.editPanel.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}if(!this.editPanel.getForm().isDirty()){this.close();return}this.saveCondition()},saveCondition:function(){var c=this.getParams();if(this.isCreate){var b=this.owner.formPanel.getStore();var a=new b.recordType(c,c.id);c.id=Ext.id();if(SYNO.SDS.DNS.CREATE===this.config.mode){b.add(a);b.commitChanges();this.close()}else{if(SYNO.SDS.DNS.EDIT===this.config.mode){b.add(a);b.remove(this.config.selection);b.commitChanges();this.close()}}}else{this.setStatusBusy();if(SYNO.SDS.DNS.CREATE===this.config.mode){this.sendWebAPI({api:"SYNO.DNSServer.Condition",version:1,method:"create",params:{service:c.service,name:c.name,condition_type:c.condition_type,condition_info:c.condition_info},callback:function(f,e,d){this.clearStatusBusy();if(f){this.owner.formPanel.getStore().reload();this.close()}else{if(e.code===10036){this.owner.getMsgBox().alert(this.title,String.format(SYNO.SDS.DNS._E(e.code),e.errors.zone,e.errors.views))}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}}},scope:this})}else{if(SYNO.SDS.DNS.EDIT===this.config.mode){this.sendWebAPI({api:"SYNO.DNSServer.Condition",version:1,method:"set",params:{service:c.service,name:c.name,condition_type:c.condition_type,condition_info:c.condition_info,org_condition_type:this.selection.data.condition_type,org_condition_info:this.selection.data.condition_info},callback:function(f,e,d){this.clearStatusBusy();if(f){this.owner.formPanel.getStore().reload();this.close()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}},scope:this})}}}},getParams:function(){var a={};a.service=this.service;a.name=this.name;if(SYNO.SDS.DNS.NOTIFY_SERVICE===this.service){a.condition_type=SYNO.SDS.DNS.ADDRESS;a.condition_info=this.getFieldValue(SYNO.SDS.DNS.ADDRESS)+" port "+this.getFieldValue(SYNO.SDS.DNS.PORT)}else{switch(this.conditionType){case SYNO.SDS.DNS.ADDRESS:a.condition_type=SYNO.SDS.DNS.ADDRESS;a.condition_info=this.getFieldValue(SYNO.SDS.DNS.ADDRESS);break;case SYNO.SDS.DNS.SUBNET:a.condition_type=SYNO.SDS.DNS.SUBNET;a.condition_info=this.getFieldValue(SYNO.SDS.DNS.ADDRESS)+"/"+this.getFieldValue(SYNO.SDS.DNS.SUBNET);break;case SYNO.SDS.DNS.KEY:a.condition_type=SYNO.SDS.DNS.KEY;a.condition_info=this.getFieldValue(SYNO.SDS.DNS.KEY);break}}if(SYNO.SDS.DNS.EDIT==this.mode){a.org_condition_info=this.org_condition_info;a.org_condition_type=this.org_condition_type}return a},getFieldValue:function(a){return this.editPanel.getForm().findField(a).getValue()},onCancel:function(){var a=this.editPanel.getForm().findField("source").getGroupValue();if(this.editPanel.getForm().findField(a).isDirty()){this.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("common","confirm_lostchange"),function(b){if("yes"===b){this.close()}},this);return}this.close()}});Ext.define("SYNO.SDS.DNS.ViewAddPanel",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent([arguments]);this.mon(this,"afterrender",function(){var a;var b;a=new SYNO.SDS.Utils.EnableCheckGroup(this.formPanel.getForm(),"forward_enable",["forwarder1","forwarder2","forward_type"]);b=new SYNO.SDS.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_enable",[this.matchClientBtnId])},this)},fillConfig:function(a){this.formPanel=this.createFormPanel();this.zonePanel=this.createZonePanel();var b={title:SYNO.SDS.DNS._V("dns","dns_view_create"),height:SYNO.SDS.DNS.DNS_GRID_HEIGHT,width:SYNO.SDS.DNS.DNS_TAB_PAENL_WIDTH,items:[{xtype:"syno_tabpanel",plain:true,activeTab:0,items:[{title:SYNO.SDS.DNS._V("dns","dns_general_set"),height:SYNO.SDS.DNS.DNS_GRID_HEIGHT-130,width:SYNO.SDS.DNS.DNS_TAB_PAENL_WIDTH-10,border:false,items:this.formPanel},{title:SYNO.SDS.DNS._V("dns","dns_view_select_zone"),height:SYNO.SDS.DNS.DNS_GRID_HEIGHT-130,width:SYNO.SDS.DNS.DNS_TAB_PAENL_WIDTH-10,border:false,items:this.zonePanel,listeners:{activate:function(){if(!this.zonePanelisActive){this.zonePanel.getStore().loadData(this.zone_info_arr);this.zonePanel.getView().updateScroller();this.zonePanelisActive=true}},scope:this}}]}],buttons:[{text:SYNO.SDS.DNS._V("common","apply"),handler:this.onSave,btnStyle:"blue",scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{text:SYNO.SDS.DNS._V("common","cancel"),handler:this.onCancle,scope:this}]};Ext.apply(b,a);return b},createFormPanel:function(){var a={layout:"form",border:false,height:SYNO.SDS.DNS.DNS_GRID_HEIGHT-130,labelWidth:220,trackResetOnLoad:true,items:[{xtype:"syno_textfield",indent:1,maxlength:32,name:"view_name",vtype:"synodnsName",fieldLabel:SYNO.SDS.DNS._V("dns","dns_view_name"),allowBlank:false,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_checkbox",name:"limit_enable",indent:1,hideLabel:true,boxLabel:SYNO.SDS.DNS._V("dns","dns_service_client_limit")},{xtype:"syno_button",name:"match_clients_btn",id:this.matchClientBtnId=Ext.id(),indent:2,autoWidth:true,text:SYNO.SDS.DNS._V("dns","dns_view_match"),handler:this.matchActive,scope:this},{htmlEncode:false,xtype:"syno_displayfield",value:"&nbsp;"},{xtype:"syno_checkbox",indent:1,name:"forward_enable",boxLabel:SYNO.SDS.DNS._V("dns","dns_forward_service_enable"),width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,hideLabel:true},{xtype:"syno_textfield",indent:2,vtype:"ip",name:"forwarder1",allowBlank:false,fieldLabel:SYNO.SDS.DNS._V("dns","dns_forwarder")+" 1",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_textfield",indent:2,vtype:"ip",name:"forwarder2",fieldLabel:SYNO.SDS.DNS._V("dns","dns_forwarder")+" 2",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_combobox",name:"forward_type",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,fieldLabel:SYNO.SDS.DNS._V("dns","dns_forward_type"),store:new Ext.data.ArrayStore({fields:["abbr","display"],data:[["Forward First",SYNO.SDS.DNS._V("dns","dns_forward_first")],["Forward Only",SYNO.SDS.DNS._V("dns","dns_forward_only")]]}),displayField:"display",valueField:"abbr",value:"Forward First",mode:"local",triggerAction:"all",indent:2}]};return new SYNO.ux.FormPanel(a)},createZonePanel:function(){this.enableColumn=new SYNO.ux.EnableColumn({dataIndex:"select",menuDisabled:true,sortable:false,width:41,align:"center",listeners:{click:function(g,h,j){var f=h.getStore();var e=f.getAt(j);var i=false;if(!SYNO.SDS.DNS.IsDLZZone(e.get("zone_name"))){return}i=e.get("select");f.each(function(k){if(SYNO.SDS.DNS.IsDLZZone(k.get("zone_name"))){k.set("select",i)}})}}});var c=[this.enableColumn,{header:SYNO.SDS.DNS._V("dns","dns_zone_name"),dataIndex:"zone_name"},{header:SYNO.SDS.DNS._V("dns","dns_domain_name_header"),dataIndex:"domain_name"},{header:SYNO.SDS.DNS._V("dns","dns_zone_type"),dataIndex:"zone_type",id:this.expendColumeId=Ext.id()}];var a=new Ext.grid.ColumnModel({defaultWidth:150,columns:c});var b=this.createStore();var d={height:SYNO.SDS.DNS.DNS_GRID_HEIGHT-130,autoWidth:true,stateful:true,enableColLock:false,enableHdMenu:false,plugins:[this.enableColumn],enableColumnMove:false,autoExpandColumn:this.expendColumeId,colModel:a,ds:b};return new SYNO.ux.GridPanel(d)},onInitial:function(){if(!this.isCreate){var a=SYNO.SDS.DNS._V("dns","dns_view_edit");this.setTitle(a)}this.loadForm()},loadForm:function(){var a=0;var c=null;var b=[];if(!this.isCreate){b.push({api:"SYNO.DNSServer.View",version:1,method:"get",params:{view_name:this.name}})}b.push({api:"SYNO.DNSServer.Zone",method:"list",params:{offset:0,limit:-1},version:1});this.setStatusBusy();this.sendWebAPI({scope:this,compound:{stopwhenerror:true,params:b},callback:function(m,f,i){this.zone_info_arr=[];if(!f.has_fail){var j=function(n){var o={};if(n){n.forEach(function(p){o[p]=true})}return o};for(a=0;a<b.size();a++){c=SYNO.API.Util.GetValByAPI(f,b[a].api,b[a].method);if("SYNO.DNSServer.View"===b[a].api&&"get"===b[a].method){this.OriSetting=c;this.formPanel.getForm().setValues(this.OriSetting)}else{if("SYNO.DNSServer.Zone"===b[a].api&&"list"===b[a].method){var g=c.items;var e=(this.isCreate)?{}:j(this.OriSetting.include_zone);for(var k=0;k<g.size();k++){var h=g[k];var d=(h.zone_name in e);this.zone_info_arr.push([d,h.zone_name,h.domain_name,h.zone_type])}}}}this.clearStatusBusy()}else{this.clearStatusBusy();var l=function(){this.close()}.bind(this);for(a=0;a<b.size();a++){if(!f.result[a].success){c=SYNO.API.Util.GetValByAPI(f,b[a].api,b[a].method);this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(c.code),l);break}}}}})},matchActive:function(){var a={owner:this.owner,name:this.name,service:SYNO.SDS.DNS.VIEW_SERVICE,isCreate:this.isCreate};if(!this.DomainDialog){this.DomainDialog=new SYNO.SDS.DNS.ConditionDialog(a);this.DomainDialog.onInitial();this.DomainDialog.open()}else{this.DomainDialog.show()}},onSave:function(){if(!this.formPanel.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}if(!this.formPanel.getForm().isDirty()&&!this.isModify()){this.creater.getStore().reload();this.close();return}if(this.zonePanelisActive&&this.conflictCheck()){this.getMsgBox().alert(this.title,SYNO.SDS.DNS._V("dns","dns_domain_conflict"));return}this.saveView()},createCondition:function(c){var a=c.view_name;var b=[];if(this.DomainDialog){b=this.DomainDialog.getCompoundParams({name:a})}if(b){this.sendWebAPI({scope:this,compound:{stopwhenerror:false,params:b},callback:function(h,g,e){this.creater.getStore().reload();if(g.has_fail){for(var d=0;d<b.size();d++){var f=SYNO.API.Util.GetValByAPI(g,b[d].api,b[d].method);this.creater.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(f.code));break}}}})}},saveView:function(){var d="";var c={};var a=[];var b=false;if(!this.isCreate){d="set";c.org_name=this.OriSetting.view_name;c.priority=this.OriSetting.priority}else{d="create";c.priority=this.priority+1}if(this.zonePanelisActive){b=true;a=this.getSelected()}c.include_change=b;c.include_zone=a;c.view_name=this.formPanel.getForm().findField("view_name").getValue();c.forwarders=[this.formPanel.getForm().findField("forwarder1").getValue(),this.formPanel.getForm().findField("forwarder2").getValue()];c.forward_type=this.formPanel.getForm().findField("forward_type").getValue();c.forward_enable=this.formPanel.getForm().findField("forward_enable").getValue();c.limit_enable=this.formPanel.getForm().findField("limit_enable").getValue();this.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.View",version:1,method:d,params:d==="create"?c:{items:[c]},callback:function(g,f,e){this.clearStatusBusy();if(g){this.creater.getStore().reload();this.close();if(this.isCreate){this.createCondition({view_name:f.view_name})}}else{if(f.code==10034||f.code==10035){this.getMsgBox().alert(this.title,String.format(SYNO.SDS.DNS._E(f.code),f.errors.zone,f.errors.view))}else{this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(f.code))}}},scope:this})},isModify:function(){if(!this.zonePanelisActive){return false}var b=this.zonePanel.getStore().getCount();for(var a=0;a<b;a++){var c=this.zonePanel.getStore().getAt(a);if(c&&c.dirty){return true}}return false},getSelected:function(){var b=[];if(this.zonePanelisActive){var a=this.zonePanel.getStore();a.each(function(c){if(c.get("select")){b.push(c.get("zone_name"))}})}return b},createStore:function(){var a=new Ext.data.ArrayStore({fields:["select","zone_name","domain_name","zone_type"],data:[]});this.addManagedComponent(a);return a},onCancle:function(){if(this.formPanel.getForm().isDirty()||this.isModify()){this.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("common","confirm_lostchange"),function(a){if("yes"===a){this.creater.onPageActivate();this.close()}},this)}else{this.creater.onPageActivate();this.close()}},hasDomain:function(c,b){if(0===c.length){return false}for(var a=0;a<c.length;a++){if(c[a].toLowerCase()==b.toLowerCase()){return true}}return false},conflictCheck:function(){var c=false;var a=[];var b=this.zonePanel.getStore();b.each(function(d){if(d.get("select")){if(this.hasDomain(a,d.get("domain_name"))){c=true;d.set("select",false)}else{a.push(d.get("domain_name"))}}},this);return c}});Ext.define("SYNO.SDS.DNS.ViewMngPanel",{extend:"SYNO.ux.GridPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent(arguments);this.mon(this,"afterlayout",function(){this.mon(this.getSelectionModel(),"selectionchange",this.onChangeBtnStatus,this);this.mon(this.getStore(),"load",this.keepSelect,this);this.mon(this,"rowdblclick",this.onEdit,this);this.mon(this,"afterlayout",function(){var a;a=new Ext.dd.DropTarget(this.getView().mainBody,{ddGroup:"DNSViewPriorityDD",copy:false,scope:this,notifyDrop:function(b,d,c){return this.scope.moveView(b.getDragData(d).rowIndex,c.selections,c.grid.getStore())}})},this,{single:true})},this)},fillConfig:function(c){this.panelName=SYNO.SDS.DNS._V("dns","dns_view_management");this.toolBar=this.createToolBar();this.upBtn=this.toolBar.getComponent("btnUp");this.downBtn=this.toolBar.getComponent("btnDown");this.deleteBtn=this.toolBar.getComponent("btnDelete");this.editBtn=this.toolBar.getComponent("btnEdit");var f=[{header:SYNO.SDS.DNS._V("dns","dns_priority"),dataIndex:"priority"},{header:SYNO.SDS.DNS._V("dns","dns_view_name_header"),dataIndex:"view_name",width:200},{header:SYNO.SDS.DNS._V("dns","dns_view_match"),dataIndex:"match_list",id:this.lastClumnId=Ext.id(),renderer:function(h){return'<div ext:qtip="'+h+'">'+h+"</div>"}}];var b=new Ext.grid.ColumnModel({columns:f});var a=["index","priority","view_name","match_list","forwarder1","forwarder2","forward_type","include_zone","forward_enable"];var d=new SYNO.API.JsonStore({appWindow:this,api:"SYNO.DNSServer.View",method:"list",version:1,root:"items",fields:a,listeners:{exception:function(j,k,l,i,m,h){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(m.code))},scope:this}});var g=new SYNO.ux.PagingToolbar({store:d,pageSize:100,displayInfo:true});var e={enableDragDrop:true,ddGroup:"DNSViewPriorityDD",colModel:b,ds:d,bbar:g,sm:new Ext.grid.RowSelectionModel(),loadMask:true,autoExpandColumn:this.lastClumnId,itemId:"panel_viewmng",tbar:this.toolBar};Ext.apply(e,c);return e},createToolBar:function(){var a=new Ext.Toolbar({defaultType:"syno_button"});a.add({text:SYNO.SDS.DNS._V("common","create"),handler:this.onCreate,scope:this});a.add({text:SYNO.SDS.DNS._V("common","alt_edit"),itemId:"btnEdit",handler:this.onEdit,disabled:true,scope:this});a.add({text:SYNO.SDS.DNS._V("common","delete"),itemId:"btnDelete",disabled:true,handler:this.onDelete,scope:this,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});a.add({text:SYNO.SDS.DNS._V("dns","dns_up"),itemId:"btnUp",disabled:true,handler:this.onUp,scope:this,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});a.add({text:SYNO.SDS.DNS._V("dns","dns_down"),itemId:"btnDown",disabled:true,handler:this.onDown,scope:this,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});return a},onPageActivate:function(){this.getStore().reload();this.getStore().sort("index","ASC");this.doLayout()},onCreate:function(){var a=new SYNO.SDS.DNS.ViewAddPanel({owner:this.owner,creater:this,isCreate:true,name:"tmp",priority:this.getStore().getCount()});a.onInitial();a.open()},onEdit:function(){var b=this.getSelectionModel().getSelections();var a=b[0].get("view_name");var c=new SYNO.SDS.DNS.ViewAddPanel({owner:this.owner,creater:this,isCreate:false,name:a});c.onInitial();c.open()},onDelete:function(){this.owner.getMsgBox().confirmDelete(this.panelName,SYNO.SDS.DNS._V("dns","dns_view_delete"),function(a){if("yes"===a){var b=this.getSelectionModel().getSelections();this.deleteView(b)}},this)},onUp:function(){var c=this.getSelectionModel().getSelected();var d=c.get("view_name");var b=c.get("priority");var a=b-1;if(1==b){this.selectRow=b;return}this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.View",version:1,method:"get",params:{view_name:d},callback:function(g,f,e){if(g){this.owner.sendWebAPI({api:"SYNO.DNSServer.View",version:1,method:"set",params:{items:[{org_name:f.view_name,priority:f.priority-1}]},callback:function(j,i,h){if(!j){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(i.code))}this.getStore().reload();this.selectRow=a-1;this.owner.clearStatusBusy()},scope:this})}else{this.owner.clearStatusBusy();this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(f.code))}},scope:this})},onDown:function(){var c=this.getSelectionModel().getSelected();var b=c.get("priority");var a=b-1;if(this.getStore().getCount()<=b){this.selectRow=b;return}var d=this.getStore().getAt(a+1).get("view_name");this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.View",version:1,method:"get",params:{view_name:d},callback:function(g,f,e){if(g){this.owner.sendWebAPI({api:"SYNO.DNSServer.View",version:1,method:"set",params:{items:[{org_name:f.view_name,priority:f.priority-1}]},callback:function(j,i,h){if(!j){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(i.code))}this.getStore().reload();this.selectRow=a+1;this.owner.clearStatusBusy()},scope:this})}else{this.owner.clearStatusBusy();this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(f.code))}},scope:this})},moveView:function(c,d,e){var f=d[0].get("priority");var g=0;var a=[];if(undefined===c){return false}if(d.length==e.getCount()){return false}if(f==c+1){return}e.each(function(h){if(-1!=d.indexOf(h)){a.push(h)}},this);for(var b=0;b<a.length;b++){if(c>(a[b].get("priority")-1)){g=g+1}}for(b=0;b<a.length;b++){e.remove(a[b])}if(c<f){e.insert(c,a)}else{e.insert(c-g+1,a)}this.reSetPriority()},reSetPriority:function(){var a=[];var b=1;this.getStore().each(function(c){a.push({org_name:c.get("view_name"),priority:b++})});this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.View",version:1,method:"set",params:{items:a},callback:function(e,d,c){this.owner.clearStatusBusy();if(!e){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(d.code))}this.getStore().reload()},scope:this})},deleteView:function(c){var a=[];for(var b=0;b<c.length;b++){a.push(c[b].get("view_name"))}this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.View",version:1,method:"delete",params:{delete_list:a},callback:function(f,e,d){if(!f){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}this.getStore().reload();this.owner.clearStatusBusy()},scope:this})},onChangeBtnStatus:function(){var a=this.getSelectionModel();var b=a.getCount();if(b>0){if(_S("demo_mode")){this.deleteBtn.disable()}else{this.deleteBtn.enable()}}else{this.deleteBtn.disable()}if(1==b){this.editBtn.enable();if(_S("demo_mode")){this.upBtn.disable();this.downBtn.disable()}else{this.upBtn.enable();this.downBtn.enable()}}else{this.editBtn.disable();this.upBtn.disable();this.downBtn.disable()}},keepSelect:function(){if(this.selectRow!==null){if(this.selectRow<this.getStore().getCount()){this.getSelectionModel().selectRow(this.selectRow,true)}}}});Ext.define("SYNO.SDS.DNS.ZoneMngPanel",{extend:"SYNO.ux.GridPanel",constructor:function(a){this.owner=a.appWin;this.module=a.module;var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent(arguments);this.mon(this,"afterlayout",function(){this.mon(this,"rowdblclick",this.onDoubleClick,this);this.mon(this,"rowcontextmenu",this.onRowContextMenu,this);this.mon(this.getStore(),"load",this.onStoreLoad,this);this.mon(this.getSelectionModel(),"selectionchange",this.onChangeBtnStatus,this)},this)},setBtnName:function(){this.editZoneBtn=this.editMenu.getComponent("editZoneBtn");this.editSOABtn=this.editMenu.getComponent("editSOABtn");this.editInfoBtn=this.editMenu.getComponent("editInfoBtn");this.enableBtn=this.editMenu.getComponent("enableBtn");this.disableBtn=this.editMenu.getComponent("disableBtn");this.editTypeBtn=this.editMenu.getComponent("editTypeBtn");this.exportFileBtn=this.exportMenu.getComponent("exportFileBtn");this.exportConfBtn=this.exportMenu.getComponent("exportConfBtn");this.deleteBtn=this.toolBar.getComponent("deleteBtn")},createToolBar:function(){var a=new Ext.Toolbar({defaultType:"syno_button"});this.createMenu=new SYNO.ux.Menu({items:[{text:SYNO.SDS.DNS._V("dns","dns_master_zone"),itemId:"btnMstZone",handler:this.createMasterZone,scope:this},{text:SYNO.SDS.DNS._V("dns","dns_slave_zone"),itemId:"btnSlvZone",handler:this.createSlaveZone,scope:this},{text:SYNO.SDS.DNS._V("dns","dns_forward_zone"),itemId:"btnFrdZone",handler:this.createForwardZone,scope:this},{text:SYNO.SDS.DNS._V("dns","dns_zone_import"),itemId:"btnImport",handler:this.onUploadZone,scope:this}]});this.createZoneMenu=new Ext.Action({text:SYNO.SDS.DNS._V("common","create"),itemId:"createZone",scope:this,menu:this.createMenu});this.editMenu=new SYNO.ux.Menu({items:[{text:SYNO.SDS.DNS._V("dns","dns_enable"),itemId:"enableBtn",hidden:true,handler:this.onChangeStatus,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this},{text:SYNO.SDS.DNS._V("dns","dns_disable"),itemId:"disableBtn",hidden:true,handler:this.onChangeStatus,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this},{text:SYNO.SDS.DNS._V("dns","dns_zone_setting"),itemId:"editInfoBtn",disabled:true,handler:this.onEditZone,scope:this},{text:SYNO.SDS.DNS._V("dns","dns_zone_soa_record"),itemId:"editSOABtn",disabled:true,handler:this.onEditZone,scope:this},{text:SYNO.SDS.DNS._V("dns","dns_resource_record"),itemId:"editZoneBtn",disabled:true,handler:this.onEditZone,scope:this},{text:SYNO.SDS.DNS._V("dns","dns_zone_change"),itemId:"editTypeBtn",disabled:true,handler:this.onEditZoneType,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this}]});this.editZoneMenu=new Ext.Action({text:SYNO.SDS.DNS._V("common","alt_edit"),itemId:"editZoneMenu",disabled:true,scope:this,menu:this.editMenu});this.exportMenu=new SYNO.ux.Menu({items:[{itemId:"exportFileBtn",disabled:true,text:SYNO.SDS.DNS._V("dns","dns_resource_record"),handler:this.onExport,scope:this},{itemId:"exportConfBtn",disabled:true,text:SYNO.SDS.DNS._V("dns","dns_zone_complete_setting"),handler:this.onExportConf,scope:this}]});this.exportZoneMenu=new Ext.Action({text:SYNO.SDS.DNS._V("dns","dns_zone_export"),itemId:"exportZone",scope:this,menu:this.exportMenu,disabled:true});a.add(this.createZoneMenu);a.add(this.editZoneMenu);a.add(this.exportZoneMenu);a.add({itemId:"deleteBtn",text:SYNO.SDS.DNS._V("common","delete"),disabled:true,handler:this.onDelete,scope:this});return a},fillConfig:function(){this.toolBar=this.createToolBar();var e=[{header:SYNO.SDS.DNS._V("dns","dns_zone_name"),dataIndex:"zone_name",width:200},{header:SYNO.SDS.DNS._V("dns","dns_domain_name_header"),dataIndex:"domain_name",width:250},{header:SYNO.SDS.DNS._V("dns","dns_zone_type"),dataIndex:"zone_type"},{header:SYNO.SDS.DNS._V("dns","dns_zone_status"),dataIndex:"zone_enable",id:this.lastClumnId=Ext.id(),align:"center",renderer:SYNO.SDS.DNS.RenderZoneStatus}];var b=new Ext.grid.ColumnModel({columns:e});var a=["zone_name","zone_type","domain_name","zone_enable","domain_type"];var c=new SYNO.API.JsonStore({appWindow:this.owner,api:"SYNO.DNSServer.Zone",method:"list",version:1,root:"items",fields:a,listeners:{exception:function(i,j,k,h,l,g){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(l.code))},scope:this}});var f=new SYNO.ux.PagingToolbar({store:c,pageSize:100,displayInfo:true});var d={title:SYNO.SDS.DNS._V("dns","dns_zone_management"),tbar:this.toolBar,colModel:b,ds:c,bbar:f,loadMask:true,sm:new Ext.grid.RowSelectionModel(),autoExpandColumn:this.lastClumnId};this.setBtnName();return d},onPageActivate:function(){this.getStore().reload()},onEditZoneType:function(){this.owner.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});var a=this.getSelectionModel().getSelected().get("zone_name");this.owner.sendWebAPI({api:"SYNO.DNSServer.Zone.SlaveZoneConf",version:1,method:"transform_to_master",params:{zone_name:a},callback:function(d,c,b){this.owner.clearStatusBusy();if(d){this.getStore().reload()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(c.code))}},scope:this})},onDoubleClick:function(a,i){var d=this.getSelectionModel().getSelected();var g=d.get("zone_name");var c=d.get("domain_name");var j=d.get("zone_type");var f=d.get("domain_type");var h=null;if(SYNO.SDS.DNS.MASTER==j||SYNO.SDS.DNS.SLAVE==j){h=new SYNO.SDS.DNS.ZoneFileDialog({owner:this.owner,zoneName:g,zoneType:j,domainName:c,memoryAlert:this.memoryAlert,domainType:f})}else{if(SYNO.SDS.DNS.FORWARD==j){h=new SYNO.SDS.DNS.ZoneBasicDialog({owner:this.owner,isCreate:false,zoneName:g,zoneType:j,domainName:c,domainType:f,creater:this})}else{return}}h.onInitial();h.open()},onEditZone:function(a,i){var d=this.getSelectionModel().getSelected();var g=d.get("zone_name");var c=d.get("domain_name");var j=d.get("zone_type");var f=d.get("domain_type");var h=null;if(a.itemId=="editInfoBtn"){h=new SYNO.SDS.DNS.ZoneBasicDialog({owner:this.owner,isCreate:false,zoneName:g,zoneType:j,domainName:c,domainType:f,creater:this});h.onInitial();h.open()}else{if(a.itemId=="editSOABtn"){h=new SYNO.SDS.DNS.ZoneSOADialog({owner:this.owner,zoneName:g,zoneType:j,domainName:c,domainType:f});h.onInitial();h.open()}else{h=new SYNO.SDS.DNS.ZoneFileDialog({owner:this.owner,zoneName:g,zoneType:j,domainName:c,memoryAlert:this.memoryAlert,domainType:f});h.onInitial();h.open()}}},resetDefaultZoneMngButtonsCfg:function(){this.zoneMngButtonsCfg={editMenu:false,showEnableOrDisable:"notShow",zoneSetting:false,soaRecord:false,resourceRecord:false,changeToMasterZone:false,exportMenu:false,exportResourceRecord:false,exportCompleteZoneSettings:false,deleteBtn:false};return this.zoneMngButtonsCfg},updateAndDisplayZoneMngButtonCfg:function(b){var a={};if(typeof this.zoneMngButtonsCfg==="undefined"){this.resetDefaultZoneMngButtonsCfg()}a=this.zoneMngButtonsCfg;a=Ext.apply(a,b);this.editZoneMenu.setDisabled(!a.editMenu);switch(a.showEnableOrDisable){case"enable":this.disableBtn.hide();this.enableBtn.show();this.enableBtn.enable();break;case"disable":this.enableBtn.hide();this.disableBtn.show();this.disableBtn.enable();break;default:this.disableBtn.hide();this.enableBtn.hide()}this.editInfoBtn.setDisabled(!a.zoneSetting);this.editSOABtn.setDisabled(!a.soaRecord);this.editZoneBtn.setDisabled(!a.resourceRecord);this.editTypeBtn.setDisabled(!a.changeToMasterZone);this.exportZoneMenu.setDisabled(!a.exportMenu);this.exportFileBtn.setDisabled(!a.exportResourceRecord);this.exportConfBtn.setDisabled(!a.exportCompleteZoneSettings);this.deleteBtn.setDisabled(!a.deleteBtn)},isSelectIncludeDLZ:function(e){var b=this.getSelectionModel();var d=b.getCount();var c=0;var a={};for(c=0;c<d;c++){a=b.selections.get(c);if(SYNO.SDS.DNS.IsDLZZone(a.get("zone_name"))){if(!e||SYNO.SDS.DNS.FORWARD===a.get("domain_type")){return true}}}return false},onChangeBtnStatus:function(){var e=this.getSelectionModel();var g=e.getCount();var f="";var h=false;var c="";var i="";var d={};if(0===g){d=this.resetDefaultZoneMngButtonsCfg();this.updateAndDisplayZoneMngButtonCfg(d);return}if(1==g){f=e.getSelected().get("zone_name");h=e.getSelected().get("zone_enable");c=e.getSelected().get("zone_type");i=e.getSelected().get("domain_type");if(!SYNO.SDS.DNS.IsDLZZone(f)){this.updateAndDisplayZoneMngButtonCfg({editMenu:true,showEnableOrDisable:h?"disable":"enable",zoneSetting:true,soaRecord:SYNO.SDS.DNS.FORWARD!==c,resourceRecord:SYNO.SDS.DNS.FORWARD!==c,changeToMasterZone:SYNO.SDS.DNS.SLAVE==c,exportMenu:true,exportResourceRecord:true,exportCompleteZoneSettings:true,deleteBtn:true})}else{this.updateAndDisplayZoneMngButtonCfg({editMenu:true,showEnableOrDisable:"notShow",zoneSetting:true,soaRecord:true,resourceRecord:true,changeToMasterZone:false,exportMenu:false,exportResourceRecord:false,exportCompleteZoneSettings:false,deleteBtn:(i===SYNO.SDS.DNS.REVERSE)?true:false})}}else{var a=this.isSelectIncludeDLZ(false);var b=this.isSelectIncludeDLZ(true);this.updateAndDisplayZoneMngButtonCfg({editMenu:false,showEnableOrDisable:"notShow",zoneSetting:false,soaRecord:false,resourceRecord:false,changeToMasterZone:false,exportMenu:!a,exportResourceRecord:false,exportCompleteZoneSettings:!a,deleteBtn:!b})}},onDelete:function(){this.owner.getMsgBox().confirmDelete(this.title,SYNO.SDS.DNS._V("dns","dns_zone_delete"),function(a){if("yes"===a){var b=this.getSelectionModel().getSelections();this.deleteZone(b)}},this)},deleteZone:function(c){var a=[];for(var b=0;b<c.length;b++){a.push({zone_name:c[b].get("zone_name"),zone_type:c[b].get("zone_type")})}this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.Zone",version:1,method:"delete",params:{items:a},callback:function(f,e,d){this.owner.clearStatusBusy();if(f){this.getStore().reload()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}},scope:this})},createMasterZone:function(a,d){var c=new SYNO.SDS.DNS.ZoneBasicDialog({owner:this.owner,creater:this,zoneType:SYNO.SDS.DNS.MASTER,domainNames:this.domainNames,isCreate:true,isADMode:this.isADMode});c.onInitial();c.open()},createSlaveZone:function(a,d){var c=new SYNO.SDS.DNS.ZoneBasicDialog({owner:this.owner,creater:this,zoneType:SYNO.SDS.DNS.SLAVE,isCreate:true});c.onInitial();c.open()},createForwardZone:function(a,d){var c=new SYNO.SDS.DNS.ZoneBasicDialog({owner:this.owner,creater:this,zoneType:SYNO.SDS.DNS.FORWARD,isCreate:true});c.onInitial();c.open()},onUploadZone:function(){var a=new SYNO.SDS.DNS.UploadZone({owner:this.owner,creater:this});a.open()},onExportConf:function(){var a=[];var c=this.getSelectionModel().getSelections();for(var b=0;b<c.length;b++){a.push(c[b].get("zone_name"))}this.owner.downloadWebAPI({webapi:{api:"SYNO.DNSServer.Zone",method:"export",params:{file_type:"complete_setting",zone_names:a},version:1},callback:function(e,d,g,f){if(false===g){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(f.code))}},scope:this})},onExport:function(){var a=this.getSelectionModel().getSelected();var b=a.get("zone_name");if(SYNO.SDS.DNS.FORWARD===a.get("zone_type")){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._V("dns","dns_forwardzone_can_not_export_resource"));return}this.owner.downloadWebAPI({webapi:{api:"SYNO.DNSServer.Zone",method:"export",params:{file_type:"resource_record",zone_name:b},version:1},callback:function(d,c,f,e){if(false===f){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}},scope:this})},onRowContextMenu:function(b,d,a){var c=this.getSelectionModel();c.selectRow(d,true);this.editMenu.showAt(a.getXY())},onChangeStatus:function(a,h){var f=this.getSelectionModel().getSelected();var g=f.get("zone_name");var i=f.get("zone_type");var c=f.get("zone_enable");this.owner.setStatusBusy();var d=SYNO.SDS.DNS.GetWebAPIName(i);if(!d){SYNO.Debug("No such api: zone_type="+i);return}this.owner.sendWebAPI({api:d,version:1,method:"set",params:{zone_name:g,zone_enable:!!!c},callback:function(j,e,b){this.owner.clearStatusBusy();if(j){this.getStore().reload()}else{this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}},scope:this})},onStoreLoad:function(b,a,c){if(false===b.reader.jsonData.resolve_enable&&this.needForwadZoneHint(b)){this.showForwardZoneHint()}this.memoryAlert=b.reader.jsonData.memory_alert;this.isADMode=this.checkIfADZoneExist(b);this.domainNames=this.getDomainNames(b)},checkIfADZoneExist:function(a){var b=false;a.each(function(c){if(0<=c.get("zone_name").indexOf("@Active Directory")){b=true;return false}return true},this);return b},getDomainNames:function(a){var b=[];a.each(function(c){if(SYNO.SDS.DNS.MASTER!==c.get("zone_type")||SYNO.SDS.DNS.FORWARD!==c.get("domain_type")){return true}if(0>b.indexOf(c.get("domain_name"))){b.push(c.get("domain_name"))}return true},this);return b},needForwadZoneHint:function(a){var b=false;a.each(function(c){if(SYNO.SDS.DNS.FORWARD===c.get("zone_type")&&true===c.get("zone_enable")){b=true;return true}},this);return b},showForwardZoneHint:function(){this.owner.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("dns","dns_forward_zone_need_resolution"),function(a){if("yes"===a){this.resolutionEnable()}},this)},resolutionEnable:function(a){this.owner.setStatusBusy();this.owner.sendWebAPI({api:"SYNO.DNSServer.ResolutionConf",version:1,method:"set",params:{resolve_enable:true},callback:function(d,c,b){this.owner.clearStatusBusy();if(!d){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(c.code))}},scope:this})}});Ext.define("SYNO.SDS.DNS.ZoneFileDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.memoryAlert=a.memoryAlert;this.callParent([b])},initEvents:function(){this.callParent(arguments);this.mon(this.zonePanel.getStore(),"beforeLoad",this.onBeforeLoad,this);this.mon(this.zonePanel.getStore(),"load",this.onLoad,this);this.mon(this.zonePanel.getStore(),"exception",this.onException,this);this.mon(this,"afterlayout",function(){if(SYNO.SDS.DNS.MASTER==this.zoneType){this.mon(this.zonePanel.getSelectionModel(),"selectionchange",this.onChangeBtnStatus,this);this.mon(this.zonePanel,"rowdblclick",this.onResourceRcdEdit,this);this.editBtn=this.toolBar.getComponent("editBtn");this.deleteBtn=this.toolBar.getComponent("deleteBtn")}},this)},onBeforeLoad:function(){if(this.searchField){this.searchField.blur()}this.setStatusBusy()},onLoad:function(){if(this.searchField){this.searchField.focus()}this.clearStatusBusy()},onException:function(){this.getMsgBox().alert(this.title,SYNO.SDS.DNS._V("error","error_unknown"));this.clearStatusBusy()},fillConfig:function(a){this.pageSize=50;this.zonePanel=this.createZonePanel(a);var b={autoHeight:true,width:670,border:false,items:this.zonePanel,layout:"fit",buttons:[{text:SYNO.SDS.DNS._V("common","alt_finish"),handler:function(){this.close()},scope:this}]};Ext.apply(b,a);return b},createZonePanel:function(c){var e=[{header:SYNO.SDS.DNS._V("dns","dns_owner"),dataIndex:"rr_owner",sortable:true,id:this.lastClumnId=Ext.id(),width:200,renderer:function(h){return'<div ext:qtip="'+h+'">'+h+"</div>"}},{header:SYNO.SDS.DNS._V("dns","dns_rr_type"),dataIndex:"rr_type",width:60,sortable:true},{header:"TTL",dataIndex:"rr_ttl",sortable:true},{header:SYNO.SDS.DNS._V("dns","dns_event_info"),dataIndex:"rr_info",width:200,sortable:true,renderer:function(h){return'<div ext:qtip="'+h+'">'+h+"</div>"}}];var b=new Ext.grid.ColumnModel({defaultWidth:100,columns:e});var a=["rr_owner","rr_ttl","rr_type","rr_info","full_record"];var d=new SYNO.SDS.DNS.SimpleJsonRecordStore({appWindow:this,fields:a,listeners:{exception:function(j,k,l,i,m,h){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(m.code))},scope:this}});this.toolBar=this.createToolBar(c.zoneName,c.domainType,d);var g=new SYNO.ux.PagingToolbar({store:d,pageSize:this.pageSize,displayInfo:true});var f={view:new SYNO.SDS.Utils.GridView(),height:380,width:640,sm:new Ext.grid.RowSelectionModel(),autoExpandColumn:this.lastClumnId,colModel:b,ds:d,tbar:(SYNO.SDS.DNS.MASTER==c.zoneType)?this.toolBar:null,bbar:g};return new SYNO.ux.GridPanel(f)},createToolBar:function(e,d,b){var a=new Ext.Toolbar({defaultType:"syno_button"});var f=this.createMenu(e,d);var c=new Ext.Action({text:SYNO.SDS.DNS._V("common","create"),itemId:"crtRR",scope:this,menu:f});a.add(c);a.add({itemId:"editBtn",disabled:true,text:SYNO.SDS.DNS._V("common","alt_edit"),handler:this.onResourceRcdEdit,scope:this});a.add({itemId:"deleteBtn",text:SYNO.SDS.DNS._V("common","delete"),disabled:true,handler:this.onDelete,tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this});this.searchField=new SYNO.SDS.DNS.RecordFilter({store:b,pageSize:this.pageSize,owner:this});a.add("->");a.add(this.searchField);return a},createMenu:function(c,b){var a=[];switch(b){case SYNO.SDS.DNS.FORWARD:a.push({text:"A Type",itemId:"A",handler:this.onCrtResourceRcd,scope:this},{text:"AAAA Type",itemId:"AAAA",handler:this.onCrtResourceRcd,scope:this},{text:"CNAME Type",itemId:"CNAME",handler:this.onCrtResourceRcd,scope:this},{text:"MX Type",itemId:"MX",handler:this.onCrtResourceRcd,scope:this},{text:"NS Type",itemId:"NS",handler:this.onCrtResourceRcd,scope:this},{text:"SPF Type",itemId:"SPF",handler:this.onCrtResourceRcd,disabled:SYNO.SDS.DNS.IsDLZZone(c),scope:this},{text:"SRV Type",itemId:"SRV",handler:this.onCrtResourceRcd,scope:this},{text:"TXT Type",itemId:"TXT",handler:this.onCrtResourceRcd,scope:this},{text:"CAA Type",itemId:"CAA",handler:this.onCrtResourceRcd,disabled:SYNO.SDS.DNS.IsDLZZone(c),scope:this});break;case SYNO.SDS.DNS.REVERSE:a.push({text:"PTR Type",itemId:"PTR",handler:this.onCrtResourceRcd,scope:this},{text:"NS Type",itemId:"NS",handler:this.onCrtResourceRcd,scope:this});break;default:break}var d=new Ext.menu.Menu({items:a});return d},onInitial:function(){var a;this.zonePanel.getStore().setBaseParam("zone_name",this.zoneName);this.zonePanel.getStore().setBaseParam("domain_name",this.domainName);this.zonePanel.getStore().setBaseParam("zone_type",this.zoneType);this.zonePanel.getStore().reload();if(SYNO.SDS.DNS.MASTER==this.zoneType){a=SYNO.SDS.DNS._V("dns","dns_zone_resource_record_edit")}else{a=SYNO.SDS.DNS._V("dns","dns_zone_resource_record_view")}this.setTitle(a)},onCrtResourceRcd:function(a,d){var c=new SYNO.SDS.DNS.RRPanel({owner:this,zoneName:this.zoneName,domainName:this.domainName,mode:SYNO.SDS.DNS.CREATE,memoryAlert:this.memoryAlert,RRtype:a.itemId});c.onInitial();c.open()},onResourceRcdEdit:function(q,m){var p=this.zonePanel.getSelectionModel().getCount();var k={};if(1==p){var j=this.zonePanel.getSelectionModel().getSelected();var a=j.get("rr_type").toUpperCase();var n=j.get("rr_info");var o=j.get("rr_owner");var g=j.get("full_record");var c=this.omitDomain(o);var l={rr_owner:c,rr_ttl:j.get("rr_ttl")};var r={rr_owner:c,rr_ttl:j.get("rr_ttl"),rr_info:n,rr_type:a,full_record:g};this.getEditInfo(l,a,n);k=new SYNO.SDS.DNS.RRPanel({owner:this,zoneName:this.zoneName,domainName:this.domainName,mode:SYNO.SDS.DNS.EDIT,RRtype:a,memoryAlert:this.memoryAlert,resourceRecord:l,orgRecord:r})}else{var f=this.zonePanel.getSelectionModel().getSelections();var d=[];var i=[];var h=[];if(!this.checkIfSelectionsAllAorAAAA()){return}h=this.checkIfSelectionsNameConflict();if(0<h.length){this.getMsgBox().alert(this.title,String.format(SYNO.SDS.DNS._V("dns","dns_dlz_record_conflict_edit"),h.join(",")));return}Ext.each(f,function(t,u){var b=t.get("rr_type").toUpperCase();var w=t.get("rr_info");var x=t.get("rr_owner");var s=t.get("full_record");var e=this.omitDomain(x);var v={rr_owner:e,rr_ttl:t.get("rr_ttl")};var y={rr_owner:e,rr_ttl:t.get("rr_ttl"),rr_info:w,rr_type:b,full_record:s};this.getEditInfo(v,b,w);d.push(y);i.push(v)},this);k=new SYNO.SDS.DNS.RRPanel({owner:this,zoneName:this.zoneName,domainName:this.domainName,mode:SYNO.SDS.DNS.BATCH_EDIT,RRtype:f[0].get("rr_type"),memoryAlert:this.memoryAlert,resourceRecord:i,orgRecord:d})}k.onInitial();k.open()},checkIfSelectionsAllAorAAAA:function(){var a=this.zonePanel.getSelectionModel();var b=function(c,e){var d=true;Ext.each(c,function(g,f){if(g.get("rr_type").toUpperCase()===e.toUpperCase()){return true}else{d=false;return false}});return d};if(!b(a.getSelections(),"A")&&!b(a.getSelections(),"AAAA")){return false}return true},checkIfSelectionsNameConflict:function(){var b=this.zonePanel.getSelectionModel();var d=[];var a=[];var c="";Ext.each(b.getSelections(),function(f,e){c=f.get("rr_owner");if(0>d.indexOf(c)){d.push(c)}else{if(0>a.indexOf(c)){a.push(c)}}return true});return a},onChangeBtnStatus:function(){var a=this.zonePanel.getSelectionModel();var c=a.getCount();var d="";var b="";this.deleteBtn.disable();this.editBtn.disable();if(0===c){return}if(1===c){d=this.zoneName;b=a.getSelected().get("rr_type");this.deleteBtn.enable();this.editBtn.enable()}else{if(this.checkIfSelectionsAllAorAAAA()){this.editBtn.enable();this.deleteBtn.enable()}else{this.deleteBtn.enable()}}},getEditInfo:function(d,a,b){var f;var e;var g;switch(a.toUpperCase()){case"A":case"AAAA":case"TXT":case"SPF":d.rr_info=b;break;case"CNAME":case"NS":case"PTR":e=this.omitDot(b);d.rr_info=e;break;case"MX":f=b;g=f.split(" ");d.mx_preference=g[0];e=this.omitDot(g[1]);d.rr_info=e;break;case"SRV":f=b;g=f.split(" ");d.rr_priority=g[0];d.rr_weight=g[1];d.rr_port=g[2];e=this.omitDot(g[3]);d.rr_info=e;break;case"CAA":f=b;e=f.split(";");g=e[0].split(" ");switch(g[1]){case SYNO.SDS.DNS.CAA.ISSUE:case SYNO.SDS.DNS.CAA.ISSUEWILD:d.rr_caa_type=g[1];d.rr_caa_issue_info=g[2];d.rr_caa_info_params=e[1];break;case SYNO.SDS.DNS.CAA.IODEF:d.rr_caa_type=g[1];d.rr_caa_iodef_domain_type=g[2].split(":")[0];if("mailto"==d.rr_caa_iodef_domain_type){d.rr_caa_iodef_info=g[2].split(":")[1]}else{d.rr_caa_iodef_info=g[2].split("://")[1]}break;default:var c=function(){var j=0;var i=0;var h="";j=e[0].indexOf(" ");i=e[0].indexOf(" ",j+1);h=e[0].substring(i+1);h=h.substring(1,h.length-1);return h};d.rr_caa_type=SYNO.SDS.DNS.CAA.CUSTOM;d.rr_caa_custom_type=g[1];d.rr_caa_custom_info=c();break}break;default:}},omitDomain:function(a){var b=this.domainName;var d=a.lastIndexOf(b);var c="";if(0===d){return c}if(0>d){return c}c=a.substring(0,d-1);return c},omitDot:function(b){var a=b;if(b.charAt(b.length-1)==="."){a=b.substring(0,b.length-1)}return a},onDelete:function(){this.getMsgBox().confirmDelete(this.title,SYNO.SDS.DNS._V("dns","dns_delete_sure"),function(b){if("yes"===b){var a=this.zonePanel.getSelectionModel().getSelections();this.deleteRecord(a)}},this)},deleteRecord:function(b){var a=[];for(var c=0;c<b.length;c++){a.push({zone_name:this.zoneName,domain_name:this.domainName,rr_owner:b[c].get("rr_owner"),rr_type:b[c].get("rr_type"),rr_ttl:b[c].get("rr_ttl"),rr_info:b[c].get("rr_info"),full_record:b[c].get("full_record")})}this.setStatusBusy();this.sendWebAPI({api:"SYNO.DNSServer.Zone.Record",version:1,method:"delete",params:{items:a},callback:function(f,e,d){this.clearStatusBusy();if(f){this.zonePanel.getStore().reload()}else{this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(e.code))}},scope:this})}});Ext.define("SYNO.SDS.DNS.ZoneSOADialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.formPanel=this.createFormPanel();this.applyBtn=new SYNO.ux.Button({text:SYNO.SDS.DNS._V("common","apply"),hidden:true,btnStyle:"blue",handler:this.onSave,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""});this.cancelBtn=new SYNO.ux.Button({text:SYNO.SDS.DNS._V("common","cancel"),handler:this.onCancle,scope:this});var b={layout:"form",height:370,width:600,items:this.formPanel,buttons:[this.applyBtn,this.cancelBtn]};Ext.apply(b,a);return b},crtCompositeField:function(c,b){var a={fieldLabel:c,indent:1,items:[{xtype:"syno_numberfield",allowBlank:false,allowDecimals:false,maxValue:2147483647,minValue:1,name:b,disabled:true,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_displayfield",width:30},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("common","time_seconds")}]};return new SYNO.ux.CompositeField(a)},createFormPanel:function(){var a=this.crtCompositeField(SYNO.SDS.DNS._V("dns","dns_refresh"),"refresh");var c=this.crtCompositeField(SYNO.SDS.DNS._V("dns","dns_retry"),"retry_times");var e=this.crtCompositeField(SYNO.SDS.DNS._V("dns","dns_expire"),"expire");var d=this.crtCompositeField(SYNO.SDS.DNS._V("dns","dns_ncache"),"ncache");var b={layout:"form",width:600,height:350,border:false,trackResetOnLoad:true,items:[{xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_host_name"),name:"host_name",vtype:"synodnsHostname",indent:1,allowBlank:false,disabled:true,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_email"),name:"host_mail",vtype:"synodnsemail",indent:1,allowBlank:false,disabled:true,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_numberfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_serial"),allowBlank:false,allowDecimals:false,maxValue:4294967295,minValue:0,name:"serial",indent:1,disabled:true,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},a,c,e,d]};return new SYNO.ux.FormPanel(b)},onInitial:function(){this.loadForm();if(SYNO.SDS.DNS.SLAVE==this.zoneType){this.setTitle(SYNO.SDS.DNS._V("dns","dns_zone_soa_record_view"));this.cancelBtn.setText(SYNO.SDS.DNS._V("common","alt_finish"))}else{this.setTitle(SYNO.SDS.DNS._V("dns","dns_zone_soa_record_edit"));this.formEnable();this.applyBtn.show()}},formEnable:function(){var a=this.formPanel.getForm();a.findField("host_name").enable();a.findField("host_mail").enable();a.findField("refresh").enable();a.findField("retry_times").enable();a.findField("expire").enable();a.findField("ncache").enable();a.findField("serial").enable()},loadForm:function(){this.setStatusBusy();this.sendWebAPI({api:"SYNO.DNSServer.Zone.SOA",version:1,method:"get",params:{domain_name:this.domainName,zone_name:this.zoneName,zone_type:this.zoneType},callback:function(c,b,a){this.clearStatusBusy();if(c){this.OriSetting=b;this.OriSetting.host_name=this.omitDot(b.host_name);this.OriSetting.host_mail=this.omitDot(b.host_mail);this.formPanel.getForm().setValues(this.OriSetting)}else{this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(b.code))}},scope:this})},omitDot:function(b){var a=b.length;if("."==b[a-1]){return b.substring(0,a-1)}else{return b}},onSave:function(){if(!this.formPanel.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}if(!this.formPanel.getForm().isDirty()){this.close();return}this.saveSOA()},saveSOA:function(){this.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});var a=this.formPanel.getForm();var b={host_name:a.findField("host_name").getValue()+".",host_mail:a.findField("host_mail").getValue()+".",refresh:a.findField("refresh").getValue(),retry_times:a.findField("retry_times").getValue(),expire:a.findField("expire").getValue(),ncache:a.findField("ncache").getValue(),serial:a.findField("serial").getValue(),domain_name:this.domainName,zone_name:this.zoneName,zone_type:this.zoneType};this.TmpSetting=b;this.sendWebAPI({api:"SYNO.DNSServer.Zone.SOA",version:1,method:"set",params:b,callback:function(e,d,c){this.clearStatusBusy();if(e){this.close()}else{this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(d.code))}},scope:this})},onCancle:function(){if(this.formPanel.getForm().isDirty()){this.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("common","confirm_lostchange"),function(a){if("yes"===a){this.close()}},this)}else{this.close()}}});Ext.define("SYNO.SDS.DNS.ZoneBasicDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},initEvents:function(){this.callParent([arguments]);this.mon(this,"afterrender",function(){var a;if(SYNO.SDS.DNS.MASTER===this.zoneType){if(this.isCreate){a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_transfer",[this.limitTransferBtnId]);a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_update",[this.limitUpdateBtnId]);a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_query",[this.limitQueryBtnId]);this.hideListenIfaceItems(true)}else{if(SYNO.SDS.DNS.IsDLZZone(this.zoneName)){a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_transfer",[this.limitTransferBtnId]);a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"listen_interface",[this.listenIfaceBtnId]);if(SYNO.SDS.DNS.IsReverseDLZZone(this.zoneName)){this.hideListenIfaceItems(true)}}else{a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_transfer",[this.limitTransferBtnId]);a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_update",[this.limitUpdateBtnId]);a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_query",[this.limitQueryBtnId]);a=new SYNO.ux.Utils.EnableCheckGroup(this.formPanel.getForm(),"enable_notify",[this.notifySlaveZoneBtnId]);this.hideListenIfaceItems(true)}}}else{if(SYNO.SDS.DNS.SLAVE==this.zoneType){a=new SYNO.SDS.Utils.EnableCheckGroup(this.formPanel.getForm(),"enable_tsig",[this.tsigKeyComboId]);a=new SYNO.SDS.Utils.EnableCheckGroup(this.formPanel.getForm(),"limit_query",[this.limitQueryBtnId])}}if(this.isCreate&&this.domainTypeField){this.mon(this.domainTypeField,"select",this.updateField,this)}},this)},updateField:function(){var d=function(g){var i="";var f=null;var h=null;this.domainNameField.setWidth(g.domainNameWitdh);i=g.showDomainNameText?this.domainTextField.show():this.domainTextField.hide();if("showHostIpDisp" in g){h=this.formPanel.getForm().findField("host_ip");SYNO.SDS.Utils.DisplayField(this.formPanel.getForm(),"host_ip",g.showHostIpDisp);h.allowBlank=g.showHostIpDisp?false:true}if("showHostIpField" in g){i=g.showHostIpField?this.hostIpField.show():this.hostIpField.hide()}if("showEmptyField" in g){i=g.showEmptyField?this.emptyField.show():this.emptyField.hide()}if("showNameServer" in g){f=this.formPanel.getForm().findField("forward_domain_name");if(g.showNameServer){this.nameServer.show();if(!this.blAddedNSInfoTip){SYNO.SDS.Utils.AddTip(f.getEl(),SYNO.SDS.DNS._V("dns","name_server_info_tip"));this.blAddedNSInfoTip=true}f.allowBlank=false}else{this.nameServer.hide();f.allowBlank=true}}}.bind(this);var b={};var e=this.domainTypeField.getValue();switch(e){case SYNO.SDS.DNS.REVERSE:case SYNO.SDS.DNS.AD_REVERSE:b={domainNameWitdh:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH_SHORT,showDomainNameText:true};if(SYNO.SDS.DNS.MASTER===this.zoneType){Ext.apply(b,{showHostIpDisp:false,showHostIpField:false});if(SYNO.SDS.DNS.REVERSE===e){Ext.apply(b,{showEmptyField:false,showNameServer:true})}else{if(SYNO.SDS.DNS.AD_REVERSE===e){Ext.apply(b,{showEmptyField:true,showNameServer:false})}}}d(b);break;case SYNO.SDS.DNS.FORWARD:b={domainNameWitdh:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,showDomainNameText:false};if(SYNO.SDS.DNS.MASTER===this.zoneType){Ext.apply(b,{showHostIpDisp:true,showHostIpField:true,showEmptyField:false,showNameServer:false})}d(b);break;default:SYNO.Debug("ZoneBasicDialog.js:updateField() unkown type");return}var c=function(f){var g=["serial_format","limit_query","limit_update","enable_notify"];Ext.each(g,function(h){this.formPanel.getForm().findField(h).setDisabled(!f)},this)}.bind(this);var a=function(f){var g=this.formPanel.getForm();var h=g.findField("enable_notify");if(f){this.addSyncDLZOptionListener("check");this.setDLZNotifySlaveValue();g.findField("limit_query").setValue(false);g.findField("limit_update").setValue(true);h.mun(h,"check",this.EnableNotifyCheckGroupHandler,this);Ext.getCmp(this.notifySlaveZoneBtnId).setDisabled(true)}else{this.removeSyncDLZOptionListener("check");h.mon(h,"check",this.EnableNotifyCheckGroupHandler,this);this.EnableNotifyCheckGroupHandler()}}.bind(this);if(SYNO.SDS.DNS.MASTER===this.zoneType){if(SYNO.SDS.DNS.AD_REVERSE===e){c(false);a(true)}else{c(true);a(false)}}this.doLayout()},EnableNotifyCheckGroupHandler:function(){Ext.getCmp(this.notifySlaveZoneBtnId).setDisabled(!this.getFieldValue("enable_notify"))},fillConfig:function(b){var a=0;var d=function(e){switch(b.zoneType){case SYNO.SDS.DNS.MASTER:return 680;case SYNO.SDS.DNS.FORWARD:return 320;default:return 440}};a+=d(b.zoneType);a+=(b.isCreate)?0:30;this.formPanel=this.createFormPanel(b,a);this.setName();this.setDLZConfig(b.zoneName,b.domainType);var c={layout:"fit",width:600,height:a,items:this.formPanel,buttons:[{text:SYNO.SDS.DNS._V("common","apply"),btnStyle:"blue",handler:this.onSave,scope:this,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{text:SYNO.SDS.DNS._V("common","cancel"),handler:this.onCancle,scope:this}]};Ext.apply(c,b);return c},setName:function(){this.domainTypeField=this.formPanel.getForm().findField("domain_type");this.domainNameField=this.formPanel.getForm().findField("domain_name");this.domainTextField=this.formPanel.getForm().findField("domain_type_text");this.hostIpField=this.formPanel.getForm().findField("host_ip");this.nameServer=this.formPanel.getForm().findField("name_server");this.emptyField=this.formPanel.getForm().findField("empty")},setDLZConfig:function(c){if(!SYNO.SDS.DNS.IsDLZZone(c)){return}var b=["zone_enable","serial_format","limit_query","limit_update","enable_notify"];Ext.each(b,function(d){this.formPanel.getForm().findField(d).setDisabled(true)},this);var a=[this.limitUpdateBtnId,this.limitQueryBtnId,this.notifySlaveZoneBtnId,this.listenIfaceBtnId];Ext.each(a,function(d){Ext.getCmp(d).setDisabled(true)},this);this.addSyncDLZOptionListener(["check"])},addSyncDLZOptionListener:function(a){var b=this.formPanel.getForm().findField("limit_transfer");Ext.each(a,function(c){b.mon(b,c,this.setDLZNotifySlaveValue,this)},this)},removeSyncDLZOptionListener:function(a){var b=this.formPanel.getForm().findField("limit_transfer");Ext.each(a,function(c){b.mun(b,c,this.setDLZNotifySlaveValue,this)},this)},hideListenIfaceItems:function(a){if(a){this.formPanel.getForm().findField("listen_interface").hide();this.formPanel.getForm().findField("listen_interface_desc").hide();Ext.getCmp(this.listenIfaceBtnId).hide()}else{this.formPanel.getForm().findField("listen_interface").show();this.formPanel.getForm().findField("listen_interface_desc").show();Ext.getCmp(this.listenIfaceBtnId).show()}},disableListenIfaceItems:function(a){this.formPanel.getForm().findField("listen_interface").setDisabled(a);Ext.getCmp(this.listenIfaceBtnId).setDisabled(a)},setDLZNotifySlaveValue:function(){this.formPanel.getForm().findField("enable_notify").setValue(this.getFieldValue("limit_transfer"))},createFormPanel:function(b,a){var d=[];var e;e=(b.isCreate)?this.setItemForCreate(b,d):this.setItemForEdit(b,d);switch(b.zoneType){case SYNO.SDS.DNS.MASTER:this.setItemForMaster(b,d);break;case SYNO.SDS.DNS.SLAVE:this.setItemForSlave(b,d);break;case SYNO.SDS.DNS.FORWARD:this.setItemForForward(b,d);break}var c={layout:"form",border:false,height:a-40,labelWidth:220,trackResetOnLoad:true,items:d};return new SYNO.ux.FormPanel(c)},setItemForCreate:function(a,b){if(SYNO.SDS.DNS.MASTER===a.zoneType||SYNO.SDS.DNS.SLAVE===a.zoneType){this.setZoneSupportDomainType(b,a.isADMode)}else{if(SYNO.SDS.DNS.FORWARD===a.zoneType){this.setZoneNotSupportDomainType(b)}}if(SYNO.SDS.DNS.MASTER===a.zoneType){b.push({xtype:"syno_textfield",indent:1,fieldLabel:SYNO.SDS.DNS._V("dns","dns_primary_address"),name:"host_ip",vtype:"ip",hidden:true,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{htmlEncode:false,xtype:"syno_displayfield",name:"empty",value:"&nbsp;",indent:1,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_compositefield",fieldLabel:SYNO.SDS.DNS._V("dns","name_server"),name:"name_server",hidden:true,indent:1,items:[{xtype:"syno_textfield",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH_SHORT,name:"rr_name_prefix",vtype:"synodnsRROwner",value:"ns"},{xtype:"syno_combobox",width:126,name:"forward_domain_name",vtype:"synodnsRROwner",store:a.domainNames,editable:true,allowBlank:false}]})}},setZoneSupportDomainType:function(a,b){a.push({xtype:"syno_combobox",indent:1,fieldLabel:SYNO.SDS.DNS._V("dns","dns_domain_type"),name:"domain_type",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,valueField:"abbr",displayField:"domain_type",value:SYNO.SDS.DNS.FORWARD,store:new SYNO.SDS.DNS.DomainTypeStore({isADMode:b})},new SYNO.ux.CompositeField({fieldLabel:SYNO.SDS.DNS._V("dns","dns_domain_name"),indent:1,items:[{xtype:"syno_textfield",name:"domain_name",vtype:"synodnsHostname",allowBlank:false},{xtype:"syno_combobox",width:126,name:"domain_type_text",store:[SYNO.SDS.DNS.V4REVERSDOMAIN,SYNO.SDS.DNS.V6REVERSDOMAIN],value:SYNO.SDS.DNS.V4REVERSDOMAIN}]}))},setZoneNotSupportDomainType:function(b){var a=new SYNO.ux.CompositeField({fieldLabel:SYNO.SDS.DNS._V("dns","dns_domain_name"),indent:1,items:[{xtype:"syno_textfield",name:"domain_name",vtype:"synodnsRROwner",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,allowBlank:false}]});b.push(a)},setItemForEdit:function(a,b){b.push({xtype:"syno_displayfield",indent:1,fieldLabel:SYNO.SDS.DNS._V("dns","dns_zone_name"),name:"zone_name",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_displayfield",indent:1,fieldLabel:SYNO.SDS.DNS._V("dns","dns_domain_name"),name:"domain_name",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_combobox",indent:1,fieldLabel:SYNO.SDS.DNS._V("dns","dns_zone_status"),name:"zone_enable",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,store:new Ext.data.ArrayStore({fields:["abbr","status"],data:[[SYNO.SDS.DNS.ENABLE,SYNO.SDS.DNS._V("dns","dns_enable")],[SYNO.SDS.DNS.DISABLE,SYNO.SDS.DNS._V("dns","dns_disable")]]}),displayField:"status",valueField:"abbr",mode:"local",triggerAction:"all"})},setItemForMaster:function(a,b){b.push({xtype:"syno_combobox",indent:1,fieldLabel:SYNO.SDS.DNS._V("dns","dns_serial_format"),name:"serial_format",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,store:new Ext.data.ArrayStore({fields:["abbr","serial_format"],data:[["integer",SYNO.SDS.DNS._V("dns","dns_serial_format_integer")],["date",SYNO.SDS.DNS._V("dns","dns_serial_format_date")]]}),displayField:"serial_format",value:"integer",valueField:"abbr",mode:"local",triggerAction:"all"},{xtype:"syno_checkbox",indent:1,hideLabel:true,name:"limit_transfer",boxLabel:SYNO.SDS.DNS._V("dns","dns_slave_check")},{xtype:"syno_displayfield",indent:2,value:SYNO.SDS.DNS._V("dns","dns_transfer_limit_desc")},{xtype:"syno_button",indent:2,id:this.limitTransferBtnId=Ext.id(),autoWidth:true,text:SYNO.SDS.DNS._V("dns","dns_transfer_rule"),handler:this.onTransferDialogActive,scope:this});this.setLimitQueryItem(b);this.setSlaveZoneNotifyItem(b);this.setLimitUpdateItem(b);this.setListenIfaceItem(b)},setItemForSlave:function(a,b){this.keyStore=new SYNO.API.JsonStore({appWindow:a.owner,api:"SYNO.DNSServer.Key",method:"list",version:1,root:"items",fields:["key_name"],listeners:{exception:function(e,f,g,d,h,c){this.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(h.code))},scope:this}});b.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_primary_address"),indent:1,name:"master_ip",vtype:"ip",allowBlank:false,width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH},{xtype:"syno_checkbox",boxLabel:SYNO.SDS.DNS._V("dns","dns_tsig_enable"),indent:1,hideLabel:true,name:"enable_tsig"},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_slave_tsig_desc"),indent:2},{xtype:"syno_combobox",fieldLabel:SYNO.SDS.DNS._V("dns","dns_key_name"),id:this.tsigKeyComboId=Ext.id(),indent:2,name:"tsig_key",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,store:this.keyStore,displayField:"key_name",valueField:"key_name",forceSelection:true,allowBlank:false,scope:this});this.setLimitQueryItem(b)},setItemForForward:function(a,b){b.push({xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_forwarder")+" 1",allowBlank:false,name:"forwarder1",vtype:"looseip",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,indent:1},{xtype:"syno_textfield",fieldLabel:SYNO.SDS.DNS._V("dns","dns_forwarder")+" 2",name:"forwarder2",vtype:"looseip",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,indent:1},{xtype:"syno_combobox",name:"forward_type",width:SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH,fieldLabel:SYNO.SDS.DNS._V("dns","dns_forward_type"),displayField:"display",valueField:"abbr",value:"first",indent:1,store:new SYNO.SDS.DNS.ForwarderStore()},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_zone_forward_desc"),indent:1})},setLimitQueryItem:function(a){a.push({xtype:"syno_checkbox",boxLabel:SYNO.SDS.DNS._V("dns","dns_service_client_limit"),name:"limit_query",indent:1},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_zone_limit_desc"),indent:2},{xtype:"syno_button",text:SYNO.SDS.DNS._V("dns","dns_match_address"),id:this.limitQueryBtnId=Ext.id(),handler:this.onQueryDialogActive,scope:this,indent:2})},setSlaveZoneNotifyItem:function(a){a.push({xtype:"syno_checkbox",boxLabel:SYNO.SDS.DNS._V("dns","enable_dns_notify_slave"),name:"enable_notify",indent:1},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_notify_slave_desc"),indent:2},{xtype:"syno_button",text:SYNO.SDS.DNS._V("dns","dns_slave_ip_list"),id:this.notifySlaveZoneBtnId=Ext.id(),handler:this.onNotifyDialogActive,scope:this,indent:2})},setLimitUpdateItem:function(a){a.push({xtype:"syno_checkbox",boxLabel:SYNO.SDS.DNS._V("dns","dns_update_limit"),name:"limit_update",indent:1},{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_update_limit_desc"),indent:2},{xtype:"syno_button",text:SYNO.SDS.DNS._V("dns","dns_update_rule"),id:this.limitUpdateBtnId=Ext.id(),handler:this.onUpdateDialogActive,scope:this,indent:2})},setListenIfaceItem:function(a){a.push({xtype:"syno_checkbox",boxLabel:SYNO.SDS.DNS._V("dns","dns_register_interface_listener"),name:"listen_interface",indent:1},{xtype:"syno_displayfield",name:"listen_interface_desc",value:SYNO.SDS.DNS._V("dns","dns_interface_listener_desc"),indent:2},{xtype:"syno_button",text:SYNO.SDS.DNS._V("dns","dns_interface_listener_list"),id:this.listenIfaceBtnId=Ext.id(),handler:this.onListenDialogActive,scope:this,indent:2})},onInitial:function(){var a="";if(this.keyStore){this.keyStore.reload()}if(this.isCreate){switch(this.zoneType){case SYNO.SDS.DNS.MASTER:a=SYNO.SDS.DNS._V("dns","dns_zone_master_create");break;case SYNO.SDS.DNS.SLAVE:a=SYNO.SDS.DNS._V("dns","dns_zone_slave_create");break;case SYNO.SDS.DNS.FORWARD:a=SYNO.SDS.DNS._V("dns","dns_zone_forward_create");break}if(this.formPanel.getForm().findField("domain_type")){this.formPanel.getForm().findField("domain_type").fireEvent("select")}this.formPanel.getForm().setValues({limit_transfer:true,limit_update:true})}else{a=SYNO.SDS.DNS._V("dns","dns_zone_setting_edit");this.loadForm()}this.setTitle(a);this.doLayout()},loadForm:function(){var a=this.zoneType;var b=SYNO.SDS.DNS.GetWebAPIName(a);if(!b){SYNO.Debug("No such api: zone_type="+a);return}this.setStatusBusy();this.sendWebAPI({api:b,version:1,method:"get",params:{zone_name:this.zoneName,zone_type:this.zoneType},callback:function(e,d,c){this.clearStatusBusy();if(e){this.OriSetting=d;this.OriSetting.zone_enable=this.OriSetting.zone_enable?SYNO.SDS.DNS.ENABLE:SYNO.SDS.DNS.DISABLE;this.formPanel.getForm().setValues(this.OriSetting);this.doLayout()}else{this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(d.code))}},scope:this})},onTransferDialogActive:function(){if(!this.transfer_dialog){this.transfer_dialog=new SYNO.SDS.DNS.ConditionDialog({owner:this,service:SYNO.SDS.DNS.TRANSFER_SERVICE,name:this.zoneName,domainTypeField:this.domainTypeField,isCreate:this.isCreate});this.transfer_dialog.onInitial();this.transfer_dialog.open()}else{this.transfer_dialog.show()}},onQueryDialogActive:function(){if(!this.query_dialog){this.query_dialog=new SYNO.SDS.DNS.ConditionDialog({owner:this,service:SYNO.SDS.DNS.QUERY_SERVICE,name:this.zoneName,isCreate:this.isCreate});this.query_dialog.onInitial();this.query_dialog.open()}else{this.query_dialog.show()}},onNotifyDialogActive:function(){if(!this.notify_dialog){this.notify_dialog=new SYNO.SDS.DNS.ConditionDialog({owner:this,service:SYNO.SDS.DNS.NOTIFY_SERVICE,name:this.zoneName,isCreate:this.isCreate});this.notify_dialog.onInitial();this.notify_dialog.open()}else{this.notify_dialog.show()}},onUpdateDialogActive:function(){if(!this.update_dialog){this.update_dialog=new SYNO.SDS.DNS.ConditionDialog({owner:this,service:SYNO.SDS.DNS.UPDATE_SERVICE,name:this.zoneName,isCreate:this.isCreate});this.update_dialog.onInitial();this.update_dialog.open()}else{this.update_dialog.show()}},onListenDialogActive:function(){if(this.listen_dialog&&this.isCreate){this.listen_dialog.show();return}this.setStatusBusy();this.sendWebAPI({api:"SYNO.DNSServer.ListenIface",version:1,method:"get",params:{zone_name:this.zoneName},callback:function(c,b,a){this.clearStatusBusy();if(!c){this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(b.code));return}this.listen_dialog=new SYNO.SDS.DNS.ListenIfaceDialog({owner:this,name:this.zoneName,isCreate:this.isCreate,ifaceStatus:b.listen_interfaces_info});this.listen_dialog.onInitial();this.listen_dialog.open()},scope:this})},onSave:function(){if(!this.formPanel.getForm().isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}if(!this.formPanel.getForm().isDirty()){this.close();return}if(this.transfer_dialog&&!this.transfer_dialog.isValid()){this.setStatusError({text:String.format(SYNO.SDS.DNS._V("dns","dns_invalid_setting_with_domain_type"),SYNO.SDS.DNS._V("dns","dns_transfer_rule")),clear:true});return}this.saveZone()},createCondition:function(g){var a=g.zone_name;var f=[];if(this.transfer_dialog){var b=this.transfer_dialog.getCompoundParams({name:a});f=f.concat(b)}if(this.update_dialog){var e=this.update_dialog.getCompoundParams({name:a});f=f.concat(e)}if(this.query_dialog){var c=this.query_dialog.getCompoundParams({name:a});f=f.concat(c)}if(this.notify_dialog){var d=this.notify_dialog.getCompoundParams({name:a});f=f.concat(d)}if(this.listen_dialog){var h=this.listen_dialog.getCompoundParams({name:a});f=f.concat(h)}if(f&&0<f.length){this.sendWebAPI({scope:this,compound:{stopwhenerror:false,params:f},callback:function(n,m,k){if(m.has_fail){for(var j=0;j<f.size();j++){var l=SYNO.API.Util.GetValByAPI(m,f[j].api,f[j].method);this.creater.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(l.code));break}}}})}},saveZone:function(){var d="create";if(!this.isCreate){d="set"}var c=this.getParameter();var a=c.zone_type;var b=SYNO.SDS.DNS.GetWebAPIName(a);if(!b){SYNO.Debug("No such api: zone_type="+a);return}this.setStatusBusy();this.sendWebAPI({api:b,version:1,method:d,params:c,callback:function(g,f,e){this.clearStatusBusy();this.creater.getStore().reload();if(g){this.close();if(this.isCreate){this.createCondition({zone_name:f.zone_name})}}else{if("set"===d&&f.code===10036){this.creater.owner.getMsgBox().alert(this.title,String.format(SYNO.SDS.DNS._E(f.code),f.errors.zone,f.errors.views))}else{this.creater.owner.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(f.code))}}},scope:this})},getParameter:function(){var a={};a.zone_type=this.zoneType;switch(this.zoneType){case SYNO.SDS.DNS.SLAVE:a.master_ip=this.getFieldValue("master_ip");a.enable_tsig=this.getFieldValue("enable_tsig");a.tsig_key=this.getFieldValue("tsig_key");a.limit_query=this.getFieldValue("limit_query");break;case SYNO.SDS.DNS.MASTER:a.serial_format=this.getFieldValue("serial_format");a.limit_transfer=this.getFieldValue("limit_transfer");a.limit_query=this.getFieldValue("limit_query");a.enable_notify=this.getFieldValue("enable_notify");a.limit_update=this.getFieldValue("limit_update");a.listen_interface=this.getFieldValue("listen_interface");if(this.isCreate){a.host_ip=this.getFieldValue("host_ip");if(SYNO.SDS.DNS.REVERSE===this.getFieldValue("domain_type")){a.name_server=this.getFieldValue("rr_name_prefix")+"."+this.getFieldValue("forward_domain_name")}}break;case SYNO.SDS.DNS.FORWARD:a.forwarder1=this.getFieldValue("forwarder1");a.forwarder2=this.getFieldValue("forwarder2");a.forward_type=this.getFieldValue("forward_type");break;default:}if(this.isCreate){if(SYNO.SDS.DNS.MASTER==this.zoneType||SYNO.SDS.DNS.SLAVE==this.zoneType){a.domain_type=this.getFieldValue("domain_type")}a.domain_name=this.getDomainName(a.domain_type)}else{a.zone_enable=this.getFieldValue("zone_enable")===SYNO.SDS.DNS.ENABLE?true:false;a.zone_name=this.zoneName;a.domain_type=this.domainType;a.domain_name=this.domainName}return a},getFieldValue:function(a){return this.formPanel.getForm().findField(a).getValue()},getDomainName:function(a){switch(a){case SYNO.SDS.DNS.REVERSE:case SYNO.SDS.DNS.AD_REVERSE:return this.formPanel.getForm().findField("domain_name").getValue()+this.formPanel.getForm().findField("domain_type_text").getValue();default:return this.formPanel.getForm().findField("domain_name").getValue()}},isDirty:function(){var b=false;var a=[this.formPanel.getForm()];if(this.isCreate){a.push(this.transfer_dialog,this.update_dialog,this.query_dialog,this.notify_dialog,this.listen_dialog)}Ext.each(a,function(c){if(c&&c.isDirty()){b=true;return false}});return b},onCancle:function(){if(this.isDirty()){this.getMsgBox().confirm(this.title,SYNO.SDS.DNS._V("common","confirm_lostchange"),function(a){if("yes"===a){this.close()}},this)}else{this.close()}}});Ext.define("SYNO.SDS.DNS.UploadZone",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){this.owner=a.owner;this.creater=a.creater;SYNO.SDS.DNS.UploadZone.superclass.constructor.call(this,Ext.apply({title:SYNO.SDS.DNS._V("dns","dns_zone_import"),resizable:false,width:550,height:200,buttons:[{text:SYNO.SDS.DNS._V("common","apply"),btnStyle:"blue",scope:this,handler:this.onUpload,disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},{text:SYNO.SDS.DNS._V("common","cancel"),scope:this,handler:this.close}],items:[new SYNO.SDS.Utils.FormPanel({itemId:"panelZone",fileUpload:true,webapi:{api:"SYNO.DNSServer.Zone",method:"import",version:1},onApiSuccess:function(){this.ownerCt.clearStatusBusy();this.ownerCt.creater.getStore().reload();this.ownerCt.close()},onApiFailure:function(d,c,b){this.ownerCt.clearStatusBusy();this.ownerCt.onFormZoneComplete(c)},trackResetOnLoad:true,labelWidth:150,frame:false,border:false,items:[{xtype:"syno_combobox",fieldLabel:SYNO.SDS.DNS._V("dns","dns_file_type"),name:"file_type",width:289,store:new Ext.data.ArrayStore({fields:["abbr","file_type"],data:[[SYNO.SDS.DNS.RESOURCERECORD,SYNO.SDS.DNS._V("dns","dns_resource_record")],[SYNO.SDS.DNS.COMPLETESETTING,SYNO.SDS.DNS._V("dns","dns_zone_complete_setting")]]}),displayField:"file_type",value:SYNO.SDS.DNS.RESOURCERECORD,valueField:"abbr",mode:"local",triggerAction:"all"},{xtype:"syno_textfield",allowBlank:false,width:289,vtype:"synodnsHostname",fieldLabel:SYNO.SDS.DNS._V("dns","dns_domain_name"),name:"domain_name"},{xtype:"syno_textfield",hidden:true,name:"domain_type"},{xtype:"syno_filebutton",inputType:"file",fieldLabel:SYNO.SDS.DNS._V("dns","dns_zone_file"),name:"upload_zone"}]})]},a));this.formZone=this.getComponent("panelZone").getForm();this.mon(this.getField("upload_zone").getEl(),"change",this.onSelectFile,this);this.monDomainNameField()},monDomainNameField:function(){this.mon(this.getField("file_type"),"select",function(){this.getField("domain_name").setVisible(SYNO.SDS.DNS.RESOURCERECORD===this.getFieldValue("file_type"));this.getField("domain_name").setDisabled(SYNO.SDS.DNS.RESOURCERECORD!==this.getFieldValue("file_type"))},this)},onSelectFile:function(f,b){var d=this.getFieldValue("upload_zone");var h=this.getZoneName(d);var a=h.indexOf("(");var c=(0>a)?h:h.slice(0,a);c=c.replace(/\s+$/,"");this.getField("domain_name").setValue(c);var e=this.getFieldValue("domain_name");var g=this.getDomainType(e);this.getField("domain_type").setValue(g)},onUpload:function(){if(!this.formZone.isValid()){this.setStatusError({text:SYNO.SDS.DNS._V("common","forminvalid"),clear:true});return}if(!this.getFieldValue("upload_zone")){this.setStatusError({text:SYNO.SDS.DNS._V("service","service_ssl_no_file")});return}this.setStatusBusy({text:SYNO.SDS.DNS._V("common","saving")});this.getComponent("panelZone").upload()},onFormZoneComplete:function(g){switch(g.code){case 10031:var a=new SYNO.SDS.DNS.UploadZone.ErrLog({owner:this});var d=[];var f;var c=[];if(!g.errors||!g.errors.items||!Ext.isArray(g.errors.items)||(g.errors.items.length===0)){this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(g.code));return}c=g.errors.items;for(var b=0;b<c.length;b++){f=c[b];d.push([f.errlog])}a.store.loadData(d,false);a.open();break;case 10038:var e=this.getFieldValue("upload_zone");var h=this.getZoneName(e);this.getMsgBox().alert(this.title,String.format(SYNO.SDS.DNS._E(g.code),h,g.errors.not_exist_zone_name));break;default:this.getMsgBox().alert(this.title,SYNO.SDS.DNS._E(g.code))}},getZoneName:function(c){var a=/(.*[/\\])?([^$]+$)/.exec(c);var b=a[2];return b.replace(/.txt$/i,"").replace(/.zone$/i,"")},getDomainType:function(c){var b=c.lastIndexOf(SYNO.SDS.DNS.V4REVERSDOMAIN);var a=c.lastIndexOf(SYNO.SDS.DNS.V6REVERSDOMAIN);if(0>b&&0>a){return SYNO.SDS.DNS.FORWARD}else{return SYNO.SDS.DNS.REVERSE}},getField:function(a){return this.formZone.findField(a)},getFieldValue:function(a){return this.formZone.findField(a).getValue()}});Ext.define("SYNO.SDS.DNS.UploadZone.ErrLog",{extend:"SYNO.SDS.ModalWindow",constructor:function(a){var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){this.descPanel=this.createDescPanel();var b={title:SYNO.SDS.DNS._V("dns","dns_zone_import"),height:370,width:700,layout:"fit",items:this.descPanel,buttons:[{text:SYNO.SDS.DNS._V("common","alt_finish"),handler:this.close,scope:this}]};Ext.apply(b,a);return b},createDescPanel:function(){this.gridPanel=this.createGridPanel();var a={height:50,border:false,layout:"form",trackResetOnLoad:true,items:[{xtype:"syno_displayfield",value:SYNO.SDS.DNS._V("dns","dns_file_format_error"),indent:1},this.gridPanel]};return new SYNO.ux.FormPanel(a)},createGridPanel:function(){var b=function(e,d){d.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"';return e};this.store=new Ext.data.ArrayStore({autoDestroy:true,fields:["errlog"],data:[]});var a=new Ext.grid.ColumnModel([{header:SYNO.SDS.DNS._V("dns","dns_event_info"),defaultWidth:225,dataIndex:"errlog",align:"center",id:this.lastClumnId=Ext.id(),renderer:b}]);var c={height:250,ds:this.store,cm:a,autoExpandColumn:this.lastClumnId,loadMask:false,enableColLock:true,enableColumnMove:false,enableHdMenu:false,selModel:new Ext.grid.RowSelectionModel({})};return new SYNO.ux.GridPanel(c)}});Ext.ns("SYNO.SDS.DNS");Ext.ns("SYNO.SDS.DNS.CAA");SYNO.SDS.DNS.DNS="dns";SYNO.SDS.DNS.RESERVED_KEYNAME="rndc-key";SYNO.SDS.DNS.CREATE="create";SYNO.SDS.DNS.EDIT="edit";SYNO.SDS.DNS.BATCH_EDIT="batch_edit";SYNO.SDS.DNS.DELETE="delete";SYNO.SDS.DNS.ADDRESS="address";SYNO.SDS.DNS.SUBNET="subnet";SYNO.SDS.DNS.KEY="key";SYNO.SDS.DNS.PORT="port";SYNO.SDS.DNS.RESOLUTION_NAME="resolve";SYNO.SDS.DNS.RECURSION_SERVICE="recursion";SYNO.SDS.DNS.VIEW_SERVICE="view";SYNO.SDS.DNS.TRANSFER_SERVICE="transfer";SYNO.SDS.DNS.QUERY_SERVICE="query";SYNO.SDS.DNS.NOTIFY_SERVICE="notify";SYNO.SDS.DNS.UPDATE_SERVICE="update";SYNO.SDS.DNS.MASTER="master";SYNO.SDS.DNS.SLAVE="slave";SYNO.SDS.DNS.RESOURCERECORD="resource_record";SYNO.SDS.DNS.COMPLETESETTING="complete_setting";SYNO.SDS.DNS.ERR_NAME_REPEAT="name_repeat";SYNO.SDS.DNS.ERR_NAME_RESERVED="dns_reserved_name";SYNO.SDS.DNS.ERR_NO_SPACE="no_enought_space";SYNO.SDS.DNS.ERR_UPLOAD_FAILED="upload_failed";SYNO.SDS.DNS.ERR_WRONG_FORMAT="format_error";SYNO.SDS.DNS.ERR_CONDITION_REPEAT="condition_repeat";SYNO.SDS.DNS.ERR_NO_ERROR="success";SYNO.SDS.DNS.ERR_UNKNOW="error";SYNO.SDS.DNS.A="A";SYNO.SDS.DNS.AAAA="AAAA";SYNO.SDS.DNS.CNAME="CNAME";SYNO.SDS.DNS.NS="NS";SYNO.SDS.DNS.MX="MX";SYNO.SDS.DNS.SRV="SRV";SYNO.SDS.DNS.SPF="SPF";SYNO.SDS.DNS.TXT="TXT";SYNO.SDS.DNS.PTR="PTR";SYNO.SDS.DNS.CAA.CAA="CAA";SYNO.SDS.DNS.V4REVERSDOMAIN=".in-addr.arpa";SYNO.SDS.DNS.V6REVERSDOMAIN=".ip6.arpa";SYNO.SDS.DNS.FORWARD="forward";SYNO.SDS.DNS.REVERSE="reverse";SYNO.SDS.DNS.AD_REVERSE="ad_reverse";SYNO.SDS.DNS.ENABLE="enable";SYNO.SDS.DNS.DISABLE="disable";SYNO.SDS.DNS.CAA.ISSUE="issue";SYNO.SDS.DNS.CAA.ISSUEWILD="issuewild";SYNO.SDS.DNS.CAA.IODEF="iodef";SYNO.SDS.DNS.CAA.CUSTOM="CA custom";SYNO.SDS.DNS.DEFAULT_RR_TTL="86400";SYNO.SDS.DNS.DEFAULT_DLZ_RR_TTL="900";SYNO.SDS.DNS.DNS_APP_WIDTH=990;SYNO.SDS.DNS.DNS_APP_HEIGHT=560;SYNO.SDS.DNS.DNS_CARD_WIDTH=797;SYNO.SDS.DNS.DNS_LIST_WIDTH=220;SYNO.SDS.DNS.DNS_DEFAULT_HEIGHT=548;SYNO.SDS.DNS.DNS_GRID_DATA_WIDTH=759;SYNO.SDS.DNS.DNS_GRID_DATA_HEIGHT=474;SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH=260;SYNO.SDS.DNS.DNS_RECD_TEXTFIELD_WIDTH=300;SYNO.SDS.DNS.DNS_TEXTFIELD_WIDTH_SHORT=130;SYNO.SDS.DNS.DNS_TOOLBAR_HEIGHT=31;SYNO.SDS.DNS.DNS_GRID_HEIGHT=500;SYNO.SDS.DNS.DNS_DIALOG_WIDTH=500;SYNO.SDS.DNS.DNS_DIALOG_HEIGHT=500;SYNO.SDS.DNS.DNS_STATUS_HEIGHT=600;SYNO.SDS.DNS.DNS_FORM_HEIGHT=600;SYNO.SDS.DNS.DNS_FORM_WIDTH=425;SYNO.SDS.DNS.DNS_BUTTON_WIDTH=100;SYNO.SDS.DNS.DNS_TEXTLABEL_WIDTH=250;SYNO.SDS.DNS.DNS_TAB_PAENL_WIDTH=575;SYNO.SDS.DNS.DNS_LABEL_WIDTH=200;SYNO.SDS.DNS.DNS_FORM_PADDING=15;SYNO.SDS.DNS.DNS_RESOURCE_RECORD_WIDTH=640;SYNO.SDS.DNS.DNS_TXT_RECORD_MAX_LENGTH=255;SYNO.SDS.DNS.AD_ZONENAME_POSTFIX="@Active Directory";SYNO.SDS.DNS._E=function(a){var b={10003:SYNO.SDS.DNS._V("user","user_file_upload_fail"),10010:SYNO.SDS.DNS._V("dns","dns_key_format_error"),10011:SYNO.SDS.DNS._V("dns","dns_reserved_keyname"),10012:SYNO.SDS.DNS._V("dns","dns_key_repeat"),10020:SYNO.SDS.DNS._V("dns","dns_rule_repeat"),10030:SYNO.SDS.DNS._V("dns","dns_file_not_found"),10031:SYNO.SDS.DNS._V("dns","dns_file_format_error"),10032:SYNO.SDS.DNS._V("dns","dns_zone_conflict"),10033:SYNO.SDS.DNS._V("dns","dns_slave_zone_file_not_exist"),10034:SYNO.SDS.DNS._V("dns","dns_slave_zone_include_more_than_twice"),10035:SYNO.SDS.DNS._V("dns","dns_update_zone_include_more_than_twice"),10036:SYNO.SDS.DNS._V("dns","dns_fail_enable_update_in_multiple_views"),10037:SYNO.SDS.DNS._V("dns","dns_zone_name_repeat"),10038:SYNO.SDS.DNS._V("dns","import_file_not_exist"),10042:SYNO.SDS.DNS._V("dns","dns_quotation_mark_not_enclosed"),10043:SYNO.SDS.DNS._V("dns","cname_conflict1"),10044:SYNO.SDS.DNS._V("dns","cname_conflict2"),10045:SYNO.SDS.DNS._V("dns","dns_dlz_record_conflict"),10046:SYNO.SDS.DNS._V("dns","dns_dlz_record_conflict_create"),10047:SYNO.SDS.DNS._V("dns","invalid_resource_record_syntax"),10050:SYNO.SDS.DNS._V("dns","dns_name_repeat")};return b[a]===undefined?_T("error","error_unknown"):b[a]};SYNO.SDS.DNS._V=function(b,a){if(SYNO.SDS.DNS.DNS===b){if(SYNO.SDS.isNSM&&(("dns_advanced_set_desc"===a)||("dns_memory_not_enough"===a))){return _TT("SYNO.SDS.DNS.Instance",b,a.concat("_northstarplus"))}return _TT("SYNO.SDS.DNS.Instance",b,a)}else{return _T(b,a)}};SYNO.SDS.DNS.RenderLogContent=function(b,a){if(null!==a){a.attr='ext:qtip="'+b+'"'}return b};Ext.form.VTypes.synodnsNameVal=/^[-_.a-zA-Z0-9]{0,32}$/;Ext.form.VTypes.synodnsNameMask=/[-_.a-zA-Z0-9]/;Ext.form.VTypes.synodnsNameText=SYNO.SDS.DNS._V("common","forminvalid");Ext.form.VTypes.synodnsName=function(a){if(!Ext.form.VTypes.synodnsNameVal.test(a)){return false}return true};Ext.form.VTypes.synodnsKeyNameVal=/^[-_.a-zA-Z0-9]{0,63}$/;Ext.form.VTypes.synodnsKeyNameMask=/[-_.a-zA-Z0-9]/;Ext.form.VTypes.synodnsKeyNameText=SYNO.SDS.DNS._V("common","forminvalid");Ext.form.VTypes.synodnsKeyName=function(a){if(!Ext.form.VTypes.synodnsKeyNameVal.test(a)){return false}return true};Ext.form.VTypes.synodnsemailText=_JSLIBSTR("vtype","bad_email");Ext.form.VTypes.synodnsemailMask=/[0-9A-Za-z!#$%&'*+\-\/=?^_`{|}~@\.]/;Ext.form.VTypes.synodnsemailVal=Ext.form.VTypes.emailVal;Ext.form.VTypes.synodnsemail=function(a){if(Ext.form.VTypes.synodnsemailVal.test(a)){return true}if(!Ext.form.VTypes.hostnameVal1.test(a)){return false}return Ext.form.VTypes.hostnameVal2.test(a)};Ext.form.VTypes.synodnsTxtVal=/[^ ]{0,1024}$/;Ext.form.VTypes.synodnsTxtText=SYNO.SDS.DNS._V("dns","dns_txt_field_error");Ext.form.VTypes.synodnsTxt=function(a){return true};Ext.form.VTypes.synodnsHostnameText=_JSLIBSTR("vtype","bad_hostname");Ext.form.VTypes.synodnsHostnameMask=/[_\-.a-zA-Z0-9]/;Ext.form.VTypes.synodnsHostnameVal1=/^[_a-zA-Z0-9][_\-.a-zA-Z0-9]{0,254}$/;Ext.form.VTypes.synodnsHostnameVal2=/^[_a-zA-Z0-9]([_\-a-zA-Z0-9]{0,61}[_a-zA-Z0-9]){0,1}([.][_a-zA-Z0-9]([_\-a-zA-Z0-9]{0,61}[_a-zA-Z0-9]){0,1}){0,}$/;Ext.form.VTypes.synodnsHostname=function(a){if(!Ext.form.VTypes.synodnsHostnameVal1.test(a)){return false}return Ext.form.VTypes.synodnsHostnameVal2.test(a)};Ext.form.VTypes.synodnsRROwnerText=_JSLIBSTR("vtype","bad_hostname");Ext.form.VTypes.synodnsRROwnerMask=/[-_.a-zA-Z0-9*]/;Ext.form.VTypes.synodnsRROwnerVal1=/^[_a-zA-Z0-9*][_\-_.a-zA-Z0-9]{0,254}$/;Ext.form.VTypes.synodnsRROwnerVal2=/^[_a-zA-Z0-9*]([_\-a-zA-Z0-9]{0,61}[_a-zA-Z0-9]){0,1}([.][_a-zA-Z0-9]([_\-a-zA-Z0-9]{0,61}[_a-zA-Z0-9]){0,1}){0,}$/;Ext.form.VTypes.synodnsRROwner=function(a){if(!Ext.form.VTypes.synodnsRROwnerVal1.test(a)){return false}if(2==a.length){if("*"==a[0]){return false}}else{if(2<a.length){if("*"==a[0]&&"."!=a[1]){return false}}}return Ext.form.VTypes.synodnsRROwnerVal2.test(a)};Ext.form.VTypes.synodnsTXTText=_JSLIBSTR("vtype","bad_hostname");Ext.form.VTypes.synodnsTXTMask=/[-_.a-zA-Z0-9*]/;Ext.form.VTypes.synodnsTXTVal1=/^[\-_a-zA-Z0-9\*][\-_.a-zA-Z0-9\*]{0,254}$/;Ext.form.VTypes.synodnsTXTVal2=/^[\-\*_a-zA-Z0-9]([\-\*_a-zA-Z0-9]{0,61}[\-\*_a-zA-Z0-9]){0,1}([.][\-\*_a-zA-Z0-9]([\-\*_a-zA-Z0-9]{0,61}[\-\*_a-zA-Z0-9]){0,1}){0,}$/;Ext.form.VTypes.synodnsTXT=function(a){if(!Ext.form.VTypes.synodnsTXTVal1.test(a)){return false}return Ext.form.VTypes.synodnsTXTVal2.test(a)};Ext.form.VTypes.synodnsv4ipText=_JSLIBSTR("vtype","bad_ip");Ext.form.VTypes.synodnsv4ipMask=/[.0-9]/;Ext.form.VTypes.synodnsv4ipVal=/^([0-9]{1,3}\.){3}[0-9]{1,3}$/;Ext.form.VTypes.synodnsv4ip=function(a){var b=0;var d;if(!Ext.form.VTypes.synodnsv4ipVal.test(a)){return false}d=a.split(".");for(var c=0;c<d.length;c++){if(("0"===d[c][0]&&d[c].length>1)){return false}b=parseInt(d[c],10);switch(c){case 0:if(b<1||b>223){return false}break;case 1:case 2:case 3:if(b<0||b>255){return false}break}}return true};Ext.form.VTypes.synodnslooseipText=_JSLIBSTR("vtype","bad_ip");Ext.form.VTypes.synodnslooseipMask=/[.:0-9A-Fa-f]/;Ext.form.VTypes.synodnslooseip=function(a){if(!Ext.form.VTypes.synodnsv4ip(a)&&!Ext.form.VTypes.loosev6ip(a)){return false}return true};Ext.form.VTypes.synodnsCAAParamsText=SYNO.SDS.DNS._V("common","forminvalid");Ext.form.VTypes.synodnsCAAParams=function(b){var c=true;var d=b.split(" ");var a=[];if(!b){return true}Ext.each(d,function(e){a=e.split("=");if(2!==a.length){c=false;return false}if(!a[0]){c=false;return false}});return c};Ext.form.VTypes.synodnsCAACustomTypeText=SYNO.SDS.DNS._V("common","forminvalid");Ext.form.VTypes.synodnsCAACustomTypeMask=/[a-zA-Z0-9]/;Ext.form.VTypes.synodnsCAACustomTypeVal=/^[a-zA-Z0-9]{1,15}$/;Ext.form.VTypes.synodnsCAACustomType=function(a){return Ext.form.VTypes.synodnsCAACustomTypeVal.test(a)};Ext.form.VTypes.synodnsCAACustomInfoText=SYNO.SDS.DNS._V("common","forminvalid");Ext.form.VTypes.synodnsCAACustomInfo=function(a){if(0<=a.indexOf('"')){return false}return true};SYNO.SDS.DNS.ZONE_STATUS_TABLE=[["disable-font","dns_disabled"],["green-status","dns_enabled"]];SYNO.SDS.DNS.RenderZoneStatus=function(b,a){var c=function(d){return'<font class="'+SYNO.SDS.DNS.ZONE_STATUS_TABLE[d][0]+'">'+SYNO.SDS.DNS._V("dns",SYNO.SDS.DNS.ZONE_STATUS_TABLE[d][1])+"</>"};return c(b===true?1:0)};SYNO.SDS.DNS.ZONE_CONDITION_TYPE_TABLE=[["normal-font"],["normal-font"],["normal-font"]];SYNO.SDS.DNS.RenderConditionType=function(d,c){var a;var b;for(a=0;a<SYNO.SDS.DNS.ZONE_CONDITION_TYPE_TABLE.length;a++){if(SYNO.SDS.DNS.ADDRESS==d){b='<font class="'+SYNO.SDS.DNS.ZONE_CONDITION_TYPE_TABLE[a][0]+'">'+SYNO.SDS.DNS._V("nfs","nfs_fieldtitle_host")+"</>"}else{if(SYNO.SDS.DNS.SUBNET==d){b='<font class="'+SYNO.SDS.DNS.ZONE_CONDITION_TYPE_TABLE[a][0]+'">'+SYNO.SDS.DNS._V("firewall","firewall_source_network")+"</>"}else{b='<font class="'+SYNO.SDS.DNS.ZONE_CONDITION_TYPE_TABLE[a][0]+'">'+SYNO.SDS.DNS._V("dns","dns_key")+"</>"}}}return b};SYNO.SDS.DNS.IsDLZZone=function(a){if(!!!a){return false}if(typeof a!=="string"){return false}if(0>=a.indexOf("@Active Directory")){return false}return true};SYNO.SDS.DNS.IsReverseDLZZone=function(a){if(!!!a){return false}if(typeof a!=="string"){return false}if(0>=a.indexOf(".in-addr.arpa@Active Directory")&&0>=a.indexOf(".ip6.arpa@Active Directory")){return false}return true};Ext.define("SYNO.SDS.DNS.SimpleJsonRecordStore",{extend:"SYNO.API.JsonStore",constructor:function(b){this.szPreField="";this.blToggleDirection=true;var a=Ext.apply({appWindow:b.appWindow,api:"SYNO.DNSServer.Zone.Record",method:"list",version:1,root:"items",fields:b.fields,baseParams:{sort_by:"rr_owner",sort_direction:"ASC",filter_by:""},setFilterString:function(c){this.baseParams.filter_by=c},clearFilterString:function(){this.baseParams.filter_by=""},sort:function(d,c){if(!d){SYNO.Debug("params is empty");return}if("DESC"===c){this.blToggleDirection=false}else{if("ASC"===c){this.blToggleDirection=true}else{if(this.szPreField===d){if(this.blToggleDirection){this.blToggleDirection=false}else{this.blToggleDirection=true}}else{this.blToggleDirection=true}}}if(this.blToggleDirection){this.baseParams.sort_direction="ASC"}else{this.baseParams.sort_direction="DESC"}this.szPreField=d;this.baseParams.sort_by=d;this.load()}},b);this.callParent([a])}});Ext.define("SYNO.SDS.DNS.ForwarderStore",{extend:"Ext.data.ArrayStore",constructor:function(b){var a=Ext.apply({fields:["abbr","display"],data:[["first",SYNO.SDS.DNS._V("dns","dns_forward_first")],["only",SYNO.SDS.DNS._V("dns","dns_forward_only")]]},b);this.callParent([a])}});Ext.define("SYNO.SDS.DNS.DomainTypeStore",{extend:"Ext.data.ArrayStore",constructor:function(b){var d=b?!!b.isADMode:false;var c=[[SYNO.SDS.DNS.FORWARD,SYNO.SDS.DNS._V("dns","dns_forward_domain")],[SYNO.SDS.DNS.REVERSE,SYNO.SDS.DNS._V("dns","dns_reverse_domain")]];if(d){c.push([SYNO.SDS.DNS.AD_REVERSE,SYNO.SDS.DNS._V("dns","dns_reverse_domain")+SYNO.SDS.DNS.AD_ZONENAME_POSTFIX])}var a=Ext.apply({fields:["abbr","domain_type"],data:c},b);this.callParent([a])}});Ext.define("SYNO.SDS.DNS.RecordFilter",{extend:"SYNO.ux.TextFilter",constructor:function(b){var a=Ext.apply({iconStyle:"filter",queryParam:"filterString"},b);this.callParent([a])},filter:function(){if(this.store){this.store.setFilterString(this.getValue())}this.callParent()},onTriggerClick:function(a){if(this.store){this.store.clearFilterString()}this.callParent([a])}});SYNO.SDS.DNS.GetWebAPIName=function(a){switch(a){case SYNO.SDS.DNS.MASTER:return"SYNO.DNSServer.Zone.MasterZoneConf";case SYNO.SDS.DNS.SLAVE:return"SYNO.DNSServer.Zone.SlaveZoneConf";case SYNO.SDS.DNS.FORWARD:return"SYNO.DNSServer.Zone.ForwardZoneConf"}return""};