/* Copyright (c) 2023 Synology Inc. All rights reserved. */ Ext.namespace("SYNO.SDS.AdminCenter"),Ext.apply(SYNO.SDS.AdminCenter,{USER_PAGING_SIZE:50,GROUP_PAGING_SIZE:25}),SYNO.SDS.AdminCenter.Module=Ext.extend(Object,{constructor:Ext.emptyFn,activate:Ext.emptyFn,deactivate:function(){return!0},focus:Ext.emptyFn,confirmCallback:function(e){},confirmLostChangeSave:function(){},confirmLostChangeDontSave:function(){},confirmLostChangeCancel:function(){},getPanel:function(){return null},getAbsoluteURL:function(e){return String.format("{0}/{1}",this.jsConfig.jsBaseURL,e)},getHelpParam:Ext.emptyFn}),Ext.define("SYNO.SDS.AdminCenter.SearchField",{extend:"SYNO.SDS.Utils.SearchField",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t={width:212,itemId:"search",listEmptyText:_T("search","no_search_result"),tpl:this.getSearchResultTpl(),listAlign:["tl-bl?",[-1,1]],type:"app",listeners:{scope:this,select:this.onSearchResultSelect.createDelegate(this)},onStoreLoad:function(e){this.tpl.appSection=0,e.filterBy(function(e){var t=e.get("owner"),i=e.get("id"),s=e.get("type");return!(!this.findAppWindow().isModuleEnabled(this.getModuleFn(i))||this.isFromCMS()&&"help"===s||!this.findAppWindow().isCMSJoined&&"SYNO.SDS.AdminCenter.Application?fn=SYNO.SDS.AdminCenter.CMS.Main"===i||"SYNO.SDS.AdminCenter.Application"!==t)}.createDelegate(this))}};return Ext.apply(t,e),t},clearLastQuery:function(){this.setValue(""),this.lastQuery=""},getModuleFn:function(e){var t=SYNO.SDS.Utils.ParseSearchID(e);return t.params&&t.params.fn?t.params.fn:""},getSearchResultTpl:function(){return new Ext.XTemplate('',"",'
','','{title}',"
","
","
",{appSection:0,getModuleIcon:this.getModuleIcon.createDelegate(this)})},getModuleIcon:function(e){var t,i=SYNO.SDS.UIFeatures.IconSizeManager.isRetinaMode();return t=String.format("images/1x/ControlPanel_{0}.png",i?"32":"16"),this.findAppWindow().jsConfig.jsBaseURL+"/"+t+"?v="+_S("fullversion")},onSearchResultSelect:function(e,t,i){var s={className:null,params:{}};switch(t.get("type")){case"app":(s=SYNO.SDS.Utils.ParseSearchID(t.get("id"))).params&&s.params.fn&&this.findAppWindow().startModule(s.params.fn,s.params)}},isFromCMS:function(){return"SYNO.SDS.CMS.Application"===this.findAppWindow().getOpenConfig("className")}}),Ext.define("SYNO.SDS.AdminCenter.SUSSearchField",{extend:"SYNO.SDS.AdminCenter.SearchField",fillConfig:function(e){var t=this.callParent([{}]);return Ext.apply(t,{queryParam:"keyword",queryDelay:200,itemId:"sus-search",store:new SYNO.API.JsonStore({autoDestroy:!0,appWindow:this.findAppWindow()||!1,api:"SYNO.Finder.AppIndexing.Search",method:"search",version:1,root:"hits",fields:["id","title","owner","desc",{name:"type",convert:function(){return"app"}},{name:"desc",convert:function(e){return String.format(e,_D("product"))}}],baseParams:{search_weight_list:[{field:"SYNOMDWildcard",weight:1},{field:"keywords",weight:5},{field:"search_title",weight:10}],from:0,size:10,lang:_S("lang")}})}),Ext.apply(t,e)}}),Ext.define("SYNO.SDS.AdminCenter.HomeScreenPanel",{extend:"SYNO.ux.Panel",constructor:function(e){this.callParent([this.fillConfig(e)]),this.addEvents("storeloaded","screenviewchanged"),this.relayEvents(this.getHomeScreenView(),["storeloaded","screenviewchanged"]),this.mon(SYNO.SDS.StatusNotifier,"thirdpartychanged",()=>{setTimeout(()=>{SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Finder.Application")?(this.searchField.hide(),this.susSearchField.show()):(this.searchField.show(),this.susSearchField.hide())},1e3)})},fillConfig:function(e){var t={cls:"home-screen-panel",layout:"fit",tbar:this.getTBar(),items:{xtype:"container",layout:"card",itemId:"view-container",activeItem:"advanced",cls:"home-screen-wrap",items:[this.getHomeScreenView()],listeners:{afterrender:{fn:this.customSetActiveItem,scope:this},resize:{fn:this.onResizePanel,scope:this,buffer:50}}},listeners:{activate:{fn:this.activateHandler,scope:this},storeloaded:{fn:e.owner.onHomeScreenReady,scope:e.owner},screenviewchanged:{fn:this.onHomeScreenViewChanged,scope:this}}};return Ext.apply(t,e),t},onResizePanel:function(e,t,i){this.getActiveView().setHeight.defer(200,this.getActiveView(),[i])},getTBar:function(){var e=SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Finder.Application");return this.searchField=new SYNO.SDS.AdminCenter.SearchField({itemId:"search-field",cls:"home-screen-search-field syno-textfilter-text",hidden:e,width:260}),this.susSearchField=new SYNO.SDS.AdminCenter.SUSSearchField({itemId:"sus-search-field",cls:"home-screen-search-field syno-textfilter-text",hidden:!e,width:260}),{xtype:"container",cls:"home-screen-tbar",items:[this.searchField,this.susSearchField]}},customSetActiveItem:function(){this.getComponent("view-container").layout.setActiveItem=function(e,t){var i,s,n,o=this.activeItem,a=this.container;if(n=(e=a.getComponent(e)).doLayout&&(this.layoutOnCardChange||!e.rendered),i=a.activeCls||"active-view",s=a.activeTime||200,t)e&&o!==e&&o&&(o.removeClass(i),o.hide.defer(s,o),o.fireEvent("deactivate")),delete e.deferLayout,e.show.defer(s,e),e.addClass.defer(s+50,e,[i]),this.activeItem=e,this.layout.defer(s,this),n&&e.doLayout.defer(s,e),e.fireEvent.defer(s,e,["activate",e]);else{if(e&&o!==e&&o){if(o.removeClass(i),o.hide(),!0!==o.hidden)return!1;o.fireEvent("deactivate")}delete e.deferLayout,e.show(),this.activeItem=e,this.layout(),e.addClass(i),n&&e.doLayout(),e.fireEvent("activate",e)}}},switchToView:function(e,t){var i=this.getActiveView().itemId;i!==e&&(this[e+"ModeLink"].hide(),this[i+"ModeLink"].show(),this.getViewContainer().layout.setActiveItem(e,t))},getHomeScreenView:function(){return this.homeScreenView?this.homeScreenView:(this.homeScreenView=new SYNO.SDS.AdminCenter.HomeScreenView({itemId:"advanced",cls:"advanced-homescreen-view active-view"}),this.homeScreenView)},onHomeScreenViewChanged:function(){this.susSearchField.clearLastQuery(),this.searchField.clearLastQuery()},activateHandler:function(){this.getHomeScreenView().refreshBadge()},setModuleVisible:function(e,t,i){var s=String.format("div[fn={0}]",e),n=this.getViewContainer();i?n.getComponent(i).setNodeVisible(s,t):this.getHomeScreenView().setNodeVisible(s,t)},setCategoryVisible:function(e,t){var i=String.format("div[name=category_root_{0}]",e);this.getHomeScreenView().setCategoryVisible(i,t)},getViewContainer:function(){return this.getComponent("view-container")},getActiveView:function(){return this.getViewContainer().layout.activeItem},loadModuleData:function(){this.getHomeScreenView().loadModuleData()},getModuleStore:function(){return this.getHomeScreenView().getModuleStore()}}),Ext.define("SYNO.SDS.AdminCenter._HomeScreenView",{extend:"SYNO.ux.FleXcroll.DataView",shortcutIconSize:64,constructor:function(e){this.badges={},this.getModuleStoreUrl(),this.callParent([this.fillConfig(e)]),this.mon(SYNO.SDS.StatusNotifier,"badgenumget",this.badgeNumGetHandler,this)},fillConfig:function(e){var t={header:!1,store:this.getModuleStore(),tpl:this.getMyTemplate(),cls:"home-screen-view",itemSelector:"div.item-wrap",singleSelect:!0,useARIA:!0,"aria-label":_T("tree","leaf_control_panel"),listeners:{scope:this,click:this.itemClickHandler,afterrender:function(e){this.initDataViewMouseEvents(e)}.bind(this),activate:this.activateHandler}};return Ext.apply(t,e),t},getModuleStoreUrl:function(){this.moduleStoreUrl="modules/modules.json"},getModuleStore:function(){return this.moduleStore?this.moduleStore:(SYNO.Debug.mark("AdminCenter load modules"),this.moduleStore=new Ext.data.JsonStore({autoDestroy:!0,proxy:new Ext.data.HttpProxy({method:"GET",disableCaching:!!Ext.isDefined(SYNO.SDS.JSDebug),url:this.getAbsoluteURL(this.moduleStoreUrl)}),root:"listItems",fields:["text","formatedTitle","items"],idProperty:"text",listeners:{scope:this,load:this.storeLoadHandler}}),this.moduleStore)},loadModuleData:function(){this.storeloaded||this.getModuleStore().load({params:{v:_S("version")}})},setNodeVisible:function(e,t){var i=this.el.select(e),s=this.nodeInfo;if(i.setVisibilityMode(Ext.Element.DISPLAY).setVisible(t),s){var n,o,a,r,l=i.el.dom;if(l){for(n=l.getAttribute("cate"),o=0;o=0)return;r=a.indexOf(l.previousSibling),a.splice(r+1,0,l),this.refreshBadge()}else a.indexOf(l)>=0&&a.splice(a.indexOf(l),1)}}},initVisibleNodeInfo:function(){var e,t,i,s,n,o,a=this.store;for(this.nodeInfo=[],o=0,e=0;e0&&((a=this.createBadge(s)).setNumWithAutoPos(o),this.badges[e]=a))},createBadge:function(e){var t=new SYNO.SDS.Utils.Notify.Badge({renderTo:e,alignOffset:[0,0],badgeWidth:20,badgeHeight:20,hideNum:!1,badgeClassName:"badge sds-application-notify-badge-num"});return this.addManagedComponent(t),t},getItemWrapperByFn:function(e){var t=String.format("div.item-wrap[fn={0}]",e);return this.el?this.el.child(t):null},getItemElByFn:function(e){var t=String.format("div.item-wrap[fn={0}] .icon-image",e);return this.el?this.el.child(t):null},initDataViewMouseEvents:function(e){this.mon(e.getTemplateTarget(),"mousedown",this.onDataViewMouseDown,this,{dataView:e})},onToggleSelectedItem:function(){if(this.hasNodeSelected()){var e,t=this.selected.elements[0],i=t.attributes;Ext.fly(t).isVisible()&&i.fn&&i.cate&&(e=i.fn.value)&&this.gotoModule(e)}},onKeySpace:function(){this.onToggleSelectedItem()},onKeyEnter:function(){this.onToggleSelectedItem()},onDataViewMouseDown:function(e,t,i){var s=i.dataView;s.cancelClick=!1,this.mouseDownXY=e.getXY(),this.mon(s.getTemplateTarget(),"mousemove",this.onDataViewMouseMove,this,{dataView:s})},onDataViewMouseMove:function(e,t,i){var s=i.dataView;if(this.mouseDownXY){var n=Ext.dd.DragDropMgr.clickPixelThresh,o=e.getXY(),a=this.mouseDownXY,r=Math.abs(a[0]-o[0]),l=Math.abs(a[1]-o[1]);r<=n&&l<=n||(delete this.mouseDownXY,s.cancelClick=!0,this.mun(s.getTemplateTarget(),"mousemove",this.onDataViewMouseMove,this))}},setCategoryVisible:function(e,t){var i=this.container.select(e).elements;0>=i.length||i.forEach(function(e){e.style.display=t?"flex":"none"},this)},getMyTemplate:function(){return new Ext.XTemplate('','
','
',"{[SYNO.SDS.UIString.GetLocalizedString(values.text)]}","
",'','
','
','
{[SYNO.SDS.UIString.GetLocalizedString(values.formatedTitle)]}
',"
","
","
","
",{printDisplayString:function(e,t){return!0===t?'style="display: none;"':Ext.isDefined(SYNO.SDS.AppPrivilege[e])&&!1===SYNO.SDS.AppPrivilege[e]||!1===SYNO.SDS.ServiceStatus[e]?'style="display: none;"':""},getIconPath:function(e){return e?String.format("images/{1}/home_icons/icn_{0}.png",e.replace("icon-","").replace(/-/g,"_"),SYNO.SDS.UIFeatures.test("isRetina")?"2x":"1x"):"images/1x/tmp/construction.png"}})},getRowIdx:function(){if(1!==this.selected.elements.length)return-1;var e=this.selected.elements[0];return this.store.data.keys.indexOf(e.getAttribute("cate"))},getVisibleColIdx:function(e){if(1!==this.selected.elements.length||!Ext.isNumber(e))return-1;var t=this.selected.elements[0];return this.nodeInfo[e].items.indexOf(t)},getActualNodeIdx:function(e,t,i,s){if(!Ext.isNumber(e)||!Ext.isNumber(t))return-1;var n,o=this.nodeInfo,a=o[e].items,r=!1;return s?(r=(n=Math.max(Math.min(a.length-1,t+i),0))>t+i,n0},selectNext:function(){if(this.hasNodeSelected()){var e,t,i=this.getRowIdx();e=this.getVisibleColIdx(i),-1!==(t=this.getActualNodeIdx(i,e,1,!0))&&this.select(t)}else this.select(0)},selectPrev:function(){if(this.hasNodeSelected()){var e,t,i=this.getRowIdx();e=this.getVisibleColIdx(i),-1!==(t=this.getActualNodeIdx(i,e,-1,!0))&&this.select(t)}else this.select(0)},onKeyDown:function(){this.selectNext()},onKeyUp:function(){this.selectPrev()},onKeyLeft:function(){this.selectPrev()},onKeyRight:function(){this.selectNext()},findItemByEl:function(e,t){if(!t||!t.attributes)return null;var i=t.attributes;if(!i.cate||!i.fn)return null;var s=i.cate.value,n=i.fn.value,o=this.getModuleStore().getById(s),a=null;return Ext.each(o.json.items,function(e,t,i){if(e.fn===n)return a=e,!1},this),a},getAbsoluteURL:function(e){return String.format("{0}/{1}",this.jsConfig.jsBaseURL,e)},getIconRootPath:function(){return this.jsConfig.jsBaseURL+"/"}}),Ext.define("SYNO.SDS.AdminCenter._ClassicalHomeScreenView",{extend:"SYNO.SDS.AdminCenter._HomeScreenView",shortcutIconSize:48}),SYNO.SDS.Injector.configure({getHomeScreenClass:{fn:function(){return"classical"===SYNO.SDS.UserSettings.getProperty("Desktop","desktopStyle")?"SYNO.SDS.AdminCenter._ClassicalHomeScreenView":"SYNO.SDS.AdminCenter._HomeScreenView"}}}),SYNO.SDS.AdminCenter.HomeScreenView=Ext.getClassByName(SYNO.SDS.Injector.resolve("getHomeScreenClass"))||SYNO.SDS.AdminCenter._HomeScreenView,Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.NFSRuleDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.module=e.module,this.blKerberosEnabled=e.blKerberosEnabled,this.blKerberosSupport=e.blKerberosSupport,this.blShareReadOnly=Ext.isDefined(e.owner.share.get("force_readonly_reason"))&&""!==e.owner.share.get("force_readonly_reason"),this.record=e.record?e.record:null,this.menu=this.createMenu(),this.panel=this.createPanel();var t=this.fillConfig(e);this.callParent([t]),this.record?this.initEditRule():this.initAddRule(),this.addTip()},fillConfig:function(e){var t={width:550,height:400,minWidth:550,minHeight:400,title:"",layout:"fit",items:[this.panel],buttons:[{text:_T("common","cancel"),scope:this,handler:this.close},{text:_T("common","save"),scope:this,btnStyle:"blue",handler:this.applyHandler}]};return Ext.apply(t,e),t},createMenu:function(){var e={fieldLabel:_T("nfs","nfs_security"),indent:0,hidden:!this.blKerberosSupport,allowBlank:!1,editable:!1,items:[{xtype:"menucheckitem",itemId:"nfs_auth_sys",text:"AUTH_SYS",hideOnClick:!1},"-",{xtype:"menucheckitem",itemId:"nfs_krb5",text:_T("nfs","nfs_kerberos_authentication"),hideOnClick:!1},{xtype:"menucheckitem",itemId:"nfs_krb5i",text:_T("nfs","nfs_kerberos_integrity"),hideOnClick:!1},{xtype:"menucheckitem",itemId:"nfs_krb5p",text:_T("nfs","nfs_kerberos_privacy"),hideOnClick:!1}]};return new SYNO.SDS.AdminCenter.Share.NFSRuleDialog.CheckItemsMenu(e)},createPanel:function(){var e=new Ext.data.ArrayStore({autoDestroy:!0,fields:["value","display"],data:[["root",_T("nfs","nfs_mapping_no")],["admin",String.format(_T("nfs","nfs_mapping_yes"),"admin")],["guest",String.format(_T("nfs","nfs_mapping_yes"),"guest")],["all_admin",_T("nfs","nfs_mapping_all")],["all_guest",_T("nfs","nfs_mapping_all_guest")]]}),t={title:_T("nfs","nfs_tab_title"),trackResetOnLoad:!0,padding:0,items:[{xtype:"syno_textfield",name:"client",maxlength:1024,fieldLabel:_T("nfs","nfs_host"),"aria-label":_T("nfs","nfs_host"),allowBlank:!1,blankText:_T("nfs","nfs_error_nohost"),renderer:Ext.util.Format.htmlEncode,validator:this.nfsClientNameValid},{xtype:"syno_combobox",name:"privilege",disabled:this.blShareReadOnly,fieldLabel:_T("nfs","nfs_privilege"),store:[["ro",_T("nfs","nfs_read_only")],["rw",this.blShareReadOnly?_T("nfs","nfs_read_only"):_T("nfs","nfs_read_write")]]},{xtype:"syno_combobox",name:"root_squash",fieldLabel:_T("nfs","nfs_mapping"),tpl:'
{display}
',displayField:"display",valueField:"value",store:e},this.menu,{xtype:"syno_checkbox",name:"async",boxLabel:_T("nfs","nfs_async_enable")},{xtype:"syno_checkbox",name:"insecure",boxLabel:_T("nfs","nfs_insecure_port_desc")},{xtype:"syno_checkbox",name:"crossmnt",boxLabel:_T("nfs","nfs_crossmnt_desc")}]};return SYNO.LayoutConfig.fill(t),new SYNO.SDS.Utils.FormPanel(t)},addTip:function(){SYNO.ux.AddTip(this.panel.getForm().findField("client").getEl(),[_T("nfs","nfs_hint_host"),_T("common","colon"),'
    ',String.format("
  • {0}
  • ",_T("nfs","nfs_fieldtitle_host")),String.format("
  • {0}{1}{2}
  • ",_T("nfs","nfs_fieldtitle_wildcard"),_T("common","colon")," *, *.synology.com"),String.format("
  • {0}{1}{2}
  • ",_T("nfs","nfs_fieldtitle_netmask"),_T("common","colon")," 203.74.205.32/255.255.255.0, 203.74.205.32/24"),"
"].join(""))},nfsClientNameValid:function(e){var t=/^\*$/;if(e.match(t))return!0;if(Ext.form.VTypes.loosev4ip(e))return!0;if(Ext.form.VTypes.FQDN(e))return!0;if(Ext.form.VTypes.loosev6ip(e))return!0;if(t=/[\s`=~!#$%&()_+{}|;'",<>?]/,e.match(t))return!1;if(t=/\/$/,e.match(t))return!1;t=/^([^\/]+)\/([^\/]+)$/;var i=e.match(t);if(i&&Ext.form.VTypes.loosev4ip(i[1])){if(Ext.form.VTypes.netmask(i[2]))return!0;if(i[2].match(/^[1-3]?[0-9]$/))if(32>=parseInt(i[2],10))return!0;return _T("common","error_badmask")}return i&&Ext.form.VTypes.loosev6ip(i[1])?!!Ext.form.VTypes.v6prefixLeng(i[2])||_T("common","error_badmask"):(t=/^\d{1,3}(\.\d{1,3}|\.\*){2}\.\*$/,e.match(t)?_T("nfs","nfs_rule_wildcard_misuse_error"):(t=/^\[[^:]*:+[^:]*\]$/,!e.match(t)||_T("nfs","nfs_rule_wildcard_misuse_error")))},initAddRule:function(){this.setTitle(_T("nfs","nfs_new_rule")),this.panel.getForm().setValues({client:"",privilege:"rw",root_squash:"root",async:!0,insecure:!1,crossmnt:!1}),this.menu.setDefaultSec(),this.panel.getForm().clearInvalid()},initEditRule:function(){this.setTitle(_T("nfs","nfs_edit_rule")),this.panel.getForm().setValues(this.record.data),"object"==typeof this.record.get("security_flavor")?this.menu.setSecurityPolicy(this.record):this.menu.setDefaultSec()},isKerberosConfirmShow:function(e){return!(!this.blKerberosSupport||this.blKerberosEnabled||!(e.security_flavor.kerberos||e.security_flavor.kerberos_integrity||e.security_flavor.kerberos_privacy))},applyHandler:function(){var e=this.panel.getForm(),t=e.getValues();if(e.isValid()){if(Ext.isDefined(t.privilege)||(t.privilege=e.findField("privilege").getValue()),t.security_flavor={kerberos:this.menu.getItemValue("nfs_krb5"),kerberos_integrity:this.menu.getItemValue("nfs_krb5i"),kerberos_privacy:this.menu.getItemValue("nfs_krb5p"),sys:this.menu.getItemValue("nfs_auth_sys")},this.record){if(t.client!==this.record.get("client")&&this.isHostExist(t.client))return;var i=this.getFirstSelection();i.set("client",t.client),i.set("privilege",t.privilege),i.set("root_squash",t.root_squash),i.set("async",t.async),i.set("insecure",t.insecure),i.set("crossmnt",t.crossmnt),i.set("security_flavor",t.security_flavor)}else{if(this.isHostExist(t.client))return;this.addRecord(t)}this.isKerberosConfirmShow(t)?this.getMsgBox().confirm(this.title,_T("nfs","nfs_kerberos_disabled_desc"),function(e){(this.close(),"yes"===e)&&new SYNO.SDS.AdminCenter.FileService.NFS.Kerberos.MainDialog({module:this.module,owner:this.module.appWin}).open()},this):this.close()}},addRecord:function(e){var t=new(Ext.data.Record.create([{name:"client"},{name:"privilege"},{name:"root_squash"},{name:"async"},{name:"insecure"},{name:"crossmnt"},{name:"security_flavor"}]))(e);this.ownerGrid.store.add(t)},getFirstSelection:function(){return this.ownerGrid.getSelectionModel().getSelected()},isRuleExist:function(e,t){var i=this.ownerGrid.store,s=!1;return i.each(function(i){if(i.get(e)===t)return s=!0,!1},this),s},isHostExist:function(e){return!!this.isRuleExist("client",e)&&(this.module.appWin.getMsgBox().alert(this.title,_T("nfs","nfs_rule_host_exist")),!0)}}),SYNO.SDS.AdminCenter.Share.NFSRuleDialog.ItemMenu=Ext.extend(SYNO.ux.Menu,{shadow:!1,useARIA:!0,constructor:function(e){SYNO.SDS.AdminCenter.Share.NFSRuleDialog.ItemMenu.superclass.constructor.call(this,e)},onRender:function(e,t){SYNO.SDS.AdminCenter.Share.NFSRuleDialog.ItemMenu.superclass.onRender.call(this,e,t),this.keyNav.destroy(),this.keyNav=null,this.keyNav=new SYNO.ux.ScheduleMenuNav(this)}}),Ext.define("SYNO.SDS.AdminCenter.Share.NFSRuleDialog.CheckItemsMenu",{extend:"Ext.form.TriggerField",overCls:"syno-ux-triggerfield-hover",triggerClass:"syno-ux-triggerfield-trigger",constructor:function(e){var t={cls:"syno-ux-menu",autoDestroy:!0,defaults:{width:190},items:e.items};this.menu=new SYNO.SDS.AdminCenter.Share.NFSRuleDialog.ItemMenu(t),this.menu.mon(this.menu,"hide",this.onHide,this),this.menu.mon(this.menu,"click",this.setSecurityText,this),this.callParent([e]),this.mon(this,"afterrender",function(){this.setSecurityText(),this.keyNav||(this.keyNav=new Ext.KeyNav(this.el,{down:function(e){this.menu.isVisible()||this.onTriggerClick()},scope:this}))},this),this.addClass("syno-ux-triggerfield"),this.addManagedComponent(this.menu)},onTriggerClick:function(){this.menu.show(this.el)},onHide:function(){this.setSecurityText(),this.focus()},setDefaultSec:function(){this.menu.getComponent("nfs_auth_sys").setChecked(!0),this.setSecurityText()},onMouseover:function(){this.addClass("syno-ux-triggerfield-hover"),this.trigger.addClass("x-form-trigger-over")},onMouseout:function(){this.removeClass("syno-ux-triggerfield-hover"),this.trigger.removeClass("x-form-trigger-over")},markInvalid:function(e){this.callParent(arguments),this.trigger.addClass("syno-ux-trigger-invalid")},clearInvalid:function(){this.callParent(arguments),this.trigger.removeClass("syno-ux-trigger-invalid")},setSecurityPolicy:function(e){this.setItemValue("nfs_auth_sys",e.get("security_flavor").sys),this.setItemValue("nfs_krb5",e.get("security_flavor").kerberos),this.setItemValue("nfs_krb5i",e.get("security_flavor").kerberos_integrity),this.setItemValue("nfs_krb5p",e.get("security_flavor").kerberos_privacy),this.setSecurityText()},setSecurityText:function(){var e,t=[];!0===this.getItemValue("nfs_auth_sys")&&t.push("sys"),!0===this.getItemValue("nfs_krb5")&&t.push("krb5"),!0===this.getItemValue("nfs_krb5i")&&t.push("krb5i"),!0===this.getItemValue("nfs_krb5p")&&t.push("krb5p"),e=t.join(","),SYNO.SDS.AdminCenter.Share.NFSRuleDialog.CheckItemsMenu.superclass.setValue.call(this,e)},getItemValue:function(e){return this.menu.getComponent(e).checked},setItemValue:function(e,t){this.menu.getComponent(e).setChecked(t)},onRender:function(e,t){this.callParent(arguments),this.label&&this.label.addClass("syno-ux-item-label"),SYNO.ux.Utils.setFormItemIndent(this),SYNO.ux.Utils.setFormFieldWidth(this)},onDestroy:function(){this.keyNav.destroy()}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),SYNO.SDS.AdminCenter.Share.onClickNfsSetting=function(e){var t=Ext.getCmp(e);t.owner.close(),SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",Ext.apply(t.findAppWindow().openConfig||{},{fn:"SYNO.SDS.AdminCenter.FileService.Main",tab:"nfs"}))},Ext.define("SYNO.SDS.AdminCenter.Share.NFSGridPanel",{extend:"SYNO.ux.DDGridPanel",constructor:function(e){this.owner=e.owner,this.module=e.module,this.store=this.createStore(),this.colModel=this.createColModel(e),this.dataModified=0,this.actionGroup=this.createActionGroup(),this.blKerberosEnabled=e.blKerberosEnabled;var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"deactivate",function(){this.getEl().unmask()},this)},fillConfig:function(e){var t="";t=!0===this.owner.share.get("is_usb_share")?this.owner.share.get("vol_path"):"yes"===this._D("usbstation")?this.owner.share.get("vol_path")+"/@sharebin/"+this.owner.share.get("name"):this.owner.share.get("vol_path")+"/"+this.owner.share.get("name");var i={title:_T("nfs","nfs_privilege_setup"),cls:"without-dirty-red-grid",store:this.store,colModel:this.colModel,autoExpandColumn:"client",viewConfig:{markDirty:!1,ddGroup:"NFSRulesDD"},enableDragDrop:!0,enableColumnMove:!1,enableHdMenu:!1,monitorWindowResize:!0,selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{scope:this,selectionchange:this.chgNFSButtonStatus}}),tbar:{defaultType:"syno_button",items:[{xtype:"syno_button",text:_T("common","create"),itemId:"addBtn",scope:this,handler:this.addRule},this.actionGroup.getArray()]},bbar:{items:[{xtype:"tbtext",itemId:"mntpath",style:{lineHeight:"24px",paddingTop:"6px"},text:String.format('{0}{1}{2}',_T("nfs","nfs_mount_path"),_T("common","colon"),t,SYNO.SDS.Utils.SelectableCLS)}]},listeners:{scope:this,activate:this.onActivate,beforedestroy:this.onBeforeDestroy,rowcontextmenu:{scope:this,fn:this.onRowContextMenu},rowdblclick:{scope:this,fn:this.onRowDblClick},afterDrop:{scope:this,fn:this.onAfterDrag}}};return Ext.apply(i,e),i},createStore:function(){return new SYNO.API.JsonStore({api:"SYNO.Core.FileServ.NFS.SharePrivilege",method:"load",version:"1",baseParams:{share_name:this.owner.share.get("name")},appWindow:this.findAppWindow(),root:"rule",idProperty:"client",fields:["client","privilege","root_squash","async","insecure","crossmnt","security_flavor"],autoDestroy:!0,listeners:{scope:this,beforeload:this.onBeforeLoad,load:this.onLoad,exception:this.onException,add:this.onStoreAdd,update:this.onStoreUpdate,remove:this.onStoreRemove}})},createColModel:function(e){var t=Ext.isDefined(e.owner.share.get("force_readonly_reason"))&&""!==e.owner.share.get("force_readonly_reason"),i=function(e){return!0===e?_T("nfs","nfs_nonprivileged_port_allow"):_T("nfs","nfs_nonprivileged_port_deny")};return new Ext.grid.ColumnModel({columns:[{id:"client",header:_T("nfs","nfs_host_position"),dataIndex:"client",width:100,renderer:Ext.util.Format.htmlEncode},{id:"privilege",header:_T("nfs","nfs_access_right"),dataIndex:"privilege",renderer:function(e){return t||"ro"===e?_T("nfs","nfs_read_only"):"rw"===e?_T("nfs","nfs_read_write"):""},align:"center",width:120},{id:"root_squash",header:_T("nfs","nfs_mapping"),dataIndex:"root_squash",renderer:function(e){var t="";switch(e){case"all_admin":t=_T("nfs","nfs_mapping_all");break;case"all_guest":t=_T("nfs","nfs_mapping_all_guest");break;case"root":t=_T("nfs","nfs_mapping_no");break;case"admin":t=String.format(_T("nfs","nfs_mapping_yes"),"admin");break;case"guest":t=String.format(_T("nfs","nfs_mapping_yes"),"guest")}return'
'+t+"
"},align:"center",width:120},{id:"async",header:_T("nfs","nfs_async"),dataIndex:"async",renderer:function(e){return!0===e?_T("common","yes"):_T("common","no")},align:"center",width:100},{name:"insecure",header:_T("nfs","nfs_insecure_port"),dataIndex:"insecure",renderer:i,align:"center",width:100},{name:"crossmnt",header:_T("nfs","nfs_crossmnt"),dataIndex:"crossmnt",renderer:i,align:"center",width:100},{name:"security_flavor",header:_T("nfs","nfs_security"),dataIndex:"security_flavor",renderer:function(e){var t=[];return e.sys&&t.push("sys"),e.kerberos&&t.push("krb5"),e.kerberos_integrity&&t.push("krb5i"),e.kerberos_privacy&&t.push("krb5p"),t.join()},hidden:!0,width:150}]})},createActionGroup:function(){var e=new Ext.Action({text:_T("common","alt_edit"),itemId:"editRule",scope:this,handler:this.editRule}),t=new Ext.Action({text:_T("common","delete"),itemId:"delRule",scope:this,handler:this.delRule});return new SYNO.ux.Utils.ActionGroup([e,t])},onActivate:function(){if(!this.blNfsEnabled){this.gotoNfsSettingId||(this.gotoNfsSettingId=Ext.id());var e=_T("share","nfs_not_enabled"),t=''+_T("nfs","nfs_title")+"",i=this.getTopToolbar();this.mask(String.format(e,t),"syno-ux-mask-info"),i.getComponent("addBtn").btnEl.set({tabIndex:-1}),i.getComponent("editRule").btnEl.set({tabIndex:-1}),i.getComponent("delRule").btnEl.set({tabIndex:-1});var s=Ext.get(this.gotoNfsSettingId);Ext.isObject(s)&&s.on("click",this.onClickNfsSetting,this)}},onBeforeDestroy:function(e){var t=Ext.get(this.gotoNfsSettingId);Ext.isObject(t)&&t.un("click",this.onClickNfsSetting,this)},onBeforeLoad:function(e,t){return this.owner.setStatusBusy({text:_T("common","msg_waiting")}),!0},onLoad:function(e,t,i){this.blKerberosSupport&&this.colModel.setHidden(5,!1),t.length>0&&this.getSelectionModel().selectFirstRow(),this.storeDataCached(e),this.owner.clearStatusBusy(),this.chgNFSButtonStatus()},storeDataCached:function(e){var t=0;this.cachedStoreData=[],e.each(function(e){this.cachedStoreData.push(JSON.stringify(e.data)),t++},this),this.cachedStoreData.size=t},storeDataCompare:function(e){if(this.dataModified=0,this.cachedStoreData.size==e.data.length){var t=0;e.each(function(e){this.cachedStoreData[t++]==JSON.stringify(e.data)||(this.dataModified=1)},this)}else this.dataModified=1},onException:function(e,t,i,s,n,o){var a=_T("nfs","nfs_fail_load_rules");this.owner.clearStatusBusy(),this.owner.getMsgBox().alert(this.title,a,this.close,this)},onStoreAdd:function(e,t,i){this.storeDataCompare(e)},onStoreUpdate:function(e,t,i){this.storeDataCompare(e)},onStoreRemove:function(e,t,i){this.storeDataCompare(e)},chgNFSButtonStatus:function(){var e=this.getSelectionModel().getSelections().length,t=this.actionGroup;1!=e?t.disable("editRule"):t.enable("editRule"),0>=e?t.disable("delRule"):t.enable("delRule")},addRule:function(){new SYNO.SDS.AdminCenter.Share.NFSRuleDialog({owner:this.owner,module:this.module,ownerGrid:this,blKerberosSupport:this.blKerberosSupport,blKerberosEnabled:this.blKerberosEnabled}).open()},editRule:function(){var e=this.getSelectionModel().getSelected();new SYNO.SDS.AdminCenter.Share.NFSRuleDialog({owner:this.owner,module:this.module,ownerGrid:this,blKerberosSupport:this.blKerberosSupport,blKerberosEnabled:this.blKerberosEnabled,record:e}).open()},delRule:function(){var e=this.getSelectionModel().getSelections();Ext.each(e,function(e,t,i){this.store.remove(e)},this),this.chgNFSButtonStatus()},onMoveRow:function(e){var t=this.store,i=this.getSelectionModel().getSelected(),s=t.indexOf(i),n=s+(e?-1:1);n<0||n>t.getCount()-1?this.getView().focusRow(s):(t.remove(i),t.insert(n,i),this.getSelectionModel().selectRecords([i]),this.getView().focusRow(n))},onRowContextMenu:function(e,t,i){var s=new SYNO.ux.Menu({autoDestroy:!0,items:[this.actionGroup.getArray(),{text:_T("common","up"),scope:this,handler:function(){this.onMoveRow(!0)}},{text:_T("common","down"),scope:this,handler:function(){this.onMoveRow(!1)}}]}),n=e.getSelectionModel();n.selectRow(t,n.isSelected(t)),s.showAt(i.getXY()),i.preventDefault()},onRowDblClick:function(e,t,i){var s=e.getStore().getAt(t);this.editRule(s)},onAfterDrag:function(){this.storeDataCompare(this.store)},enumNFSRules:function(){var e=[];return this.store.each(function(t){e.push({client:t.get("client"),privilege:t.get("privilege"),root_squash:t.get("root_squash"),async:t.get("async"),insecure:t.get("insecure"),crossmnt:t.get("crossmnt"),security_flavor:t.get("security_flavor")})},this),e},hasKerboerosSecurity:function(){var e=!1,t={};return this.store.each(function(i){!0!==(t=i.get("security_flavor")).kerberos&&!0!==t.kerberos_integrity&&!0!==t.kerberos_privacy||(e=!0)},this),e},onRuleCheck:function(){var e=!0;return this.owner.getIsSnapshotBrowsing()&&this.store.each(function(t){t.get("crossmnt")||(e=!1)},this),e},applyCrossMnt:function(){this.store.each(function(e){e.set("crossmnt",!0)})},onClickNfsSetting:function(e){e.preventDefault(),SYNO.SDS.AdminCenter.Share.onClickNfsSetting(this.getId())},getWebAPI:function(){return 0===this.dataModified?[]:[{api:"SYNO.Core.FileServ.NFS.SharePrivilege",method:"save",version:"1",params:{share_name:this.owner.share.get("name"),rule:this.enumNFSRules()}}]}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.MessageComboBox",{extend:"SYNO.ux.ComboBox",listClass:"syno-ux-combobox-list syno-ux-message-combobox-list",constructor:function(e){var t,i;this.displayField=e.displayField||"display",this.descriptionField=e.descriptionField||"description",this.tooltip=e.tooltip||"tooltip",this.tooltip&&(i='ext:qtip="{'+this.tooltip+':htmlEncode}"'),t={tpl:new Ext.XTemplate('',"
',"
{'+this.displayField+":htmlEncode}
","
{'+this.descriptionField+":htmlEncode}
","
","
")},this.callParent([Ext.apply(t,e)])}}),Ext.reg("syno_share_combobox",SYNO.SDS.AdminCenter.Share.MessageComboBox),Ext.define("SYNO.SDS.AdminCenter.Share.Dialog",{extend:"SYNO.SDS.ModalWindow",moveShareMsg:_T("share","init_status"),constructor:function(e){this.module=e.module,this.owner=e.owner,this.share=e.share,this.mode=e.mode,this.supportShareSnapshot="yes"===this._D("support_share_snapshot","no"),this.supportShareQuota="yes"===this._D("support_share_quota","no"),this.share&&this.share.get("is_cluster_share")&&(this.supportShareSnapshot=!1,this.supportShareQuota=!1),this.snapshot=e.snapshot,this.blKeyManagerEnabled=e.blKeyManagerEnabled,this.rgQuotaUnit=[["TB","TB"],["GB","GB"],["MB","MB"]],this.defineGrid();var t=this.fillTabPanelConfig(e);this.callParent([t]),this.panel=this.getComponent("tab"),this.shareTab=this.panel.getComponent("shareForm"),this.encryptTab=this.panel.getComponent("encryptForm"),this.advancedTab=this.panel.getComponent("advancedForm"),this.gridPanel=this.panel.getComponent("sharegrid"),this.formPanel=this.panel.getComponent("advperm"),this.shareForm=this.shareTab.getForm(),this.encryptForm=this.encryptTab.getForm(),this.advancedForm=this.advancedTab.getForm(),SYNO.ux.AddTip(this.shareForm.findField("hide_unreadable").getEl(),_T("share","tip_hide_nonprivileged_folder")),this.supportShareSnapshot&&(SYNO.ux.AddTip(this.advancedTab.getForm().findField("enable_share_cow").getEl(),_T("share","share_integrity_protection_tip")),"yes"===this._D("support_online_compr_switch","no")?SYNO.ux.AddTip(this.advancedForm.findField("enable_share_compress").getEl(),_T("share","share_compress_tip")):SYNO.ux.AddTip(this.advancedForm.findField("enable_share_compress").getEl(),_T("share","enable_share_compress_help"))),this.share&&"homes"===this.share.get("name").toLowerCase()&&SYNO.ux.AddTip(this.shareForm.findField("enable_recycle_bin").getEl(),_T("share","enable_homes_recycle_tip")),this.loadData(),"yes"===this._D("supportNFS","no")&&this._S("is_admin")&&(this.nfsPanel=this.panel.getComponent("nfsgrid"),this.nfsPanel&&this.nfsPanel.getStore()&&this.nfsPanel.getStore().load()),this.mon(this,"afterlayout",function(e,t){this.blKeyManagerEnabled?(this.enableGroupDummy1=new SYNO.ux.Utils.EnableCheckGroup(this.encryptForm,"encryption",["enc_passwd","enc_passwd2","add_to_keymanager"],[]),this.ckg_keymanager=new SYNO.ux.Utils.EnableCheckGroup(this.encryptForm,"add_to_keymanager",["keymanager_cypher","keymanager_passphrase"],[])):this.enableGroupDummy1=new SYNO.ux.Utils.EnableCheckGroup(this.encryptForm,"encryption",["enc_passwd","enc_passwd2","add_to_keymanager"],[]),this.enableGroupDummy2=new SYNO.ux.Utils.EnableCheckGroup(this.shareForm,"enable_recycle_bin",["recycle_bin_admin_only"],[],{disable_group:!0}),this.startTabId&&this.panel.setActiveTab(this.startTabId)},this,{single:!0}),this.mon(this,"deactivate",this.deactivate,this),this.mon(this.shareForm.findField("vol_path"),"collapse",this.onLocationChange,this)},fillTabPanelConfig:function(e){var t=this.fillShareFormConfig(e),i=this.fillEncryptFormConfig(e),s=this.fillAdvancedFormConfig(e),n="";"clone"===this.mode?(n=_T("share","share_clone"),n=String.format(n,this.share.get("name"))):"create"===this.mode?n=_T("share","share_add"):(n=_T("share","share_edit_title"),n=String.format(n,this.share.get("name")));var o=[t,i,s];if("edit"===this.mode){var a=this.share.get("encryption"),r=!this.share.get("is_aclmode")&&"homes"===this.share.get("name").toLowerCase();o.push(new SYNO.SDS.Share.PermissionGrid({module:this.module,owner:this,itemId:"sharegrid",disabled:(1===a||this.isClusterShareDisable())&&!0===this.share.get("is_aclmode"),hidden:1===a&&!0===this.share.get("is_aclmode"),hideCustomColumn:!SYNO.SDS.ControlPanel.Share.isCustomizable(this.share.data)})),o.push(new SYNO.SDS.Share.AdvanceForm({module:this.module,owner:this,disabled:(1===a||this.isClusterShareDisable())&&!0===this.share.get("is_aclmode")||r,itemId:"advperm"})),"yes"===this._D("supportNFS","no")&&this._S("is_admin")&&o.push(new SYNO.SDS.AdminCenter.Share.NFSGridPanel({module:this.module,owner:this,itemId:"nfsgrid",disabled:1===a||2===a&&0===e.blNfsEncryptShareSupport||this.isDisableNFS()||this._S("demo_mode"),blNfsEnabled:e.blNfsEnabled,blKerberosSupport:e.blKerberosSupport,blKerberosEnabled:e.blKerberosEnabled}))}var l=new SYNO.SDS.Utils.TabPanel({itemId:"tab",activeTab:0,deferredRender:!1,useDefaultBtn:!1,items:o}),d={title:n,width:860,height:590,layout:"fit",buttons:[{xtype:"syno_button",text:_T("common","cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",text:_T("common","save"),btnStyle:"blue",scope:this,handler:this.onApply}],closeAction:"onCancel",items:l};return Ext.apply(d,e),d},onApply:function(){"edit"===this.mode?this.editHandler():this.createHandler()},defineGrid:function(){SYNO.SDS.Share.PermissionGrid||Ext.define("SYNO.SDS.Share.PermissionGrid",{extend:"SYNO.SDS.Share.ShareGrid",constructor:function(e){var t=e.hideCustomColumn;"SYNO.SDS.CMS.Application"===e.module.appWin.getOpenConfig("className")&&(t=t||e.module.appWin._S("version")<4475),e.module.appWin._S("is_admin")||(t=!0),this.colCu=new SYNO.SDS.Share.CustomColumn({module:e.module,owner:e.owner,ownerGrid:this,dataIndex:"is_custom",id:"is_custom",hidden:t,applyCallback:function(){this.store.load()},applyTarget:this}),e.colCu=this.colCu,e.isShowPreview=!0,this.callParent([e])}})},getEncWarnMsgList:function(){var e=[_T("share","share_encryption_warning_desc"),'','",'",'","
1.',_T("share","share_encryption_warning_savekey"),"
2.',_T("share","share_encryption_warning_perf"),"
3.',_T("share","share_encryption_warning_length"),"
","
",_T("common","ask_cont")];return"yes"===this._D("supportNFS","no")&&this._S("is_admin")&&(e=[_T("share","share_encryption_warning_desc"),'','",'",'","
1.',_T("share","share_encryption_warning_savekey"),"
2.',_T("share","share_encryption_warning_perf"),"
3.',_T("share","share_encryption_warning_length"),"
","
",_T("common","ask_cont")]),e},confirm_encryption:function(e,t){this.getMsgBox().confirm(_T("tree","leaf_sharefolder"),_T("share","share_encryption_key_download"),function(i,s,n){"yes"===i&&t.call(this,e)},this,{yes:{text:_T("common","ok"),btnStyle:"blue"}});var i=this.getMsgBox().getDialog();i.setWidth(600),i.setPosition([this.getPosition()[0]+(this.getWidth()-i.getWidth())/2,this.getPosition()[1]+(this.getHeight()-i.getHeight())/2-20])},createHandler:function(){var e=this.shareForm.findField("name").getValue(),t=this.getFsType("vol_path"),i=this.encryptForm.findField("encryption").getValue(),s=this.encryptForm.findField("add_to_keymanager").getValue(),n=this.encryptForm.findField("keymanager_passphrase").getValue(),o={};return this.shareForm.isValid()?this.isShowBtrfsOption()&&!this.advancedForm.isValid()?(this.panel.setActiveTab("advancedForm"),void this.setStatusError({text:_T("error","error_bad_field"),clear:!0})):void("yes"!==this._D("usbstation","no")||"web"!==e.toLowerCase()||"ext4"===t?(o.name=e,o.shareinfo=this.getParamShareForm(),o.shareinfo.name_org=this.shareForm.findField("name_org").getValue(),i?s?(this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share.KeyManager.Store",method:"verify",params:{passphrase:n},encryption:["passphrase"],version:1,scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),e)this.confirm_encryption(o,this.submitCreateShareInfo);else{var s=SYNO.API.Response.GetFirstError(t),n=SYNO.API.Errors.core[s.code]||_T("keymanager","error_invalid_passphrase");this.getMsgBox().alert("warning_msg",n)}}})):this.confirm_encryption(o,this.submitCreateShareInfo):this.submitCreateShareInfo(o)):this.getMsgBox().alert(this.title,String.format(_T("service","no_ext4_external_devices"),e))):(this.panel.setActiveTab("shareForm"),void this.setStatusError({text:_T("error","error_bad_field"),clear:!0}))},getParamShareForm:function(){var e={},t=this.advancedForm;return Ext.each(["name","vol_path","desc"],function(t,i,s){e[t]=this.shareForm.findField(t).getValue()},this),Ext.each(["hidden","enable_recycle_bin","recycle_bin_admin_only","hide_unreadable"],function(t,i,s){this.shareForm.findField(t).isDirty()&&(e[t]=this.shareForm.findField(t).getValue())},this),Ext.each(["encryption","enc_passwd"],function(t,i,s){this.encryptForm.findField(t).isDirty()&&(e[t]=this.encryptForm.findField(t).getValue())},this),this.isShowBtrfsOption()&&(this.isBtrfsShare("vol_path")&&(e.enable_share_cow=t.findField("enable_share_cow").getValue(),e.enable_share_compress=t.findField("enable_share_compress").getValue()),this.supportShareQuota&&(t.findField("enable_share_quota").isDirty()||t.findField("quota_unit").isDirty()||t.findField("quota_value").isDirty())&&(t.findField("enable_share_quota").getValue()?e.share_quota=this.getQuotaInMB():e.share_quota="0")),e},submitCreateShareInfo:function(e){"clone"===this.mode&&this.snapshot&&(e.snapshot=this.snapshot),this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share",method:this.mode,params:e,encryption:["shareinfo"],version:1,scope:this,callback:function(t,i,s){this.clearStatusBusy();var n="";if(!t){var o=SYNO.API.Response.GetFirstError(i);if(n=SYNO.API.Errors.core[o.code]||_T("common","error_system"),3309===o.code)n=String.format(n,this._D("maxshares"));else if(3343===o.code&&o.errors&&o.errors.hard){var a="clone"===this.mode?o.errors.hard[e.shareinfo.name_org]:o.errors.hard[e.name];n=_T("volume","hard_check_fail"),n+="
"+SYNO.SDS.Utils.GetFeasibilityCheckMsgJoin(a)+""}return this.getMsgBox().alert("warning_msg",n),!1}if(e.shareinfo.name=i.name,e.shareinfo.encryption&&this.exportEncryptionKey(e.name,e.shareinfo.enc_passwd),!this.encryptForm.findField("add_to_keymanager").getValue())return this.updateAndNotify(e),!0;this.initKeyManagerRequest(),this.addKeyToKeyManager(this.updateAndNotify,e)}})},addKeyToKeyManager:function(e,t){var i=this.KeyManager.name,s=this.KeyManager.password,n=this.KeyManager.cypher,o=this.KeyManager.passphrase;this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share.KeyManager.Key",method:"add",params:{share_name:i,share_cypher:n,share_password:s,passphrase:o},encryption:["share_password","passphrase"],version:1,scope:this,callback:function(i,s,n){if(this.clearStatusBusy(),!i){var o=SYNO.API.Response.GetFirstError(s),a=SYNO.API.Errors.core[o.code]||_T("common","error_system");return this.getMsgBox().alert("warning_msg",a),!1}e.call(this,t)}})},updateAndNotify:function(e){this.module.getPanel().fireEvent("sharefolderchanged",e.shareinfo.name),SYNO.SDS.StatusNotifier.fireEvent("sharefolderchanged","permission"),this.newShareInfo=Ext.apply({is_aclmode:!0,encryption:!0===e.shareinfo.encryption?2:0},e.shareinfo),"create"===this.mode?this.loadPermissionData(this.getCreateResult()):this.close()},getCreateResult:function(){return Ext.isObject(this.newShareInfo)?new Ext.data.Record(this.newShareInfo):null},onCancel:function(){this.isAnyFormDirty()?this.confirmLostChangePromise({dontSave:function(){this.close()},cancel:function(){return!1},save:this.onApply},this):this.close()},fillShareFormConfig:function(e){var t=new Ext.data.JsonStore({idProperty:"value",fields:["value","display","size_total_mb","vol_name","desc","tooltip","volume_quota_status"],data:[[0,0]]}),i={title:_T("share","share_subject"),itemId:"shareForm",border:!1,frame:!1,autoScroll:!0,header:!1,height:350,trackResetOnLoad:!0,items:[{validationEvent:"keyup",xtype:"syno_textfield",name:"name",maxlength:32,fieldLabel:_T("share","share_name")+' '+_T("common","star")+"",labelHtmlEncode:!1,allowBlank:!1,blankText:_T("share","error_noname"),width:350,vtype:"sharename"},{xtype:"hidden",name:"name_org"},{xtype:"syno_textfield",name:"desc",maxlength:64,width:350,fieldLabel:_T("share","share_comment")},{xtype:"syno_share_combobox",name:"vol_path",fieldLabel:_T("volume","volume_share_position"),store:t,displayField:"display",descriptionField:"desc",tooltip:"tooltip",valueField:"value",disabled:"clone"===this.mode,allowBlank:!1,width:350},{xtype:"hidden",name:"vol_orig"},{xtype:"syno_displayfield",name:"my_vol_status",fieldLabel:_T("volume","volume_share_position")},{xtype:"syno_checkbox",name:"hidden",boxLabel:_T("share","share_hide"),hidden:"no"===this._D("support_share_encryption","no")},{xtype:"syno_checkbox",name:"hide_unreadable",boxLabel:_T("share","share_hide_unreadable"),hideLabel:!0},{xtype:"syno_checkbox",name:"enable_recycle_bin",hidden:!this._S("is_admin"),boxLabel:_T("share","share_enable_recycle_bin"),hideLabel:!0},{xtype:"syno_checkbox",name:"recycle_bin_admin_only",hidden:!this._S("is_admin"),boxLabel:_T("network","cifs_safe_recycle_bin"),width:500,indent:1},{xtype:"syno_button",indent:1,width:"auto",id:this.cleanBinBtnId=Ext.id(),text:_T("share","share_clean_recycle_bin"),scope:this,handler:this.onCleanBinBtnClick,hidden:"edit"!==this.mode||!this._S("is_admin")},{xtype:"syno_displayfield",indent:1,tabIndex:-1,htmlEncode:!1,hidden:!this._S("is_admin"),value:''+_T("common","note")+_T("common","colon")+' '+_T("network","cifs_recycle_bin_help_link")+"",listeners:{afterrender:SYNO.SDS.AdminCenter.Share.Utils.ShowHelpCallback(SYNO.SDS.AdminCenter.TaskScheduler.Main.prototype.getHelpParam()),scope:this}},{xtype:"syno_displayfield",tabIndex:-1,htmlEncode:!1,value:[''+_T("common","star")+" "+_T("firewall","firewall_field_blank_alert")]}]};return Ext.apply(i,e),new SYNO.SDS.Utils.FormPanel(i)},isEncrytionHidden:function(){return!this._S("is_admin")||"clone"===this.mode||"no"===this._D("support_share_encryption","no")},fillEncryptFormConfig:function(e){var t=[{xtype:"syno_checkbox",name:"encryption",boxLabel:_T("share","share_encryption_enable"),listeners:{scope:this,check:function(e,t){if(this.isShowBtrfsOption()){var i=this.advancedForm.findField("enable_share_compress");t&&i.getValue()&&this.exclusiveChecking(e)}}}},{xtype:"syno_textfield",textType:"password",name:"enc_passwd",minLength:8,maxLength:64,width:180,allowBlank:!1,fieldLabel:_T("share","share_encryption_key"),validator:function(e){return-1===e.indexOf("=")&&-1===e.indexOf(",")&&-1===e.indexOf(":")||_T("share","encryption_password_invalid")},disabled:!0,indent:1},{xtype:"syno_textfield",textType:"password_confirm",name:"enc_passwd2",confirmFor:"enc_passwd",confirmFailedText:_T("share","share_encryption_key_confirm_mismatch"),maxlength:64,width:180,allowBlank:!1,fieldLabel:_T("share","share_encryption_key_confirm"),disabled:!0,indent:1},{xtype:"syno_displayfield",name:"no_encryption_reason",hidden:!0,htmlEncode:!1,value:''+_T("common","note")+_T("common","colon")+' '+String.format(_T("share","no_encryption_reason"),_T("common","here"))+"",listeners:{afterrender:SYNO.SDS.AdminCenter.Share.Utils.ShowHelpCallback("AdminCenter/file_share_create.html"),scope:this}}],i=[{xtype:"syno_checkbox",name:"add_to_keymanager",boxLabel:_T("share","share_encryption_add_to_keymanager"),indent:1,disabled:!0,listeners:{check:function(e,t){t&&!this.blKeyManagerEnabled&&this.getMsgBox().confirm(_T("keymanager","init_dialog_title"),_T("keymanager","init_dialog_msg"),function(t){if("yes"===t){var i=new SYNO.SDS.AdminCenter.Share.InitStore({share_module:this.module.panel,share_dialog:this,module:this.module,owner:this.owner,shares:this.module.panel.store.data.items});i.open(),this.mon(i,"close",function(){this.blKeyManagerEnabled||e.setValue(!1)},this)}else e.setValue(!1)},this,{no:{text:_T("common","no")},yes:{text:_T("keymanager","init_dialog_confirm"),btnStyle:"blue"}})},scope:this}},{xtype:"syno_textfield",name:"keymanager_passphrase",fieldLabel:_T("keymanager","common_passphrase"),textType:"password",minLength:8,maxLength:64,width:180,allowBlank:!1,indent:2,disabled:!0,hidden:!0},{xtype:"syno_combobox",name:"keymanager_cypher",fieldLabel:_T("keymanager","common_cypher"),displayField:"display",valueField:"value",store:new Ext.data.ArrayStore({fields:["value","display"],data:[[0,_T("keymanager","common_passphrase")],[1,_T("keymanager","common_machinekey")]]}),value:1,indent:2,disabled:!0,hidden:!0}],s=[{xtype:"syno_checkbox",name:"enc_auto_mount",boxLabel:_T("share","share_encryption_autodecrypt"),indent:1,disable:!0,hidden:!0}],n=[{xtype:"syno_displayfield",name:"encryption_desc",htmlEncode:!1,indent:1,style:{marginTop:"12px"},value:''+_T("common","note")+_T("common","colon")+'
  • '+_T("share","share_encryption_warning_perf")+"
  • "+_T("share","share_encryption_warning_length")+"
"}],o={title:_T("share","share_tab_encryption"),itemId:"encryptForm",border:!1,frame:!1,autoScroll:!0,header:!1,height:350,trackResetOnLoad:!0,items:[t,i,s,n],owner:this};return Ext.apply(o,e),new SYNO.SDS.Utils.FormPanel(o)},updateKeyManagerUI:function(){var e=this.encryptForm,t=e.findField("add_to_keymanager"),i=e.findField("keymanager_passphrase"),s=e.findField("keymanager_cypher"),n=e.findField("enc_auto_mount");"edit"===this.mode&&this.share.get("enc_auto_mount")?(t.hide(),i.hide(),i.setValue("2PassValidation"),s.hide(),n.show()):"edit"===this.mode&&0!==this.share.get("encryption")?(t.hide(),i.hide(),i.setValue("2PassValidation"),s.hide(),n.hide()):this.blKeyManagerEnabled?(SYNO.SDS.AdminCenter.Share.LocalStore===this.keyManagerLocation?(t.show(),i.hide(),i.setValue("2PassValidation"),s.hide()):(t.show(),i.show(),i.setValue(""),s.show()),n.hide()):(t.hide(),i.hide(),i.setValue("2PassValidation"),s.hide(),n.hide()),!this._S("is_admin")&&SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main")&&t.hide()},fillAdvancedFormConfig:function(e){var t=this,i={title:_T("share","share_advance_privileges"),itemId:"advancedForm",border:!1,frame:!1,autoScroll:!0,header:!1,height:350,trackResetOnLoad:!0,items:[{xtype:"syno_checkbox",name:"enable_snapshot_browsing",hidden:!0},{xtype:"syno_checkbox",name:"enable_share_cow",hidden:!t.supportShareSnapshot,checked:!1,boxLabel:_T("share","share_integrity_protection_enable"),listeners:{enable:function(){t.restoreValue("enable_share_cow"),t.advancedForm.findField("enable_share_cow_desc").enable()},disable:function(){let e=t.advancedForm.findField("enable_share_cow").checked;t.storeValue("enable_share_cow"),!1===e&&t.advancedForm.findField("enable_share_cow_desc").disable()},check:function(e,i){var s=t.shareForm.findField("vol_path").getValue(),n=t.volumeAttrMap[s],o=t.advancedForm;i&&"generic"===n?o.findField("enable_share_compress").enable():o.findField("enable_share_compress").disable()}}},{xtype:"syno_displayfield",name:"enable_share_cow_desc",hidden:!t.supportShareSnapshot,indent:1,value:_T("share","share_integrity_protection_enable_desc")},{xtype:"syno_checkbox",name:"enable_share_compress",hidden:!t.supportShareSnapshot,indent:1,boxLabel:_T("share","share_compress_enable"),listeners:{scope:t,enable:function(){t.restoreValue("enable_share_compress"),t.advancedForm.findField("enable_share_compr_desc").enable()},disable:function(){t.storeValue("enable_share_compress"),t.advancedForm.findField("enable_share_compr_desc").disable()},check:function(e,i){var s=t.encryptForm.findField("encryption");i&&s.getValue()&&t.exclusiveChecking(e)}}},{xtype:"syno_displayfield",name:"enable_share_compr_desc",hidden:!t.supportShareSnapshot||"edit"!==t.mode,indent:2,value:_T("share","share_compress_edit_desc")},{xtype:"syno_compositefield",hideLabel:!0,hidden:!t.supportShareQuota,items:[{xtype:"syno_checkbox",name:"enable_share_quota",boxLabel:_T("share","share_quota_enable"),listeners:{scope:t,check:{fn:t.onEnableShareQuota},disable:function(){var e=t.advancedForm;t.storeValue("enable_share_quota"),e.findField("quota_unit").disable(),e.findField("quota_value").disable()},enable:function(){var e=t.advancedForm;t.restoreValue("enable_share_quota"),e.findField("enable_share_quota").getValue()&&(e.findField("quota_value").enable(),e.findField("quota_unit").enable())}}},{xtype:"syno_displayfield",htmlEncode:!1,name:"share_quota_used"},{xtype:"syno_displayfield",name:"share_quota_status",hidden:!0}],fieldLabel:_T("share","share_quota_enable")},{xtype:"syno_compositefield",indent:1,hideLabel:!0,hidden:!t.supportShareQuota,items:[{xtype:"syno_numberfield",width:90,disabled:!0,value:0,name:"quota_value",vtype:"number",listeners:{scope:t,disable:function(){t.storeValue("quota_value")},enable:function(){t.restoreValue("quota_value")}},validator:function(e){var i=t.advancedForm,s=t.shareForm.findField("vol_path").getValue(),n=t.shareForm.findField("vol_path").getStore().getById(s).data,o=i.findField("quota_unit").getValue(),a=i.findField("quota_value").getValue();return"GB"===o?a*=1024:"TB"===o&&(a*=1048576),!(n.size_total_mb<=a)||String.format(_T("user","user_quota_limit_max_vol"),n.vol_name,(n.size_total_mb/1024).toFixed(2))}},{xtype:"syno_combobox",name:"quota_unit",width:60,displayField:"display",valueField:"value",disabled:!0,value:t.rgQuotaUnit[1][0],store:new Ext.data.ArrayStore({fields:["value","display"],data:t.rgQuotaUnit})}]},{xtype:"syno_displayfield",name:"share_cow_desc",htmlEncode:!1,indent:1,style:{marginTop:"18px"},value:''+_T("common","note")+_T("common","colon")+" "+_T("share","share_cow_desc1")+'
  • '+_T("share","share_cow_desc2")+"
  • "+_T("share","share_cow_desc3")+"
  • "+("create"===t.mode?"
  • "+_T("share","share_cow_desc5")+"
  • ":"")+"
"}]};return Ext.apply(i,e),new SYNO.SDS.Utils.FormPanel(i)},loadData:function(){var e=[{api:"SYNO.Core.Storage.Volume",method:"list",params:{limit:-1,offset:0,location:""===this._D("usbstation")?"internal":"external",option:"include_cold_storage"},version:1}];if("create"!==this.mode&&("yes"===this._D("usbstation")&&(this.panel.hideTabStripItem("advancedForm"),this.panel.hideTabStripItem("advperm")),this.isEncrytionHidden()&&this.panel.hideTabStripItem("encryptForm"),this.isShowBtrfsOption()||this.panel.hideTabStripItem("advancedForm")),"create"!==this.mode){if(!this.share)return this.setStatusError({text:_T("common","error_system"),clear:!0}),!1;var t=[];"clone"!==this.mode&&(t=["hidden","recyclebin","advance_setting","encryption","is_cluster_share","is_cold_storage_share"],this.supportShareSnapshot&&(t=t.concat(["enable_snapshot_browsing"])),this.supportShareQuota&&(t=t.concat(["share_quota"]))),t=t.concat(["enable_share_cow","enable_share_compress"]),e=e.concat([{api:"SYNO.Core.Share",method:"get",params:{name:this.share.get("name"),additional:t},version:1}])}this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({params:{},compound:{stopwhenerror:!0,params:e},timeout:36e4,scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),!0===t.isTimeout||!0===t.has_fail){var s=_T("common","error_system");return t.result[1].error&&(s=SYNO.API.Errors.core[t.result[1].error.code]||_T("common","error_system")),this.getMsgBox().alert(this.title,s,function(){this.close()},this),this.setStatusError({text:s,clear:!0}),!1}if(SYNO.ux.Utils.displayFormField(this.shareForm,"my_vol_status",!1),"clone"===this.mode)this.setCloneHandler(t);else if("create"===this.mode){if(!1===this.pushVolumeList(null,this.getVolumeList(t),null))return!1;this.shareForm.findField("enable_recycle_bin").setValue(!0),this.shareForm.findField("recycle_bin_admin_only").setValue(!0)}else this.setEditHandler(t)&&SYNO.SDS.Share.PermissionDialog.prototype.loadPermissionData.call(this,this.share);return!1!==this.hasWritableVol||"clone"!==this.mode&&"create"!==this.mode?(this.onLocationChange(this.shareForm.findField("vol_path")),!0):(this.getMsgBox().alert(this.title,_T("share","create_wizard_no_volume"),function(){this.close()},this),!1)}})},getVolumeList:function(e){return SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Storage.Volume","list","volumes")},launchStoargeManager:async function(){let e="",t=await SYNO.SDS.AdminCenter.Share.GetPoolList(this);e="yes"===this._D("usbstation","no")?_T("volume","volume_share_noexternal"):0===t.length?_T("volume","volume_share_pool_create"):_T("volume","volume_share_volume_create"),this.getMsgBox().alert(this.title,e,function(){if("SYNO.SDS.CMS.Application"!==this.module.appWin.findAppWindow().getOpenConfig("className")){var e=_T("volume","create_volume"),i="volume";0===t.length&&(e=_T("volume","volume_raid_creation_title"),i="both"),SYNO.SDS.AppLaunch("SYNO.SDS.StorageManager.Instance",{fn:"SYNO.SDS.StorageManager.Pool.Main",vueWizard:"CreateWizard",modalParam:{width:820,height:560,title:e,mode:i}})}this.close()},this)},isUsbStation:function(){return"yes"===this._D("usbstation","no")},checkVolumes:function(e,t){return!!(Ext.isArray(e)&&e.length>0)||(!(this.isUsbStation()||!Ext.isObject(t)||!t.is_usb_share)||(this.launchStoargeManager(),!1))},pushVolumeList:function(e,t,i){var s=this.shareForm.findField("vol_path").getStore(),n=Ext.isObject(i)?i.name.toLowerCase():"",o=Ext.isObject(i)&&0!==i.encryption;if(!this.checkVolumes(t,i))return!1;this.volumeFsMap={},this.volumeAttrMap={},this.dedupedVolume=[],this.hasWritableVol=!1;var a=[],r=!1;if(Ext.each(t,function(t,i,s){if(this.volumeFsMap[t.volume_path]=t.fs_type,this.volumeAttrMap[t.volume_path]=t.volume_attribute,!0===t.deduped&&this.dedupedVolume.push(t.volume_path),e===t.volume_path&&t.fs_type,t.readonly){if(t.volume_path===e)return this.getMsgBox().alert(this.title,_T("error","error_volume_ro"),function(){this.close()},this),r=!0,!1}else{if("yes"===this._D("usbstation","no")){if(o&&"ext3"!==t.fs_type&&"ext4"!==t.fs_type)return;if(("homes"===n||"web"==n)&&"ext4"!==t.fs_type)return}var l,d,c,h;h="btrfs"===t.fs_type?"generic"===t.volume_attribute?String.format("{0}",_T("volume","volume_add_fs_btrfs_type")):String.format("{0}",_T("volume","volume_add_fs_btrfs_peta_type")):String.format("{0}",t.fs_type),l=String.format("{0}{1} {2}",SYNO.SDS.Utils.StorageUtils.VolumeNameRenderer(t),_T("common","colon"),h),d=String.format("{0}{1} {2}",_T("volume","volume_freesize"),_T("common","colon"),SYNO.SDS.Utils.StorageUtils.UiRenderHelper.SizeRender(t.size_free_byte)),""!==t.description&&(c=Ext.util.Format.htmlEncode(t.description)),a.push([t.volume_path,l,t.size_total_byte/1024/1024,t.display_name,d,t.volume_id,c,t.volume_quota_status]),this.hasWritableVol=!0}},this),r)return!1;if(0===a.length)return!0;a.sort(function(e,t){return e[5]-t[5]});var l=[];return Ext.each(a,function(e,t,i){l=l.concat({value:e[0],display:e[1],size_total_mb:e[2],vol_name:e[3],desc:Ext.util.Format.htmlEncode(e[4]),tooltip:e[6],volume_quota_status:e[7]})}),s.loadData(l),e||(e=a[0][0],a[0][2]),this.shareForm.setValues({vol_path:e,vol_orig:e}),!0},setCloneHandler:function(e){var t=e.result[1].data,i=t.vol_path,s=this.advancedForm;this.pushVolumeList(i,this.getVolumeList(e)),this.shareForm.setValues({name_org:t.name}),this.shareForm.findField("enable_recycle_bin").setValue(!0),this.shareForm.findField("recycle_bin_admin_only").setValue(!0),s.findField("enable_share_cow").initValue=t.enable_share_cow,s.findField("enable_share_compress").initValue=t.enable_share_compress},setEditHandler:function(e){var t=e.result[1].data,i=t.vol_path;switch("homes"!==t.name.toLowerCase()&&-1===i.indexOf("SATA")||this.shareForm.findField("name").disable(),t.enable_recycle_bin||Ext.getCmp(this.cleanBinBtnId).disable(),this.shareForm.setValues({name_org:t.name}),this.shareForm.setValues(t),t.encryption){case 0:var s=this.encryptForm.findField("encryption").getEl();if(s){var n=_T("share","no_encryption_help_link"),o=_T("common","here"),a=String.format(_T("share","no_encryption_reason"),`${o}`);SYNO.ux.AddTip(s,a)}SYNO.ux.Utils.displayFormField(this.encryptForm,"no_encryption_reason",!1);break;case 1:this.shareForm.findField("enable_recycle_bin").disable(),Ext.getCmp(this.cleanBinBtnId).disable(),this.isEncrytionHidden()||(this.encryptForm.setValues({encryption:!0}),this.encryptForm.findField("encryption").disable(),this.encryptForm.findField("enc_passwd").disable(),this.encryptForm.findField("enc_passwd2").disable(),this.enableGroupDummy1.enable_fields=[]),this.advancedForm.findField("enable_share_compress").disable();break;case 2:this.shareForm.findField("name").disable(),this.shareForm.findField("vol_path").disable(),SYNO.ux.AddTip(this.shareForm.findField("vol_path").getEl(),_T("share","share_move_encryption_tip")),this.isEncrytionHidden()||(this.encryptForm.setValues({encryption:!0}),this.encryptForm.findField("enc_passwd").disable(),this.encryptForm.findField("enc_passwd2").disable(),this.enableGroupDummy1.enable_fields=[]);break;default:var r="Error: unknown encryption = "+this.shareInfo.encryption;this.getMsgBox().alert("warning_msg",r)}if(this.updateKeyManagerUI(),this.isClusterShareDisable(t)&&(this.shareForm.findField("enable_recycle_bin").disable(),Ext.getCmp(this.cleanBinBtnId).disable()),this.isClusterShare(t)&&(this.encryptForm.findField("encryption").disable(),this.encryptForm.findField("enc_passwd").disable(),this.encryptForm.findField("enc_passwd2").disable()),this.isColdStorageShare(t)&&(this.encryptForm.findField("encryption").disable(),this.encryptForm.findField("enc_passwd").disable(),this.encryptForm.findField("enc_passwd2").disable()),!1===this.pushVolumeList(i,this.getVolumeList(e),t))return!1;if(t.is_usb_share){var l="-";-1!==t.vol_path.indexOf("USB")?l="SDCARD"===t.external_dev_type?_T("tree","leaf_sdcard"):_T("status","status_usb"):-1!==t.vol_path.indexOf("sata")&&(l=_T("status","status_sata")),this.shareForm.setValues({my_vol_status:l}),this.formPanel.disable(),SYNO.ux.Utils.displayFormField(this.shareForm,"my_vol_status",!0),SYNO.ux.Utils.displayFormField(this.shareForm,"vol_path",!1),this.encryptForm.findField("encryption").disable(),this.encryptForm.findField("enc_passwd").disable(),this.encryptForm.findField("enc_passwd2").disable()}else this.isShowBtrfsOption()&&this.setEditAdvancedTab(t);return this.isShowVolume()||(SYNO.ux.Utils.displayFormField(this.shareForm,"vol_path",!1),SYNO.ux.Utils.displayFormField(this.shareForm,"my_vol_status",!1)),this.isCanRename()||this.shareForm.findField("name").disable(),!0},getQuotaStatus:function(){const e=this.shareForm.findField("vol_path").getValue(),t=this.shareForm.findField("vol_path").getStore().getById(e);return t?t.data.volume_quota_status:"unknown"},needDisableQuotaUsed(e){return"incompatible"===this.getQuotaStatus()},setEditAdvancedTab:function(e){var t=this.advancedForm;if(delete e.encryption,t.setValues(e),this.supportShareQuota&&e.hasOwnProperty("quota_value")&&e.quota_value>0){t.setValues({enable_share_quota:!0});var i=e.quota_value;i/1024/1024==Math.floor(i/1024/1024)?(t.setValues({quota_unit:"TB"}),t.setValues({quota_value:i/1024/1024})):i/1024==Math.floor(i/1024)?(t.setValues({quota_unit:"GB"}),t.setValues({quota_value:i/1024})):(t.setValues({quota_unit:"MB"}),t.setValues({quota_value:i}))}if(t.findField("share_quota_status").initValue=this.supportShareQuota?e.share_quota_status:void 0,this.needDisableQuotaUsed(e))t.setValues({share_quota_used:""});else if(this.supportShareQuota&&e.hasOwnProperty("share_quota_used")){var s,n=SYNO.SDS.Utils.CapacityRender(e.share_quota_used,2);s=String.format(_T("share","share_used"),''+n+""),t.setValues({share_quota_used:s})}t.findField("enable_share_cow").initValue=e.enable_share_cow,t.findField("enable_share_compress").initValue=e.enable_share_compress},editHandler:function(){var e=this.shareForm.findField("name").getValue(),t=this.getFsType("vol_path");if(!this.shareForm.isValid())return this.panel.setActiveTab("shareForm"),void this.setStatusError({text:_T("error","error_bad_field"),clear:!0});if(!this.isEncrytionHidden()&&!this.encryptForm.isValid())return this.panel.setActiveTab("encryptForm"),void this.setStatusError({text:_T("error","error_bad_field"),clear:!0});if(this.isShowBtrfsOption()&&!this.advancedForm.isValid())return this.panel.setActiveTab("advancedForm"),void this.setStatusError({text:_T("error","error_bad_field"),clear:!0});if(this.isAnyFormDirty())if("yes"!==this._D("usbstation","no")||"web"!==e.toLowerCase()||"ext4"===t){if(!0===this.share.get("is_aclmode"))if("surveillance"===this.shareForm.findField("name").getValue().toLowerCase())return void this.getMsgBox().alert(this.title,_T("share","share_acl_share_not_support"));var i=this.formPanel.getForm().findField("unite_permission");i.isDirty()&&!0===i.getValue()?this.getMsgBox().alert(this.title,_T("share","warn_enable_advanced_permission"),function(){this.confirmPolling()},this):this.confirmPolling()}else this.getMsgBox().alert(this.title,String.format(_T("service","no_ext4_external_devices"),e));else this.close()},setItemUnchecked:function(e){e.setValue(!1)},exclusiveChecking:function(e){var t=this.encryptForm.findField("encryption"),i=this.advancedForm.findField("enable_share_compress"),s=this.encryptForm.findField("add_to_keymanager");t===e?this.getMsgBox().confirm(_T("tree","leaf_sharefolder"),_T("share","share_compress_to_encrypt_confirm"),function(e){"yes"===e?this.setItemUnchecked(i):this.setItemUnchecked(t)},this,{no:{text:_T("common","no")},yes:{text:_T("common","yes"),btnStyle:"blue"}}):i===e&&this.getMsgBox().confirm(_T("tree","leaf_sharefolder"),_T("share","share_encrypt_to_compress_confirm"),function(e){"yes"===e?(this.setItemUnchecked(t),this.setItemUnchecked(s)):this.setItemUnchecked(i)},this,{no:{text:_T("common","no")},yes:{text:_T("common","yes"),btnStyle:"blue"}})},confirmPolling:function(){var e={},t=this.shareForm.findField("vol_path"),i=this.encryptForm.findField("encryption"),s=this.advancedForm.findField("enable_share_cow"),n=this.advancedForm.findField("enable_share_compress"),o="yes"===this._D("support_online_compr_switch","no");e.name=this.shareForm.findField("name_org").getValue(),e.shareinfo=this.getParamShareForm(),e.shareinfo.encryption=this.encryptForm.findField("encryption").getValue(),e.shareinfo.enc_passwd=this.encryptForm.findField("enc_passwd").getValue(),this.shareActionPolling=t.isDirty()||i.isDirty()||s.isDirty()||n.isDirty(),this.doShareMove=t.isDirty()||i.isDirty()||s.isDirty()||n.isDirty()&&!o,this.shareActionPolling&&this.doShareMove&&this.isShowBtrfsOption()&&this.advancedForm.findField("enable_share_quota").getValue()&&(e.shareinfo.share_quota=this.getQuotaInMB()),this.verifyPassphrase(e)},verifyPassphrase:function(e){var t=this.encryptForm.findField("add_to_keymanager").getValue(),i=this.encryptForm.findField("keymanager_passphrase").getValue();t?(this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share.KeyManager.Store",method:"verify",params:{passphrase:i},encryption:["passphrase"],version:1,scope:this,callback:function(t,i,s){if(this.clearStatusBusy(),t)this.submitValidShareInfo(e);else{var n=SYNO.API.Response.GetFirstError(i),o=SYNO.API.Errors.core[n.code]||_T("keymanager","error_invalid_passphrase");this.getMsgBox().alert("warning_msg",o)}}})):this.submitValidShareInfo(e)},addAlignedBullet:function(e){return String.format('
{0}
',e)},submitValidShareInfo:function(e){this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share",method:"validate_set",params:e,encryption:["shareinfo"],version:1,scope:this,callback:function(t,i,s){var n=[],o="",a="",r=[];if(this.clearStatusBusy(),!t){if(i&&i.errors&&i.errors.warning_package){for(var l=[],d=0;d";const e=this.isVolDedup("vol_path"),t="v1"===this.getQuotaStatus(),i=this.advancedForm.findField("enable_share_quota").getValue();h+=_T("share","share_move_please_note")+_T("common","colon")+"
",h+=this.addAlignedBullet(_T("share","share_move_serivce_stopped")),this.isBtrfsShare("vol_orig")&&(h+=this.addAlignedBullet(_T("share","share_move_snapshot_lost_warning")),this.isBtrfsShare("vol_path")||(h+=this.addAlignedBullet(_T("share","share_move_quota_lost_warning"))),e&&t&&i&&(h+=this.addAlignedBullet(_T("share","share_move_dedup_quota_lost_warning")))),"homes"===this.share.get("name").toLowerCase()&&(h+=this.addAlignedBullet(_T("user","home_volume_change"))),h+="
",h+="
"+_T("common","ask_cont");var u=_T("common","continue"),p=this.encryptForm.findField("encryption");p.isDirty()&&(u=p.getValue()?_T("share","btn_encrypt_share"):_T("share","btn_decrypt_share")),r.push({custom:!0,style:this.isBtrfsShare("vol_orig")?"warning":"normal",btn:u,text:h})}if(i&&i.hasOwnProperty("warning_pause_service")&&(Ext.each(i.warning_pause_service,function(e){n.push(SYNO.SDS.AdminCenter.Share.Utils.GetServiceI18N(e))}),o=""+n.join(", ")+"
",r.push({text:String.format(_T("share","share_service_pause_confirm"),o)})),"yes"===this._D("supportNFS","no")&&this._S("is_admin")&&this.supportShareSnapshot){var _=this.getIsSnapshotBrowsing(),m=!!this.nfsPanel.disabled||this.nfsPanel.onRuleCheck();_&&!m&&this.nfsPanel.dataModified&&r.push({text:_T("share","share_nfs_crossmnt_apply_confirm"),callback:function(t){"yes"===t&&this.nfsPanel.applyCrossMnt(),this.showConfirmMsg(r,e,i)}})}this.showConfirmMsg(r,e,i)}})},showFeasibilityCheckMsg:function(e,t){var i;t&&t.hard?(i=_T("share","edit_hard_check_fail"),i+="
"+SYNO.SDS.Utils.GetFeasibilityCheckMsgJoin(t.hard[e.name])+"",this.getMsgBox().alert("warning_msg",i)):t&&t.soft?(i=_T("share","edit_soft_check_fail"),i+="
"+SYNO.SDS.Utils.GetFeasibilityCheckMsgJoin(t.soft[e.name])+"",this.getMsgBox().confirm("warning_msg",i,function(t){"yes"===t&&this.showEncryptWarnMsg(e)},this)):this.showEncryptWarnMsg(e)},showEncryptWarnMsg:function(e){this.IsToEncrypt()?this.confirm_encryption(e,this.submitEditShareInfo):this.submitEditShareInfo(e)},IsToEncrypt:function(){let e=this.encryptForm.findField("encryption");return e.isDirty()&&!0===e.getValue()},showConfirmMsg:function(e,t,i){var s;if(i&&i.hard||0===e.length)this.showFeasibilityCheckMsg(t,i);else if((s=e.pop()).custom||"warning"==s.style){var n=new SYNO.SDS.AdminCenter.Share.Move({owner:this,module:this.module,appWin:this.appWin,msg:s,scope:this,callback:function(s){"yes"===s&&this.showConfirmMsg(e,t,i)}});n.loadMessage(s.text),n.open()}else{this.getMsgBox().confirm("warning_msg",s.text,function(n){s.callback?s.callback.call(this,n):"yes"===n&&this.showConfirmMsg(e,t,i)},this);var o=this.getMsgBox().getDialog();o.setWidth(600),o.setPosition([this.getPosition()[0]+(this.getWidth()-o.getWidth())/2,this.getPosition()[1]+(this.getHeight()-o.getHeight())/2-20])}},submitEditShareInfo:function(e){var t=!0,i=this.gridPanel.disabled?[]:this.gridPanel.getWebAPI(),s=this.formPanel.disabled?[]:this.formPanel.getWebAPI(),n=i.concat(s);if("yes"===this._D("supportNFS","no")&&this._S("is_admin")){var o=this.nfsPanel.disabled?[]:this.nfsPanel.getWebAPI();n=n.concat(o)}for(var a=0;a{this.sendWebAPI({api:"SYNO.Core.RecycleBin",method:"start",version:1,params:e,scope:this})})},this,t)},restoreValue:function(e){var t=this.advancedForm.findField(e);t.hasSetOriginValue&&(t.setValue(t.originValue),t.hasSetOriginValue=!1)},storeValue:function(e){var t=this.advancedForm.findField(e);t.hasSetOriginValue||(t.originValue=t.getValue(),t.hasSetOriginValue=!0),"syno_checkbox"===t.xtype?t.setValue(!1):"syno_numberfield"===t.xtype&&(t.setValue(0),t.clearInvalid())},adjustQuotaTip:function(e){let t=void 0;const i=e=>SYNO.ux.AddTip(this.advancedForm.findField("share_quota_used").getEl(),e).id;e&&(t=Ext.util.Format.htmlEncode(_T("share","share_quota_unsupported_desc"))),t?(this.quotaTipID?Ext.getCmp(this.quotaTipID).show():this.quotaTipID=i(""),Ext.getCmp(this.quotaTipID).el.set({"ext:wtip":t})):this.quotaTipID&&Ext.getCmp(this.quotaTipID).hide()},onLocationChange:function(e){var t=this.getFsType("vol_path"),i=this.getVolAttr("vol_path");this.isVolDedup("vol_path");if("yes"===this._D("usbstation","no")&&"clone"!==this.mode&&("ext3"===t||"ext4"===t?this.encryptForm.findField("encryption").enable():(!0===this.encryptForm.findField("encryption").getValue()&&this.getMsgBox().alert(this.title,_T("share","share_enc_ext4_only")),this.encryptForm.setValues({encryption:!1,enc_passwd:"",enc_passwd2:""}),this.encryptForm.findField("encryption").disable())),"create"===this.mode&&"btrfs"===t&&("generic"===i?this.encryptForm.findField("encryption").enable():this.encryptForm.findField("encryption").disable()),this.isShowBtrfsOption()){var s=this.advancedForm;const a="incompatible"===this.getQuotaStatus();if(this.supportShareQuota&&("btrfs"!==t||a?(s.findField("enable_share_quota").disable(),s.findField("share_quota_used").disable()):(s.findField("enable_share_quota").enable(),s.findField("share_quota_used").enable(),s.findField("quota_value").validate()),this.adjustQuotaTip(a)),"btrfs"===t){var n=s.findField("enable_share_cow"),o=s.findField("enable_share_compress");"create"===this.mode?(n.enable(),n.getValue()?o.enable():o.disable()):(e.getValue()===this.shareForm.findField("vol_orig").getValue()?(n.disable(),n.setValue(n.initValue),o.setValue(o.initValue)):n.enable(),!1===n.getValue()||1===this.share.data.encryption||"generic"!==i?o.disable():o.enable())}else s.findField("enable_share_cow").disable(),s.findField("enable_share_compress").disable()}},startShareMovePolling:function(e,t){var i={ok:_T("common","hide"),cancel:_T("common","cancel")};this.getMsgBox().show({width:300,progress:!0,closable:!1,buttons:i,fn:function(t,i,s){"ok"===t?this.onCloseMsgBox():"cancel"===t&&this.onCancelMoveJob(e)}.createDelegate(this),msg:this.moveShareMsg,scope:this}),this.module.panel.share_move_pollingId=this.pollReg({webapi:{api:"SYNO.Core.Share",method:"move_status",version:1,params:{task_id:e.task_id}},interval:5,immediate:!0,scope:this,status_callback:function(i,s,n,o){var a=s.data;if(!i){this.stopShareMovePolling();var r=SYNO.API.Response.GetFirstError(s),l=SYNO.API.Errors.core[r.code]||_T("common","error_system");if(5608==r.code)if(r.errors&&r.errors.error&&r.errors.error.errors&&r.errors.error.errors.invalid_list)l=l+"
"+r.errors.error.errors.invalid_list.slice(0,5).join(",
")+"
";return this.getMsgBox().alert("warning_msg",l),this.sendWebAPI({webapi:{api:"SYNO.Core.Share",version:1,method:"stop_move",params:{task_id:e.task_id,bg_taskid:e.bg_taskid},scope:this}}),!1}if(i&&void 0!==a)if("success"===a.status)this.sendWebAPI({webapi:{api:"SYNO.Core.Share",version:1,method:"stop_move",params:{task_id:e.task_id,bg_taskid:e.bg_taskid},scope:this}}),this.stopShareMovePolling(),this.getMsgBox().hide(),this.KeyManager.enable?this.addKeyToKeyManager(this.applyDone,t):this.applyDone(t);else if("cancelled"===a.status)this.stopShareMovePolling(),this.onCloseMsgBox();else if("checking"===a.status)this.moveShareMsg=_T("share","enough_space_check"),this.getMsgBox().updateProgress(0,"",this.moveShareMsg);else{var d,c=(100*a.processed_size/a.total).toFixed(2),h=this.getRemainTimeStr(a),u=Ext.util.Format.fileSize(a.transfer_rate.toFixed(2))+"/s";!0===a.data_transfer_mode?(this.moveShareMsg=String.format('{0}{1} %',_T("share","share_move_progress"),c),d=String.format('
{0}: {1} ({2} / {3})
{4}: {5}
',_T("rsrcmonitor","transfer_rate"),u,Ext.util.Format.fileSize(a.processed_size||0),Ext.util.Format.fileSize(a.total),_T("download","download_time_left"),h)):(this.moveShareMsg=String.format('{0}{1} %',_T("common","applying_settings")+"...",c),d=String.format("
{0}: {1}
",_T("download","download_time_left"),h)),this.getMsgBox().updateProgress(c/100,d,this.moveShareMsg,!0),this.getMsgBox().getDialog().progressStatus.removeClass("syno-mb-progress-status")}}})},getRemainTimeStr:function(e){return e?((t=(e.total-e.processed_size)/e.transfer_rate)/86400>1?n=_T("common","time_greater_day"):(n="",i=parseInt(t/3600,10),s=parseInt(t/60-60*i,10),parseInt(t-60*s-3600*i,10),n+=i>=1?i+" "+_T("status","status_hour")+", ":"",""===(n+=s>=1?s+" "+_T("status","status_minute"):"")&&(n=_T("common","time_less_min"))),n):_T("common","unknown");var t,i,s,n},onCloseMsgBox:function(){this.getMsgBox().getDialog().doClose(),this.applyDone()},onCancelMoveJob:function(e){this.stopShareMovePolling(),this.sendWebAPI({webapi:{api:"SYNO.Core.Share",version:1,method:"stop_move",params:{task_id:e.task_id,bg_taskid:e.bg_taskid},scope:this}}),this.onCloseMsgBox()},stopShareMovePolling:function(){this.module.panel.stopShareMovePolling()},deactivate:function(){return!0},getQuotaInMB:function(){var e=this.advancedForm,t=e.findField("quota_value").getValue(),i=e.findField("quota_unit").getValue();return"TB"===i?t=1024*t*1024:"GB"===i&&(t*=1024),t},confirmQuotaUpdate:function(e){const t=this.getVolumeName(),i=String.format(_T("share","share_quota_recalculate_warn"),t);this.getMsgBox().confirm(this.title,i,t=>{e&&e.setValue("yes"===t),"yes"===t&&this.enableShareQuota(!0)})},getVolumeName:function(){const e=this.shareForm.findField("vol_path").getValue();return this.shareForm.findField("vol_path").getStore().getById(e).data.vol_name},onEnableShareQuota:function(){this.enableShareQuota()},enableShareQuota:function(e){var t=this.advancedForm,i=t.findField("enable_share_quota").getValue();let s=t.findField("quota_value").getValue();if(i&&0===s&&!0!==e){const e=this.shareForm.findField("vol_path").isDirty()&&"edit"===this.mode,i=this.isVolDedup("vol_path"),s="v1"===this.getQuotaStatus();if(i&&s&&!e)return void this.confirmQuotaUpdate(t.findField("enable_share_quota"))}i?(t.findField("quota_value").enable(),t.findField("quota_unit").enable(),0===t.findField("quota_value").getValue()&&t.setValues({quota_value:10})):(t.findField("quota_value").disable(),t.findField("quota_unit").disable(),t.setValues({quota_value:0}))},getIsSnapshotBrowsing:function(){var e=this.advancedForm.findField("enable_snapshot_browsing");return!(!this.supportShareSnapshot||e.disabled)&&e.getValue()},isBtrfsShare:function(e){return"btrfs"===this.getFsType(e)},getFsType:function(e){var t=this.shareForm.findField(e).getValue();return this.volumeFsMap[t]},getVolAttr:function(e){var t=this.shareForm.findField(e).getValue();return this.volumeAttrMap[t]},isVolDedup:function(e){let t=this.shareForm.findField(e).getValue();return this.dedupedVolume.includes(t)},isAnyFormDirty:function(){var e=this.shareTab.isFormDirty(),t=this.encryptTab.isFormDirty(),i=this.advancedTab.isFormDirty(),s="edit"===this.mode&&SYNO.SDS.Share.PermissionDialog.prototype.isChanged.call(this),n="edit"===this.mode&&this.nfsPanel&&0!==this.nfsPanel.dataModified;return e||t||i||s||n},isShowBtrfsOption:function(){return this.supportShareSnapshot||this.supportShareQuota},isShowVolume:function(){return!this.share||!this.share.get("is_cluster_share")},isCanRename:function(){return!this.share||!this.share.get("is_cluster_share")},isColdStorageShare:function(e){return!(!e||!e.is_cold_storage_share)||!(e||!this.share||!this.share.get("is_cold_storage_share"))},isClusterShare:function(e){return!(!e||!e.is_cluster_share)||!(e||!this.share||!this.share.get("is_cluster_share"))},isClusterShareDisable:function(e){return!!this.isClusterShare(e)&&(!(!e||e.cluster_share_mount)||!(e||!this.share||this.share.get("cluster_share_mount")))},isDisableNFS:function(){return!(!this.share||!this.share.get("is_cluster_share"))}}),Ext.define("SYNO.SDS.AdminCenter.Share.CreateWizard",{extend:"SYNO.SDS.Wizard.ModalWindow",constructor:function(e){this.applyShareDialogFunctions(),this.module=e.module,this.owner=e.owner,this.share=e.share,this.store=e.store,this.mode="create",this.supportShareSnapshot="yes"===this._D("support_share_snapshot","no"),this.supportShareQuota="yes"===this._D("support_share_quota","no"),this.share&&this.share.get("is_cluster_share")&&(this.supportShareSnapshot=!1,this.supportShareQuota=!1),this.snapshot=e.snapshot,this.blKeyManagerEnabled=e.blKeyManagerEnabled,this.rgQuotaUnit=[["TB","TB"],["GB","GB"],["MB","MB"]],this.defineGrid();var t=Ext.apply({},e);delete t.owner,this.shareTab=this.fillShareFormConfig(Ext.apply({headline:_T("share","create_wizard_basic_info"),itemId:"basic_info",nextId:this.isEncrytionHidden()?this.isShowBtrfsOption()?"adv_setting":"summary":"enc_setting",getNext:function(){var e=this.getForm().findField("name").getValue(),t=!1;return this.module.panel.store.each(function(i){if(e.toLowerCase()===i.get("name").toLowerCase())return t=!0,!1}),t?(this.getForm().findField("name").markInvalid(_T("share","share_already_exist")),!1):!!this.getForm().isValid()&&this.nextId}},t)),this.encryptTab=this.fillEncryptFormConfig(Ext.apply({headline:_T("share","share_tab_encryption"),itemId:"enc_setting",nextId:this.isShowBtrfsOption()?"adv_setting":"summary",getNext:function(){return!!this.getForm().isValid()&&this.nextId}},t)),this.advancedTab=this.fillAdvancedFormConfig(Ext.apply({headline:_T("share","create_wizard_adv_setting"),itemId:"adv_setting",nextId:"summary",getNext:function(){return!!this.getForm().isValid()&&this.nextId}},t)),this.summary=new SYNO.SDS.AdminCenter.Share.CreateShareSummaryStep({headline:_T("share","create_wizard_confirm_setting"),description:"",module:this.module,owner:this,itemId:"summary",nextId:"sharegrid",getNext:function(){return this.owner.onApply(),!1}}),this.shareForm=this.shareTab.getForm(),this.encryptForm=this.encryptTab.getForm(),this.advancedForm=this.advancedTab.getForm(),this.gridPanel=new SYNO.SDS.Share.PermissionGrid({module:this.module,owner:this,itemId:"sharegrid",disabled:!1,hidden:!1,hideCustomColumn:!1,height:404,bwrapCfg:{cls:"x-panel-bwrap",style:"padding-top: 0px; padding-bottom: 0px;"},headline:_T("share","create_wizard_perm_setting"),description:"",getNext:function(){return this.owner.onPermissionWizardApply(),!1},checkState:function(){SYNO.SDS.Wizard.Step.prototype.checkState.apply(this,arguments),this.owner.getButton("back").hide(),this.owner.getButton("next").setText(_T("common","commit"))}}),this.formPanel=new SYNO.SDS.Share.AdvanceForm({module:this.module,owner:this,itemId:"advperm"});var i,s=function(e){return new Ext.Container({headline:e.headline,itemId:e.itemId,nextId:e.nextId,getNext:e.getNext.createDelegate(e),items:e})},n=Ext.apply({title:_T("share","create_wizard_title"),resizable:!1,width:800,height:585,steps:[this.shareTab,s(this.encryptTab),s(this.advancedTab),this.summary,(i=this.gridPanel,new SYNO.ux.Panel({headline:i.headline,itemId:i.itemId,nextId:i.nextId,getNext:i.getNext.createDelegate(i),checkState:i.checkState.createDelegate(i),items:i}))]},e);this.callParent([n]),SYNO.ux.AddTip(this.shareForm.findField("hide_unreadable").getEl(),_T("share","tip_hide_nonprivileged_folder")),this.supportShareSnapshot&&(SYNO.ux.AddTip(this.advancedTab.getForm().findField("enable_share_cow").getEl(),_T("share","share_integrity_protection_tip")),"yes"===this._D("support_online_compr_switch","no")?SYNO.ux.AddTip(this.advancedForm.findField("enable_share_compress").getEl(),_T("share","share_compress_tip")):SYNO.ux.AddTip(this.advancedForm.findField("enable_share_compress").getEl(),_T("share","enable_share_compress_help"))),this.loadData(),this.mon(this,"afterlayout",function(e,t){this.blKeyManagerEnabled?(this.enableGroupDummy1=new SYNO.ux.Utils.EnableCheckGroup(this.encryptForm,"encryption",["enc_passwd","enc_passwd2","add_to_keymanager"],[]),this.ckg_keymanager=new SYNO.ux.Utils.EnableCheckGroup(this.encryptForm,"add_to_keymanager",["keymanager_cypher","keymanager_passphrase"],[])):this.enableGroupDummy1=new SYNO.ux.Utils.EnableCheckGroup(this.encryptForm,"encryption",["enc_passwd","enc_passwd2","add_to_keymanager"],[]),this.enableGroupDummy2=new SYNO.ux.Utils.EnableCheckGroup(this.shareForm,"enable_recycle_bin",["recycle_bin_admin_only"],[],{disable_group:!0})},this,{single:!0}),this.updateKeyManagerUI(),this.mon(this,"deactivate",this.deactivate,this),this.mon(this.shareForm.findField("vol_path"),"collapse",this.onLocationChange,this)},applyShareDialogFunctions:function(){var e=SYNO.SDS.AdminCenter.Share.Dialog.prototype;for(var t in e)e.hasOwnProperty(t)&&Ext.isFunction(e[t])&&!this.hasOwnProperty(t)&&(this[t]=e[t].createDelegate(this))},loadPermissionData:function(e){var t=e.get("vol_path")||e.get("real_path"),i=0===(t=t.toLowerCase()).indexOf("/volumeusb")||0===t.indexOf("/volumesd")||0===t.indexOf("/volumesata"),s=e.get("vol_path");s||(i?(s=e.get("real_path"),"yes"===this._D("usbstation","no")&&(s=s.replace(/\/@sharebin\/.*/,""))):s=e.get("real_path").replace(e.get("path"),""),e.set("vol_path",s));var n=[{api:"SYNO.Core.Directory.LDAP",method:"get",version:1},{api:"SYNO.Core.Share",method:"get",version:1,params:{name:e.get("name"),additional:["disable_list","disable_modify","disable_download","unite_permission","is_aclmode"]}},{api:"SYNO.Core.Storage.Volume",method:"get",version:1,params:{volume_path:s}}];this.gridPanel.getKnownAPI("SYNO.Core.Directory.Domain")&&(n.push({api:"SYNO.Core.Directory.Domain",method:"get",version:1}),n.push({api:"SYNO.Core.Directory.Domain",method:"test_dc",version:1}),"yes"===this._D("supportdomain")&&n.push({api:"SYNO.Core.Directory.Domain",method:"get_domain_list",version:2})),this.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:n},scope:this,callback:function(t,i,s){if(this.clearStatusBusy(),t&&!i.has_fail){var n=SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Directory.Domain","get","enable_domain"),o=SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Directory.Domain","test_dc","test_join_success");n&&!o&&this.owner.getMsgBox().alert("warning_msg",_T("share","warning_directory_service_offline"));var a=SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Storage.Volume","get").volume;e.set("share_path",a.volume_path+"/"+e.get("name")),e.set("readonly",a.readonly),e.set("is_aclmode",SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Share","get","is_aclmode")),e.set("is_sync_share",SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Share","get","is_sync_share")),this.gridPanel.loadPermissions(e,i),this.goNext("sharegrid"),this.gridPanel.getTopToolbar().getComponent("search").updateElSize()}else{var r=SYNO.API.Response.GetFirstError(i);this.getMsgBox().alert("share",SYNO.API.Errors.core[r.code]||_T("common","commfail"))}}})},onPermissionWizardApply:function(){if(this.gridPanel.isChanged()){var e=this.gridPanel.getWebAPI();SYNO.SDS.Share.PermissionDialog.prototype.sendApplyRequest.call(this,e)}else this.close()}}),Ext.define("SYNO.SDS.AdminCenter.Share.CreateShareSummaryStep",{extend:"SYNO.SDS.Wizard.SummaryStep",constructor:function(e){this.callParent(arguments)},activate:function(){this.genSummary.call(this.owner,this.getStore()),this.getView().syncFocusEl(0),this.getView().refresh()},genSummary:function(e){var t=this,i=function(e){return t.shareForm.findField(e).getValue()},s=function(e){return t.advancedForm.findField(e).getValue()},n=function(e){return e?_T("share","create_wizard_enabled"):""};e.removeAll(!0),e.append(_T("share","share_name"),i("name")),e.append(_T("share","share_comment"),i("desc"));var o=i("vol_path"),a=t.shareForm.findField("vol_path").getStore().getById(o).get("display");e.append(_T("volume","volume_share_position"),a);var r=i("hidden"),l=i("hide_unreadable"),d="";r&&l?d=_T("share","share_hide_in_windows")+"; "+_T("share","share_hide_without_perm"):(d+=r?_T("share","share_hide_in_windows"):"",d+=l?_T("share","share_hide_without_perm"):""),e.append(_T("share","share_visibility"),d);var c,h="";if(i("enable_recycle_bin")&&(h=i("recycle_bin_admin_only")?_T("share","recycle_bin_enabled_admin_only"):_T("share","create_wizard_enabled")),e.append(_T("share","recycle_bin"),h),e.append(_T("share","share_encryption"),n((c="encryption",t.encryptForm.findField(c).getValue()))),t.supportShareSnapshot&&(e.append(_T("share","share_cow"),n(s("enable_share_cow"))),e.append(_T("share","share_compression"),n(s("enable_share_compress")))),t.supportShareQuota){var u=s("enable_share_quota")?s("quota_value")+" "+s("quota_unit"):"";e.append(_T("share","create_wizard_quota"),u)}}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.Delete",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={cls:"x-window-dlg confirm-delete-icon",padding:"0px 30px 0 30px",closable:!1,width:640,resizable:!1,draggable:!1,layout:"fit",fbar:["->",{xtype:"syno_button",itemId:"cancel",text:_T("common","cancel"),scope:this,handler:this.close},{xtype:"syno_button",text:_T("common","delete"),itemId:"apply",btnStyle:"red",disabled:!0,scope:this,handler:this.onClickDelete}],items:[{xtype:"syno_formpanel",itemId:"deleteFormPanel",padding:"0px 0px 0px 0px",height:250,items:[{xtype:"syno_displayfield",name:"title",value:_T("share","share_delete"),itemCls:"user-delete-message",style:"font-size: 14px;",htmlEncode:!1},{xtype:"syno_displayfield",name:"message",htmlEncode:!1},{xtype:"syno_displayfield",name:"shares",htmlEncode:!1},{xtype:"syno_displayfield",name:"feasibility"},this.grid=new SYNO.SDS.Wizard.SummaryStep({layout:"fit",height:150,columns:[{width:150,header:_T("share","share"),dataIndex:"key",renderer:function(e,t){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',""+e+""}},{id:"value",autoExpand:!0,header:_T("common","action"),dataIndex:"value",scope:this,renderer:function(e,t,i,s,n,o){var a=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(a)+'"',a}}]}),{xtype:"syno_checkbox",boxLabel:String.format('{0}',e.alert_message?e.alert_message:_T("share","share_delete_confirm")),htmlEncode:!1,name:"confirm",listeners:{check:{scope:this,fn:this.onCheckboxCheck}}}]}]};return Ext.apply(t,e),t},updateGridCheckMsg:function(e,t){var i,s,n=this.grid.getStore();for(i=0;i5?(e=String.format(_T("share","share_cfrmrmv_num"),r.length),n.findField("shares").hide()):r.length>1?(e=_T("share","share_cfrmrmv_multiple"),n.findField("shares").setValue(String.format("{0}",Ext.util.Format.htmlEncode(r.join(", "))))):n.findField("shares").setValue(String.format("{0}",Ext.util.Format.htmlEncode(r.join(", ")))),o.setValue(e),!(l&&(l.hard||l.soft)&&void 0!==l||d&&(d.hard||d.soft)&&void 0!==d))return a.hide(),void this.grid.hide();for(s in l&&l.hard&&Object.keys(l.hard).forEach(function(e){c.hard[e]=l.hard[e]}),l&&l.soft&&Object.keys(l.soft).forEach(function(e){c.soft[e]=l.soft[e]}),d&&d.hard&&Object.keys(d.hard).forEach(function(e){c.hard[e]=d.hard[e]}),d&&d.soft&&Object.keys(d.soft).forEach(function(e){c.soft[e]=d.soft[e]}),0{1}
",_T("share","share_cannot_delete_for_reserved"),a.warning_external.join(""));s.push(d)}if(a.hasOwnProperty("warning_mount_point")){var c=String.format("{0}
{1}
",_T("share","error_mount_point_delete"),a.warning_mount_point.join(""));s.push(c)}try{SYNO.SDS.C2FS.UtilForDSM.exclusiveDeleteErrorMsg(o).forEach(function(e){s.push(e)})}catch(e){}0",{xtype:"syno_button",text:_T("common","cancel"),itemId:"no",scope:this,handler:this.close},{xtype:"syno_button",text:e.msg.btn?e.msg.btn:_T("common","continue"),itemId:"yes",btnStyle:"warning"==e.msg.style?"red":"blue",disabled:!0,scope:this,handler:this.onClickMove}]};return Ext.apply(t,e),t},createFormPanel:function(e){var t={header:!1,trackResetOnLoad:!0,autoScroll:!0,autoHeight:!0,items:[{xtype:"syno_displayfield",name:"warning_msg",htmlEncode:!1},{xtype:"syno_checkbox",boxLabel:String.format('{0}',_T("share","share_move_confirm")),htmlEncode:!1,name:"confirm",listeners:{check:{scope:this,fn:this.onCheckboxCheck}}}]};return new SYNO.SDS.Utils.FormPanel(t)},loadMessage:function(e){this.formPanel.getForm().findField("warning_msg").setValue(e)},onCheckboxCheck:function(e,t){this.getFooterToolbar().getComponent("yes").setDisabled(!t)},onClickMove:function(){this.callback.call(this.scope||window,"yes"),this.close()}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.Decrypt",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.shares=e.share,this.decrypt_by_km=e.decrypt_by_km,this.km_location=e.km_location;var t=this.fillConfig(e);this.callParent([t]),this.panel=this.getComponent("formpanel"),this.DefineBehaviors()},isStoreInRoot:function(){return this.km_location===SYNO.SDS.AdminCenter.Share.LocalStore},fillConfig:function(e){var t=this.isStoreInRoot()?[{xtype:"syno_radio",name:"decrypt_method",width:400,inputValue:"keymanager",boxLabel:_T("share","share_encryption_decrypt_by_keymanager_system_partition")},{xtype:"syno_textfield",textType:"password",name:"passphrase",maxLength:64,allowBlank:!0,hidden:!0}]:[{xtype:"syno_radio",name:"decrypt_method",width:200,inputValue:"keymanager",boxLabel:_T("share","share_encryption_decrypt_by_keymanager")+_T("common","colon")},{xtype:"syno_textfield",textType:"password",name:"passphrase",maxLength:64,allowBlank:!1}],i=new SYNO.SDS.Utils.FormPanel({itemId:"formpanel",trackResetOnLoad:!0,fileUpload:!0,webapi:{api:"SYNO.Core.Share.CryptoFile",method:"decrypt",version:1,scope:this},items:[{xtype:"container",layout:"column",hideLabel:!0,hidden:this.shares.length>1,items:[{xtype:"syno_radio",name:"decrypt_method",width:200,inputValue:"manual",boxLabel:_T("share","share_encryption_keyinput")+_T("common","colon"),checked:!0},{xtype:"syno_textfield",textType:"password",name:"passwd",maxLength:64,allowBlank:!1}]},{xtype:"syno_displayfield"},{xtype:"container",layout:"column",hideLabel:!0,hidden:this.shares.length>1,items:[{xtype:"syno_radio",name:"decrypt_method",width:200,inputValue:"keyfile",boxLabel:_T("share","share_encryption_importfrom")},{xtype:"syno_filebutton",allowBlank:!1,name:"password_file",textConfig:{width:192}}]},{xtype:"syno_displayfield"},{xtype:"container",layout:"column",hideLabel:!0,hidden:!this.decrypt_by_km,items:t},{xtype:"hidden",name:"name",value:this.shares[0].id}],onApiSuccess:this.onActionComplete,onApiFailure:this.onFormFailed}),s={width:600,height:260,minWidth:600,minHeight:230,title:_T("share","share_encryption_decrypt"),layout:"fit",items:i,keys:[{key:Ext.EventObject.ENTER,scope:this,handler:this.onSubmit}],buttons:[{itemId:"cancel",text:_T("common","cancel"),scope:this,handler:this.close},{itemId:"apply",btnStyle:"blue",text:_T("common","apply"),scope:this,handler:this.onSubmit}]};return Ext.apply(s,e),s},DefineBehaviors:function(){this.mon(this,"afterlayout",function(e,t){var i=this.panel.getForm();new SYNO.ux.Utils.EnableRadioGroup(i,"decrypt_method",{manual:["passwd"],keyfile:["password_file"],keymanager:["passphrase"]})},this,{single:!0})},onOpen:function(){this.callParent(arguments),this.panel.getForm().findField("passwd").focus(!1,100)},onSubmit:function(){var e=this.panel.getForm();if(e.isValid()){this.setStatusBusy({text:_T("common","msg_waiting")});var t=e.findField("decrypt_method").getGroupValue();if("keyfile"===t){if(!e.findField("password_file").getValue())return;this.get("formpanel").upload()}else if("manual"===t){var i=e.findField("passwd").getValue();if(!i)return;this.doSubmitEncryption(t,i)}else{var s=e.findField("passphrase").getValue();if(!s&&!this.isStoreInRoot())return;this.doSubmitByKeyManager(s)}}},doSubmitByKeyManager:function(e){for(var t=[],i=0;i

{1}

",e,t)};switch(e){case"cu":return t("black",_T("share","share_permission_custom")||"Custom");case"na":return t("red",_T("share","share_permission_none"));case"rw":return t("orange",_T("share","share_permission_writable"));case"ro":return t("blue",_T("share","share_permission_readonly"));case"default":return t("black",_T("common","default"));default:return e}},SYNO.SDS.AdminCenter.Share.Utils.GetPackageName=function(e){return"media"===e?_T("welcome","welcome_package_mediaserver"):"audio"===e?_T("welcome","welcome_package_audio"):"itune"===e?_T("firewall","firewall_service_desc_itunes"):"photo"===e?_T("welcome","welcome_package_photo"):"surveillance"===e?_T("tree","leaf_surveillance"):"web"===e?_T("tree","leaf_web"):"netbackup"===e?_T("service","service_rsync"):e},SYNO.SDS.AdminCenter.Share.Utils.ShowHelpCallback=function(e){return function(t){var i=t.el.query("a");if(i[0]){var s=Ext.fly(i[0]),n=function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:String.format("SYNO.SDS.AdminCenter.Application:{0}",e)},!1)};s.addKeyListener(Ext.EventObject.SPACE,n,this),s.addKeyListener(Ext.EventObject.ENTER,n,this),this.mon(s,"click",n,this)}}},Ext.define("SYNO.SDS.AdminCenter.Share.Utils.PermissionColumn",{extend:"Ext.grid.Column",constructor:function(e){var t=Ext.apply({width:120,align:"center",renderer:this.colorize},e);this.callParent([t])},colorize:function(e,t,i,s,n,o){return SYNO.SDS.AdminCenter.Share.Utils.colorizePermission(Ext.isFunction(this.convert)?this.convert(i):e)}}),Ext.namespace("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.SortButton",{extend:"SYNO.ux.Button",constructor:function(e){var t,i=this;i.appWin=e.appWin,i.owner=e.owner,t={itemId:"sort",tooltip:_T("pkgmgr","sort"),iconCls:"syno-sm-sort-btn",menu:{defaults:{checked:!1},cls:"syno-ux-check-menu",items:e.menuItems,show:function(e,t,s){var n=i.owner.store.getSortState();this.floating?(this.parentMenu=s,this.el||(this.render(),this.doLayout(!1,!0)),this.items.each(function(e){e.setChecked(e.sortField===n.field)},this),this.showAt(this.el.getAlignToXY(e,t||this.defaultAlign,this.defaultOffsets),s)):Ext.menu.Menu.superclass.show.call(this)}},listeners:{menuhide:function(){i.focus()}}},i.callParent([t])},getMenuClass:function(){return""}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.ListView",{extend:"SYNO.ux.ExpandableListView",constructor:function(e){var t;t={innerTpl:this.createInnerTpl(),useARIA:!0,trackResetOnLoad:!1,cls:"syno-admincenter-share-listview"},this.callParent([Ext.apply(t,e)])},defaultC2ShareTpl:function(){return(new Ext.XTemplate).html},defaultC2ShareInnerTpl:function(){return(new Ext.XTemplate).html},reloadTpl:function(){this.innerTpl=this.createInnerTpl(),this.tpl=this.createTpl({}),this.refresh()},createTpl:function(e){var t=e.toggleWrapCls||this.toggleWrapCls;return new Ext.XTemplate('','","",'
')},createInnerTpl:function(){var e='',t='';return new Ext.XTemplate('',"
",String.format(e,_T("share","share_comment")+_T("common","colon")),String.format(t,"{desc:htmlEncode}"),"
",'
','',SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.C2FS.Application")&&SYNO.SDS.C2FS&&SYNO.SDS.C2FS.UtilForDSM&&Ext.isFunction(SYNO.SDS.C2FS.UtilForDSM.c2ShareInnerTpl)?SYNO.SDS.C2FS.UtilForDSM.c2ShareInnerTpl():this.defaultC2ShareInnerTpl(),"",'','
',"
",String.format(e,_T("share","share_advance_permissions")+_T("common","colon")),String.format(t,"{unite_permission}"),"
",'
',"
",String.format(e,_T("share","recycle_bin")+_T("common","colon")),String.format(t,"{enable_recycle_bin}"),"
",'
','',"
",String.format(e,_T("share","share_quota")+_T("common","colon")),String.format(t,"{quota_value}"),"
",'
',"
",String.format(e,_T("share","share_size")+_T("common","colon")),String.format(t,"{share_quota_used}"),"
",'
',"
",'',"
",String.format(e,_T("share","share_compression")+_T("common","colon")),String.format(t,"{enable_share_compress}"),"
",'
',"
",String.format(e,_T("share","share_cow")+_T("common","colon")),String.format(t,"{enable_share_cow}"),"
",'
',"
",'',"
",String.format(e,_T("common","readonly")+_T("common","colon")),String.format(t,"{force_readonly_reason}"),"
",'
',"
","
","
")}}),Ext.namespace("SYNO.SDS.AdminCenter.Share.Migrate"),Ext.define("SYNO.SDS.AdminCenter.Share.Migrate.WelcomePanel",{extend:"SYNO.SDS.Wizard.WelcomeStep",targetShare:[],originShare:[],callbacks:null,constructor:function(e){var t=Ext.apply({headline:_T("sharemigrate","welcome_title"),description:_T("sharemigrate","welcome_desc")},e);SYNO.LayoutConfig.fill(t),this.callParent([t]),this.originShare=this.callbacks.getTargetShare().slice(0)},activate:function(){SYNO.SDS.Wizard.WelcomeStep.prototype.activate.apply(this,arguments),this.targetShare=this.originShare.slice(0)},getNext:function(){return this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.Share.Migration",version:1,method:"check",params:{shares:this.originShare},scope:this,callback:function(e,t,i,s){if(this.owner.clearStatusBusy(),!1===e&&t&&t.errors){var n=t.errors.fail_shares,o=t.errors.migrated_before,a=t.errors.acl_exceed,r=t.errors.not_support,l=t.errors.cifs_share,d=t.errors.service_share,c=t.errors.umount_enc,h="";h=o?_T("sharemigrate","migrated_share"):a?String.format("{0} ({1})",_T("sharemigrate","acl_exceed"),_T("acl_editor","acl_rules_reach_limit_report").split("/")[1].trim().replace("_maxCount_","200")):r?_T("sharemigrate","not_support"):l?_T("sharemigrate","cifs_share"):d?_T("sharemigrate","unsupport_service_share"):c?_T("sharemigrate","umount_enc"):_T("sharemigrate","unknown_error"),this.owner.getMsgBox().alert(_T("sharemigrate","title"),h),this.removeFailShare(n)}this.callbacks.setTargetShare(this.targetShare),0"+_T("sharemigrate","description_yes")+"

",t=Ext.apply({height:300,headline:_T("sharemigrate","replace_all"),items:[this.pBar,{xtype:"syno_radio",htmlEncode:!1,boxLabel:i,name:"mode",hidden:!0,itemId:"replace_yes",inputValue:0},{xtype:"syno_radio",htmlEncode:!1,boxLabel:_T("sharemigrate","recommand_no")+"

"+_T("sharemigrate","description_no")+"

",name:"mode",hidden:!0,itemId:"replace_no",inputValue:1},{xtype:"syno_checkbox",itemId:"confirm_migrate",htmlEncode:!1,boxLabel:'
'+_T("sharemigrate","caution")+"
",hideLabel:!0,listeners:{check:{scope:this,fn:this.onCheckboxCheck}}}]},e),SYNO.LayoutConfig.fill(t),this.callParent([t])},onCheckboxCheck:function(e,t){this.owner.getButton("next").setDisabled(!t)},activate:function(){this.beforeSuggestion(),this.pBar.progressBar.setStyle({height:this.pBar.getHeight().toString()+"px"}),this.pBar.textEl.setStyle({height:this.pBar.getHeight().toString()+"px",width:this.pBar.getWidth().toString()+"px"})},checkState:function(){SYNO.SDS.Wizard.Step.prototype.checkState.apply(this,arguments),this.owner.getButton("next").setText(_T("common","alt_start")),1==this.targetShare.length&&"web"===this.targetShare[0]?(this.items.get("replace_yes").disable(),this.items.get("replace_no").setValue(!0),this.afterSuggestion()):this.checkSuggestion()},beforeSuggestion:function(){this.pBar&&this.items&&(this.pBar.show(),this.items.get("replace_yes").hide(),this.items.get("replace_no").hide(),this.items.get("confirm_migrate").hide())},afterSuggestion:function(){this.pBar&&this.items&&(this.pBar.hide(),this.items.get("replace_yes").show(),this.items.get("replace_no").show(),this.items.get("confirm_migrate").show())},checkSuggestion:function(){this.owner.getButton("back").disable(),this.owner.getButton("next").disable(),this.sendWebAPI({webapi:{api:"SYNO.Core.Share.Migration",version:1,method:"start",scope:this,params:{polling:"suggestion",shares:this.callbacks.getTargetShare()},callback:function(e,t,i,s){if(!e||!t||!t.task_id)return this.owner.getMsgBox().alert(_T("sharemigrate","title"),_T("common","error_system")),this.owner.getButton("back").enable(),!1;this.suggestionTaskId=t.task_id,this.pollingTaskId=this.pollReg({interval:1,immediate:!0,scope:this,webapi:{api:"SYNO.Core.Share.Migration",method:"status",version:1,params:{polling:"suggestion",task_id:this.suggestionTaskId}},status_callback:this.pollingSuggestion})}}})},pollingSuggestion:function(e,t,i,s){var n=1,o=0,a=0,r=0,l="",d=null;return e&&t?(t.data&&((d=t.data).total&&d.done&&d.share&&(n=d.total,o=d.done),r=100*o/n,l=String.format('
{0} {1} %
',_T("usb","usb_st_fsck"),Math.round(r)),this.pBar.updateProgress(o/n,l)),t.finish?(t.data&&void 0!==t.data.suggestion&&this.items&&(this.pBar.hide(),0===(a=t.data.suggestion)?(this.items.get("replace_yes").setValue(!0),this.afterSuggestion()):1===a&&(this.items.get("replace_no").setValue(!0),this.afterSuggestion())),this.pollUnreg(this.pollingTaskId),this.stopPolling(),this.owner.getButton("back").enable(),void this.owner.doLayout()):void 0):(this.pollUnreg(this.pollingTaskId),this.owner.getButton("back").enable(),!1)},stopPolling:function(){this.sendWebAPI({webapi:{api:"SYNO.Core.Share.Migration",version:1,method:"stop",scope:this,params:{polling:"suggestion"}}})},migrateStart:function(){var e=parseInt(this.getForm().getValues().mode,10);this.sendWebAPI({webapi:{api:"SYNO.Core.Share.Migration",version:1,method:"start",scope:this,params:{polling:"migrate",shares:this.callbacks.getTargetShare(),migrate_method:e},callback:function(e,t,i,s){if(this.owner.clearStatusBusy(),!e||!t||!t.task_id)return this.owner.getMsgBox().alert(_T("sharemigrate","title"),_T("common","error_system")),!1;this.callbacks.setTaskId(t.task_id),this.callbacks.setMigrating(!0),this.owner.goNext(this.nextId)}}})},getNext:function(){return this.owner.setStatusBusy(),this.sendWebAPI({webapi:{api:"SYNO.Core.Share.Migration.Task",version:1,method:"list",scope:this,params:{polling:"migrate"},callback:function(e,t,i,s){return e?t&&t.admin?(this.owner.getMsgBox().alert(_T("sharemigrate","title"),_T("sharemigrate","wait_migrate")),this.owner.clearStatusBusy(),!1):void this.migrateStart():(this.owner.clearStatusBusy(),!1)}}}),!1}}),Ext.define("SYNO.SDS.AdminCenter.Share.Migrate.ProgressPanel",{extend:"SYNO.ux.FormPanel",pBar:null,pollingTaskId:null,callbacks:null,constructor:function(e){var t;this.pBar=new Ext.ProgressBar(Ext.apply({xtype:"progress",name:"progress_bar",height:20},e)),t=Ext.apply({headline:_T("sharemigrate","progress_headline"),height:300,items:[this.pBar]},e),SYNO.LayoutConfig.fill(t),this.callParent([t])},activate:function(){this.pBar.progressBar.setStyle({height:this.pBar.getHeight().toString()+"px"}),this.pBar.textEl.setStyle({height:this.pBar.getHeight().toString()+"px",width:this.pBar.getWidth().toString()+"px"}),this.pollingTaskId=this.pollReg({interval:1,immediate:!0,scope:this,webapi:{api:"SYNO.Core.Share.Migration",method:"status",version:1,params:{polling:"migrate",task_id:this.callbacks.getTaskId()}},status_callback:this.pollingUpdate})},checkState:function(){SYNO.SDS.Wizard.Step.prototype.checkState.apply(this,arguments),this.owner.getButton("back").hide(),this.owner.getButton("next").disable(),this.owner.getButton("next").setText(_T("common","finish"))},pollingUpdate:function(e,t,i,s){var n=1,o=0,a="",r=null;return e&&t?(t.data&&((r=t.data).total&&r.done&&r.share&&(n=r.total,o=r.done),a=r.path?Ext.util.Format.ellipsis(r.path,55):"",this.pBar.updateProgress(o/n,a)),t.finish?(this.pollUnreg(this.pollingTaskId),this.pBar.updateProgress(100,_T("common","finish")),this.owner.getButton("next").enable(),this.callbacks.setMigrating(!1),this.callbacks.setFinish(!0),void this.stopPolling()):void 0):(this.pollUnreg(this.pollingTaskId),this.owner.getMsgBox().alert(_T("sharemigrate","title"),_T("sharemigrate","fail")),this.callbacks.setMigrating(!1),!1)},stopPolling:function(){this.sendWebAPI({webapi:{api:"SYNO.Core.Share.Migration",version:1,method:"stop",scope:this,params:{polling:"migrate"}}})},getNext:function(){return this.nextId}}),Ext.define("SYNO.SDS.AdminCenter.Share.Migrate.Wizard",{extend:"SYNO.SDS.Wizard.ModalWindow",targetShare:[],panelWelcome:null,panelSelectMethod:null,panelProgress:null,taskId:null,caller:null,migrating:!1,finish:!1,constructor:function(e){var t=this;this.owner=e.owner,this.module=e.module,this.targetShare=e.targetShare,this.caller=e.caller,this.panelWelcome=new SYNO.SDS.AdminCenter.Share.Migrate.WelcomePanel({itemId:"welcome",owner:this,callbacks:{getTargetShare:function(){return t.getTargetShare()},setTargetShare:function(e){return t.setTargetShare(e)}},nextId:"select"}),this.panelSelectMethod=new SYNO.SDS.AdminCenter.Share.Migrate.SelectMethodPanel({itemId:"select",owner:this,callbacks:{setTaskId:function(e){return t.setTaskId(e)},getTargetShare:function(){return t.getTargetShare()},setMigrating:function(e){return t.setMigrating(e)}},nextId:"progress"}),this.panelProgress=new SYNO.SDS.AdminCenter.Share.Migrate.ProgressPanel({itemId:"progress",owner:this,callbacks:{getTargetShare:function(){return t.getTargetShare()},getTaskId:function(){return t.getTaskId()},setMigrating:function(e){return t.setMigrating(e)},setFinish:function(e){return t.setFinish(e)}},nextId:null});var i=[this.panelWelcome,this.panelSelectMethod,this.panelProgress],s=Ext.apply({title:_T("sharemigrate","title"),dd:!0,width:600,height:500,resizable:!0,steps:i},e);this.callParent([s]),this.setStatusBusy(),this.sendWebAPI({webapi:{api:"SYNO.Core.Share.Migration.Task",version:1,method:"list",scope:this,params:{polling:"migrate"},callback:function(e,t,i,s){if(this.clearStatusBusy(),!e)return!1;t&&(t.data&&t.data.shares&&this.setTargetShare(t.data.shares),t.admin&&(this.owner.getMsgBox().alert(_T("sharemigrate","title"),_T("sharemigrate","go_migrate")),this.setTaskId(t.admin),this.goNext("progress")))}}})},getTaskId:function(){return this.taskId},setTaskId:function(e){return this.taskId=e,!0},getTargetShare:function(){return this.targetShare},setTargetShare:function(e){return this.targetShare=e,!0},setMigrating:function(e){return this.migrating=e,!0},setFinish:function(e){return this.finish=e,!0},onClose:function(){return!this.migrating&&(!0===this.finish&&this.caller.store.load(),SYNO.SDS.AdminCenter.Share.Migrate.Wizard.superclass.onClose.apply(this,arguments))}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.KeyManagerGrid",{extend:"SYNO.ux.EditorGridPanel",passphrase:"",constructor:function(e){var t={title:_T("keymanager","app_title"),module:this,header:!1,border:!1,height:404,width:750,ds:this.createStore(e),cm:this.createColumnModel(),selModel:new Ext.grid.RowSelectionModel({singleSelect:!1}),autoExpandColumn:"description",tbar:this.createTBar(),plugins:[this.enableColumn]};Ext.apply(t,e),this.callParent([t]),this.defineBehaviors()},onSelectionChange:function(){0===this.getSelectionModel().getSelections().length?(this.actionGroup.disable("export"),this.actionGroup.disable("encryption"),this.actionGroup.disable("delete")):(this.actionGroup.enable("export"),this.actionGroup.enable("encryption"),this.actionGroup.enable("delete"))},defineBehaviors:function(){this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this)},createColumnModel:function(){this.enableColumn=new SYNO.ux.EnableColumn({header:_T("keymanager","common_mount_on_boot"),dataIndex:"auto_mount",enableFastSelectAll:!0,renderer:function(e,t,i){return 1===i.get("encrypt_type")?SYNO.ux.EnableColumn.prototype.renderer.call(this,e,t,i):SYNO.SDS.Share.renderCheckBox.call(this,"disabled",t,i)},isIgnore:function(e,t){return 1!==t.get("encrypt_type")}});var e=[{header:_T("share","share"),dataIndex:"share_name",id:"share_name"},{header:_T("keymanager","common_status"),dataIndex:"share_status",id:"share_status",renderer:function(e,t,i){return"mount"===e?_T("share","share_encryption_decrypt"):"umount"===e?_T("share","share_encryption_encrypt"):"unencrypted"===e?_T("keymanager","common_unencrypted"):_T("keymanager","common_unknown")}},{header:_T("share","share_comment"),dataIndex:"description",id:"description",editor:new SYNO.ux.TextField({allowBlank:!0})},{header:_T("keymanager","common_cypher"),dataIndex:"encrypt_type",id:"encrypt_type",renderer:function(e,t,i){return 0===e?_T("keymanager","common_passphrase"):1===e?_T("keymanager","common_machinekey"):_T("keymanager","common_unknown_cypher")}},this.enableColumn];return new Ext.grid.ColumnModel({defaults:{sortable:!1,width:150},columns:e})},createStore:function(e){var t={api:"SYNO.Core.Share.KeyManager.Key",method:"list",version:1,appWindow:e.owner,baseParams:{},listeners:{scope:this,beforeload:function(){this.owner.setStatusBusy({text:_T("common","loading")})},load:function(){this.onSelectionChange(),this.owner.clearStatusBusy()},exception:function(e,t,i,s,n,o){this.owner.clearStatusBusy(),SYNO.Debug("Store exception: ",e,t,i,s,n,o)}},root:"keys",totalProperty:"total",id:"share_name",fields:["share_name","share_status","description","encrypt_type","auto_mount"],remoteSort:!1,defaultSortable:!0,pruneModifiedRecords:!0,scope:this};return new SYNO.API.JsonStore(t)},isSHA:function(){return _S("ha_running")},isAHA:function(){return"yes"===_D("support_dual_head","no")},createTBar:function(){var e=new Ext.Action({text:_T("common","add"),itemId:"add",scope:this,handler:this.addHandler}),t=new Ext.Action({text:_T("share","share_encryption_exportkey"),itemId:"export",scope:this,handler:this.confirmExport}),i=new Ext.Action({text:_T("share","share_encryption_decrypt"),itemId:"mount",scope:this,handler:this.mountHandler}),s=new Ext.Action({text:_T("share","share_encryption_encrypt"),itemId:"umount",scope:this,handler:this.umountHandler}),n=new SYNO.ux.SplitButton({text:_T("share","share_encryption"),itemId:"encryption",scope:this,handler:this.mountHandler,menu:{items:[i,s]}}),o=new Ext.Action({text:_T("common","delete"),itemId:"delete",scope:this,handler:this.deleteHandler}),a=new Ext.Action({text:_T("common","configure"),itemId:"configure",scope:this,handler:this.configureHandler}),r=this.isSHA()||this.isAHA(),l=new Ext.Action({text:_T("iscsilun","clone"),itemId:"clone",scope:this,hidden:!r,handler:this.cloneHandler});return this.actionGroup=new SYNO.ux.Utils.ActionGroup([e,t,n,o,a,l]),new Ext.Toolbar({defaultType:"syno_button",items:[this.actionGroup.getArray()]})},addHandler:function(){new SYNO.SDS.AdminCenter.Share.AddKey({keys:this.getStore().data.keys,module:this.module,owner:this.owner,shares:this.shares,passphrase:this.passphrase,storeInRoot:this.storeInRoot}).open()},configureHandler:function(){new SYNO.SDS.AdminCenter.Share.StoreConfig({module:this.module,owner:this.owner,shares:this.shares,passphrase:this.passphrase,storeInRoot:this.storeInRoot}).open()},multiSelHandler:function(e){var t=this.getSelectionModel().getSelections();if(0!==t.length){for(var i=[],s=0;s=0;s.encryption&&!n&&t.push([s.name,s.name])}var o=new Ext.data.ArrayStore({fields:["value","display"],data:t}),a={xtype:"syno_fieldset",title:_T("keymanager","fs_encryption_share"),collapsible:!1,items:[{xtype:"syno_combobox",name:"share_name",fieldLabel:_T("share","share"),labelWidth:200,displayField:"display",valueField:"value",store:o,value:0!==t.length?t[0][0]:"",allowBlank:!1},{xtype:"hidden",name:"__cIpHeRtExT"}]},r={xtype:"syno_fieldset",title:_T("keymanager","fs_encryption_key"),collapsible:!1,items:[{xtype:"container",layout:"column",hideLabel:!0,items:[{xtype:"syno_radio",name:"decrypt_method",width:200,inputValue:"manual",boxLabel:_T("share","share_encryption_keyinput")+_T("common","colon"),checked:!0},{xtype:"syno_textfield",textType:"password",name:"share_password",minLength:8,maxLength:64,allowBlank:!1,validator:function(e){return-1===e.indexOf("=")&&-1===e.indexOf(",")||_T("share","encryption_password_invalid")}}]},{xtype:"syno_displayfield"},{xtype:"container",layout:"column",hideLabel:!0,items:[{xtype:"syno_radio",name:"decrypt_method",width:200,inputValue:"keyfile",boxLabel:_T("share","share_encryption_importfrom")},{xtype:"syno_filebutton",allowBlank:!1,name:"share_password_file",textConfig:{width:184}}]}]},l=new Ext.data.ArrayStore({fields:["value","display"],data:this.storeInRoot?[[1,_T("keymanager","common_machinekey")]]:[[0,_T("keymanager","common_passphrase")],[1,_T("keymanager","common_machinekey")]]}),d={xtype:"syno_fieldset",title:_T("keymanager","fs_encryption_cypher"),collapsible:!1,items:[{xtype:"syno_combobox",name:"share_cypher",fieldLabel:_T("keymanager","common_cypher"),labelWidth:200,displayField:"display",valueField:"value",store:l,value:1}]},c={title:_T("keymanager","win_title_new_key"),itemId:"newkeyForm",border:!1,frame:!1,autoScroll:!0,header:!1,height:350,trackResetOnLoad:!0,fileUpload:!0,webapi:{api:"SYNO.Core.Share.KeyManager.Key",method:"add_by_file",version:1,scope:this},onApiSuccess:this.onActionComplete,onApiFailure:this.onFormFailed,items:[a,d,r]};return Ext.apply(c,e),new SYNO.SDS.Utils.FormPanel(c)},DefineBehaviors:function(){this.mon(this,"afterlayout",function(e,t){var i=this.panelNewKey.getForm();new SYNO.ux.Utils.EnableRadioGroup(i,"decrypt_method",{manual:["share_password"],keyfile:["share_password_file"]}),SYNO.ux.AddTip(this.panelNewKey.getForm().findField("share_cypher").getEl(),_T("keymanager","tip_cypher"))},this,{single:!0})},onSubmit:function(){var e=this.panelNewKey.getForm();if(e.isValid()){var t=e.findField("share_name").getValue(),i=e.findField("decrypt_method").getGroupValue();if("keyfile"===i){if(!e.findField("share_password_file").getValue())return;this.encryptPassphrase()}else{var s=e.findField("share_cypher").getValue(),n=e.findField("share_password").getValue();if(!n)return;this.doSubmitEncryption(t,s,i,n)}}},encryptPassphrase:function(){SYNO.API.currentManager.requestAPI("SYNO.API.Encryption","getinfo",1,{format:"module"},this.onEncryptData,this)},onEncryptData:function(e,t,i){e&&(SYNO.Encryption.CipherKey=t.cipherkey,SYNO.Encryption.RSAModulus=t.public_key,SYNO.Encryption.CipherToken=t.ciphertoken,SYNO.Encryption.TimeBias=t.server_time-Math.floor(+new Date/1e3));var s={passphrase:JSON.stringify(this.passphrase)},n=SYNO.Encryption.EncryptParam(s),o=this.get("newkeyForm"),a=n[t.cipherkey]||"";o.getForm().findField("__cIpHeRtExT").setValue(a),o.upload()},doSubmitEncryption:function(e,t,i,s){this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share.KeyManager.Key",method:"add",params:{share_name:e,share_cypher:t,share_password:s,passphrase:this.passphrase},encryption:["share_password","passphrase"],version:1,scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),!e){var s=SYNO.API.Response.GetFirstError(t),n=SYNO.API.Errors.core[s.code]||_T("common","error_system");return this.getMsgBox().alert("warning_msg",n),!1}this.close()}})},onActionComplete:function(e,t,i){this.ownerCt.clearStatusBusy(),this.ownerCt.module.getPanel().store.load(),this.ownerCt.close()},onFormFailed:function(e,t,i){var s=SYNO.API.Response.GetFirstError(t),n=SYNO.API.Errors.core[s.code]||_T("common","error_system");return this.ownerCt.clearStatusBusy(),this.ownerCt.getMsgBox().alert("warning_msg",n),!1}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.StoreConfig",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.shares=e.shares,this.storeInRoot=e.storeInRoot,this.passphrase=e.passphrase,this.shareList=[[SYNO.SDS.AdminCenter.Share.LocalStore,_T("system","system_volume")]];for(var t=0;t .x-panel-bwrap { padding: 0 8px 8px 8px;}",flex:1,items:[this.treePanel]}],layout:{type:"vbox",align:"stretch",pack:"start"},height:500,width:600};return(t=Ext.apply(t,this.initFbar())).tbar=this.initToolbar(),Ext.apply(t,e)},onOpen:function(e){this.callParent(arguments),this.treePanel&&this.treePanel.load()},initToolbar:function(){return this.reportSavePath=new SYNO.ux.TextField({id:"syno-perm-report-save-path",fieldLabel:_T("common","folder"),width:365,readOnly:!0,allowBlank:!1,validateOnBlur:!0,blankText:_T("mediaservice","error_empty_path"),emptyText:_T("perm_report","save_path_placeholder")}),{xtype:"syno_toolbar",border:!1,style:{padding:"0 20px"},items:[{xtype:"syno_compositefield",items:[{xtype:"syno_displayfield",value:_T("perm_report","save_to")+_T("common","colon"),width:188},this.reportSavePath]}]}},selectPathHandler:function(){void 0===this.pathSelector&&(this.pathSelector=new SYNO.SDS.Utils.FileChooser.Chooser({parent:this,owner:this,closeOwnerWhenNoShare:!0,closeOwnerNumber:1,enumColdStorage:!0,enumC2Share:!0,needrw:!0,usage:{type:"chooseDir"},title:_T("mediaservice","select_folder"),folderToolbar:!0,listeners:{scope:this,choose:function(e,t,i){this.reportSavePath.setValue(t.fullpath),e.close()},close:function(){delete this.pathSelector}}})),this.pathSelector.show()},initFbar:function(){return{useStatusBar:!0,buttons:[{xtype:"syno_button",text:_T("common","cancel"),minWidth:80,autoHeight:!0,scope:this,handler:this.cancelHandler},{xtype:"syno_button",btnStyle:"blue",text:_T("autoblock","autoblock_export_ip_list"),minWidth:80,autoHeight:!0,scope:this,handler:this.applyHandler}]}},applyHandler:function(){if(!this.reportSavePath.isValid())return void this.setStatusError({text:_T("error","error_bad_field"),clear:!0});!1!==this.createReport()||this.setStatusError({text:_T("mediaservice","select_one"),clear:!0})},cancelHandler:function(){this.close()},createReport:function(){var e=[],t=this.reportSavePath.value;return this.treePanel.collectFolderList(e),0!==e.length&&(this.owner.sendWebAPI({api:"SYNO.Core.Share.PermissionReport",version:1,method:"export",params:{folders:e,save_path:t},scope:this,callback:function(e,t,i){t.task_id&&t.bg_taskid&&e?(this.task_id=t.task_id,this.bg_taskid=t.bg_taskid,Ext.isDefined(t.filename)&&(this.reportName=t.filename),this.startExport()):this.showDebugMsgBox(_T("error","error_error_system"))}}),!0)},startExport:function(){this.getMsgBox().show({width:150,closable:!1,progress:!1,buttons:{ok:_T("common","hide"),cancel:_T("common","cancel")},fn:function(e,t,i){"ok"===e?(this.stopPermissionReportPolling(),this.closeMsgBox(),this.close()):this.stopExport()}.createDelegate(this),msg:_T("perm_report","exporting_desc"),scope:this}),this.module.panel.permission_report_export_pollingId=this.pollReg({webapi:{api:"SYNO.Core.Share.PermissionReport",method:"export_status",version:1,params:{task_id:this.task_id}},interval:2,immediate:!1,scope:this,status_callback:function(e,t,i,s){var n=t.data;if(e)if(t.finish||"success"===n.status)this.stopExport();else if("initializing"===n.status);else if("scanning"===n.status){let e=Ext.util.Format.number(n.output,"0,000"),t=String.format(_T("perm_report","export_progress_desc"),e),i=String.format("
{0}
{1}
",_T("perm_report","exporting_desc"),t);this.getMsgBox().updateProgress("","",i,!0)}else n.status,this.stopExport();else{let e=SYNO.API.getErrorString(t.code);this.getMsgBox().alert("",e,function(){this.stopExport()}.createDelegate(this))}}})},stopExport:function(){this.stopExportPermissionReport(),this.stopPermissionReportPolling(),this.closeMsgBox(),this.applyDone()},stopExportPermissionReport:function(){this.sendWebAPI({api:"SYNO.Core.Share.PermissionReport",version:1,method:"export_stop",params:{task_id:this.task_id,bg_taskid:this.bg_taskid},scope:this})},stopPermissionReportPolling:function(){this.module.panel.stopPermissionReportPolling()},closeMsgBox:function(){this.getMsgBox().getDialog().doClose()},applyDone:function(){this.close()},numberWithCommas:function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},showDebugMsgBox:function(e){this.getMsgBox().alert("",e,function(){this.closeMsgBox(),this.close()}.createDelegate(this))}}),Ext.define("SYNO.SDS.AdminCenter.Share.PermissionReport.TreePanel",{extend:"SYNO.ux.TreePanel",constructor:function(e){this.uiProvider=SYNO.SDS.AdminCenter.Share.PermissionReport.TreeNodeUI,this.callParent([this.fillConfig(e)]),this.mon(this,"checkchange",this.onCheckChange,this)},fillConfig:function(e){var t=new SYNO.SDS.AdminCenter.Share.PermissionReport.TreeLoader({owner:this,nodeUI:this.uiProvider}),i=Ext.apply({useArrows:!0,autoScroll:!0,border:!1,region:"center",containerScroll:!0,animate:!0,enableDD:!1,useGradient:!1,loader:t,rootVisible:!1,root:new Ext.tree.AsyncTreeNode({draggable:!1,id:"root"})},e);return Ext.apply(i,e)},load:function(){this.sendWebAPI({api:"SYNO.Core.File",method:"list",version:1,params:{needrw:!1,folder_path:"/",support_enum_cold_storage:!0,node:"fm_root"},callback:function(e,t,i){if(!e)return void this.getMsgBox().alert("",SYNO.API.getErrorString(t.code));let s=[];Ext.each(t,function(e){Ext.isDefined(e.id)&&Ext.isDefined(e.path)&&s.push(e)},this),this.createShareNode(s)},scope:this})},createShareNode:function(e){let t="fm_root_"+this._S("hostname"),i=this.createTreeLoader(e);this.shareNode=t,this.root.appendChild({id:t,expanded:!0,leaf:!1,text:this._S("hostname"),loader:i,checked:!1},this)},createTreeLoader:function(e){return new SYNO.SDS.AdminCenter.Share.PermissionReport.TreeLoader({owner:this,nodeData:e,nodeUI:this.uiProvider,sendWebAPI:this.sendWebAPI.createDelegate(this)})},onCheckChange:function(e){var t,i=e.getUI(),s=function(e){var t=0,i=0;return e.eachChild(function(e){var s=e.getUI()||{};s.checkbox&&Ext.isFunction(s.getCheckValue)&&(!1===s.getCheckValue()&&(i+=1),t+=1)}),0===t?e.getUI().getCheckValue():i!==t&&"gray"},n=function(e,t){e.eachChild(function(e){e.getUI().setCheckValue(t),n(e,t)})};if(!1===(t=i.getCheckValue()))this.isShareNode(e)?i.setCheckValue("gray"):i.setCheckValue(!0),n(e,!0);else{if(!0!==t&&"gray"!==t)return void SYNO.Debug("Unexpected checked value: ",t);i.setCheckValue(!1),n(e,!1)}!function(e){for(var t,i,n,o=e.parentNode,a=!0;o&&(t=o.getUI())&&o.attributes&&o.attributes.hasOwnProperty("checked")&&(!0===(n=t.getCheckValue())?a=!1:n===(i=s(o))?a=!1:(t.setCheckValue(i),o=o.parentNode),a););}(e)},isShareNode:function(e){return this.shareNode===e.id},collectFolderList:function(e){var t;t=this.getNodeById(this.shareNode),Ext.each(t.childNodes,function(t){this.setFolderList(t,e)},this)},setFolderList:function(e,t){var i;Ext.isDefined(e)&&Ext.isDefined(e.attributes)?(!0===e.attributes.checked&&(i=e.attributes.additional.real_path,i=e.expanded?i.concat("/"):i.concat("/*"),t.push(i)),("gray"===e.attributes.checked||!0===e.attributes.checked&&!0===e.expanded)&&Ext.each(e.childNodes,function(e){this.setFolderList(e,t)},this)):SYNO.Debug("In setFolderList, sth undefined: ",e)}}),Ext.define("SYNO.SDS.AdminCenter.Share.PermissionReport.TreeLoader",{extend:"Ext.tree.TreeLoader",constructor:function(e){this.dataUrl="dummy",this.callParent([e])},checkEncryption:function(e){if(Ext.isArray(e.encryption)&&!Ext.isEmpty(e.params))for(var t=e.encryption,i=0,s=t.length;i
','',this.indentMarkup,"",'','','",'',o(e.text),"","
",'',""].join("");!0!==s&&e.nextSibling&&(n=e.nextSibling.ui.getEl())?this.wrap=Ext.DomHelper.insertHtml("beforeBegin",n,l):this.wrap=Ext.DomHelper.insertHtml("beforeEnd",i,l),this.elNode=this.wrap.childNodes[0],this.ctNode=this.wrap.childNodes[1];var d=this.elNode.childNodes,c=0;this.indentNode=d[c++],this.ecNode=d[c++],this.checkbox=d[c++],this.iconNode=d[c++],(t.icon||t.iconCls)&&c++,this.anchor=d[c++],this.textNode=this.anchor.firstChild,a&&(this.createInputField(a,t,this.elNode),c++),this.syncCheckCssClass(),e.on("disabledchange",this.onDisabled,this)},onIdChange:function(e){var t=Ext.util.Format.htmlEncode;this.rendered&&this.elNode.setAttribute("ext:tree-node-id",t(e))},createInputField:function(e,t,i){var s=e;switch(Ext.isObject(e)?(this.inputConfig=Ext.apply({},e),s=e.xtype||"textfield",delete e.xtype):this.inputConfig={},Ext.isDefined(t.value)&&(this.inputConfig.value=t.value),this.inputConfig.renderTo=i,s){case"textfield":this.input=new SYNO.ux.TextField(this.inputConfig);break;case"numberfield":this.input=new SYNO.ux.NumberField(this.inputConfig)}},initEvents:function(){return this.callParent(arguments)},isDisabled:function(){return!0===this.node.disabled},onClick:function(e){if(!e.getTarget(".x-form-field"))return e.getTarget(".syno-tree-node-cb")&&this.toggleCheck(),this.callParent(arguments)},onDblClick:function(e){e.getTarget(".syno-tree-node-cb")||this.disabled||!1!==this.fireEvent("beforedblclick",this.node,e)&&(!this.animating&&this.node.isExpandable()&&this.node.toggle(),this.fireEvent("dblclick",this.node,e))},onDisabled:function(e,t){this.input&&(t?this.input.disable():this.input.enable()),this.checkbox&&(t?this.checkbox.classList.add("syno-ux-cb-disabled"):this.checkbox.classList.remove("syno-ux-cb-disabled"))},onCheckChange:function(){this.fireEvent("checkchange",this.node)},getExpanded:function(){return this.node.expanded},getCheckValue:function(){return this.node.attributes.checked},setCheckValue:function(e){this.node.disabled||e!==this.getCheckValue()&&(e="false"!==e&&"off"!==e&&"0"!==e&&("gray"===e?"gray":!!e),this.node.attributes.checked=e,this.syncCheckCssClass())},syncCheckCssClass:function(){var e=this.getCheckValue();this.checkbox&&(Ext.each(["checked","grayed","disabled"],function(e){this.checkbox.classList.remove("syno-ux-cb-"+e)},this),!0===e?this.checkbox.classList.add("syno-ux-cb-checked"):"gray"===e&&this.checkbox.classList.add("syno-ux-cb-grayed"),this.node.disabled&&this.checkbox.classList.add("syno-ux-cb-disabled"))}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.CleanHomeRecycleDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.panel=this.createFormPanel();let t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){return Ext.apply({title:_T("share","share_clean_recycle_bin"),autoDestroy:!0,width:500,height:250,resizable:!1,items:[this.panel],buttons:[{text:_T("common","cancel"),btnStyle:"grey",scope:this,handler:this.close},{btnStyle:"blue",itemId:"continue",text:_T("common","continue"),disabled:!0,scope:this,handler:this.apply}]},e)},createFormPanel:function(){let e={border:!1,autoHeight:!0,trackResetOnLoad:!0,items:[{xtype:"syno_displayfield",value:_T("share","clean_home_recycle_bin_select_desc")},{xtype:"syno_checkbox",name:"clean_homes_recycle_bin",boxLabel:_T("share","clean_homes_recycle_bin"),listeners:{check:{fn:this.onCheck,scope:this}}},{xtype:"syno_checkbox",name:"clean_home_recycle_bin",boxLabel:_T("share","clean_home_recycle_bin"),listeners:{check:{fn:this.onCheck,scope:this}}}]};return new SYNO.SDS.Utils.FormPanel(e)},onCheck:function(){let e=this.panel.getForm().findField("clean_home_recycle_bin").getValue()||this.panel.getForm().findField("clean_homes_recycle_bin").getValue();this.getFooterToolbar().getComponent("continue").setDisabled(!e)},apply:function(){let e=[];this.panel.getForm().findField("clean_home_recycle_bin").getValue()&&e.push({id:"home"}),this.panel.getForm().findField("clean_homes_recycle_bin").getValue()&&e.push({id:"homes"}),this.callback.call(this.owner,e),this.close()}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),SYNO.SDS.AdminCenter.Share.LocalStore="/usr/syno/etc/.encrypt",SYNO.SDS.AdminCenter.Share.GetPoolList=async function(){let e={};try{e=(await this.sendWebAPIPromise({api:"SYNO.Core.Storage.Pool",method:"list",params:{limit:-1,offset:0},version:1})).pools}catch(e){}return e},Ext.define("SYNO.SDS.AdminCenter.Share.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(),this.panel=new SYNO.SDS.AdminCenter.Share.Panel({module:this,appWin:e.appWin})},activate:function(e){return this.setActivateParams(e),!0},focus:function(e){this.setActivateParams(e),this.panel.store.load()},getPanel:function(){return this.panel},getHelpParam:function(){return"AdminCenter/file_share_desc.html"},deactivate:function(){return!0},setActivateParams:function(e){e&&(e.c2share_name&&(this.toggleC2ShareOnLoad=e.c2share_name),"create"===e.dlg?this.panel.launchShareDialog({mode:"create",type:e.type}):"clone"===e.dlg?this.panel.launchShareDialog({mode:"clone",blNfsEnabled:e.params.blNfsEnabled,blNfsEncryptShareSupport:e.params.nfsEncryptShareSupport,blKerberosSupport:e.params.blKerberosSupport,blKerberosEnabled:e.params.blKerberosEnabled,share:e.params.share,snapshot:e.params.snapshot}):"edit"===e.dlg&&this.panel.launchShareDialog({mode:"edit",blNfsEnabled:e.params.blNfsEnabled,blNfsEncryptShareSupport:e.params.nfsEncryptShareSupport,blKerberosSupport:e.params.blKerberosSupport,blKerberosEnabled:e.params.blKerberosEnabled,share:e.params.share,startTabId:e.params.tabId}))}}),Ext.define("SYNO.SDS.AdminCenter.Share.Panel",{extend:"SYNO.ux.Panel",title:"Panel for Share",share_move_pollingId:void 0,quota_update_pollingId:void 0,cls:"syno-share-panel",constructor:function(e){this.module=e,this.appWin=e.appWin,this.nfsEnabled=!1,this.nfsKerberosSupport=!1,this.nfsKerberosEnabled=!1,this.nfsEncryptShareSupport=!1,this.supportShareSnapshot="yes"===this._D("support_share_snapshot","no"),this.supportShareQuota="yes"===this._D("support_share_quota","no"),this.supportBtrfs="yes"===this._D("support_btrfs","no"),this.c2fsPkgName="SYNO.SDS.C2FS.Application",this.initC2Setting(),this.initWebAPI();var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"show",this.showHandler,this),this.mon(this,"sharefolderchanged",function(e){this.scrollShareName=e,this.showHandler()},this),this.mon(this.store,"load",this.checkShareMovePolling,this),this.mon(this.store,"load",this.checkQuotaUpdatePolling,this),this.mon(this,"afterrender",function(){this.mon(this.el,"keydown",function(e){e.getKey()==e.DELETE&&this.deleteHandler()},this)},this),this.initC2Event()},fillConfig:function(e){this.store=this.createStore(e),this.view=this.createView(this.store),this.actionGroup=this.createActionGroup(),this.tbar=this.createTBar();var t={tbar:this.tbar,layout:"fit",enableHdMenu:!1,bbar:new SYNO.ux.PageLessToolbar({store:this.store,pageSize:-1,displayInfo:!0,displayButtons:!1}),items:[this.view],listeners:{scope:this,rowdblclick:{scope:this,fn:function(e,t,i){var s=this.store.getAt(t);s&&-1===s.data.vol_path.indexOf("Gluster")&&this.launchShareDialog({share:s})}}}};return Ext.apply(t,e),t},initWebAPI:function(){this.webapiNfsGet={api:"SYNO.Core.FileServ.NFS",version:1,method:"get"},this.webapiNfsKerberosGet={api:"SYNO.Core.FileServ.NFS.Kerberos",version:1,method:"get"},this.webapiKeyManagerExplore={api:"SYNO.Core.Share.KeyManager.Store",version:1,method:"explore"},this.webapiKeyManagerKeyList={api:"SYNO.Core.Share.KeyManager.Key",version:1,method:"list"},this.webapiStorageGet={api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{limit:-1,offset:0,location:""===this._D("usbstation")?"internal":"external",option:"include_cold_storage"}}},showHandler:function(){if(this._S("is_admin")){var e=[];e.push(this.webapiNfsGet),e.push(this.webapiNfsKerberosGet),e.push(this.webapiKeyManagerExplore),e.push(this.webapiKeyManagerKeyList),e.push(this.webapiStorageGet),this.appWin.setStatusBusy({text:_T("common","msg_waiting")}),this.appWin.sendWebAPI({compound:{stopwhenerror:!1,params:e},timeout:6e5,scope:this,callback:function(e,t,i){this.appWin.clearStatusBusy(),e?this.afterLoad(t):this.appWin.setStatusError()}})}else this.store.load()},appLaunchStorageManager:async function(){var e=_T("volume","volume_share_volume_create"),t=_T("volume","create_volume"),i="volume";0===(await SYNO.SDS.AdminCenter.Share.GetPoolList.call(this)).length&&(e=_T("volume","volume_share_pool_create"),t=_T("volume","volume_raid_creation_title"),i="both"),this.appWin.getMsgBox().alert(this.title,e,function(){SYNO.SDS.AppLaunch("SYNO.SDS.StorageManager.Instance",{fn:"SYNO.SDS.StorageManager.Pool.Main",vueWizard:"CreateWizard",modalParam:{width:820,height:560,title:t,mode:i}}),this.appWin.close()},this)},afterLoad:function(e){if(e.result.forEach(function(e){if(!0===SYNO.ux.Utils.checkApiConsistency(this.webapiNfsGet,e))this.nfsEnabled=e.data.enable_nfs,this.nfsEncryptShareSupport=e.data.support_encrypt_share;else if(!0===SYNO.ux.Utils.checkApiConsistency(this.webapiNfsKerberosGet,e))this.nfsKerberosSupport=e.data.kerberos_support,this.nfsKerberosEnabled=00,this.keyManagerLocation=e.data.stores[0];else if(!0===SYNO.ux.Utils.checkApiConsistency(this.webapiKeyManagerKeyList,e)){if(this.keyManagerKeyList={},e&&e.data&&e.data.keys)for(var t=0;t`},sharedFolderSizeRenderer:function(e,t,i){return"updating"===e&&Ext.isNumber(t)?String.format("{0} ({1}%) {2}",_T("share","share_quota_status_calculating"),t.toFixed(1),this.makeWhiteTip(_T("share","share_quota_calculating_progress_desc"))):"incompatible"===e||"ready_to_update"===e?String.format("{0} {1}",_T("share","share_quota_status_unsupported"),this.makeWhiteTip(_T("share","unable_to_get_share_size"))):Ext.isNumber(i)?SYNO.SDS.Utils.CapacityRender(i,2):null},checkQuotaUpdatePolling:function(){var e=!1;this.quota_update_pollingId||(this.store.data.items.forEach(function(t){if("updating"===t.json.share_quota_status)return e=!0,!1}),e&&(this.quota_update_pollingId=this.pollReg({webapi:{api:"SYNO.Core.Share",method:"list",version:1,params:{additional:["share_quota"]}},interval:5,immediate:!0,scope:this,status_callback:function(e,t,i,s){let n=this,o=t.shares,a=!1;if(e&&void 0!==o&&Array.isArray(o)){let e={};o.forEach(function(t){void 0!==t.name&&(e[t.name]=t)}),this.store.data.items.forEach(function(t){let i=e[t.json.name];if(void 0===i)return!0;"updating"===i.share_quota_status&&(a=!0),t.set("quota_value",n.sharedFolderQuotaRenderer(i.share_quota_status,i.quota_value)),t.set("share_quota_used",n.sharedFolderSizeRenderer(i.share_quota_status,i.share_quota_update_progress,i.share_quota_used))}),a||this.stopQuotaUpdatePolling()}}})))},stopQuotaUpdatePolling:function(){this.quota_update_pollingId&&(this.pollUnreg(this.quota_update_pollingId),this.quota_update_pollingId=void 0)},stopPermissionReportPolling:function(){this.permission_report_export_pollingId&&(this.pollUnreg(this.permission_report_export_pollingId),this.permission_report_export_pollingId=void 0)},isSelectedShareInKeyManager:function(e){for(var t=!0,i=0;i",new SYNO.ux.TextFilter({iconStyle:"filter",emptyText:_T("common","filter_label_text"),itemId:"search",localFilter:!0,localFilterField:["title","status"],tabIndex:-1,blOr:!0,store:this.store}),new Ext.Spacer({width:6}),new SYNO.SDS.AdminCenter.Share.SortButton({appWin:this.appWin,owner:this,menuItems:[{text:_T("pkgmgr","sort_by_name"),sortField:"title",handler:this.onSort,scope:this},{text:_T("volume","volume"),sortField:"vol_path",handler:this.onSort,scope:this}]})]})},onSort:function(e,t){var i=this.store.getSortState(),s="ASC";i.field===e.sortField&&(s="ASC"===i.direction?"DESC":"ASC"),this.store.sort(e.sortField,s)},initC2Setting:function(){this.isC2PkgStatusStart=SYNO.SDS.StatusNotifier.isAppEnabled(this.c2fsPkgName)},isSupportC2:function(){return"yes"===this._D("support_c2fs","no")&&"Beijing"!==_S("timezone")},isSupportTransformToC2:function(){return this.isSupportC2()&&SYNO.SDS.C2FS&&SYNO.SDS.C2FS.UtilForDSM&&Ext.isFunction(SYNO.SDS.C2FS.UtilForDSM.canTransformToC2Share)&&Ext.isFunction(SYNO.SDS.C2FS.UtilForDSM.initTransformC2ShareWizard)},canTransformToC2Share:function(e){return!0===this.isC2PkgStatusStart&&SYNO.SDS.C2FS&&SYNO.SDS.C2FS.UtilForDSM&&Ext.isFunction(SYNO.SDS.C2FS.UtilForDSM.canTransformToC2Share)&&SYNO.SDS.C2FS.UtilForDSM.canTransformToC2Share(e)},initC2Event:function(){this.isSupportC2()&&(this.isC2PkgStatusStart&&SYNO.SDS.JSLoad(this.c2fsPkgName,function(){this.isSupportTransformToC2()&&this.actionGroup.get("action").initialConfig.menu.get("transform_to_c2share").show()}.bind(this)),this.mon(this,"beforedestroy",function(){SYNO.SDS.Packages.unregisterPackageStatusChange(this.onC2PackageStatusChange,this)},this),SYNO.SDS.Packages.registerPackageStatusChange(this.onC2PackageStatusChange,this,"HybridShare"))},createActionGroup:function(){var e=this.supportShareSnapshot&&"yes"===this._D("support_btrfs","no"),t=new Ext.Action({text:_T("common","create"),itemId:"add",scope:this,hidden:e,handler:function(){this.launchShareDialog({mode:"create"})}}),i=new SYNO.ux.Menu({items:[{text:this.isSupportC2()?_T("share","create_share"):_T("common","create"),itemId:"create",scope:this,handler:function(){this.launchShareDialog({mode:"create"})}},{text:_T("share","create_c2_share_folder"),itemId:"c2_share_folder",scope:this,hidden:!this.isSupportC2(),disabled:!this.isC2PkgStatusStart,handler:function(){if(this.isC2PkgStatusStart)try{this.launchShareDialog({mode:"create",type:"c2_share"})}catch(e){this.appWin.getMsgBox().alert("alert",_T("error","error_error_system"))}else this.appWin.getMsgBox().alert("alert",String.format(_T("share","c2_need_package"),"C2FS"))}},{text:_T("iscsilun","clone"),itemId:"clone",scope:this,handler:function(){var e=this.view.getSelectedRecords()[0];e&&this.launchShareDialog({share:e,mode:"clone"})}}]}),s=new Ext.Action({text:_T("common","create"),itemId:"creation",hidden:!e,scope:this,menu:i}),n=new Ext.Action({text:_T("common","alt_edit"),itemId:"edit",scope:this,handler:function(){var e=this.view.getSelectedRecords();e&&e[0]&&this.launchShareDialog({share:e[0]})}}),o=new Ext.Action({text:_T("common","delete"),itemId:"delete",scope:this,handler:this.deleteHandler}),a=new Ext.Action({text:_T("keymanager","app_title"),itemId:"key_manager",scope:this,handler:this.keyManagerHandler});this.menuEncryption=new SYNO.ux.Menu({items:[{text:_T("share","share_encryption_encrypt"),itemId:"encrypt",scope:this,handler:this.encryptHandler},{text:_T("share","share_encryption_decrypt"),itemId:"decrypt",scope:this,handler:this.decryptHandler},{text:_T("share","share_encryption_exportkey"),itemId:"exportkey",scope:this,handler:this.exportKeyHandler},a]});var r=new Ext.Action({text:_T("share","share_encryption"),itemId:"encryption",hidden:"no"===this._D("support_share_encryption","no")||!this._S("is_admin"),scope:this,menu:this.menuEncryption}),l=new Ext.Action({text:_T("share","share_clean_all_recycle_bin"),scope:this,hidden:!1,handler:this.cleanRecycleHandler}),d=new Ext.Action({text:_T("network","cifs_recycle_bin_set_clean_policy"),itemId:"new_recycle_policy",scope:this,hidden:!1,handler:this.newRecyclePolicyHandler}),c=new Ext.Action({text:_T("sharemigrate","button"),itemId:"migrate",hidden:"yes"!==this._D("support_synoacl"),scope:this,handler:this.migrateHandler}),h=new Ext.Action({text:_T("perm_report","export_report_title"),itemId:"perm_report",hidden:"yes"!==this._D("support_synoacl")||!this._S("is_admin"),scope:this,handler:this.permissionReportHandler}),u=new Ext.Action({text:_T("share","c2_transform_to_c2share"),itemId:"transform_to_c2share",hidden:!0,disabled:!0,scope:this,handler:this.transformToC2Handler});this.menuOtherActions=new SYNO.ux.Menu({items:[l,d,c,h,u]});var p=new Ext.Action({text:_T("rcpower","action"),itemId:"action",hidden:!this._S("is_admin"),scope:this,menu:this.menuOtherActions});return new SYNO.ux.Utils.ActionGroup([t,s,n,o,r,p])},onContainerContextMenu:function(e,t){var i=this.view.getSelectedIndexes(),s=this.view.getSelectedNodes();this.onContextMenu(e,i[0],s[0],t)},onContextMenu:function(e,t,i,s){for(var n=this.view.getSelectedRecords(),o=0;o`:e.is_share_moving?_T("share","share_moving"):e.is_force_readonly?_T("common","readonly"):e.is_applying_settings?_T("common","applying_settings"):""},conditionClsRenderer:function(e){return e.is_offline_share?"item-status":e.is_share_moving||e.is_applying_settings?"blue-status":e.is_force_readonly?"orange-status":""},volumeRenderer:function(e){if(-1!==e.vol_path.indexOf("usb"))return!1===e.is_usb_share?e.display_vol_name:"SDCARD"===e.external_dev_type?_T("tree","leaf_sdcard"):_T("status","status_usb");if(-1!==e.vol_path.indexOf("sata"))return _T("status","status_sata");if(-1!==e.vol_path.indexOf("Gluster"))return _T("status","status_gluster");var t=this.volumes.find(function(t){return t.volume_path==e.vol_path}),i=e.vol_path.replace("/volume",""),s=Ext.util.Format.htmlEncode(Ext.isObject(t)?t.description:"");return Ext.isDefined(s)&&""!==s?String.format("{0} {1} ({2})",_T("volume","volume"),i,s):String.format("{0} {1}",_T("volume","volume"),i)},createStore:function(e){var t=this,i=["hidden","encryption","is_aclmode","unite_permission","is_support_acl","is_sync_share","is_force_readonly","force_readonly_reason","recyclebin","is_share_moving","is_cluster_share","is_exfat_share","is_c2_share","is_cold_storage_share","is_missing_share","is_offline_share"],s=[{name:"title",sortType:"asNaturalUCString",mapping:"name"},{name:"status",convert:function(e,i){return!0===i.is_missing_share?t.volumeRenderer(i)+" "+_T("volume","space_missing"):!0===i.is_cluster_share?_T("share","peta_share_control_panel_vol_desc"):t.volumeRenderer(i)}},{name:"condition",convert:function(e,i){return t.conditionRenderer(i)}},{name:"iconCls",convert:function(e,t){return!0===t.is_missing_share||!0===t.is_offline_share?"item-icon-missing":""}},{name:"statusIconCls",convert:function(e,t){if(t.is_c2_share)return"syno-admincenter-c2share-icon";switch(t.encryption){case 0:return t.enable_share_compress?"syno-admincenter-share-compression":"default";case 1:return"syno-admincenter-share-lock";case 2:return"syno-admincenter-share-unlock";default:return"default"}}},{name:"conditionCls",convert:function(e,i){return t.conditionClsRenderer(i)}},{name:"unite_permission",convert:function(e,t){return e?_T("common","enabled"):_T("common","disabled")}},{name:"enable_recycle_bin",convert:function(e,t){return e?_T("common","enabled"):_T("common","disabled")}},{name:"force_readonly_reason",convert:function(e,t){return SYNO.SDS.Utils.GetFeasibilityCheckMsg(e)}},{name:"is_support_quota",convert:function(e,i){return t.supportShareQuota&&Ext.isDefined(i.share_quota_status)}},{name:"is_btrfs_share",convert:function(e,i){return t.supportBtrfs&&Ext.isDefined(i.enable_share_compress)&&Ext.isDefined(i.enable_share_cow)}},"name","desc","hidden","vol_path","encryption","is_aclmode","is_support_acl","is_usb_share","is_sync_share","display_vol_name","external_dev_type","support_action","is_force_readonly","is_share_moving","is_applying_settings","task_id","is_cluster_share","is_exfat_share","cluster_share_mount","is_c2_share","is_cold_storage_share","is_missing_share","is_offline_share"];return this.supportShareSnapshot&&(i=i.concat(["support_snapshot"]),s=s.concat(["support_snapshot"])),this.supportShareQuota&&(i=i.concat(["share_quota"]),s=s.concat([{name:"quota_value",convert:function(e,i){return t.sharedFolderQuotaRenderer(i.share_quota_status,e)}},{name:"share_quota_used",convert:function(e,i){return t.sharedFolderSizeRenderer(i.share_quota_status,i.share_quota_update_progress,e)}}])),this.supportBtrfs&&(i=i.concat(["enable_share_compress","enable_share_cow"]),s=s.concat([{name:"enable_share_compress",convert:function(e,t){var i=t.share_quota_logical_size-t.share_quota_used,s=t.share_quota_logical_size?i/t.share_quota_logical_size*100:0;return e?t.support_compression_ratio&&0<=i?String.format("{0} {1} ({2}%)",_T("share","saved"),SYNO.SDS.Utils.CapacityRender(i,2),s.toFixed(1)):_T("common","enabled"):_T("common","disabled")}},{name:"enable_share_cow",convert:function(e,t){return e?_T("common","enabled"):_T("common","disabled")}}])),new SYNO.API.JsonStore({fields:s,api:"SYNO.Core.Share",method:"list",version:1,idProperty:"name",totalProperty:"total",remoteSort:!1,defaultSortable:!0,sortInfo:{field:"title",direction:"ASC"},baseParams:{additional:i.concat(["include_cold_storage_share","is_cold_storage_share","include_missing_share","is_missing_share","include_offline_share","is_offline_share"]),shareType:"all"},root:"shares",appWindow:this.appWin,scope:this,listeners:{beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:this.onLoad},exception:{scope:this,fn:function(e,t,i,s,n,o){this.findAppWindow().getMsgBox().alert("warning_msg",SYNO.API.getErrorString(n.code)),this.findAppWindow().clearStatusBusy()}}}})},createView:function(e){var t=new SYNO.SDS.AdminCenter.Share.ListView({itemId:"listview",store:e});return t.mon(t,"selectionchange",this.onSelectionChange,this),t.mon(t,"containercontextmenu",this.onContainerContextMenu,this),t.mon(t,"contextmenu",this.onContextMenu,this),t},descRenderer:function(e,t,i){e=Ext.util.Format.htmlEncode(e);var s=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+s+'"',e},onBeforeLoad:function(){return Ext.isDefined(this.volumeInfoIsLatest)?(delete this.volumeInfoIsLatest,!0):(this.appWin.setStatusBusy({text:_T("common","msg_waiting")}),this.appWin.sendWebAPI({api:"SYNO.Core.Storage.Volume",method:"list",version:1,scope:this,params:{limit:-1,offset:0,location:""===this._D("usbstation")?"internal":"external"},callback:function(e,t,i){e?(this.volumes=t.volumes,this.volumeInfoIsLatest=!0,this.store.load()):(this.appWin.clearStatusBusy(),this.appWin.setStatusError())}}),!1)},onC2PackageStatusChange:function(e){(function(){return!1===this.isC2PkgStatusStart&&"start"===e||!0===this.isC2PkgStatusStart&&"start"!==e}).bind(this)()&&(this.isC2PkgStatusStart=SYNO.SDS.StatusNotifier.isAppEnabled(this.c2fsPkgName),this.isSupportTransformToC2()?this.actionGroup.get("action").initialConfig.menu.get("transform_to_c2share").show():this.actionGroup.get("action").initialConfig.menu.get("transform_to_c2share").hide(),this.isC2PkgStatusStart?this.actionGroup.get("creation").initialConfig.menu.get("c2_share_folder").enable():this.actionGroup.get("creation").initialConfig.menu.get("c2_share_folder").disable(),this.loadC2Info())},loadC2Info:function(){if(!this.isC2PkgStatusStart)return this.view.reloadTpl(),void this.store.each(function(e){!1!==e.get("is_c2_share")&&(e.set("condition",_T("share","c2_no_package_status")),e.set("conditionCls","red-status"))});SYNO.SDS.JSLoad(this.c2fsPkgName,function(){this.view.reloadTpl(),SYNO.SDS.C2FS.UtilForDSM.fetchInfoOfC2Share(this.store)},this,function(){this.view.reloadTpl(),this.store.each(function(e){!1!==e.get("is_c2_share")&&(e.set("condition",_T("share","c2_no_package_status")),e.set("conditionCls","red-status"))})})},onLoad:function(e,t,i){if(this.loadC2Info(),this.appWin.clearStatusBusy(),this.onSelectionChange(),0===this.store.data.length){var s=this.actionGroup;s.disableAll();var n=s.get("creation").initialConfig.menu.get("clone");return s.enable("add"),s.enable("creation"),void n.disable()}if(void 0!==this.module.toggleC2ShareOnLoad){var o=this.module.toggleC2ShareOnLoad,a=e.indexOfId(o);if(-1===a)return;this.view.select(a),this.view.toggledItemIds.includes(o)||this.view.toggleSelectedItem(),delete this.module.toggleC2ShareOnLoad}if(Ext.isDefined(this.scrollShareName)){var r=this.scrollShareName;delete this.scrollShareName;var l=e.indexOfId(r);-1!==l&&(this.view.select(l),this.view.ensureVisible(l))}},launchShareDialog:function(e,t,i){if("clone"===e.mode||"create"===e.mode){var s=this._D("maxshares");if(s<=this.store.getTotalCount())return void this.findAppWindow().getMsgBox().alert(this.title,String.format(_T("share","error_toomanysh"),s))}var n,o,a=this.store.getTotalCount();if("clone"===e.mode)n=new SYNO.SDS.AdminCenter.Share.Dialog(Ext.apply({module:this.module,owner:this.module.appWin,blNfsEnabled:void 0!==e.blNfsEnabled?e.blNfsEnabled:this.nfsEnabled,blNfsEncryptShareSupport:void 0!==e.blNfsEncryptShareSupport?e.blNfsEncryptShareSupport:this.nfsEncryptShareSupport,blKerberosSupport:void 0!==e.blKerberosSupport?e.blKerberosSupport:this.nfsKerberosSupport,blKerberosEnabled:void 0!==e.blKerberosEnabled?e.blKerberosEnabled:this.nfsKerberosEnabled,blKeyManagerEnabled:this.keyManagerEnabled,keyManagerLocation:this.keyManagerLocation,mode:"clone"},e)),o=e.share.get("encryption");else if("create"===e.mode)if("c2_share"===e.type){var r=SYNO.SDS.C2FS.UtilForDSM.getAndCheckNotSupportReason();if(""!==r)return void this.appWin.getMsgBox().alert("alert",r);n=SYNO.SDS.C2FS.UtilForDSM.initCreateC2ShareWizard(Ext.apply({width:820,height:560,module:this.module,owner:this.appWin},e))}else n=new SYNO.SDS.AdminCenter.Share.CreateWizard(Ext.apply({module:this.module,owner:this.module.appWin,store:this.store,blNfsEnabled:this.nfsEnabled,blNfsEncryptShareSupport:this.nfsEncryptShareSupport,blKerberosSupport:this.nfsKerberosSupport,blKerberosEnabled:this.nfsKerberosEnabled,blKeyManagerEnabled:this.keyManagerEnabled,keyManagerLocation:this.keyManagerLocation,startTabId:t},e));else if(!0===e.share.get("is_c2_share")){if(!this.isC2PkgStatusStart)return void this.appWin.getMsgBox().alert("alert",String.format(_T("share","c2_need_package"),"C2FS"));n=SYNO.SDS.C2FS.UtilForDSM.initEditC2ShareWizard(Ext.apply({module:this.module,owner:this.module.appWin,blNfsEnabled:this.nfsEnabled,blNfsEncryptShareSupport:this.nfsEncryptShareSupport,blKerberosSupport:this.nfsKerberosSupport,blKerberosEnabled:this.nfsKerberosEnabled,blKeyManagerEnabled:this.keyManagerEnabled,keyManagerLocation:this.keyManagerLocation,startTabId:t,mode:"edit"},e))}else n=new SYNO.SDS.AdminCenter.Share.Dialog(Ext.apply({module:this.module,owner:this.module.appWin,blNfsEnabled:this.nfsEnabled,blNfsEncryptShareSupport:this.nfsEncryptShareSupport,blKerberosSupport:this.nfsKerberosSupport,blKerberosEnabled:this.nfsKerberosEnabled,blKeyManagerEnabled:this.keyManagerEnabled,keyManagerLocation:this.keyManagerLocation,startTabId:t,mode:"edit"},e));"clone"===e.mode&&0===o||"create"===e.mode?("clone"===e.mode&&0===o&&this.mon(n,"beforeclose",function(){var e=n.getCreateResult();e&&this.launchShareDialog({share:e},"sharegrid")},this,{single:!0}),a>=255?this.findAppWindow().getMsgBox().confirm(this.title,_T("share","error_toomanyafpsh")+" "+_T("common","ask_cont"),function(t){"yes"===t&&("create"===e.mode?n.onOpen():n.open())},this):"create"===e.mode?n.onOpen():n.open()):n.open()},migrateHandler:function(e,t){var i,s=this.view.getSelectedRecords()[0],n=[];s&&s.data&&s.data.name&&(n.push(s.data.name),i=new SYNO.SDS.AdminCenter.Share.Migrate.Wizard({targetShare:n,caller:this,module:this.module,owner:this.module.appWin}),SYNO.SDS.Utils.S2S.confirmIfSyncShareAffected(!1,{name:s.data.name,is_sync_share:s.data.is_sync_share,no_check_permission:!0},{dialogTitle:this.title,dialogMsg:_T("s2s","s2s_warn_share_change_priv"),dialogOwner:this.module.appWin,continueHandler:function(){i.open()},abortHandler:Ext.emptyFn,scope:this}))},permissionReportHandler:function(e,t){new SYNO.SDS.AdminCenter.Share.PermissionReport.Dialog({module:this.module,owner:this.module.appWin}).open()},transformToC2Handler:function(e,t){var i=this.view.getSelectedRecords()[0];i&&i.data&&i.data.name&&SYNO.SDS.C2FS.UtilForDSM.initTransformC2ShareWizard({module:this.module,owner:this.appWin,share:i}).open()},launchKeyManager:function(){var e=new SYNO.SDS.AdminCenter.Share.KeyManager({module:this.module,owner:this.module.appWin,shares:this.store.data.items,storeInRoot:this.keyManagerLocation===SYNO.SDS.AdminCenter.Share.LocalStore});e.open(),this.mon(e,"close",function(){this.showHandler()},this)},keyManagerHandler:function(e,t){this.sendWebAPI({api:"SYNO.Core.Share.KeyManager.Store",method:"explore",version:1,params:{},scope:this,callback:function(e,t,i){if(e)if(0===t.stores.length){var s=new SYNO.SDS.AdminCenter.Share.InitStore({share_module:this,module:this.module,owner:this.module.appWin,shares:this.store.data.items});s.open(),this.mon(s,"close",function(){this.keyManagerEnabled&&this.launchKeyManager()},this)}else this.keyManagerLocation=t.stores[0],this.launchKeyManager();else{var n=SYNO.API.Response.GetFirstError(t),o=SYNO.API.Errors.core[n.code]||_T("common","error_system");this.getMsgBox().alert("warning_msg",o)}}})},deleteHandler:function(){var e=this.view.getSelectedRecords();this.deleteShare(e)},newRecyclePolicyHandler:function(){var e=this.view.getSelectedRecords();this.module.appWin.startModule("SYNO.SDS.AdminCenter.TaskScheduler.Main",{newRecycleBinPolicy:!0,share:e})},cleanRecycleHandler:function(){if(this._S("demo_mode"))this.findAppWindow().getMsgBox().alert(this.title,_JSLIBSTR("uicommon","error_demo"));else{var e={yes:{text:Ext.MessageBox.buttonText.yes,btnStyle:"red"},no:{text:Ext.MessageBox.buttonText.no}};this.findAppWindow().getMsgBox().confirmDelete(_T("share","share_clean_recycle_bin"),_T("share","share_all_recycle_bin_clean_warn"),function(e){"yes"===e&&this.sendWebAPI({api:"SYNO.Core.RecycleBin",method:"start",version:1,prams:{}})},this,e)}},deleteShare:function(e){if(e){var t={normal:[],c2:[]},i=[],s=[],n=!1;if(Ext.each(e,function(e,i,o){-1!==e.get("vol_path").indexOf("Gluster")?s.push(e.get("name")):!0===e.get("is_c2_share")?t.c2.push(e.get("name")):t.normal.push(e.get("name")),!0===e.get("is_btrfs_share")&&(n=!0)},this),0!==s.length)return this.errorGlusterMsg(s.join(", ")),!1;if(0!==t.normal.length||0!==t.c2.length){if(i.push({api:"SYNO.Core.Share",method:"validate_delete",params:{name:t.normal}}),0!==t.c2.length){if(!this.isC2PkgStatusStart)return void this.appWin.getMsgBox().alert("alert",String.format(_T("share","c2_need_package"),"C2FS"));i.push({api:"SYNO.C2FS.Share",method:"validate_delete",params:{name:t.c2}})}this.module.appWin.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({compound:{mode:"parallel",params:i},timeout:6e5,version:1,scope:this,callback:function(e,i,s){this.module.appWin.clearStatusBusy();var o=SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Share","validate_delete"),a=SYNO.API.Response.GetValByAPI(i,"SYNO.C2FS.Share","validate_delete");if(i.has_fail){var r={},l=o&&o.errors?o.errors:{},d=a&&a.errors?a.errors:{};Object.keys(l).forEach(function(e){Array.isArray(l[e])&&(r[e]=l[e].concat(d[e]))}),Object.keys(d).forEach(function(e){Array.isArray(d[e])&&!r.hasOwnProperty(e)&&(r[e]=d[e])}),Object.keys(r).forEach(function(e){r[e]=r[e].filter(function(e){return e})});var c=this.combineWarningMsg(r);try{SYNO.SDS.C2FS.UtilForDSM.exclusiveValidateDeleteWarnMsg(a).forEach(function(e){c.push(e)})}catch(e){}return 0===c.length&&c.push(_T("common","error_system")),this.module.appWin.getMsgBox().alert("warning_msg",c.join("")),!1}o||a?this.warningConfirm(i,t,n):this.loadDeleteDialog(i,t,n)}})}}},errorGlusterMsg:function(e){var t;return t=_T("share","share_gluster_share")+e,this.module.appWin.getMsgBox().alert("warning_msg",t),!1},warningConfirm:function(e,t,i){var s=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Share","validate_delete"),n=SYNO.API.Response.GetValByAPI(e,"SYNO.C2FS.Share","validate_delete"),o={warning_sd_destination:[],warning_usb_destination:[],warning_disable_service:[]};s&&(s.warning_sd_destination&&o.warning_sd_destination.push(s.warning_sd_destination),s.warning_usb_destination&&o.warning_usb_destination.push(s.warning_usb_destination),s.warning_disable_service&&o.warning_disable_service.push(s.warning_disable_service)),n&&(n.warning_sd_destination&&o.warning_sd_destination.push(n.warning_sd_destination),n.warning_usb_destination&&o.warning_usb_destination.push(n.warning_usb_destination),n.warning_disable_service&&o.warning_disable_service.push(n.warning_disable_service)),Object.keys(o).forEach(function(e){0!==o[e].length?o[e]=o[e].join(", "):delete o[e]});var a=this.combineWarningConfirm(o);0!==a.length?this.module.appWin.getMsgBox().confirmDelete("warning_msg",a,function(s,n,o){if("yes"===s){if(0===t.normal.length&&0===t.c2.length)return;this.loadDeleteDialog(e,t,i)}},this):this.loadDeleteDialog(e,t,i)},generatePackageWarningMsg:function(e,t){for(var i,s=[],n=0;n{1}
",t,e.join(", ")),i=String.format(i,s.join(", "))},combineWarningMsg:function(e){var t=[];if(e.hasOwnProperty("warning_external")){var i=String.format("{0}
{1}
",_T("share","share_cannot_delete_for_reserved"),e.warning_external.join(", "));t.push(i)}if(e.hasOwnProperty("warning_mount_point")){var s=String.format("{0}
{1}
",_T("share","error_mount_point_delete"),e.warning_mount_point.join(", "));t.push(s)}if(e.hasOwnProperty("warning_homes")){var n=String.format("{0}
{1}
",_T("share","error_home_service"),e.warning_homes.join(", "));t.push(n)}if(e.hasOwnProperty("warning_ftp_anonymousroot")){var o=String.format("{0}
{1}
",_T("share","error_ftp_anonymousroot"),e.warning_ftp_anonymousroot.join(", "));t.push(o)}if(e.hasOwnProperty("warning_ftp_userchroot")&&t.push(String.format("{0}
{1}
",_T("share",1==e.warning_ftp_userchroot.length?"error_ftp_userchroot":"error_ftp_userchroot_plural"),e.warning_ftp_userchroot.join(", "))),e.hasOwnProperty("warning_replica_demote")){var a=String.format("{0}
{1}
",_T("share","error_replica_demote"),e.warning_replica_demote.join(", "));t.push(a)}if(e.hasOwnProperty("warning_replica_promote")){var r=String.format("{0}
{1}
",_T("snapmgr","error_replica_promote"),e.warning_replica_promote.join(", "));t.push(r)}if(e.hasOwnProperty("warning_disable_package")||e.hasOwnProperty("warning_uninstall_package")?(e.hasOwnProperty("warning_disable_package")&&t.push(this.generatePackageWarningMsg(e.warning_disable_package,_T("share","error_packages"))),e.hasOwnProperty("warning_uninstall_package")&&t.push(this.generatePackageWarningMsg(e.warning_uninstall_package,_T("share","error_package_uninstall")))):e.hasOwnProperty("warning_package")&&t.push(this.generatePackageWarningMsg(e.warning_package,_T("share","error_packages"))),e.hasOwnProperty("warning_cluster_share")){var l=String.format("{0}
{1}
",_T("share","error_cluster_share"),e.warning_cluster_share.join(", "));t.push(l)}return t},combineWarningConfirm:function(e){var t="";if(e.hasOwnProperty("warning_sd_destination")){var i=String.format(_T("share","share_rmsdcopyfolderempty"),e.warning_sd_destination);t=i}if(e.hasOwnProperty("warning_usb_destination")){var s=String.format(_T("share","share_rmusbcopyfolderempty"),e.warning_usb_destination);t=""===t?s:t+""+s}return e.hasOwnProperty("warning_disable_service")&&(Ext.each(e.warning_disable_service,function(e){var i,s,n=e.services,o=[];if(!Ext.isArray(n))return!1;Ext.each(n,function(e){o.push(SYNO.SDS.AdminCenter.Share.Utils.GetServiceI18N(e))}),i=""+e.share+"",s=""+o.join(", ")+"",t=""===t?String.format(_T("share","share_service_disable_confirm"),i,s):t+"
"+String.format(_T("share","share_service_disable_confirm"),i,s)}),t=t+"

"+_T("share","share_service_disable_confirm_post")),t},loadDeleteDialog:function(e,t,i){var s,n=t.normal.length+t.c2.length>1;s=i||t.c2.length>0?n?_T("share","share_delete_confirm_more"):_T("share","share_single_delete_confirm_more"):n?_T("share","share_delete_confirm_multiple"):_T("share","share_delete_confirm"),s+='
    ',i&&(s+=n?String.format("
  • {0}
  • ",_T("share","share_snapshot_delete_confirm")):String.format("
  • {0}
  • ",_T("share","share_snapshot_single_delete_confirm"))),t.c2.length>0&&(s+=String.format("
  • {0}
  • ",_T("share","c2share_delete_confirm"))),s+="
";var o=new SYNO.SDS.AdminCenter.Share.Delete({module:this,owner:this.module.appWin,shares:t,alert_message:s});o.open(),o.loadShareName(_T("share","share_cfrmrmv"),e)},encryptHandler:function(e,t){var i=this.view.getSelectedRecords()[0];this.module.appWin.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share.Crypto",method:"validate_encrypt",version:1,params:{name:i.id},scope:this,callback:function(e,t,s){var n=[],o="",a="",r=[];if(this.module.appWin.clearStatusBusy(),!e)return this.module.appWin.getMsgBox().alert("warning_msg",_T("common","error_system")),void this.store.load();t&&t.warning_pause_service?(Ext.each(t.warning_pause_service,function(e){n.push(SYNO.SDS.AdminCenter.Share.Utils.GetServiceI18N(e))}),o=""+n.join(", ")+"
",a=String.format(_T("share","encrypt_share_service_pause_confirm"),i.id,o)):a=_T("share","share_encryption_encrypt_confirm"),r.push(a),this.showConfirmMsg(r,i.id,t)}})},showFeasibilityCheckMsg:function(e,t){var i;t&&t.hard?(i=_T("share","edit_hard_check_fail"),i+="
"+SYNO.SDS.Utils.GetFeasibilityCheckMsgJoin(t.hard[e])+"",this.module.appWin.getMsgBox().alert("warning_msg",i)):t&&t.soft?(i=_T("share","edit_soft_check_fail"),i+="
"+SYNO.SDS.Utils.GetFeasibilityCheckMsgJoin(t.soft[e])+"",this.module.appWin.getMsgBox().confirm("warning_msg",i,function(t){"yes"==t?this.doEncrypt(e):this.store.load()},this)):this.doEncrypt(e)},showConfirmMsg:function(e,t,i){var s;i&&i.hard||0===e.length?this.showFeasibilityCheckMsg(t,i):(s=e.pop(),this.module.appWin.getMsgBox().confirm("warning_msg",s,function(s){"yes"===s&&(0===e.length?this.showFeasibilityCheckMsg(t,i):this.showConfirmMsg(e,t,i))},this),this.module.appWin.getMsgBox().getDialog().setWidth(600))},doEncrypt:function(e){this.module.appWin.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Share.Crypto",method:"encrypt",version:1,params:{name:e},scope:this,callback:function(e,t,i){this.module.appWin.clearStatusBusy(),e||this.module.appWin.getMsgBox().alert("warning_msg",_T("share","mount_point_not_empty")),SYNO.SDS.StatusNotifier.fireEvent("sharefolderchanged","permission"),this.store.load()}})},decryptHandler:function(){var e=this.view.getSelectedRecords();new SYNO.SDS.AdminCenter.Share.Decrypt({module:this.module,owner:this.module.appWin,share:e,decrypt_by_km:this.isSelectedShareInKeyManager(e),km_location:this.keyManagerLocation}).open()},exportKeyHandler:function(){var e=this.view.getSelectedRecords()[0];new SYNO.SDS.AdminCenter.Share.Export({module:this.module,owner:this.module.appWin,share:e}).open()}}),Ext.define("SYNO.SDS.AdminCenter.FileService.FakeWinTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.link_id=Ext.id();let t=String.format('{1}',this.link_id,_T("tree","leaf_packagemanage")),i=String.format(_T("domain","need_samba_service"),t,_T("network","smb_app_name"));var s=Ext.apply({title:_T("network","wnds_file_service"),items:[{xtype:"syno_displayfield",value:i,htmlEncode:!1,listeners:{afterrender:function(){this.mon(Ext.get(this.link_id),"click",this.launchPkgSMBPage)},scope:this}},{xtype:"syno_checkbox",itemId:"enable_samba",checked:!1,hidden:!0}]},e);this.callParent([s])},launchPkgSMBPage:function(){SYNO.SDS.AppLaunch("SYNO.SDS.PkgManApp.Instance",{action:"open",packages:["SMBService"]})}}),Ext.define("SYNO.SDS.AdminCenter.FileService.AfpTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module;var t=this.fillConfig(e);this.afpTMEnable=!1,this.callParent([t]),this.macHelpBox=Ext.getCmp(this.macHelpBox),this.on("afterlayout",this.onPanelAfterLayout,this,{single:!0})},onPanelAfterLayout:function(e,t){e.mon(e.getForm().findField("enable_afp"),"check",function(e,t){this.setMacHelpBoxVisible(t),this.getComponent("advanceBtnId").setDisabled(!t)},this),this.checkEnableAFP=new SYNO.ux.Utils.EnableCheckGroup(e.getForm(),"enable_afp",["afp_transfer_log_enable"])},setMacHelpBoxVisible:function(e){this.macHelpBox.setVisible(e),this.doLayout()},fillConfig:function(e){var t={title:_T("network","apple_subject"),autoScroll:!0,webapi:{api:"SYNO.Core.FileServ.AFP",methods:{get:"get",set:"set"},version:1},items:this.createMacTabObj(e)};return Ext.apply(t,e),t},createMacTabObj:function(e){return[{xtype:"syno_checkbox",itemId:"enable_afp",name:"enable_afp",boxLabel:_T("network","apple_enable")},{xtype:"syno_checkbox",name:"afp_transfer_log_enable",itemId:"afp_transfer_log_enable",indent:1,boxLabel:_T("service","service_afp_transfer_log"),listeners:{enable:{scope:this,fn:function(e){!0===this.getComponent("enable_afp").originalValue&&!0===e.originalValue&&this.getComponent("afpLogBtn").setDisabled(!1)}},disable:{scope:this,fn:function(){this.getComponent("afpLogBtn").setDisabled(!0)}}}},{xtype:"syno_button",btnStyle:"default",itemId:"afpLogBtn",name:"afpLogBtn",text:_T("log","log_subtitle"),autoWidth:!0,indent:2,style:{marginBottom:"0px"},handler:function(){SYNO.SDS.AppLaunch("SYNO.SDS.LogCenter.BuiltIn",{logType:"fileTransfer",protocol:"afpxfer"})}},{xtype:"spacer",height:18},{xtype:"syno_button",btnStyle:"default",name:"advanceBtnId",itemId:"advanceBtnId",text:_T("common","adv_setting"),indent:1,style:{marginBottom:"0px"},scope:this,handler:this.onAfpAdvSettingBtnClick},{xtype:"spacer",height:18},{xtype:"syno_displayfield",itemId:"afpNoteId",fieldLabel:"Note",hideLabel:!0,indent:1,htmlEncode:!1,value:''+_T("common","note")+_T("common","colon")+'
",listeners:{render:function(e){var t=e.el.select("a"),i=t.item(0);i&&this.mon(i,"click",function(e){e.preventDefault(),SYNO.SDS.AdminCenter.FileService.AfpTab.Utils.onClickServiceDiscoveryUrl(this.module.appWin)},this);var s=t.item(1);s&&this.mon(s,"click",function(e){e.preventDefault(),SYNO.SDS.AdminCenter.FileService.AfpTab.Utils.onClickFileIndexUrl(this.module.appWin)},this)},scope:this,single:!0,buffer:80}},{xtype:"box",hidden:"true",id:this.macHelpBox=Ext.id(),tpl:new Ext.XTemplate('
'+_T("network","share_access_prompt")+'
'+_T("network","share_access_prompt_mac")+" ("+_T("network","mac_finder")+")"+_T("common","colon")+'afp://{hostname}.local
',{promptId:Ext.id(),promptMacId:Ext.id(),promptMacHostnameId:Ext.id()})}]},selectHelpText:function(e,t){var i=t.ownerDocument.createRange();i.selectNode(t.firstChild);var s=window.getSelection();s.removeAllRanges(),s.addRange(i)},onAfpAdvSettingBtnClick:function(){new SYNO.SDS.AdminCenter.FileService.AFP.AdvancedSettingDialog({module:this.module,owner:this.module.appWin}).open()},onBeforeRequest:function(e){return!0},processParams:function(e,t){var i={};if("set"==e){i=this.getForm().getValues(),this.getForm().findField("afp_transfer_log_enable").isDirty()&&(t=t.concat({api:"SYNO.Core.SyslogClient.FileTransfer",method:"set",version:1,params:{afp:i.afp_transfer_log_enable}})),this.afpChange=this.getForm().findField("enable_afp").isDirty();var s=this.getForm().findField("enable_afp").checked;this.afpChange&&(this.afpTMEnable=!!s&&this.afpTMEnable,t=t.concat({api:"SYNO.Core.FileServ.ServiceDiscovery",method:"set",version:1,params:{enable_afp_time_machine:this.afpTMEnable}}))}return t=(t=(t=(t=t.concat({api:"SYNO.Core.FileServ.ServiceDiscovery",method:"get",version:1})).concat({api:"SYNO.Core.SyslogClient.FileTransfer",method:"get",version:1})).concat({api:"SYNO.Core.Network",method:"get",version:1})).filter(function(e){return!!this.getKnownAPI(e.api)},this)},processReturnData:function(e,t,i){for(var s=!1,n={api:"SYNO.Core.SyslogClient.FileTransfer",method:"get",version:1},o={api:"SYNO.Core.Network",method:"get",version:1},a={api:"SYNO.Core.FileServ.ServiceDiscovery",method:"get",version:1},r=0;re.indexOf("=")}},{xtype:"syno_combobox",name:"local_name",itemId:"local_name",fieldLabel:_T("app_privilege","local_user"),store:this.userStore,displayField:"local_name",valueField:"local_name",triggerAction:"all",mode:"remote",editable:!0,resizable:!0,pageSize:SYNO.SDS.AdminCenter.USER_PAGING_SIZE,width:250,grow:!0,allowBlank:!1,queryParam:"filter",listWidth:300,maxHeight:360,minChars:1,typeAhead:!0,typeAheadDelay:1e3,listeners:{scope:this,change:this.isValidUser,blur:this.isValidUser}}]};return SYNO.LayoutConfig.fill(e),new SYNO.SDS.Utils.FormPanel(e)},onApplyBtnClick:function(){var e=this.panel.getComponent("local_name").getValue();this.isValidUser(e)&&this.panel.getForm().isValid()?this.panel.getForm().isDirty()?this.applyHandler():this.close():this.setStatusError({text:_T("common","forminvalid"),clear:!0})},applyHandler:function(){var e="",t={},i=this.panel.getComponent("kerberos_principal").getValue(),s=this.panel.getComponent("local_name").getValue();this.principal?(e="set",t={id:this.principal.id,kerberos_principal:i,local_name:s}):(e="create",t={idmap:[{kerberos_principal:i,local_name:s}]}),this.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({api:"SYNO.Core.FileServ.NFS.IDMap",method:e,params:t,version:1,scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),e)this.owner.idmapTab.idmapStore.reload(),this.close();else if(2351==t.code)this.setStatusError({text:_T("nfs","nfs_krb5_princ_conflict"),clear:!0});else if(2353==t.code){var s=_T("error","error_bad_field");this.setStatusError({text:s,clear:!0})}else this.setStatusError({text:_T("common","commfail"),clear:!0})}})},isValidUser:function(){var e=!1,t=this.panel.getComponent("local_name").getValue();return this.userStore.each(function(i){t===i.get("local_name")&&(e=!0)},this),e||this.panel.getComponent("local_name").markInvalid(_T("firewall","firewall_field_blank_alert")),e},onActivate:function(){this.userStore.load({params:{offset:0,limit:SYNO.SDS.AdminCenter.USER_PAGING_SIZE}})},createUserStore:function(){return new SYNO.API.JsonStore({api:"SYNO.Core.FileServ.NFS.IDMap",method:"list",version:1,root:"idmap",idProperty:"local_name",fields:["local_name"],appWindow:this.findAppWindow()||!1,autoDestroy:!0,baseParams:{offset:0,limit:this.pageSize,suggestion:!0},sortInfo:{field:"local_name",direction:"ASC"},totalProperty:"total",listeners:{scope:this,beforeload:this.onBeforeLoad,exception:this.onException,load:this.onLoad}})},onBeforeLoad:function(){this.setStatusBusy()},onException:function(){this.clearStatusBusy(),this.setStatusError({text:_T("common","commfail"),clear:!0})},onLoad:function(){this.clearStatusBusy()}}),Ext.ns("SYNO.SDS.AdminCenter.FileService.NFS.Kerberos"),Ext.define("SYNO.SDS.AdminCenter.FileService.NFS.Kerberos.KeyUploadDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.applyBtn=new SYNO.ux.Button({disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",btnStyle:"blue",text:_T("common","apply"),handler:this.onApplyBtnClick,scope:this}),this.cancelBtn=new SYNO.ux.Button({text:_T("common","cancel"),btnStyle:"grey",handler:this.close,scope:this}),this.panel=this.configForm();var t=Ext.apply({dsmStyle:"v5",title:_T("nfs","nfs_kerberos_import_keys"),autoDestroy:!0,width:500,height:200,layout:"fit",items:[this.panel],buttons:[this.cancelBtn,this.applyBtn]},e);Ext.apply(t,e),this.callParent([t])},configForm:function(){var e={border:!1,itemId:"formpanel",fileUpload:!0,trackResetOnLoad:!0,labelWidth:130,padding:0,items:[{xtype:"syno_displayfield",value:_T("nfs","nfs_select_import_key")},{xtype:"syno_filebutton",name:"keytab_file",fieldLabel:_T("nfs","nfs_kerberos_keys")}],webapi:{api:"SYNO.Core.FileServ.NFS.Kerberos",method:"upload_key",version:1},onApiSuccess:function(){this.ownerCt.owner.kerberosTab.keyStore.reload(),this.ownerCt.clearStatusBusy(),this.ownerCt.close()},onApiFailure:function(e,t,i){var s=SYNO.API.getErrorString(t);this.ownerCt.clearStatusBusy(),this.ownerCt.setStatusError({text:s,clear:!0})}};return SYNO.LayoutConfig.fill(e),new SYNO.SDS.Utils.FormPanel(e)},onApplyBtnClick:function(){this.panel.getForm().findField("keytab_file").getValue()?0",new SYNO.ux.TextFilter({iconStyle:"search",itemId:"search",store:this.idmapStore,queryAction:"list",enumAction:"list",queryParam:"filter",pageSize:SYNO.SDS.AdminCenter.USER_PAGING_SIZE})]},listeners:{scope:this,activate:{fn:function(){this.idmapStore.load()}}},bbar:new SYNO.ux.PagingToolbar({store:this.idmapStore,pageSize:SYNO.SDS.AdminCenter.USER_PAGING_SIZE,displayInfo:!0})};Ext.apply(t,e),SYNO.LayoutConfig.fill(t),this.callParent([t])},onCreateMapBtnClick:function(){new SYNO.SDS.AdminCenter.FileService.NFS.IDMap.EditMapDialog({module:this.module,owner:this.owner,principal:null}).open()},onEditMapBtnClick:function(){var e=this.getSelectionModel().getSelected();new SYNO.SDS.AdminCenter.FileService.NFS.IDMap.EditMapDialog({module:this.module,owner:this.owner,principal:e.data}).open()},onDefaultMapBtnClick:function(){this.defaultMapDialog=new SYNO.SDS.UserChooser({owner:this.ownerCt.ownerCt,module:this.module,title:_T("nfs","nfs_default_map_list"),setStoreConfig:function(){return{api:"SYNO.Core.FileServ.NFS.IDMap",method:"list",version:"1",id:"id",root:"idmap"}},setApiParams:function(){return{suggestion:!0}},setStoreField:function(){return["id","kerberos_principal","local_name"]},setColModel:function(){return[{id:"kerberos_principal",header:_T("nfs","nfs_krb5_principal"),dataIndex:"kerberos_principal",width:200},{id:"description",header:_T("app_privilege","local_user"),dataIndex:"local_name",width:150}]},setTextFilterConfig:function(){return{queryAction:"list",queryParam:"filter"}},setGridPanelConfig:function(){return{enableHdMenu:!1,autoExpandColumn:"kerberos_principal"}},singleSelect:!1,localOnly:!0}),this.mon(this.defaultMapDialog,"beforeclose",this.onBeforeCloseDefaultMap,this),this.defaultMapDialog.getFooterToolbar().getComponent("ok").setText(_T("common","add")),this.defaultMapDialog.chooseUsers()},onBeforeCloseDefaultMap:function(e){var t=[],i=e.getRecords();if(0===i.length)return!0;for(var s=0;s=t||!!this._S("demo_mode"))},onDelMapBtnClick:function(){this.module.appWin.getMsgBox().confirmDelete(this.title,_T("nfs","nfs_idmap_delete_confirm_desc"),function(e){"yes"===e&&this.doDelete()},this)},doDelete:function(){for(var e=[],t=this.getSelectionModel().getSelections(),i=0;i0?_T("nfs","nfs_v4_1_domain"):_T("nfs","nfs_v4_domain"),maxlength:512,vtype:"hostname"},{xtype:"displayfield",height:10},{xtype:"syno_displayfield",name:"krb5_desc",itemId:"krb5_desc",value:_T("nfs","nfs_kerberos_desc"),hidden:!0},{xtype:"syno_button",synotype:"indent_no_label",name:"krb5_btn",itemId:"krb5_btn",text:_T("nfs","nfs_kerberos_setting"),id:this.nfsKrb5SetId=Ext.id(),handler:this.onNfsKerberosBtnClick,hidden:!0,scope:this},{xtype:"syno_displayfield",fieldLabel:_T("nfs","nfs_krb5_principal"),name:"kerberos_principal",itemId:"krb5_principal",hidden:!0},{xtype:"displayfield",height:10}]};return new SYNO.SDS.Utils.FormPanel(t)},afterLoad:function(e){for(var t={api:"SYNO.Core.FileServ.NFS.AdvancedSetting",method:"get",version:1},i={api:"SYNO.Core.FileServ.NFS.Kerberos",method:"get",version:1},s=0;sthis.nfsApiMaxVersion?["enable_nfs_v4","read_size","write_size",this.nfsKrb5SetId,"unix_pri_enable"]:["nfs_max_protocol","nfs_enabled_protocol"],this.checkEnableNFS=new SYNO.ux.Utils.EnableCheckGroup(e.getForm(),"enable_nfs",i)},fillConfig:function(e){var t,i=this.nfsApiMaxVersion;t=2>this.nfsApiMaxVersion?this.createNfsTabObj(e):this.createNfsTabObjV3(e);var s={title:_T("tree","leaf_nfs"),autoScroll:!0,webapi:{api:"SYNO.Core.FileServ.NFS",methods:{get:"get",set:"set"},version:i},items:t};return Ext.apply(s,e),s},createNfsTabObj:function(e){return this.packetSizeStore=this.createLocalStore(),[{xtype:"syno_checkbox",name:"enable_nfs",itemId:"enable_nfs",boxLabel:_T("nfs","nfs_enable")},{xtype:"syno_checkbox",name:"enable_nfs_v4",indent:1,boxLabel:_T("nfs","nfs_enable_version_4")},{xtype:"displayfield",height:10},{xtype:"syno_checkbox",name:"unix_pri_enable",indent:1,boxLabel:_T("common","apply_default_umask")},{xtype:"syno_displayfield",indent:1,value:_T("nfs","nfs_prefer_rw_size_desc")},{xtype:"syno_combobox",name:"read_size",fieldLabel:_T("nfs","nfs_prefer_read_size"),displayField:"display",valueField:"value",value:this.rgPacketSize[1][0],indent:1,store:this.packetSizeStore},{xtype:"syno_combobox",name:"write_size",fieldLabel:_T("nfs","nfs_prefer_write_size"),displayField:"display",valueField:"value",value:this.rgPacketSize[1][0],indent:1,store:this.packetSizeStore},{xtype:"displayfield",height:10},{xtype:"syno_displayfield",name:"krb5_desc",itemId:"krb5_desc",indent:1,value:_T("nfs","nfs_kerberos_desc"),hidden:!0},{xtype:"syno_button",synotype:"indent_no_label",name:"krb5_btn",itemId:"krb5_btn",text:_T("nfs","nfs_kerberos_setting"),indent:1,id:this.nfsKrb5SetId=Ext.id(),handler:this.onNfsKerberosBtnClick,hidden:!0,scope:this},{xtype:"syno_displayfield",fieldLabel:_T("nfs","nfs_krb5_principal"),name:"kerberos_principal",itemId:"krb5_principal",hidden:!0,indent:1},{xtype:"displayfield",height:10},{xtype:"syno_displayfield",indent:1,value:''+_T("common","note")+_T("common","colon")+" "+String.format(_T("nfs","nfs_share_permission_desc"),''+_T("helptoc","share")+""),listeners:{render:function(e){var t=e.el.first("a");t&&this.mon(t,"click",function(e){e.preventDefault(),SYNO.SDS.AdminCenter.FileService.NfsTab.Utils.onClickShareUrl(this.module.appWin)},this)},scope:this,single:!0,buffer:80}}]},createNfsTabObjV3:function(e){return this.isNfsMaxProtocolReady=!1,this.updateAvailNfsVerArray(3,0,!1),[{xtype:"syno_checkbox",name:"enable_nfs",itemId:"enable_nfs",boxLabel:_T("nfs","nfs_enable"),listeners:{check:{scope:this,fn:this.onNfsCheckHandler}}},{xtype:"syno_combobox",name:"nfs_max_protocol",itemId:"nfs_max_protocol",fieldLabel:_T("nfs","nfs_max_protocol"),displayField:"display",valueField:"value",indent:1,labelWidth:250,value:this.rgAvailNfsVer[0][0],store:new Ext.data.ArrayStore({fields:["value","display"],data:this.rgAvailNfsVer}),listeners:{select:this.updateEnabledNfsVer,scope:this}},{xtype:"syno_displayfield",name:"nfs_enabled_protocol",itemId:"nfs_enabled_protocol",htmlEncode:!1,indent:1,labelWidth:250,fieldLabel:_T("nfs","nfs_avail_protocol"),isDirty:function(){return!1}},{xtype:"syno_button",btnStyle:"default",name:"NfsadvanceBtnId",itemId:"NfsadvanceBtnId",text:_T("common","adv_setting"),autoWidth:!0,indent:1,style:{marginTop:"12px"},scope:this,handler:this.onNfsAdvSettingBtnClick},{xtype:"syno_displayfield",itemId:"nfsNoteId",indent:1,style:{marginTop:"6px"},htmlEncode:!1,value:''+_T("common","note")+_T("common","colon")+" "+String.format(_T("nfs","nfs_share_permission_desc"),''+_T("helptoc","share")+""),listeners:{render:function(e){var t=e.el.first("a");t&&this.mon(t,"click",function(e){e.preventDefault(),SYNO.SDS.AdminCenter.FileService.NfsTab.Utils.onClickShareUrl(this.module.appWin)},this)},scope:this,single:!0,buffer:80}}]},selectHelpText:function(e,t){var i=t.ownerDocument.createRange();i.selectNode(t.firstChild);var s=window.getSelection();s.removeAllRanges(),s.addRange(i)},onNfsKerberosBtnClick:function(){new SYNO.SDS.AdminCenter.FileService.NFS.Kerberos.MainDialog({module:this.module,owner:this.module.appWin}).open()},onNfsAdvSettingBtnClick:function(){new SYNO.SDS.AdminCenter.FileService.NFS.AdvancedSettingsDialog({nfs_enable:this.getForm().findField("enable_nfs").getValue(),nfs_v4_enable:this.nfs_enable_nfs_v4,nfs_v4_max_minor_version:this.nfs_enabled_minor_ver,module:this.module,owner:this.module.appWin}).open()},createLocalStore:function(){return this.rgPacketSize=[[4096,"4KB"],[8192,"8KB"],[16384,"16KB"],[32768,"32KB"]],new Ext.data.ArrayStore({fields:["value","display"],data:this.rgPacketSize})},updateAvailNfsVerArray:function(e,t,i){var s=[[0,"NFSv3"]];if(4<=e&&(s.push([1,"NFSv4"]),1<=t&&s.push([2,"NFSv4.1"])),!0===i){var n=0;!0===this.nfs_enable_nfs_v4&&(n=s[1][0],1===this.nfs_enabled_minor_ver&&(n=s[2][0])),n>s[s.length-1][0]&&(n=s[s.length-1][0]),this.getComponent("nfs_max_protocol").store.loadData(s),this.getComponent("nfs_max_protocol").setValue(n),!1===this.isNfsMaxProtocolReady&&(this.isNfsMaxProtocolReady=!0,this.getComponent("nfs_max_protocol").initValue())}this.rgAvailNfsVer=s.slice()},updateAvailNfsVer:function(){var e=this.nfs_support_major_ver,t=this.nfs_support_minor_ver;this.updateAvailNfsVerArray(e,t,!0),this.updateEnabledNfsVer(null),this.getComponent("nfs_enabled_protocol").initValue()},updateEnabledNfsVer:function(e){for(var t=this.getComponent("nfs_max_protocol").getValue(),i=this.rgAvailNfsVer,s="NFSv2",n=0;nthis.nfsApiMaxVersion&&(t=t.concat({api:"SYNO.Core.FileServ.NFS.Kerberos",method:"get",version:1})),t=t.filter(function(e){return!!this.getKnownAPI(e.api)},this)},processReturnData:function(e,t,i){for(var s={api:"SYNO.Core.FileServ.NFS.Kerberos",method:"get",version:1},n=0;n',a=String.format(o,"acl-grid-item-user"),r=String.format(o,"acl-grid-item-group"),l=String.format('
\t{0}
',n);return"user"===s?a+l:r+l},scope:this},{id:"path",header:_T("ftp","ftp_root_dir"),dataIndex:"path",width:200,renderer:function(e,t,i){var s=Ext.util.Format.htmlEncode(e.substr(1)),n=!0;return i.data.path_exist||(t.attr=String.format('ext:qtip="{0}"',_T("mediaservice","error_folder_not_exist")),n=!1),"/home"===i.data.path&&(0'+s+""},scope:this},{header:"type",id:"type",dataIndex:"type",hidden:!0}]}),selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:{fn:this.onChgButtonStatus,buffer:50,scope:this}}})};Ext.apply(t,e),SYNO.LayoutConfig.fill(t),this.callParent([t])},createActions:function(){var e=function(e,t,i,s,n){return new Ext.Action(Ext.apply({text:e,itemId:t,scope:s,handler:i},n))};return this.actions={add:e(_T("common","add"),"addBtn",function(){this.openRuleDialog("add")},this),edit:e(_T("common","alt_edit"),"editBtn",function(){this.openRuleDialog("edit")},this),del:e(_T("common","remove"),"delBtn",this.onDelBtnClick,this)},this.actions},getAction:function(e){return e in this.actions?this.actions[e]:void SYNO.Debug("no this action: "+e)},enableAction:function(e,t){var i=this.getAction(e);i&&i[t?"enable":"disable"]()},initEvents:function(){this.mon(this.ruleStore,"beforeload",this.onGridBeforeLoad,this),this.mon(this.ruleStore,"load",this.onGridAfterLoad,this),this.mon(this.ruleStore,"exception",this.onGridException,this),this.mon(this.ruleStore,"update",this.onChgButtonStatus,this),this.mon(this.ruleStore,"add",this.onStoreAdd,this),this.mon(this.ruleStore,"remove",this.onStoreRemove,this),this.mon(this,"afterlayout",function(){this.ddrow=new Ext.dd.DropTarget(this.getView().mainBody,{ddGroup:"ChrootRulesDD",copy:!1,scope:this,notifyDrop:function(e,t,i){return this.scope.mvRules(e.getDragData(t).rowIndex,i.selections,i.grid.getStore())}})},this,{single:!0})},onGridException:function(e,t,i,s,n,o){var a=_T("common","commfail");SYNO.API.Erros.core[n.code]&&(a=SYNO.API.Erros.core[n.code]),this.owner.getMsgBox().alert(this.title,a),this.onChgButtonStatus(),this.owner.clearStatusBusy()},onGridBeforeLoad:function(e,t){this.owner.setStatusBusy({text:_T("common","loading")})},onGridAfterLoad:function(e,t,i){this.onChgButtonStatus(),this.owner.clearStatusBusy()},onStoreAdd:function(e,t,i){this.isRuleChanged=!0,this.onChgButtonStatus()},onStoreRemove:function(e,t,i){this.isRuleChanged=!0,this.onChgButtonStatus()},isDirty:function(){return 0=i.getCount()?i.add(t):i.insert(e,t),this.isRuleChanged=!0,!0},onShow:function(){this.ruleStore.load({params:{offset:0,limit:SYNO.SDS.AdminCenter.USER_PAGING_SIZE}})},onChgButtonStatus:function(){var e=this.getSelectionModel().getCount();this.enableAction("del",0t.getCount()-1||(this.inaction=!0,t.remove(i),t.insert(s,i),this.getSelectionModel().selectRecords([i]),this.inaction=!1)},createRuleStore:function(){return new SYNO.API.JsonStore({api:"SYNO.Core.FileServ.FTP.ChrootUser",method:"load",version:2,root:"rules",fields:["type","name","path","path_exist"],appWindow:this.owner||!1,defaultSortable:!0})},onDelBtnClick:function(){for(var e=this.getSelectionModel().getSelections(),t=this.getStore(),i=0;i{1}',_T("ftp","ftp_domain_ldap_user_home_disabled"),t.boxLabel))):this.userHomeEnabled?t.setDisabled(!1):(this.panel.getForm().setValues({chroot_type:"custom"}),t.setDisabled(!0),t.boxlabelEl.update(String.format('{1}',_T("ftp","ftp_user_home_disabled"),t.boxLabel)))},fillConfig:function(e){var t={owner:e.owner,module:e.module,width:500,autoHeight:!0,autoScroll:!1,title:e.title,items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),handler:this.onCloseHandler,scope:this},{btnStyle:"blue",text:_T("common","ok"),handler:this.onUpdateRuleGrid,disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this}]};return Ext.apply(t,e),t},onCloseHandler:function(){this.close()},getRecord:function(){var e={type:"",name:"",path:""},t=this.panel.getForm().findField("chroot_type").getGroupValue(),i=this.panel.getComponent("cmb_owner").getValue().split(":");return void 0!==i[0]&&""!==i[0]&&(e.type=i[0]),void 0!==i[1]&&""!==i[1]&&(e.name=i[1]),e.path="home"===t?"/home":"/"+this.panel.getForm().findField("chroot_share").getValue(),e},validateData:function(e){if(this.panel.getComponent("cmb_owner").valueNotFound()||""===e.type||""===e.name)return this.setStatusError({text:_T("acl_editor","error_invalid_user_or_group"),clear:!0}),!1;if(!this.panel.getForm().isValid())return this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1;var t=-1;null!==this.rule&&(t=this.owner.panel.getStore().indexOf(this.owner.panel.getSelectionModel().getSelected()));for(var i=this.owner.panel.getStore().getRange(),s=0;s=t)},createUserStore:function(){return new SYNO.API.JsonStore({api:"SYNO.Core.FileServ.FTP.ChrootUser",method:"list",version:1,root:"user",idProperty:"id",fields:["id","name","descr"],totalProperty:"total",appWindow:this.findAppWindow()||!1,defaultSortable:!0,baseParams:{type:"all",chroot:!0},paramNames:{start:"offset",limit:"limit"}})},onDelBtnClick:function(){this.module.appWin.getMsgBox().confirmDelete(_T("ftp","ftp_chroot_user_list"),_T("ftp","ftp_cfrm_remove_users"),function(e){"yes"==e&&this.doDelete()},this)},doDelete:function(){for(var e=[],t=this.getSelectionModel().getSelections(),i=0;i=this.ftpShareStore.getCount()||(t?i.enable():i.disable())},isAnonymousChrootShareValid:function(){for(var e=this.panel.getForm().findField("anonymous_chroot_share").getValue(),t=!1,i=0;i=this.ftpShareStore.getCount()?(e.findField("anonymous_chroot").disable(),e.findField("no_share").show(),e.findField("no_share").getItemCt().setARIA({tabIndex:-1})):(e.findField("anonymous").getValue()?e.findField("anonymous_chroot").enable():e.findField("anonymous_chroot").disable(),""===e.findField("anonymous_chroot_share").getValue()&&e.setValues({anonymous_chroot_share:this.ftpShareStore.getAt(0).get("name")})),this.panel.getComponent("xferFieldSet").getComponent("exportLogBtn").setDisabled(!t),s?this.panel.getComponent("xferFieldSet").getComponent("viewLogBtn").disable():this.panel.getComponent("xferFieldSet").getComponent("viewLogBtn").setDisabled(!t)},onApplyBtnClick:function(){var e=this.panel.getForm(),t=e.getValues(),i=t.xferlog,s=[];e.isDirty()?(this.needResetAnonymousChrootShare&&(void 0===t.anonymous_chroot&&(t.anonymous_chroot=!1),void 0===t.anonymous_chroot_share&&(t.anonymous_chroot_share="")),e.findField("xferlog").isDirty()&&(s=s.concat({api:"SYNO.Core.SyslogClient.FileTransfer",method:"set",version:1,params:{ftp:i}})),s=s.concat({api:"SYNO.Core.FileServ.FTP.Security",method:"set",version:1,params:t}),this.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({compound:{stopwhenerror:!1,params:s},scope:this,callback:function(t,i,s){if(this.clearStatusBusy(),i.has_fail){var n=SYNO.API.Response.GetFirstError(i);1905==n.code?(e.findField("anonymous_chroot_share").markInvalid(SYNO.API.Erros.core[n.code]),this.setStatusError({text:_T("error","error_invalid"),clear:!0})):this.setStatusError({text:SYNO.API.Erros.core[n.code],clear:!0})}else this.close()}})):this.close()},onCloseBtnClick:function(){if(!this.panel.getForm().isDirty())return this.close(),!0;this.confirmLostChangePromise({dontSave:this.close,cancel:Ext.emptyFn,save:this.onApplyBtnClick},this)},setAllValues:function(e){var t={},i=[],s=!1;Ext.each(e.result,function(e){Ext.apply(t,e.data)});for(var n={api:"SYNO.Core.FileServ.FTP.Security",method:"list_ftp_share",version:1},o={api:"SYNO.Core.User.Home",method:"get",version:1},a={api:"SYNO.Core.SyslogClient.FileTransfer",method:"get",version:1},r=0;r{0}',_T("ftp","ftp_no_share"))},{xtype:"hidden",name:"share_status"},{xtype:"syno_checkbox",name:"enable_umask",itemId:"enable_umask",boxLabel:_T("common","apply_default_umask")}]}},onSelectUserBtnClick:function(){(2<=this.getKnownAPI("SYNO.Core.FileServ.FTP.ChrootUser").maxVersion?new SYNO.SDS.AdminCenter.FileService.FTP.ChrootRuleDialog({module:this.module,owner:this,userHomeEnabled:this.userHomeEnabled,domainUserHomeEnabled:this.domainUserHomeEnabled,ldapUserHomeEnabled:this.ldapUserHomeEnabled}):new SYNO.SDS.AdminCenter.FileService.FTP.ChrootUserDialog({module:this.module,owner:this,domainUserHomeEnabled:this.domainUserHomeEnabled,ldapUserHomeEnabled:this.ldapUserHomeEnabled})).open()},onUserChrootCheck:function(e,t){this.panel.getComponent("securityFieldSet").getComponent("select_user_btn").setDisabled(!t)}}),Ext.ns("SYNO.SDS.AdminCenter.FileService"),Ext.define("SYNO.SDS.AdminCenter.FileService.FtpSftpTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.SFTP_DEFAULT_PORT=22,this.defaultPasvMinPort=parseInt(this._D("ftp_pasv_def_min_port","55536"),10),this.defaultPasvMaxPort=parseInt(this._D("ftp_pasv_def_max_port","55663"),10),this.sftpPort=0,this.ftpApiMaxVersion=this.getKnownAPI("SYNO.Core.FileServ.FTP").maxVersion,this.hasGetFtpExtIP=!1;var t=this.fillConfig(e);this.callParent([t]),this.generalForm=this.getComponent("generalFieldSet"),this.ftpForm=this.getComponent("ftpFieldSet"),this.sftpForm=this.getComponent("sftpFieldSet"),this.on("afterlayout",function(e,t){var i=e.ftpForm.getComponent("custom_port_desc");this.checkEnableCustomPortRange=new SYNO.ux.Utils.EnableRadioGroup(e.getForm(),"custom_port_range",{true:["port_low","port_high"]}),this.checkEnableExtIP=new SYNO.ux.Utils.EnableCheckGroup(e.getForm(),"use_ext_ip",["ext_ip"]),SYNO.ux.Utils.DescribeGroup(e.getForm().findField("timeout"),e.getForm().findField("timeout_desc")),SYNO.ux.Utils.DescribeGroup(i.items.get(1),i.items.get(0)),SYNO.ux.Utils.DescribeGroup(i.items.get(3),i.items.get(2))},this,{single:!0})},fillConfig:function(e){var t={title:_T("tree","leaf_ftp"),autoScroll:!0,labelWidth:300,items:[this.createFtpTabObj(e),this.createSftpTabObj(e),this.createGeneralTabObj(e)]};return Ext.apply(t,e),t},createGeneralTabObj:function(e){return{xtype:"syno_fieldset",stateId:"SYNO.SDS.AdminCenter.FileService.Main::ftp::general",title:_T("common","general"),itemId:"generalFieldSet",collapsible:!0,items:[{xtype:"syno_displayfield",itemId:"ftp_adv_opt_desc",value:_T("ftp","ftp_advanced_option_desc")},{xtype:"syno_button",btnStyle:"default",itemId:"advBtn",text:_T("common","adv_setting"),autoWidth:!0,handler:this.onFtpAdvSettingBtnClick,scope:this},SYNO.SDS.BandwidthControl.SchedulePanelConfig(this,"FTP")]}},onFtpAdvSettingBtnClick:function(){new SYNO.SDS.AdminCenter.FileService.FTP.AdvancedSettingDialog({module:this.module,owner:this.module.appWin}).open()},createFtpTabObj:function(e){var t={xtype:"syno_fieldset",stateId:"SYNO.SDS.AdminCenter.FileService.Main::ftp::ftp",title:_T("ftp","ftp_ftpes"),itemId:"ftpFieldSet",name:"ftpFieldSet",collapsible:!0,webapi:{api:"SYNO.Core.FileServ.FTP",methods:{get:"get",set:"set"},version:1},items:[{xtype:"syno_checkbox",itemId:"enable_ftp",name:"enable_ftp",boxLabel:_T("ftp","ftp_enabled"),listeners:{scope:this,check:this.setFormsEnabled}},{xtype:"syno_checkbox",itemId:"enable_ftps",name:"enable_ftps",boxLabel:_T("ftp","ftpes_enabled"),listeners:{scope:this,check:this.setFormsEnabled}},{xtype:"syno_compositefield",indent:1,items:[{xtype:"syno_numberfield",name:"timeout",maxlength:4,width:166,fieldLabel:_T("ftp","ftp_timeout"),validator:function(e){var t=parseInt(e,10);return!(t<1||t>7200)||_T("error","error_bad_field")}},{xtype:"syno_displayfield",name:"timeout_desc",value:_T("time","time_second")+" "+_T("ftp","timeout_range"),"aria-label":_T("time","time_second")+" "+SYNO.ux.Utils.ConvertSingleSymbolToString(_T("ftp","timeout_range"),"~")}]},{xtype:"syno_numberfield",indent:1,name:"portnum",maxlength:5,width:166,fieldLabel:_T("ftp","ftp_port"),vtype:"port",validator:function(e){return!SYNO.SDS.Utils.isReservedPort("ftp",e,e)||_T("service","error_dl_port_in_used")}},{xtype:"syno_displayfield",indent:1,value:_T("ftp","ftp_pasv_port_range")},{xtype:"syno_radio",checked:!0,indent:2,name:"custom_port_range",inputValue:"false",boxLabel:_T("service","service_dl_default_port")+" ("+this.defaultPasvMinPort+"-"+this.defaultPasvMaxPort+")","aria-label":_T("service","service_dl_default_port")+this.defaultPasvMinPort+_T("ftp","ftp_port_to")+this.defaultPasvMaxPort},{xtype:"syno_radio",indent:2,name:"custom_port_range",inputValue:"true",boxLabel:_T("ftp","ftp_manual_port_range")+_T("common","colon")},{xtype:"syno_compositefield",hideLabel:!0,fieldLabel:"composite field",itemId:"custom_port_desc",indent:3,items:[{xtype:"syno_displayfield",value:_T("ftp","ftp_port_from")+_T("common","colon")},{xtype:"syno_numberfield",name:"port_low",maxlength:5,vtype:"port"},{xtype:"syno_displayfield",value:_T("ftp","ftp_port_to")+_T("common","colon")},{xtype:"syno_numberfield",name:"port_high",maxlength:5,vtype:"port"}]},{xtype:"syno_checkbox",indent:1,name:"use_ext_ip",boxLabel:_T("ftp","ftp_pasv_ext_ip")},{xtype:"syno_combobox",name:"ext_ip",itemId:"ext_ip",indent:2,fieldLabel:_T("ftp","ftp_pasv_ext_ip_assign"),store:new Ext.data.JsonStore({fields:["display","value"],idProperty:"value",data:[]}),editable:!0,displayField:"display",valueField:"value",width:230,allowBlank:!1,owner:this,onTriggerClick:function(){!1===this.disabled&&this.owner.onFtpExternalIPComboClick(this)},validator:function(e){if(""===e)return _JSLIBSTR("extlang","fieldblank");if(Ext.form.VTypes.ip(e))return!0;for(var t=0;t=t.length)n.module.panel.setStatusError({text:_T("routerconf","routerconf_external_ip_warning")});else{n.hasGetFtpExtIP=!0;for(var a=[],r=[],l=[],d=0;d(o=e.findField("port_high").getValue())&&(e.findField("port_low").setValue(o),e.findField("port_high").setValue(n),n=e.findField("port_low").getValue(),o=e.findField("port_high").getValue()),SYNO.SDS.Utils.isReservedPort("ftp",n,o))?(this.ownerCt.setStatusError({text:_T("ftp","ftp_port_in_used"),clear:!0}),!0):i>=n&&i<=o?(this.ownerCt.setStatusError({text:_T("ftp","ftp_ports_conflict"),clear:!0}),!0):s==i||s>=n&&s<=o?(this.ownerCt.setStatusError({text:_T("app_port_alias","err_port_dup"),clear:!0}),!0):i==this.sftpPort&&(this.ownerCt.setStatusError({text:_T("app_port_alias","err_port_dup"),clear:!0}),!0)},beforeRequest:function(e){return"set"!=e||!this.isPortConflict(this.getForm())},processParams:function(e,t){for(var i=this.getForm(),s={api:"SYNO.Core.FileServ.FTP.SFTP",method:"set",version:1},n=0;n=e.length)return this.actionGroup.disable("edit"),void this.actionGroup.disable("delete");this._S("demo_mode")||this.actionGroup.enable("delete"),1===e.length?this.actionGroup.enable("edit"):this.actionGroup.disable("edit")},createHandler:function(){new SYNO.SDS.AdminCenter.FileService.Rsync.CreateAccountDialog({owner:this.owner,module:this,title:_T("common","add"),isEdit:!1,old_name:"",password:"",confirmpassword:""}).open()},EditHandler:function(){var e=this.getSelectionModel().getSelections();Ext.isArray(e)&&1===e.length&&new SYNO.SDS.AdminCenter.FileService.Rsync.CreateAccountDialog({owner:this.owner,module:this,title:_T("common","alt_edit"),isEdit:!0,old_name:e[0].json.name,password:"12345678",confirmpassword:"87654321"}).open()},deleteHandler:function(){this.owner.getMsgBox().confirmDelete(_T("service","rsync_account"),_T("service","delete_check_rsync_account"),this.deleteBtnCB,this)},deleteBtnCB:function(e){var t=this.getSelectionModel().getSelections(),i=[];if("yes"==e&&!(0>=t.length)){for(var s=0;s";break;case SYNO.SDS.S2S.LAST_RESULT_PARTIAL:n="https://sy.to/s2serrorcode",o=String.format(_T("s2s","err_partial_success_reason"),``,""),s=''+_T("s2s","err_partial_success")+"",s+=String.format('
',o);break;case SYNO.SDS.S2S.LAST_RESULT_CANCEL:s=_T("common","alt_cancel");break;default:s=_T("status","status_not_available")}return s},SYNO.SDS.S2S.ScheduleRenderer=function(e,t,i){switch(e.mode){case SYNO.SDS.S2S.SCHD_REALTIME:return _T("s2s","s2s_lbl_sched_realtime");case SYNO.SDS.S2S.SCHD_MANUAL:return _T("s2s","s2s_lbl_sched_mode_man");default:var s=SYNO.SDS.S2S.ScheduleDateToString(e,e.mode);return s+="
",s+=SYNO.SDS.S2S.ScheduleTimeToString(e),null!==t&&(t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(s)+'"'),_T("schedule","schedule_advance")}},SYNO.SDS.S2S.GenGetJobParams=function(e){return{api:"SYNO.S2S.Client.Job",version:1,method:"get",params:{id:e,additional:["schedule","server","use_block","use_compression","use_ssh","ssh_port","user","rsync_timeout","sync_remote_mount"]}}},SYNO.SDS.S2S.GenListJobParams=function(e){return Ext.apply({api:"SYNO.S2S.Client.Job",version:1,method:"list"},e)},SYNO.SDS.S2S.GenGetShareParams=function(e){return Ext.apply({api:"SYNO.Core.Share",version:1,method:"list",params:{shareType:["local","enc","dec","cluster","cold_storage"]}},e)},SYNO.SDS.S2S.GenRunActionParamsByAction=function(e,t){var i={api:"SYNO.S2S.Client.Job",params:{id:t}};switch(e){case SYNO.SDS.S2S.ACTION_SYNC_NOW:i.version=1,i.method="start",i.params.sync_mode="normal";break;case SYNO.SDS.S2S.ACTION_SYNC_FULL:i.version=1,i.method="start",i.params.sync_mode="full_sync";break;case SYNO.SDS.S2S.ACTION_DELETE:i.version=1,i.method="delete";break;case SYNO.SDS.S2S.ACTION_CANCEL:i.version=1,i.method="stop";break;default:return void SYNO.Debug("SYNO.SDS.S2S.S2SaskPage: unknown action ["+e+"]")}return i},SYNO.SDS.S2S.GenGetNetworkParams=function(e){return Ext.apply({api:"SYNO.Core.System",version:1,method:"info",params:{type:"network"}},e)},SYNO.SDS.S2S.GenCreateJobParams=function(e){return Ext.apply({api:"SYNO.S2S.Client.Job",version:1,method:"create"},e)},SYNO.SDS.S2S.GenSetJobParams=function(e){return Ext.apply({api:"SYNO.S2S.Client.Job",version:1,method:"set"},e)},SYNO.SDS.S2S.GenListServerParams=function(e){return Ext.apply({api:"SYNO.S2S.Client",version:1,method:"list_server",params:{sort_by:"name"}},e)},SYNO.SDS.S2S.GenGetServerParams=function(e){return Ext.apply({api:"SYNO.S2S.Server",version:1,method:"get"},e)},SYNO.SDS.S2S.GenListPairParams=function(e){return Ext.apply({api:"SYNO.S2S.Server.Pair",version:1,method:"list",params:{additional:["sync_shares"]}},e)},SYNO.SDS.S2S.GenDelPairParams=function(e){return Ext.apply({api:"SYNO.S2S.Server.Pair",version:1,method:"delete"},e)},Ext.define("SYNO.SDS.S2S.ClientDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){return Ext.apply({width:780,minWidth:720,height:300,minHeight:300,title:_T("s2s","s2s_btn_client_task_list"),layout:{type:"fit"},items:[this.jobGrid=new SYNO.SDS.S2S.JobGrid({owner:this})],closeAction:"closeHandler",buttons:[{text:_T("common","close"),handler:this.closeHandler,scope:this}]},e)},onShow:function(){return this.jobGrid.onPageActivate()},closeHandler:function(){this.jobGrid.onPageDeactivate(),this.close()}}),Ext.define("SYNO.SDS.S2S.JobGrid",{extend:"SYNO.ux.GridPanel",constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"activate",function(e,t){this.applyActionAndReload(null),this.startPollStatus(!1)},this),this.mon(this,"deactivate",function(e,t){this.stopPollStatus()},this)},fillConfig:function(e){this.actionGroup=this.createActionGroup();var t=new SYNO.API.Store({reader:new Ext.data.JsonReader({idProperty:SYNO.SDS.S2S.FIELD_ID,root:"",fields:[{name:SYNO.SDS.S2S.FIELD_ID},{name:SYNO.SDS.S2S.FIELD_SHARE},{name:SYNO.SDS.S2S.FIELD_SERVER,sortType:function(e){return e.name}},{name:SYNO.SDS.S2S.FIELD_STATUS},{name:SYNO.SDS.S2S.FIELD_RESULT},{name:SYNO.SDS.S2S.FIELD_SCHD,sortType:function(e){switch(e.mode){case SYNO.SDS.S2S.SCHD_REALTIME:return _T("s2s","s2s_lbl_sched_realtime");case SYNO.SDS.S2S.SCHD_MANUAL:return _T("s2s","s2s_lbl_sched_mode_man");default:return _T("schedule","schedule_advance")}}}]})});return this.addManagedComponent(t),Ext.apply({store:t,cm:this.getColModel(),tbar:this.toolbar=this.getToolbar(),listeners:{rowdblclick:{scope:this,fn:this.onRowDblClick},containercontextmenu:{scope:this,fn:this.onContainerContextMenu},rowcontextmenu:{scope:this,fn:this.onRowContextMenu}},selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{spacepressed:{scope:this,fn:this.onSpacePress},selectionchange:{scope:this,fn:this.onSelectionChange}}})},e)},startPollStatus:function(e){this.pollStatus||(this.pollStatus=this.pollReg({immediate:e,interval:SYNO.SDS.S2S.JobPollingIntervalSec,webapi:SYNO.SDS.S2S.GenListJobParams({params:{additional:["last_sync_result","server","schedule","status"]}}),status_callback:this.afterRequestJobs,scope:this}))},stopPollStatus:function(){this.pollStatus&&(this.pollUnreg(this.pollStatus),this.pollStatus=null)},getColModel:function(){return this.cm?this.cm:(this.cm=new Ext.grid.ColumnModel({defaults:{sortable:!0,menuDisabled:!0,align:"center"},columns:[{width:.15,header:_T("s2s","col_task_name"),dataIndex:SYNO.SDS.S2S.FIELD_ID},{width:.15,header:_T("s2s","s2s_lbl_src_share"),dataIndex:SYNO.SDS.S2S.FIELD_SHARE,renderer:SYNO.SDS.S2S.SyncShareRenderer},{width:.15,header:_T("s2s","col_task_destination"),dataIndex:SYNO.SDS.S2S.FIELD_SERVER,renderer:SYNO.SDS.S2S.DestinationRenderer},{width:.1,header:_T("s2s","col_task_status"),dataIndex:SYNO.SDS.S2S.FIELD_STATUS,renderer:SYNO.SDS.S2S.CurStatusRenderer},{width:.15,header:_T("s2s","s2s_lbl_lastSync_result"),dataIndex:SYNO.SDS.S2S.FIELD_RESULT,renderer:SYNO.SDS.S2S.LastResultRenderer},{width:.1,header:_T("s2s","s2s_lbl_sched_mode"),dataIndex:SYNO.SDS.S2S.FIELD_SCHD,renderer:SYNO.SDS.S2S.ScheduleRenderer}]}),this.cm)},createActionGroup:function(){var e=function(e){return new Ext.Action(Ext.apply({disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):""},e))},t=e({text:_T("common","create"),itemId:"create",handler:this.onCreateJob,scope:this}),i=e({itemId:"edit",disabled:!0,text:_T("common","alt_edit"),handler:this.onEditJob,scope:this}),s=e({itemId:"remove",disabled:!0,text:_T("common","delete"),handler:function(e,t){this.owner.getMsgBox().confirm(_T("s2s","s2s_app_title"),_T("common","remove_cfrmrmv"),function(e){"yes"===e&&this.applyActionAndReload(SYNO.SDS.S2S.ACTION_DELETE)},this)},scope:this}),n=e({itemId:"cancel",disabled:!0,text:_T("netbackup","netbkp_cancel"),handler:function(e,t){this.applyActionAndReload(SYNO.SDS.S2S.ACTION_CANCEL)},scope:this}),o=e({itemId:"sync_now",disabled:!0,text:_T("s2s","s2s_btn_sync_imm"),handler:function(e,t){this.applyActionAndReload(SYNO.SDS.S2S.ACTION_SYNC_NOW)},scope:this}),a=e({itemId:"sync_all",disabled:!0,text:_T("s2s","s2s_btn_full_sync"),handler:function(e,t){this.applyActionAndReload(SYNO.SDS.S2S.ACTION_SYNC_FULL)},scope:this});return new SYNO.ux.Utils.ActionGroup([t,i,s,n,o,a])},getToolbar:function(){var e=this.actionGroup.getArray();return new Ext.Toolbar({defaultType:"syno_button",items:e})},onPageActivate:function(){return this.startPollStatus(!0),!0},onPageDeactivate:function(){return this.stopPollStatus(),!0},onCreateJob:function(e,t){var i=this.getStore().getCount(),s=this._D("s2s_task_max","2");if(i>=(s=parseInt(s,10)))this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("s2s","s2s_warn_reach_maxtask"));else{this.stopPollStatus();var n=new SYNO.SDS.S2S.NewJobWizard({module:this.module,appWin:this.appWin,owner:this.owner});this.mon(n,"close",function(e){this.applyActionAndReload(),this.startPollStatus(!1)},this),n.open()}},onEditJob:function(e,t){var i=this.getSelectionModel().getSelected();if(i){this.stopPollStatus();var s=new SYNO.SDS.S2S.ConfigDialog({owner:this.owner,jobId:i.get(SYNO.SDS.S2S.FIELD_ID)});this.mon(s,"close",function(e){this.applyActionAndReload(),this.startPollStatus(!1)},this),s.open()}},afterRequestJobs:function(e,t,i,s){e&&t&&Ext.isArray(t.jobs)||(SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.afterRequestJobs: get job list fail"),t={jobs:[]}),this.owner.clearStatusBusy();var n=t.jobs.length,o=this.getStore(),a=!1;if(o.getTotalCount()!==n)a=!0;else for(var r=0;n>r;r++){var l=o.getById(t.jobs[r][SYNO.SDS.S2S.FIELD_ID]);if(!l){a=!0;break}l.set(SYNO.SDS.S2S.FIELD_SHARE,t.jobs[r].sync_shares),l.set(SYNO.SDS.S2S.FIELD_SERVER,t.jobs[r].additional.server),l.set(SYNO.SDS.S2S.FIELD_STATUS,t.jobs[r].additional.status),l.set(SYNO.SDS.S2S.FIELD_RESULT,t.jobs[r].additional.last_sync_result),l.set(SYNO.SDS.S2S.FIELD_SCHD,t.jobs[r].additional.schedule)}a?o.loadData(t.jobs,!1):o.commitChanges(),this.onSelectionChange(this.getSelectionModel())},onRowContextMenu:function(e,t,i){e.getSelectionModel().selectRow(t,this.getSelectionModel().isSelected(t)),this.onContainerContextMenu(e,i)},onContainerContextMenu:function(e,t){var i=this.actionGroup.getArray();new SYNO.ux.Menu({autoDestroy:!0,items:i}).showAt(t.getXY()),t.preventDefault()},onRowDblClick:function(e){this.onSpacePress({grid:e})},onSpacePress:function(e){var t=e.grid.getSelectionModel().getSelections();t&&1==t.length&&this.isJobCan(SYNO.SDS.S2S.ACTION_EDIT,t[0].get(SYNO.SDS.S2S.FIELD_STATUS))&&this.onEditJob()},onSelectionChange:function(e){var t=e.getSelections(),i={edit:!0,remove:!0,cancel:!0,sync_now:!0,sync_all:!0};if(!this._S("demo_mode")&&t){1===t.length&&this.isJobCan(SYNO.SDS.S2S.ACTION_EDIT,t[0].get(SYNO.SDS.S2S.FIELD_STATUS))&&(i.edit=!1);for(var s=0;t.length>s;s++){var n=t[s].get(SYNO.SDS.S2S.FIELD_STATUS);if(this.isJobCan(SYNO.SDS.S2S.ACTION_DELETE,n)&&(i.remove=!1),this.isJobCan(SYNO.SDS.S2S.ACTION_CANCEL,n)&&(i.cancel=!1),this.isJobCan(SYNO.SDS.S2S.ACTION_SYNC_NOW,n)){var o=t[s].get(SYNO.SDS.S2S.FIELD_SCHD).mode;SYNO.SDS.S2S.SCHD_REALTIME!==o&&(i.sync_now=!1)}this.isJobCan(SYNO.SDS.S2S.ACTION_SYNC_FULL,n)&&(i.sync_all=!1)}for(var a in i)i.hasOwnProperty(a)&&(i[a]?this.actionGroup.disable(a):this.actionGroup.enable(a))}},isJobCan:function(e,t){switch(e){case SYNO.SDS.S2S.ACTION_EDIT:case SYNO.SDS.S2S.ACTION_SYNC_NOW:case SYNO.SDS.S2S.ACTION_SYNC_FULL:return t!==SYNO.SDS.S2S.STATUS_SYNCING;case SYNO.SDS.S2S.ACTION_CANCEL:return t===SYNO.SDS.S2S.STATUS_SYNCING;case SYNO.SDS.S2S.ACTION_DELETE:return!0;default:return!1}},applyActionAndReload:function(e){var t,i=SYNO.SDS.S2S.GenListJobParams({params:{additional:["last_sync_result","server","schedule","status"]}}),s=[i];if(e){var n=this.getSelectionModel().getSelections(),o=this.getValidJobIdsByAction(e,n);(t=SYNO.SDS.S2S.GenRunActionParamsByAction(e,o))&&s.unshift(t)}this.owner.setStatusBusy(),this.stopPollStatus(),this.sendWebAPI({compound:{stopwhenerror:!1,params:s},callback:function(e,s,n,o){if(this.owner.clearStatusBusy(),this.startPollStatus(!1),!e||!s)return SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.applyActionAndReload: sendWebAPI fail"),void this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("common","error_system"));SYNO.SDS.S2S.handleWebApiData(s.result,t,function(e,t){e&&(e.success||(SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.applyActionAndReload: command "+e.method+" fail"),this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),SYNO.SDS.S2S.GetWebAPIErrorString(e))))},this),SYNO.SDS.S2S.handleWebApiData(s.result,i,function(e,t){e?this.afterRequestJobs(e.success,e.data):SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.applyActionAndReload: no list job result")},this)},scope:this})},getValidJobIdsByAction:function(e,t){var i=[];if(t)e:for(var s=0;t.length>s;s++){var n=t[s].get(SYNO.SDS.S2S.FIELD_STATUS),o=t[s].get(SYNO.SDS.S2S.FIELD_SCHD).mode;switch(e){case SYNO.SDS.S2S.ACTION_SYNC_NOW:if(SYNO.SDS.S2S.STATUS_IDLE!==n||SYNO.SDS.S2S.SCHD_REALTIME===o)continue;break;case SYNO.SDS.S2S.ACTION_SYNC_FULL:if(SYNO.SDS.S2S.STATUS_IDLE!==n)continue;break;case SYNO.SDS.S2S.ACTION_DELETE:break;case SYNO.SDS.S2S.ACTION_CANCEL:if(SYNO.SDS.S2S.STATUS_SYNCING!==n)continue;break;default:SYNO.Debug("SYNO.SDS.S2S.S2SaskPage: unknown btn pressed");break e}i.push(t[s].get(SYNO.SDS.S2S.FIELD_ID))}return i}}),Ext.define("SYNO.SDS.S2S.PairDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"afterlayout",function(e){this.setStatusBusy(),this.sendWebAPI(SYNO.SDS.S2S.GenListPairParams({callback:this.afterRequestPairs,scope:this}))},this,{single:this})},fillConfig:function(e){return Ext.apply({width:500,height:320,padding:15,title:_T("s2s","s2s_dlg_pairinfo_title"),layout:{type:"fit"},items:[this.pairGrid=this.createGridPanel(e)],buttons:[{text:_T("common","close"),handler:function(){this.close()},scope:this}]},e)},createGridPanel:function(e){return new SYNO.ux.GridPanel({border:!1,store:this.createPairStore(),autoExpandColumn:"descr",columns:[{menuDisabled:!0,sortable:!1,width:200,header:_T("s2s","s2s_col_sharename"),dataIndex:"share"},{id:"descr",menuDisabled:!0,sortable:!1,width:150,header:_T("s2s","s2s_col_pairedclient"),dataIndex:"display",renderer:Ext.util.Format.htmlEncode}],tbar:{xtype:"toolbar",items:[{xtype:"syno_button",id:this.resetBtnId=Ext.id(),disabled:!0,text:_T("s2s","s2s_btn_unlink"),tooltip:e.appWin._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onResetBtnClick,scope:this}]},selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:{fn:function(e){this._S("demo_mode")||(0===e.getSelections().length?Ext.getCmp(this.resetBtnId).disable():Ext.getCmp(this.resetBtnId).enable())},scope:this}}})})},createPairStore:function(){var e=new SYNO.API.JsonStore({root:"",fields:[{name:"client_id"},{name:"client_name"},{name:"share"},{name:"display"}]});return this.addManagedComponent(e),e},afterRequestPairs:function(e,t,i,s){if(this.clearStatusBusy(),!e||!t||!Ext.isArray(t.clients))return SYNO.Debug("SYNO.SDS.S2S.S2STaskPage: get clients fail"),void this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),SYNO.SDS.S2S.GetWebAPIErrorString({error:t}));for(var n=t.clients,o=[],a=0;n.length>a;a++)for(var r=n[a].additional.sync_shares,l=0;r.length>l;l++)o.push({client_id:n[a].id,client_name:n[a].name,share:r[l],display:n[a].name+" \\ "+r[l]});this.pairGrid.getStore().loadData(o)},onResetBtnClick:function(){var e=this.pairGrid.getSelectionModel().getSelections(),t=[];Ext.each(e,function(e,i,s){t.push(e.get("share"))},this),this.getMsgBox().confirm(_T("s2s","s2s_app_title"),_T("s2s","s2s_cfm_reset_sharepair"),function(e){"yes"===e&&this.applyDeletePairByShareName(t)},this)},applyDeletePairByShareName:function(e){var t=SYNO.SDS.S2S.GenListPairParams(),i=SYNO.SDS.S2S.GenDelPairParams({params:{id_type:"sync_share",id:e}});this.setStatusBusy({text:_T("common","reset")}),this.sendWebAPI({compound:{stopwhenerror:!0,params:[i,t]},callback:function(e,s,n,o){var a=!1;if(this.clearStatusBusy(),!e||!s)return SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.applyDeletePairByShareName: sendWebAPI fail"),void this.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("common","error_system"));SYNO.SDS.S2S.handleWebApiData(s.result,i,function(e,t){if(!e||!e.success)return SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.applyDeletePairByShareName: deletePairWebAPI fail"),void(a=SYNO.SDS.S2S.GetWebAPIErrorString(e))},this),SYNO.SDS.S2S.handleWebApiData(s.result,t,function(e,t){if(!e)return SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.applyDeletePairByShareName: listPairWebAPI fail"),void(a=SYNO.SDS.S2S.GetWebAPIErrorString(e));this.afterRequestPairs(e.success,e.data)},this),a&&this.getMsgBox().alert(_T("s2s","s2s_app_title"),a)},scope:this})}}),Ext.define("SYNO.SDS.S2S.NewJobWizard",{extend:"SYNO.SDS.Wizard.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.mon(this.panelDestination,"test_connection",this.onTestConnection,this),this.mon(this,"afterlayout",this.requestJobsAndShares,this,{single:!0})},fillConfig:function(e){var t=[this.panelName=new SYNO.SDS.S2S.NamePanel({itemId:"taskname",nextId:"srcShare",header:!1,headline:_T("s2s","s2s_wiz_lbl_create_task"),description:_T("s2s","s2s_wiz_lbl_create_task_name"),owner:this}),this.panelShare=new SYNO.SDS.S2S.SharePanel({itemId:"srcShare",nextId:"destnet",header:!1,headline:_T("s2s","s2s_wiz_lbl_srcShare_select"),description:_T("s2s","s2s_wiz_sub_srcShare_select"),isWizard:!0,owner:this}),this.panelDestination=new SYNO.SDS.S2S.DestinationPanel({itemId:"destnet",nextId:"schedule",header:!1,headline:_T("s2s","s2s_wiz_lbl_set_dest"),description:_T("s2s","s2s_wiz_sub_set_dest"),owner:this}),this.panelSchedule=new SYNO.SDS.S2S.SchdPanel({itemId:"schedule",nextId:"summary",header:!1,headline:_T("s2s","s2s_wiz_lbl_setSched_title"),description:_T("s2s","s2s_wiz_sub_setSched"),owner:this}),this.panelOverview=new SYNO.SDS.S2S.OverviewPanel({itemId:"summary",nextId:null,header:!1,headline:_T("s2s","s2s_wiz_lbl_summary"),description:_T("wizcommon","summary_descr"),owner:this,getNext:function(){return this.owner.applyNewJob(),!1}})];return Ext.apply({title:_T("s2s","s2s_wiz_title"),width:600,height:560,steps:t},e)},onTestConnection:function(e){var t=e.getValues();t.sync_shares=this.panelShare.getSelectedShares(),SYNO.SDS.S2S.TestConnection(this,t,SYNO.SDS.S2S.TestConnectionCallBack,this)},requestJobsAndShares:function(){var e=SYNO.SDS.S2S.GenListJobParams(),t=SYNO.SDS.S2S.GenGetShareParams(),i=SYNO.SDS.S2S.GenGetNetworkParams();this.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:[e,t,i]},callback:function(s,n,o,a){var r=!1;if(this.clearStatusBusy(),!s||!n)return SYNO.Debug("SYNO.SDS.S2S.NewJobWizard.requestJobsAndShares: sendWebAPI fail"),void this.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("common","error_system"),function(){this.close()},this);SYNO.SDS.S2S.handleWebApiData(n.result,e,function(e,t){if(!e||!e.data)return SYNO.Debug("SYNO.SDS.S2S.NewJobWizard.requestJobsAndShares: listJobWebAPI fail"),void(r=SYNO.SDS.S2S.GetWebAPIErrorString(e));this.panelName.initUniqueId(e.data.jobs)},this),SYNO.SDS.S2S.handleWebApiData(n.result,t,function(e,t){if(!e||!e.data)return SYNO.Debug("SYNO.SDS.S2S.NewJobWizard.requestJobsAndShares: getShareWebAPI fail"),void(r=SYNO.SDS.S2S.GetWebAPIErrorString(e));this.panelShare.setValues(e.data.shares,[])},this),SYNO.SDS.S2S.handleWebApiData(n.result,i,function(e,t){if(!e||!e.data)return SYNO.Debug("SYNO.SDS.S2S.NewJobWizard.requestJobsAndShares: request network fail"),void(r=SYNO.SDS.S2S.GetWebAPIErrorString(e));var i=[];Ext.each(e.data.nif,function(e,t,s){i.push(e.addr),Ext.isArray(e.ipv6)&&Ext.each(e.ipv6,function(e){i.push(e.addr)})}),i.push(e.data.hostname.toLowerCase()),this.panelDestination.setInvalidDests(i)},this),r&&this.getMsgBox().alert(_T("s2s","s2s_app_title"),r,function(){this.close()},this)},scope:this})},applyNewJob:function(){var e={};Ext.apply(e,this.panelName.getForm().getValues()),Ext.apply(e,this.panelShare.getValues()),Ext.apply(e,this.panelDestination.getValues()),Ext.apply(e,this.panelSchedule.getValues()),this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI(SYNO.SDS.S2S.GenCreateJobParams({params:e,callback:function(e,t,i,s){this.clearStatusBusy(),e?this.close():this.getMsgBox().alert(_T("s2s","s2s_app_title"),SYNO.SDS.S2S.GetWebAPIErrorString({error:t}))},scope:this}))}}),Ext.define("SYNO.SDS.S2S.ConfigDialog",{extend:"SYNO.SDS.ModalWindow",applyBtnId:void 0,constructor:function(e){this.jobId=e.jobId;var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"afterlayout",this.requestJobConfAndShares,this,{single:!0}),this.mon(this.panelDestination,"test_connection",this.onTestConnection,this),this.mon(this.panelDestination,"destination_change",this.onDestinationChange,this)},fillConfig:function(e){var t=[this.panelShare=new SYNO.SDS.S2S.SharePanel({checkConfirmRename:!0,header:!1,title:_T("s2s","s2s_lbl_src_share"),headline:_T("s2s","s2s_wiz_lbl_srcShare_select"),description:_T("s2s","s2s_wiz_sub_srcShare_select"),cls:"s2s-edit",isWizard:!1,owner:this}),this.panelDestination=new SYNO.SDS.S2S.DestinationPanel({header:!1,title:_T("s2s","tab_destination"),headline:_T("s2s","s2s_wiz_lbl_set_dest"),description:_T("s2s","s2s_wiz_sub_set_dest"),owner:this}),this.panelSchedule=new SYNO.SDS.S2S.SchdPanel({header:!1,title:_T("s2s","s2s_wiz_lbl_schedule"),headline:_T("s2s","s2s_wiz_lbl_setSched_title"),description:_T("s2s","s2s_wiz_sub_setSched"),owner:this})];return Ext.apply({width:600,height:540,padding:15,title:_T("common","alt_edit"),layout:{type:"fit"},items:[{xtype:"syno_tabpanel",deferredRender:!1,plain:!0,activeTab:0,items:t}],fbar:{xtype:"statusbar",defaultText:" ",statusAlign:"left",buttonAlign:"left",items:[{text:_T("common","cancel"),xtype:"syno_button",btnStyle:"grey",handler:this.cancelHandler,scope:this},{id:this.applyBtnId=Ext.id(),text:_T("common","apply"),xtype:"syno_button",btnStyle:"blue",handler:this.applyHandler,scope:this}]}},e)},applyHandler:function(){return 0===this.panelShare.getSelectedShares().length?(this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("usbbackup","usbbkp_no_share")),!1):!1===this.panelShare.hasConfirmRename()?(this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("s2s","s2s_warn_accept_share_change")),!1):this.panelDestination.getForm().isValid()?!0===this.panelShare.isFirstSyncHomes()?(this.owner.getMsgBox().confirm(_T("s2s","s2s_app_title"),_T("s2s","s2s_warn_disable_server_home_service"),function(e){"yes"===e&&this.testConnection()},this),!1):void this.testConnection():(this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("error","error_bad_field")),!1)},testConnection:function(){var e=this.panelDestination.getValues();e.sync_shares=this.panelShare.getSelectedShares(),e.id=this.jobId,SYNO.SDS.S2S.TestConnection(this,e,function(e,t,i,s){e?this.applyJob():this.getMsgBox().alert(_T("s2s","s2s_app_title"),SYNO.SDS.S2S.GetWebAPIErrorString({error:t},_T("netbackup","netbkp_connection_testing_fail")))},this)},cancelHandler:function(){this.close()},onDestinationChange:function(e){this.panelShare.setConfirmRename(!1)},onTestConnection:function(e){var t=e.getValues();t.sync_shares=this.panelShare.getSelectedShares(),t.id=this.jobId,0!==t.sync_shares.length?SYNO.SDS.S2S.TestConnection(this,t,SYNO.SDS.S2S.TestConnectionCallBack,this):this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("usbbackup","usbbkp_no_share"))},requestJobConfAndShares:function(){var e=SYNO.SDS.S2S.GenGetShareParams(),t=SYNO.SDS.S2S.GenGetJobParams(this.jobId),i=SYNO.SDS.S2S.GenGetNetworkParams();this.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:[e,t,i]},callback:function(s,n,o,a){var r={},l=!1;if(this.clearStatusBusy(),!s||!n)return SYNO.Debug("SYNO.SDS.S2S.ConfigDialog.requestJobConfAndShares: sendWebAPI fail"),void this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("common","error_system"),function(){this.close()},this);SYNO.SDS.S2S.handleWebApiData(n.result,t,function(e,t){if(!e||!e.data)return SYNO.Debug("SYNO.SDS.S2S.ConfigDialog.requestJobConfAndShares: request jobs fail"),void(l=SYNO.SDS.S2S.GetWebAPIErrorString(e));r=e.data.jobs[0],this.panelDestination.setValues(r.additional),this.panelSchedule.setValues(r.additional.schedule)},this),SYNO.SDS.S2S.handleWebApiData(n.result,e,function(e,t){if(!e||!e.data)return SYNO.Debug("SYNO.SDS.S2S.ConfigDialog.requestJobConfAndShares: request shares fail"),void(l=SYNO.SDS.S2S.GetWebAPIErrorString(e));this.panelShare.setValues(e.data.shares,r.sync_shares?r.sync_shares:[])},this),SYNO.SDS.S2S.handleWebApiData(n.result,i,function(e,t){if(!e||!e.data)return SYNO.Debug("SYNO.SDS.S2S.ConfigDialog.requestJobConfAndShares: request network fail"),void(l=SYNO.SDS.S2S.GetWebAPIErrorString(e));var i=[];Ext.each(e.data.nif,function(e,t,s){i.push(e.addr),Ext.isArray(e.ipv6)&&Ext.each(e.ipv6,function(e){i.push(e.addr)})}),i.push(e.data.hostname.toLowerCase()),this.panelDestination.setInvalidDests(i)},this),l&&this.getMsgBox().alert(_T("s2s","s2s_app_title"),l,function(){this.close()},this)},scope:this})},applyJob:function(){var e={id:this.jobId};Ext.apply(e,this.panelShare.getValues()),Ext.apply(e,this.panelDestination.getValues()),Ext.apply(e,this.panelSchedule.getValues()),this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI(SYNO.SDS.S2S.GenSetJobParams({params:e,callback:function(e,t,i,s){this.clearStatusBusy(),e?this.close():this.getMsgBox().alert(_T("s2s","s2s_app_title"),SYNO.SDS.S2S.GetWebAPIErrorString({error:t}))},scope:this}))}}),Ext.define("SYNO.SDS.S2S.NamePanel",{extend:"SYNO.SDS.Utils.FormPanel",ID_PREFIX:"Folder Sync ",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){return Ext.apply({title:_T("s2s","col_task_destination"),items:[{xtype:"syno_textfield",name:"id",id:this.nameId=Ext.id(),allowBlank:!1,maxLength:SYNO.SDS.S2S.BKPSET_MAX_LEN,vtype:"taskname",fieldLabel:_T("s2s","s2s_lbl_task_name")}]},e)},checkIdConflict:function(){this.owner.setStatusBusy(),this.sendWebAPI(SYNO.SDS.S2S.GenListJobParams({callback:function(e,t,i,s){if(this.owner.clearStatusBusy(),!e||!t||!t.jobs)return SYNO.Debug("SYNO.SDS.S2S.SharePanel.checkIdConflict: list job fail"),void this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),SYNO.SDS.S2S.GetWebAPIErrorString({error:t}));var n=Ext.getCmp(this.nameId).getValue();this.existJobId(t.jobs,n)?(SYNO.Debug("SYNO.SDS.S2S.SharePanel.setValues: id exists"),this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("s2s","s2s_warn_duplicate_taskname"),function(){Ext.getCmp(this.nameId).focus(!0)},this)):(this.owner.goNext(this.nextId),this.owner.panelShare.setConfirmRename(!1),this.owner.getButton("next").setDisabled(!0))},scope:this}))},existJobId:function(e,t){if(!e)return!1;for(var i=0;e.length>i;i++)if(e[i].id===t)return!0;return!1},initUniqueId:function(e){var t=1,i=this.ID_PREFIX+t;if(e)for(;this.existJobId(e,i);)t++,i=this.ID_PREFIX+t;Ext.getCmp(this.nameId).setValue(i)},getValues:function(){return this.getForm().getValues()},getNext:function(){if(!this.getForm().isValid())return this.owner.setStatusError({text:_T("common","forminvalid"),clear:!0}),Ext.getCmp(this.nameId).focus(!0),!1;var e=Ext.util.Format.trim(Ext.getCmp(this.nameId).getValue());return Ext.getCmp(this.nameId).setValue(e),this.checkIdConflict(),!1},summary:function(e){e.append(_T("s2s","col_summary_task_name"),Ext.getCmp(this.nameId).getValue())}}),Ext.define("SYNO.SDS.S2S.SharePanel",{extend:"SYNO.SDS.Utils.FormPanel",isWizard:!1,constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.isWizard=e.isWizard,this.mon(this,"afterlayout",function(){this.setConfirmRename(t.checkConfirmRename)},this,{single:!0}),this.mon(this.selectCol,"click",function(){this.setConfirmRename(!1)},this),this.mon(Ext.getCmp(this.shareGridId),"headerclick",function(e,t,i){0===t&&this.setConfirmRename(!1)},this)},fillConfig:function(e){var t=new SYNO.API.Store({reader:new Ext.data.JsonReader({idProperty:"name",root:"",fields:[{name:"selected"},{name:"name"}]})});this.addManagedComponent(t);var i=new Ext.grid.ColumnModel({defaults:{menuDisabled:!0},columns:[this.selectCol=new SYNO.ux.EnableColumn({width:75,header:_T("usbbackup","usbbkp_select_all"),align:"center",dataIndex:"selected"}),{sortable:!0,width:350,header:_T("s2s","col_share_name"),align:"center",dataIndex:"name"}]});return Ext.apply({checkConfirmRename:!1,items:[{xtype:"syno_gridpanel",id:this.shareGridId=Ext.id(),loadMask:!0,enableColumnMove:!1,enableHdMenu:!1,padding:0,height:300,cm:i,ds:t,plugins:[this.selectCol]},{xtype:"syno_checkbox",name:"confirmRename",id:this.confirmRenameId=Ext.id(),height:"auto",boxLabel:_T("s2s","s2s_wiz_warn_shareData_del"),listeners:{check:{fn:function(e,t){this.isWizard?(this.owner.getButton("next").setDisabled(!t),this.owner.getButton("next").setTooltip(t?"":_T("s2s","s2s_warn_accept_share_change"))):(Ext.getCmp(this.owner.applyBtnId).setDisabled(!t),Ext.getCmp(this.owner.applyBtnId).setTooltip(t?"":_T("s2s","s2s_warn_accept_share_change")))},scope:this}}}]},e)},setConfirmRename:function(e){Ext.getCmp(this.confirmRenameId).setValue(e)},setValues:function(e,t){if(!Ext.isArray(e)||!Ext.isArray(t))return SYNO.Debug("SYNO.SDS.S2S.SharePanel.setValues: set shares fail"),void this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("s2s","err_unexpected_error"));var i=0,s={};for(i=0;t.length>i;i++)s[t[i]]=!0;for(i=0;e.length>i;i++)e[i].selected=!!s[e[i].name];Ext.getCmp(this.shareGridId).getStore().loadData(e,!1)},getSelectedShares:function(){for(var e=Ext.getCmp(this.shareGridId).getStore(),t=[],i=0;e.getTotalCount()>i;i++){var s=e.getAt(i);s.get("selected")&&t.push(s.get("name"))}return t},getValues:function(){return{sync_shares:this.getSelectedShares()}},hasConfirmRename:function(){return Ext.getCmp(this.confirmRenameId).getValue()},isFirstSyncHomes:function(){var e=Ext.getCmp(this.shareGridId).getStore().getModifiedRecords(),t=!1;return Ext.each(e,function(e){if(e.get("selected")&&"homes"===e.get("name"))return t=!0,!1}),t},getNext:function(){return 0===this.getSelectedShares().length?(this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("usbbackup","usbbkp_no_share")),!1):!1===this.hasConfirmRename()?(this.owner.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("s2s","s2s_warn_accept_share_change")),!1):!0===this.isFirstSyncHomes()?(this.owner.getMsgBox().confirm(_T("s2s","s2s_app_title"),_T("s2s","s2s_warn_disable_server_home_service"),function(e){"yes"===e&&this.owner.goNext(this.nextId)},this),!1):this.nextId},summary:function(e){var t=this.getSelectedShares();0===t.length?e.append(_T("s2s","col_summary_share_list"),_T("s2s","no_selected_share")):e.append(_T("s2s","col_summary_share_list"),t.join(","))}}),Ext.define("SYNO.SDS.S2S.DestinationPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.hasFindServer=!1;var t=this.fillConfig(e);this.callParent([t]),this.addEvents("test_connection","destination_change"),this.mon(this,"afterlayout",function(e,t){SYNO.ux.AddTip(this.getForm().findField("use_block").getEl(),_T("s2s","s2s_wiz_desc_enable_blockLvl"))},this,{single:!0}),this.mon(this,"afterlayout",function(){var e=new Ext.Component({autoEl:"span",renderTo:this.getForm().findField("ssh_port_check").getEl().next("label")});SYNO.ux.AddTip(e.getEl(),_T("s2s","s2s_wiz_desc_customize_ssh_port"))},this,{single:!0})},fillConfig:function(e){var t=new SYNO.API.Store({reader:new Ext.data.JsonReader({idProperty:"name",root:"",fields:[{name:"ip"},{name:"name"},{name:"display"}]})});return this.addManagedComponent(t),Ext.apply({labelWidth:275,items:[this.combServer=new SYNO.ux.ComboBox({name:"server",allowBlank:!1,editable:!0,width:200,mode:"local",displayField:"display",valueField:"display",triggerAction:"all",fieldLabel:_T("netbackup","netbkp_set_ip"),emptyText:_T("netbackup","netbkp_input_addr"),owner:this,store:t,validator:Ext.createDelegate(this.validateServerName,this),onTriggerClick:function(){this.owner.onServerComboClick()},listeners:{change:{fn:function(e){this.fireEvent("destination_change")},scope:this}}}),{xtype:"syno_textfield",name:"user",allowBlank:!1,fieldLabel:_T("netbackup","netbkp_account")},{xtype:"syno_textfield",name:"password",fieldLabel:_T("common","password"),inputType:"password"},{xtype:"syno_numberfield",name:"rsync_timeout",allowBlank:!1,allowNegative:!1,maxValue:86400,minValue:600,maxlength:5,fieldLabel:_T("s2s","s2s_connection_timeout"),value:600},{xtype:"syno_checkbox",name:"ssh_port_check",boxLabel:_T("s2s","s2s_lbl_customize_ssh_port"),scope:this,handler:function(e,t){t?this.getForm().findField("ssh_port").enable():this.getForm().findField("ssh_port").disable()}},{xtype:"syno_numberfield",name:"ssh_port",disabled:!0,allowBlank:!1,indent:1,maxlength:5,vtype:"port",fieldLabel:_T("common","port")},{xtype:"syno_checkbox",name:"use_ssh",boxLabel:_T("netbackup","encryption_enable")},{xtype:"syno_checkbox",name:"use_compression",boxLabel:_T("netbackup","compression_enable")},{xtype:"syno_checkbox",name:"use_block",boxLabel:_T("s2s","s2s_wiz_lbl_enable_blockLvl")},{xtype:"syno_checkbox",name:"sync_remote_mount",boxLabel:_T("s2s","s2s_sync_remote_mount")},{xtype:"syno_button",text:_T("netbackup","netbkp_test_connection"),handler:function(e,t){this.fireEvent("test_connection",this)},scope:this}]},e)},validateServerName:function(e){var t=this.invalidDests,i=e.indexOf("("),s=e.indexOf(")");return e=e.toLowerCase(),i>0&&i0&&(i=e.substring(0,t)),Ext.form.VTypes.netbiosName(i)||Ext.form.VTypes.hostname(i)&&!Ext.form.VTypes.looseip(i)?i:""},getHostIp:function(e){var t=e.indexOf("("),i=e.indexOf(")"),s=e;return t>0&&to;o++){var a=t.servers[o].name;t.servers[o].ip!==a&&(a+="("+t.servers[o].ip+")"),n.push({ip:t.servers[o].ip,name:t.servers[o].name,display:a})}this.combServer.isExpanded()||this.combServer.el.focus(),this.combServer.getStore().loadData(n)},setInvalidDests:function(e){e?Ext.isArray(e)?this.invalidDests=e.slice(0):this.invalidDests=[e]:this.invalidDests=null},setValues:function(e){if(e){var t=e.server.name,i=e.server.ip,s=t;i!==s&&(s+="("+i+")"),this.combServer.setValue(s);var n=this.getForm();n.findField("use_block").setValue(e.use_block),n.findField("use_compression").setValue(e.use_compression),n.findField("use_ssh").setValue(e.use_ssh),n.findField("ssh_port_check").setValue(0!==e.ssh_port),n.findField("ssh_port").setValue(e.ssh_port?e.ssh_port:""),n.findField("user").setValue(e.user),n.findField("rsync_timeout").setValue(e.rsync_timeout),n.findField("sync_remote_mount").setValue(e.sync_remote_mount),n.findField("password").setValue(SYNO.SDS.S2S.GetFakePswd())}else SYNO.Debug("SYNO.SDS.S2S.DestinationPanel.setValues: fail")},getValues:function(e,t){var i=this.getForm(),s=i.findField("server").getValue(),n=this.getHostName(s);return{server_ip:this.getHostIp(s),server_name:n,use_block:i.findField("use_block").getValue(),use_compression:i.findField("use_compression").getValue(),use_ssh:i.findField("use_ssh").getValue(),ssh_port:i.findField("ssh_port").disabled?0:parseInt(i.findField("ssh_port").getValue(),10),user:i.findField("user").getValue(),password:i.findField("password").getValue(),rsync_timeout:parseInt(i.findField("rsync_timeout").getValue(),10),sync_remote_mount:i.findField("sync_remote_mount").getValue()}},getNext:function(){return this.getForm().isValid()?this.nextId:(this.owner.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1)},summary:function(e){var t=this.getForm();e.append(_T("netbackup","netbkp_account"),t.findField("user").getValue()),t.findField("use_ssh").getValue()?e.append(_T("netbackup","netbkp_security"),_T("netbackup","netbkp_high_security")):e.append(_T("netbackup","netbkp_security"),_T("netbackup","netbkp_low_security")),t.findField("ssh_port").disabled?e.append(_T("s2s","col_summary_customize_ssh_port"),_T("common","default")):e.append(_T("s2s","col_summary_customize_ssh_port"),t.findField("ssh_port").getValue()),t.findField("use_compression").getValue()?e.append(_T("netbackup","netbkp_data_compression"),_T("common","enabled")):e.append(_T("netbackup","netbkp_data_compression"),_T("common","disabled")),t.findField("use_block").getValue()?e.append(_T("s2s","col_summary_blockbkp"),_T("common","enabled")):e.append(_T("s2s","col_summary_blockbkp"),_T("common","disabled")),e.append(_T("s2s","s2s_connection_timeout"),t.findField("rsync_timeout").getValue()),t.findField("sync_remote_mount").getValue()?e.append(_T("s2s","s2s_sync_remote_mount"),_T("common","enabled")):e.append(_T("s2s","s2s_sync_remote_mount"),_T("common","disabled"))}}),Ext.define("SYNO.SDS.S2S.SchdPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"afterlayout",function(e,t){new SYNO.ux.Utils.EnableRadioGroup(e.getForm(),this.scheduleRadio,{manual:[],realtime:[],advance:[this.advSchdBtn,"txtadvscheduletime","txtadvscheduleday"]}),this.setValues({})},this,{single:!0})},fillConfig:function(e){var t=new Date;return this.advSchdMode=SYNO.SDS.S2S.SCHE_WEEKLY,this.schdData={week_day:SYNO.SDS.S2S.WEEK_ALL,mode:SYNO.SDS.S2S.SCHD_REALTIME,start_year:t.getFullYear(),start_month:t.getMonth()+1,start_day:t.getDate(),first_hour:0,first_min:0,repeat_hour:0,repeat_min:0,repeat_in_day:0},this.scheduleRadio="schedule_radio",Ext.apply({title:Ext.util.Format.ellipsis(_T("usbbackup","usbbkp_schedule"),15),tabTip:_T("usbbackup","usbbkp_schedule"),items:[{xtype:"syno_radiogroup",items:[{name:this.scheduleRadio,id:this.radioRealtimeId=Ext.id(),checked:!0,inputValue:SYNO.SDS.S2S.SCHD_REALTIME,boxLabel:_T("s2s","s2s_wiz_lbl_setSched_realtime"),handler:this.schdModeChangeHandler,scope:this},{name:this.scheduleRadio,id:this.radioManualId=Ext.id(),checked:!1,inputValue:SYNO.SDS.S2S.SCHD_MANUAL,boxLabel:_T("s2s","s2s_wiz_lbl_setSched_man"),handler:this.schdModeChangeHandler,scope:this},{name:this.scheduleRadio,id:this.radioAdvanceId=Ext.id(),checked:!1,inputValue:SYNO.SDS.S2S.SCHD_ADVANCE,boxLabel:_T("schedule","schedule_advance"),handler:this.schdModeChangeHandler,scope:this},{xtype:"syno_button",id:this.advSchdBtn=Ext.id(),text:_T("schedule","schedule_title"),autoWidth:!0,indent:1,handler:function(e,t){var i=new SYNO.SDS.S2S.AdvSchdDialog({title:_T("schedule","schedule_advance"),owner:this.owner});this.mon(i,"confirm",this.onApplyAdvSchd,this),i.setValues(this.schdData),i.open()},scope:this},{xtype:"syno_displayfield",name:"txtadvscheduletime",disabled:!0,indent:1,value:" "},{xtype:"syno_displayfield",name:"txtadvscheduleday",disabled:!0,indent:1,value:" "}]}]},e)},setValues:function(e){if(e){switch(Ext.apply(this.schdData,e),this.schdData.mode){case SYNO.SDS.S2S.SCHD_MANUAL:case SYNO.SDS.S2S.SCHD_REALTIME:this.getForm().findField(this.scheduleRadio).setValue(this.schdData.mode);break;default:this.advSchdMode=this.schdData.mode,this.getForm().findField(this.scheduleRadio).setValue(SYNO.SDS.S2S.SCHD_ADVANCE)}this.printAdvSchd()}},getValues:function(){return{schedule_mode:this.schdData.mode,schedule_start_year:this.schdData.start_year,schedule_start_month:this.schdData.start_month,schedule_start_day:this.schdData.start_day,schedule_first_hour:this.schdData.first_hour,schedule_first_min:this.schdData.first_min,schedule_repeat_hour:this.schdData.repeat_hour,schedule_repeat_min:this.schdData.repeat_min,schedule_repeat_in_day:this.schdData.repeat_in_day,schedule_week_day:this.schdData.week_day}},schdModeChangeHandler:function(e,t){if(t)switch(e.getId()){case this.radioManualId:this.schdData.mode=SYNO.SDS.S2S.SCHD_MANUAL;break;case this.radioRealtimeId:this.schdData.mode=SYNO.SDS.S2S.SCHD_REALTIME;break;default:this.schdData.mode=this.advSchdMode}},onApplyAdvSchd:function(e,t){t&&(Ext.apply(this.schdData,t),this.advSchdMode=t.mode,this.printAdvSchd())},printAdvSchd:function(){var e=this.getForm().findField("txtadvscheduletime"),t=this.getForm().findField("txtadvscheduleday");e.setValue(SYNO.SDS.S2S.ScheduleDateToString(this.schdData,this.advSchdMode)),t.setValue(SYNO.SDS.S2S.ScheduleTimeToString(this.schdData))},getNext:function(){return this.nextId},summary:function(e){var t="";switch(this.schdData.mode){case SYNO.SDS.S2S.SCHD_REALTIME:t=_T("s2s","s2s_lbl_sched_realtime");break;case SYNO.SDS.S2S.SCHD_MANUAL:t=_T("s2s","s2s_lbl_sched_mode_man");break;default:t=SYNO.SDS.S2S.ScheduleDateToString(this.schdData,this.schdData.mode),t+=", ",t+=SYNO.SDS.S2S.ScheduleTimeToString(this.schdData)}e.append(_T("s2s","s2s_wiz_lbl_schedule"),t)}}),Ext.define("SYNO.SDS.S2S.OverviewPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){return Ext.apply({border:!1,layout:{type:"fit"},height:390,items:[this.grid=new SYNO.SDS.Wizard.SummaryStep({})]},e)},activate:function(){var e=this.owner.stepStack,t=null;this.grid.getStore().removeAll(!0);for(var i=0;i=a;a++)o.push(n(a));return t(e,o)},s=function(e){return Ext.apply({xtype:"syno_combobox",editable:!1,triggerAction:"all",mode:"local",displayField:"display",valueField:"value"},e)},n=i(this,0,23,function(e){return[String.leftPad(String(e),2,"0"),e]}),o=i(this,0,59,function(e){return[String.leftPad(String(e),2,"0"),e]}),a=t(this,[[_T("schedule","no_repeat"),SYNO.SDS.S2S.SCHE_ONCE],[_T("schedule","repeat_monthly"),SYNO.SDS.S2S.SCHE_MONTHLY],[_T("schedule","repeat_yearly"),SYNO.SDS.S2S.SCHE_YEARLY]]);return this.periodStore=t(this,[]),this.lastWorkHourStore=t(this,[]),this.scheduleRadio="scheduleRadio",Ext.apply({height:500,items:[{xtype:"syno_fieldset",title:_T("time","time_date"),items:[{xtype:"syno_radiogroup",items:[{name:this.scheduleRadio,boxLabel:_T("schedule","run_on_days"),inputValue:SYNO.SDS.S2S.RADIO_BY_WEEK},{xtype:"syno_schedulefield",id:this.weekDayId=Ext.id(),allowBlank:!1,editable:!1,boxMinWidth:200,boxMaxWidth:200,indent:1},{name:this.scheduleRadio,boxLabel:_T("schedule","by_date"),inputValue:SYNO.SDS.S2S.RADIO_BY_DATE},{xtype:"syno_datetimefield",id:this.startDateId=Ext.id(),allowBlank:!1,editable:!1,boxMinWidth:200,boxMaxWidth:200,indent:1,maxValue:"2037/12/31",minValue:"2005/1/1"},s({id:this.byDateId=Ext.id(),value:SYNO.SDS.S2S.SCHE_ONCE,boxMinWidth:200,boxMaxWidth:200,indent:1,store:a})]}]},{xtype:"syno_fieldset",title:_T("time","time_time"),items:[{xtype:"syno_compositefield",fieldLabel:_T("schedule","run_time_first"),items:[s({id:this.fisrtHourId=Ext.id(),width:60,store:n,listeners:{select:{fn:function(){this.updatePeriodStore(),this.updateLastWorkTimeStore()},scope:this}}}),{xtype:"syno_displayfield",value:":",tabIndex:-1},s({id:this.firstMinId=Ext.id(),width:60,store:o,listeners:{select:{fn:function(){this.updatePeriodStore(),this.updateLastWorkTimeStore()},scope:this}}})]},s({id:this.periodId=Ext.id(),value:0,fieldLabel:_T("schedule","schedule_every"),store:this.periodStore,listeners:{select:{fn:function(){this.updateLastWorkTimeStore()},scope:this}}}),s({id:this.repeatTimesId=Ext.id(),value:0,fieldLabel:_T("schedule","run_time_last"),store:this.lastWorkHourStore})]}]},e)},setValues:function(e){if(e){for(var t=[],i=0;e.week_day.length>i;i++)"0"!==e.week_day.charAt(i)&&t.push(i);switch(Ext.getCmp(this.weekDayId).setValue(t.join(",")),Ext.getCmp(this.startDateId).setValue(new Date(e.start_year,e.start_month-1,e.start_day)),Ext.getCmp(this.startDateId).isValid()||Ext.getCmp(this.startDateId).setValue(new Date),Ext.getCmp(this.fisrtHourId).setValue(e.first_hour),Ext.getCmp(this.firstMinId).setValue(e.first_min),this.updatePeriodStore(),Ext.getCmp(this.periodId).setValue(60*e.repeat_hour+e.repeat_min),this.updateLastWorkTimeStore(),Ext.getCmp(this.repeatTimesId).setValue(e.repeat_in_day),e.mode){case SYNO.SDS.S2S.SCHE_MONTHLY:case SYNO.SDS.S2S.SCHE_YEARLY:case SYNO.SDS.S2S.SCHE_ONCE:this.getForm().findField(this.scheduleRadio).setValue(SYNO.SDS.S2S.RADIO_BY_DATE),Ext.getCmp(this.byDateId).setValue(e.mode);break;default:this.getForm().findField(this.scheduleRadio).setValue(SYNO.SDS.S2S.RADIO_BY_WEEK),Ext.getCmp(this.byDateId).setValue(SYNO.SDS.S2S.SCHE_ONCE)}}},getValues:function(){for(var e=this.getForm().findField(this.scheduleRadio).getGroupValue(),t=Ext.getCmp(this.startDateId).getValue(),i="",s=["0","0","0","0","0","0","0"],n=Ext.getCmp(this.weekDayId).getValue().split(","),o=0;n.length>o;o++){s[parseInt(n[o],10)]="1"}switch(e){case SYNO.SDS.S2S.RADIO_BY_WEEK:i=SYNO.SDS.S2S.SCHE_WEEKLY;break;default:case SYNO.SDS.S2S.RADIO_BY_DATE:i=Ext.getCmp(this.byDateId).getValue()}return{mode:i,start_year:t.getFullYear(),start_month:t.getMonth()+1,start_day:t.getDate(),first_hour:Ext.getCmp(this.fisrtHourId).getValue(),first_min:Ext.getCmp(this.firstMinId).getValue(),repeat_hour:Math.floor(Ext.getCmp(this.periodId).getValue()/60),repeat_min:Ext.getCmp(this.periodId).getValue()%60,repeat_in_day:Ext.getCmp(this.repeatTimesId).getValue(),week_day:s.join("")}},updatePeriodStore:function(){var e,t=[],i=1440-(60*Ext.getCmp(this.fisrtHourId).getValue()+Ext.getCmp(this.firstMinId).getValue());t.push([_T("schedule","schedule_every_once"),0]),i>15&&t.push([String.format(_T("s2s","s2s_lbl_sched_every_min"),15),15]),i>30&&t.push([String.format(_T("s2s","s2s_lbl_sched_every_min"),30),30]);for(var s=1;i>60*s;s++)e=String.format(_T("s2s","s2s_lbl_sched_mode_every"),s),t.push([e,60*s]);this.periodStore.loadData(t),Ext.getCmp(this.periodId).getValue()>i&&Ext.getCmp(this.periodId).setValue(0)},updateLastWorkTimeStore:function(){for(var e=[],t=60*Ext.getCmp(this.fisrtHourId).getValue()+Ext.getCmp(this.firstMinId).getValue(),i=t,s=Ext.getCmp(this.repeatTimesId).getValue(),n=Ext.getCmp(this.periodId).getValue(),o=0;i<1440;){var a=Math.floor(i/60),r=i%60;if(e.push([SYNO.SDS.S2S.GetFormattedTimeStr(a,r),o]),i=t+ ++o*n,0===n)break}this.lastWorkHourStore.loadData(e),s>=o?Ext.getCmp(this.repeatTimesId).setValue(0):Ext.getCmp(this.repeatTimesId).setValue(s)}}),Ext.define("SYNO.SDS.S2S.AdvSchdDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.addEvents("confirm")},fillConfig:function(e){return this.panelSchedule=new SYNO.SDS.S2S.AdvSchdPanel({owner:this}),Ext.apply({title:e.title,width:510,height:480,items:[this.panelSchedule],buttons:[{text:_T("common","cancel"),handler:this.cancelHandler,scope:this},{text:_T("common","apply"),handler:this.applyHandler,btnStyle:"blue",scope:this}]},e)},applyHandler:function(){this.fireEvent("confirm",this,this.getValues()),this.close()},cancelHandler:function(){this.fireEvent("confirm",this,null),this.close()},getValues:function(){return this.panelSchedule.getValues()},setValues:function(e){this.panelSchedule.setValues(e)}}),Ext.ns("SYNO.SDS.AdminCenter.FileService"),Ext.define("SYNO.SDS.AdminCenter.FileService.RsyncTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"afterlayout",this.enableCheckGroup,this,{single:!0})},enableCheckGroup:function(){new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable",["rsync_sshd_port","enable_rsync_account"]),this.updateRsyncUI()},fillConfig:function(e){var t={title:_T("service","service_rsync"),autoScroll:!0,webapi:{api:"SYNO.Backup.Service.NetworkBackup",methods:{get:"get",set:"set"},version:1},items:this.createRsyncItems(e)};return Ext.apply(t,e),t},createRsyncItems:function(e){var t=[{xtype:"syno_displayfield",value:String.format(_T("service","service_rsync_desc"),"yes"===e.module.appWin._D("dockerdsm")||SYNO.SDS.Utils.isInVirtualDSM()?_T("service","service_rsync_nondsm_server"):_T("service","service_rsync_dsm_server"))},{xtype:"syno_checkbox",name:"enable",boxLabel:_T("service","enable_rsync_service"),listeners:{scope:this,check:this.updateRsyncUI}},{xtype:"syno_numberfield",name:"rsync_sshd_port",indent:1,maxlength:5,vtype:"port",labelWidth:270,fieldLabel:_T("service","rsync_sshd_port"),validator:function(e){return!SYNO.SDS.Utils.isReservedPort("ssh",e,e)||_T("service","error_dl_port_in_used")}},{xtype:"syno_checkbox",name:"enable_rsync_account",indent:1,boxLabel:_T("service","enable_rsync_account")},{xtype:"syno_displayfield",name:"rsync_account_desc",indent:2,value:_T("service","rsync_account_desc")},{xtype:"syno_button",id:this.AccountBtnId=Ext.id(),indent:2,disabled:!0,text:_T("service","edit_rsync_account"),handler:this.showRsyncAccount,scope:this}];return t.push(SYNO.SDS.BandwidthControl.SchedulePanelConfig(this,"NetworkBackup")),t},getScheduleForm:function(){return this.getForm()},updateRsyncUI:function(){var e=this.getForm(),t=e.findField("enable").getValue();this.bandwidthSettingEnable(t),e.findField("rsync_account_desc").setDisabled(!t),t?Ext.getCmp(this.AccountBtnId).enable():Ext.getCmp(this.AccountBtnId).disable()},processReturnData:function(e,t,i){this.processBandwidthReturnData(t,i),this.getForm().loadRecords(t.result,i.compound),this.sendServiceEvent()},processBandwidthReturnData:function(e,t){for(var i={api:"SYNO.Core.BandwidthControl.Protocol",method:"get",version:1,protocol:"NetworkBackup"},s=0;sparseInt(i[n],10))return!1;if(parseInt(s[n],10)'+_T("s2s","s2s_warn_multisrc_upgrade")+""},{xtype:"syno_displayfield",id:this.s2sResetDescId=Ext.id(),hidden:!0,value:_T("s2s","s2s_wiz_lbl_reset_desc")},{xtype:"syno_button",id:this.s2sResetBtnId=Ext.id(),hidden:!0,name:"resetS2Sbtn",text:_T("s2s","s2s_btn_cancel_sharepair"),handler:this.resetS2SPairInfo,scope:this}),i.push({xtype:"syno_button",id:this.s2sTaskListBtnId=Ext.id(),name:"clientS2Sbtn",text:_T("s2s","s2s_btn_client_task_list"),handler:this.showS2STasks,scope:this}),"yes"===this._D("netbkp")&&i.push({xtype:"syno_displayfield",hideLabel:!0,htmlEncode:!1,indent:0,value:''+_T("common","note")+_T("common","colon")+" "+String.format(_T("s2s","s2s_server_desc"),''+_T("service","service_rsync")+""),listeners:{render:function(e){var t=e.el.first("a");t&&this.mon(t,"click",function(e){e.preventDefault(),this.findAppWindow().startModule("SYNO.SDS.AdminCenter.FileService.Main",{tab:"rsync"})},this)},scope:this,single:!0,buffer:80}}),t.items=i,t},createBonjourListener:function(){return{check:{scope:this,fn:this.onBonjourCheckHandler}}},processParams:function(e,t){var i=this.getComponent("bonjourFieldSet"),s=this.getComponent("enable_ssdp").getComponent("ssdpCheckBox"),n=i.getComponent("enable_avahi"),o=i.getComponent("enable_printer_support"),a=i.getComponent("enable_smb_time_machine"),r=i.getComponent("enable_afp_time_machine"),l=this.getForm().findField("tftp_enable"),d=this.getForm().findField("tftp_root_path"),c=this.module.panel.smbTab.getForm().getValues().enable_samba,h=this.getComponent("enable_bypass_traverse_checking").getComponent("bypassCheckBox");if("set"==e){if(this.supportBtrfs){var u=this.getComponent("enable_reflink_copy").getComponent("reflinkCheckBox");u.isDirty()&&(t=t.concat({api:"SYNO.Core.FileServ.ReflinkCopy",method:"set",version:1,params:{reflink_copy_enable:u.getValue()}}))}(s.isDirty()||n.isDirty())&&(t=t.concat({api:"SYNO.Core.Web.DSM",method:"set",version:2,params:{enable_ssdp:s.getValue(),enable_avahi:n.getValue()}})),n.checked&&o.isDirty()&&(t=t.concat({api:"SYNO.Core.ExternalDevice.Printer.BonjourSharing",method:"set",version:1,params:{enable_bonjour_support:o.checked}})),n.checked&&(a.isDirty()||r.isDirty())&&(t=t.concat({api:"SYNO.Core.FileServ.ServiceDiscovery",method:"set",version:1,params:{enable_afp_time_machine:r.checked,enable_smb_time_machine:a.checked}})),c&&n.checked&&a.isDirty()&&a.checked&&(t=t.concat({api:"SYNO.Core.FileServ.SMB",method:"set",version:3,params:{enable_samba:!0,smb_max_protocol:3,enable_op_lock:!0,enable_durable_handles:!0,enable_smb2_leases:!0}})),this.bonjourChange=this.getForm().findField("enable_avahi").isDirty(),this.tftpChange=l.isDirty(),(this.tftpChange||d.isDirty())&&(t=t.concat({api:"SYNO.Core.TFTP",method:"set",version:1,params:{enable:l.getValue(),root_path:d.getValue()}})),h.isDirty()&&(t=t.concat({api:"SYNO.Core.ACL",method:"set_bypass_traverse",version:1,params:{enable:h.getValue()}}))}return this.supportBtrfs&&(t=t.concat({api:"SYNO.Core.FileServ.ReflinkCopy",method:"get",version:1})),t=(t=(t=(t=(t=t.concat({api:"SYNO.Core.Web.DSM",method:"get",version:2})).concat({api:"SYNO.Core.ExternalDevice.Printer.BonjourSharing",method:"get",version:1})).concat({api:"SYNO.Core.FileServ.ServiceDiscovery",method:"get",version:1})).concat({api:"SYNO.Core.TFTP",method:"get",version:1})).concat({api:"SYNO.Core.ACL",method:"get_bypass_traverse",version:1})},processReturnData:function(e,t,i){var s=!1,n=!1,o=!1,a=!1,r=!1,l=!1,d=!1,c="",h=!1,u=this.getComponent("bonjourFieldSet").getComponent("TimeMachineBtnId"),p={api:"SYNO.Core.Web.DSM",method:"get",version:2},_={api:"SYNO.Core.ExternalDevice.Printer.BonjourSharing",method:"get",version:1},m={api:"SYNO.Core.FileServ.ServiceDiscovery",method:"get",version:1},f={api:"SYNO.Core.FileServ.SMB",method:"get",version:3},S={api:"SYNO.Core.FileServ.ReflinkCopy",method:"get",version:1},g={api:"SYNO.Core.TFTP",method:"get",version:1},y={api:"SYNO.Core.ACL",method:"get_bypass_traverse",version:1};Ext.each(t.result,function(e,t){!0===SYNO.ux.Utils.checkApiConsistency(p,e)?(s=e.data.enable_ssdp,n=e.data.enable_avahi):!0===SYNO.ux.Utils.checkApiConsistency(S,e)?l=e.data.reflink_copy_enable:!0===SYNO.ux.Utils.checkApiConsistency(_,e)?o=e.data.enable_bonjour_support:!0===SYNO.ux.Utils.checkApiConsistency(m,e)?(a=e.data.enable_afp_time_machine,r=e.data.enable_smb_time_machine):!0===SYNO.ux.Utils.checkApiConsistency(f,e)?(this.enableSmbDurable=e.data.enable_durable_handles,this.enableSmb2Lease=e.data.enable_smb2_leases,this.smbMaxProtocol=e.data.smb_max_protocol,this.enableSmbOpLock=e.data.enable_op_lock):!0===SYNO.ux.Utils.checkApiConsistency(g,e)?(d=e.data.enable,c=e.data.root_path):!0===SYNO.ux.Utils.checkApiConsistency(y,e)&&(h=e.data.enable)},this),this.supportBtrfs?this.getForm().setValues({enable_ssdp:s,enable_reflink_copy:l,enable_avahi:n,enable_printer_support:o,enable_afp_time_machine:a,enable_smb_time_machine:r,tftp_enable:d,enable_bypass_traverse_checking:h,tftp_root_path:c}):this.getForm().setValues({enable_ssdp:s,enable_avahi:n,enable_printer_support:o,enable_afp_time_machine:a,enable_smb_time_machine:r,tftp_enable:d,enable_bypass_traverse_checking:h,tftp_root_path:c}),n||u.setDisabled(!0),this.sendServiceEvent()},sendServiceEvent:function(){this.bonjourChange&&SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.WinMacNfs.BONJOUR",!this.getForm().findField("enable_avahi").getValue()),this.tftpChange&&SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.FTP.TFTP",!this.getForm().findField("tftp_enable").getValue())},onBonjourCheckHandler:function(e,t){var i=!t;this.getComponent("bonjourFieldSet").getComponent("TimeMachineBtnId").setDisabled(i)},onTimeMachineBtnClick:function(){new SYNO.SDS.AdminCenter.FileService.Bonjour.TimeMachineDialog({module:this.module,owner:this.module.appWin}).open()},requestS2SServerInfo:function(e){if("yes"===this._D("support_s2s")&&"yes"!==this._D("usbstation")){var t=SYNO.SDS.S2S.GenListPairParams(),i=SYNO.SDS.S2S.GenGetServerParams();this.module.appWin.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:[t,i]},callback:function(e,s,n,o){var a={clients:[],enable:!1,status:SYNO.SDS.S2S.STATUS_UNKNOWN,isMultiClient:!0};if(this.module.appWin.clearStatusBusy(),!e||!s)return SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.requestServerInfo: sendWebAPI fail"),void this.module.appWin.getMsgBox().alert(_T("s2s","s2s_app_title"),_T("common","error_system"));SYNO.SDS.S2S.handleWebApiData(s.result,t,function(e,t){e&&e.data?a.clients=e.data.clients:e.error&&e.error.code===SYNO.SDS.S2S.ERRCODE_NO_CONFIG&&e.error.code===SYNO.SDS.S2S.ERRCODE_CONFIG_EMPTY||SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.requestServerInfo: get clients fail")},this),SYNO.SDS.S2S.handleWebApiData(s.result,i,function(e,t){e&&e.data?(a.enable=e.data.enable,a.status=e.data.status,a.isMultiClient=e.data.is_multi_client):SYNO.Debug("SYNO.SDS.S2S.S2STaskPage.requestServerInfo: get server config fail")},this),this.setS2SValues(a),this.doLayout()},scope:this})}},getS2SServerStatusString:function(e){switch(e){case SYNO.SDS.S2S.STATUS_SYNCING:return''+_T("s2s","s2s_lbl_status_sync")+"";case SYNO.SDS.S2S.STATUS_IDLE:return''+_T("s2s","s2s_lbl_status_idle")+"";default:return"-"}},setS2SValues:function(e){if(e){var t=this.getS2SServerStatusString(e.status);this.getForm().setValues([{id:this.s2sStatusId,value:t},{id:this.s2sPairLstId,value:Ext.util.Format.ellipsis(Ext.pluck(e.clients,"name").join(", "),50)}]),Ext.getCmp(this.s2sResetBtnId).setVisible(e.enable),Ext.getCmp(this.s2sPairLstId).setVisible(e.enable),this.isMultiClient=e.isMultiClient,e.enable&&!e.isMultiClient?(Ext.getCmp(this.s2sResetDescId).setVisible(!0),Ext.getCmp(this.s2sUpgradeDescId).setVisible(!0)):(Ext.getCmp(this.s2sResetDescId).setVisible(!1),Ext.getCmp(this.s2sUpgradeDescId).setVisible(!1)),e.isMultiClient?Ext.getCmp(this.s2sResetBtnId).setText(_T("s2s","s2s_btn_cancel_sharepair")):Ext.getCmp(this.s2sResetBtnId).setText(_T("common","alt_reset"))}else SYNO.Debug("SYNO.SDS.S2S.ServerPanel.setValues")},resetS2SPairInfo:function(){if(this.isMultiClient){var e=new SYNO.SDS.S2S.PairDialog({module:this.module,appWin:this.module.appWin,owner:this.module.appWin});this.mon(e,"close",this.requestS2SServerInfo,this),e.show()}else this.module.appWin.getMsgBox().confirm(_T("s2s","s2s_app_title"),_T("s2s","s2s_cfm_upgrade_reset"),function(e){"yes"===e&&this.sendWebAPI(SYNO.SDS.S2S.GenDelPairParams({callback:function(e,t,i,s){e?this.requestS2SServerInfo():this.module.appWin.getMsgBox().alert(_T("s2s","s2s_app_title"),SYNO.SDS.S2S.GetWebAPIErrorString({error:t}))},scope:this}))},this)},showS2STasks:function(){new SYNO.SDS.S2S.ClientDialog({module:this.module,appWin:this.module.appWin,owner:this.module.appWin}).show()}}),Ext.ns("SYNO.SDS.AdminCenter.FileService"),Ext.define("SYNO.SDS.AdminCenter.FileService.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.panel=new SYNO.SDS.AdminCenter.FileService.TabPanel({module:this})},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"win":return"yes"===this.panel._D("supportNFS","no")?"AdminCenter/file_winmacnfs_desc.html":"AdminCenter/file_winmac_desc.html";case"afp":return"AdminCenter/file_winmacnfs_mac.html";case"nfs":return"AdminCenter/file_winmacnfs_nfs.html";case"ftp":return"AdminCenter/file_ftp_desc.html";case"rsync":return"AdminCenter/file_rsync.html";case"adv":return"AdminCenter/file_service_discovery.html";default:return"AdminCenter/file_desc.html"}},getPanel:function(){return this.panel},setActivateParams:function(e){e&&e.tab&&(this.panel.setActiveTab(e.tab),"ftp"===e.tab&&!0===e.launchAdvanceDialog&&this.panel.getComponent("ftp").onFtpAdvSettingBtnClick())},activate:function(e){this.setActivateParams(e),this.panel.loadAllForm(),e&&e.tab&&this.panel.setActiveTab(e.tab)},deactivate:function(){for(var e=this.panel.getAllForms(),t=0;t{0}",SYNO.SDS.Utils.GetFeasibilityCheckMsg(e))}),String.format("{0}
    {1}
",e,i)},confirmACLBypassTraversePromise:function(){var e=this.advTab.getForm().findField("enable_bypass_traverse_checking").getValue(),t=this.advTab.getForm().findField("enable_bypass_traverse_checking").isDirty();return new Promise(function(i,s){t?this.sendWebAPI({api:"SYNO.Core.ACL",method:"validate_set_bypass_traverse",params:{enable:e},version:1,scope:this,callback:function(t,n,o){if(!t){let e=SYNO.API.Response.GetFirstError(n);const t=SYNO.API.Errors.core[e.code]||_T("common","error_system");return this.findWindow().getMsgBox().alert(null,t),void s()}if(n&&Ext.isArray(n.hard_reasons)&&n.hard_reasons.length>0){var a=e?_T("service","enable_bypass_traverse_hard_check_fail"):_T("service","disable_bypass_traverse_hard_check_fail");return this.findWindow().getMsgBox().alert(null,this.getFeasibilityCheckMsg(a,n.hard_reasons)),void s()}n&&Ext.isArray(n.soft_reasons)&&n.soft_reasons.length>0?this.findWindow().getMsgBox().confirm(null,this.getFeasibilityCheckMsg(_T("service","bypass_traverse_soft_check_fail"),n.soft_reasons),function(e){"yes"===e?i():s()},this):i()}}):i()}.bind(this))},applyHandler:function(e,t){this.confirmDisableAvahiPromise().then(this.confirmDisableSMBAFPPromise.bind(this)).then(this.confirmSMBTMConfigPromise.bind(this)).then(this.confirmWSTransferPromise.bind(this)).then(this.confirmACLBypassTraversePromise.bind(this)).then(this.applyAllForm.bind(this)).catch(Ext.emptyFn)}}),Ext.namespace("SYNO.SDS.Share"),Ext.define("SYNO.SDS.AdminCenter.User.ShareGrid",{extend:"SYNO.ux.GridPanel",WEBAPI_PARAM_SHARE_TYPE:["dec","local","usb","sata","cluster","c2","cold_storage"],WEBAPI_PARAM_ADDITIONAL:["hidden","encryption","is_aclmode"],constructor:function(e){var t=e.owner.newuser;this.owner=e.owner,this.isCopyMode=e.owner.isCopyMode,this.showHomesWarning=!0;var i=["is_aclmode","is_readonly","is_writable","is_deny","name","preview","inherit","is_custom","share_path","is_unite_permission",{name:"force_readonly_reason",defaultValue:void 0},"is_mask"];"yes"===this._D("support_s2s","no")&&i.push("is_sync_share");var s="",n="";!this.isCopyMode&&t?(s="list_by_group",n="local_group"):(s="list_by_user",n=e.owner.authType+"_user");var o=new SYNO.API.JsonStore({autoDestroy:!0,appWindow:e.appWin,api:"SYNO.Core.Share.Permission",method:s,version:1,baseParams:{user_group_type:n,share_type:this.WEBAPI_PARAM_SHARE_TYPE,additional:this.WEBAPI_PARAM_ADDITIONAL},listeners:{exception:{scope:e.owner,fn:SYNO.SDS.AdminCenter.User.UserDialog.prototype.onStoreException},load:{scope:this,fn:this.onLoad}},root:"shares",idProperty:"name",totalProperty:"total",fields:i}),a=new SYNO.ux.EnableColumn({header:_T("share","share_permission_readonly"),dataIndex:"is_readonly",width:SYNO.SDS.AdminCenter.User.UserDialog.prototype._defaultColumnWidth,align:"center",ownerGrid:this,isIgnore:function(e,t){return!0===t.get("is_mask")||this.ownerGrid.isAdminGroupMember()&&t.get("is_aclmode")},renderer:function(e,t,i){return!0===i.get("is_mask")?e="disabled":this.ownerGrid.isAdminGroupMember()&&i.get("is_aclmode")&&(e="disabled"),SYNO.SDS.Share.renderCheckBox.call(this,e,t,i)}}),r=new SYNO.ux.EnableColumn({header:_T("share","share_permission_writable"),dataIndex:"is_writable",width:SYNO.SDS.AdminCenter.User.UserDialog.prototype._defaultColumnWidth,align:"center",isIgnore:function(e,t){return!0===t.get("is_mask")},renderer:function(e,t,i){return!0===i.get("is_mask")?SYNO.SDS.Share.renderCheckBox.call(this,"disabled",t,i):SYNO.ux.EnableColumn.prototype.renderer.call(this,e,t,i)}}),l=new SYNO.ux.EnableColumn({header:_T("share","share_permission_none"),dataIndex:"is_deny",width:SYNO.SDS.AdminCenter.User.UserDialog.prototype._defaultColumnWidth,align:"center",isIgnore:function(e,t){return!0===t.get("is_mask")},renderer:function(e,t,i){return!0===i.get("is_mask")?SYNO.SDS.Share.renderCheckBox.call(this,"disabled",t,i):SYNO.ux.EnableColumn.prototype.renderer.call(this,e,t,i)}}),d=e.hideCustomColumn;"SYNO.SDS.CMS.Application"===e.module.appWin.getOpenConfig("className")&&(d=d||e.module.appWin._S("version")<4475),d=(d=!this.isCopyMode&&(d||t))||"yes"===this._D("usbstation","no")||!e.module.appWin._S("is_admin");var c=new SYNO.SDS.Share.CustomColumn({module:e.module,owner:e.owner,ownerGrid:this,dataIndex:"is_custom",hidden:d,isLockCustomSetting:!!this.isCopyMode,applyCallback:function(){this.getStore().load({params:{name:this.owner.username}})},applyTarget:this}),h=new Ext.grid.ColumnModel([new SYNO.SDS.Share.InfoColumn({dataIndex:"is_unite_permission",width:50,hidden:t,getHeaderAriaAttr:function(){return'aria-label="'+_T("share","unite_permission_description")+'"'}}),{id:"name",header:_T("share","share_name"),dataIndex:"name",tooltip:_T("share","share_name"),width:100,renderer:function(e,t){return e&&(t.attr=String.format('ext:qtip="{0}"',e)),e}},{header:_T("share","share_preview"),id:"preview",dataIndex:"preview",useHtmlEncodeRender:!1,tooltip:_T("share","share_preview"),width:120},new SYNO.SDS.AdminCenter.Share.Utils.PermissionColumn({header:_T("share","share_inherit"),dataIndex:"inherit",align:"left",width:158,tooltip:_T("share","share_inherit"),hidden:this._S("diskless")}),l,r,a,c]),u=''+_T("common","note")+_T("common","colon")+" "+_T("share","share_privileges_priority"),p={title:_T("share","share_rights"),cm:h,ds:o,cls:"without-dirty-red-grid",plugins:[a,r,l,c,new SYNO.ux.plugin.GroupHeaderGrid({groups:[{header:_T("share","share_user_permission"),dataIndex:["is_deny","is_writable","is_readonly","is_custom"]}]})],autoExpandColumn:"name",enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,colRo:a,colRw:r,colNa:l,colCu:c,clicksToEdit:1,loadMask:!0,sm:new Ext.grid.RowSelectionModel({singleSelect:!0}),bbar:new SYNO.ux.PageLessToolbar({store:o,doRefresh:this.doRefresh.bind(this)}),fbar:{xtype:"syno_toolbar",layout:"fit",style:"padding-top: 12px;",items:[{xtype:"syno_displayfield",htmlEncode:!1,style:"white-space: normal;",value:u,"aria-label":SYNO.ux.Utils.ConvertSingleSymbolToString(u,">",!0)}]},footerCfg:{style:"padding: 0px;"}};Ext.apply(p,e),this.callParent([p]),this.mon(this,"afterrender",this.defineShareGridBehaviors,this),this.mon(l,"click",function(e,t,i,s){var n=t.getStore().getAt(i);this.showHomesWarning&&"homes"===n.id&&!0===n.get("is_deny")&&!0===n.get("is_aclmode")&&(this.appWin.getMsgBox().alert(this.title,_T("share","warn_deny_rule_homes")),this.showHomesWarning=!1)},this)},doRefresh:function(){if(this.owner.newuser||!this.isChanged())if(this.owner.newuser){let e=[];this.owner.groupGrid.getStore().each(function(t){!0===t.get("is_member")&&e.push(t.get("name"))}),this.getStore().load({params:{name:e}})}else this.getStore().load({params:{name:this.owner.username}});else this.owner.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),function(e){"yes"===e?(this.owner.setStatusBusy(),this.owner.sendWebAPI({compound:{params:this.getWebAPI(this.owner.username)},callback:function(e,t){if(this.owner.clearStatusBusy(),e&&!t.has_fail)this.getStore().commitChanges(),this.doRefresh();else{let e=SYNO.API.Response.GetFirstError(t);this.owner.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})):(this.getStore().rejectChanges(),this.doRefresh())},this)},initComponent:function(){this.callParent(arguments),this.mon(this,"headerclick",function(e,t,i){this.getStore().suspendEvents(!1)},this)},defineShareGridBehaviors:function(){this.colRo.checkSelectAll(this.getStore()),this.colRw.checkSelectAll(this.getStore()),this.colNa.checkSelectAll(this.getStore()),this.mon(this,"cellclick",this.onGridCellClick,this),this.mon(this.getSelectionModel(),"spacepressed",this.onGridCellSpacePressed,this),this.mon(this,"headerspace",function(e){var t=this.getColumnModel(),i=t.findColumnIndex(e.dataIndex),s=t.getColumnId(i);this.onGridHeaderClick.call(this,t.getColumnById(s))},this),this.mon(this,"headerclick",function(e,t,i){var s=e.getColumnModel(),n=s.getColumnId(t);this.onGridHeaderClick.call(this,s.getColumnById(n))},this),"local"===this.owner.authType&&this.mon(this,"activate",function(){if(this.isAdminGroupMember()){var e=this.getStore();e.suspendEvents(!1),e.each(function(e){e.get("is_aclmode")&&this.restorePermission(e,"is_readonly")},this),this.checkPreviewAll(),e.resumeEvents()}this.getView().refresh()},this)},onLoad:function(e,t,i){e.suspendEvents(!1),!this.isCopyMode&&this.owner.newuser&&Ext.each(t,function(e){e.set("inherit",SYNO.SDS.AdminCenter.Share.Utils.convertBoolPermissions(e)),e.set("is_deny",!1),e.set("is_writable",!1),e.set("is_readonly",!1),e.set("is_custom",!1)},this),this.checkPreviewAll(),e.commitChanges(),e.resumeEvents(),this.getView().refresh()},restorePermission:function(e,t){var i=e.getChanges();i.hasOwnProperty(t)&&e.set(t,!i[t])},onGridCellSpacePressed:function(e,t){var i=e.grid,s=i.getStore().indexOf(e.getSelected()),n=e.getColIdx();0<=n&&this.onGridCellClick(i,s,n,t)},onGridCellClick:function(e,t,i,s){var n=e.getStore().getAt(t),o=e.getColumnModel().getDataIndex(i);if(!_S("is_admin")&&"is_writable"===o&&n.getChanges().hasOwnProperty("is_writable")&&this.owner.sharePermLimited.hasOwnProperty(n.data.name)&&!this.owner.sharePermLimited[n.data.name]&&!0===n.get("is_writable"))return n.set("is_writable",!1),void this.owner.getMsgBox().alert(this.title,_T("error","error_privilege_not_enough"));(function(e){return"is_readonly"===e||"is_writable"===e||"is_deny"===e})(o)&&(!0===n.get(o)?function(t,i){"is_readonly"!==t&&(i.set("is_readonly",!1),e.colRo.checkSelectAll(e.getStore())),"is_writable"!==t&&(i.set("is_writable",!1),e.colRw.checkSelectAll(e.getStore())),"is_deny"!==t&&(i.set("is_deny",!1),e.colNa.checkSelectAll(e.getStore())),"is_custom"!==t&&i.set("is_custom",!1)}(o,n):this.restorePermission(n,"is_custom")),this.checkPreview(n)},onGridHeaderClick:function(e){e.box_el&&(e.box_el.hasClass("syno-ux-cb-checked")?("is_readonly"!==e.dataIndex&&(this.colRo.box_el.removeClass("syno-ux-cb-checked"),this.colRo.onSelectAll()),"is_writable"!==e.dataIndex&&(this.colRw.box_el.removeClass("syno-ux-cb-checked"),this.colRw.onSelectAll()),"is_deny"!==e.dataIndex&&(this.colNa.box_el.removeClass("syno-ux-cb-checked"),this.colNa.onSelectAll()),this.getStore().each(function(e){e.set("is_custom",!1)},this)):this.getStore().each(function(e){this.restorePermission(e,"is_custom")},this)),this.checkPreviewAll(),this.getStore().resumeEvents(),this.getView().refresh()},checkPreview:function(e){e.set("preview",SYNO.SDS.AdminCenter.Share.Utils.colorizePermission(this.getFinalPermission(e)))},isChanged:function(){return 0!==this.getStore().getModifiedRecords().length},isAdminGroupMember:function(){if(Ext.isBoolean(this.owner.isAdminGroupMember))return this.owner.isAdminGroupMember;var e=null;return this.owner.groupGrid.store.each(function(t){if("administrators"===t.get("name").toLowerCase())return e=t,!1}),null!==e&&!0===e.get("is_member")},getFinalPermission:function(e){return"na"===e.data.inherit?"na":"cu"===e.data.inherit?e.data.is_deny?"na":"cu":"rw"===e.data.inherit?e.data.is_deny?"na":e.data.is_custom?"cu":"rw":e.data.is_deny?"na":e.data.is_custom?"cu":e.data.is_writable?"rw":"-"!==e.data.inherit||e.data.is_readonly?this.isAdminGroupMember()&&e.data.is_aclmode?"rw":"ro":"homes"===e.data.name?"default":"na"},getOpenConfig:function(){return{userName:this.owner.username,userType:"user"}},getWebAPI:function(e){var t=[];return Ext.each(this.getStore().getModifiedRecords(),function(e){t.push({name:e.data.name,is_readonly:e.data.is_readonly,is_writable:e.data.is_writable,is_deny:e.data.is_deny,is_custom:e.data.is_custom})}),0===t.length?[]:[{api:"SYNO.Core.Share.Permission",method:"set_by_user_group",version:1,params:{name:e||this.owner.username,user_group_type:this.owner.authType+"_user",permissions:t}}]},checkPreviewAll:function(){this.getStore().each(function(e){this.checkPreview(e)},this)},getShareInfoForS2S:function(){var e=[];return Ext.each(this.getStore().getModifiedRecords(),function(t){e.push({name:t.data.name,is_sync_share:t.data.is_sync_share,permissions:[{is_readonly:t.data.is_readonly,is_deny:t.data.is_deny,is_writable:t.data.is_writable,is_custom:t.data.is_custom}]})}),e}}),Ext.define("SYNO.SDS.AdminCenter.User.GenPasswordDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.passwordChecker=e.passwordChecker,this.user_account=this.passwordChecker.getInfo("getUserAcc"),this.user_fullname=this.passwordChecker.getInfo("getUserDesc"),this.panel=this.createPanel(),this.form=this.panel.getForm();var t={title:_T("passwd","passwd_generator"),width:300,height:150,resizable:!1,buttons:[{text:_T("common","cancel"),scope:this,handler:this.close},{text:_T("common","commit"),btnStyle:"blue",scope:this,handler:this.apply}],items:[this.panel]};Ext.apply(t,e),this.callParent([t])},createPanel:function(){var e,t;for(e=0;e<100&&(t=this.genPasswd(),!0!==this.passwordChecker.isPasswordValid(t,this.user_account,this.user_fullname));e++);var i={border:!1,items:[{xtype:"syno_textfield",width:200,hideLabel:!0,value:t,name:"random_passwd"}]};return SYNO.LayoutConfig.fill(i),new Ext.form.FormPanel(i)},applyPasswd:function(e){this.passwordChecker.setValue("getPasswd",e),this.passwordChecker.setValue("getPasswdConfirm",e)},apply:function(){var e=this.form.findField("random_passwd").getValue();this.applyPasswd(e),this.owner.userForm.findField("password").hidePasswordStrength(),this.close()},genPasswd:function(){var e,t,i=[],s=6,n="abcdefghijklmnopqrstuvwxyz",o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",a="~`!@#$%^&*()-_+={[}]|\\:;\"'<,>.?/",r="1234567890",l=n+o+a+r,d=0,c=function(e,t){return e.substr(t,1)};for(!0===this.passwordChecker.passwordPolicy.mixed_case&&(i.push(c(o,Math.floor(Math.random()*o.length))),i.push(c(n,Math.floor(Math.random()*n.length)))),!0===this.passwordChecker.passwordPolicy.included_numeric_char&&i.push(c(r,Math.floor(Math.random()*r.length))),!0===this.passwordChecker.passwordPolicy.included_special_char&&i.push(c(a,Math.floor(Math.random()*a.length))),!0===this.passwordChecker.passwordPolicy.min_length_enable&&(s=this.passwordChecker.passwordPolicy.min_length),d=i.length;d0;d--)t=Math.floor(Math.random()*d),e=i[d-1],i[d-1]=i[t],i[t]=e;return i.join("")}}),Ext.define("SYNO.SDS.AdminCenter.User.ChangePasswordDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.passwordChecker=e.passwordChecker,this.ori_name=e.ori_name,this.name=e.name,this.desc=e.desc,this.hideRandPwdBtn=void 0!==this.passwordChecker&&(!1===this.passwordChecker.passwordPolicy.strong_password_enable||"admin"===this.ori_name);var t=this.createPanel();this.userForm=t.getForm();var i={title:String.format(_T("user","change_password_title"),this.ori_name),width:418,height:this.hideRandPwdBtn?219:247,resizable:!1,layout:"fit",buttons:[{text:_T("common","cancel"),handler:this.close,scope:this},{text:_T("common","save"),btnStyle:"blue",handler:this.onApply,scope:this}],items:[t]};Ext.apply(i,e),this.callParent([i])},createPanel:function(){var e={labelWidth:170,padding:0,cls:"change-passwd-panel",items:[{xtype:"syno_button",text:_T("passwd","passwd_gen_title"),style:"margin-bottom: 12px;",hidden:this.hideRandPwdBtn,scope:this,handler:function(){new SYNO.SDS.AdminCenter.User.GenPasswordDialog({owner:this,passwordChecker:this.passwordChecker}).open()}},{xtype:"syno_passwordfield","aria-label":_T("user","user_passwd"),fieldLabel:_T("user","user_passwd"),maxLength:127,width:200,name:"password",updateWhenRender:!1,startValidate:!0,validator:this.passwordChecker?this.passwordChecker.isStrongValidator.createDelegate(this.passwordChecker):Ext.emptyFn,listeners:{afterrender:function(){this.hidePasswordStrength()},password_strength_get:function(){this.showPasswordStrength()}}},{xtype:"syno_textfield",textType:"password_confirm",fieldLabel:_T("user","user_repswd"),maxLength:127,name:"confirmpassword",width:200,labelHtmlEncode:!1,confirmFor:"password",validator:function(e){return e===this.ownerCt.getForm().findField(this.confirmFor).getValue()||_T("pppoe","error_password")}},{xtype:"hidden",name:"name",value:this.name},{xtype:"hidden",name:"description",value:this.desc}]},t=new SYNO.SDS.Utils.FormPanel(e);return this.passwordChecker&&(this.passwordChecker.getForm=function(){return t.getForm()}),t},onApply:function(){var e=this;if(!this.userForm.isValid())return this.getMsgBox().alert(e.title,_T("common","forminvalid")),!1;e.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.User",method:"set",version:1,params:{name:e.ori_name,password:this.userForm.findField("password").getValue()},encryption:["password"],callback:function(t,i){e.clearStatusBusy(),t?(e.updateUserInfo(i.password_last_change),e.close()):e.getMsgBox().alert(e.title,SYNO.API.getErrorString(i))}})},updateUserInfo:function(e){let t="";if(0===e)t=String.format('{0}',_T("user","user_acnt_mustchange"));else if(0",this.findField]},bbar:new SYNO.ux.PagingToolbar({store:this.getStore(),pageSize:this.pageSize,displayInfo:!0})},e);this.callParent([t])},initEvents:function(){this.mon(this,"activate",this.onActivate,this)},createAppStore:function(){return this.filter_store?this.filter_store:(this.filter_store=new SYNO.API.JsonStore({api:"SYNO.Core.AppPriv.App",method:"list",version:1,baseParams:{user_type:this.type,offset:0,limit:-1},idProperty:"app_id",root:"application",appWindow:this.module.appWin,loaded:!1,autoLoad:!0,listeners:{scope:this,load:function(e,t){e.sort("name","ASC"),e.insert(0,new Ext.data.Record({name:_T("itunes","itunes_any"),app_id:""})),this.privFilter.store.loaded||(this.privFilter.setValue(""),this.privFilter.store.loaded=!0),SYNO.SDS.AdminCenter.AppPrivileges.Utils.setUserTypeApp(e.baseParams.user_type,t),this.isAppLoaded=!0,this.clearAppBusyMask()}},autoDestroy:!0,fields:["name","app_id"]}),this.filter_store)},renderPrivileges:function(e,t,i,s,n,o){var a=[];if(!Ext.isArray(e))return"";var r=this.createAppStore();return Ext.each(e,function(e){if("SYNO.Rsync"!==e||"0"!==this._D("maxdisks")){var t=r.getById(e);t&&t.get("name")&&a.push(t.get("name"))}},this),a.sort(),a.join(", ")},load:function(){this.getStore().load({callback:function(e,t,i){i&&(this.isLoaded=!0)},scope:this})},onActivate:function(){this.isLoaded||this.load()},onListAppException:function(e,t,i,s,n,o){this.module.appWin.getMsgBox().alert(this.title,SYNO.API.getErrorString(n)),this.module.appWin.clearStatusBusy()},onBeforeLoad:function(e,t){this.module.appWin.setStatusBusy(),Ext.apply(t.params,{filter_method:this.privMethod.getValue(),filter_priv:this.privFilter.getValue()})},onLoad:function(e,t,i){this.isAppPermStoreLoaded=!0,this.clearAppBusyMask()},clearAppBusyMask:function(){this.isAppLoaded&&this.isAppPermStoreLoaded&&(this.getView().refresh(),this.module.appWin.clearStatusBusy())},onSelectionChange:function(){var e=this.getSelectionModel().getSelections();this.editAction.setDisabled(!e.length)},onEdit:function(){var e=this.getSelectionModel().getSelections();e.length&&new SYNO.SDS.AdminCenter.AppPrivileges.EditWindow({type:this.type,recs:e,owner:this.module.appWin,module:this.module}).open()}}),Ext.define("SYNO.SDS.AdminCenter.AppPrivileges.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin},createPanel:function(){this.title=_T("tree","leaf_appprivilege");var e=[];return Ext.each(["local","domain","ldap"],function(t){this.isSupport(t,this.appWin)&&e.push(this.createPrivGrid(t))},this),new SYNO.SDS.Utils.TabPanel({module:this,title:this.title,activeTab:0,fbar:void 0,items:e})},getPanel:function(){return this.panel||(this.panel=this.createPanel()),this.panel},getHelpParam:function(){return"AdminCenter/application_appprivilege.html"},activate:function(){return this.getPanel().items.each(function(e){e.findField&&e.findField.rendered&&e.findField.reset()},this),this.checkTypeStatus(),this.getPanel().doLayout(),this.loadTypeStatus(),!0},deactivate:function(){return this.getPanel().items.each(function(e){e.isLoaded=!1}),!0},loadTypeStatus:function(){this.appWin.setStatusBusy();var e=[{api:"SYNO.Core.Directory.LDAP",version:1,method:"get"}];this.getKnownAPI("SYNO.Core.Directory.Domain")&&e.push({api:"SYNO.Core.Directory.Domain",version:1,method:"get"}),this.appWin.sendWebAPI({compound:{stopwhenerror:!0,params:e},scope:this,callback:this.loadTypeStatusHandler})},loadTypeStatusHandler:function(e,t,i,s){var n,o,a={},r=!1;if(!this.appWin.isDestroyed)if(this.appWin.clearStatusBusy(),e&&!t.has_fail){for(n in this.getKnownAPI("SYNO.Core.Directory.Domain")&&(r=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get","enable_domain")),o=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.LDAP","get","enable_client"),Ext.apply(a,{domain:r,ldap:o}),this.isEnabled=function(e){return"local"===e||!!a[e]},a)a[n]&&!this.getPrivGridByType(n)&&this.getPanel().add(this.createPrivGrid(n));this.checkTypeStatus()}else this.appWin.getMsgBox().alert(this.title,_T("common","error_system"))},isSupport:function(e,t){return"local"===e||("domain"===e?"yes"===t._D("supportdomain"):"ldap"===e?"yes"===t._D("supportldap"):void 0)},isEnabled:function(e){return"local"===e},checkTypeStatus:function(){this.getPanel().items.each(function(e){this.isSupport(e.type,this.appWin)?this.getPanel().unhideTabStripItem(e):this.getPanel().hideTabStripItem(e),this.isEnabled(e.type)?(this.getPanel().unhideTabStripItem(e),e.enable()):e.disable()},this),this.getPanel().layout.activeItem.disabled&&(this.getPanel().layout.setActiveItem("local"),this.getPanel().layout.activeItem.show())},createPrivGrid:function(e){return new SYNO.SDS.AdminCenter.AppPrivileges.PrivilegeGrid({module:this,itemId:e,type:e})},getPrivGridByType:function(e){return this.getPanel().getComponent(e)}}),Ext.define("SYNO.SDS.AdminCenter.AppPrivileges.EditWindow",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.editUsers=[],Ext.each(e.recs,function(e){this.editUsers.push(e.data.user_name)},this),this.panel=this.initAppPrivilegeEditGrid({recs:e.recs});var t="";if(1===e.recs.length)t=e.recs[0].data.user_name;else{var i="";e.recs.each(function(e){i+=e.data.user_name+", "}),t=i.substr(0,i.length-2)}var s={title:Ext.util.Format.ellipsis(t,50,!0),layout:"fit",width:480,height:320,minWidth:480,minHeight:320,buttons:[{btnStyle:"blue",text:_T("common","apply"),scope:this,handler:this.onApplyClick},{text:_T("common","cancel"),scope:this,handler:this.close}],items:[this.panel]};Ext.apply(s,e),this.callParent([s]),this.panel.mon(this,"activate",function(){var t,i,s;t=SYNO.SDS.AdminCenter.AppPrivileges.Utils.getUserTypeApp(this.ownerCt.type),Ext.each(t,function(t){i=0,s=0,Ext.each(e.recs,function(e){-1==e.data.accepted_app.indexOf(t[1])?s++:i++}),t.push(0!==i&&(0===s||"gray"))}),this.getStore().loadData(t)},this.panel)},initAppPrivilegeEditGrid:function(e){var t,i=new Ext.data.ArrayStore({autoDestroy:!0,fields:["display","value","checked"]});return t=new SYNO.ux.EnableColumn({id:"privilege",header:_T("app_privilege","grant_privilege"),dataIndex:"checked",width:150,align:"center"}),new SYNO.ux.GridPanel(Ext.apply({itemId:"grid",ds:i,plugins:t,cm:new Ext.grid.ColumnModel([{id:"name",header:_T("user","user_account"),dataIndex:"display",width:100},t]),autoExpandColumn:"name",enableHdMenu:!1,selModel:new Ext.grid.RowSelectionModel({singleSelect:!1})},e))},onApplyClick:function(){var e=this.panel.getStore().getModifiedRecords(),t=[],i=[];e.length?(Ext.each(e,function(e){e.data.checked?t.push(e.data.value):i.push(e.data.value)}),this.setStatusBusy({text:_T("common","saving")}),this.module.appWin.sendWebAPI({api:"SYNO.Core.AppPriv",version:1,method:"set",params:{user_name:this.editUsers,accepted_app:t,rejected_app:i},scope:this,callback:this.onApplyCallback})):this.close()},onApplyCallback:function(e,t,i,s){this.clearStatusBusy(),e?(-1!==this.editUsers.indexOf(this._S("user"))&&this.applyModifiedRecord(t,this.panel.getStore()),this.module.getPanel().items.each(function(e){e.isLoaded=!1}),this.module.getPanel().layout.activeItem.load(),this.close()):this.setStatusError()},applyModifiedRecord:function(e,t){var i=t.getModifiedRecords();Ext.each(i,function(e){var t=e.data.value,i=e.data.checked;SYNO.SDS.StatusNotifier.setAppPrivilege(t,i)})}}),SYNO.SDS.AdminCenter.AppPrivileges.Utils={setApp:function(e,t){t.each(function(t){e.push([t.get("name"),t.get("app_id")])}),e.sort(function(e,t){return e[0]===t[0]?0:e[0]'+_T("app_privilege","deny_privilege")+"":"custom"===e?_T("app_privilege","grant_by_ip"):void 0},s=[this.allowCol,this.denyCol,this.advCol];e.showPreview&&"user"===e.entity_type&&s.push(new SYNO.ux.plugin.GroupHeaderGrid({groups:[{header:_T("share","share_user_permission"),dataIndex:["allow","deny","custom"]}]}));var n=Ext.apply({module:this,header:!1,border:!1,height:404,cls:"without-dirty-red-grid",ds:this.store,cm:new Ext.grid.ColumnModel({columns:[{id:"name",header:_T("common","name"),dataIndex:"name",width:168,scope:this,renderer:function(e,t){return e&&(t.attr=String.format('ext:qtip="{0}"',e)),e}},{header:_T("share","share_preview"),id:"preview",dataIndex:"preview",width:120,hidden:!e.showPreview,renderer:i},{header:_T("share","share_inherit"),id:"inherit",dataIndex:"inherit",width:180,hidden:!e.showPreview,renderer:i},this.allowCol,this.denyCol,this.advCol]}),plugins:s,autoExpandColumn:"name",enableHdMenu:!1,selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),bbar:new SYNO.ux.PageLessToolbar({store:this.store,doRefresh:this.doRefresh.bind(this)}),fbar:{xtype:"syno_toolbar",layout:"fit",style:"padding-top: 12px;",items:[{xtype:"syno_displayfield",htmlEncode:!1,style:"white-space: normal;",value:''+_T("common","note")+_T("common","colon")+" "+_T("app_privilege","affected_by_group")}]},footerCfg:{style:"padding: 0px;"}},e);this.callParent([n]),this.mon(this,"afterrender",this.definePrivGridBehaviors,this),this.mon(this,"activate",this.onLoadPrivilege,this,{single:!0})},definePrivGridBehaviors:function(){this.mon(this,"cellclick",this.onGridCellClick,this),this.mon(this.getSelectionModel(),"spacepressed",this.onGridCellSpacePressed,this),this.mon(this,"headerclick",function(e,t,i){var s=e.getColumnModel(),n=s.getColumnId(t);this.onGridHeaderClick.call(this,s.getColumnById(n))},this),this.mon(this,"headerspace",function(e){var t=this.getColumnModel(),i=t.findColumnIndex(e.dataIndex),s=t.getColumnId(i);this.onGridHeaderClick.call(this,t.getColumnById(s))},this)},activate:function(){this.onLoadPrivilege()},doRefresh:function(){this.owner.newuser||this.owner.newgroup||!this.isChanged()?this.onLoadPrivilege():this.owner.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),function(e){"yes"===e?(this.owner.setStatusBusy(),this.owner.sendWebAPI({compound:{stopwhenerror:!0,params:this.getWebAPI()},callback:function(e,t,i){if(this.owner.clearStatusBusy(),e&&!t.has_fail)this.store.commitChanges(),this.doRefresh();else{let e=SYNO.API.Response.GetFirstError(t);this.owner.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})):(this.store.rejectChanges(),this.doRefresh())},this)},onLoadPrivilege:function(){this.onBeforeLoadApp(),this.loadRules()},loadRules:function(){var e=[];if(this.isRuleReady=!1,Ext.isDefined(this.entity_name)&&(e=e.concat([{api:"SYNO.Core.AppPriv.Rule",version:1,method:"get",params:{entity_type:this.entity_type,entity_name:this.entity_name}}])),this.showPreview){var t={};"user"===this.entity_type&&(t=Ext.isDefined(this.entity_name)?{username:this.entity_name,include_user:!1}:{groups:this.previewGroups,is_group_name:void 0===this.isGroupName||this.isGroupName,include_everyone:!0}),e=e.concat({api:"SYNO.Core.AppPriv.App",version:2,method:"preview",params:t})}this.owner.sendWebAPI({compound:{stopwhenerror:!0,params:e},scope:this,callback:function(e,t,i,s){if(!e||t.has_fail)return this.owner.clearStatusBusy(),void this.owner.getMsgBox().alert(this.title,_T("common","error_system"));if(Ext.isDefined(this.entity_name)){var n=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.AppPriv.Rule","get");this.appRules=n.rules}if(this.showPreview){var o=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.AppPriv.App","preview");this.onRenderInherit(o.applications)}this.isRuleReady=!0,this.onRenderPriv()}})},getAppRules:function(){return this.isRuleReady?this.appRules:[]},onGridCellSpacePressed:function(e,t){var i=e.grid,s=i.getStore().indexOf(e.getSelected()),n=e.getColIdx();0<=n&&this.onGridCellClick(i,s,n,t)},onGridCellClick:function(e,t,i,s){var n=e.getStore().getAt(t),o=e.getColumnModel().getDataIndex(i);(function(e){return"allow"===e||"deny"===e})(o)&&(!0===n.get(o)?function(t,i){"allow"!==t&&(i.set("allow",!1),e.allowCol.checkSelectAll(e.getStore())),"deny"!==t&&(i.set("deny",!1),e.denyCol.checkSelectAll(e.getStore())),"custom"!==t&&i.set("custom",!1)}(o,n):this.restorePermission(n,"custom")),this.checkPreview(n)},restorePermission:function(e,t){var i=e.getChanges();i.hasOwnProperty(t)&&e.set(t,!i[t])},onGridHeaderClick:function(e){e.box_el&&(e.box_el.hasClass("syno-ux-cb-checked")?("allow"!==e.dataIndex&&(this.allowCol.box_el.removeClass("syno-ux-cb-checked"),this.allowCol.onSelectAll()),"deny"!==e.dataIndex&&(this.denyCol.box_el.removeClass("syno-ux-cb-checked"),this.denyCol.onSelectAll()),this.getStore().each(function(e){e.set("custom",!1)},this)):this.getStore().each(function(e){this.restorePermission(e,"custom")},this)),this.checkPreviewAll()},onBeforeLoadApp:function(){this.owner.setStatusBusy(),this.appReady=!1,this.owner.sendWebAPI({api:"SYNO.Core.AppPriv.App",version:2,method:"list",params:{offset:0,limit:this.pageSize},scope:this,callback:function(e,t,i){e?this.onLoad(t):this.owner.getMsgBox().alert(this.title,_T("common","error_system"))}})},onLoad:function(e){var t,i=e.applications,s=[];for(t=0;t0&&o.push({api:"SYNO.Core.AppPriv.Rule",version:1,method:"delete",params:{rules:t}}),i.length>0&&o.push({api:"SYNO.Core.AppPriv.Rule",version:1,method:"set",params:{rules:i}}),o},onRenderInherit:function(e){this.store.suspendEvents(!1);var t,i,s=this.store.getCount(),n=e.length;for(t=0;t5496,this.supportShareQuota="yes"===e.owner._D("support_share_quota","no"),this.showMask=!1,this.isCopyMode=e.owner.isCopyMode,this.owner=e.owner,this.hideUsedCapacity=e.hideUsedCapacity;var t=this.createStore(),i=this.createColModel(t),s=Ext.apply({plugins:[i.getColumnById("quota_enabled")],cls:"quota-grid",autoExpandColumn:"display_name",enableHdMenu:!1,enableColumnMove:!1,clicksToEdit:1,store:t,colModel:i,selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),view:new SYNO.ux.GroupingView({showGroupName:!1,getRowClass:function(e){if(this.isQuotaStatusDisabled(e.get("quota_status")))return"quota-row-disable"}.bind(this)}),bbar:new SYNO.ux.PageLessToolbar({store:t,doRefresh:this.doRefresh.bind(this)}),fbar:{xtype:"syno_toolbar",layout:"fit",style:"padding-top: 12px;",items:[{xtype:"syno_displayfield",htmlEncode:!1,style:"white-space: normal;",value:''+_T("common","note")+_T("common","colon")+" "+_T("user","quota_unconstrained_by_group")}]},footerCfg:{style:"padding: 0px;"},listeners:{beforeedit:{scope:this,fn:function(e){var t=e.record;"crash"!==t.get("status")&&t.get("target")||(e.cancel=!0),this.supportGroupQuota||t.get("quota_enabled")||(e.cancel=!0)}},validateedit:{scope:this,fn:this.checkVolumeConstraint}}},e);this.callParent([s]),this.mon(this,"activate",function(e){if(e.unmask(),e.showMask)e.mask.defer(100,e,[_T("user","edit_quota_latter")]);else if(e.owner.shareGrid&&e.owner.shareGrid.isAdminGroupMember()){var t=String.format(_T("user","edit_adminquota"),""+e.owner.userForm.findField("name").getValue()+"");e.mask.defer(100,e,[t])}}),this.mon(this,"deactivate",function(e){e.unmask()}),this.supportGroupQuota||(this.mon(this,"afteredit",function(e){var t=e.record;t.get("quota_enabled")&&"quota"===e.field&&0===e.value&&t.set("quota_enabled",!1)}),this.mon(this,"headerclick",this.onHeaderClick,this),this.mon(this,"cellclick",this.onCellClick,this,{delay:100}))},isQuotaStatusDisabled:function(e){return"incompatible"===e},convertToMB:function(e,t){return"TB"===t?1024*e*1024:"GB"===t?1024*e:e},checkVolumeConstraint:function(e){var t=e.record,i=t.get("total"),s=null,n="";if("quota"===e.field)s=this.convertToMB(e.value,t.get("unit"));else{if("unit"!==e.field)return!1;s=this.convertToMB(t.get("quota"),e.value)}return s>=i?(i/=1024,n=String.format(_T("user","user_quota_limit_max_vol"),t.get("volume"),i.toFixed(2)),e.grid.owner.getMsgBox().alert(_T("user","error_quota_set"),n),!1):!(t.get("limit_4T")&&s>=4194304)||(n="TB"===t.get("unit")?String.format(_JSLIBSTR("extlang","maxnumber"),"3 TB"):"GB"===t.get("unit")?String.format(_JSLIBSTR("extlang","maxnumber"),"4095 GB"):String.format(_JSLIBSTR("extlang","maxnumber"),"4194304 MB"),e.grid.owner.getMsgBox().alert(_T("user","error_quota_set"),n),!1)},onCellClick:function(e,t,i,s){var n=e.getStore().getAt(t);"quota_enabled"===e.getColumnModel().getColumnAt(i).id&&"crash"!==n.get("status")&&n.get("target")&&(n.get("quota_enabled")?(n.set("quota",1),e.startEditing(t,i-2)):n.set("quota",0))},onHeaderClick:function(e,t,i){var s=i.getTarget("input",1,!1);"quota_enabled"===e.getColumnModel().getColumnAt(t).id&&s&&e.getStore().each(function(e){if(!e.get("target"))return!0;s.classList.contains("syno-ux-cb-checked")?0===e.get("quota")&&e.set("quota",1):e.set("quota",0)})},createStore:function(){return new Ext.data.GroupingStore({listeners:{beforeload:{scope:this,fn:function(){this.owner.setStatusBusy()}},load:{scope:this,fn:function(){this.owner.clearStatusBusy()}},exception:{scope:this,fn:function(e,t,i,s,n,o){this.owner.clearStatusBusy(),SYNO.Debug("Store exception: ",e,t,i,s,n,o)}}},reader:new Ext.data.JsonReader({fields:[{name:"name",mapping:"name"},{name:"description",mapping:"description"},{name:"used",mapping:"used"},{name:"preview",mapping:"preview"},{name:"group_limit",mapping:"group_limit"},{name:"quota",mapping:"quota"},{name:"unit",mapping:"unit"},{name:"quota_enabled",mapping:"quota_enabled"},{name:"limit_4T",mapping:"limit_4T"},{name:"status",mapping:"status"},{name:"quota_status",mapping:"quota_status"},{name:"deduped",mapping:"deduped"},{name:"total",mapping:"total"},{name:"volume",mapping:"volume"},{name:"target",mapping:"target"},{name:"display_name",mapping:"display_name"}]}),groupField:"volume",idProperty:"name",autoDestroy:!0,remoteSort:!1})},doRefresh:function(){if("yes"!==_D("supportquota","no"))return;if(!this.owner.newuser&&this.isDirty())return void this.owner.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),function(e){"yes"===e?(this.owner.setStatusBusy(),this.owner.sendWebAPI({compound:{params:this.getWebAPI(this.owner.username)},callback:function(e,t,i){if(this.owner.clearStatusBusy(),e&&!t.has_fail)this.getStore().commitChanges(),this.doRefresh();else{let e=SYNO.API.Response.GetFirstError(t);this.owner.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})):(this.getStore().rejectChanges(),this.doRefresh())},this);let e={api:"SYNO.Core.Quota",version:1,params:{support_share_quota:"yes"===_D("support_share_user_quota","no")}};this.owner.newuser?(e.method="inspect",e.params.groups=[],this.owner.groupGrid&&this.owner.groupGrid.getStore().each(function(t){!0===t.get("is_member")&&e.params.groups.push(t.get("name"))})):(e.method="get",e.params.name=this.owner.username),this.owner.setStatusBusy(),this.owner.sendWebAPI({compound:{stopwhenerror:!0,params:[{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{offset:0,limit:-1,option:"include_cold_storage",location:"internal"}},e]},callback:function(t,i,s){if(this.owner.clearStatusBusy(),t&&!i.has_fail)this.loadQuotaSettings(SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Quota",e.method),SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Storage.Volume","list"));else{let e=SYNO.API.Response.GetFirstError(i);this.owner.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})},createColModel:function(e){let t=this;var i=new Ext.data.ArrayStore({fields:["value","display"],data:this.supportShareQuota?[["TB",_T("common","size_tb")],["GB",_T("common","size_gb")],["MB",_T("common","size_mb")]]:[["GB",_T("common","size_gb")],["MB",_T("common","size_mb")]]}),s=[{header:this.supportShareQuota?_T("common","volume_share"):_T("volume","volume"),dataIndex:"display_name",align:"left",renderer:function(e,t,i){return t.attr='ext:qtip="'+e+'"',"normal"===i.get("status")?e:String.format('({0})',e)}},{header:_T("user","acnt_used_cap"),dataIndex:"used",hidden:this.hideUsedCapacity,align:"left",width:120,renderer:function(e,i,s){return t.isQuotaStatusDisabled(s.get("quota_status"))?"-":!this.hidden&&s.get("target")?SYNO.SDS.Utils.CapacityRender(e,2):"-"}},{header:_T("user","user_quota_preview"),hidden:!this.supportGroupQuota,align:"left",width:120,renderer:function(e,i,s){return s.get("target")?t.isQuotaStatusDisabled(s.get("quota_status"))?_T("user","user_quota_no_limit"):s.get("quota")?`${s.get("quota")} ${_T("common","size_"+s.get("unit").toLowerCase())}`:0!==s.get("group_limit")?SYNO.SDS.Utils.CapacityRender(s.get("group_limit"),2):_T("user","user_quota_no_limit"):"-"}},{header:_T("user","group_quota_limit"),dataIndex:"group_limit",hidden:!this.supportGroupQuota,align:"left",width:135,renderer:function(e,i,s){return s.get("target")?t.isQuotaStatusDisabled(s.get("quota_status"))?_T("user","user_quota_no_limit"):0===s.get("group_limit")?_T("user","user_quota_no_limit"):SYNO.SDS.Utils.CapacityRender(e,2):"-"}},{header:_T("personal_settings","user_quota_capacity"),dataIndex:"quota",id:"quota",align:"left",width:140,editor:new SYNO.ux.NumberField({allowBlank:!0,allowNegative:!1,allowDecimals:!1,validateOnBlur:!0,selectOnFocus:!0,emptyText:_T("dhcp_server","unlimited"),validationEvent:"keyup",vtype:"number",listeners:{beforeshow:function(e){e.getValue()||e.reset()}}}),renderer:function(e,t,i){return e||(i.set(this.dataIndex,0),t.attr='style="color:#aaaaaa;"',e=_T("dhcp_server","unlimited")),i.get("target")?e:""}},{header:"",dataIndex:"unit",id:"unit",align:"left",width:80,editor:new SYNO.ux.ComboBox({store:i,lazyRender:!0,mode:"local",displayField:"display",valueField:"value",triggerAction:"all",editable:!1}),renderer:function(e,t,i){return i.get("target")?_T("common","size_"+e.toLowerCase()):""}},new SYNO.ux.EnableColumn({header:_T("user","enable_quota"),id:"quota_enabled",dataIndex:"quota_enabled",width:195,hidden:this.supportGroupQuota,enableFastSelectAll:!0,isIgnore:function(e,t){return!t.get("target")},renderer:function(e,t,i){return i.get("target")?SYNO.ux.EnableColumn.prototype.renderer.apply(this,arguments):""}}),{dataIndex:"volume",hidden:!0,groupRenderer:function(e,i,s){return"share"===s.get("target")&&(e+=" (btrfs)"),"volume"===s.get("target")&&(e+=" (ext4)"),t.isQuotaStatusDisabled(s.get("quota_status"))&&(wtip=Ext.util.Format.htmlEncode(_T("user","user_quota_unsupported")),e+=``),e}}];return new Ext.grid.ColumnModel({defaults:{width:130,align:"center"},columns:s,isCellEditable:function(i,s){var n=e.getAt(s);return!t.isQuotaStatusDisabled(n.get("quota_status"))&&Ext.grid.ColumnModel.prototype.isCellEditable.call(this,i,s)}})},configLeafObj:function(e,t){Ext.isDefined(e.quota)?(e.quota=Math.floor(e.quota),e.unit="MB",e.quota%1024==0&&(e.quota/=1024,e.unit="GB"),e.quota%1024==0&&(e.quota/=1024,e.unit="TB")):(e.quota=0,e.unit="GB"),e.quota_enabled=0!==e.quota,e.quota_enabled||(e.unit="GB"),Ext.isDefined(e.group_limit)||(e.group_limit=0),e.status=t.readonly?"crash":"normal",e.volume=t.display_name,e.total=Math.floor(t.size_total_byte/1024/1024),e.leaf=!0,e.expanded=!1},loadQuotaSettings:function(e,t){var i=this,s={},n=[];Ext.each(t.volumes,function(e){s[e.volume_path]=e}),Ext.isDefined(e.user_quota)||(e.user_quota=e.quota),Ext.each(e.user_quota,function(e){var t=s[e.volume];e.support_share_quota?(e.children=e.shares,e.leaf=!1,e.expanded=!0,e.status=t.readonly?"crash":"normal",e.volume=t.display_name,e.total=Math.floor(t.size_total_byte/1024/1024),e.display_name=t.display_name,e.description=Ext.util.Format.htmlEncode(t.description),Ext.each(e.children,function(s){i.configLeafObj(s,t),s.target="share",s.limit_4T=!1,s.display_name=s.name,s.description=Ext.util.Format.htmlEncode(s.description),s.quota_status=e.quota_status,s.deduped=e.deduped,n.push(s)})):(i.configLeafObj(e,t),e.target="volume",e.limit_4T=!0,e.name=t.volume_path,e.display_name=t.display_name,e.description=Ext.util.Format.htmlEncode(t.description),n.push(e))}),this.getStore().loadData(n)},isDirty:function(){return 0!==this.getStore().getModifiedRecords().length},confirmQuotaUpdate:function(){return this.getStore().getModifiedRecords().some(e=>"v1"===e.get("quota_status")&&!0===e.get("deduped"))},getWebAPI:function(e){var t=[];return this.getStore().getModifiedRecords().forEach(function(e){var i=parseInt(e.get("quota"),10);"share"===e.get("target")?t.push({share:e.get("name"),quota:this.convertToMB(i,e.get("unit"))}):"volume"===e.get("target")&&t.push({volume:e.get("name"),quota:this.convertToMB(i,e.get("unit"))})},this),0===t.length?[]:[{api:"SYNO.Core.Quota",method:"set",version:1,params:{name:e,user_quota:t}}]}}),Ext.define("SYNO.SDS.AdminCenter.User.UserDialog",{extend:"SYNO.SDS.ModalWindow",specialAccounts:["guest"],_defaultNameColumnWidth:150,_defaultColumnWidth:130,WEBAPI_PARAM_SHARE_TYPE:["dec","local","usb","sata","cluster","c2","cold_storage"],WEBAPI_PARAM_ADDITIONAL:["hidden","encryption","is_aclmode"],constructor:function(e){this.module=e.module,this.owner=e.owner,this.username=e.username,this.passwordChecker=e.passwordChecker,this.twoFactorObj={},this.authType=e.authType||"local",this.supportShareUserQuota="yes"===this._D("support_share_user_quota","no"),this.supportSharedOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main"),this.supportAppPrivOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.AppRulePrivileges.Main"),this.isSupportAppPriv=this._S("version")>4931,this.commonUsernames=[],this.panel=this.createTabPanel(e);var t={width:910,height:590,minWidth:910,minHeight:420,layout:"fit",buttons:[{text:_T("common","alt_cancel"),scope:this,handler:this.close},{text:_T("common","save"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.panel]};Ext.apply(t,e),this.callParent([t]),this.defineBehaviors(),this.userFormPanel.mon(this.userForm.findField("name"),"blur",function(){this.isValid()&&this.clearInvalid()},this.userForm.findField("password")),this.userFormPanel.mon(this.userForm.findField("description"),"blur",function(){this.isValid()&&this.clearInvalid()},this.userForm.findField("password"))},onClose:function(){return!1!==this.callParent(arguments)&&(!this.isTabsDirty()||(this.getMsgBox().confirm(_T("user","user_acnt_info"),_T("common","confirm_lostchange"),function(e){"yes"===e&&this.doClose()},this),!1))},createTabPanel:function(e){this.userFormPanel=this.initUserForm(),this.userForm=this.userFormPanel.getForm(),this.groupGrid=this.initGroupGrid({owner:this,module:this.module,appWin:this}),this.shareGrid=this.supportSharedOperation?this.initShareGrid({owner:this,module:this.module,appWin:this}):null,this.quotaGrid=this.initQuotaGrid({owner:this,module:this.module,appWin:this}),this.bandwidthGrid=this.initBandwidthGrid({owner:this,module:this.module,preview:!0}),this.appPrivilegeGrid=this.supportAppPrivOperation?this.initPrivilegeGrid({title:_T("user","user_application"),owner:this,module:this.module,entity_type:"user",entity_name:this.username,isSupportAppPriv:this.isSupportAppPriv,showPreview:!0,appFilter:function(t){if(-1'+_T("common","star")+"","aria-label":_T("user","user_account"),name:"name",disabled:"local"!==this.authType,allowBlank:!1,blankText:_T("user","error_noname"),validateOnBlur:!0,validationDelay:250,validationEvent:"keyup",validator:function(e){let t=this.userForm.findField("name");return!t.isDirty()||("admin"===t.originalValue.toLowerCase()?"admin"===e||_T("user","error_cannot_rename_admin"):!Array.isArray(this.commonUsernames)||!this.commonUsernames.includes(e.toLowerCase())||String.format(_T("user","error_dont_use_admin"),e))}.bind(this),maxLength:64,width:220,labelHtmlEncode:!1,vtype:"username"},{xtype:"syno_textfield",disabled:"local"!==this.authType,fieldLabel:_T("user","user_fullname"),maxLength:64,width:220,name:"description"},{xtype:"syno_textfield",fieldLabel:_T("user","user_email"),name:"email",hidden:"local"!==this.authType,maxLength:512,width:220,vtype:"email",validator:function(){return!0!==this.ownerCt.getForm().findField("notify_by_email").getValue()||""!==this.getValue()||_T("user","empty_email")}},{xtype:"syno_compositefield",fieldLabel:_T("user","user_passwd"),width:500,hidden:"local"!==this.authType||this.newuser,disabled:"local"!==this.authType||this.newuser,items:[{xtype:"syno_displayfield",name:"password_last_change",style:"min-width: 220px;",htmlEncode:!1,isDirty:function(){return!1}},{xtype:"syno_button",text:_T("personal_settings","change_password"),handler:function(){new SYNO.SDS.AdminCenter.User.ChangePasswordDialog({owner:this,passwordChecker:this.passwordChecker,ori_name:this.username,name:this.userForm.findField("name").getValue(),desc:this.userForm.findField("description").getValue()}).open()},scope:this}]},{xtype:"syno_compositefield",fieldLabel:_T("user","user_passwd")+(i?' '+_T("common","star")+"":""),width:500,cls:"password-composite-field",labelHtmlEncode:!1,hidden:"local"!==this.authType||!this.newuser,disabled:"local"!==this.authType||!this.newuser,items:[{xtype:"syno_passwordfield","aria-label":_T("user","user_passwd"),maxLength:127,width:220,name:"password",updateWhenRender:!1,startValidate:!1,validator:this.passwordChecker&&this.newuser?this.passwordChecker.isStrongValidator.createDelegate(this.passwordChecker):void 0,listeners:{afterrender:function(){this.hidePasswordStrength()},password_strength_get:function(){this.showPasswordStrength()}}},{xtype:"syno_button",text:_T("passwd","passwd_gen_title"),tabIndex:-1,hidden:void 0!==this.passwordChecker&&(!1===this.passwordChecker.passwordPolicy.strong_password_enable||"admin"===this.username),scope:this,handler:function(){new SYNO.SDS.AdminCenter.User.GenPasswordDialog({owner:this,passwordChecker:this.passwordChecker}).open()}}]},{xtype:"syno_textfield",textType:"password_confirm",fieldLabel:_T("user","user_repswd")+(i?' '+_T("common","star")+"":""),"aria-label":_T("user","user_repswd"),hidden:"local"!==this.authType||!this.newuser,disabled:"local"!==this.authType||!this.newuser,maxLength:127,name:"confirmpassword",width:220,labelHtmlEncode:!1,confirmFor:"password",validator:function(e){var t=this.ownerCt.getForm().findField(this.confirmFor).getValue();return e===t||"12345678"===t&&"87654321"===e||_T("pppoe","error_password")}},{xtype:"syno_checkbox",name:"notify_by_email",hidden:!0,value:!1,boxLabel:_T("user","create_user_notification_mail"),listeners:{check:function(){var e=this.ownerCt.getForm().findField("email"),t=this.ownerCt.getForm().findField("send_password");this.checked?(e.label.dom.innerHTML=_T("user","user_email")+' '+_T("common","star")+":",t.enable()):(e.label.dom.innerHTML=_T("user","user_email")+":",t.setValue(!1),t.disable())}}},{xtype:"syno_checkbox",name:"send_password",hidden:!0,indent:1,value:!1,boxLabel:_T("user","send_user_password")},{xtype:"syno_checkbox",name:"cannot_chg_passwd",hidden:"local"!==this.authType,boxLabel:_T("user","user_chpasswd_disallow")},{xtype:"syno_checkbox",name:"passwd_never_expire",hidden:"local"!==this.authType,boxLabel:_T("user","passwd_never_expire")},{xtype:"syno_checkbox",name:"disabled",hidden:"local"!==this.authType,boxLabel:_T("user","user_account_disable")},{xtype:"syno_radio",indent:1,boxLabel:_T("user","user_disable_immediately"),name:"disableimmediately",hidden:"local"!==this.authType,inputValue:"setdisableimmediately"},{xtype:"syno_compositefield",name:"expirefield",hidden:"local"!==this.authType,hideLabel:!0,indent:1,items:[{xtype:"syno_radio",width:217,boxLabel:_T("user","user_disable_date"),name:"disableimmediately",inputValue:"setdisabledate"},{xtype:"syno_datetimefield",format:"Y/n/j",invalidText:_JSLIBSTR("extlang","invaliddate").replace("{1}","Y/m/d"),allowBlank:!1,width:220,name:"expireddate",maxValue:new Date(2038,0,19),minValue:new Date(2003,1,1)}]},{xtype:"syno_displayfield",tabIndex:-1,htmlEncode:!1,hidden:"local"!==this.authType,value:[''+_T("common","star")+" "+_T("firewall","firewall_field_blank_alert")]},{xtype:"syno_button",id:this.reset_otp_btn=Ext.id(),text:_T("user","reset_user_otp"),scope:this,hidden:!0,handler:this.resetUserOTPConfirm},{xtype:"syno_displayfield",id:this.note_2fa=Ext.id(),hidden:!0,scope:this,htmlEncode:!1,value:String.format('{0}{1} ',_T("common","note"),_T("common","colon"))+String.format(_T("otp_enforcement","note_set_up_otp"),''+_T("common","user_setting")+"")}]};return Ext.apply(s,e),(t=new SYNO.SDS.Utils.FormPanel(s)).getForm().findField("send_password").disable(),this.passwordChecker&&this.passwordChecker.initPasswordChecker({getForm:function(){return t.getForm()},getUserAcc:"name",getUserDesc:"description",getPasswd:"password",getPasswdConfirm:"confirmpassword",getStartValidate:function(){return this.getForm().findField("password").startValidate}}),t},initGroupGrid:function(e){var t=new SYNO.API.JsonStore({appWindow:e.appWin,autoDestroy:!0,api:"SYNO.Core.Group",method:"list",version:1,fields:[{name:"name",type:"string"},{name:"description",type:"string"},{name:"is_member",type:"boolean"}],root:"groups",id:"name",remoteSort:!1,listeners:{exception:{scope:e.owner,fn:SYNO.SDS.AdminCenter.User.UserDialog.prototype.onStoreException}}});let i=function(e,t){return"users"===e||"administrators"===e&&0<=["admin","guest",_S("user")].indexOf(t)};var s=new SYNO.ux.EnableColumn({enableFastSelectAll:!0,header:_T("userwizard","join_group"),dataIndex:"is_member",width:SYNO.SDS.AdminCenter.User.UserDialog.prototype._defaultColumnWidth,align:"center",username:e.owner.username,isIgnore:function(e,t){return i(t.get("name"),this.username)},renderer:function(e,t,s){return i(s.get("name"),this.username)?this.disableRenderer(e,t,s):SYNO.ux.EnableColumn.prototype.renderer.call(this,e,t,s)}}),n=new Ext.grid.ColumnModel([{id:"name",header:_T("group","grp_name"),dataIndex:"name",width:this._defaultNameColumnWidth+this._defaultColumnWidth/2},{header:_T("group","grp_desc"),id:"description",dataIndex:"description",renderer:Ext.util.Format.htmlEncode,width:3.5*this._defaultColumnWidth},s]),o={title:_T("user","tabpanel_user_groups"),cm:n,ds:t,bbar:new SYNO.ux.PageLessToolbar({store:t,doRefresh:function(){let t=e.owner,i=()=>{t.setStatusBusy(),this.checkGroupPolling(t.username,function(e){t.clearStatusBusy(),"local"===t.authType&&t.groupGrid.getStore().load({params:{name_only:!1,user:e,type:"local"},callback:function(){t.newuser&&t.groupGrid.getStore().getAt(t.groupGrid.getStore().find("name","users")).set("is_member",!0)}})})},s=e=>{"yes"===e?(this.setStatusBusy(),this.sendWebAPI({compound:{params:this.serializeGroupTab()},callback:function(e,t){if(this.clearStatusBusy(),e&&!t.has_fail)this.groupGrid.getStore().commitChanges(),i();else{let e=SYNO.API.Response.GetFirstError(t);this.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})):(this.groupGrid.getStore().rejectChanges(),i())};t.newuser||0===t.groupGrid.getStore().getModifiedRecords().length?i():t.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),s,t)}.bind(this)}),plugins:[s],autoExpandColumn:"name",enableColLock:!1,enableHdMenu:!1,cls:"without-dirty-red-grid"};return Ext.apply(o,e),new SYNO.ux.GridPanel(o)},initPrivilegeGrid:function(e){return e.isSupportAppPriv?(e.owner.isCopyMode&&(e.isLockCustomSetting=!0),new SYNO.SDS.AdminCenter.AppRulePrivileges.EditAppPrivPanel(e)):new SYNO.SDS.AdminCenter.AppPrivileges.EditWindow.prototype.initAppPrivilegeEditGrid(e)},initShareGrid:function(e){return new SYNO.SDS.AdminCenter.User.ShareGrid(e)},initBandwidthGrid:function(e){var t=this,i=function(e,t,i,s,n,o){return"enabled"!==i.get("policy")?(t.attr='style="color:#aaaaaa;"',e="-"):e||(i.set(this.dataIndex,0),t.attr='style="color:#aaaaaa;"',e=_T("dhcp_server","unlimited")),e},s=function(e,i){var s;void 0!==(s=t.selModel.getSelected())&&(void 0!==s.data.schedule_plan&&""!==s.data.schedule_plan||(s.data.schedule_plan="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"),void 0!==s.data.upload_limit_2&&""!==s.data.upload_limit_2||(s.data.upload_limit_2=0),void 0!==s.data.download_limit_2&&""!==s.data.download_limit_2||(s.data.download_limit_2=0),SYNO.SDS.BandwidthControl.SchedulePlanWinOpen.createDelegate(t,["user",s,!0])())},n=new SYNO.ux.NumberField({allowBlank:!0,allowNegative:!1,allowDecimals:!1,validationEvent:"keyup",selectOnFocus:!0,maxLength:9,emptyText:_T("dhcp_server","unlimited"),validateOnBlur:!0,validator:function(e){if(!this.bandwidthGrid.activeEditor||"FileStation"!==this.bandwidthGrid.activeEditor.record.get("protocol"))return!0;var t=parseInt(e,10);return!(("upload_limit_1"==a[this.bandwidthGrid.activeEditor.col].dataIndex||"download_limit_1"==a[this.bandwidthGrid.activeEditor.col].dataIndex)&&t<10&&t>0)||_WFT("bandwidth","bandwidth_min_rate")}.createDelegate(this),vtype:"number",listeners:{beforeshow:function(e){e.getValue()||e.reset()}}}),o=new Ext.data.ArrayStore({fields:["display","value"],data:[[_T("bandwidth","mode_disable_user"),"disabled"],[_T("bandwidth","mode_enable"),"enabled"],[_T("bandwidth","mode_schedule"),"scheduled"]],autoDestroy:!0}),a=[];a.push({header:_T("bandwidth","bandwidth_protocol"),dataIndex:"protocol",width:115,renderer:SYNO.SDS.BandwidthControl.ProtocolTitle}),!0===e.preview&&a.push({header:_T("bandwidth","bandwidth_preview"),dataIndex:"preview",width:130,renderer:function(e,t,i,s,n,o){var a=i.get("policy"),r=0,l=0;return"scheduled"===a?_T("bandwidth","mode_schedule"):("enabled"===a?(r=i.get("upload_limit_1"),l=i.get("download_limit_1")):(r=i.get("upload_result"),l=i.get("download_result")),r||(r=_T("dhcp_server","unlimited")),l||(l=_T("dhcp_server","unlimited")),`${r} / ${l}`)}}),a.push({header:_T("bandwidth","mode"),dataIndex:"policy",width:236,renderer:function(e){return"notexist"===e||"disabled"===e||!1===e?_T("bandwidth","mode_disable_user"):"enabled"===e||!0===e?_T("bandwidth","mode_enable"):"scheduled"===e?_T("bandwidth","mode_schedule"):e},editor:new SYNO.ux.ComboBox({name:"modeSelect",hiddenName:"modeSelect",typeAhead:!0,triggerAction:"all",displayField:"display",valueField:"value",hideLabel:!0,id:Ext.id(),editable:!1,forceSelection:!0,valueNotFoundText:_T("bandwidth","mode_disable_user"),store:o,mode:"local",tpl:new Ext.XTemplate('','
',"{display}","
","
"),listeners:{scope:this,select:function(e,t,i){"scheduled"===t.data.value&&s(),e.fireEvent("blur")}}})}),a.push({header:`${_T("bandwidth","bandwidth_up_rate")} (${_T("bandwidth","speed_unit")})`,dataIndex:"upload_limit_1",width:125,editor:n,renderer:i}),a.push({header:`${_T("bandwidth","bandwidth_down_rate")} (${_T("bandwidth","speed_unit")})`,dataIndex:"download_limit_1",width:140,editor:n,renderer:i}),a.push({dataIndex:"schedule_plan",hidden:!0}),a.push({dataIndex:"upload_limit_2",hidden:!0}),a.push({dataIndex:"download_limit_2",hidden:!0});var r=new Ext.grid.ColumnModel(a);r.isCellEditable=function(e,t){var i=l.getAt(t),s=r.findColumnIndex("policy");return("enabled"===i.get("policy")||e===s)&&Ext.grid.ColumnModel.prototype.isCellEditable.call(this,e,t)};var l=new SYNO.API.JsonStore({api:"SYNO.Core.BandwidthControl",method:"get",version:2,appWindow:this,baseParams:{name:this.isCopyMode?this.defaultData.name:"",owner_type:"local_user"},fields:["upload_result","download_result","upload_limit_1","download_limit_1","policy","protocol","protocol_ui","owner_type","schedule_plan","upload_limit_2","download_limit_2"],root:"bandwidths",remoteSort:!1,listeners:{exception:{scope:e.owner,fn:SYNO.SDS.AdminCenter.User.UserDialog.prototype.onStoreException}}}),d=new SYNO.ux.Toolbar,c=new SYNO.ux.Button({name:"schedulePlanBtn",text:_T("bandwidth","edit_adv_setting"),tabIndex:-1,disabled:!0,scope:this,handler:s});d.add(c);var h={title:_T("bandwidth","bandwidth_tab_title"),cm:r,ds:l,tbar:d,itemId:"bandwidth",enableHdMenu:!1,enableColumnMove:!1,clicksToEdit:1,selModel:this.selModel=new Ext.grid.RowSelectionModel({singleSelect:!0,listeners:{selectionchange:{fn:function(e){e.getCount()>0?c.enable(!1):c.disable(!1)},scope:this}}}),bbar:new SYNO.ux.PageLessToolbar({store:l,doRefresh:function(){this.newuser||0===this.bandwidthGrid.getStore().getModifiedRecords().length?this.bandwidthGrid.getStore().load({params:{name:this.username}}):this.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),function(e){"yes"===e?(this.setStatusBusy(),this.sendWebAPI({compound:{params:this.serializeBandwidthTab()},callback:function(e,t){if(this.clearStatusBusy(),e&&!t.has_fail)this.bandwidthGrid.getStore().commitChanges(),this.bandwidthGrid.getStore().load({params:{name:this.username}});else{let e=SYNO.API.Response.GetFirstError(t);this.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})):(this.bandwidthGrid.getStore().rejectChanges(),this.bandwidthGrid.getStore().load({params:{name:this.username}}))},this)}.bind(this)})};return Ext.apply(h,e),new SYNO.ux.EditorGridPanel(h)},initQuotaGrid:function(e){return"yes"===this._D("supportquota","no")?new SYNO.SDS.AdminCenter.User.QuotaGrid({title:_T("user","user_quota_capacity"),owner:e.owner,module:e.owner,itemId:"quota"}):{loadQuotaSettings:Ext.emptyFn,getWebAPI:function(){return[]},isDirty:function(){return!1}}},defineBehaviors:function(){"local"===this.authType&&(new SYNO.ux.Utils.EnableCheckGroup(this.userForm,"disabled",["disableimmediately","expireddate"]),new SYNO.ux.Utils.EnableRadioGroup(this.userForm,"disableimmediately",{setdisabledate:["expireddate"],setdisableimmediately:[]}),this.userFormPanel.mon(this.userFormPanel,"passwordchange",this.checkConnection,this))},checkConnection:function(e){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.CurrentConnection",method:"list_by_user",version:1,params:{username:e},callback:function(e,t){if(this.clearStatusBusy(),!e)return;if(0>=t.total)return;let i=new Set,s="",n={yes:{text:_T("connections","end_connections")},no:{text:_T("common","no")}};t.items.forEach(function(e){e.can_be_kicked&&i.add(e.protocol)}),0>=i.size||(s=_S("user")===this.username?String.format(_T("connections","confirm_kill_connection_self"),i.join(", ")):String.format(_T("connections","confirm_kill_connection_others"),i.join(", ")),this.getMsgBox().confirm("",s,function(e){"yes"===e&&this.kickConnection(t.items)},this,n))},scope:this})},kickConnection:function(e){let t=[],i=[];e.forEach(function(e){e.can_be_kicked&&("HTTP/HTTPS"===e.protocol?i.push({descr:e.descr,who:e.who,from:e.from}):t.push({pid:e.pid,type:e.type,who:e.who,from:e.from}))}),this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.CurrentConnection",method:"kick_connection",version:1,params:{http_conn:i,service_conn:t},callback:function(e,t){this.clearStatusBusy(),e||this.getMsgBox().alert("",SYNO.API.Errors.core[t.code]||_T("common","error_system"))},scope:this})},onStoreException:function(e,t,i,s,n,o){if(SYNO.Debug("Store exception: options:",e,t,i,s,n,o),!this.isAlertExist)if(this.isAlertExist=!0,3202!==n.code)SYNO.SDS.AdminCenter.User.Alert.call(this,_T("user","failed_load_user"),function(){this.close(),this.isAlertExist=!1},this);else{var a=this.getGroupTaskData(),r=a&&Ext.isArray(a.running)?a.running.map(function(e){return e.data.name})[0]:void 0;this.groupGrid.getEl().mask(SYNO.API.Errors.core[n.code]+(r?" ("+r+")":""),"syno-ux-mask-info")}},loadSuccess:function(e,t){this.clearStatusBusy();var i=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.User","get").users[0],s=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Share.Permission","list_by_user"),n=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Storage.Volume","list"),o=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Quota","get"),a=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.AppPriv","get"),r=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.AppPriv.App","list"),l=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.BandwidthControl","get");this.twoFactorObj=SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.SecureSignIn.Instance")?SYNO.API.Response.GetValByAPI(e,"SYNO.SecureSignIn.Method.Admin","get"):{};var d=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.FileServ.SMB","get"),c=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Group.Member","admin_check"),h=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.User.PasswordExpiry","get");if(Ext.isObject(c)&&(this.isAdminGroupMember=c.users[0].is_admin),"guest"===i.name&&d&&d.enable_samba&&d.enable_local_master_browser&&this.GuestWithLMB(),"local"===this.authType){if((this._S("user")===i.name||!0===this.owner.getOpenConfig("cms_self")&&_S("user")===i.name)&&(this._S("demo_mode")&&(this.userForm.findField("password").disable(),this.userForm.findField("confirmpassword").disable()),this.userForm.findField("disabled").disable(),this.userForm.findField("cannot_chg_passwd").disable()),this._S("demo_mode")&&"admin"===i.name.toLowerCase()&&(this.userForm.findField("password").disable(),this.userForm.findField("confirmpassword").disable(),this.userForm.findField("disabled").disable(),this.userForm.findField("cannot_chg_passwd").disable()),"admin"===i.name.toLowerCase()&&SYNO.ux.AddTip(this.userForm.findField("disabled").getEl(),_T("user","disable_admin_tip")),!0===h.password_expire_enable&&"guest"!==i.name||this.userForm.findField("passwd_never_expire").hide(),this.userForm.setValues({password:"12345678",confirmpassword:"87654321"}),this.userForm.findField("password").startValidate=!0,"normal"===i.expired?(i.disabled=!1,i.disableimmediately="setdisableimmediately"):"now"===i.expired?(i.disabled=!0,i.disableimmediately="setdisableimmediately"):(i.disabled=!0,i.disableimmediately="setdisabledate",i.expireddate=new Date(i.expired)),0===i.password_last_change)i.password_last_change=String.format('{0}',_T("user","user_acnt_mustchange"));else if(0=n.volumes.length)&&this.panel.hideTabStripItem("quota"),(!l.bandwidths||0>=l.bandwidths.length)&&this.panel.hideTabStripItem("bandwidth"),"two-factor"===this.twoFactorObj.mode&&"on"===this.twoFactorObj.status&&Ext.getCmp(this.reset_otp_btn).show(),_S("user")===this.username){Ext.getCmp(this.note_2fa).show();var p=Ext.get(this.set2fa_link);p&&this.mon(p,"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.App.PersonalSettings.Instance")},this)}this.shareGrid&&s.shares&&s.shares.length>0&&this.shareGrid.getStore().loadData(s);this.needShowAppPrivilege(this.username)&&!this.isSupportAppPriv&&this.appPrivilegeGrid.getStore().loadData(this.loadAppPrivilege(r,a))},loadAppPrivilege:function(e,t){var i=[];return Ext.each(e.application,function(e){i.push([e.name,e.app_id])}),Ext.each(i,function(e){t&&t.accepted_app?e.push(-1!==t.accepted_app.indexOf(e[1])):e.push(!0)}),i},needShowAppPrivilege:function(e){return"admin"!=e&&"guest"!=e},loadDetail:function(e){var t=[{api:"SYNO.Core.User",version:1,method:"get",params:{name:e,additional:["description","email","expired","cannot_chg_passwd","passwd_never_expire","password_last_change"]}},{api:"SYNO.Core.User.PasswordExpiry",version:1,method:"get"},{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{offset:0,limit:-1,option:"include_cold_storage",location:"internal"}},{api:"SYNO.Core.BandwidthControl",method:"get",version:2,params:{name:e,owner_type:"local_user"}}];SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.SecureSignIn.Instance")&&t.push({api:"SYNO.SecureSignIn.Method.Admin",version:1,method:"get",params:{account:e}}),this.getKnownAPI("SYNO.Core.FileServ.SMB")&&t.push({api:"SYNO.Core.FileServ.SMB",version:1,method:"get"}),(_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main"))&&t.push({api:"SYNO.Core.Share.Permission",method:"list_by_user",version:1,params:{name:e,user_group_type:this.authType+"_user",share_type:this.WEBAPI_PARAM_SHARE_TYPE,additional:this.WEBAPI_PARAM_ADDITIONAL}}),"yes"===this._D("supportquota","no")&&t.push({api:"SYNO.Core.Quota",version:1,method:"get",params:{name:e,support_share_quota:this.supportShareUserQuota}}),this.needShowAppPrivilege(e)&&!this.isSupportAppPriv&&(t=t.concat([{api:"SYNO.Core.AppPriv",version:1,method:"get",params:{user_name:e}},{api:"SYNO.Core.AppPriv.App",version:1,method:"list",params:{user_type:this.authType}}])),"local"!==this.authType?t.push({api:"SYNO.Core.Group.Member",method:"admin_check",version:1,params:{name:e}}):t.push({api:"SYNO.Core.User.UsernamePolicy",version:1,method:"list"}),this.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:t},callback:function(e,t,i){e&&!t.has_fail?this.loadSuccess(t,i):(this.clearStatusBusy(),SYNO.SDS.AdminCenter.User.Alert.call(this,_T("user","failed_load_user"),this.close,this))},scope:this})},onOpen:function(){this.setStatusBusy(),this.loadInfo(this.username),this.callParent(arguments)},loadInfo:function(e){""!==e&&this.setTitle(e),"no"===this._D("supportquota","no")&&this.panel.hideTabStripItem("quota"),this.checkSpecialAccout(e)&&(this.userForm.findField("email").disable(),this.userForm.findField("name").disable()),this.checkGroupPolling(e,function(e){"local"===this.authType&&this.groupGrid.getStore().load({params:{name_only:!1,user:e,type:"local"}}),this.loadDetail(e)})},GuestWithLMB:function(){this.userForm.findField("password").disable(),this.userForm.findField("confirmpassword").disable(),this.userForm.findField("disabled").disable()},resetUserOTPConfirm:function(){var e={yes:{text:_T("common","disable")},no:{text:_T("common","cancel")}};this.getMsgBox().confirm(_T("user","reset_user_otp"),_T("user","reset_user_otp_confirm"),function(e){"yes"===e&&this.resetUserOTP()},this,e)},resetUserOTP:function(){SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.SecureSignIn.Instance")&&this.sendWebAPI({api:"SYNO.SecureSignIn.Method.Admin",version:1,method:"reset",params:{account:this.username},callback:this.reset2faDone,scope:this})},reset2faDone:function(e,t,i){if(e){Ext.getCmp(this.reset_otp_btn).hide();var s=String.format('
{1}
',Ext.id(),_T("user","reset_otp_success"));new SYNO.SDS.ToastBox({owner:this,html:s})}else SYNO.SDS.AdminCenter.User.Alert.call(this,_T("user","reset_otp_failed"))},checkSpecialAccout:function(e){for(var t=0;t0&&t.push({api:"SYNO.Core.User.Group",method:"join",version:1,params:{join_group:i,leave_group:s,name:n}}),t},serializeShareTab:function(){return this.shareGrid.getWebAPI(this.userForm.findField("name").getValue())},serializeQuotaTab:function(){return this.quotaGrid.getWebAPI(this.userForm.findField("name").getValue())},serializeBandwidthTab:function(){var e=[],t=this.bandwidthGrid.getStore();return Ext.each(t.getModifiedRecords(),function(t){t.data.name=this.userForm.findField("name").getValue(),e.push(t.data)},this),0{1}
',e,i.join(", "))},checkBandwidthSetting:function(e,t){var i=this.bandwidthGrid.getStore(),s=[],n=[],o="",a=!1,r=!1;Ext.each(e,function(e){e.success&&("SYNO.Core.FileServ.FTP"===e.api&&(e.data.enable_ftp||e.data.enable_ftps)?a=!0:"SYNO.Core.FileServ.FTP.SFTP"===e.api&&e.data.enable?a=!0:"SYNO.Backup.Service.NetworkBackup"===e.api&&e.data.enable?r=!0:"SYNO.Core.BandwidthControl.Protocol"===e.api&&"disabled"===e.data.policy&&n.push(e.data.protocol))}),a||n.remove("FTP"),r||n.remove("NetworkBackup");i.each(function(e){let t=e.get("protocol");0<=n.indexOf(t)&&!function(e){let t=e.get("policy");return 0<=["notexist","disabled"].indexOf(t)||"enabled"===t&&!e.get("upload_limit_1")&&!e.get("download_limit_1")}(e)&&s.push(t)},this),s.length>0?(o=this.getConfirmString(_T("bandwidth","bandwidth_global_conf_enable_desc"),s)||_T("bandwidth","bandwidth_global_conf_enable_desc"),this.getMsgBox().confirm(_T("bandwidth","bandwidth_tab_title"),o,function(e){"yes"===e?this.setGlobalConf(s):this.applyUserData()},this)):this.applyUserData()},applyUserData:function(){if(!this.isTabsDirty())return this.clearStatusBusy(),this.close(),!1;this.sendWebAPI({scope:this,compound:{stopwhenerror:!1,params:this.serializeApplyData()},encryption:["password"],callback:this.applyDone})},applyDone:function(e,t,i){var s=this.userForm.findField("name").getValue()||this.username;if(this.clearStatusBusy(),t.has_fail)SYNO.SDS.AdminCenter.User.Alert.call(this,t.result),this.lastResult=!1;else{if(t.result){var n=t.result.filter(function(e){return"SYNO.Core.User.Group"===e.api&&"join"===e.method&&e.data.task_id})[0];if(n)return this.setStatusBusy(),void this.startGroupPolling(n.data.task_id,s)}this.ignoreDirty=!0,this.hide(),this.fireEvent("userchange",s),this.close()}},getGroupTaskData:function(){var e;return Ext.isFunction(this.ownerGrid.getCacheData)?e=this.ownerGrid.getCacheData.call(this.ownerGrid):(SYNO.Debug("getGroupTaskData from local variable"),e=this.groupTaskCache),e.groupTask},setGroupTaskData:function(e){var t;return Ext.isFunction(this.ownerGrid.getCacheData)?t=this.ownerGrid.getCacheData.call(this.ownerGrid):(SYNO.Debug("setGroupTaskData to local variable"),t=this.groupTaskCache),t.groupTask=e,t.groupTask},checkGroupPolling:function(e,t){if(t=Ext.isFunction(t)?t:Ext.emptyFn,"local"===this.authType){var i=this.getGroupTaskData();if(void 0===i)this.sendWebAPI({api:"SYNO.Core.User.Group",version:1,method:"join_list",params:{},scope:this,callback:function(i,s){if(!i){var n=SYNO.API.Response.GetFirstError(s),o=SYNO.API.Errors.core[n.code]||_T("common","error_system");return this.getMsgBox().alert("warning_msg",o),!1}var a={running:Ext.value(s.running,[]),interrupted:Ext.value(s.interrupted,[]),finished:Ext.value(s.finished,[])};SYNO.Debug("loading task status",a),this.setGroupTaskData(a);var r=a.running.map(function(e){return{name:e.data.name,task_id:e.task_id}}).filter(function(t){return t.name===e})[0];r?this.startGroupPolling(r.task_id,e):t.call(this,e)}});else{SYNO.Debug("checkGroup using cache",i,this.ownerGrid.cacheData);var s=(Ext.isArray(i.finished)?i.finished:[]).concat(Ext.isArray(i.interrupted)?i.interrupted:[]).map(function(e){return e.task_id});if(s.length>0&&(SYNO.Debug("clear stopped task",s),this.sendWebAPI({api:"SYNO.Core.User.Group",version:1,method:"join_stop",params:{task_id:s},scope:this,callback:function(e,t,i){if(e){if(!t||!Ext.isArray(t.task_id)||t.task_id.length<=0)return;var s=t.task_id,n=this.getGroupTaskData();n.interrupted=n.interrupted.reject(function(e){return s.any(function(t){return e.task_id===t})}),n.finished=n.finished.reject(function(e){return s.any(function(t){return e.task_id===t})}),this.setGroupTaskData(n)}}})),i.running&&Ext.isArray(i.running)){var n=i.running.map(function(e){return{name:e.data.name,task_id:e.task_id}}).filter(function(t){return t.name===e})[0];if(n)return void this.startGroupPolling(n.task_id,e)}t.call(this,e)}}else t.call(this,e)},startGroupPolling:function(e,t){this.getMsgBox().show({title:_T("share","percentage"),width:300,wait:!1,progress:!0,closable:!1,msg:_T("common","msg_waiting"),hideDlg:!0,scope:this});var i=this.pollReg({webapi:{api:"SYNO.Core.User.Group",method:"join_status",version:1,params:{task_id:e}},interval:3,immediate:!0,scope:this,status_callback:function(e,s,n,o){var a=s.data;if(!e){this.stopGroupPolling(i,t);var r=SYNO.API.Response.GetFirstError(s),l=SYNO.API.Errors.core[r.code]||_T("common","error_system");return this.getMsgBox().alert("warning_msg",l),!1}s.finish?(this.stopGroupPolling(i,t),this.getMsgBox().hide()):this.getMsgBox().updateProgress(a.progress/a.total,"",_T("common","msg_waiting"),!0)}})},stopGroupPolling:function(e,t){this.clearStatusBusy(),this.pollUnreg(e),this.setGroupTaskData(void 0),this.ignoreDirty=!0,this.hide(),this.fireEvent("userchange",t),this.close()},failureAlert:function(e,t){this.clearStatusBusy(),this.getMsgBox().alert(_T("tree","leaf_user"),_T("common","error_system"),function(){this.close()},this)}}),Ext.define("SYNO.SDS.AdminCenter.User.UploadUserFileDialog",{extend:"SYNO.SDS.ModalWindow",ds:null,constructor:function(e){this.owner=e.owner,this.module=e.module,this.supportNotificationSet=_S("is_admin"),this.password_must_change=e.password_must_change,this.panel=this.createPanel(),this.supportNotificationSet=_S("is_admin");var t={layout:"fit",width:760,height:620,resizable:!1,title:_T("user","user_upload"),buttons:[{text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","alt_apply"),itemId:"apply",scope:this,disabled:!0,handler:this.onSubmit}],items:[this.panel]};Ext.apply(t,e),this.callParent([t]),this.DefineBehaviors()},createPanel:function(){var e;this.grid=this.createPreviewGrid();var t={border:!1,padding:0,webapi:{api:"SYNO.Core.User",version:1,methods:{set:"parse_user_list"}},fileUpload:!0,items:[{xtype:"syno_checkbox",name:"overwrite",boxLabel:_T("user","user_check_overwrite")},{xtype:"syno_checkbox",name:"new_user_mail",boxLabel:_T("user","create_user_notification_mail"),listeners:{check:function(){var e=this.ownerCt.getForm().findField("send_password");this.checked?e.enable():e.disable()}}},{xtype:"syno_checkbox",name:"send_password",boxLabel:_T("user","send_user_password")},{xtype:"syno_checkbox",name:"password_must_change",boxLabel:_T("user","first_time_login_change_passwd"),checked:this.password_must_change},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_compositefield",hideLabel:!0,flex:3,items:[{xtype:"syno_displayfield",hideLabel:!0,value:_T("user","user_file")+_T("common","colon"),style:{"padding-right":"20px"}},{xtype:"syno_filebutton",hideLabel:!0,name:"filename",value:""}]},{xtype:"syno_compositefield",hideLabel:!0,flex:2,items:[{xtype:"syno_displayfield",hideLabel:!0,value:_T("common","delimiter")+_T("common","colon"),style:{"padding-right":"20px"}},{xtype:"syno_combobox",width:120,hideLabel:!0,name:"delimiter",displayField:"display",tpl:new Ext.XTemplate('
{display}
'),valueField:"value",value:this.delimiterOldOption=0,store:new Ext.data.ArrayStore({fields:["value","display"],data:[[0,_T("common","tab_str")],[1,_T("common","comma_str")],[2,_T("common","semicolon_str")]]})}]}]},this.grid]};return(e=new SYNO.SDS.Utils.FormPanel(t)).getForm().findField("send_password").disable(),e},createPreviewGrid:function(){var e=this,t=new SYNO.API.JsonStore({root:"items",totalProperty:"total",fields:[{name:"name",mapping:"name"},{name:"password",mapping:"password"},{name:"description",mapping:"description"},{name:"email",mapping:"email"},{name:"quota",mapping:"quota"},{name:"group",mapping:"group"},{name:"status",mapping:"status"}],listeners:{exception:{scope:this,fn:function(e,t,i,s,n,o){SYNO.Debug("Store exception: options:",e,t,i,s,n,o)}},load:{scope:this,fn:this.onLoad}},sortInfo:{field:"status",direction:"DESC"}});function i(e,t){var i=Ext.util.Format.htmlEncode(e);return t.attr=String.format('ext:qtip="{0}"',Ext.util.Format.htmlEncode(i)),i}this.ds=t;var s=[{header:_T("user","user_account"),dataIndex:"name",width:100,sortable:!0,renderer:i},{header:_T("user","user_passwd"),dataIndex:"password",width:75,sortable:!0,renderer:i},{header:_T("user","user_fullname"),dataIndex:"description",id:"description",width:100,sortable:!0,renderer:i},{header:_T("user","user_email"),dataIndex:"email",width:125,sortable:!0,renderer:i},{header:_T("group","group_name"),dataIndex:"group",width:100,sortable:!0,renderer:i}];this._S("diskless")||"yes"===this._D("usbstation","no")||s.push({header:_T("user","user_quota_capacity"),dataIndex:"quota",width:100,sortable:!0,renderer:function(e,t){if(""===e)return _T("user","user_quota_nolimit");for(var i=e.split(","),s=[],n=0;n"),r=s.join(" ");return t.attr=String.format('ext:qtip="{0}"',Ext.util.Format.htmlEncode(a)),r}}),s.push({header:_T("user","user_acnt_status"),dataIndex:"status",width:150,sortable:!0,renderer:function(t,i){var s="";switch(t){case 1:s=_T("user","error_user_invalid");break;case 2:s=_T("user","error_user_repeat");break;case 3:s=_T("user","error_exist");break;case 4:s=_T("user","error_status_nameused");break;case 5:s=_T("user","error_pwd_maxlen");break;case 6:s=_T("user","error_desc");break;case 7:s=_T("user","error_badmail");break;case 8:s=_T("user","error_quota_set");break;case 9:s=String.format(_T("user","error_too_much_user"),e._D("maxaccounts"));break;case 10:s=_T("user","user_overwrite");break;case 11:s=_T("user","error_privilege");break;case 12:s=_T("user","error_group");break;default:s=""}return i.attr=String.format('ext:qtip="{0}"',s),""+s+""}});var n=new Ext.grid.ColumnModel(s,!0);return new SYNO.ux.GridPanel({ds:t,cm:n,cls:"without-dirty-red-grid",padding:"6px 0px 0px 0px",height:330,autoExpandColumn:"description",selModel:new Ext.grid.RowSelectionModel,view:new SYNO.ux.FleXcroll.grid.BufferView({scrollDelay:!1,cacheSize:50})})},onLoad:function(){var e,t=!1;for(e=0;e'+Ext.util.Format.htmlEncode(i.errors.invalid_field)+"")),this.getMsgBox().alert(_T("user","user_upload"),s)},prepareApplyParameter:function(e,t){var i=[];return this.ds.each(function(e){var t=parseInt(e.get("status"),10);if(0!==t&&10!==t)return!0;i.push({name:e.get("name"),password:e.get("password"),description:e.get("description"),email:e.get("email"),group:e.get("group"),quota:e.get("quota"),overwrite:10===t})}),i},startPolling:function(){this.pollingId=this.pollReg({webapi:{api:"SYNO.Core.User",method:"import_status",version:1,params:{task_id:this.taskId}},interval:5,immediate:!0,scope:this,status_callback:this.onPollRequestComplete})},stopPolling:function(){Ext.isDefined(this.pollingId)&&(this.pollUnreg(this.pollingId),delete this.pollingId)},onPollRequestComplete:function(e,t,i){if(!e)return this.stopPolling(),this.clearStatusBusy(),void SYNO.SDS.AdminCenter.User.Alert.call(this,t.code,function(){3116!==t.code&&3117!==t.code||(this.module.ds.reload(),this.close())},this);t.finished&&(this.sendWebAPI({webapi:{api:"SYNO.Core.User",version:1,method:"import_stop",params:{task_id:this.taskId},scope:this}}),this.stopPolling(),this.clearStatusBusy(),this.module.appWin.getMsgBox().alert(_T("tree","leaf_user"),_T("common","setting_applied")),this.module.ds.reload(),this.close())},onMainRequestComplete:function(e,t,i){if(!e)return this.clearStatusBusy(),void SYNO.SDS.AdminCenter.User.Alert.call(this,t.code);this.taskId=t.task_id,this.startPolling()},onSubmit:function(){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.User",version:1,method:"import",scope:this,params:{users:this.prepareApplyParameter(),new_user_mail:this.panel.getForm().findField("new_user_mail").getValue(),send_password:this.panel.getForm().findField("send_password").getValue(),password_must_change:this.panel.getForm().findField("password_must_change").getValue(),delimiter:this.panel.getForm().findField("delimiter").getValue()},callback:this.onMainRequestComplete})}}),Ext.define("SYNO.SDS.AdminCenter.User.CreateUserSummaryStep",{extend:"SYNO.SDS.Wizard.SummaryStep",constructor:function(e){this.isCopyMode=e.isCopyMode,this.defaultData=e.defaultData,this.callParent(arguments),this.supportSharedOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main")},activate:function(){this.genSummary.call(this.owner,this.getStore()),this.getView().syncFocusEl(0),this.getView().refresh()},genSummary:function(e){var t=[],i=[],s=[],n=[],o=this.userForm.findField("name").getValue(),a=this.userForm.findField("description").getValue(),r=this.userForm.findField("email").getValue(),l=[],d=[],c=[];e.removeAll(!0),e.append(_T("user","user_account"),o),e.append(_T("user","user_fullname"),a),e.append(_T("user","user_email"),r),this.groupGrid.getStore().each(function(e){return this.isCopyMode&&(e.markDirty(),this.groupGrid.getStore().modified.push(e)),e.data.is_member&&t.push(e.get("name")),!0},this),e.append(_T("group","group_list"),t.join(",")),this.supportSharedOperation&&(this.shareGrid.getStore().each(function(e){this.isCopyMode&&(e.markDirty(),this.getStore().modified.push(e));var t=this.getFinalPermission(e);"rw"==t?i.push(e.data.name):"ro"==t?n.push(e.data.name):"na"==t&&s.push(e.data.name)},this.shareGrid),e.append(_T("common","writeable"),i.join(", ")),e.append(_T("common","readonly"),n.join(", ")),e.append(_T("share","share_add_deny"),s.join(", "))),"yes"===this._D("supportquota","no")&&this.quotaGrid.getStore().each(function(t){if(this.isCopyMode&&(t.markDirty(),this.quotaGrid.getStore().modified.push(t)),t.get("target")){var i="";0!==t.get("quota")?i=String.format("{0} {1}",t.get("quota"),t.get("unit")):0!==t.get("group_limit")&&(i=SYNO.SDS.Utils.CapacityRender(t.get("group_limit"),2)),""!==i&&e.append(t.get("share"===t.get("target")?"name":"volume"),i+" ("+_T("storage_report","user_quota")+")")}},this);if(this.supportAppPrivOperation&&this.appPrivilegeGrid&&(this.isSupportAppPriv?this.appPrivilegeGrid.getStore().each(function(e){var t,i,s;this.isCopyMode&&(t=this.appPrivilegeGrid.getStore().modified,i=e.get("app_id"),s=!1,t.forEach(function(e){e.get("app_id")===i&&(s=!0)}),s||(e.markDirty(),this.appPrivilegeGrid.getStore().modified.push(e))),e.get("allow")&&l.push(e.get("name")),e.get("deny")&&d.push(e.get("name"))},this):this.appPrivilegeGrid.getStore().each(function(e){e.get("checked")&&l.push(e.get("display"))})),this.isCopyMode&&!this.defaultData.ignoreAppPriv&&!0!==this.appPrivilegePageActivated)for(var h=function(e){return(1!==e.length||"0.0.0.0"!==e[0])&&0!==e.length},u=this.defaultData.appPriv.rules.length-1;u>=0;u--){var p=this.defaultData.appPriv.rules[u];this.defaultData.appPriv.rules[u].entity_name=o,1!==p.allow_ip.length||h(p.allow_ip)||l.push(p.appName),1!==p.deny_ip.length||h(p.deny_ip)||d.push(p.appName)}e.append(_T("app_privilege","has_privilege"),l.join(", ")),e.append(_T("app_privilege","has_no_privilege"),d.join(", ")),this.bandwidthGrid.getStore().each(function(e){if(this.isCopyMode&&(e.markDirty(),this.bandwidthGrid.getStore().modified.push(e)),"notexist"===e.get("policy"))return;let t=SYNO.SDS.BandwidthControl.ProtocolTitle(e.get("protocol"));if("scheduled"===e.get("policy"))return void c.push(`${t}(${_T("bandwidth","mode_schedule")})`);let i=e.get("upload_limit_1"),s=e.get("download_limit_1");i||(i=_T("dhcp_server","unlimited")),s||(s=_T("dhcp_server","unlimited")),c.push(`${t}(${i}/${s})`)},this),e.append(_T("bandwidth","bandwidth_settings"),c.join(", "))}}),Ext.define("SYNO.SDS.AdminCenter.User.CreateUserWizardDialog",{extend:"SYNO.SDS.Wizard.ModalWindow",constructor:function(e){this.owner=e.owner,this.module=e.module,this.isCopyMode=e.isCopyMode,this.defaultData=e.defaultData,this.passwordChecker=e.passwordChecker,this.newuser=!0,this.usernameValidating=!1,this.newusermail=!1,this.isAlertExist=!1,this.authType="local",this.supportSharedOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main"),this.supportAppPrivOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.AppRulePrivileges.Main"),this.supportNotificationSet=_S("is_admin"),this.isSupportAppPriv=_S("version")>4931,this.commonUsernames=[];var t=Ext.apply({title:_T("userwizard","wizard_title"),resizable:!1,width:800,height:570,steps:[]},e),i="";i=this.isCopyMode?["summary"]:["group"],this.userFormPanel=SYNO.SDS.AdminCenter.User.UserDialog.prototype.initUserForm.call(this,{headline:_T("userwizard","userinfo_title"),title:"",itemId:"user",nextId:i,owner:this,passwordChecker:this.passwordChecker,module:this.module,getNext:function(){return this.owner.groupPageActivated=!0,this.getForm().isValid()?this.owner.validUserName(!0):SYNO.Debug("form invalid",this.getForm()),!1}}),this.groupGrid=SYNO.SDS.AdminCenter.User.UserDialog.prototype.initGroupGrid({appWin:this,owner:this,module:this.module,height:414,width:720,bwrapCfg:{cls:"x-panel-bwrap",style:"padding-bottom: 0px;"}});var s=new Ext.Container({headline:_T("userwizard","grpinfo_title"),title:"",itemId:"group",nextId:this.supportSharedOperation?"share":"no"===this._D("supportquota","no")?["appprivilege"]:["quota"],appWin:this,owner:this,module:this.module,items:[this.groupGrid],getNext:function(){this.owner.sharePageActivated=!0;var e=[],t=[];return this.owner.groupGrid.getStore().each(function(i){!0===i.get("is_member")&&(e.push(i.get("name")),t.push(i.json.gid.toString()))}),this.appWin.appPrivilegeGrid&&(this.appWin.appPrivilegeGrid.previewGroups=t,this.appWin.appPrivilegeGrid.isGroupName=!1),"yes"===this.owner._D("supportquota","no")&&this.owner.sendQuotaRequest(e),this.owner.goNext(this.nextId),this.owner.shareGrid&&(this.owner.getButton("next").disable(),this.owner.shareGrid.getStore().load({params:{name:this.owner.isCopyMode?this.owner.defaultData.name:e},callback:function(){this.owner.getButton("next").enable()},scope:this})),!1}}),n=new Ext.Container;this.supportSharedOperation&&(this.shareGrid=SYNO.SDS.AdminCenter.User.UserDialog.prototype.initShareGrid({appWin:this,owner:this,module:this.module,height:414,width:720,bwrapCfg:{cls:"x-panel-bwrap",style:"padding-bottom: 0px;"}}),n=new Ext.Container({headline:_T("userwizard","shareinfo_title"),title:"",itemId:"share",nextId:"no"===this._D("supportquota","no")?["appprivilege"]:["quota"],appWin:this,owner:this,module:this.module,items:[this.shareGrid],getNext:function(){return this.owner.quotaGrid.fireEvent("activate",this.owner.quotaGrid),this.owner.quotaPageActivated=!0,this.owner.goNext(this.nextId),!1}})),this.quotaGrid="yes"===this._D("supportquota","no")?new SYNO.SDS.AdminCenter.User.QuotaGrid({appWin:this,owner:this,module:this.module,hideUsedCapacity:!0,height:414,width:720,bwrapCfg:{cls:"x-panel-bwrap",style:"padding-bottom: 0px;"}}):{loadQuotaSettings:Ext.emptyFn,getWebAPI:function(){return[]}};var o="yes"===this._D("supportquota","no")?new Ext.Container({headline:_T("userwizard","quotainfo_title"),title:"",itemId:"quota",nextId:this.supportAppPrivOperation?"appprivilege":"bandwidth",appWin:this,owner:this,module:this.module,items:[this.quotaGrid],getNext:function(){return this.owner.supportAppPrivOperation&&(this.owner.appPrivilegePageActivated=!0,this.owner.appPrivilegeGrid.fireEvent("activate")),this.owner.goNext(this.nextId),!1}}):this.quotaGrid,a=new Ext.Container;this.supportAppPrivOperation&&(this.appPrivilegeGrid=SYNO.SDS.AdminCenter.User.UserDialog.prototype.initPrivilegeGrid({owner:this,module:this.module,height:414,width:720,entity_type:"user",entity_name:this.isCopyMode?this.defaultData.name:void 0,hide_custom:!this.isCopyMode,isSupportAppPriv:this.isSupportAppPriv,showPreview:!0,appFilter:function(e){if(-15496?this.isCopyMode?(t.method="get",t.params.name=this.defaultData.name):(t.method="inspect",t.params.groups=e):(t.method="get",t.params.name=""),this.quotaGrid.showMask=!1,this.sendWebAPI({compound:{stopwhenerror:!0,params:[{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{offset:0,limit:-1,option:"include_cold_storage",location:"internal"}},t]},scope:this,callback:function(e,i,s){i.has_fail?this.quotaGrid.showMask=!0:this.quotaGrid.loadQuotaSettings(SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Quota",t.method),SYNO.API.Response.GetValByAPI(i,"SYNO.Core.Storage.Volume","list"))}})},InitTask:function(){this.setStatusBusy();var e=this.getACLRuleAPIs();e=e.concat([{api:"SYNO.Core.Notification.Mail.Conf",version:1,method:"get"},{api:"SYNO.Core.User.PasswordExpiry",version:1,method:"get"},{api:"SYNO.Core.User.UsernamePolicy",version:1,method:"list"}]),this.supportAppPrivOperation&&(this.isSupportAppPriv||(e=e.concat([{api:"SYNO.Core.AppPriv.App",version:1,method:"list"},{api:"SYNO.Core.AppPriv",version:1,method:"get"}]))),this.sendWebAPI({compound:{stopwhenerror:!1,params:e},scope:this,callback:function(e,t,i){if(!this.isDestroyed)if(this.clearStatusBusy(),t.has_fail)SYNO.SDS.AdminCenter.User.Alert.call(this,t.result);else{this.getACLRuleCallback(t.result,i.compound);var s=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Notification.Mail.Conf","get","send_welcome_mail"),n=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Notification.Mail.Conf","get","enable_mail");if(s&&(this.newusermail=s,this.userForm.findField("notify_by_email").setValue(this.newusermail)),!n){var o=this.userForm.findField("notify_by_email");this.supportNotificationSet?this.userFormPanel.mon(o,"check",this.validMail,this):(o.disable(),SYNO.ux.AddTip(o.getEl(),_T("delegation","tip_user_ask_admin_to_set_notification")))}var a=this.userForm.findField("passwd_never_expire");if(SYNO.API.Response.GetValByAPI(t,"SYNO.Core.User.PasswordExpiry","get","password_expire_enable")?(a.show(),a.setValue(!1)):(a.hide(),a.setValue(!0)),this.supportAppPrivOperation&&!this.isSupportAppPriv){var r=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.AppPriv.App","list"),l=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.AppPriv","get");r.accepted_app=r.application;var d=SYNO.SDS.AdminCenter.User.UserDialog.prototype.loadAppPrivilege(r,l);this.appPrivilegeGrid&&this.appPrivilegeGrid.getStore().loadData(d)}let e=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.User.UsernamePolicy","list");Array.isArray(e)&&(this.commonUsernames=e)}}})},getACLRuleAPIs:function(){if(!this.isCopyMode)return[];if(!_S("is_admin")&&!SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main"))return[];for(var e=[],t=0;t",{xtype:"syno_button",itemId:"cancel",text:_T("common","cancel"),scope:this,handler:this.close},{xtype:"syno_button",itemId:"apply",text:_T("common","delete"),btnStyle:"red",disabled:!!this.homesExist,scope:this,handler:this.onClickDelete}]};return Ext.apply(t,e),t},createFormPanel:function(){var e={trackResetOnLoad:!0,autoScroll:!0,autoHeight:!0,items:[{xtype:"syno_displayfield",itemCls:"user-delete-message",style:"font-size: 14px;",htmlEncode:!1,name:"message"},{xtype:"syno_displayfield",htmlEncode:!1,name:"username"}]};return this.homesExist&&e.items.push({xtype:"syno_checkbox",name:"",htmlEncode:!1,boxLabel:String.format('{0}',_T("user","user_delete_confirm")),listeners:{check:{scope:this,fn:this.onCheckboxCheck}}}),new SYNO.SDS.Utils.FormPanel(e)},loadUserName:function(e){var t=this.formPanel.getForm(),i=t.findField("message"),s=t.findField("username"),n=e.length>5,o=(this.homesExist?_T("user","user_rm_home_warning"):"")+(n?String.format(_T("user","user_cfrmrmv_num"),e.length):_T("user","user_cfrmrmv"));i.setValue(o),n?s.setVisible(!1):s.setValue(e.join(", ")),this.names=e},onClickDelete:function(){SYNO.SDS.Utils.PasswordConfirmDialog.openDialog(this,this.applySetting)},applySetting:function(){this.applyDeleteUser(),this.close()},applyDeleteUser:function(){this.appWin.setStatusBusy({text:_T("user","deleting_user")}),this.appWin.sendWebAPI({api:"SYNO.Core.User",version:1,method:"delete",params:{name:this.names},timeout:6e5,scope:this,callback:this.applyDeleteUserDone})},applyDeleteUserDone:function(e,t,i){e||SYNO.SDS.AdminCenter.User.Alert.call(this.appWin,t.code),this.appWin.clearStatusBusy(),this.ownerGrid.findField&&this.ownerGrid.findField.reset(),this.ownerGrid.getStore().load({params:{start:0,limit:this.ownerGrid.pageSize}})},onCheckboxCheck:function(e,t){this.getFooterToolbar().getComponent("apply").setDisabled(!t)}}),Ext.define("SYNO.SDS.AdminCenter.User.DelegateCheckbox",{extend:"SYNO.ux.TriModeCheckbox",isDirty:function(){return this.callParent()&&""!==this.getValue()},getNextStat:function(){var e=this.callParent();return null!==e&&e}}),Ext.define("SYNO.SDS.AdminCenter.User.DelegateDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.type=e.type,this.name=e.name.sort(),this.delegationFormPanel=this.initDelegationForm(),this.delegationForm=this.delegationFormPanel.getForm(),this.getDelegationRoles();var t={width:648,height:550,minWidth:648,minHeight:550,layout:"fit",title:_T("delegation","title"),buttons:[{text:_T("common","alt_cancel"),scope:this,handler:this.close},{text:_T("common","alt_apply"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.delegationFormPanel]};Ext.apply(t,e),this.callParent([t]),this.delegationForm.findField("desc").getEl().addListener("click",this.launchHelp,this)},launchHelp:function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/file_user_delegate.html"},!1)},getDelegationRoles:function(){var e=[];this.roles=[],this.sendWebAPI({api:"SYNO.Core.ActionPriv.Role",version:1,method:"list",callback:function(t,i,s){if(t){this.roles=i.roles,Ext.each(this.roles,function(t){e.push(new SYNO.SDS.AdminCenter.User.DelegateCheckbox({name:t.priv_id,boxLabel:_T(t.title.split(":")[0],t.title.split(":")[1]),htmlEncode:!1,itemCls:"role-delegate-checkbox"}),{xtype:"syno_displayfield",value:_T(t.desc.split(":")[0],t.desc.split(":")[1]),indent:1,htmlEncode:!1,name:"desc"})});var n={xtype:"syno_fieldset",title:_T("delegation","roles"),collapsible:!1,padding:"0 0 0 4px",itemId:"roles_fieldset",items:e};this.delegationFormPanel.remove("roles_fieldset"),this.delegationFormPanel.add(n),this.delegationFormPanel.doLayout()}else this.getMsgBox().alert(_T("delegation","title"),_T("delegation","failed_get_roles"))},scope:this})},onClose:function(){return!0===this.confirmToLeave||!1!==this.callParent(arguments)&&(!this.isTabsDirty()||(this.getMsgBox().confirm(_T("delegation","delegation"),_T("common","confirm_lostchange"),function(e){"yes"===e&&(this.confirmToLeave=!0,this.close())},this),!1))},initDelegationForm:function(e){this.linkID=Ext.id();var t={title:_T("delegation","title"),labelWidth:150,items:[{xtype:"syno_displayfield",htmlEncode:!1,value:String.format(_T("delegation","desc"),'',""),name:"desc"},{xtype:"syno_displayfield",hideLabel:!1,fieldLabel:_T("delegation","delegate_to"),name:"name",allowBlank:!1,blankText:_T("user","error_noname"),htmlEncode:!1,width:400,value:this.name},{xtype:"spacer",height:12},{xtype:"syno_fieldset",title:_T("delegation","roles"),collapsible:!1,itemId:"roles_fieldset",items:[]}]};return Ext.apply(t,e),new SYNO.SDS.Utils.FormPanel(t)},setDefaultValue:function(e,t){var i=this.delegationForm.findField(e);null!==i&&(i.setValue(t),i.originalValue=t)},onOpen:function(){this.loadInfo(this.username),this.callParent(arguments)},loadInfo:function(e){this.setStatusBusy();var t=[{api:"SYNO.Core.ActionPriv",version:1,method:"get",params:{type:this.type,name:this.name}}];"user"===this.type&&t.push({api:"SYNO.Core.Group.Member",version:1,method:"admin_check",params:{name:this.name}}),this.sendWebAPI({compound:{params:t},callback:function(e,t,i){if(this.clearStatusBusy(),e&&!t.has_fail){var s,n,o=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Group.Member","admin_check"),a=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.ActionPriv","get"),r=!1;if(Ext.isObject(o)){for(s=0;s"+this.name[0]+"
"):_T("delegation","contain_admin_user")}else{for(s=0;sadministrators")}r&&(this.delegationFormPanel.getEl().mask(n,"syno-ux-mask-info"),this.getFooterToolbar().getComponent("apply").disable()),Ext.isObject(a)&&a.privileges&&Ext.each(a.privileges,function(e){this.setDefaultValue(e.priv_id,"full"===e.state||null)},this)}else this.owner.getMsgBox().alert(_T("delegation","title"),_T("delegation","failed_get_privs"))},scope:this})},isTabsDirty:function(){return!!this.delegationForm.isDirty()},setPrivileges:function(){for(var e=[],t=[],i=0;i',constructor:function(e){this.module=e.module,this.owner=e.owner,this.previewFormPanel=this.initPreviewForm(),this.previewForm=this.previewFormPanel.getForm();var t={width:648,height:550,minWidth:648,minHeight:550,layout:"fit",title:_T("delegation","permission_viewer"),buttons:[{text:_T("common","alt_close"),scope:this,handler:this.close}],items:[this.previewFormPanel]};Ext.apply(t,e),this.callParent([t]),this.previewFormPanel.mon(this.previewForm.findField("permission_type"),"select",function(){"roles"===this.previewForm.findField("permission_type").getValue()?this.previewForm.findField("account_type").disable():this.previewForm.findField("account_type").enable(),this.getPreviewResult()},this),this.previewFormPanel.mon(this.previewForm.findField("account_type"),"select",function(){this.getPreviewResult()},this)},exportHandler:function(){this.downloadWebAPI({webapi:{api:"SYNO.Core.ActionPriv",method:"export",version:1}})},onOpen:function(){this.getDelegationRoles(),this.callParent(arguments)},initPreviewForm:function(e){var t={title:_T("delegation","permission_viewer"),items:[{xtype:"syno_displayfield",value:_T("delegation","export_desc"),name:"desc"},{xtype:"syno_button",text:_T("delegation","export"),itemId:"export",style:{marginLeft:"8px"},scope:this,handler:this.exportHandler},{xtype:"spacer",height:18},{xtype:"syno_fieldset",title:_T("delegation","permission_preview"),collapsible:!1,style:{marginBottom:"0px"},itemId:"permission_preview_fieldset",items:[{xtype:"syno_compositefield",hideLabel:!0,fieldLabel:"permission_preview",itemId:"permission_preview",items:[{xtype:"syno_combobox",name:"permission_type",width:250,valueField:"id",displayField:"display",allowBlank:!1,store:new Ext.data.JsonStore({fields:["id","display"],idProperty:"id",data:[{id:"roles",display:_T("delegation","preview_by_roles")},{id:"account",display:_T("delegation","preview_by_account")}]}),value:"roles",tpl:new Ext.XTemplate('','
',"{display}","
","
")},{xtype:"syno_combobox",name:"account_type",width:250,valueField:"id",displayField:"display",allowBlank:!1,disabled:!0,store:new Ext.data.JsonStore({fields:["id","display"],idProperty:"id",data:[{id:"all",display:_T("delegation","all_account")},{id:"local",display:_T("delegation","local_account")},{id:"directory",display:_T("delegation","directory_account")}]}),value:"all",tpl:new Ext.XTemplate('','
',"{display}","
","
")}]},{xtype:"syno_fieldset",title:"",collapsible:!1,itemId:"preview_data",bwrapCfg:{padding:0},items:[]}]}]};return Ext.apply(t,e),new SYNO.SDS.Utils.FormPanel(t)},getRoleNameStr:function(e,t){for(var i=0;i{1}
',e,e)},parseAccountPreviewData:function(e,t){var i=[],s="";return Ext.each(e,function(e){s="";for(var n=0;n'+e.name+'
'+_T("tree","leaf_"+t)+"
"},{xtype:"syno_displayfield",htmlEncode:!1,value:this.addQtipTo(s)})},this),i},parseRolesPreviewData:function(e){var t=[];return Ext.each(e,function(e){(e.user.length>0||e.group.length>0)&&t.push({xtype:"syno_displayfield",htmlEncode:!1,height:1,padding:4,value:this.SEPARATOR_LINE},{xtype:"syno_displayfield",htmlEncode:!1,height:24,value:this.getRoleNameStr(e.priv_id,"title").bold()},{xtype:"syno_displayfield",htmlEncode:!1,height:32,hideLabel:!1,fieldLabel:_T("tree","leaf_user"),style:"padding-left: 5px;",hidden:!(e.user.length>0),value:e.user.length>0?this.addQtipTo(e.user.sort().join(", ")):"-"},{xtype:"syno_displayfield",htmlEncode:!1,height:32,hideLabel:!1,fieldLabel:_T("tree","leaf_group"),style:"padding-left: 5px;",hidden:!(e.group.length>0),value:e.group.length>0?this.addQtipTo(e.group.sort().join(", ")):"-"})},this),t},getPreviewResult:function(){var e=this.previewForm.findField("permission_type").getValue(),t=this.previewForm.findField("account_type").getValue(),i="roles"===e,s="all"===t||"local"===t,n="all"===t||"directory"===t;this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.ActionPriv",version:1,method:"preview",params:{roles:i,local:!i&&s,directory:!i&&n},callback:function(e,t,i){if(this.clearStatusBusy(),e){var s=[];t.roles&&t.roles.length>0?s.push(this.parseRolesPreviewData(t.roles)):t.user&&t.group?(t.user.length>0&&s.push(this.parseAccountPreviewData(t.user,"user")),t.group.length>0&&s.push(this.parseAccountPreviewData(t.group,"group"))):this.body.mask(_T("delegation","empty_setting"),"syno-ux-mask-info");var n={xtype:"syno_fieldset",title:"",itemId:"preview_data",bwrapCfg:{padding:0},labelWidth:150,items:s};this.previewFormPanel.getComponent("permission_preview_fieldset").remove("preview_data"),this.previewFormPanel.getComponent("permission_preview_fieldset").add(n),this.previewFormPanel.doLayout()}else this.owner.getMsgBox().alert(_T("delegation","title"),_T("delegation","failed_get_preview"))},scope:this})}}),Ext.define("SYNO.SDS.AdminCenter.Group.MemberGrid",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.module=e.module,this.owner=e.owner,this.groupName=e.groupName;let t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){this.store=new Ext.data.JsonStore({fields:[{name:"name",sortType:"asNaturalUCString"},{name:"desc",sortType:"asNaturalUCString"},"is_member"],pruneModifiedRecords:!0,sortInfo:{field:"name",direction:"ASC"}});let t=function(e,t){return"users"===e||"administrators"===e&&0<=["admin","guest",_S("user")].indexOf(t)},i=new SYNO.ux.EnableColumn({enableFastSelectAll:!0,header:this.owner.newgroup?_T("common","add"):_T("group","group_members"),dataIndex:"is_member",align:"center",groupName:this.groupName,isIgnore:function(e,i){return t(this.groupName,i.get("name"))},renderer:function(e,i,s){return t(this.groupName,s.get("name"))?this.disableRenderer(e,i,s):SYNO.ux.EnableColumn.prototype.renderer.call(this,e,i,s)}});var s={title:_T("group","group_members"),store:this.store,columns:[{header:_T("user","user_account"),dataIndex:"name",sortable:!0,renderer:function(e,t,i){return"administrators"===this.groupName&&_S("user")===e?`${e} (${_T("group","current_account")})`:e}.bind(this)},{header:_T("user","user_fullname"),dataIndex:"desc",sortable:!0},i],plugins:[i],autoExpandColumn:"desc",enableHdMenu:!1,enableColumnMove:!1,view:new SYNO.ux.FleXcroll.grid.BufferView({trackResetOnLoad:!1,scrollDelay:!1,cacheSize:50}),tbar:["->",this.getSearchField()],bbar:new SYNO.ux.PageLessToolbar({store:this.store,doRefresh:this.doRefresh.bind(this)}),listeners:{scope:this,afterrender:this.onAfterrender,activate:this.onActivate}};return Ext.apply(s,e)},onAfterrender:function(e){if(this.load(),this.owner.newgroup){var t=e.getGridEl(),i=e.tbar;t.setStyle("padding-top","0px"),i.setStyle("padding-top","24px")}},onActivate:function(e){"users"===this.groupName&&e.mask(_T("group","users_group_mask_info"),"syno-ux-mask-info")},getSearchField:function(){let e={itemId:"search",localFilter:!0,localFilterField:["name","desc"],blOr:!0,width:200,emptyText:_T("user","search_user"),store:this.store};return this.owner.newgroup?new SYNO.ux.TextFilter(e):new SYNO.ux.SearchField(Ext.apply(e,{menu:new SYNO.ux.Menu({cls:"syno-ux-check-menu",items:[{checked:!0,value:"all",text:_T("common","show_all")},{value:"member",text:_T("group","group_members")}],defaults:{group:"member_search_type",checked:!1},listeners:{scope:this,itemclick:this.onMemberMenuSelect}}),getMenu:function(){return this.menu}}))},onMemberMenuSelect:function(e){this.memberSearchType=e.value,this.load()},load:function(){this.owner.newgroup||!this.isDirty()?this.groupName?this.loadMembers():this.loadUsers():this.owner.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),function(e){"yes"===e?this.saveAndLoad():(this.getStore().rejectChanges(),this.load())},this)},loadUsers:function(){this.owner.setStatusBusy(),this.owner.sendWebAPI({api:"SYNO.Core.User",method:"list",version:1,params:{additional:["description"]},callback:function(e,t,i){if(this.owner.clearStatusBusy(),!e){let e=SYNO.API.Response.GetFirstError(t);return void this.getMsgBox().alert("warning_msg",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}let s=t.users.map(e=>({name:e.name,desc:e.description,is_member:!1}));this.getStore().loadData(s)},scope:this})},loadMembers:function(){let e=[{api:"SYNO.Core.Group.Member",method:"list",version:1,params:{group:this.groupName,ingroup:!0}}];"member"!==this.memberSearchType&&e.push({api:"SYNO.Core.Group.Member",method:"list",version:1,params:{group:this.groupName,ingroup:!1}}),this.owner.setStatusBusy(),this.owner.sendWebAPI({compound:{params:e},callback:function(e,t,i){if(this.owner.clearStatusBusy(),!e||t.has_fail){let e=SYNO.API.Response.GetFirstError(t);return void this.getMsgBox().alert("warning_msg",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}let s=t.result[0].data.users.map(e=>({name:e.name,desc:e.description,is_member:!0}));t.result[1]&&(s=s.concat(t.result[1].data.users.map(e=>({name:e.name,desc:e.description,is_member:!1})))),this.getStore().loadData(s)},scope:this})},doRefresh:function(){this.load()},saveAndLoad:function(){this.owner.setStatusBusy(),this.owner.sendWebAPI({compound:{params:this.getWebAPIParams(this.groupName)},callback:function(e,t,i){if(this.owner.clearStatusBusy(),e&&!t.has_fail)this.getStore().commitChanges(),this.load();else{let e=SYNO.API.Response.GetFirstError(t);this.owner.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})},isDirty:function(){return 0{e.get("is_member")?t.push(e.get("name")):i.push(e.get("name"))}),[{api:"SYNO.Core.Group.Member",method:"change",version:1,params:{group:e,add_member:t,remove_member:i}}]):[]}}),Ext.ns("SYNO.SDS.AdminCenter.Group"),Ext.ns("SYNO.SDS.Share"),SYNO.SDS.AdminCenter.Group.GetErrMsg=function(e,t){var i=3299,s=SYNO.API.Errors.core[i],n="";if(e){if("string"==typeof e)s=e;else if("number"==typeof e)i=e,s=SYNO.API.Errors.core[e];else if(e instanceof Array)for(var o=0;o'+_T("common","note")+_T("common","colon")+" "+_T("share","share_privileges_priority"),n={title:_T("tree","leaf_group"),store:i,header:!1,height:350,cls:"without-dirty-red-grid",stripeRows:!0,enableColumnMove:!1,enableHdMenu:!1,autoExpandColumn:"name",colModel:new Ext.grid.ColumnModel({columns:[new SYNO.SDS.Share.InfoColumn({dataIndex:"is_unite_permission",width:55,hidden:e.newGroup||!1}),{id:"name",header:_T("share","share_name"),dataIndex:"name",width:200},new SYNO.SDS.AdminCenter.Share.Utils.PermissionColumn({header:_T("share","share_inherit"),align:"left",hidden:e.newGroup,convert:SYNO.SDS.AdminCenter.Share.Utils.convertBoolPermissions}),this.colNa,this.colRw,this.colRo,this.colCu]}),plugins:[this.colRo,this.colRw,this.colNa,this.colCu],selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),bbar:new SYNO.ux.PageLessToolbar({store:i,doRefresh:this.doRefresh.bind(this)}),fbar:{xtype:"syno_toolbar",layout:"fit",style:"padding-top: 12px;",items:[{xtype:"syno_displayfield",htmlEncode:!1,style:"white-space: normal;",value:s,"aria-label":SYNO.ux.Utils.ConvertSingleSymbolToString(s,">",!0)}]},footerCfg:{style:"padding: 0px;"}};Ext.apply(n,e),this.callParent([n]),this.mon(this,"afterrender",this.defineShareGridBehaviors,this),this.mon(this,"afterlayout",function(e,t){e.getView().updateScroller()},this),this.mon(this.colNa,"click",function(e,t,i,s){var n=t.getStore().getAt(i);this.showHomesWarning&&"homes"===n.id&&!0===n.get("is_deny")&&!0===n.get("is_aclmode")&&(this.owner.getMsgBox().alert(this.title,_T("share","warn_deny_rule_homes")),this.showHomesWarning=!1)},this)},doRefresh:function(){this.owner.newgroup||!this.isChanged()?this.loadInfo(this.owner.groupName):this.owner.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),function(e){"yes"===e?this.saveAndRefresh():(this.getStore().rejectChanges(),this.doRefresh())},this)},saveAndRefresh:function(){this.owner.setStatusBusy(),this.owner.sendWebAPI({compound:{params:this.getWebAPI(this.owner.groupName)},callback:function(e,t,i){if(this.owner.clearStatusBusy(),e&&!t.has_fail)this.getStore().commitChanges(),this.doRefresh();else{let e=SYNO.API.Response.GetFirstError(t);this.owner.getMsgBox().alert("",SYNO.API.Errors.core[e.code]||_T("common","error_system"))}},scope:this})},createStore:function(){var e=["is_aclmode","name","permission","is_writable","is_readonly","is_deny","is_custom","share_path","is_unite_permission",{name:"force_readonly_reason",defaultValue:void 0},"is_mask"];return"yes"===this.module._D("support_s2s","no")&&e.push("is_sync_share"),new SYNO.API.JsonStore({autoDestroy:!0,appWindow:this.owner,api:"SYNO.Core.Share.Permission",method:"list_by_group",version:1,baseParams:{user_group_type:this.authType+"_group",share_type:this.WEBAPI_PARAM_SHARE_TYPE,additional:this.WEBAPI_PARAM_ADDITIONAL},listeners:{exception:{scope:this,fn:this.onStoreException},beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:this.onLoad}},root:"shares",idProperty:"name",totalProperty:"total",fields:e})},onBeforeLoad:function(e,t){this.owner.setStatusBusy()},onLoad:function(e,t,i){this.owner.clearStatusBusy(),this.loadedPrivList=[];for(var s=0;s=i?(i/=1024,n=String.format(_T("user","user_quota_limit_max_vol"),t.get("volume"),i.toFixed(2)),e.grid.owner.getMsgBox().alert(_T("user","error_quota_set"),n),!1):!(t.get("limit_4T")&&s>=4194304)||(n="TB"===t.get("unit")?String.format(_JSLIBSTR("extlang","maxnumber"),"3 TB"):"GB"===t.get("unit")?String.format(_JSLIBSTR("extlang","maxnumber"),"4095 GB"):String.format(_JSLIBSTR("extlang","maxnumber"),"4194304 MB"),e.grid.owner.getMsgBox().alert(_T("user","error_quota_set"),n),!1)},onCellClick:function(e,t,i,s){var n=e.getStore().getAt(t);"quota_enabled"===e.getColumnModel().getColumnAt(i).id&&"crash"!==n.get("status")&&n.get("target")&&(n.get("quota_enabled")?(n.set("quota",1),e.startEditing(t,i-2)):n.set("quota",0))},onHeaderClick:function(e,t,i){var s=i.getTarget("input",1,!1);"quota_enabled"===e.getColumnModel().getColumnAt(t).id&&s&&e.getStore().each(function(e){if(!e.get("target"))return!0;s.classList.contains("syno-ux-cb-checked")?e.set("quota",0):0===e.get("quota")&&e.set("quota",1)})},createStore:function(){return new Ext.data.GroupingStore({listeners:{beforeload:{scope:this,fn:function(){this.owner.setStatusBusy()}},load:{scope:this,fn:function(){this.owner.clearStatusBusy()}},exception:{scope:this,fn:function(e,t,i,s,n,o){this.owner.clearStatusBusy(),SYNO.Debug("Store exception: ",e,t,i,s,n,o)}}},reader:new Ext.data.JsonReader({fields:[{name:"name",mapping:"name"},{name:"description",mapping:"description"},{name:"quota",mapping:"quota"},{name:"unit",mapping:"unit"},{name:"quota_enabled",mapping:"quota_enabled"},{name:"limit_4T",mapping:"limit_4T"},{name:"status",mapping:"status"},{name:"quota_status",mapping:"quota_status"},{name:"deduped",mapping:"deduped"},{name:"total",mapping:"total"},{name:"volume",mapping:"volume"},{name:"target",mapping:"target"},{name:"display_name",mapping:"display_name"}]}),groupField:"volume",idProperty:"name",autoDestroy:!0,remoteSort:!1})},createColModel:function(e){let t=this;var i=new Ext.data.ArrayStore({fields:["value","display"],data:this.supportShareQuota?[["TB",_T("common","size_tb")],["GB",_T("common","size_gb")],["MB",_T("common","size_mb")]]:[["GB",_T("common","size_gb")],["MB",_T("common","size_mb")]]}),s=[{header:this.supportShareQuota?_T("common","volume_share"):_T("volume","volume"),dataIndex:"display_name",width:150,renderer:function(e,t,i){return t.attr='ext:qtip="'+e+'"',"normal"===i.get("status")?e:String.format('({0})',e)}},{header:_T("group","group_quota_header"),dataIndex:"quota",id:"quota",width:120,editor:new SYNO.ux.NumberField({allowBlank:!0,allowNegative:!1,allowDecimals:!1,validateOnBlur:!0,selectOnFocus:!0,emptyText:_T("dhcp_server","unlimited"),validationEvent:"keyup",vtype:"number",listeners:{beforeshow:function(e){e.getValue()||e.reset()}}}),renderer:function(e,t,i){return e||(i.set(this.dataIndex,0),t.attr='style="color:#aaaaaa;"',e=_T("dhcp_server","unlimited")),i.get("target")?e:""}},{header:"",dataIndex:"unit",id:"unit",width:80,editor:new SYNO.ux.ComboBox({store:i,lazyRender:!0,mode:"local",displayField:"display",valueField:"value",triggerAction:"all",editable:!1}),renderer:function(e,t,i){return i.get("target")?_T("common","size_"+e.toLowerCase()):""}},new SYNO.ux.EnableColumn({header:_T("user","enable_quota"),id:"quota_enabled",dataIndex:"quota_enabled",align:"center",width:170,hidden:!0,enableFastSelectAll:!0,isIgnore:function(e,t){return!t.get("target")},renderer:function(e,t,i){return i.get("target")?SYNO.ux.EnableColumn.prototype.renderer.apply(this,arguments):""}}),{dataIndex:"volume",hidden:!0,groupRenderer:function(e,i,s){return"share"===s.get("target")&&(e+=" (btrfs)"),"volume"===s.get("target")&&(e+=" (ext4)"),t.isQuotaStatusDisabled(s.get("quota_status"))&&(wtip=Ext.util.Format.htmlEncode(_T("user","user_quota_unsupported")),e+=``),e}}];return new Ext.grid.ColumnModel({defaults:{width:130,align:"left"},columns:s,isCellEditable:function(i,s){var n=e.getAt(s);return!t.isQuotaStatusDisabled(n.get("quota_status"))&&Ext.grid.ColumnModel.prototype.isCellEditable.call(this,i,s)}})},configLeafObj:function(e,t){e.quota=Math.floor(e.quota),e.unit="MB",e.quota%1024==0&&(e.quota/=1024,e.unit="GB"),e.quota%1024==0&&(e.quota/=1024,e.unit="TB"),e.quota_enabled=0!==e.quota,e.quota_enabled||(e.unit="GB"),e.status=t.readonly?"crash":"normal",e.volume=t.display_name,e.total=Math.floor(t.size_total_byte/1024/1024),e.leaf=!0,e.expanded=!1},loadQuotaSettings:function(e,t,i){var s=this,n={},o=[];Ext.each(t.volumes,function(e){n[e.volume_path]=e}),Ext.each(e.group_quota,function(e){var t=n[e.volume];e.support_share_quota?(e.children=e.shares,e.leaf=!1,e.expanded=!0,e.status=t.readonly?"crash":"normal",e.volume=t.display_name,e.total=Math.floor(t.size_total_byte/1024/1024),e.display_name=t.display_name,e.description=Ext.util.Format.htmlEncode(t.description),Ext.each(e.children,function(i){s.configLeafObj(i,t),i.target="share",i.limit_4T=!1,i.display_name=i.name,i.description=Ext.util.Format.htmlEncode(i.description),i.quota_status=e.quota_status,i.deduped=e.deduped,o.push(i)})):(s.configLeafObj(e,t),e.target="volume",e.limit_4T=!0,e.name=t.volume_path,e.display_name=t.display_name,e.description=Ext.util.Format.htmlEncode(t.description),o.push(e))}),this.getStore().loadData(o),Ext.isObject(i)&&i.is_admin&&(this.mon(this,"activate",function(e){e.mask(String.format(_T("user","edit_adminquota"),i.name))}),this.mon(this,"deactivate",function(e){e.unmask()}))},initForCreation:function(){this.owner.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({compound:{stopwhenerror:!0,params:[{api:"SYNO.Core.Quota",method:"get",version:1,params:{name:this.owner.groupName?this.owner.groupName:"",subject_type:"group",support_share_quota:"yes"===this._D("support_share_user_quota","no")}},{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{offset:0,limit:-1,option:"include_cold_storage",location:"internal"}}]},scope:this,callback:function(e,t,i){this.isDestroyed||(this.owner.clearStatusBusy(),t.has_fail?SYNO.SDS.AdminCenter.Group.Alert.call(this.owner,SYNO.API.Response.GetFirstError(t)||3299):this.loadQuotaSettings(SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Quota","get"),SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Storage.Volume","list")))}})},isDirty:function(){return 0!==this.getStore().getModifiedRecords().length},confirmQuotaUpdate:function(){return this.getStore().getModifiedRecords().some(e=>"v1"===e.get("quota_status")&&!0===e.get("deduped"))},getWebAPI:function(e){var t=[];return this.getStore().getModifiedRecords().forEach(function(e){var i=parseInt(e.get("quota"),10);"share"===e.get("target")?t.push({share:e.get("name"),quota:this.convertToMB(i,e.get("unit"))}):"volume"===e.get("target")&&t.push({volume:e.get("name"),quota:this.convertToMB(i,e.get("unit"))})},this),0===t.length?[]:[{api:"SYNO.Core.Quota",method:"set",version:1,params:{name:e,group_quota:t}}]}}),Ext.define("SYNO.SDS.AdminCenter.Group.GroupDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.isAlertExist=!1,this.authType=e.authType||"local",this.supportSharedOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main"),this.supportAppPrivOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.AppRulePrivileges.Main");var t=this.createFormPanel(e);this.groupForm=t.getForm(),this.memberGrid=new SYNO.SDS.AdminCenter.Group.MemberGrid({owner:this,module:e.module,itemId:"member",groupName:e.groupName}),this.groupGrid=this.supportSharedOperation?new SYNO.SDS.AdminCenter.Group.GroupShareGrid({title:_T("share","share_rights"),owner:this,module:e.module,itemId:"share",authType:this.authType}):null;var i="yes"===e.module._D("supportquota","no")&&e.module._S("version")>5496;this.quotaGrid=i?new SYNO.SDS.AdminCenter.Group.QuotaGrid({title:_T("user","user_quota_capacity"),owner:this,module:e.module,itemId:"quota"}):{loadQuotaSettings:Ext.emptyFn,isDirty:function(){return!1},getWebAPI:function(){return[]}},this.bandwidthGrid=this.initBandwidthGrid({owner:this,module:e.module});var s=[];"local"===this.authType&&(s.push(t),s.push(this.memberGrid)),this.groupGrid&&s.push(this.groupGrid),i&&s.push(this.quotaGrid),this.isSupportAppPriv=e.module._S("version")>4931&&this.supportAppPrivOperation,this.isSupportAppPriv&&(this.appPrivilegeGrid=this.initPrivilegeGrid({title:_T("user","user_application"),owner:this,module:e.module,entity_type:"group",entity_name:e.groupName,appFilter:function(e){if(e.supportIP&&-1'+_T("common","star")+"","aria-label":_T("group","group_name"),allowBlank:!1,validationEvent:"keyup",blankText:_T("group","error_noname"),vtype:"groupname"},{xtype:"syno_textfield",name:"description",maxlength:64,fieldLabel:_T("group","group_desc")},{xtype:"hidden",name:"new_name"},{xtype:"syno_displayfield",tabIndex:-1,htmlEncode:!1,value:[''+_T("common","star")+" "+_T("firewall","firewall_field_blank_alert")]}],listeners:{actioncomplete:{scope:this,fn:this.onActionComplete},actionfailed:{scope:this,fn:this.onActionFailed}}},e);return new SYNO.ux.FormPanel(t)},initPrivilegeGrid:function(e){return new SYNO.SDS.AdminCenter.AppRulePrivileges.EditAppPrivPanel(e)},initBandwidthGrid:function(e){var t=this,i=function(e,t,i,s,n,o){return"enabled"!==i.get("policy")?(t.attr='style="color:#aaaaaa;"',e="-"):e||(i.set(this.dataIndex,0),t.attr='style="color:#aaaaaa;"',e=_T("dhcp_server","unlimited")),e},s=function(e,i){var s=t.selModel.getSelected();void 0!==s&&(void 0!==s.data.schedule_plan&&""!==s.data.schedule_plan||(s.data.schedule_plan="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"),void 0!==s.data.upload_limit_2&&""!==s.data.upload_limit_2||(s.data.upload_limit_2=0),void 0!==s.data.download_limit_2&&""!==s.data.download_limit_2||(s.data.download_limit_2=0),SYNO.SDS.BandwidthControl.SchedulePlanWinOpen.createDelegate(t,["user",s,!1])())},n=new SYNO.ux.NumberField({allowBlank:!0,allowNegative:!1,allowDecimals:!1,validationEvent:"keyup",selectOnFocus:!0,maxLength:9,emptyText:_T("dhcp_server","unlimited"),validateOnBlur:!0,validator:function(e){if(!this.bandwidthGrid.activeEditor||"FileStation"!==this.bandwidthGrid.activeEditor.record.get("protocol"))return!0;var t=parseInt(e,10);return!(("upload_limit_1"==r.config[this.bandwidthGrid.activeEditor.col].dataIndex||"download_limit_1"==r.config[this.bandwidthGrid.activeEditor.col].dataIndex)&&t<10&&t>0)||_WFT("bandwidth","bandwidth_min_rate")}.createDelegate(this),vtype:"number",listeners:{beforeshow:function(e){e.getValue()||e.reset()}}}),o=new Ext.data.ArrayStore({fields:["display","value"],data:[[_T("bandwidth","mode_enable"),"enabled"],[_T("bandwidth","mode_schedule"),"scheduled"]],autoDestroy:!0}),a={header:_T("bandwidth","mode"),dataIndex:"policy",width:160,renderer:function(e){return"disabled"===e||"notexist"===e||!1===e?_T("bandwidth","mode_enable"):"enabled"===e||!0===e?_T("bandwidth","mode_enable"):"scheduled"===e?_T("bandwidth","mode_schedule"):e},editor:new SYNO.ux.ComboBox({name:"modeSelect",hiddenName:"modeSelect",typeAhead:!0,triggerAction:"all",displayField:"display",valueField:"value",hideLabel:!0,id:Ext.id(),editable:!1,forceSelection:!0,valueNotFoundText:_T("bandwidth","mode_enable"),store:o,mode:"local",tpl:new Ext.XTemplate('','
',"{display}","
","
"),listeners:{scope:this,select:function(e,t){"scheduled"===t.data.value&&s(),e.fireEvent("blur")}}})},r=new Ext.grid.ColumnModel([{header:_T("bandwidth","bandwidth_protocol"),dataIndex:"protocol",width:120,align:"left",renderer:SYNO.SDS.BandwidthControl.ProtocolTitle},a,{header:`${_T("bandwidth","bandwidth_up_rate")} (${_T("bandwidth","speed_unit")})`,dataIndex:"upload_limit_1",width:115,align:"left",editor:n,renderer:i},{header:`${_T("bandwidth","bandwidth_down_rate")} (${_T("bandwidth","speed_unit")})`,dataIndex:"download_limit_1",width:135,align:"left",editor:n,renderer:i},{dataIndex:"schedule_plan",align:"center",hidden:!0},{dataIndex:"upload_limit_2",align:"center",hidden:!0},{dataIndex:"download_limit_2",align:"center",hidden:!0}]);r.isCellEditable=function(e,t){var i=d.getAt(t),s=r.findColumnIndex("policy");return("enabled"===i.get("policy")||e===s)&&Ext.grid.ColumnModel.prototype.isCellEditable.call(this,e,t)};let l=function(e){return 0<=["disabled","notexist"].indexOf(e)||!e};var d=new SYNO.API.JsonStore({api:"SYNO.Core.BandwidthControl",method:"get",version:2,appWindow:this,baseParams:{name:"",owner_type:"local_group"},pruneModifiedRecords:!0,fields:[{name:"upload_limit_1",convert:function(e,t){return l(t.policy)?0:e}},{name:"download_limit_1",convert:function(e,t){return l(t.policy)?0:e}},{name:"policy",convert:function(e,t){return l(t.policy)?"enabled":e}},"protocol","protocol_ui","owner_type","schedule_plan","upload_limit_2","download_limit_2"],root:"bandwidths",remoteSort:!1,listeners:{exception:{scope:e.owner,fn:SYNO.SDS.AdminCenter.Group.GroupDialog.prototype.onStoreException}}}),c=new SYNO.ux.Toolbar,h=new SYNO.ux.Button({name:"schedulePlanBtn",text:_T("bandwidth","edit_adv_setting"),disabled:!0,scope:this,handler:s});c.add(h);var u={title:_T("bandwidth","bandwidth_tab_title"),cm:r,ds:d,tbar:c,enableHdMenu:!1,enableColumnMove:!1,clicksToEdit:1,selModel:this.selModel=new Ext.grid.RowSelectionModel({singleSelect:!0,listeners:{selectionchange:{fn:function(e){e.getCount()>0?h.enable(!1):h.disable(!1)},scope:this}}}),bbar:new SYNO.ux.PageLessToolbar({store:d,doRefresh:function(){this.newgroup||0===this.bandwidthGrid.getStore().getModifiedRecords().length?this.bandwidthGrid.getStore().load({params:{name:this.groupName}}):this.owner.getMsgBox().confirm("",_T("share","share_save_chg_before_reload"),this.bandwidthConfirmSaveChange,this)}.bind(this)})};return Ext.apply(u,e),new SYNO.ux.EditorGridPanel(u)},bandwidthConfirmSaveChange:function(e){if("yes"!==e)return this.bandwidthGrid.getStore().rejectChanges(),void this.bandwidthGrid.getStore().load({params:{name:this.groupName}});let t=[];Ext.each(this.bandwidthGrid.getStore().getModifiedRecords(),function(e){e.data.name=this.groupName,t.push(e.data)},this),this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.BandwidthControl",method:"set",version:1,params:{bandwidths:t},callback:function(e,t,i){this.clearStatusBusy(),e?(this.bandwidthGrid.getStore().commitChanges(),this.bandwidthGrid.getStore().load({params:{name:this.groupName}})):this.getMsgBox().alert("",SYNO.API.Errors.core[t.error.code]||_T("common","error_system"))},scope:this})},onActionComplete:function(e,t){},onActionFailed:function(e,t){},hasForbidSelf:function(){let e=this.appPrivilegeGrid?this.appPrivilegeGrid.store.getModifiedRecords():[];return!!this.memberGrid&&this.memberGrid.getStore().findBy(e=>_S("user")===e.get("name")&&e.get("is_member"))>=0&&e.some(e=>"SYNO.Desktop"===e.get("app_id")&&"group"===e.get("entity_type")&&!0===e.get("deny"))},onSaveGroup:function(){if(this.hasForbidSelf()){let e=String.format(_T("app_privilege","warning_forbid_self_group"),this.groupName),t={yes:{text:_T("common","continue"),btnStyle:"red"},no:{text:Ext.MessageBox.buttonText.cancel}};this.getMsgBox().confirmDelete(this.title,e,function(e){"yes"===e&&this.confirmQuotaUpdate()},this,t)}else this.confirmQuotaUpdate()},confirmQuotaUpdate:function(){if(this.quotaGrid.confirmQuotaUpdate()){let e=_T("user","confirm_quota_update");this.getMsgBox().confirm("",e,function(e){"yes"===e?this.queryGlobalConf():this.clearStatusBusy()},this)}else this.queryGlobalConf()},queryGlobalConf:function(){this.setStatusBusy({text:_T("common","saving")});var e={api:"SYNO.Core.BandwidthControl.Protocol",method:"get",version:1},t=Ext.apply({params:{protocol:"FTP"}},e),i=Ext.apply({params:{protocol:"FileStation"}},e),s=Ext.apply({params:{protocol:"NetworkBackup"}},e),n=[t,i,{api:"SYNO.Core.FileServ.FTP",method:"get",version:1},{api:"SYNO.Core.FileServ.FTP.SFTP",method:"get",version:1}];"no"===this._D("usbstation","no")&&n.push(s,{api:"SYNO.Backup.Service.NetworkBackup",method:"get",version:1}),this.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:n},scope:this,callback:function(e,t,i){e?this.checkGlobalProtocol(t.result,i.compound):this.onActionFailed()}})},setGlobalConf:function(e){for(var t={api:"SYNO.Core.BandwidthControl.Protocol",method:"set",version:1},i=[],s=0;s{1}
',e,i.join(", "))},checkGlobalProtocol:function(e,t){var i=this.bandwidthGrid.getStore(),s=[],n=[],o="",a=!1,r=!1;Ext.each(e,function(e){e.success&&("SYNO.Core.FileServ.FTP"===e.api&&(e.data.enable_ftp||e.data.enable_ftps)?a=!0:"SYNO.Core.FileServ.FTP.SFTP"===e.api&&e.data.enable?a=!0:"SYNO.Backup.Service.NetworkBackup"===e.api&&e.data.enable?r=!0:"SYNO.Core.BandwidthControl.Protocol"===e.api&&"disabled"===e.data.policy&&n.push(e.data.protocol))}),a||n.remove("FTP"),r||n.remove("NetworkBackup");i.each(function(e){let t=e.get("protocol");0<=n.indexOf(t)&&!function(e){let t=e.get("policy");return 0<=["notexist","disabled"].indexOf(t)||"enabled"===t&&!e.get("upload_limit_1")&&!e.get("download_limit_1")}(e)&&s.push(t)},this),s.length>0?(o=this.getConfirmString(_T("bandwidth","bandwidth_global_conf_enable_desc"),s)||_T("bandwidth","bandwidth_global_conf_enable_desc"),this.getMsgBox().confirm(_T("bandwidth","bandwidth_tab_title"),o,function(e){"yes"===e?this.setGlobalConf(s):this.applySetting()},this)):this.applySetting()},createApiArray:function(){var e={},t=this.groupForm.getFieldValues(!0);e.name=this.groupName,t.name&&(e.new_name=t.name),Ext.isDefined(t.description)&&(e.description=t.description);var i=[];Ext.each(this.bandwidthGrid.getStore().getModifiedRecords(),function(t){t.data.name=e.new_name||e.name,i.push(t.data)},this);var s=[];return"local"===this.authType&&this.groupForm.isDirty()&&s.push({api:"SYNO.Core.Group",method:"set",version:1,params:e}),this.groupGrid&&(s=s.concat(this.groupGrid.getWebAPI(e.new_name||e.name))),s=s.concat(this.quotaGrid.getWebAPI(e.new_name||e.name)),00&&this.bandwidthGrid.getStore().loadData(i)},load:function(e,t){this.setTitle(e),this.groupForm.findField("name").setDisabled("users"===e||"administrators"===e||"http"===e),this.bandwidthGrid.setDisabled("http"===e),this.groupName=e,this.lastResult=!1,this.isSupportAppPriv&&(this.appPrivilegeGrid.entity_name=e);var i=[{api:"SYNO.Core.Group",method:"admin_check",version:1,params:{name:e}},{api:"SYNO.Core.BandwidthControl",method:"get",version:2,params:{name:e,owner_type:"local_group"}}];"yes"===this._D("supportquota","no")&&this._S("version")>5496&&(i=i.concat([{api:"SYNO.Core.Quota",method:"get",version:1,params:{name:e,subject_type:"group",support_share_quota:"yes"===this._D("support_share_user_quota","no")}},{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{offset:0,limit:-1,option:"include_cold_storage",location:"internal"}}])),this.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:i},scope:this,callback:function(e,t,i){if(!e||t.has_fail){var s=SYNO.API.Response.GetFirstError(t);this.getMsgBox().alert(this.title,SYNO.API.Erros.core[s.code]||_T("common","error_system")),this.close()}else this.loadSuccess(t)}}),this.groupForm.setValues({name:e,description:t}),this.groupGrid&&this.groupGrid.loadInfo(this.groupName),this.show()},getResult:function(){var e={};return e.success=this.lastResult,e.group=this.groupName,e},cancelCallback:function(){this.isDirty()?this.getMsgBox().confirm(_T("user","user_acnt_info"),_T("common","confirm_lostchange"),function(e){"yes"===e&&this.doClose()},this):this.doClose()}}),Ext.define("SYNO.SDS.AdminCenter.Group.CreateGroupSummaryStep",{extend:"SYNO.SDS.Wizard.SummaryStep",activate:function(){var e=this.owner,t=this.getStore(),i=[],s=[],n=[],o=[],a=[],r=e.groupForm.findField("name").getValue(),l=e.groupForm.findField("description").getValue();this.supportSharedOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main"),t.removeAll(!0),t.append(_T("group","group_name"),r),t.append(_T("group","group_desc"),l);let d=e.memberGrid.getStore().getModifiedRecords().map(e=>e.get("name"));t.append(_T("group","group_members"),d.join(", ")),this.supportSharedOperation&&(e.groupGrid.getStore().each(function(e){var t=this.getFinalPermission(e);"rw"==t?i.push(e.data.name):"ro"==t?n.push(e.data.name):"na"==t&&s.push(e.data.name)},e.groupGrid),t.append(_T("common","writeable"),i.join(", ")),t.append(_T("common","readonly"),n.join(", ")),t.append(_T("share","share_add_deny"),s.join(", "))),this.owner.isSupportQuota&&this.owner.quotaGrid.getStore().each(function(e){if(e.get("target")&&e.get("quota_enabled")){var i=String.format("{0} {1}",e.get("quota"),e.get("unit"));t.append(e.get("share"===e.get("target")?"name":"volume"),i+" ("+_T("user","group_quota_limit")+")")}}),this.owner.appPrivilegeGrid&&(this.owner.appPrivilegeGrid.getStore().each(function(e){e.get("allow")&&o.push(e.get("name"))}),t.append(_T("tree","leaf_appprivilege"),o.join(", "))),e.bandwidthGrid.getStore().getModifiedRecords().forEach(function(e){if("notexist"===e.get("policy"))return;let t=SYNO.SDS.BandwidthControl.ProtocolTitle(e.get("protocol"));if("scheduled"===e.get("policy"))return void a.push(`${t}(${_T("bandwidth","mode_schedule")})`);let i=e.get("upload_limit_1"),s=e.get("download_limit_1");i||(i=_T("dhcp_server","unlimited")),s||(s=_T("dhcp_server","unlimited")),a.push(`${t}(${i}/${s})`)}),t.append(_T("bandwidth","bandwidth_settings"),a.join(", ")),this.getView().syncFocusEl(0),this.getView().refresh()}}),Ext.define("SYNO.SDS.AdminCenter.Group.CreateGroupWizardDialog",{extend:"SYNO.SDS.Wizard.ModalWindow",constructor:function(e){this.isAlertExist=!1,this.owner=e.owner,this.module=e.module,this.newgroup=!0,this.supportSharedOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.Share.Main"),this.supportAppPrivOperation=_S("is_admin")||SYNO.SDS.ActionPrivilege.AllowList.includes("SYNO.SDS.AdminCenter.AppRulePrivileges.Main"),this.isSupportAppPriv=this._S("version")>4931,this.isSupportQuota="yes"===this._D("supportquota","no")&&this._S("version")>5496;var t=Ext.apply({title:_T("group","group_wizard_title"),width:640,height:500,steps:[]},e);this.groupFormPanel=SYNO.SDS.AdminCenter.Group.GroupDialog.prototype.createFormPanel.call(this,{headline:_T("group","group_basicinfo"),description:_T("group","groupinfo_descr"),title:"",itemId:"group",nextId:"member",owner:this,module:this.module,getNext:function(){return this.getForm().isValid()?this.owner.validGroupName(!0):SYNO.Debug("form invalid",this.getForm()),!1}}),this.memberGrid=new SYNO.SDS.AdminCenter.Group.MemberGrid({owner:this,module:this.module,height:345,width:560});var i=new Ext.Container({headline:_T("group","group_member_title"),owner:this,module:this.module,items:[this.memberGrid],itemId:"member",nextId:this.supportSharedOperation?"share":this.isSupportQuota?"quota":this.supportAppPrivOperation&&this.isSupportAppPriv?"appprivilege":"bandwidth",getNext:function(){return this.nextId}}),s=new Ext.Container;this.supportSharedOperation&&(this.groupGrid=new SYNO.SDS.AdminCenter.Group.GroupShareGrid({owner:this,module:this.module,authType:"local",newGroup:!0,height:345,width:560,bwrapCfg:{cls:"x-panel-bwrap",style:"padding-bottom: 0px;"}}),s=new Ext.Container({headline:_T("group","group_shareinfo_title"),description:_T("group","group_shareinfo_descr"),title:"",itemId:"share",nextId:this.isSupportQuota?"quota":this.supportAppPrivOperation&&this.isSupportAppPriv?"appprivilege":"bandwidth",owner:this,module:this.module,items:[this.groupGrid],getNext:function(){return this.nextId}})),this.quotaGrid=this.isSupportQuota?new SYNO.SDS.AdminCenter.Group.QuotaGrid({owner:this,module:this.module,height:345,width:560,bwrapCfg:{cls:"x-panel-bwrap",style:"padding-bottom: 0px;"}}):{initForCreation:Ext.emptyFn,getWebAPI:function(){return[]}};var n=this.isSupportQuota?new Ext.Container({headline:_T("group","quotainfo_title"),description:_T("userwizard","quotainfo_descr"),title:"",owner:this,module:this.module,items:[this.quotaGrid],itemId:"quota",nextId:this.supportAppPrivOperation&&this.isSupportAppPriv?"appprivilege":"bandwidth",getNext:function(){return this.owner.supportAppPrivOperation&&this.owner.isSupportAppPriv&&this.owner.appPrivilegeGrid.fireEvent("activate"),this.nextId}}):this.quotaGrid,o=new Ext.Container;this.supportAppPrivOperation&&this.isSupportAppPriv&&(this.appPrivilegeGrid=SYNO.SDS.AdminCenter.Group.GroupDialog.prototype.initPrivilegeGrid({owner:this,module:this.module,height:345,width:560,entity_type:"group",hide_custom:!0,appFilter:function(e){if(e.supportIP&&-10&&this.supportSharedOperation&&e.push({api:"SYNO.Core.Share.Permission",method:"set_by_user_group",version:1,params:{name:t.name,user_group_type:"local_group",permissions:s}}),e=e.concat(this.quotaGrid.getWebAPI(t.name));var n=[];this.bandwidthGrid.getStore().getModifiedRecords().forEach(function(e){e.data.name=this.groupForm.findField("name").getValue(),n.push(e.data)},this),0",t]}):"domain"===this.authType?(e.updateButton.grid=this,e.domainFilter.grid=this,{items:[new SYNO.ux.Button(i),this.btnDelegate,e.updateButton,"->",{xtype:"syno_displayfield",itemId:"filterName",value:_T("helptoc","directory_service_domain")+_T("common","colon"),style:"margin-right: 8px"},e.domainFilter,t]}):{items:[{xtype:"syno_button",text:_T("common","create"),itemId:"create_grp",scope:this,handler:this.createHandler},new SYNO.ux.Button(i),new SYNO.ux.Button(s),this.btnDelegate,"->",t]}},isLocal:function(){return"local"===this.authType},createHandler:function(){this._D("maxgroups")<=this.store.getTotalCount()?SYNO.SDS.AdminCenter.Group.Alert.call(this.findAppWindow(),3209,this):new SYNO.SDS.AdminCenter.Group.CreateGroupWizardDialog({owner:this.module.owner,sharePermLimited:this.sharePermLimited,module:this}).open()},editHandler:function(){var e=this.getFirstSelection();e&&(this.position=this.getBottomToolbar().cursor+this.store.indexOf(e),this.launchGroupDialog(e.get("name"),e.get("description")))},deleteHandler:function(){var e=this.getSelectionModel();if(!0!==e.isIdSelected("users")&&!0!==e.isIdSelected("administrators")&&!0!==e.isIdSelected("http")){var t=e.getSelections();if(0!==t.length){var i=[];Ext.each(t,function(e,t,s){i.push(e.get("name"))},this),this.module.owner.getMsgBox().confirmDelete(_T("tree","leaf_group"),5"+i.join(", "),function(e){"yes"===e&&(this.position=this.getBottomToolbar().cursor+this.store.indexOf(t[0]),this.applyDeleteGroup(i))},this)}else this.module.owner.getMsgBox().alert(_T("tree","leaf_group"),_T("group","error_rmvempty"))}else this.module.owner.getMsgBox().alert(_T("tree","leaf_group"),_T("group","error_rmvdef"),function(){var t=this.store.indexOfId("users");-1!==t&&e.deselectRow(t),-1!==(t=this.store.indexOfId("administrators"))&&e.deselectRow(t),-1!==(t=this.store.indexOfId("http"))&&e.deselectRow(t)},this)},delegateHandler:function(){var e=[],t=this.getSelectionModel().getSelections();0!==t.length?(Ext.each(t,function(t){e.push(t.get("name"))}),this.launchGroupDelegateDialog(e)):this.module.owner.getMsgBox().alert(_T("tree","leaf_group"),_T("group","error_rmvempty"))},getFirstSelection:function(){var e=this.getSelectionModel().getSelected();return e||(this.module.owner.getMsgBox().alert(_T("tree","leaf_group"),_T("group","error_rmvempty")),null)},clearSearch:function(){this.toolbar.getComponent("search").reset()},applyDeleteGroup:function(e){this.module.owner.setStatusBusy({text:_T("group","deleting_group")}),this.module.owner.sendWebAPI({api:"SYNO.Core.Group",method:"delete",version:1,params:{name:e},scope:this,callback:this.applyDeleteGroupDone})},applyDeleteGroupDone:function(e,t,i,s){this.module.owner.clearStatusBusy();var n=0;if(e)this.isLocal()||(n=Math.floor(this.position/this.pageSize)*this.pageSize)>=this.totalNum-i.name.length&&(n-=this.pageSize)<0&&(n=0);else if(SYNO.SDS.AdminCenter.Group.Alert.call(this,t.code),t.code&&3202===t.code)return;this.store.load({params:{offset:n,limit:this.pageSize,type:this.authType}})},onSelectionChange:function(e){var t=e.getCount(),i=this.actionGroup;0===t?(Ext.iterate(i,function(e,t,i){t.disable()},this),this.btnDelegate.menu.getComponent("delegate").disable()):(i.delete.enable(),e.isIdSelected("users")||e.isIdSelected("administrators")?this.btnDelegate.menu.getComponent("delegate").disable():this.btnDelegate.menu.getComponent("delegate").enable(),t>1?i.edit.disable():i.edit.enable())},onContainerContextMenu:function(e,t){var i=e.getSelectionModel().getSelected(),s=e.store.indexOf(i);this.onRowContextMenu(e,s,t)},onRowContextMenu:function(e,t,i){var s=[];"local"===this.authType?Ext.iterate(this.actionGroup,function(e,t,i){s.push(t)},this):s.push(this.actionGroup.edit);var n=new SYNO.ux.Menu({autoDestroy:!0,items:s}),o=e.getSelectionModel();o.selectRow(t,o.isSelected(t)),n.showAt(i.getXY()),i.preventDefault()},onRowDblClick:function(e,t,i){var s=this.store.getAt(t);s&&(this.position=this.getBottomToolbar().cursor+this.store.indexOf(s),this.launchGroupDialog(s.get("name"),s.get("description")))},onStoreException:function(e,t,i,s,n,o){if(this.module.owner.clearStatusBusy(),SYNO.Debug("Store exception: options:",s),s.params.substr&&this.clearSearch(),3203===n.code)return this.getEl().mask(_T("directory_service","warr_db_not_ready"),"syno-ux-mask-info"),void(this.updateButton.pollingId||this.updateButton.restartPolling());var a=SYNO.SDS.AdminCenter.Group.GetErrMsg(n.code?n.code:3299);this.module.owner.getMsgBox().alert(this.title,a,function(){},this)},onBeforeLoad:function(e,t){if("domain"===this.authType){var i=[];this.domainFilter.setValue(this.module.currDomain),this.store.baseParams.domain_name=this.module.currDomain?this.module.currDomain:"",this.getColumnModel().getColumnsBy(function(e){return e.hidden||i.push(e.dataIndex),!1}),t.params.searchFields=i}this.module.owner.setStatusBusy()},onLoad:function(e,t,i){if(this.onSelectionChange(this.selModel),this.module.owner.clearStatusBusy(),this.totalNum=e.totalLength,this.focusGroup){var s=e.indexOfId(this.focusGroup);-1!==s&&(this.getSelectionModel().selectRow(s),function(){this.getView().focusRow(s)}.defer(100,this))}},onGroupDialogClose:function(e){var t=e.getResult();if(!0===t.success){var i=0;this.isLocal()||(i=Math.floor(this.position/this.pageSize)*this.pageSize),this.focusGroup=t.group,this.store.load({params:{offset:i,limit:this.pageSize,type:this.authType}})}},launchGroupDialog:function(e,t){var i=new SYNO.SDS.AdminCenter.Group.GroupDialog({owner:this.module.owner,module:this,authType:this.authType,groupName:e,sharePermLimited:this.sharePermLimited,newGroup:!1});i.mon(i,"close",this.onGroupDialogClose,this),i.load(e,t)},launchGroupDelegateDialog:function(e){new SYNO.SDS.AdminCenter.User.DelegateDialog({owner:this.module.owner,module:this.module,type:"group",name:e}).open()}}),Ext.define("SYNO.SDS.AdminCenter.Group.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.owner=e.appWin,this.callParent([e]),this.panel=new SYNO.SDS.AdminCenter.Group.GridPanel({module:this})},getPanel:function(){return this.panel},getHelpParam:function(){return"AdminCenter/file_group_desc.html"},activate:function(){return!0},deactivate:function(){return!0}}),Ext.define("SYNO.SDS.AdminCenter.User.HomeFieldSet",{extend:"SYNO.ux.FieldSet",moveShareMsg:String.format('
{0}
',_T("share","share_move_progress")),initEvents:function(){this.callParent(arguments);this.mon(this,"afterlayout",()=>{new SYNO.ux.Utils.EnableCheckGroup(this.ownerCt.getForm(),"enable",["location"])},this,{single:!0}),this.mon(this,"afterlayout",()=>{this.volProcessingTip=SYNO.ux.AddTip(this.ownerCt.getForm().findField("location"),_T("user","home_volume_processing"))},this,{single:!0})},constructor:function(e){this.authType=e.authType||"local",this.stopHomePollingCallback=e.stopHomePollingCallback||Ext.emptyFn,this.homeInfo={},this.homePollingId=void 0,this.hasWebStation=SYNO.API.GetKnownAPI("SYNO.WebStation.Default");const t=Ext.apply({title:"local"===this.authType?_T("user","user_home_set"):"",collapsible:"local"===this.authType,webapi:{api:"SYNO.Core.User.Home",version:1,methods:{get:"get",set:"set"},params:{get:{additional:["personal_photo_enable"]}}},items:this.createItems(e)},e);this.callParent([t])},createItems:function(e){let t=_T("user","user_home_enable");"domain"===e.authType?t=_T("domain","domain_user_home_enable"):"ldap"===e.authType&&(t=_T("ldap","ldap_user_home_enable"));const i=String.format(_T("share","note_enable_home_recycle_bin"),'',""),s=String.format(_T("share","note_enable_home_recycle_bin"),"","");let n=''+_T("common","note")+_T("common","colon")+" ";return"local"===this.authType?n+=i:n+='
  • '+_T("domain","domain_user_home_notice")+"
  • "+s+"
",[{xtype:"syno_checkbox",name:"enable",ref:"enable",boxLabel:t,listeners:{check:function(e,t){if(t&&_D("usbstation")){if(0===this.location.getStore().getCount())return this.findWindow().getMsgBox().alert(null,String.format(_T("service","no_ext4_external_devices"),_T("helptoc","user_home"))),e.setValue(!1),!1}!t&&this.homeInfo.chroot&&this.homeInfo.chroot_include_home&&this.findWindow().getMsgBox().alert(null,_T("user","user_chroot_warning"))},afterrender:function(e){SYNO.ux.AddTip(e,_T("user","homes_tooltip"))},scope:this}},{xtype:"syno_displayfield",indent:1,name:"errorMsg",ref:"errorMsg",htmlEncode:!1,hidden:!0},{xtype:"syno_message_combobox",indent:1,width:360,fieldLabel:_T("user","location_of_homes"),name:"location",ref:"location",store:new Ext.data.JsonStore({autoDestroy:!0,idProperty:"value",fields:["value","display","desc"]}),allowBlank:!1,displayField:"display",descriptionField:"desc",valueField:"value",triggerAction:"all",editable:!1,grow:!0},{xtype:"syno_displayfield",indent:1,name:"recycle_bin_status",htmlEncode:!1,fieldLabel:_T("home","recycle_bin_status")},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,name:"user_home_note",value:n,listeners:{afterrender:function(e){const t=e.el.first("a");t&&this.mon(t,"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Share.Main"})},this)},scope:this}}]},showMoveShareProgress:function(){this.findWindow().getMsgBox().show({title:"",width:300,msg:this.moveShareMsg,progress:!0,progressText:"0 %",closable:!1})},updateMoveShareProgress:function(e){let t="";t=e>99?"100 %":String.format("{0} %",Math.round(100*e)/100),this.findWindow().getMsgBox().updateProgress(e/100,t,this.moveShareMsg)},startHomePolling:function(e){this.showMoveShareProgress(),this.homePollingId=this.pollReg({webapi:{api:"SYNO.Core.User.Home",method:"status",version:1,params:{task_id:e}},interval:3,immediate:!0,scope:this,status_callback:function(e,t,i,s){if(!e||!t.success)return this.findWindow().getMsgBox().alert(_T("tree","leaf_notification"),SYNO.SDS.AdminCenter.User.Error2Msg(t.error.code)),void this.stopHomePolling(!0);t.finish?(this.findWindow().getMsgBox().hide(),this.stopHomePolling(!0),this.stopHomePollingCallback()):this.updateMoveShareProgress(t.data.percent)}})},stopHomePolling:function(e){void 0!==this.homePollingId&&(this.pollUnreg(this.homePollingId),this.homePollingId=void 0),e&&this.sendWebAPI({api:"SYNO.Core.User.Home",method:"stop",version:1,callback:function(e,t,i){e||SYNO.SDS.AdminCenter.User.Alert(this.owner)},scope:this})},isHomePolling:function(){return this.homePollingId},restartHomePolling:function(){if(this.isHomePolling())return;const e=(t,i)=>{i>=t.length||this.sendWebAPI({api:"SYNO.Core.User.Home",method:"status",version:1,params:{task_id:t[i]},scope:this,callback:function(s,n,o,a){!s||n.finish?e(t,i+1):this.startHomePolling(o.task_id)}})};this.findWindow().pollList({task_id_prefix:"userhome",extra_group_tasks:["admin"],scope:this,callback:function(t,i,s,n){t&&Ext.isArray(i.admin)&&e(i.admin,0)}})},getFeasibilityCheckMsg:function(e,t){let i="";return Ext.each(t,function(e){i+=String.format("
  • {0}
  • ",SYNO.SDS.Utils.GetFeasibilityCheckMsg(e))}),String.format('{0}

      {1}
    ',e,i)},getBtrfsErrorMsg:function(){let e="";const t=this.homeInfo.location,i=this.location.getValue();return t===i?e:(this.volumeFsMap={},Ext.each(this.homeInfo.volumes,function(e,t,i){this.volumeFsMap[e.volume_path]=e.fs_type},this),"btrfs"===this.volumeFsMap[t]&&(e+="
  • "+_T("share","share_move_snapshot_lost_warning")+"
  • ","btrfs"!==this.volumeFsMap[i]&&(e+="
  • "+_T("share","share_move_quota_lost_warning")+"
  • ")),e)},doFeasibilityCheck:function(){const e=this.enable.getValue(),t=this.location.getValue();this.homeInfo.enable!==e?(this.findWindow().setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({api:"SYNO.Core.User.Home",method:"validate_set",params:{enable:e,location:t},version:1,scope:this,callback:function(e,t,i){if(this.findWindow().clearStatusBusy(),e)Ext.isArray(t.hard_reasons)&&t.hard_reasons.length>0?this.findWindow().getMsgBox().alert(null,this.getFeasibilityCheckMsg(_T("share","edit_hard_check_fail"),t.hard_reasons)):Ext.isArray(t.soft_reasons)&&t.soft_reasons.length>0?this.findWindow().getMsgBox().confirm(null,this.getFeasibilityCheckMsg(_T("home","edit_soft_check_fail"),t.soft_reasons),function(e){"yes"===e&&this.doSubmit()},this,{yes:{text:_T("common","continue")},no:{text:_T("common","cancel")}}):this.doSubmit();else{let e=SYNO.API.Response.GetFirstError(t);const i=SYNO.API.Errors.core[e.code]||_T("common","error_system");this.findWindow().getMsgBox().alert(null,i)}}})):this.doSubmit()},doSubmit:function(){var e=this.location.getValue();this.enable.getValue()&&e!==this.homeInfo.location&&""!==this.homeInfo.location?(this.findWindow().setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({api:"SYNO.Core.User.Home",method:"move_check",version:1,params:{location:e},scope:this,callback:function(e,t,i){if(this.findWindow().clearStatusBusy(),!e)return void SYNO.Debug("failed to perform move_check");const s=()=>{let e=_T("share","share_move_desc_time_spent")+"
    ";e+=_T("share","share_move_please_note")+_T("common","colon")+"
    ",e+="
  • "+_T("share","share_move_serivce_stopped")+"
  • ",e+=this.getBtrfsErrorMsg(),e+="
  • "+_T("user","home_volume_change")+"
  • ",e+="
    "+_T("common","ask_cont");const t=new SYNO.SDS.AdminCenter.Share.Move({owner:this.findWindow(),msg:e,scope:this,callback:function(e){"yes"===e&&this.submitHomeChange(!0)}});t.loadMessage(e),t.open()};Ext.isArray(t.hard_reasons)&&t.hard_reasons.length>0?this.findWindow().getMsgBox().alert(null,this.getFeasibilityCheckMsg(_T("share","edit_hard_check_fail"),t.hard_reasons)):Ext.isArray(t.soft_reasons)&&t.soft_reasons.length>0?this.findWindow().getMsgBox().confirm(null,this.getFeasibilityCheckMsg(_T("share","edit_soft_check_fail"),t.soft_reasons),function(e){"yes"===e&&s()},this):s()}})):this.submitHomeChange(!1)},submitHomeChange:function(e){const t=this.enable.getValue();e&&(this.successHandler=this.startHomePolling),SYNO.SDS.Utils.S2S.confirmIfSyncShareAffected(!1,t?{name:"homes",is_sync_share:this.homeInfo.userhome_in_s2s,no_check_permission:!0}:null,{dialogTitle:null,dialogMsg:_T("s2s","s2s_warn_homes_enable"),dialogOwner:this.findWindow(),continueHandler:function(){this.ownerCt&&Ext.isFunction(this.ownerCt.applyForm)&&this.ownerCt.applyForm()},abortHandler:function(){this.enable.setValue(!1)},scope:this})},isHomeEnableChanged:function(e){return!(e===this.homeInfo.enable)},applyHandler:function(){const e=this.homeInfo.location,t=this.location.getValue(),i=this.enable.getValue();if(e!==t&&2==this.homeInfo.encryption)return this.owner.getMsgBox().alert(this.title,_T("user","warning_move_share_decrypted")),!1;if((this.homeInfo.enable_userdir||this.homeInfo.personal_photo_enable)&&this.isHomeEnableChanged(i)&&!i)if("local"!==this.authType)this.doSubmit();else{let e=[];this.homeInfo.enable_userdir&&e.push(_T("service","service_web_localuser")),this.homeInfo.personal_photo_enable&&e.push(_T("service","service_photo_personal_title")),this.findWindow().getMsgBox().minWidth=400,this.findWindow().getMsgBox().confirm(_T("user","user_home_set"),String.format(_T("service","service_app_uhconflict"),e.join(", ")),function(e,t){"yes"==e?(SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.PersonalPhotoStation",!0),this.doFeasibilityCheck()):this.enable.setValue(!0)},this)}else this.doFeasibilityCheck()},processParams:function(e,t){if("set"===e){let e=t.find(e=>"SYNO.Core.User.Home"===e.api);e&&""===this.homeInfo.remote_location&&("local"===this.authType?!1===e.params.enable&&(this.homeInfo.enable_domain&&(e.params.enable_domain=!1),this.homeInfo.enable_ldap&&(e.params.enable_ldap=!1)):("domain"===this.authType?e.params.enable_domain=e.params.enable:"ldap"===this.authType&&(e.params.enable_ldap=e.params.enable),0==e.params.enable&&!0===this.homeInfo.enable&&delete e.params.enable))}let i=[{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{offset:0,limit:-1,location:"yes"===_D("usbstation","no")?"external":"internal",option:"include_cold_storage"}},{api:"SYNO.Core.FileServ.FTP.Security",version:1,method:"get",params:{}},{api:"SYNO.Core.FileServ.FTP.ChrootUser",version:2,method:"load"},{api:"SYNO.S2S.Server.Pair",version:1,method:"list",params:{additional:["sync_shares"]}}];return this.hasWebStation&&(i=i.concat([{api:"SYNO.WebStation.Default",version:1,method:"get"}])),i},processReturnData:function(e,t,i){if("local"!==this.authType&&0===SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Storage.Volume","list","total"))return void("SYNO.SDS.CMS.Application"===this.findAppWindow().getOpenConfig("className")?SYNO.SDS.AdminCenter.User.Alert.call(this.findAppWindow(),_T("cms","cms_no_volumes")):SYNO.SDS.AdminCenter.User.Alert.call(this.findAppWindow(),_T("volume","volume_share_volumeno"),function(){SYNO.SDS.AppLaunch("SYNO.SDS.StorageManager.Instance")}));const s=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.User.Home","get"),n=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Storage.Volume","list"),o=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.FileServ.FTP.Security","get"),a=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.FileServ.FTP.ChrootUser","load"),r=SYNO.API.Response.GetValByAPI(t,"SYNO.S2S.Server.Pair","list");let l=!1;if(r&&r.clients&&Ext.each(r.clients,function(e){if(Ext.each(e.additional.sync_shares,function(e){if("homes"===e)return l=!0,!1}),l)return!1}),this.successHandler)Ext.each(t.result,function(e){"SYNO.Core.User.Home"===e.api&&"get"===e.method&&(e.data={})});else{Ext.apply(this.homeInfo,s),s.additional&&Ext.apply(this.homeInfo,s.additional);const e=s.location;Ext.apply(this.homeInfo,n),SYNO.SDS.AdminCenter.User.CreateVolumeMap(n),this.homeInfo.userhome_in_s2s=l;const t=n.map[e];let i=!1,o="",a=!1,r=!1;if(Ext.each(n.volumes,function(e){if(!e.readonly)return i=!0,!1}),i?t&&(0<=["volume_op_fsck","volume_op_balance"].indexOf(t.status)?r=!0:t.readonly&&(o=''+_T("user","home_volume_crash")+"",a=!0)):(o=''+_T("volume","volume_share_volumeno")+"",this.enable.disable(),a=!0),a)return this.enable.disable(),this.errorMsg.setValue(o),this.errorMsg.originalValue=o,this.errorMsg.setVisible(!0),void Ext.getCmp(this.volProcessingTip.id).hide();if(r?(this.enable.disable(),this.errorMsg.setVisible(!1),Ext.getCmp(this.volProcessingTip.id).show()):(this.enable.enable(),this.errorMsg.setVisible(!1),Ext.getCmp(this.volProcessingTip.id).hide()),1==this.homeInfo.encryption){const e=''+_T("user","warning_status_share_encrypted")+"";this.errorMsg.setValue(e),this.errorMsg.originalValue=e,this.errorMsg.setVisible(!0)}let d=this.location.getStore();n.volumes&&n.total&&(d.removeAll(),Ext.each(n.volumes,function(e){return!!e.readonly||("yes"===_D("usbstation")&&"ext4"!==e.fs_type||void d.loadData({value:e.volume_path,display:SYNO.SDS.Utils.StorageUtils.VolumeNameSizeRenderer(e),desc:e.description},!0))},this)),d.sort("value","ASC"),"domain"===this.authType?this.homeInfo.enable=this.homeInfo.enable_domain:"ldap"===this.authType&&(this.homeInfo.enable=this.homeInfo.enable_ldap),this.homeInfo.recycle_bin_status=!0===this.homeInfo.enable_recycle_bin?''+_T("common","enabled")+"":''+_T("common","disabled")+"",this.ownerCt.getForm().setValues(this.homeInfo),0!==n.volumes.length&&0!==d.getCount()&&!this.location.getValue()&&d.getRange(0,0)[0].get("value")&&this.ownerCt.getForm().setValues({location:d.getRange(0,0)[0].get("value")})}if(this.homeInfo.chroot=o.user_chroot,a&&a.rules&&(this.homeInfo.chroot_include_home=a.rules.some(e=>"/home"===e.path)),this.hasWebStation){const e=SYNO.API.Response.GetValByAPI(t,"SYNO.WebStation.Default","get");this.homeInfo.enable_userdir=e.enable_userdir}else this.homeInfo.enable_userdir=!1;if("get"===e)return;if(this.successHandler){const e=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.User.Home","set");this.successHandler(e.task_id),this.successHandler=null}const d=!0===this.enable.getValue()?"create":"delete";SYNO.SDS.StatusNotifier.fireEvent("sharefolderchanged",d)}}),Ext.define("SYNO.SDS.AdminCenter.User.OptionTab",{extend:"SYNO.SDS.Utils.FormPanel",default_min_length:8,default_max_length:127,default_history_num:1,default_max_history:99,default_min_age:1,default_max_age:999,itemId:"option_tab",constructor:function(e){this.owner=e.owner,this.module=e.module,this.passwordChecker=e.passwordChecker,this.form=this.getForm(),this.enable_mail=!0,this.showMustChgPwdConfirm=!0,this.setAllMustChgPwd=!1,this.neverExpiredList=[],this.userHomeFieldSet=new SYNO.SDS.AdminCenter.User.HomeFieldSet({module:this.module,authType:"local",stopHomePollingCallback:this.loadForm.bind(this)}),Ext.QuickTips.init();var t=Ext.apply({title:_T("common","advanced"),border:!1,trackResetOnLoad:!0,useDefaultBtn:!0,items:[{xtype:"syno_fieldset",stateId:"SYNO.SDS.AdminCenter.User.Main::advance::password",title:_T("passwd","passwd_strength_title"),collapsible:!0,webapi:{api:"SYNO.Core.User.PasswordPolicy",version:1,methods:{get:"get",set:"set"}},items:[{xtype:"syno_checkbox",name:"enable_reset_passwd_by_email",boxLabel:_T("passwd","forget_pass_enable"),listeners:{check:function(e,t){t&&!this.enable_mail&&this.confirmMailService(e,"pwd_settings")},scope:this}},{xtype:"syno_checkbox",name:"password_must_change",boxLabel:_T("passwd","mustchange_after_reset")},{xtype:"syno_checkbox",name:"strong_password_enable",boxLabel:_T("passwd","passwd_strength_enforce")},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,value:String.format(_T("passwd","passwd_strength_desc"),'',""),listeners:{scope:this,afterrender:function(e){const t=e.el.first("a");t&&this.mon(t,"click",function(){this.owner.onClickHelp()},this)}}},{xtype:"syno_checkbox",indent:1,name:"exclude_username",boxLabel:_T("passwd","exclude_username")},{xtype:"syno_checkbox",indent:1,name:"mixed_case",boxLabel:_T("passwd","mixed_case")},{xtype:"syno_checkbox",indent:1,name:"included_numeric_char",boxLabel:_T("passwd","included_numeric_char")},{xtype:"syno_checkbox",indent:1,name:"included_special_char",boxLabel:_T("passwd","included_special_char")},{xtype:"syno_checkbox",indent:1,name:"exclude_common_password",boxLabel:_T("passwd","exclude_common_password")},{indent:1,xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_checkbox",name:"min_length_enable",width:280,boxLabel:_T("passwd","min_length_enable")},{xtype:"syno_numberfield",defaultMinValue:this.default_min_length,maxValue:this.default_max_length,width:100,name:"min_length",validator:function(e){return!this.isDirty()||(!(e=i)||_T("passwd","invalid_expire_general_rule")},this)}]},{indent:1,xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_checkbox",name:"enable_login_prompt",id:this.enable_login_prompt_id=Ext.id(),width:330,boxLabel:_T("passwd","expire_warning")},{xtype:"syno_numberfield",minValue:this.default_min_age,maxValue:this.default_max_age,width:100,name:"login_prompt_days",value:this.default_min_age,maxlength:2,validator:Ext.createDelegate(function(e){var t=Ext.getCmp(this.enable_login_prompt_id).getValue(),i=Ext.getCmp(this.max_age_id).getValue();return!(!0===t&&e>=i)||_T("passwd","invalid_expire_general_rule")},this)}]},{xtype:"syno_checkbox",indent:1,name:"allow_reset_after_expired",boxLabel:_T("passwd","expire_change_pwd")},{xtype:"syno_checkbox",indent:1,name:"enable_mail_notification",listeners:{check:function(e,t){t&&!this.enable_mail&&this.confirmMailService(e,"pwd_expiration")},scope:this},boxLabel:_T("passwd","expire_notification")},{xtype:"syno_compositefield",hideLabel:!0,indent:2,items:[{xtype:"syno_displayfield",name:"mail_notify_time",value:_T("passwd","notify_time"),width:302},{xtype:"syno_combobox",store:s,displayField:"display",valueField:"value",triggerAction:"all",mode:"local",width:93,name:"mail_scheduled_hour",value:t[0][0],editable:!1},{xtype:"syno_displayfield",value:":",tabindex:-1},{xtype:"syno_combobox",store:n,displayField:"display",valueField:"value",triggerAction:"all",width:93,mode:"local",name:"mail_scheduled_minute",value:i[0][0],editable:!1}]},{indent:2,xtype:"syno_textfield",fieldLabel:_T("passwd","notify_frequency"),labelWidth:364,width:204,name:"mail_notification_days",allowBlank:!1,maskRe:/[0-9,]/,regex:/^([0-9]{1,3}(,[0-9]{1,3})*|^[^0])$/,value:"7",maxLength:4096,listeners:{afterrender:function(e){SYNO.ux.AddTip(this.getEl(),_T("passwd","notify_frequency_tip"))}},validator:Ext.createDelegate(function(e){var t=e.split(",").map(Number),i=Ext.getCmp(this.min_age_enable_id).getValue(),s=Ext.getCmp(this.max_age_id).getValue(),n=Ext.getCmp(this.min_age_id).getValue();return t.sort(function(e,t){return t-e}),t[0]>s?_T("passwd","notify_day_greater_than_maxage"):!0===i&&t[t.length-1]0&&(this.form.setValues({strong_password_enable:!0}),this.form.setValues(n.strong_password),this.successHandler||(this.oriStrongPasswordEnable=n.strong_password.strong_password_enable)),this.form.findField("password_expire_enable").suspendEvents(!0),this.form.setValues(o),this.form.findField("password_expire_enable").resumeEvents(),this.userHomeFieldSet.processReturnData(e,t,i)},checkError:function(e){let t=!1,i=[];Ext.each(e.result,function(e){if(!e.success){if("SYNO.S2S.Server.Pair"===e.api&&(703===e.error.code||707===e.error.code))return!0;if("SYNO.Core.User.Home"===e.api&&"get"===e.method&&3113===e.error.code)return!0;e.error&&e.error.code&&i.push(e.error.code),t=!0}});const s=SYNO.API.Errors.core[i[0]]||_JSLIBSTR("uicommon","error_system");return{hasError:t,errMsg:s}},onApiSuccess:function(e,t,i){this.findWindow().clearStatusBusy(),t.has_fail=this.checkError(t).hasError,"set"===e&&(t.has_fail?(this.module.confirmSaveLostReject&&this.module.confirmSaveLostReject(),this.module.panel&&this.module.panel.setActiveTab("option_tab")):(this.module.confirmSaveLostResolve&&this.module.confirmSaveLostResolve(),this.setStatusOK())),this.callParent(arguments)},processParams:function(e,t){for(var i=0;ithis.getForm().findField(e).isDirty())},onBeforeRequest:function(e){if("set"===e&&this.showMustChgPwdConfirm&&this.isPasswordRuleModified()){return new SYNO.SDS.AdminCenter.User.ConfirmSetMustChgPwdDialog({module:this.module,owner:this.owner,callback:function(e){this.showMustChgPwdConfirm=!1,this.setAllMustChgPwd="yes"===e,this.applyHandler(),this.showMustChgPwdConfirm=!0},scope:this}).open(),!1}return!0},getMailSetting:function(){this.sendWebAPI({compound:{stopwhenerror:!1,params:[{api:"SYNO.Core.Notification.Mail.Conf",version:1,method:"get"},{api:"SYNO.Core.Notification.Push.Mail",version:1,method:"get"},{api:"SYNO.Core.NormalUser",version:1,method:"get"}]},scope:this,callback:function(e,t,i,s){t.has_fail||(this.enable_mail=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Notification.Mail.Conf","get","enable_mail")||SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Notification.Push.Mail","get","enable_mail"),this.current_user_mail=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.NormalUser","get","email"))}})},activate:function(){this.userHomeFieldSet.restartHomePolling(),this.getMailSetting()},deactivate:function(){return this.userHomeFieldSet.stopHomePolling(),!this.getForm().isDirty()},defineBehaviors:function(){new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"min_length_enable",["min_length"]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"strong_password_enable",["exclude_username","included_numeric_char","included_special_char","min_length_enable","min_length","mixed_case","exclude_common_password","exclude_history","history_num"]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"exclude_history",["history_num"]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"min_age_enable",["min_age"],[],{disable_group:!0}),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_login_prompt",["login_prompt_days"],[],{disable_group:!0}),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_mail_notification",["mail_notify_time","mail_scheduled_hour","mail_scheduled_minute","mail_notification_days"],[],{disable_group:!0}),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"password_expire_enable",["max_age","min_age_enable","min_age","enable_login_prompt","login_prompt_days","allow_reset_after_expired","enable_mail_notification","mail_notify_time","mail_scheduled_hour","mail_scheduled_minute","mail_notification_days"],[],{disable_group:!0})},applyHandler:function(){return!this.form.findField("strong_password_enable").getValue()||!this.form.findField("exclude_history").getValue()||this.form.findField("password_expire_enable").getValue()&&this.form.findField("min_age_enable").getValue()?this.form.findField("strong_password_enable").getValue()&&!this.hasRule()?(this.owner.getMsgBox().alert(this.title,_T("passwd","invalid_rule")),!1):!!this.onBeforeRequest("set")&&this.userHomeFieldSet.applyHandler():(this.owner.getMsgBox().alert(this.title,_T("passwd","invalid_history_rule")),!1)},hasRule:function(){var e=this,t=!1;return Ext.each(["exclude_username","mixed_case","included_numeric_char","included_special_char","min_length_enable","exclude_common_password","exclude_history"],function(i){if(e.getForm().findField(i).getValue())return t=!0,!1}),t}}),Ext.define("SYNO.SDS.AdminCenter.User.UnExpireUserDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=e.appWin,this.neverExpiredList=e.neverExpiredList,this.panel=this.createPanel(e);var t={width:600,height:420,minWidth:600,minHeight:420,layout:"fit",title:_T("user","join_never_expired_list"),buttons:[{text:_T("common","alt_cancel"),scope:this,handler:this.close},{text:_T("common","alt_apply"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.panel]};Ext.apply(t,e),this.callParent([t])},onApply:function(){this.panel.getStore().each(function(e){e.get("is_checked")&&this.neverExpiredList.push(e.get("name"))},this),this.close()},createPanel:function(e){var t=new SYNO.API.JsonStore({appWindow:this,autoDestroy:!0,api:"SYNO.Core.Group.ValidLocalAdmin",method:"list",version:1,baseParams:{},listeners:{exception:{scope:this,fn:this.onStoreException},beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:this.onLoad}},fields:[{name:"is_checked",type:"boolean",mapping:function(e){return e.name===_S("user")}},{name:"name",type:"string"}],root:"users",id:"name",remoteSort:!1}),i=new SYNO.ux.EnableColumn({enableFastSelectAll:!0,header:_T("userwizard","join_group"),dataIndex:"is_checked",width:50,align:"center"}),s=new Ext.grid.ColumnModel([i,{id:"name",header:_T("user","user_account"),dataIndex:"name",width:150}]),n={title:_T("user","user_groups"),cm:s,ds:t,plugins:[i],autoExpandColumn:"name",enableColLock:!1,enableHdMenu:!1,cls:"without-dirty-red-grid",bbar:{autoHeight:!0,items:[{tabIndex:0,xtype:"syno_displayfield",style:{"white-space":"pre-wrap","word-wrap":"break-word"},value:_T("user","user_never_expire_list_desc"),"aria-label":_T("user","user_never_expire_list_desc")}]}};return Ext.apply(n,e),new SYNO.ux.GridPanel(n)},afterRender:function(e){this.callParent([e]),this.panel.getStore().load()},onStoreException:function(e){this.clearStatusBusy()},onBeforeLoad:function(e,t){this.setStatusBusy()},onLoad:function(e,t,i){this.clearStatusBusy()}}),Ext.define("SYNO.SDS.AdminCenter.User.ConfirmSetMustChgPwdDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){let t={width:580,minHeight:160,autoHeight:!0,resizable:!1,draggable:!1,header:!1,cls:"x-window-dlg",padding:"24px 30px 0px",elements:"body",items:[{xtype:"syno_displayfield",value:_T("user","confirm_set_must_chg_pwd")},{xtype:"syno_checkbox",checked:!1,htmlEncode:!1,boxLabel:`${_T("user","agree_set_must_chg_pwd")}`,listeners:{scope:this,check:function(e,t){this.getFooterToolbar().getComponent("apply").setDisabled(!t)}}}],fbar:{items:[{xtype:"syno_button",text:_T("common","skip"),handler:function(){this.btnHandler("no")},scope:this},{xtype:"syno_button",itemId:"apply",text:_T("common","yes"),btnStyle:"blue",disabled:!0,handler:function(){this.btnHandler("yes")},scope:this}]}};return Ext.apply(t,e)},btnHandler:function(e){this.callback&&this.callback.call(this.scope||window,e),this.close()}}),Ext.namespace("SYNO.SDS.AdminCenter.User"),SYNO.SDS.AdminCenter.User.applyPasswordPolicy=function(e,t){Object.keys(t).length>0?(t.strong_password_enable=!0,e.passwordPolicy=Ext.apply({},t)):(t.strong_password_enable=!1,e.passwordPolicy=Ext.apply({},t))},SYNO.SDS.AdminCenter.User.Error2Msg=function(e){return SYNO.API.getErrorString(e)},SYNO.SDS.AdminCenter.User.CreateVolumeMap=function(e){e.map={},Ext.each(e.volumes,function(t){e.map[t.volume_path]=t})},SYNO.SDS.AdminCenter.User.Alert=function(e,t,i){var s=_T("tree","leaf_user"),n=_T("common","error_system"),o=-1,a="";if(e){if("string"==typeof e)n=e;else if("number"==typeof e)o=e,n=SYNO.SDS.AdminCenter.User.Error2Msg(o);else if(e instanceof Array)for(var r=0;r",this.findField]}):"domain"===this.authType?(e.updateButton.grid=this,e.domainFilter.grid=this,{items:[this.btnEdit,e.homeButton,this.btnDelegate,e.updateButton,"->",{xtype:"syno_displayfield",itemId:"filterName",value:_T("helptoc","directory_service_domain")+_T("common","colon"),style:"margin-right: 8px"},e.domainFilter,this.findField]}):{items:[this.actionCreate=new SYNO.ux.SplitButton({text:_T("common","create"),handler:this.createHandler,scope:this,itemId:"create_users",menu:{items:[{text:_T("user","newuser_dlgtitle"),scope:this,handler:this.createHandler},{text:_T("user","user_import"),scope:this,handler:this._S("demo_mode")?function(){SYNO.SDS.AdminCenter.User.Alert.call(this.appWin,_JSLIBSTR("uicommon","error_demo"))}:this.launchUserFileDialog},{text:_T("user","copy_user"),itemId:"copy_user",scope:this,disabled:!0,handler:this.copyUserHandler}]}}),this.btnEdit,this.btnDel,this.btnDelegate,"->",this.findField]}},createStore:function(){var e={api:"SYNO.Core.User",method:"list",version:1,appWindow:this.appWin,baseParams:{type:this.authType,offset:0,limit:this.pageSize,additional:"domain"===this.authType?["email","fullname","description","expired","office","telephone","title","department","company"]:["email","description","expired","2fa_status"]},listeners:{exception:{scope:this,fn:this.onStoreException},beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:this.onLoad}},root:"users",totalProperty:"total",id:"name",fields:"domain"===this.authType?["name","fullname","description","email","expired","office","telephone","title","department","company"]:[{name:"name",sortType:"asNaturalUCString"},"description","email","expired","2fa_status"],remoteSort:!this.isLocal(),defaultSortable:!0,scope:this};return this.isLocal()&&(e.sortInfo={field:"name",direction:"asc"}),new SYNO.API.JsonStore(e)},createColumnModel:function(){var e=[{header:_T("user","user_account")+"",headerHtmlEncode:!1,dataIndex:"name",hideable:!1,width:200},{header:_T("domain","full_name"),dataIndex:"fullname",width:200,hidden:"domain"!==this.authType},{header:_T("user","user_email"),dataIndex:"email",width:200,hidden:"ldap"===this.authType},{id:"descr",header:_T("user","user_fullname"),dataIndex:"description",width:200,renderer:function(e,t){var i=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(i)+'"',i}},{header:_T("user","user_2fa_status"),dataIndex:"2fa_status",id:"disabled",width:150,scope:this,renderer:function(e){return!0===e?_T("user","user_2fa_enabled"):_T("user","user_2fa_disabled")}},{header:_T("user","user_acnt_status"),dataIndex:"expired",id:"disabled",width:150,scope:this,renderer:function(e){if("Must Change"===e)return''+_T("user","user_acnt_mustchange")+"";if("Password Expired"===e)return''+_T("user","user_pwd_expired")+"";if("Locked"===e)return''+_T("user","user_acnt_locked")+"";if("normal"==e)return _T("user","user_acnt_normal");if("now"==e)return''+_T("user","user_acnt_disabled")+"";if("lockout"==e)return''+_T("user","user_lockout")+"";if("expired"===e)return''+_T("user","user_acnt_expired")+"";var t=new Date;if(t.setHours(0,0,0,0),new Date(e)'+_T("user","user_acnt_expired")+"";if(e){var i=SYNO.SDS.DateTimeFormatter(Date.parseDate(e,"Y/n/j"),{type:"date"});return''+_T("user","user_acnt_expired_date")+i+""}return _T("user","user_acnt_unknow_status")}},{header:_T("user","user_telephone"),dataIndex:"telephone",width:150,hidden:!0},{header:_T("user","user_title"),dataIndex:"title",width:150,hidden:!0},{header:_T("user","user_department"),dataIndex:"department",width:150,hidden:!0},{header:_T("user","user_company"),dataIndex:"company",width:150,hidden:!0},{header:_T("user","user_office"),dataIndex:"office",width:150,hidden:!0}];return new Ext.grid.ColumnModel({defaults:{sortable:"ldap"!==this.authType},columns:e})},createBBar:function(){return this.isLocal()?new SYNO.ux.PageLessToolbar({store:this.module.ds,displayInfo:!0}):new SYNO.ux.PagingToolbar({store:this.module.ds,pageSize:this.pageSize,displayButtons:!0,displayInfo:!0})},onBeforeLoad:function(e,t){if("domain"===this.authType){var i=[];this.domainFilter.setValue(this.module.currDomain),this.store.baseParams.domain_name=this.module.currDomain?this.module.currDomain:"",this.getColumnModel().getColumnsBy(function(e){return e.hidden||i.push(e.dataIndex),!1}),t.params.searchFields=i}this.appWin.setStatusBusy()},onLoad:function(e,t,i){if(this.appWin.clearStatusBusy(),this.isFirstLoad=!1,this.setButtonState(),"local"===this.authType){if(this.focusUserName){var s=this.getStore().indexOfId(this.focusUserName);this.getSelectionModel().selectRow(s),function(){this.getView().focusRow(s)}.defer(100,this),this.focusUserName=null}this.module.launchUserDialogOnLoad&&(this.launchUserDialog(this.module.launchUserDialogOnLoad),this.module.launchUserDialogOnLoad="")}},onStoreException:function(e,t,i,s,n,o){var a=this.module.getPanel();if(SYNO.Debug("Store exception: options:",e,t,i,s,n,o),this.appWin.clearStatusBusy(),n.code){if(3105===n.code)return this.getEl().mask(_T("directory_service","warr_db_not_ready"),"syno-ux-mask-info"),void(this.updateButton.pollingId||this.updateButton.restartPolling());n.code,a.userTab&&"list"===s.params.action&&a.userTab.getTopToolbar().getComponent("search").getValue()&&a.userTab.getTopToolbar().getComponent("search").reset(),SYNO.SDS.AdminCenter.User.Alert.call(this.appWin,_T("user","failed_load_user"))}else this.appWin.setStatusError()},deselectUsers:function(e){for(var t=this.getSelectionModel(),i=0;i1?this.actionDel.enable():1!=t||this.selectReservedUser(e)?this.actionDel.disable():this.actionDel.enable()),1==t&&e.getSelections()[0].id.toUpperCase()!==SYNO.SDS.AdminCenter.User.CMS_USER.toUpperCase()?(this.actionEdit.enable(),"local"===this.authType&&this.actionCreate.menu.getComponent("copy_user").enable()):(this.actionEdit.disable(),"local"===this.authType&&this.actionCreate.menu.getComponent("copy_user").disable()),0'+_T("common","star")+"",maxlength:255,allowBlank:!1,labelHtmlEncode:!1,vtype:"iporhostname"},{xtype:"syno_textfield",name:"ldap_server_ip",fieldLabel:"ldap_server_ip",hidden:!0},{xtype:"syno_textfield",name:"dns",fieldLabel:_T("directory_service","dns_server")+' '+_T("common","star")+"",labelHtmlEncode:!1,maxlength:64,allowBlank:!1,emptyText:"IP LIST (EXAMPLE: 192.168.1.1,192.168.1.2)",maskRe:/[,.:0-9A-Fa-f]/,validator:SYNO.SDS.AdminCenter.DirectoryService.Util.MultiIPValidator},{xtype:"syno_displayfield",htmlEncode:!1,value:''+_T("common","star")+" "+_T("firewall","firewall_field_blank_alert")}]},onAfterLayout:function(){this.sendWebAPI({api:"SYNO.Core.Network",method:"get",version:1,callback:function(e,t){var i;t.dns_primary&&(i=t.dns_secondary?t.dns_primary+","+t.dns_secondary:t.dns_primary,this.getForm().findField("dns").setValue(i))},scope:this})},checkServerAddress:function(){var e=this.getForm().findField("server_type").getValue(),t=[],i={api:"SYNO.Core.DirectoryServiceCheck.Domain",method:"check_server_address",version:1,params:this.getForm().getValues(),scope:this},s={api:"SYNO.Core.DirectoryServiceCheck.LDAP",method:"check_server_address",version:1,params:this.getForm().getValues(),scope:this};"ldap"===e?t.push(s):"domain"===e?t.push(i):"auto"===e&&(t.push(i),t.push(s)),this.owner.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,mode:"parallel",params:t},scope:this,callback:function(e,t,i){var s,n=this.getForm().findField("server_type").getValue();if(this.owner.clearStatusBusy(),e){for(var o=0;o
    {[Ext.util.Format.htmlEncode(values.domain)]}
    '),forceSelection:!0,listeners:{select:this.onSelect}},e);this.callParent([t])},updateList:function(e){var t=[],i=!0;Ext.each(e,function(e){"object"==typeof e?(e[1]?t.push(e):t.push([_T("directory_service","domainou_list_all_items"),e[1],e[2]]),e[1]&&e[1]===this.getValue()&&(i=!1)):(t.push([e,e,e]),e===this.getValue()&&(i=!1))},this),this.getStore().loadData(t),i&&0!==t.length&&(this.setValue(t[0][1]||""),this.module.currDomain=t[0][1]||"")},onSelect:function(e,t){var i="",s=this.grid.getStore();this.grid&&e.data&&e.data.value&&(i=e.data.value),this.module.currDomain=i,s.baseParams.domain_name=this.module.currDomain,s.load({params:{offset:0}}),this.collapse()}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.UpdateButton",{extend:"SYNO.ux.Button",constructor:function(e){this.pollingId=void 0;var t=Ext.apply({text:_T("directory_service","update_all_domain"),scope:this,handler:this.updateAll},e);this.callParent([t])},updateAll:function(){this.grid&&(this.grid.getEl().mask(_T("directory_service","warr_db_not_ready"),"syno-ux-mask-info"),this.appWin.sendWebAPI({api:"SYNO.Core.Directory.Domain",method:"update_start",version:1,params:{domain_name:"@all"},scope:this,callback:this.startPolling}))},restartPolling:function(){if(!this.pollingId){var e=this,t=function(i,s){s>=i.length?e.updateAll():e.sendWebAPI({api:"SYNO.Core.Directory.Domain",method:"update_status",version:1,params:{task_id:i[s]},scope:e,callback:function(n,o,a,r){n&&"updating"===o.status?e.startPolling(!0,{task_id:a.task_id}):t(i,s+1)}})};this.appWin.pollList({task_id_prefix:"DomainUpdate",extra_group_tasks:["admin"],scope:this,callback:function(i,s,n,o){i&&(Ext.isArray(s.admin)?t(s.admin,0):null===s.admin&&e.updateAll())}})}},loadDomain:function(){this.sendWebAPI({api:"SYNO.Core.Directory.Domain",version:2,method:"get_domain_list",scope:this,callback:function(e,t,i){e?(this.panel?this.panel.loadDomainList(t.domain_list):this.grid&&this.grid.domainFilter.updateList(t.domain_list),this.grid.getStore().load()):this.grid.getStore().load()}})},startPolling:function(e,t,i,s){this.grid&&(e?this.pollingId=this.appWin.pollReg({webapi:{api:"SYNO.Core.Directory.Domain",method:"update_status",version:1,params:{task_id:t.task_id}},interval:5,immediate:!0,scope:this,status_callback:function(e,t,i,s){e&&"finish"===t.status&&(this.stopPolling(),this.grid.getEl().unmask(),this.loadDomain())}}):SYNO.Debug("Failed to start update."))},stopPolling:function(){this.pollingId&&(this.appWin.pollUnreg(this.pollingId),this.pollingId=void 0)}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.DCIP",{extend:"SYNO.ux.CompositeField",defaultMargins:"0 0 0 0",boxMinHeight:28,initEvents:function(){this.callParent(arguments),this.mon(this,"afterrender",this.addTip,this)},constructor:function(e){this.name=e.name;const t={name:this.name,fieldLabel:_T("network","domain_kdc_ip"),items:this.createItems(e)};this.callParent([t])},createItems:function(e){return this.superBoxSelect=new SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.SuperBoxSelect(Ext.apply({owner:this},e)),this.boxCmp=new Ext.BoxComponent({width:0,height:28}),[this.superBoxSelect,this.boxCmp]},addTip:function(){SYNO.ux.AddTip(this.boxCmp.getEl(),_T("domain","dcip_tip"))},updateLayout:function(){this.setHeight(this.superBoxSelect.getHeight()),this.findWindow().doLayout()},getValue:function(){return this.superBoxSelect.getValue()},setDCIPValue:function(e){this.superBoxSelect.setDCIPValue(e)}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.SuperBoxSelect",{extend:"SYNO.ux.SuperBoxSelect",initEvents:function(){this.callParent(arguments),this.mon(this,"afterrender",this.setDCIPValue,this),this.mon(this,"afterrender",function(){this.mon(this,"autosize",this.updateLayout,this)},this)},constructor:function(e){const t={maxlength:255,ctCls:"syno-domain-dcip-field",hideLabel:!0,style:"text-transform: uppercase;",store:new Ext.data.SimpleStore({fields:["host"]}),mode:"local",allowAddNewData:!0,addNewDataOnBlur:!0,renderFieldBtns:!1,htmlEncode:!0,displayField:"host",valueField:"host",maskRe:/[-.*:0-9A-Za-z]/,validator:SYNO.SDS.AdminCenter.DirectoryService.Util.DCIPValidator,listeners:{scope:this,newitem:function(e,t){this.addItem({host:t.toUpperCase()})}}};this.callParent([Ext.apply(t,e)])},setDCIPValue:function(e){let t=[],i=[];i=Ext.isString(e)?e.split(","):Ext.isArray(e)?e:this.dcipValue?this.dcipValue.split(","):[];for(const e of i)""!==e&&t.push({host:e});this.setValueEx(t),this.originalValue=this.getValue()},updateLayout:function(){this.oldHeight!==this.getHeight()&&(this.oldHeight=this.getHeight(),this.owner.updateLayout())}}),Ext.reg("syno_dcip_superboxselect",SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.DCIP),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.DirectoryWizard.DomainInfoStep",{extend:"SYNO.ux.FormPanel",LABEL_WIDTH:222,FIELDSET_WIDTH:300,ouCandidateData:[],constructor:function(e){var t=Ext.apply({headline:_T("directory_service","domain_info_title"),labelWidth:this.LABEL_WIDTH,fieldWidth:this.FIELDSET_WIDTH,cls:"syno-directory-wizard-body-auto-height",items:this.initComponents()},e);this.callParent([t])},initComponents:function(){var e=new SYNO.SDS.AdminCenter.DirectoryService.Domain.CheckItemsMenu({name:"register_nics",fieldLabel:_T("domain","dns_register_nic"),width:this.FIELDSET_WIDTH-10,allowBlank:!1,editable:!1,parentForm:this,owner:this});return[{xtype:"syno_displayfield",fieldLabel:_T("network","wnds_domain"),style:"text-transform: uppercase;",name:"server_address"},{xtype:"syno_displayfield",fieldLabel:_T("directory_service","dns_server"),name:"dns"},{xtype:"syno_combobox",name:"manage_mode",fieldLabel:_T("directory_service","domain_manage_mode"),mode:"local",forceSelection:!0,editable:!1,displayField:"display",valueField:"value",value:0,tpl:'
    {display}
    ',store:new Ext.data.JsonStore({fields:["display","value"],data:[{display:_T("directory_service","trust_domain_mode"),value:0},{display:_T("directory_service","domain_ou_mode"),value:1}]})},{xtype:"syno_textfield",name:"username",maxLength:64,labelHtmlEncode:!1,fieldLabel:`${_T("directory_service","domain_account")} ${_T("common","star")}`,value:"administrator",allowBlank:!1},{xtype:"syno_textfield",textType:"password",name:"password",maxLength:127,fieldLabel:_T("directory_service","join_password"),allowBlank:!0},{xtype:"syno_dcip_superboxselect",name:"dc_ips",width:this.FIELDSET_WIDTH},e,{xtype:"syno_checkbox",name:"enable_ou_select",value:!1,boxLabel:_T("directory_service","specify_ou")},{xtype:"syno_displayfield",htmlEncode:!1,value:`${_T("common","star")} ${_T("firewall","firewall_field_blank_alert")}`}]},sendOuWebapi:function(){this.ouCandidateData=[],this.dns=this.getForm().findField("dns").getValue(),this.domain_name=this.getForm().findField("server_address").getValue(),this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.Directory.Domain",version:1,method:"list_candidate_ou",params:{server:this.dns,username:this.getForm().findField("username").getValue(),password:this.getForm().findField("password").getValue(),fqdn_name:this.domain_name},encryption:["password"],scope:this,callback:function(e,t,i){this.owner.clearStatusBusy(),e?(Ext.each(t.ou_list,function(e,t){var i=e;""===e&&(i=_T("common","default"));var s=[i,e];this.ouCandidateData.push(s)},this),this.owner.goNext(this.nextId)):this.errorHandling(t)}})},errorHandling:function(e){var t=SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrorData(e),i=_T("common","commfail");return SYNO.API.Errors.core[t.code]&&(i=SYNO.API.Errors.core[t.code]),this.owner.getMsgBox().alert(_T("network","wnds_domain"),i),!0},activate:function(){var e=this.owner.serverSettingStep.getForm().getValues();this.getForm().setValues(e)},getNext:function(){return!!this.getForm().isValid()&&(this.enable_ou_select=this.getForm().findField("enable_ou_select").getValue(),this.enable_ou_select?this.sendOuWebapi():(this.owner.domainOUStep.getForm().findField("ou_specified").setValue(""),this.owner.goNext("domain_check_join")),!1)},getBack:function(){this.owner.setTitle(_T("directory_service","wizard_title")),this.owner.goBack("server_type")}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.DirectoryWizard.DomainOUStep",{extend:"SYNO.ux.FormPanel",LABEL_WIDTH:182,FIELDSET_WIDTH:300,initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("ou_specified").getEl(),_T("domain","ou_candidate_tip"))},this,{single:!0}),this.ou_condidate_store.on("load",function(){this.getForm().findField("ou_specified").setValue("")},this)},constructor:function(e){this.ou_condidate_store=new Ext.data.ArrayStore({fields:["display","value"],data:[]});var t=Ext.apply({headline:_T("directory_service","domain_ou_title"),items:[{xtype:"syno_combobox",name:"ou_specified",fieldLabel:_T("domain","specified_ou"),labelWidth:this.LABEL_WIDTH,width:this.FIELDSET_WIDTH,allowBlank:!1,forceSelection:!0,mode:"local",displayField:"display",valueField:"value",resizable:!0,editable:!0,tpl:'
    {display}
    ',store:this.ou_condidate_store}]},e);this.callParent([t])},activate:function(){var e=this.owner.domainInfoStep.ouCandidateData;this.ou_condidate_store.loadData(e,!1)}}),Ext.ns("SYNO.SDS.AdminCenter.DirectoryService.Util"),SYNO.SDS.AdminCenter.DirectoryService.Util.MultiIPValidator=function(e){if(!Ext.isString(e))return _JSLIBSTR("vtype","bad_ip");if(0===e.length)return!0;const t=e.split(/,+/);for(const e of t)if(!Ext.form.VTypes.ip(e))return _JSLIBSTR("vtype","bad_ip");return!0},SYNO.SDS.AdminCenter.DirectoryService.Util.DCIPValidator=function(e){return Ext.isString(e)?0===e.length||(!(!Ext.form.VTypes.ip(e)&&!Ext.form.VTypes.FQDN2(e))||_JSLIBSTR("vtype","bad_ip")):_JSLIBSTR("vtype","bad_ip")},SYNO.SDS.AdminCenter.DirectoryService.Util.DirectoryServiceDataGetCB=function(e,t,i){let s,n=_T("common","commfail");if(!0===t.isTimeout)return{error:n=_T("network","domain_join_err")};if(!0===t.has_fail&&!Ext.isEmpty(SYNO.API.GetKnownAPI("SYNO.Core.Directory.Domain"))&&!SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get_domain_list","code"))return s=SYNO.API.Response.GetFirstError(t),SYNO.API.Errors.core[s.code]&&(n=SYNO.API.Errors.core[s.code]),{error:n};let o={};return o.enable_domain=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get","enable_domain"),o.domain_list=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get_domain_list","domain_list"),o.enable_ldap=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.LDAP","get","enable_client"),o},SYNO.SDS.AdminCenter.DirectoryService.Util.GetFeasibilityMsgList=function(e){let t="";return Ext.each(e,function(e){t+=String.format("
  • {0}
  • ",SYNO.SDS.Utils.GetFeasibilityCheckMsg(e))}),String.format("
      {0}
    ",t)},Ext.define("SYNO.SDS.AdminCenter.DirectoryService.Util.ArrayReader",{extend:"Ext.data.JsonReader",constructor:function(e){this.createArrayElement=e.createArrayElement||null,this.callParent([e])},extractData:function(e,t){let i=[];return e.forEach(function(e,t,s){Ext.isFunction(this.createArrayElement)?i.push(this.createArrayElement(e)):i.push({item:e})},this),SYNO.SDS.AdminCenter.DirectoryService.Util.ArrayReader.superclass.extractData.call(this,i,t)}}),SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg=function(e){return SYNO.API.Errors.core[e]||_T("common","error_system")},Ext.define("SYNO.SDS.AdminCenter.DirectoryService.Util.HomeDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.panel=this.createFormPanel(e);const t=Ext.apply({title:_T("user","user_home_set"),width:620,autoHeight:!0,closeAction:"cancelHandler",resizable:!1,layout:"fit",items:this.panel,buttons:[{btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.cancelHandler},{btnStyle:"blue",text:_T("common","apply"),scope:this,handler:this.applyHandler}]},e);this.callParent([t]),this.mon(this,"afterlayout",this.loadForm,this,{single:!0})},loadForm:function(){this.findWindow().setStatusBusy(),this.panel.loadForm()},createFormPanel:function(e){this.userHomeFieldSet=new SYNO.SDS.AdminCenter.User.HomeFieldSet({authType:e.authType});const t={border:!1,trackResetOnLoad:!0,userHomeFieldSet:this.userHomeFieldSet,items:[this.userHomeFieldSet],processParams:function(e,t){return t=t.concat(this.userHomeFieldSet.processParams(e,t))},processReturnData:function(e,t,i){if(this.findWindow().clearStatusBusy(),t.has_fail){const e=this.checkError(t);if(e.hasError)return void this.findWindow().getMsgBox().alert(null,e.errMsg)}this.userHomeFieldSet.processReturnData(e,t,i)},onApiSuccess:function(e,t,i){t.has_fail=this.checkError(t).hasError,"set"!==e||t.has_fail?this.processReturnData(e,t,i):this.findWindow().close()},checkError:function(e){let t=!1,i=[];Ext.each(e.result,function(e){if(!e.success){if("SYNO.S2S.Server.Pair"===e.api&&(703===e.error.code||707===e.error.code))return!0;if("SYNO.Core.User.Home"===e.api&&"get"===e.method&&3113===e.error.code)return!0;e.error&&e.error.code&&i.push(e.error.code),t=!0}});const s=SYNO.API.Errors.core[i[0]]||_JSLIBSTR("uicommon","error_system");return{hasError:t,errMsg:s}}};return new SYNO.SDS.Utils.FormPanel(t)},applyHandler:function(){this.panel.getForm().isDirty()?this.userHomeFieldSet.applyHandler():this.close()},cancelHandler:function(){this.panel.getForm().isDirty()?this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),function(e){"yes"===e&&this.close()},this):this.close()}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.Util.HomeButton",{extend:"SYNO.ux.Button",constructor:function(e){const t=Ext.apply({text:_T("user","user_home_set"),scope:this,hidden:!_S("is_admin"),handler:this.launchHomeDialog},e);this.callParent([t])},launchHomeDialog:function(){new SYNO.SDS.AdminCenter.DirectoryService.Util.HomeDialog({owner:this.appWin,module:this.module,authType:this.authType}).open()}}),SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrorData=function(e){return Ext.isBoolean(e.has_fail)?SYNO.API.Response.GetFirstError(e):e.error?e.error:e},Ext.define("SYNO.SDS.AdminCenter.DirectoryService.LDAP.ProfileDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.store=new Ext.data.GroupingStore({reader:new Ext.data.JsonReader({root:"rules",fields:["category","attribute","target"]}),groupField:"category"}),this.store.loadData(e.data),this.panel=this.createPanel(this.store);var t=Ext.apply({title:_T("ldap","profile_title"),autoDestroy:!0,width:480,height:500,minWidth:480,minHeight:500,layout:"fit",items:[this.panel],closeAction:"onCancel",buttons:[{btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.onCancel},{btnStyle:"blue",text:_T("common","save"),scope:this,handler:this.onApply}]},e);this.callParent([t])},createPanel:function(e){var t=[{header:_T("ldap","profile_origin"),dataIndex:"attribute",sortable:!1},{header:_T("ldap","profile_target"),dataIndex:"target",sortable:!1,id:"target",editor:new SYNO.ux.TextField({}),renderer:"htmlEncode"},{header:_T("ldap","profile_map"),dataIndex:"category",sortable:!1,hidden:!0}];return new SYNO.ux.EditorGridPanel({clicksToEdit:1,autoExpandColumn:"target",enableHdMenu:!1,enableColumnMove:!1,store:e,columns:t,selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),listeners:{viewready:function(e){e.getView().updateScroller()}},view:new SYNO.ux.GroupingView({forceFit:!0,showGroupName:!1,enableGroupingMenu:!1})})},hasModification:function(){return 0!==this.store.getModifiedRecords().length},onCancel:function(){if(!this.hasModification())return this.close(),!0;this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),function(e){"yes"===e&&this.close()},this)},onApply:function(){if(!this.hasModification())return this.close(),!0;this.setStatusBusy();var e=[];this.store.each(function(t){e.push(t.data)},this),this.sendWebAPI({api:"SYNO.Core.Directory.LDAP.Profile",method:"set",version:1,params:{rules:e},callback:this.afterApplyDone,scope:this})},afterApplyDone:function(e,t,i){if(this.clearStatusBusy(),e)return this.applyCallback&&this.applyCallback.call(this.applyTarget||this,this.hasModification()),this.close(),!0;this.getMsgBox().alert(this.title,_T("error","save"))}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.DirectoryWizard.LDAPInfoStep",{extend:"SYNO.ux.FormPanel",LABEL_WIDTH:314,FIELDSET_WIDTH:172,initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("enable_idmap").getEl(),_T("ldap","idmap_support_tips")),this.enableGroup=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_client_certificate",[this.btnUploadCertificate]),SYNO.ux.AddTip(this.getForm().findField("enable_client_certificate").getEl(),_T("ldap","ldap_client_certificate_tips"))},this,{single:!0})},constructor:function(e){this.module=e.module;var t=Ext.apply({headline:_T("directory_service","ldap_info_title"),labelWidth:this.LABEL_WIDTH,fieldWidth:this.FIELDSET_WIDTH,items:this.initComponents()},e);this.callParent([t])},initComponents:function(){return[{xtype:"syno_textfield",name:"bind_dn",fieldLabel:_T("ldap","bind_account")+' '+_T("common","star")+"",labelHtmlEncode:!1,listeners:{change:function(e,t,i){-1!=t.search(",cn=nasAccount,cn=Syno,dc=")&&-1!=this.getForm().findField("base_dn").getValue().search(",dc=c2,dc=")?(this.getForm().findField("encryption").setValue("no"),this.getForm().findField("encryption").disable()):this.getForm().findField("encryption").enable()},scope:this},allowBlank:!1},{xtype:"syno_textfield",textType:"password",name:"bind_pw",fieldLabel:_T("user","user_passwd")+' '+_T("common","star")+"",labelHtmlEncode:!1,allowBlank:!1},{xtype:"syno_combobox",name:"encryption",fieldLabel:_T("ldap","security_type"),forceSelection:!0,editable:!1,displayField:"display",valueField:"value",value:"no",store:new Ext.data.JsonStore({fields:["display","value"],data:[{display:_T("ldap","no_ssl"),value:"no"},{display:_T("ldap","with_ssl"),value:"ssl"},{display:_T("ldap","with_tls"),value:"start_tls"}]})},{xtype:"syno_combobox",name:"base_dn",fieldLabel:_T("ldap","base_dn")+' '+_T("common","star")+"",labelHtmlEncode:!1,allowBlank:!1,editable:!0,forceSelection:!1,selectOnFocus:!1,displayField:"item",valueField:"item",listeners:{change:function(e,t,i){-1!=t.search(",dc=c2,dc=")&&-1!=this.getForm().findField("bind_dn").getValue().search(",cn=nasAccount,cn=Syno,dc=")?(this.getForm().findField("encryption").setValue("no"),this.getForm().findField("encryption").disable()):this.getForm().findField("encryption").enable()},scope:this},mode:"remote",store:new SYNO.API.Store({autoDestroy:!0,appWindow:this.findAppWindow(),api:"SYNO.Core.Directory.LDAP.BaseDN",method:"list",version:2,reader:new SYNO.SDS.AdminCenter.DirectoryService.Util.ArrayReader({root:"base_dn",fields:["item"]}),listeners:{exception:this.onLoadBaseDNException,beforeload:this.onBeforeLoadBaseDN,load:this.onLoadBaseDN,scope:this}}),validator:function(e){return e.trim()===e}},{xtype:"syno_compositefield",fieldLabel:_T("ldap","profile_title"),items:[{xtype:"syno_combobox",name:"profile",width:this.FIELDSET_WIDTH,mode:"remote",allowBlank:!1,editable:!1,value:"standard",valueNotFoundText:_T("ldap","profile_standard"),valueField:"value",displayField:"display",store:new SYNO.API.Store({autoDestroy:!0,appWindow:this.findAppWindow(),api:"SYNO.Core.Directory.LDAP.Profile",method:"list",version:1,reader:new SYNO.SDS.AdminCenter.DirectoryService.Util.ArrayReader({root:"profiles",fields:["value","display"],createArrayElement:function(e){return{value:e,display:_T("ldap","profile_"+e)||e}}},this)}),listeners:{select:{fn:function(){Ext.getCmp(this.btnProfileAdvance).enable()},single:!0},scope:this}},{xtype:"syno_button",synotype:"indent_no_label",id:this.btnProfileAdvance=Ext.id(),width:"auto",text:_T("ldap","profile_advance"),disabled:!0,scope:this,handler:this.onProfileBtnClick}]},{xtype:"syno_numberfield",name:"update_min",maxlength:5,value:1440,minValue:1,fieldLabel:_T("directory_service","domain_update_period")+" ("+_T("common","time_minutes")+")"},{xtype:"syno_checkbox",name:"enable_idmap",boxLabel:_T("ldap","idmap_support"),value:!1},{xtype:"syno_checkbox",boxLabel:_T("ldap","ldap_enable_client_certificate"),listeners:{scope:this,check:function(e,t,i){t&&this.findWindow().getMsgBox().alert(this.title,_T("ldap","ldap_client_certificate_note"))}},name:"enable_client_certificate"},{xtype:"syno_button",indent:1,id:this.btnUploadCertificate=Ext.id(),text:_T("ldap","ldap_upload_client_certificate"),scope:this,handler:this.uploadCertificateDialog},{xtype:"syno_displayfield",htmlEncode:!1,value:''+_T("common","star")+" "+_T("firewall","firewall_field_blank_alert")}]},uploadCertificateDialog:function(){new SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util.UploadCADialog({module:this.module,owner:this.module.appWin}).open()},onBeforeLoadBaseDN:function(e,t){t.params.server_address=this.owner.serverSettingStep.getForm().findField("ldap_server_ip").getValue(),t.params.encryption=this.getForm().findField("encryption").getValue(),this.owner.setStatusBusy()},onLoadBaseDNException:function(e,t,i,s,n,o){var a=this.getForm().findField("base_dn");void 0===n.code?this.owner.getMsgBox().alert(_T("ldap","base_dn"),_T("ldap_error","ldap_operations_error")):this.owner.getMsgBox().alert(_T("ldap","base_dn"),SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(n.code)),delete a.lastQuery,a.setValue(""),this.owner.clearStatusBusy()},onLoadBaseDN:function(){var e=this.getForm().findField("base_dn");this.owner.clearStatusBusy(),delete e.lastQuery},onProfileBtnClick:function(){this.sendWebAPI({api:"SYNO.Core.Directory.LDAP.Profile",method:"get",version:1,params:{name:this.getForm().findField("profile").getValue()},callback:this.afterLoadProfile,scope:this})},afterLoadProfile:function(e,t,i){e?new SYNO.SDS.AdminCenter.DirectoryService.LDAP.ProfileDialog({owner:this.owner,resizable:!1,closable:!0,data:t,applyCallback:this.resetProfile,applyTarget:this}).open():this.owner.getMsgBox().alert(this.title,SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(t.code))},resetProfile:function(e){var t=this.getForm();e&&t.setValues({profile:"customized"})},getNext:function(){return!!this.getForm().isValid()&&this.nextId},getBack:function(){this.owner.setTitle(_T("directory_service","wizard_title")),this.owner.goBack("server_type")}}),Ext.ns("SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.Utils"),SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.Utils={getIssueTitle:function(e,t=!1){const i=this.issueContent[e]||{};return(i[t?1:0]||i[0]||{}).title||_T("directory_service","issue_title_unknown_and_retry")},getComponent:function(e){let t=[];return e.forEach(e=>{t.push(this.components[e])}),t},getIssueContent:function(e,t=!1){let i={details:"",recAction:{}};const s=this.issueContent[e]||{},n=s[t?1:0]||s[0]||{};return i.details=n.details||_T("directory_service","details_unknown_and_retry"),i.recAction.items=this.getComponent(n.component||[]),i.recAction.description=n.action||_T("directory_service","action_unknown_and_retry"),i}},SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.Utils.issueContent={1000:[{title:_T("directory_service","issue_title_dns_resolve_fail"),details:_T("directory_service","details_dns_resolve_fail"),action:_T("directory_service","action_dns_resolve_fail"),component:["server_address","dns"]}],1003:[{title:_T("directory_service","issue_title_dns_no_ip_record"),details:_T("directory_service","details_dns_no_ip_record"),action:_T("directory_service","action_dns_no_ip_record"),component:["server_address","dns"]}],1004:[{title:_T("directory_service","issue_title_no_ns_record"),details:_T("directory_service","details_no_ns_record"),action:_T("directory_service","action_dns_resolve_fail"),component:["server_address","dns"]}],1005:[{title:_T("directory_service","issue_title_no_srv_record"),details:_T("directory_service","details_no_srv_record"),action:_T("directory_service","action_no_srv_record"),component:[]}],1006:[{title:_T("directory_service","issue_title_absent_srv_record"),details:_T("directory_service","details_absent_srv_record"),action:_T("directory_service","action_absent_srv_record"),component:[]}],1007:[{title:_T("directory_service","issue_title_srv_no_address_record"),details:_T("directory_service","details_srv_no_address_record"),action:_T("directory_service","action_srv_no_address_record"),component:[]}],1008:[{title:_T("directory_service","issue_title_dns_resolve_fail"),details:_T("directory_service","details_can_not_find_any_dc"),action:_T("directory_service","action_dns_resolve_fail"),component:["dns"]}],1009:[{title:_T("directory_service","issue_title_resolve_fqdn_fail"),details:_T("directory_service","details_resolve_fqdn_fail"),action:_T("directory_service","action_resolve_fqdn_fail"),component:["dc_ips"]},{title:_T("directory_service","issue_title_resolve_fqdns_fail"),details:_T("directory_service","details_resolve_fqdns_fail"),action:_T("directory_service","action_resolve_fqdns_fail"),component:["dc_ips"]}],1010:[{title:_T("directory_service","issue_title_single_port_invalid"),details:_T("directory_service","details_single_port_invalid"),action:_T("directory_service","action_single_port_invalid"),component:["dc_ips"]}],1011:[{title:_T("directory_service","issue_title_single_port_invalid"),details:_T("directory_service","details_single_port_invalid"),action:_T("directory_service","action_single_port_invalid"),component:["dc_ips"]},{title:_T("directory_service","issue_title_multiple_ports_invalid"),details:_T("directory_service","details_multiple_ports_invalid"),action:_T("directory_service","action_multiple_ports_invalid"),component:["dc_ips"]}],1012:[{title:_T("directory_service","issue_title_single_port_invalid"),details:_T("directory_service","details_single_port_invalid"),action:_T("directory_service","action_single_port_invalid"),component:["dc_ips"]}],1013:[{title:_T("directory_service","issue_title_single_port_invalid"),details:_T("directory_service","details_single_port_invalid"),action:_T("directory_service","action_single_port_invalid"),component:["dc_ips"]}],1014:[{title:_T("directory_service","issue_title_single_port_invalid"),details:_T("directory_service","details_single_port_invalid"),action:_T("directory_service","action_single_port_invalid"),component:["dc_ips"]}],1015:[{title:_T("directory_service","issue_title_single_port_invalid"),details:_T("directory_service","details_single_port_invalid"),action:_T("directory_service","action_single_port_invalid"),component:["dc_ips"]}],1016:[{title:_T("directory_service","issue_title_single_port_invalid"),details:_T("directory_service","details_single_port_invalid"),action:_T("directory_service","action_ldap_server_port_invalid"),component:[]}],1020:[{title:_T("directory_service","issue_title_inconsistent_mtu_value"),details:_T("directory_service","details_inconsistent_mtu_value"),action:_T("directory_service","action_inconsistent_mtu_value"),component:[]}],1021:[{title:_T("directory_service","issue_title_nas_ip_conflict"),details:_T("directory_service","details_nas_ip_conflict"),action:_T("directory_service","action_nas_ip_conflict"),component:[]}],1022:[{title:_T("directory_service","issue_title_domain_ip_conflict"),details:_T("directory_service","details_domain_ip_conflict"),action:_T("directory_service","action_domain_ip_conflict"),component:[]}],1023:[{title:_T("directory_service","issue_title_nas_hostname_conflict"),details:_T("directory_service","details_nas_hostname_conflict"),action:_T("directory_service","action_nas_hostname_conflict"),component:[]}],1024:[{title:_T("directory_service","issue_title_workgroup_conflict"),details:_T("directory_service","details_workgroup_conflict"),action:_T("directory_service","action_workgroup_conflict"),component:[]}],1030:[{title:_T("directory_service","issue_title_bad_auth_info"),details:_T("directory_service","details_bad_auth_info"),action:_T("directory_service","action_bad_auth_info"),component:["bind_dn","pwd"]}],1031:[{title:_T("directory_service","issue_title_domain_bad_auth_info"),details:_T("directory_service","details_domain_bad_auth_info"),action:_T("directory_service","action_domain_bad_auth_info"),component:["username","password"]}],1032:[{title:_T("directory_service","issue_title_account_lockout"),details:_T("directory_service","details_account_lockout"),action:_T("directory_service","action_account_lockout"),component:["username","password"]}],1033:[{title:_T("directory_service","issue_title_password_expired"),details:_T("directory_service","details_password_expired"),action:_T("directory_service","action_password_expired"),component:["username","password"]}],1034:[{title:_T("directory_service","issue_title_ntlm_service_disable"),details:_T("directory_service","details_ntlm_service_disable"),action:_T("directory_service","action_ntlm_service_disable"),component:[]}],1035:[{title:_T("directory_service","issue_title_ntlm_account_restriction"),details:_T("directory_service","details_ntlm_account_restriction"),action:_T("directory_service","action_ntlm_account_restriction"),component:[]}],1036:[{title:_T("directory_service","issue_title_kerberos_too_much_diff_time"),details:_T("directory_service","details_kerberos_too_much_diff_time"),action:_T("directory_service","action_kerberos_too_much_diff_time"),component:[]}],1037:[{title:_T("directory_service","issue_title_machine_logon_fail"),details:_T("directory_service","details_machine_logon_fail"),action:_T("directory_service","action_machine_logon_fail"),component:["dc_ips"]}],1040:[{title:_T("directory_service","issue_title_bad_user_profile"),details:_T("directory_service","details_bad_profile"),action:_T("directory_service","action_bad_profile"),component:["base_dn","profile_user_filter","profile_user_uid","profile_user_uid_number"]}],1041:[{title:_T("directory_service","issue_title_bad_group_profile"),details:_T("directory_service","details_bad_profile"),action:_T("directory_service","action_bad_profile"),component:["base_dn","profile_group_filter","profile_group_cn","profile_group_gid_number"]}],1042:[{title:_T("directory_service","issue_title_ldap_user_name_invalid"),details:_T("directory_service","details_ldap_user_name_empty"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1043:[{title:_T("directory_service","issue_title_ldap_user_name_duplicated"),details:_T("directory_service","details_ldap_user_name_duplicated"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1044:[{title:_T("directory_service","issue_title_ldap_user_id_invalid"),details:_T("directory_service","details_ldap_user_id_empty"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1045:[{title:_T("directory_service","issue_title_ldap_user_id_invalid"),details:_T("directory_service","details_ldap_user_id_bad_type"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1046:[{title:_T("directory_service","issue_title_ldap_user_id_duplicated"),details:_T("directory_service","details_ldap_user_id_duplicated"),action:_T("directory_service","action_ldap_user_duplicated_id_number")+"
    "+_T("directory_service","action_enable_setting"),component:["enable_idmap"]},{title:_T("directory_service","issue_title_ldap_user_id_duplicated"),details:_T("directory_service","details_ldap_user_id_duplicated"),action:_T("directory_service","action_ldap_user_duplicated_id_numbers")+"
    "+_T("directory_service","action_enable_setting"),component:["enable_idmap"]}],1047:[{title:_T("directory_service","issue_title_ldap_group_name_invalid"),details:_T("directory_service","details_ldap_group_name_empty"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1048:[{title:_T("directory_service","issue_title_ldap_group_name_duplicated"),details:_T("directory_service","details_ldap_group_name_duplicated"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1049:[{title:_T("directory_service","issue_title_ldap_group_id_invalid"),details:_T("directory_service","details_ldap_group_id_empty"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1050:[{title:_T("directory_service","issue_title_ldap_group_id_invalid"),details:_T("directory_service","details_ldap_group_id_bad_type"),action:_T("directory_service","action_ldap_bad_data"),component:[]}],1051:[{title:_T("directory_service","issue_title_ldap_group_id_duplicated"),details:_T("directory_service","details_ldap_group_id_duplicated"),action:_T("directory_service","action_ldap_group_duplicated_id_number")+"
    "+_T("directory_service","action_enable_setting"),component:["enable_idmap"]},{title:_T("directory_service","issue_title_ldap_group_id_duplicated"),details:_T("directory_service","details_ldap_group_id_duplicated"),action:_T("directory_service","action_ldap_group_duplicated_id_numbers")+"
    "+_T("directory_service","action_enable_setting"),component:["enable_idmap"]}],1052:[{title:_T("directory_service","issue_title_no_samba_schema"),details:_T("directory_service","details_ldap_dont_support_samba_schema"),action:_T("directory_service","action_enable_setting"),component:["enable_cifs_pam","enable_cifs_pam_note"]}],1053:[{title:_T("directory_service","issue_title_no_ntpassword"),details:_T("directory_service","details_ldap_user_lost_ntpassword"),action:_T("directory_service","action_add_ntpassword_or_enable_cifs_pam"),component:["enable_cifs_pam","enable_cifs_pam_note"]}],1054:[{title:_T("directory_service","issue_title_ldap_need_tls"),details:_T("directory_service","details_ldap_need_tls"),action:_T("directory_service","action_ldap_need_tls"),component:["encryption"]}],1071:[{title:_T("directory_service","issue_title_domain_machine_name_conflict"),details:_T("directory_service","details_domain_machine_name_conflict"),action:_T("directory_service","action_domain_machine_name_conflict"),component:[]}],1074:[{title:_T("directory_service","issue_title_duplicate_spn"),details:_T("directory_service","details_duplicate_spn"),action:_T("directory_service","action_duplicate_spn"),component:[]}],1075:[{title:_T("directory_service","issue_title_check_spn_fail"),details:_T("directory_service","details_check_spn_fail"),action:_T("directory_service","action_check_spn_fail"),component:[]}],1076:[{title:_T("directory_service","issue_title_check_account_flags_fail"),details:_T("directory_service","details_check_account_flags_fail"),action:_T("directory_service","action_check_account_flags_fail"),component:[]}],1077:[{title:_T("directory_service","issue_title_check_gpo_fail"),details:_T("directory_service","details_check_gpo_fail"),action:_T("directory_service","action_check_gpo_fail"),component:[]},{title:_T("directory_service","issue_title_check_gpo_fail"),details:_T("directory_service","details_check_gpo_fail"),action:_T("directory_service","action_check_gpo_fail"),component:[]}],1078:[{title:_T("directory_service","issue_title_machine_max_limit"),details:_T("directory_service","details_machine_max_limit"),action:_T("directory_service","action_machine_max_limit"),component:[]}],1080:[{title:_T("directory_service","issue_title_machine_account_conflict"),details:_T("directory_service","details_machine_account_conflict"),action:_T("directory_service","action_machine_account_conflict"),component:[]}],1081:[{title:_T("directory_service","issue_title_machine_password_not_sync"),details:_T("directory_service","details_machine_password_not_sync"),action:_T("directory_service","action_machine_password_not_sync"),component:[]},{title:_T("directory_service","issue_title_plural_machine_password_not_sync"),details:_T("directory_service","details_plural_machine_password_not_sync"),action:_T("directory_service","action_plural_machine_password_not_sync"),component:[]}],1082:[{title:_T("directory_service","issue_title_domain_time_not_sync"),details:_T("directory_service","details_domain_time_not_sync"),action:_T("directory_service","action_domain_time_not_sync"),component:[]}],1083:[{title:_T("directory_service","issue_title_domain_bad_auth_info"),details:_T("directory_service","details_domain_bad_auth_info"),action:_T("directory_service","action_domain_bad_auth_info"),component:["username","password"]}],1085:[{title:_T("directory_service","issue_title_check_winbind_fail"),details:_T("directory_service","details_check_winbind_fail"),action:_T("directory_service","action_check_winbind_fail"),component:[]}],1086:[{title:_T("directory_service","issue_title_check_winbind_fail"),details:_T("directory_service","details_check_winbind_fail"),action:_T("directory_service","action_check_winbind_fail"),component:[]}],1087:[{title:_T("directory_service","issue_title_check_winbind_fail"),details:_T("directory_service","details_check_winbind_fail"),action:_T("directory_service","action_check_winbind_fail"),component:[]}],1088:[{title:_T("directory_service","issue_title_check_winbind_fail"),details:_T("directory_service","details_check_winbind_fail"),action:_T("directory_service","action_check_winbind_fail"),component:[]}],1089:[{title:_T("directory_service","issue_title_check_winbind_fail"),details:_T("directory_service","details_check_winbind_fail"),action:_T("directory_service","action_check_winbind_fail"),component:[]}],1090:[{title:_T("directory_service","issue_title_smb_conf_bad_value"),details:_T("directory_service","details_smb_conf_bad_value"),action:_T("directory_service","action_smb_conf_bad_value"),component:[]},{title:_T("directory_service","issue_title_smb_conf_bad_value"),details:_T("directory_service","details_smb_conf_bad_values"),action:_T("directory_service","action_smb_conf_bad_values"),component:[]}],1120:[{title:_T("directory_service","issue_title_dc_no_response"),details:_T("directory_service","details_dc_no_response"),action:_T("directory_service","action_dc_no_response"),component:["dc_ips"]},{title:_T("directory_service","issue_title_dc_no_response"),details:_T("directory_service","details_dc_no_response"),action:_T("directory_service","action_dc_no_response"),component:["dc_ips"]}],1121:[{title:_T("directory_service","issue_title_can_not_find_any_dc"),details:_T("directory_service","details_can_not_find_any_dc"),action:_T("directory_service","action_can_not_find_any_dc"),component:[]}],1122:[{title:_T("directory_service","issue_title_dc_is_rodc"),details:_T("directory_service","details_dc_is_rodc"),action:_T("directory_service","action_dc_is_rodc"),component:["rwdc_fqdn_name"]}],1123:[{title:_T("directory_service","issue_title_insufficient_authorization"),details:_T("directory_service","details_insufficient_authorization"),action:_T("directory_service","action_insufficient_authorization"),component:["username","password"]}],1124:[{title:_T("network","domain_join_err"),details:_T("network","domain_join_err"),action:_T("network","domain_join_err"),component:[]}],1128:[{title:_T("directory_service","issue_title_smb_unsuccessful"),details:_T("directory_service","details_smb_unsuccessful"),action:_T("directory_service","action_smb_unsuccessful"),component:[]}],1301:[{title:_T("directory_service","issue_title_ntlm_account_not_exist"),details:_T("directory_service","details_ntlm_account_not_exist"),action:_T("directory_service","action_ntlm_account_not_exist"),component:[]}],1302:[{title:_T("directory_service","issue_title_domain_access_denied"),details:_T("directory_service","details_domain_access_denied_user"),action:_T("directory_service","action_domain_access_denied"),component:[]}],1303:[{title:_T("directory_service","issue_title_domain_access_denied"),details:_T("directory_service","details_domain_access_denied_machine"),action:_T("directory_service","action_domain_access_denied"),component:[]}],1304:[{title:_T("directory_service","issue_title_local_access_denied"),details:_T("directory_service","details_local_access_denied"),action:_T("directory_service","action_local_access_denied"),component:[]}],2000:[{title:_T("directory_service","issue_title_dns_resolve_fail"),details:_T("directory_service","details_dns_resolve_fail"),action:_T("directory_service","action_dns_resolve_fail"),component:["dns"]}],2001:[{title:_T("directory_service","issue_title_no_ns_record"),details:_T("directory_service","details_no_ns_record"),action:_T("directory_service","action_dns_resolve_fail"),component:["dns"]}],2002:[{title:_T("directory_service","issue_title_can_not_find_any_dc"),details:_T("directory_service","details_can_not_find_any_dc"),action:_T("directory_service","action_dns_resolve_fail"),component:["dns"]}],2100:[{title:_T("directory_service","issue_title_machine_logon_fail"),details:_T("directory_service","details_machine_logon_fail"),action:_T("directory_service","action_ad_machine_logon_fail"),component:[]}]},SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.Utils.components={server_address:{xtype:"syno_textfield",name:"server_address",fieldLabel:_T("directory_service","server_address"),maxlength:255,allowBlank:!1,vtype:"iporhostname"},dns:{xtype:"syno_textfield",name:"dns",fieldLabel:_T("directory_service","dns_server"),maxlength:64,allowBlank:!1,emptyText:"IP LIST (EXAMPLE: 192.168.1.1,192.168.1.2)",maskRe:/[,.:0-9A-Fa-f]/,validator:SYNO.SDS.AdminCenter.DirectoryService.Util.MultiIPValidator},username:{xtype:"syno_textfield",name:"username",maxLength:64,fieldLabel:_T("directory_service","domain_account"),allowBlank:!1},password:{xtype:"syno_textfield",textType:"password",name:"password",maxLength:127,fieldLabel:_T("directory_service","join_password"),allowBlank:!0},base_dn:{xtype:"syno_displayfield",fieldLabel:_T("ldap","base_dn"),name:"base_dn"},encryption:{xtype:"syno_combobox",name:"encryption",fieldLabel:_T("ldap","security_type"),forceSelection:!0,editable:!1,displayField:"display",valueField:"value",value:"start_tls",store:new Ext.data.JsonStore({fields:["display","value"],data:[{display:_T("ldap","with_ssl"),value:"ssl"},{display:_T("ldap","with_tls"),value:"start_tls"}]})},bind_dn:{xtype:"syno_textfield",name:"bind_dn",fieldLabel:_T("ldap","bind_account"),allowBlank:!1},pwd:{xtype:"syno_textfield",textType:"password",name:"bind_pw",fieldLabel:_T("user","user_passwd"),allowBlank:!1},profile_user_filter:{xtype:"syno_textfield",name:"profile_user_filter",fieldLabel:"filter",maxlength:255,emptyText:"objectClass=posixAccount"},profile_user_uid:{xtype:"syno_textfield",name:"profile_user_uid",fieldLabel:"uid",maxlength:255,emptyText:"uid"},profile_user_uid_number:{xtype:"syno_textfield",name:"profile_user_uid_number",fieldLabel:"uidNumber",maxlength:255,emptyText:"uidNumber"},profile_group_filter:{xtype:"syno_textfield",name:"profile_group_filter",fieldLabel:"filter",maxlength:255,emptyText:"objectClass=posixGroup"},profile_group_cn:{xtype:"syno_textfield",name:"profile_group_cn",fieldLabel:"cn",maxlength:255,emptyText:"cn"},profile_group_gid_number:{xtype:"syno_textfield",name:"profile_group_gid_number",fieldLabel:"uidNumber",maxlength:255,emptyText:"gidNumber"},enable_idmap:{xtype:"syno_checkbox",name:"enable_idmap",boxLabel:_T("ldap","idmap_support"),value:!1},enable_cifs_pam:{xtype:"syno_checkbox",name:"enable_cifs_pam",boxLabel:_T("ldap","smb_support_pam"),value:!1},enable_cifs_pam_note:{xtype:"syno_displayfield",hideLabel:!0,htmlEncode:!1,value:_T("ldap_error","ldap_smb2_enable_warning")+"
    "+_T("ldap_error","ldap_cifs_pam_enabled"),name:"enable_cifs_pam_note"},enable_client_cert:{xtype:"syno_checkbox",boxLabel:_T("ldap","ldap_enable_client_certificate"),listeners:{scope:this,check:function(e,t,i){t&&this.findWindow().getMsgBox().alert(this.title,_T("ldap","ldap_client_certificate_note"))}},name:"enable_client_certificate"},upload_client_cert:{xtype:"syno_button",indent:1,text:_T("ldap","ldap_upload_client_certificate"),scope:this,handler:function(){new SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util.UploadCADialog({module:this.module,owner:this.module.appWin}).open()}},rwdc_fqdn_name:{xtype:"syno_textfield",name:"rwdc_fqdn_name",style:"text-transform:uppercase;",fieldLabel:_T("domain","rwdc_ip"),vtype:"ip",maxlength:255},dc_ips:{xtype:"syno_dcip_superboxselect",name:"dc_ips",width:260}},Ext.define("SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBarStore",{extend:"Ext.data.JsonStore",constructor:function(e){const t=Ext.apply({autoDestroy:!0,fields:["status","categoryName","desc","issueList"]},e);this.callParent([t])}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.FixDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){if(this.Utils=SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.Utils,this.issue=e.issue,this.dialogContent=this.Utils.getIssueContent(this.issue.errCode,this.issue.isPlural),!this.dialogContent)return void this.getMsgBox().alert(this.issue.title,_T("common","error_system"));this.issueInfoEncoding(),this.detailPanel=this.createDetailPanel(),this.suggestionForm=this.createSuggestionForm(),this.innerPanel=new SYNO.ux.Panel({width:580,height:370,layout:{type:"vbox",align:"center"},items:[this.detailPanel,this.suggestionForm]});const t=Ext.apply({width:580,height:480,resizable:!1,shadow:!0,buttonAlign:"left",fbar:new Ext.Toolbar({cls:"x-statusbar",style:{"padding-left":"24px"},items:this.createButtons()}),items:this.innerPanel},e);this.callParent([t]),this.setValueToForm()},issueInfoEncoding:function(){Ext.iterate(this.issue.info,function(e,t){if(Ext.isArray(t)){let i=[];Ext.each(t,function(e){i.push(Ext.util.Format.htmlEncode(e))}),this.issue.info[e]=i}else this.issue.info[e]=Ext.util.Format.htmlEncode(t)},this)},createButtons:function(){const e=0===this.dialogContent.recAction.items.length?_T("directory_service","check_again"):_T("common","commit");return[{xtype:"syno_button",text:_T("directory_service","ignore_issue"),hidden:!this.issue.allowSkipIssue||0===this.issue.level,scope:this,handler:this.afterClickSkip},"->",{xtype:"syno_button",text:_T("common","close"),scope:this,handler:this.close},{xtype:"syno_button",btnStyle:"blue",text:e,hidden:this.issue.unknownError||!1,itemId:"apply",scope:this,handler:this.onSubmit}]},createDetailPanel:function(){const e=[{xtype:"label",name:"detail_title",text:_T("directory_service","details_title"),cls:"detail-panel-titles"},{xtype:"label",name:"detail_desc",cls:"detail-panel-desc",data:this.issue.info||{},tpl:new Ext.Template(this.dialogContent.details)}];return new SYNO.ux.Panel({width:540,cls:"fix-dialog-detail-panel",margins:{top:12,right:0,bottom:18,left:0},padding:"14px 20px 14px 20px",items:e})},createSuggestionForm:function(){const e=this.dialogContent.recAction;let t={};this.issue.info&&this.setupSuggestionTemplate(t);let i=[{xtype:"syno_displayfield",hideLabel:!0,data:t||{},tpl:new Ext.Template(e.description)}];i=i.concat(e.items);const s={title:_T("directory_service","recommended_action_title"),width:540,header:!0,border:!1,labelWidth:182,fieldWidth:260,trackResetOnLoad:!0,flex:1,items:i};return new SYNO.ux.FormPanel(s)},setupSuggestionTemplate:function(e){Ext.iterate(this.issue.info,function(t,i){Ext.isArray(i)?e[t]=this.transformArrayToHTML(i):e[t]=i},this)},transformArrayToHTML:function(e){let t="",i="";return e.forEach(function(e){t+="
  • "+e+"
  • "}),i='
      '+t+"
    "},setValueToForm:function(){let e=this.suggestionForm.getForm();const t=e.findField("dc_ips"),i=this.suggestionForm.getForm().getValues();e.setValues(this.testParams),t&&t.setDCIPValue(this.testParams.dc_ips),Ext.iterate(i,function(t,i){i&&e.findField(t).setValue(i)},this)},onSubmit:function(){const e=this.suggestionForm.getForm();if(!e.isValid())return!1;this.needRetestAll=!1;if((e=>{let t=!1;return e.items.each(e=>{if(e.isDirty()&&(t=!0,this.issue.forceRetestFieldList.find(t=>t===e.name)))return this.needRetestAll=!0,!1},this),t})(e)&&Ext.isFunction(this.issue.saveConfBeforeRetestFn)){const t=Ext.applyIf(e.getValues(),this.testParams);return this.setStatusBusy(),void this.issue.saveConfBeforeRetestFn(this,t,this.needRetestAll,this.retestIssue.bind(this))}this.retestIssue()},retestIssue:function(){Ext.apply(this.testParams,this.suggestionForm.getForm().getValues()),this.testParams.dc_ips&&Ext.isArray(this.testParams.dc_ips)&&(this.testParams.dc_ips=this.testParams.dc_ips.join(",")),this.needRetestAll&&(this.issue.retest="all"),this.applyCallback(this.issue),this.close()},afterClickSkip:function(){this.skipCallback(this.issue),this.close()}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBarView",{extend:"SYNO.ux.FleXcroll.DataView",disallowBack:!1,toggleAnimation:!0,constructor:function(e){if(!e.store)throw new Error("store is required to construct SYNO.SDS.AdminCenter.DirectoryService.StatusBarView");this.isDoingAnimation=!1;const t=Ext.apply({style:"margin: auto",tpl:this.createTpl(),store:e.store},e);this.callParent([t])},createTpl:function(){const e=this.createIssueBarTpl();return new Ext.XTemplate('','
    ','
    ','
    ','','
    ',"
    ",'','
    ',"
    ","
    ",'
    ','
    ',"{categoryName}","
    ",'
    ',"{desc}","
    ","
    ",'','
    ','
    ','
    ',"
    ","
    ","
    ","
    ",'','","","
    ","
    ",'
    ',{compiled:!0,isCompleted:function(e){return"success"===e||"warning"===e||"fail"===e}})},createIssueBarTpl:function(){return new Ext.XTemplate('
    ','
    ','
    ',"
    ","
    ",'
    ','
    ',"{title}","
    ","
    ",'
    ',"
    ","
    ")},appendFixBtn:function(e){e.forEach(function(e){e.btn=new SYNO.ux.Button({btnStyle:0===e.level?"red":"grey",text:_T("directory_service","fix"),disabled:!!e.skipped,renderTo:Ext.fly(e.id).child(".third-area"),handler:this.launchFixDialog.bind(this,e),scope:this})}.bind(this))},launchFixDialog:function(e,t,i){let s=Ext.fly(t.getId()).parent(".status-issue-bar").child(".issue-title");s&&(s.addClass("seen"),e.seen=!0);const n={owner:this.findWindow(),title:e.title,testParams:e.testParams,issue:e,applyCallback:e.applyCallback,skipCallback:e.skipCallback,saveConfBeforeRetestFn:e.saveConfBeforeRetestFn};new SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.FixDialog(n).open()},onClick:function(e,t,i){let s=Ext.fly(t).parent(".status-category-bar");s&&s.child(".item-toggle")&&(s=s.parent(".syno-directory-wizard-status-container"))&&(s.child(".item-toggle-expanded")?this.shrinkBar():this.expandBar())},isExpand:function(){const e=Ext.fly(this.getId());if(!e)return!1;const t=e.child(".syno-directory-wizard-status-container").child(".item-toggle");return!!t&&t.hasClass("item-toggle-expanded")},shrinkBar:function(e=!1){this.toggleHandler(!1,e)},expandBar:function(e=!1){this.toggleHandler(!0,e)},toggleHandler:function(e,t){const i=Ext.fly(this.getId()).child(".syno-directory-wizard-status-container"),s=i.child(".item-toggle");let n=i.child(".item-detail");n&&s&&!this.isDoingAnimation&&(s[e?"addClass":"removeClass"]("item-toggle-expanded"),n.setVisibilityMode(Ext.Element.DISPLAY),t||!this.toggleAnimation?(n[e?"show":"hide"](),this.updateFlexcroll()):(this.isDoingAnimation=!0,n[e?"slideIn":"slideOut"]("t",{duration:.25,callback:function(){this.isDoingAnimation=!1,this.updateFlexcroll()}.bind(this)})))},updateFlexcroll:function(){if(this.fleXcrollerOwner){this.fleXcrollerOwner.updateFleXcroll();const e=Ext.get(this.fleXcrollerOwner.getScrollTarget().id+"_scrollwrapper").child(".vscrollerbase");e&&!e.isVisible()&&this.setFleXcrollToTop()}},setFleXcrollToTop:function(){this.fleXcrollerOwner&&(this.fleXcrollerOwner.getScrollTarget().dom.fleXdata.scroller[1]=!0,this.fleXcrollerOwner.updateFleXcroll(!0))}}),Ext.ns("SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp"),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBarPanel",{extend:"SYNO.ux.Panel",testMode:"post",statusBarList:[],constructor:function(e){this.testMode="wizard"===e.testMode?"wizard":"post",this.statusBarList=this.initComponents(e);const t=Ext.apply({autoFlexcroll:!1,items:this.statusBarList,bodyStyle:"padding: 0"},e);this.callParent([t])},initComponents:function(e){let t=[],i={module:e.module,width:e.statusBarWidth,fleXcrollerOwner:e.fleXcrollerOwner||this,allowSkipIssue:!!this.isWizardTest(),stopWhenHasFail:!!this.isWizardTest(),forceExpanded:!!this.isWizardTest(),forceRetestFieldList:Ext.isArray(e.forceRetestFieldList)?e.forceRetestFieldList:[],saveConfBeforeRetestFn:e.saveConfBeforeRetestFn?e.saveConfBeforeRetestFn:this.saveConfBeforeRetestFn,categoryTestDoneCallback:this.doNextCategory.bind(this)};const s=e.testData;return Ext.each(s.categoryList,e=>{Ext.apply(i,{disallowBack:s.categoryStageList[e].disallowBack,categoryName:_T("directory_service","category_"+e),categoryStage:s.categoryStageList[e]}),t.push(new SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBar(i))}),t},isWizardTest:function(){return"wizard"===this.testMode},isAllTestDone:function(){return this.currentStatusBarIndex>=this.statusBarList.length},startTest:function(e){this.currentStatusBarIndex=-1,this.testParams=e,0!==this.findWindow().init_time&&(e.init_time=this.findWindow().init_time),this.doNextCategory()},doNextCategory:function(){this.currentStatusBarIndex++,this.isAllTestDone()?this.allTestDoneCallback&&this.allTestDoneCallback(this.testParams):this.statusBarList[this.currentStatusBarIndex].doCategoryTest()},resetAllStatusBars:function(){this.statusBarList.forEach(e=>{e.resetStatus()})}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBar",{extend:"SYNO.ux.Panel",STATUS_CHECKING:"checking",STATUS_SUCCESS:"success",STATUS_WARNING:"warning",STATUS_FAIL:"fail",loaderDelay:"0s",Utils:SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.Utils,allowSkipIssue:!0,stopWhenHasFail:!0,forceExpanded:!0,forceRetestFieldList:[],saveConfBeforeRetestFn:null,initEvents:function(){this.callParent(arguments),this.mon(this.store,"load",this.afterLoad,this)},constructor:function(e){this.completeDesc=e.categoryStage.completeDesc,this.stageList=e.categoryStage.stageList,this.testParams=e.testParams,this.stageWorkQueue=[],this.store=new SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBarStore,this.view=new SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBarView({fleXcrollerOwner:e.fleXcrollerOwner,store:this.store});for(let e=0;e{const t=e.split(","),i=parseFloat(t[0].substr(t[0].indexOf("(")+1)),s=parseFloat(t[1]);let n=Math.atan2(s,i)/(2*Math.PI);return n<0&&(n+=1),-n+"s"})(t)},afterLoad:function(){(()=>{let e=Ext.get(Ext.DomQuery.selectNode(String.format("#{0} .loader.checking",this.id)));e&&e.setStyle("animation-delay",this.loaderDelay)})(),this.statusData.status!==this.STATUS_WARNING&&this.statusData.status!==this.STATUS_FAIL||this.view.appendFixBtn(this.statusData.issueList),this.isExpand&&this.view.expandBar(!0),this.view.updateFlexcroll(),this.isIssueHandled()||this.statusData.status!==this.STATUS_WARNING&&this.statusData.status!==this.STATUS_FAIL||!this.forceExpanded||this.view.expandBar()},genCategoryStatus:function(){return 0===this.statusData.issueList.length?this.STATUS_SUCCESS:this.criticalIssueCount>0?this.STATUS_FAIL:this.STATUS_WARNING},genCategoryDesc:function(){return 0===this.stageWorkQueue.length?0===this.statusData.issueList.length?_T("directory_service",this.completeDesc)||_T("directory_service","all_pass"):1===this.statusData.issueList.length?1===this.criticalIssueCount?_T("directory_service","single_critical_issue_short"):_T("directory_service","single_minor_issue_short"):this.criticalIssueCount>0?String.format(_T("directory_service","multi_critical_issues_short"),this.criticalIssueCount):String.format(_T("directory_service","multi_minor_issues_short"),this.minorIssueCount):1===this.statusData.issueList.length?1===this.criticalIssueCount?_T("directory_service","single_critical_issue"):_T("directory_service","single_minor_issue"):this.criticalIssueCount>0?String.format(_T("directory_service","multi_critical_issues"),this.criticalIssueCount):String.format(_T("directory_service","multi_minor_issues"),this.minorIssueCount)},setBackBtnEnable:function(e){if(this.module&&this.module.backBtn){if(this.disallowBack)return void this.module.backBtn.disable();e?this.module.backBtn.enable():this.module.backBtn.disable()}},doCategoryTest:function(){this.testParams=this.ownerCt.testParams,this.resetStatus(),this.doStageTest()},doStageTest:function(){if(0!==this.needSkipStageCount)return this.needSkipStageCount--,this.stageWorkQueue.shift(),void this.doStageTest();if(this.setBackBtnEnable(!1),0!==this.stageWorkQueue.length)return void this.sendStageTest(this.stageWorkQueue.shift());this.webAPIRequest=null;let e="";e=0===this.statusData.issueList.length?this.STATUS_SUCCESS:0!==this.minorIssueCount&&0===this.criticalIssueCount?this.STATUS_WARNING:this.STATUS_FAIL,this.updateStatusBar({status:e,desc:this.genCategoryDesc()}),this.forceExpanded=!0,this.isRetestMode||(this.isRetestMode=!0,this.categoryTestDoneCallback())},sendStageTest:function(e){let t=JSON.parse(JSON.stringify(e));this.updateStatusBar({status:this.STATUS_CHECKING,desc:_T("directory_service",t.desc)||_T("directory_service","status_checking")}),this.view.shrinkBar(!0),t.testList.forEach(e=>{e.encryption=Ext.apply(e.encryption||[],["password"]),e.params=Ext.apply(e.params||{},this.testParams)}),this.currentStage=t,this.webAPIRequest=this.sendWebAPI({compound:{stopwhenerror:!1,mode:"parallel",params:t.testList},timeout:864e5,encryption:Ext.isString(this.testParams.password)?["password"]:[],callback:this.afterStageTest,scope:this})},checkProgressErrorCode:function(e){const t=e.error.code;let i="";if(1110===t)i=_T("directory_service","already_in_directory_service");else if(1111===t)i=_T("directory_service","join_process_is_running");else if(1112===t)i=_T("directory_service","join_process_exist");else if(1113===t)i=_T("directory_service","join_progress_not_exist");else{if(1114!==t)return!1;i=_T("directory_service","join_process_interrupt")}return e.error.errors&&e.error.errors.runner&&(i=i.replace(/{user}/g,e.error.errors.runner)),e.error.errors&&e.error.errors.client_ip&&(i=i.replace(/{IP}/g,e.error.errors.client_ip)),1112===t?this.findWindow().getMsgBox().confirm(this.title,i,function(e,t){"no"!==e?this.sendWebAPI({api:"SYNO.Core.DirectoryServiceCheck.Progress",method:"end_progress",version:1,scope:this,params:{force_remove:!0},callback:function(e,t,i){this.doCategoryTest()}}):this.findWindow().close()},this):this.findWindow().getMsgBox().alert(this.title,i,function(){this.findWindow().close()},this),!0},afterStageTest:function(e,t){if(!this.ownerCt)return;let i=!1;this.webAPIRequest=null;for(const[e,s]of t.result.entries()){if(s.success){this.applyDataToTestParams(s.data);continue}if(this.checkProgressErrorCode(s))return;const t=this.constructIssue(s,e);if(!t)return void this.showErrAlert(s);i=!0;let n=this.statusData.issueList.find(e=>t.errCode===e.errCode);if(!n){this.statusData.issueList.push(t),0===t.level?this.criticalIssueCount++:this.minorIssueCount++;continue}t.levele.stageNumber===t.stageNumber);o?o.testList.push(t.testItem):n.stageList=n.stageList.concat(t.stageList)}if(this.isIssueHandled()||!1===this.stopWhenHasFail)return this.needSkipStageCount=i&&Number(this.currentStage.skipStageWhenFailed)||0,void this.doStageTest();this.updateStatusBar({status:this.criticalIssueCount>0?this.STATUS_FAIL:this.STATUS_WARNING,desc:this.genCategoryDesc()}),this.setBackBtnEnable(!0)},applyDataToTestParams:function(e){Ext.apply(this.testParams,e||{}),0==this.findWindow().init_time&&e&&e.init_time&&0!==e.init_time&&(this.findWindow().init_time=e.init_time)},showErrAlert:function(e){this.cancelWebAPIRequest(),this.findWindow().getMsgBox().alert(this.title,_T("disk_info","disk_contact_syno"),function(){this.findWindow().inException=!0,this.findWindow().close()},this),SYNO.Debug(String.format("Webapi error. API: {0}, method: {1}, error code: {2}",e.api,e.method,e.error.code))},constructIssue:function(e,t){if(void 0===e.success)return;let i=!1;void 0===e.error.errors&&(e.error.errors={},i=!0),this.applyDataToTestParams(e.error.errors.data);const s=this.currentStage.testList[t],n={testItem:s,id:Ext.id(null,"issue-"),unknownError:i,errCode:e.error.code,level:e.error.errors.level||0,info:e.error.errors.info||{},isPlural:e.error.errors.isPlural,allowSkipIssue:this.allowSkipIssue,forceRetestFieldList:this.forceRetestFieldList,stageNumber:this.currentStage.stageNumber,retest:s.retest,testParams:this.testParams,title:new Ext.XTemplate(this.Utils.getIssueTitle(e.error.code,e.error.errors.isPlural)).apply(e.error.errors.info||{}),applyCallback:this.applyCallback.bind(this),skipCallback:this.skipCallback.bind(this),saveConfBeforeRetestFn:this.saveConfBeforeRetestFn};let o=Ext.applyIf({testList:[s]},this.currentStage);if(n.stageList=[o],Number(this.stageList[n.stageNumber].skipStageWhenFailed)>0)for(let e=n.stageNumber+1;et.id===e.id);-1!==t&&(this.statusData.issueList.splice(t,1),0===e.level?this.criticalIssueCount--:1===e.level&&this.minorIssueCount--),this.stopWhenHasFail?this.stageWorkQueue.splice(0,0,...e.stageList):this.stageWorkQueue=Ext.apply([],e.stageList),this.doStageTest()}},retestStage:function(e){this.cancelWebAPIRequest(),this.needSkipStageCount=0;let t=[];for(const i of this.statusData.issueList)i.stageNumber===e.stageNumber?(0===i.level?this.criticalIssueCount--:1===i.level&&this.minorIssueCount--,i.skipped&&this.skippedIssueCount--):t.push(i);this.statusData.issueList=t,this.stageWorkQueue.push(this.stageList[e.stageNumber]),this.doStageTest()},skipCallback:function(e){let t=this.statusData.issueList;for(let i=0;i${_T("common","learn_more")}`,t=String.format(_T("network","http_negotiate_iwa_info"),e);SYNO.ux.AddTip(this.getForm().findField("enable_http_negotiate").getEl(),t)},constructor:function(e){this.module=e.module,this.owner=e.owner,this.domainData=e.domainData;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){return Ext.apply({title:_T("network","wnds_domain"),trackResetOnLoad:!0,fieldWidth:this.FIELD_WIDTH,labelWidth:this.LABEL_WIDTH,items:this.configItems(e.domainData)},e)},load:function(){var e=this.getForm();this.setStatusBusy(),this.domainData&&(this.getForm().setValues(this.domainData),!0===this.domainData.enable_adserver&&(e.findField("kdc").disable(),this.findById(this.domainRejoinBtnId).disable()),this.selectDomainBtn.setDisabled(1===this.domainData.manage_mode)),this.sendWebAPI({api:"SYNO.Core.Directory.Domain.Schedule",method:"get",version:1,scope:this,callback:function(e,t){if(!e)return this.onSceduleTypeSelect(),void this.clearStatusBusy();this.getForm().setValues(t),this.updateScheduleLoadData(t),this.clearStatusBusy()}})},createUpdateComposite:function(){var e,t,i,s,n,o=[],a=[],r=[1,2,3,6,12];for(t=[[_T("time","ntpdate_daily"),0],[_T("time","ntpdate_weekly"),1],[_T("time","ntpdate_monthly"),2],[_T("service","service_disable"),3]],i=new Ext.data.ArrayStore({fields:["display","value"],data:t}),e=0;e<24;++e)o.push([String.leftPad(String(e),2,"0"),e]);for(s=new Ext.data.ArrayStore({fields:["display","value"],data:o}),e=0;e
    {display}
    ',listeners:{scope:this,select:function(e){const t=e.getValue();this.selectDomainBtn.setDisabled(1===t)}}},{xtype:"syno_compositefield",name:"button_container",style:"margin-buttom: 4px",items:[this.selectDomainBtn]},this.itemUpdateComposite,{xtype:"compositefield",fieldLabel:_T("network","enable_http_negotiate_dsm_7"),items:[{xtype:"syno_combobox",store:i,name:"enable_http_negotiate",style:"margin-buttom: 4px",displayField:"display",valueField:"value",width:120,triggerAction:"all",hidden:!1,mode:"local",editable:!1}]},{xtype:"syno_button",width:"auto",style:"margin-top: 5px",id:this.domainRejoinBtnId=Ext.id(),name:"rejoin",text:_T("domain","rejoin"),scope:this,handler:this.onDomainRejoinBtnClick}]},dailySet:function(){var e=this.getForm();e.findField("repeat_hour").setVisible(!0),e.findField("hour_label").setVisible(!1),e.findField("hour").setVisible(!1),e.findField("week_name").setVisible(!1),e.findField("week_name").getVisibilityEl().setVisible(!1),e.findField("date").setVisible(!1)},weeklySet:function(){var e=this.getForm();e.findField("repeat_hour").setVisible(!1),e.findField("hour_label").setVisible(!0),e.findField("hour").setVisible(!0),e.findField("week_name").setVisible(!0),e.findField("week_name").getVisibilityEl().setVisible(!0),e.findField("date").setVisible(!1)},monthlySet:function(){var e=this.getForm();e.findField("repeat_hour").setVisible(!1),e.findField("hour_label").setVisible(!0),e.findField("hour").setVisible(!0),e.findField("week_name").setVisible(!1),e.findField("week_name").getVisibilityEl().setVisible(!1),e.findField("date").setVisible(!0)},disableSet:function(){var e=this.getForm();e.findField("repeat_hour").setVisible(!1),e.findField("hour_label").setVisible(!1),e.findField("hour").setVisible(!1),e.findField("week_name").setVisible(!1),e.findField("week_name").getVisibilityEl().setVisible(!1),e.findField("date").setVisible(!1)},onSceduleTypeSelect:function(){var e=this.getForm().findField("schedule_type").getValue();return 0===e?this.dailySet():1===e?this.weeklySet():2===e?this.monthlySet():3===e&&this.disableSet(),this.doLayout(),!0},onDomainRejoinBtnClick:function(){new SYNO.SDS.AdminCenter.DirectoryService.RejoinDialog({module:this.module,owner:this.owner,domainEnable:!0}).open()},updateScheduleLoadData:function(e){var t,i=this.getForm(),s=3,n={};1===(t=(n=e).date_type)?(s=2,n.repeat_hour=1,n.week_name="0",n.date=Date.parseDate(n.date,"Y/n/j")):0===t&&n.repeat_hour?(s=0,n.hour=0,n.week_name="0",n.date=new Date):0===t?(s=1,n.repeat_hour=1,n.date=new Date):2===t&&(s=3),i.setValues(Ext.apply(n,{schedule_type:s})),this.onSceduleTypeSelect()},isScheduleDirty:function(){var e=!1,t=this.getForm();return this.itemUpdateComposite.items.forEach(function(i){t.findField(i.name).isDirty()&&(e=!0)}),e},getScheduleParams:function(){var e,t=this.getForm(),i={date_type:0,week_name:"0,1,2,3,4,5,6",date:new Date,hour:0,min:0,repeat_hour:0,last_work_hour:0};return this.isScheduleDirty()?(3==(e=t.findField("schedule_type").getValue())?i={date_type:2}:0===e?(i.date_type=0,i.repeat_hour=t.findField("repeat_hour").getValue(),i.week_name="0,1,2,3,4,5,6",i.hour=0,i.last_work_hour=23):1===e?(i.date_type=0,i.repeat_hour=0,i.week_name=t.findField("week_name").getValue(),i.hour=t.findField("hour").getValue(),i.last_work_hour=i.hour):2===e&&(i.date_type=1,i.repeat_hour=0,i.repeat=1,i.week_name="0,1,2,3,4,5,6",i.hour=t.findField("hour").getValue(),i.date=t.findField("date").getValue().format("Y/n/j"),i.last_work_hour=i.hour),i):null},isParamNeedCheck:function(){return this.getForm().findField("dns").isDirty()||this.getForm().findField("kdc").isDirty()},getApplyWebAPIs:function(e){var t,i=[];return e&&(i.push({api:"SYNO.Core.Directory.Domain.Conf",method:"set",version:2,params:e}),i.push({api:"SYNO.Core.Directory.SSO.IWA",method:"set",version:1,params:e})),this.isParamNeedCheck()&&i.push({api:"SYNO.Core.DirectoryServiceCheck.Common",method:"get_stages",version:1,params:{type:"domain_posttest"}}),(t=this.getScheduleParams())&&i.push({api:"SYNO.Core.Directory.Domain.Schedule",method:"set",version:1,params:t}),i}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.LDAPGeneralEdit",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.ldapData=e.ldapData,this.isProfileDirty=!1;var t=[{xtype:"syno_combobox",fieldLabel:_T("ldap","security_type"),forceSelection:!0,store:new Ext.data.JsonStore({fields:["display","value"],data:[{display:_T("ldap","no_ssl"),value:"no"},{display:_T("ldap","with_ssl"),value:"ssl"},{display:_T("ldap","with_tls"),value:"start_tls"}]}),width:200,name:"encryption",value:"no",editable:!1,valueField:"value",displayField:"display"},{xtype:"syno_combobox",fieldLabel:_T("ldap","base_dn"),allowBlank:!1,validator:function(e){return e.trim()===e},listeners:{change:function(e,t,i){-1!=t.search(",dc=c2,dc=")?(this.getForm().findField("encryption").setValue("no"),this.getForm().findField("encryption").disable()):this.getForm().findField("encryption").enable()},scope:this},name:"base_dn",store:new SYNO.API.Store({autoDestroy:!0,appWindow:e.module.owner,api:"SYNO.Core.Directory.LDAP.BaseDN",method:"list",version:2,reader:new SYNO.SDS.AdminCenter.DirectoryService.Util.ArrayReader({root:"base_dn",fields:["item"]}),listeners:{exception:this.onLoadBaseDNException,beforeload:this.onBeforeLoadBaseDN,load:this.onLoadBaseDN,scope:this}}),width:200,mode:"remote",forceSelection:!1,selectOnFocus:!1,editable:!0,valueField:"item",displayField:"item"},{xtype:"syno_compositefield",synotype:"indent",fieldLabel:_T("ldap","profile_title"),items:[{xtype:"syno_combobox",name:"profile",store:new SYNO.API.Store({autoDestroy:!0,appWindow:e.module.owner,api:"SYNO.Core.Directory.LDAP.Profile",method:"list",version:1,reader:new SYNO.SDS.AdminCenter.DirectoryService.Util.ArrayReader({root:"profiles",fields:["value","display"],createArrayElement:function(e){return{value:e,display:_T("ldap","profile_"+e)||e}}})}),width:200,mode:"remote",allowBlank:!1,editable:!1,valueNotFoundText:_T("ldap","profile_"+this.ldapData.profile),valueField:"value",displayField:"display"},{synotype:"indent_no_label",xtype:"syno_button",width:"auto",id:this.btnProfileAdvance=Ext.id(),text:_T("ldap","profile_advance"),scope:this,handler:this.onProfileBtnClick}]},{xtype:"syno_button",width:"auto",style:"margin-top: 5px",id:this.RejoinBtnId=Ext.id(),name:"rejoin",text:_T("ldap","rebind"),scope:this,handler:this.onRejoinBtnClick}],i=Ext.apply({trackResetOnLoad:!0,fieldWidth:218,labelWidth:215,items:t},e);this.callParent([i])},load:function(){this.ldapData&&(this.getForm().setValues(this.ldapData),-1!=this.getForm().findField("base_dn").getValue().search(",dc=c2,dc=")&&this.getForm().findField("encryption").disable())},onBeforeRequest:function(e){var t=this.getForm(),i=t.getValues();return t.isDirty()?t.isValid()?"start_tls"===i.encryption&&"domino"===i.profile?(this.module.panel.clearStatusBusy(),this.module.panel.setStatusError({text:_T("ldap","domino_not_support_tls"),clear:!0}),!1):(t.findField("profile").isDirty()&&(i.profile=t.findField("profile").getValue()),!1):(this.module.panel.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1):(this.module.panel.get("sso").isVisible()||this.module.panel.setStatusError({text:_T("error","nochange_subject"),clear:!0}),!1)},onBeforeLoadBaseDN:function(e,t){var i=this.getForm(),s=i.findField("base_dn");if(!this.ldapData.server_address)return s.store.removeAll(),this.module.panel.setStatusError({text:_T("ldap","set_host_first"),clear:!0}),delete s.lastQuery,!1;t.params.server_address=this.ldapData.server_address,t.params.encryption=i.findField("encryption").getValue(),this.module.panel.setStatusBusy()},onLoadBaseDNException:function(e,t,i,s,n,o){var a=this.getForm().findField("base_dn");void 0===n.code?this.module.appWin.getMsgBox().alert(_T("ldap","base_dn"),_T("ldap_error","ldap_operations_error")):this.module.appWin.getMsgBox().alert(_T("ldap","base_dn"),SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(n.code)),delete a.lastQuery,a.setValue(""),this.module.panel.clearStatusBusy()},onLoadBaseDN:function(){var e=this.getForm().findField("base_dn");this.module.panel.clearStatusBusy(),delete e.lastQuery},onProfileBtnClick:function(){this.sendWebAPI({api:"SYNO.Core.Directory.LDAP.Profile",method:"get",version:1,params:{name:this.getForm().findField("profile").getValue()},callback:this.afterLoadProfile,scope:this})},onRejoinBtnClick:function(){new SYNO.SDS.AdminCenter.DirectoryService.RejoinDialog({module:this.module,owner:this.owner,data:this.ldapData,domainEnable:!1}).open()},afterLoadProfile:function(e,t,i){e?new SYNO.SDS.AdminCenter.DirectoryService.LDAP.ProfileDialog({module:this.module,owner:this.module.appWin,data:t,applyCallback:this.resetProfile,applyTarget:this}).open():this.module.appWin.getMsgBox().alert(this.title,SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(t.code))},resetProfile:function(e){var t=this.getForm();this.isProfileDirty=e,e&&t.setValues({profile:"customized"})},isParamNeedCheck:function(){return this.getForm().findField("encryption").isDirty()||this.getForm().findField("base_dn").isDirty()||this.isProfileDirty},getApplyWebAPIs:function(e){var t=[];return t.push({api:"SYNO.Core.Directory.LDAP.Profile",method:"set",version:1,params:{name:e.profile}}),t.push({api:"SYNO.Core.Directory.LDAP",method:"set",version:2,params:e}),this.isParamNeedCheck()&&t.push({api:"SYNO.Core.DirectoryServiceCheck.Common",method:"get_stages",version:1,params:{type:"ldap_posttest"}}),t},getExtraInfo:function(e,t){var i=[{api:"SYNO.Core.Directory.LDAP.Profile",method:"get",version:1,params:{name:t.profile},scope:this},{api:"SYNO.Core.FileServ.SMB",method:"get",params:{},version:3,scope:this}];this.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:i},scope:this,callback:function(i,s,n){var o;this.clearStatusBusy(),i?(o=SYNO.API.Response.GetValByAPI(s,"SYNO.Core.Directory.LDAP.Profile","get"),t.profile_rules=o.rules,o=SYNO.API.Response.GetValByAPI(s,"SYNO.Core.FileServ.SMB","get"),t.SMBStatus=o.enable_samba,e(t)):this.findWindow().getMsgBox.alert(this.title,_T("common","error_system"))}})}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.LDAPAdvanceEdit",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.afterLoadData=!1,this.SMBStatus=!1;var t=[{xtype:"syno_numberfield",name:"update_min",maxlength:5,minValue:1,fieldLabel:_T("directory_service","domain_update_period")+" ("+_T("common","time_minutes")+")"},{xtype:"syno_combobox",name:"ldap_schema",fieldLabel:_T("ldap","group_member_attr"),displayField:"display",valueField:"value",listeners:{change:function(e,t,i){"rfc2307"===t?this.getForm().findField("expand_nested_groups").disable():this.getForm().findField("expand_nested_groups").enable()},scope:this},store:new Ext.data.ArrayStore({fields:["display","value"],data:[["memberOf","rfc2307bis"],["memberUid","rfc2307"]]})},{xtype:"syno_checkbox",boxLabel:_T("ldap","smb_support_pam"),listeners:{enable:function(e){this.is_syno_server&&e.disable()},check:function(e,t){this.afterLoadData&&e.isDirty()&&t&&this.sendWebAPI({api:"SYNO.Core.FileServ.SMB",method:"get",params:{},version:3,scope:this,callback:this.SMBStatusHandler})},scope:this},name:"enable_cifs_pam"},{xtype:"syno_checkbox",boxLabel:_T("ldap","idmap_support"),disabled:!0,listeners:{enable:function(e){this.getForm().findField("enable_client").originalValue&&e.disable()},scope:this},name:"enable_idmap"},{xtype:"syno_checkbox",boxLabel:_T("directory_service","expand_nested_groups"),name:"expand_nested_groups"},{xtype:"syno_numberfield",indent:1,name:"nested_group_level",maxlength:2,value:9,fieldLabel:_T("directory_service","nested_groups_level")},{xtype:"syno_checkbox",boxLabel:_T("ldap","ldap_enable_client_certificate"),listeners:{scope:this,check:function(e,t,i){t&&this.afterLoad&&this.getForm().findField("enable_client_certificate").isDirty()&&this.findWindow().getMsgBox().alert(this.title,_T("ldap","ldap_client_certificate_note"))}},name:"enable_client_certificate"},{xtype:"syno_button",indent:1,id:this.btnUploadCertificate=Ext.id(),text:_T("ldap","ldap_upload_client_certificate"),scope:this,handler:this.uploadCertificateDialog}],i=Ext.apply({trackResetOnLoad:!0,fieldWidth:218,labelWidth:215,items:t},e);this.callParent([i])},initEvents:function(){this.callParent(arguments),this.mon(this,"activate",function(){this.getKnownAPI("SYNO.Core.FileServ.SMB")?this.getForm().findField("enable_cifs_pam").enable():this.getForm().findField("enable_cifs_pam").disable(),this.getForm().findField("enable_cifs_pam").getValue()||this.getForm().findField("enable_cifs_pam").disable()}),this.mon(this,"afterlayout",function(){this.enableGroup=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_client_certificate",[this.btnUploadCertificate]),this.enableGroup2=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"expand_nested_groups",["nested_group_level"]),SYNO.ux.AddWhiteTipWithItem(Ext.getCmp(this.getForm().findField("enable_cifs_pam").getEl().id),{xtype:"syno_displayfield",htmlEncode:!1,value:String.format(_T("ldap","smb_support_pam_tips"),'',""),listeners:{afterrender:function(e){this.mon(Ext.get(this.cifs_pam_id),"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/file_directory_service_configuration.html"},!1)})},scope:this}}),SYNO.ux.AddTip(this.getForm().findField("enable_idmap").getEl(),_T("ldap","idmap_support_tips")),SYNO.ux.AddTip(this.getForm().findField("enable_client_certificate").getEl(),_T("ldap","ldap_client_certificate_tips")),SYNO.ux.AddWhiteTipWithItem(Ext.getCmp(this.getForm().findField("ldap_schema").getEl().id),{xtype:"syno_displayfield",htmlEncode:!1,value:_T("ldap","ldap_schema_tips")})},this,{single:!0}),this.sendWebAPI({api:"SYNO.Core.FileServ.SMB",method:"get",params:{},version:3,scope:this,callback:function(e,t){this.SMBStatus=t.enable_samba}})},SMBStatusHandler:function(e,t){if(e){var i=[];this.SMBStatus=t.enable_samba,this.SMBStatus&&i.push(_T("ldap_error","ldap_smb2_enable_warning")),i.push(_T("ldap_error","ldap_cifs_pam_enabled")),this.owner.getMsgBox().alert(_T("directory_service","directory_service_title"),i.join("
    "))}else this.SMBStatus=!1},load:function(){this.ldapData&&(this.getForm().setValues(this.ldapData),this.is_syno_server=this.ldapData.is_syno_server,this.afterLoadData=!0,"rfc2307"===this.getForm().findField("ldap_schema").getValue()&&this.getForm().findField("expand_nested_groups").disable()),this.afterLoad=!0},uploadCertificateDialog:function(){new SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util.UploadCADialog({module:this.module,owner:this.owner}).open()},afterBindWarning:function(){this.getForm().findField("enable_cifs_pam").getValue()&&(this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({api:"SYNO.Core.FileServ.SMB",method:"get",params:{},version:3,scope:this,callback:this.applyCIFSSetting}))},applyCIFSSetting:function(e,t){if(e){var i=[];i.push({api:"SYNO.Core.FileServ.SMB",method:"set",version:3,params:{enable_samba:t.enable_samba,smb_max_protocol:0,smb_min_protocol:0}}),i.push({api:"SYNO.Core.FileServ.ServiceDiscovery",method:"set",version:1,params:{enable_smb_time_machine:!1}}),this.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:i},scope:this,callback:this.afterApplyCIFSPam})}else{this.clearStatusBusy();var s=SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(t.code?t.code:2799);this.module.appWin.getMsgBox().alert(this.title,s)}},afterApplyCIFSPam:function(e,t,i,s){if(this.clearStatusBusy(),!e||t.has_fail){var n=SYNO.API.Response.GetFirstError(t),o=SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(n?n.code:2799);this.module.appWin.getMsgBox().alert(this.title,o)}},getApplyWebAPIs:function(e){var t=[];return e.enable_cifs_pam&&this.SMBStatus&&t.push({api:"SYNO.Core.FileServ.SMB",method:"set",version:3,params:{enable_samba:this.SMBStatus,smb_max_protocol:0,smb_min_protocol:0}},{api:"SYNO.Core.FileServ.ServiceDiscovery",method:"set",version:1,params:{enable_smb_time_machine:!1}}),t}}),Ext.ns("SYNO.SDS.AdminCenter.DirectoryService"),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.EditDialog",{extend:"SYNO.SDS.ModalWindow",generalPanel:null,advancePanel:null,constructor:function(e){this.module=e.module,this.owner=e.owner,this.panel=this.createTabPanel(e);var t={title:_T("common","alt_edit"),width:720,minWidth:720,height:480,layout:"fit",buttons:[{text:_T("common","cancel"),scope:this,handler:this.close},{text:_T("common","save"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.panel]};Ext.apply(t,e),this.callParent([t])},createTabPanel:function(e){var t;if(e.domainData)this.directoryType="domain",this.generalPanel=new SYNO.SDS.AdminCenter.DirectoryService.DomainGeneralEdit({title:_T("common","general"),module:this.module,owner:this,domainData:e.domainData,itemId:"domainGeneralEdit"}),this.advancePanel=new SYNO.SDS.SMBService.Domain.OptionsForm({title:_T("common","advanced"),module:this.module,owner:this,domainEnable:!0,is_dc:e.domainData.enable_adserver,itemId:"domainAdvancedEdit"});else{if(!e.ldapData)return this.directoryType="",null;this.directoryType="ldap",this.generalPanel=new SYNO.SDS.AdminCenter.DirectoryService.LDAPGeneralEdit({title:_T("common","general"),module:this.module,owner:this,ldapData:e.ldapData,itemId:"ldapGeneralEdit"}),this.advancePanel=new SYNO.SDS.AdminCenter.DirectoryService.LDAPAdvanceEdit({title:_T("common","advanced"),module:this.module,owner:this,ldapData:e.ldapData,itemId:"ldapAdvancedEdit"})}return t={activeTab:0,plain:!0,defaults:{height:310},useDefaultBtn:!1,items:[this.generalPanel,this.advancePanel]},new SYNO.SDS.Utils.TabPanel(t)},getDirtyField:function(e){var t=e.getForm(),i=t.getValues();return i.kdc&&Ext.isArray(i.kdc)&&(i.kdc=t.findField("kdc").getValue()),t.items.each(function(e){e.isDirty()||delete i[e.name]}),e.itemUpdateComposite&&e.itemUpdateComposite.items.forEach(function(e){delete i[e.name]}),0===Object.keys(i).length?null:i},onApply:function(){var e,t,i=[],s={};this.generalPanel.getForm().isValid()&&this.advancePanel.getForm().isValid()&&(this.isTabsDirty()?("domain"===this.directoryType?(e=this.getDirtyField(this.generalPanel),t=this.getDirtyField(this.advancePanel),e||t?(Ext.apply(s,e),Ext.apply(s,t)):s=null):"ldap"===this.directoryType&&(Ext.apply(s,this.generalPanel.getForm().getValues()),Ext.apply(s,this.advancePanel.getForm().getValues()),s.enable_idmap=this.advancePanel.getForm().findField("enable_idmap").getValue(),s.enable_cifs_pam=this.advancePanel.getForm().findField("enable_cifs_pam").getValue()),i=i.concat(this.generalPanel.getApplyWebAPIs(s)),this.advancePanel.getApplyWebAPIs&&(i=i.concat(this.advancePanel.getApplyWebAPIs(s))),0!==i.length?this.setApply(i,s):SYNO.Debug("have dirty but webapis empty. some setting wrong")):this.close())},setApply:function(e,t){this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({compound:{stopwhenerror:!1,params:e},encryption:["bind_pw"],scope:this,callback:function(e,i,s){var n=_T("common","commfail");if(!e||i.has_fail)return SYNO.Debug(i),this.clearStatusBusy(),void this.findAppWindow().getMsgBox().alert(this.title,n);if(this.module.panel.getComponent("directory").loadDirectoryService(),this.clearStatusBusy(),Ext.isFunction(this.generalPanel.isParamNeedCheck)&&this.generalPanel.isParamNeedCheck()){var o=SYNO.API.Response.GetValByAPI(i,"SYNO.Core.DirectoryServiceCheck.Common","get_stages");Ext.applyIf(t,this.domainData||this.ldapData||{}),Ext.isFunction(this.generalPanel.getExtraInfo)?this.generalPanel.getExtraInfo(this.launchPostTestDialog.bind(this,o),t):this.launchPostTestDialog(o,t)}this.doClose()}})},launchPostTestDialog:function(e,t){var i=this.domainData?"domain":this.ldapData?"ldap":null;new SYNO.SDS.AdminCenter.DirectoryService.PostTestDialog({module:this.module,owner:this.module.appWin,directoryType:i,testData:e,testParams:t}).open()},onClose:function(){return!1!==this.callParent(arguments)&&(!this.isTabsDirty()||(this.getMsgBox().confirm(_T("directory_service","directory_service_title"),_T("common","confirm_lostchange"),function(e){"yes"===e&&this.doClose()},this),!1))},isTabsDirty:function(){return!(!this.generalPanel||!this.generalPanel.isFormDirty())||!(!this.advancePanel||!this.advancePanel.isFormDirty())},onOpen:function(e){this.callParent(arguments),this.generalPanel&&this.generalPanel.load(),this.advancePanel&&this.advancePanel.load()}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.ConfirmRetestDlg",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){let t={width:480,minHeight:120,autoHeight:!0,resizable:!1,draggable:!1,header:!1,cls:"x-window-dlg",padding:"24px 30px 0",elements:"body",items:[{xtype:"syno_displayfield",hideLabel:!0,value:_T("directory_service","retest_confirm")},{itemId:"notShowAgain",xtype:"syno_checkbox",checked:!1,boxLabel:_T("directory_service","no_retest_confirm_again")}],fbar:{items:[{xtype:"syno_button",text:_T("common","cancel"),btnStyle:"default",handler:this.noHandler,scope:this},{xtype:"syno_button",text:_T("common","continue"),btnStyle:"blue",handler:this.yesHandler,scope:this}]}};return Ext.apply(t,e)},yesHandler:function(){const e=this.getComponent("notShowAgain").getValue();SYNO.SDS.UserSettings.setProperty("SYNO.SDS.AdminCenter.DirectoryService.PostTestDialog","hideConfirm",e),this.confirmCallback&&Ext.isFunction(this.confirmCallback.yes)&&this.confirmCallback.yes(),this.close()},noHandler:function(){this.confirmCallback&&Ext.isFunction(this.confirmCallback.no)&&this.confirmCallback.no(),this.close()}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.PostTestDialog",{extend:"SYNO.SDS.ModalWindow",initEvents:function(){this.callParent(arguments),this.mon(this,"beforeclose",this.onBeforeClosePostTest,this,{single:!0}),this.mon(this,"afterlayout",this.onAfterLayout,this,{single:!0})},constructor:function(e){this.module=e.module,this.owner=e.owner,this.statusBarPanel=this.createStatusBarPanel(e);var t={title:_T("directory_service","env_setting_test"),width:580,height:480,layout:"fit",resizable:!1,bodyStyle:{"padding-top":"12px"},buttons:[{text:_T("common","alt_close"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.close}],items:[this.statusBarPanel]};Ext.apply(t,e),this.callParent([t])},createStatusBarPanel:function(e){const t="domain"===e.directoryType?["dns","dc_ips"]:[];return new SYNO.SDS.AdminCenter.DirectoryService.StatusBarCmp.StatusBarPanel({module:this.module,forceExpanded:!1,statusBarWidth:490,testData:e.testData,testMode:"post",forceRetestFieldList:t,saveConfBeforeRetestFn:this.saveConfBeforeRetestFn.bind(this),allTestDoneCallback:this.allTestDoneCallback.bind(this)})},saveConfBeforeRetestFn:function(e,t,i,s){let n=[];"domain"===this.directoryType?(void 0!==t.dc_ips&&(Ext.isString(t.dc_ips)?t.kdc=t.dc_ips.toUpperCase():Ext.isArray(t.dc_ips)?t.kdc=t.dc_ips.join(",").toUpperCase():(SYNO.Debug("dc_ips is not string or array type."),t.kdc="")),n.push({api:"SYNO.Core.Directory.Domain.Conf",method:"set",version:2,params:t})):"ldap"===this.directoryType&&(n.push({api:"SYNO.Core.Directory.LDAP.Profile",method:"set",version:1,params:{name:t.profile}}),n.push({api:"SYNO.Core.Directory.LDAP",method:"set",version:2,params:t}));const o=()=>{this.sendWebAPI({compound:{stopwhenerror:!1,params:n},encryption:["bind_pw"],scope:this,callback:function(t,i,n){if(!t||i.has_fail)return SYNO.Debug("Failed to save config.",i),this.clearStatusBusy(),void e.getMsgBox().alert(null,_T("common","commfail"));s&&Ext.isFunction(s)&&s()}})},a=SYNO.SDS.UserSettings.getProperty("SYNO.SDS.AdminCenter.DirectoryService.PostTestDialog","hideConfirm");if(!i||a)o();else{const t={owner:this,confirmCallback:{yes:o,no:()=>{e.clearStatusBusy()}}};new SYNO.SDS.AdminCenter.DirectoryService.ConfirmRetestDlg(t).show()}},allTestDoneCallback:function(e){SYNO.Debug("All test done.",e),this.sendWebAPI({api:"SYNO.Core.DirectoryServiceCheck.Common",method:"set_last_test",version:1})},onBeforeClosePostTest:function(){const e=this.findAppWindow().activePage.getComponent("directory");return e&&e.loadDirectoryService(),!0},onAfterLayout:function(){SYNO.SDS.UserSettings.setProperty("SYNO.SDS.AdminCenter.DirectoryService.PostTestDialog","hideConfirm",!1),this.prepareParams()&&this.statusBarPanel.startTest(this.testParams)},prepareParams:function(){if(this.testParams.client_status&&delete this.testParams.client_status,"domain"===this.directoryType)this.settleDomainParams();else{if("ldap"!==this.directoryType)return this.getMsgBox().alert(this.title,_T("common","error_system"),function(){this.close()},this),!1;this.settleLDAPParams()}return!0},settleDomainParams:function(){this.testParams.domain_name&&(this.testParams.server_address=this.testParams.domain_name),this.testParams.kdc&&(this.testParams.dc_ips=this.testParams.kdc)},settleLDAPParams:function(){this.testParams.profile&&(this.testParams.name=this.testParams.profile),this.testParams.encryption&&("ssl"===this.testParams.encryption?this.testParams.port=636:this.testParams.port=389)}}),Ext.ns("SYNO.SDS.AdminCenter.DirectoryService"),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.DirectoryTab",{extend:"SYNO.ux.Panel",initEvents:function(){this.callParent(arguments),this.mon(this,"activate",this.onTabActivate)},constructor:function(e){var t;this.module=e.module,this.owner=e.owner,this.itemId=e.itemId,t=this.fillConfig(e),this.callParent([t]),this.loadDirectoryService()},fillConfig:function(e){var t={title:_T("directory_service","directory_service_title"),layout:"card",style:"padding-top: 0px",items:[]};return this.BeforeJoinForm=new SYNO.SDS.AdminCenter.DirectoryService.BeforeJoin({module:e.module,owner:e.owner,itemId:"BeforeJoin"}),this.AfterJoinForm=new SYNO.SDS.AdminCenter.DirectoryService.AfterJoin({module:e.module,owner:e.owner,itemId:"AfterJoin"}),t.items=[this.BeforeJoinForm,this.AfterJoinForm],t},onTabActivate:function(){var e=!1;this.owner.domainRunning?this.AfterJoinForm.domainData||(e=!0):this.owner.ldapRunning&&this.AfterJoinForm.ldapData||(e=!0),e&&this.loadDirectoryService()},dropData:function(){this.owner.domainRunning&&this.AfterJoinForm.setConnectionStatus("--"),this.AfterJoinForm.domainData=null,this.AfterJoinForm.ldapData=null},colorT:function(e,t){return String.format('{0}',e,t||"black")},loadDirectoryService:function(){var e=[{api:"SYNO.Core.DirectoryServiceCheck.Common",method:"get_last_test",version:1},{api:"SYNO.Core.Directory.LDAP",method:"get",version:2}];this.getKnownAPI("SYNO.Core.Directory.Domain")&&e.push({api:"SYNO.Core.Directory.Domain",method:"get",version:1,params:{get:{additional:!0}}}),_S("is_admin")&&(e=e.concat({api:"SYNO.Core.Directory.SSO.IWA",method:"get",version:1})),this.module.appWin.setStatusBusy(),this.AfterJoinForm.setConnectionStatus(this.colorT(_T("directory_service","status_checking"),"blue")),this.sendWebAPI({compound:{stopwhenerror:!1,params:e},scope:this,callback:this.processReturnData})},getLDAPConnectionStatus:function(e){var t,i;return!0===e.enable_client?(i=e.error||2799,t=this.colorT(SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(i),2702===i?"green":"red"),!0===e.is_syno_server&&(t+=" ("+_T("ldap","syno_server")+")"),2712===i&&(t=String.format(t,_T("ldap","base_dn")+" ("+e.base_dn+")"))):t=this.colorT(_T("common","disabled")),t},processReturnData:function(e,t,i){if(e){var s,n=!1,o=!1,a=this.AfterJoinForm.getComponent(this.AfterJoinForm.leaveBtnId),r=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get");Ext.apply(r,SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.SSO.IWA","get"));var l=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.LDAP","get"),d=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.DirectoryServiceCheck.Common","get_last_test");if(this.info_store_data=[],d){const e=new Date(Number(d.last_test_time));d.last_test_time=Number.isNaN(e.getTime())?"--":SYNO.SDS.DateTimeFormatter(e),Ext.apply(r,d),Ext.apply(l,d)}if(!r&&!l)return SYNO.Debug("Error"),this.owner.updateTabs(o,n),void this.module.appWin.clearStatusBusy();if(r&&(!0===r.enable_domain&&(n=!0,s={api:"SYNO.Core.Directory.Domain",method:"test_dc",version:1,scope:this,callback:this.processDomainConnectionStatus}),!0===r.enable_adserver?(a.disable(),a.setTooltip(_T("domain","warn_cant_leave_by_ad_mode"))):(a.enable(),a.setTooltip(""))),l&&!0===l.enable_client&&(o=!0),this.owner.updateTabs(o,n),o)l.client_status=this.getLDAPConnectionStatus(l),this.ldap_data=l,2702===(l.error||2799)?this.owner.setLdapUserGroupGrid(!0):this.owner.setLdapUserGroupGrid(!1);if(n){const e=0===r.manage_mode?_T("helptoc","directory_service_domain"):_T("directory_service","organizational_unit");if(this.owner.getComponent("domain_user").getTopToolbar().getComponent("filterName").setValue(e+_T("common","colon")),this.owner.getComponent("domain_group").getTopToolbar().getComponent("filterName").setValue(e+_T("common","colon")),this.AfterJoinForm.setData(r),a.setText(_T("directory_service","leave_domain")),"NT4"===r.domain_type){this.AfterJoinForm.getComponent(this.AfterJoinForm.testBtnId).disable();const e=_T("domain","nt4_not_support");this.AfterJoinForm.getComponent(this.AfterJoinForm.testBtnId).setTooltip(e),this.AfterJoinForm.setConnectionStatus(this.colorT(_T("domain","deprecated_nt4"),"red"))}}else o&&(this.AfterJoinForm.setData(l),a.setText(_T("directory_service","leave_ldap")));if(n||o){if(this.getLayout().setActiveItem(1),!_S("is_admin")){a.disable(),this.AfterJoinForm.getComponent(this.AfterJoinForm.editBtnId).disable(),this.AfterJoinForm.getComponent(this.AfterJoinForm.testBtnId).disable();const e=_T("directory_service","warn_delegate_user_cant_operate");a.setTooltip(e),this.AfterJoinForm.getComponent(this.AfterJoinForm.editBtnId).setTooltip(e),this.AfterJoinForm.getComponent(this.AfterJoinForm.testBtnId).setTooltip(e)}}else this.getLayout().setActiveItem(0);this.module.appWin.clearStatusBusy(),s&&this.sendWebAPI(s)}else this.module.appWin.clearStatusBusy()},processDomainConnectionStatus:function(e,t,i){if(this.AfterJoinForm&&this.AfterJoinForm.items&&0!==this.AfterJoinForm.items.length)return this.AfterJoinForm.domainData&&"NT4"===this.AfterJoinForm.domainData.domain_type?(this.AfterJoinForm.setConnectionStatus(this.colorT(_T("domain","deprecated_nt4"),"red")),void this.owner.setDomainUserGroupGrid(!1)):void(e&&(!0===t.test_join_success?(this.AfterJoinForm.setConnectionStatus(this.colorT(_T("network","status_connected"),"green")),this.owner.setDomainUserGroupGrid(!0)):(this.AfterJoinForm.setConnectionStatus(this.colorT(_T("network","error_testjoin"),"red")),this.owner.setDomainUserGroupGrid(!1))))}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.BeforeJoin",{extend:"SYNO.ux.Panel",constructor:function(e){var t;this.module=e.module,this.owner=e.owner,t=this.fillConfig(e),this.callParent([t])},fillConfig:function(e){var t={title:_T("directory_service","directory_service_title"),layout:{type:"vbox",align:"center",pack:"center"},items:[]};return t.items.push({xtype:"label",name:"empty_domain_icon",cls:"syno-empty-domain-icon"},{xtype:"label",name:"notice_join_directory",text:_T("directory_service","notice_join_directory"),cls:"syno-directory-empty-text",margins:"20 0"},{xtype:"syno_button",name:"join_button",text:_T("directory_service","join"),btnStyle:"blue",style:{paddingLeft:20,paddingRight:20},disabled:!this._S("is_admin"),scope:this,handler:this.launchDirectoryWizard}),Ext.apply(t,e),t},launchDirectoryWizard:function(){new SYNO.SDS.AdminCenter.DirectoryService.DirectoryWizard.Wizard({owner:this.module.appWin,module:this.module}).open()}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.AfterJoin",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t;this.module=e.module,this.owner=e.owner,this.data=e.data,t=this.fillConfig(e),this.callParent([t])},getItems:function(e,t){return[{xtype:"syno_button",width:"auto",id:this.leaveBtnId=Ext.id(),scope:this,handler:this.leaveHandler},{xtype:"syno_button",width:"auto",id:this.editBtnId=Ext.id(),text:_T("common","alt_edit"),scope:this,handler:this.editHandler},{xtype:"syno_button",width:"auto",id:this.testBtnId=Ext.id(),text:_T("directory_service","server_testing"),scope:this,handler:this.serverTestingHandler},{xtype:"syno_fieldset",title:_T("directory_service","basic_info"),collapsible:!1,items:[{xtype:"syno_displayfield",fieldLabel:_T("ldap","ldap_server"),hidden:!t,name:"server_address"},{xtype:"syno_displayfield",fieldLabel:_T("network","wnds_domain"),hidden:!e,name:"domain_name"},{xtype:"syno_displayfield",fieldLabel:_T("network","domain_type"),hidden:!e,name:"domain_type"},{xtype:"syno_displayfield",fieldLabel:_T("directory_service","dns_server"),name:"dns"},{xtype:"syno_displayfield",fieldLabel:_T("network","domain_kdc_ip"),hidden:!e,name:"kdc",style:{"word-wrap":"break-word"}},{xtype:"syno_displayfield",fieldLabel:_T("directory_service","domain_manage_mode"),hidden:!e,name:"manage_mode"},{xtype:"syno_displayfield",fieldLabel:_T("network","enable_http_negotiate_dsm_7"),hidden:!e,name:"enable_http_negotiate"},{xtype:"syno_displayfield",fieldLabel:_T("ldap","base_dn"),hidden:!t,name:"base_dn"},{xtype:"syno_displayfield",fieldLabel:_T("ldap","security_type"),hidden:!t,name:"encryption"},{xtype:"syno_displayfield",fieldLabel:_T("ldap","profile_title"),hidden:!t,name:"profile"},{xtype:"syno_displayfield",fieldLabel:_T("tunnel","tunnel_status"),name:"client_status",value:"--",htmlEncode:!1},{xtype:"syno_displayfield",fieldLabel:_T("directory_service","last_test_time"),name:"last_test_time",value:"--"}]}]},fillConfig:function(e){this.items=this.getItems(e.domainRunning,e.LDAPRunning);var t={items:this.items};return Ext.apply(t,e),t},leaveHandler:function(){new SYNO.SDS.AdminCenter.DirectoryService.LeaveDialog({module:this.module,owner:this.module.appWin,domainData:this.domainData,ldapData:this.ldapData}).open()},editHandler:function(){new SYNO.SDS.AdminCenter.DirectoryService.EditDialog({module:this.module,owner:this.module.appWin,domainData:this.domainData,ldapData:this.ldapData}).open()},serverTestingHandler:function(){var e,t,i;this.domainData?(i="domain",e="domain_posttest",t=this.domainData):this.ldapData&&(i="ldap",e="ldap_posttest",t=this.ldapData),this.findWindow().setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.DirectoryServiceCheck.Common",method:"get_stages",version:1,params:{type:e},callback:function(e,s,n){(this.findWindow().clearStatusBusy(),e)?new SYNO.SDS.AdminCenter.DirectoryService.PostTestDialog({module:this.module,owner:this.module.appWin,directoryType:i,testData:s,testParams:t}).open():this.findWindow().getMsgBox().alert(this.title,_T("common","error_system"))},scope:this})},setConnectionStatus:function(e){this.getForm().findField("client_status").setValue(e)},setData:function(e){var t,i,s,n,o=["domain_name","domain_type","dns","manage_mode","kdc","enable_http_negotiate"],a=["server_address","base_dn","encryption","profile"],r=Object.assign({},e,{enable_http_negotiate:e.enable_http_negotiate?_T("directory_service","enabled"):_T("common","disabled")});if((i=this.getForm()).setValues(r),e.advance_domain_conf&&e.advance_domain_conf.kdc&&(e.kdc=e.advance_domain_conf.kdc,i.findField("kdc").setValue(e.kdc.toUpperCase())),0===e.manage_mode?i.findField("manage_mode").setValue(_T("directory_service","trust_domain_mode")):1===e.manage_mode&&i.findField("manage_mode").setValue(_T("directory_service","domain_ou_mode")),e.encryption&&("no"===e.encryption?i.findField("encryption").setValue(_T("ldap","no_ssl")):"ssl"===e.encryption?i.findField("encryption").setValue(_T("ldap","with_ssl")):"start_tls"===e.encryption&&i.findField("encryption").setValue(_T("ldap","with_tls"))),e.profile&&i.findField("profile").setValue(_T("ldap","profile_"+e.profile)),e.enable_domain){this.domainData=e,this.ldapData=null,s=o,n=a;const t=i.findField("enable_http_negotiate").getEl();if(t){const e=`${_T("common","learn_more")}`,i=String.format(_T("network","http_negotiate_iwa_info"),e);SYNO.ux.AddTip(t,i)}}else{if(!e.enable_client)return;this.domainData=null,this.ldapData=e,s=a,n=o}for(t=0;t'+_T("common","star")+""},s=this.DEFAULT_FIELD_WIDTH;return[{xtype:"syno_textfield",width:s,name:"oidc_name",itemId:"oidc_name",fieldLabel:i(_T("common","name")),labelHtmlEncode:!1,allowBlank:!1,hidden:t,disabled:t,value:e?e.oidc_name:"",maxlength:512},{xtype:"syno_textfield",width:s,name:"oidc_wellknown",itemId:"oidc_wellknown",fieldLabel:i("Wellknown URL"),labelHtmlEncode:!1,allowBlank:!1,hidden:t,disabled:t,validator:this.ValidURL,value:e?e.oidc_wellknown:"",maxlength:2048},{xtype:"syno_textfield",width:s,name:"oidc_client_id",itemId:"oidc_client_id",fieldLabel:i(_T("sso","client_id")),labelHtmlEncode:!1,allowBlank:!1,hidden:t,disabled:t,value:e?e.oidc_client_id:"",maxlength:512},{xtype:"syno_textfield",width:s,name:"oidc_client_secret",itemId:"oidc_client_secret",textType:"password",fieldLabel:i(_T("sso","client_secret")),labelHtmlEncode:!1,allowBlank:!1,hidden:t,disabled:t,value:e?e.oidc_client_secret:"",maxlength:512},{xtype:"syno_textfield",width:s,name:"oidc_redirect_uri",itemId:"oidc_redirect_uri",fieldLabel:i(_T("sso","redirect_uri")),labelHtmlEncode:!1,allowBlank:!1,hidden:t,disabled:t,validator:this.ValidURL,value:e?e.oidc_redirect_uri:"",maxlength:2048},{xtype:"syno_textfield",width:s,name:"oidc_scope",itemId:"oidc_scope",fieldLabel:_T("sso","scope"),allowBlank:!0,hidden:t,disabled:t,value:e?e.oidc_scope:"",maxlength:512},{xtype:"syno_textfield",width:s,name:"oidc_user_claim",itemId:"oidc_user_claim",fieldLabel:i(_T("sso","user_claim")),labelHtmlEncode:!1,allowBlank:!1,hidden:t,disabled:t,value:e?e.oidc_user_claim:"",maxlength:512}]},hasModification:function(){return this.panel.getForm().isDirty()},onCancel:function(){this.hasModification()?this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),function(e){"leftCustom"===e?this.close():"yes"===e&&this.onApply()},this,{yes:_T("common","save"),cancel:!0,leftCustom:{text:_T("common","dont_save"),extraStyle:"syno-ux-button-dontsave"}}):this.close()},onApply:function(){if(!this.hasModification())return this.close(),!0;var e=this.panel.getForm();if(!e.isValid())return this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1;this.setStatusBusy();var t=null;switch(e.findField("sso_profile").getValue()){case"azure":t="SYNO.Core.Directory.Azure.SSO";break;case"websphere":t="SYNO.Core.Directory.WebSphere.SSO";break;case"oidc":t="SYNO.Core.Directory.OIDC.SSO"}null===t&&(this.clearStatusBusy(),this.close()),this.sendWebAPI({api:t,method:"set",version:1,params:e.getValues(),encryption:["azure_client_secret","websphere_client_secret","oidc_client_secret"],callback:this.afterApplyDone,scope:this})},afterApplyDone:function(e,t,i){if(this.clearStatusBusy(),e)return this.applyTarget.getForm().findField("sso_profile").setValue(this.panel.getForm().findField("sso_profile").getValue()),this.applyCallback&&this.applyCallback.call(this.applyTarget||this,this.hasModification()),this.close(),!0;this.getMsgBox().alert(this.title,_T("error","save"))},applyCallback:function(e){}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.SSOTab",{extend:"SYNO.SDS.Utils.FormPanel",DEFAULT_WIDTH:365,ValidURL:function(e){var t=e.replace(/https?:\/\/\[/i,"").replace(/\].*$/,"");return!1!==/^(https?):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:(?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9]))?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(e)||!1!==/((^https?):\/\/([a-z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*)(:(?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9]))?$/i.test(e)||!1!==Ext.form.VTypes.v6ipVal.test(t)||_T("error","error_bad_field")},getFieldSetSyno:function(){return[{xtype:"syno_checkbox",boxLabel:_T("sso","enable"),name:"enable_sso"},{fieldLabel:_T("sso","server"),xtype:"syno_textfield",name:"host",indent:1,allowBlank:!1,validator:this.ValidURL,listeners:{blur:function(){this.setValue(this.getValue().replace(/\/$/,""))}},emptyText:"http://nas.example.com:5000",width:this.DEFAULT_WIDTH},{xtype:"syno_textfield",fieldLabel:_T("sso","app_id"),name:"appid",indent:1,width:this.DEFAULT_WIDTH,allowBlank:!1},{xtype:"syno_checkbox",indent:1,boxLabel:_T("sso","sso_default_login"),name:"sso_default_login"},{xtype:"syno_displayfield",name:"sso_note_info_synosso",indent:1,htmlEncode:!1,value:''+_T("common","note")+""+_T("common","colon")+_T("sso","note_install_synosso")}]},getFieldSetOIDC:function(){return[{xtype:"syno_checkbox",boxLabel:_T("sso","oidc_enable"),listeners:{scope:this,check:function(e,t,i){t&&""!==this.getForm().findField("sso_profile").getValue()?this.infoBox.show():this.infoBox.hide(),this.doLayout()}},name:"sso_enable"},{xtype:"syno_textfield",fieldLabel:"sso_profile",name:"sso_profile",hideLabel:!0,hidden:!0},{xtype:"syno_button",width:"auto",indent:1,id:this.btnProfileAdvance=Ext.id(),text:_T("sso","sso_oidc_settings"),scope:this,handler:this.onProfileBtnClick},{xtype:"syno_displayfield",name:"sso_note_info_oidc",indent:1,htmlEncode:!1,value:''+_T("common","note")+""+_T("common","colon")+_T("sso","note_join_directory")},{xtype:"box",data:{},id:this.infoBoxId=Ext.id(),tpl:new Ext.XTemplate('
    '+_T("ldap","profile_title")+':{sso_profile:htmlEncode}
    '+_T("sso","azure_client_id")+':{sso_client_id:htmlEncode}
    '+_T("sso","token_endpoint")+':{sso_token_endpoint:htmlEncode}
    '+_T("sso","auth_endpoint")+':{sso_auth_endpoint:htmlEncode}
    '+_T("sso","redirect_uri")+':{sso_redirect_uri:htmlEncode}
    ',{sso_profile_label:Ext.id(),sso_profile:Ext.id(),sso_client_id_label:Ext.id(),sso_client_id:Ext.id(),sso_token_endpoint_label:Ext.id(),sso_token_endpoint:Ext.id(),sso_auth_endpoint_label:Ext.id(),sso_auth_endpoint:Ext.id(),sso_redirect_uri_label:Ext.id(),sso_redirect_uri:Ext.id()})}]},constructor:function(e){this.err_msg=null;var t=Ext.apply({title:_T("sso","title"),trackResetOnLoad:!0,hideMode:"offsets",items:[{xtype:"syno_displayfield",name:"sso_client_desc",htmlEncode:!1,value:_T("sso","sso_client_desc")}].concat(this.getFieldSetOIDC(),this.getFieldSetSyno())},e);this.callParent([t]),this.infoBox=Ext.getCmp(this.infoBoxId)},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("appid").getEl(),_T("sso","tip_app_id")),this.enableGroup=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_sso",["host","appid","sso_default_login"]),this.azureSSOGroup=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"sso_enable",["sso_profile",this.btnProfileAdvance])},this,{single:!0});var e=this.owner.buttons.find(function(e){return e.text&&e.text===_T("common","commit")});this.mon(e,"click",this.onApplyBtnClick,this)},onApplyBtnClick:function(){var e=this.getForm();if(e.isDirty())if(e.isValid()){var t=this.getForm().findField("sso_enable").getValue(),i=this.getForm().findField("sso_profile").getValue().trim();if(t&&""===i)this.module.appWin.getMsgBox().confirm(this.title,_T("sso","profile_confirm"),function(e){"yes"===e&&this.openProfileDialog(null,"")},this);else{this.isVisible()&&this.module.panel.setStatusBusy({text:_T("common","saving")});var s=[{api:"SYNO.Core.Directory.SSO",method:"set",version:1,params:e.getValues()},{api:"SYNO.Core.Directory.SSO.Profile",method:"set",version:1,params:e.getValues()},{api:"SYNO.Core.Directory.SSO",method:"get",version:1},{api:"SYNO.Core.Directory.SSO.Profile",method:"get",version:1}];this.sendWebAPI({compound:{params:s},scope:this,callback:this.afterApplyDone})}}else this.isVisible()&&this.module.panel.setStatusError({text:_T("common","forminvalid"),clear:!0});else this.module.panel.getActiveTab()===this&&this.module.panel.setStatusError({text:_T("error","nochange_subject"),clear:!0})},onBeforeRequest:function(e){return"set"!=e||""!==this.getForm().findField("sso_profile").getValue()},onChangeSSOProfile:function(e){var t=this.getForm().findField("sso_profile").getValue().trim();this.getSSOProfileInfo(t,this.setSSODisplayFields)},afterApplyDone:function(e,t,i){if(this.module.panel.clearStatusBusy(),e){return this.processReturnData(null,t,i),this.module.panel.setStatusOK(),void this.checkPossibleLoadJSError()}this.module.panel.setStatusError()},openProfileDialog:function(e,t){new SYNO.SDS.AdminCenter.DirectoryService.SSO.ProfileDialog({module:this.module,owner:this.module.appWin,data:e,profile:t,applyCallback:this.resetProfile,applyTarget:this}).open()},resetInfoBox:function(){this.getSSOProfileInfo(this.panel.getForm().findField("sso_profile").getValue(),this.setSSODisplayFields)},onProfileBtnClick:function(){var e=this.getForm().findField("sso_profile").getValue().trim();""===e?this.openProfileDialog(null,""):this.getSSOProfileInfo(e,this.afterLoadSSOProfile)},afterLoadSSOProfile:function(e,t,i){if(e){var s=this.getForm().findField("sso_profile").getValue().trim();if("azure"===s||"websphere"===s||"oidc"===s)new SYNO.SDS.AdminCenter.DirectoryService.SSO.ProfileDialog({module:this.module,owner:this.module.appWin,data:t,profile:s,applyCallback:this.resetProfile,applyTarget:this}).open()}else this.module.appWin.getMsgBox().alert(this.title,SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(t.code))},resetProfile:function(e){if(e){var t=this.getForm().findField("sso_profile").getValue().trim();this.getSSOProfileInfo(t,this.setSSODisplayFields)}},processParams:function(e,t){return t=(t=t.concat({api:"SYNO.Core.Directory.SSO",method:"get",version:1})).concat({api:"SYNO.Core.Directory.SSO.Profile",method:"get",version:1})},processReturnData:function(e,t,i){if(this.callParent(arguments),t.result){var s={api:"SYNO.Core.Directory.SSO",method:"get",version:1},n={api:"SYNO.Core.Directory.SSO.Profile",method:"get",version:1};Ext.each(t.result,function(e,t){!0===SYNO.ux.Utils.checkApiConsistency(s,e)?this.getForm().setValues(e.data):!0===SYNO.ux.Utils.checkApiConsistency(n,e)&&(this.getForm().setValues({sso_enable:e.data.sso_enable,sso_profile:e.data.sso_profile}),e.data.sso_enable?this.infoBox.show():this.infoBox.hide(),this.doLayout(),this.getSSOProfileInfo(e.data.sso_profile,this.setSSODisplayFields))},this)}},checkExit:function(){this.module.confirmLostChangeResolve&&this.module.confirmLostChangeResolve()},checkPossibleLoadJSError:function(){var e=this.form.findField("enable_sso").getValue(),t=null!==this.form.findField("host").getValue().match(/^https/);e?t?this.alert("",_T("sso","warn_invalid_cert")):this.sendWebAPI({api:"SYNO.Core.Web.DSM",method:"get",version:1,scope:this,callback:function(e,t,i){e&&t.enable_https?this.alert("",_T("sso","warn_insecure")):this.checkExit()}}):this.checkExit()},setSSODisplayFields:function(e,t,i){if(e){var s=this.getForm().findField("sso_profile").getValue().trim(),n={};switch(s){case"azure":n={sso_client_id:t.azure_client_id,sso_token_endpoint:t.azure_token_endpoint,sso_auth_endpoint:t.azure_authorization_endpoint,sso_redirect_uri:t.azure_redirect_uri};break;case"websphere":n={sso_client_id:t.websphere_client_id,sso_token_endpoint:t.websphere_token_endpoint,sso_auth_endpoint:t.websphere_authorization_endpoint,sso_redirect_uri:t.websphere_redirect_uri};break;case"oidc":n={sso_client_id:t.oidc_client_id,sso_token_endpoint:t.oidc_token_endpoint,sso_auth_endpoint:t.oidc_authorization_endpoint,sso_redirect_uri:t.oidc_redirect_uri}}this.infoBox.show(),this.infoBox.update({sso_profile:s,sso_client_id:n.sso_client_id,sso_token_endpoint:n.sso_token_endpoint,sso_auth_endpoint:n.sso_auth_endpoint,sso_redirect_uri:n.sso_redirect_uri}),this.doLayout()}else this.module.appWin.getMsgBox().alert(this.title,SYNO.SDS.AdminCenter.DirectoryService.Util.GetErrMsg(t.code))},alert:function(e,t){this.module.appWin.el.hasClass("active-win")&&this.module.appWin.getMsgBox().alert(e,t,function(){this.checkExit()},this)},getSSOProfileRender:function(){return new SYNO.SDS.AdminCenter.DirectoryService.Util.ArrayReader({root:"profiles",fields:["value","display"],createArrayElement:function(e){return{value:e,display:_T("sso","profile_"+e)||e}}})},getSSOProfileInfo:function(e,t){var i=null;switch(e){case"azure":i="SYNO.Core.Directory.Azure.SSO";break;case"websphere":i="SYNO.Core.Directory.WebSphere.SSO";break;case"oidc":i="SYNO.Core.Directory.OIDC.SSO"}null!==i&&this.sendWebAPI({api:i,method:"get",version:1,callback:t,scope:this})}}),Ext.ns("SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util"),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util.UpdateButton",{extend:"SYNO.ux.Button",constructor:function(e){var t=Ext.apply({text:_T("ldap","update_ldap_data"),scope:this,handler:this.refresh},e);this.callParent([t])},startPolling:function(){Ext.isDefined(this.pollingId)||(this.pollingId=this.pollReg({interval:5,immediate:!0,scope:this,webapi:{api:"SYNO.Core.Directory.LDAP.Refresh",method:"get_status",version:1},status_callback:function(e,t,i){t.ready?(!0===this.need_reload&&this.grid.getStore().reload(),this.need_reload=!1,this.setText(_T("ldap","update_ldap_data")),this.enable()):(this.need_reload=!0,this.setText(_T("update","updating")),this.disable())}}))},stopPolling:function(){Ext.isDefined(this.pollingId)&&(this.pollUnreg(this.pollingId),delete this.pollingId,delete this.need_reload)},refresh:function(){this.disable(),this.setText(_T("update","updating")),this.need_reload=!0,this.sendWebAPI({api:"SYNO.Core.Directory.LDAP.Refresh",method:"start",version:1,callback:function(e,t,i,s){e||this.enable()},scope:this})}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util.UploadCADialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.module=e.module,this.panel=this.createPanel();var t={title:_T("ldap","ldap_upload_client_certificate_title"),layout:"fit",width:600,height:230,buttons:[{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.close},{xtype:"syno_button",btnStyle:"blue",text:_T("ldap","upload"),itemId:"apply",scope:this,disabled:!0,handler:this.onSubmit}],items:[this.panel]};Ext.apply(t,e),this.callParent([t]),this.defineBehaviors()},createPanel:function(){var e={border:!1,webapi:{api:"SYNO.Core.Directory.LDAP",version:1,methods:{set:"upload_certificate"}},fileUpload:!0,items:[{xtype:"syno_filebutton",fieldLabel:_T("service","service_ssl_crt"),name:"filename_crt",listeners:{scope:this,change:this.onImportFilePathChanged},value:""},{xtype:"syno_filebutton",fieldLabel:_T("service","service_ssl_key"),name:"filename_key",listeners:{scope:this,change:this.onImportFilePathChanged},value:""}]};return new SYNO.SDS.Utils.FormPanel(e)},defineBehaviors:function(){this.mon(this.panel.getForm(),"actioncomplete",this.onFormSuccess,this),this.mon(this.panel.getForm(),"actionfailed",this.onFormFailed,this),this.btnUpload=this.getFooterToolbar().getComponent("apply")},onImportFilePathChanged:function(e,t){""!==this.panel.getForm().findField("filename_crt").getValue()&&""!==this.panel.getForm().findField("filename_key").getValue()&&this.btnUpload.enable()},onFormSuccess:function(e,t){this.clearStatusBusy(),t.result.success&&this.close()},onFormFailed:function(e,t){this.clearStatusBusy(),this.getMsgBox().alert(_T("user","user_upload"),"upload file failed")},onSubmit:function(){this.setStatusBusy(),this.panel.getForm().doAction("apply")}}),Ext.ns("SYNO.SDS.AdminCenter.DirectoryService"),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.owner=e.appWin,this.appWin=e.appWin,this.callParent([e]),this.panel=new SYNO.SDS.AdminCenter.DirectoryService.TabPanel({module:this})},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"domain":case"ldap":return"AdminCenter/file_directory_service_join.html";case"domain_user":case"domain_group":case"ldap_user":case"ldap_group":return"AdminCenter/file_directory_service_user_group.html";case"sso":return"AdminCenter/file_directory_service_sso.html";default:return"AdminCenter/file_directory_service_desc.html"}},getPanel:function(){return this.panel},setActivateParams:function(e){e&&e.tab&&this.panel.setActiveTab(e.tab)},activate:function(e){this.panel.resetAllForm(),this.setActivateParams(e),this.panel.loadAllForm()},deactivate:function(){var e=this.panel.getComponent("sso");return(!e||!e.getForm().isDirty())&&(this.panel.getComponent("directory").dropData(),this.panel.getEl().unmask(),!0)},confirmLostChangeSave:function(){return new Promise(function(e,t){this.confirmLostChangeResolve=e,this.panel.getComponent("sso").onApplyBtnClick()}.bind(this))}}),Ext.define("SYNO.SDS.AdminCenter.DirectoryService.TabPanel",{extend:"SYNO.SDS.Utils.TabPanel",initEvents:function(){this.callParent(arguments),this.mon(this.getComponent("domain_user"),"activate",function(){this.getComponent("domain_user").activate()},this),this.mon(this.getComponent("ldap_user"),"activate",function(){this.getComponent("ldap_user").activate()},this)},constructor:function(e){var t;this.domainRunning=!1,this.ldapRunning=!1,this.module=e.module,t=Ext.apply({activeTab:0,items:[]},e),this.callParent([t])},initComponent:function(){this.items.push(new SYNO.SDS.AdminCenter.DirectoryService.DirectoryTab({module:this.module,owner:this,itemId:"directory"})),"yes"===this.module.owner._D("supportdomain","no")&&this.items.push(new SYNO.SDS.AdminCenter.User.UserListGrid({title:_T("directory_service","domain_user_tab"),appWin:this.module.owner,owner:this.module.owner,module:this.module,itemId:"domain_user",disabled:!0,authType:"domain",homeButton:new SYNO.SDS.AdminCenter.DirectoryService.Util.HomeButton({module:this.module,appWin:this.module.owner,authType:"domain"}),updateButton:new SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.UpdateButton({module:this.module,appWin:this.module.owner,panel:this}),domainFilter:new SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.Filter({module:this.module})}),new SYNO.SDS.AdminCenter.Group.GridPanel({title:_T("directory_service","domain_group_tab"),module:this.module,itemId:"domain_group",disabled:!0,authType:"domain",updateButton:new SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.UpdateButton({module:this.module,appWin:this.module.owner,panel:this}),domainFilter:new SYNO.SDS.AdminCenter.DirectoryService.Domain.Util.Filter({module:this.module})})),this.items.push(new SYNO.SDS.AdminCenter.User.UserListGrid({title:_T("directory_service","ldap_user_tab"),appWin:this.module.owner,owner:this.module.owner,module:this.module,itemId:"ldap_user",disabled:!0,authType:"ldap",homeButton:new SYNO.SDS.AdminCenter.DirectoryService.Util.HomeButton({module:this.module,appWin:this.module.owner,authType:"ldap"}),updateButton:new SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util.UpdateButton({appWin:this.module.owner})}),new SYNO.SDS.AdminCenter.Group.GridPanel({title:_T("directory_service","ldap_group_tab"),module:this.module,itemId:"ldap_group",disabled:!0,authType:"ldap",updateButton:new SYNO.SDS.AdminCenter.DirectoryService.LDAP.Util.UpdateButton({appWin:this.module.owner})}));var e=this.module.owner.openConfig.dsm_version;_S("is_admin")&&"5.0"!==e&&"5.1"!==e&&this.items.push(new SYNO.SDS.AdminCenter.DirectoryService.SSOTab({module:this.module,owner:this,itemId:"sso"})),this.callParent(arguments)},loadDomainList:function(e){0!==e.length&&(this.getComponent("domain_user").domainFilter.updateList(e),this.getComponent("domain_group").domainFilter.updateList(e))},loadAllForm:function(){this.hideTabStripItem("ldap_user"),this.hideTabStripItem("ldap_group"),this.hideTabStripItem("domain_user"),this.hideTabStripItem("domain_group"),this.callParent([{timeout:36e4}])},processParams:function(e,t){return t=this.callParent(arguments),Ext.isEmpty(this.getKnownAPI("SYNO.Core.Directory.Domain"))?t.filter(function(e){return!e.api.startsWith("SYNO.Core.Directory.Domain")}):_S("is_admin")?(Ext.isEmpty(this.getKnownAPI("SYNO.GlusterfsMgmt.Service"))||(t=t.concat([{api:"SYNO.GlusterfsMgmt.Service",method:"get",version:1}])),t):t},processReturnData:function(e,t,i){var s=SYNO.SDS.AdminCenter.DirectoryService.Util.DirectoryServiceDataGetCB(e,t,i);s.error?this.module.appWin.getMsgBox().alert(this.title,s.error):this.callParent(arguments)},setDomainUserGroupGrid:function(e){if(e)return this.getComponent("domain_user").enable(),void this.getComponent("domain_group").enable();this.getComponent("domain_user").disable(),this.getComponent("domain_group").disable()},setLdapUserGroupGrid:function(e){if(e)return this.getComponent("ldap_user").enable(),void this.getComponent("ldap_group").enable();this.getComponent("ldap_user").disable(),this.getComponent("ldap_group").disable()},onApiFailure:function(e,t){t.isTimeout?this.getEl().mask(_T("error","error_timeout"),"syno-ux-mask-info"):this.getEl().mask(_T("error","error_error_system"),"syno-ux-mask-info")},updateTabs:function(e,t){this.ldapRunning=e,this.domainRunning=t,this.hideTabStripItem("ldap_user"),this.hideTabStripItem("ldap_group"),this.hideTabStripItem("domain_user"),this.hideTabStripItem("domain_group");var i=this.getComponent("ldap_user"),s=this.getComponent("ldap_group"),n=this.getComponent("domain_user"),o=this.getComponent("domain_group");i.disable(),s.disable(),n.disable(),o.disable(),e&&(this.unhideTabStripItem("ldap_user"),this.unhideTabStripItem("ldap_group")),"yes"===this.module.owner._D("supportdomain","no")&&t&&(this.unhideTabStripItem("domain_user"),this.unhideTabStripItem("domain_group"))},checkDomainEnable:function(){return"yes"===this.module.owner._D("supportdomain","no")&&!(!this.domainRunning&&!this.getComponent("domain").getForm().findField("enable_domain").getValue())},checkLDAPEnable:function(){return!(!this.ldapRunning&&!this.getComponent("ldap").getForm().findField("enable_client").getValue())}}),Ext.define("SYNO.SDS.AdminCenter.WebAPIUtils",{getReqCompoundParam:function(e,t,i){var s=[];e instanceof Array?s=e:s.append(e);for(var n=0;n"+String.format(_T("routerconf","routerconf_goto_module"),i);n.getMsgBox().confirm(_T("tree","leaf_routerconf"),o,function(e){"yes"===e&&SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:t,tab:s}),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.closeOrFireFailEvent.call(this,!0)},this)}else SYNO.Debug("app is undefined")}.bind(this);this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding",version:1,method:"detect_pre_check",callback:function(i,s,n){s&&!s.is_avahi_alive?t(String.format(_T("routerconf","avahi_is_not_alive"),_T("controlpanel","leaf_file_services"),_T("common","advanced")),"SYNO.SDS.AdminCenter.FileService.Main",_T("common","advanced"),"adv"):e()},scope:this})}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PublicAccess.WelcomeStep",{extend:"SYNO.SDS.Wizard.WelcomeStep",constructor:function(e){if(!e.owner)throw Error("DescStep constructor failed");var t=this.createConfig(e);t=Ext.apply(t,{headline:_T("routerconf","detect_router_desc_title"),description:_T("routerconf","routerconf_setup_router")}),this.callParent([t])},createConfig:function(e){var t=new Ext.XTemplate('
    ','
      ','',"
    • {item}
    • ","
      ","
    ","
    "),i=e.gateway?e.gateway:"",s=e.ifname?e.ifname:"",n=''+_T("common","note")+_T("common","colon")+" ";return Ext.apply({items:[{xtype:"syno_displayfield",value:_T("routerconf","detect_router_desc")},{xtype:"syno_displayfield",value:_T("tcpip","tcpip_gateway")+_T("common","colon")+''+i+" ("+s+")",htmlEncode:!1},{htmlEncode:!1,xtype:"syno_displayfield",tpl:t,data:function(){var e=[],t=[_T("routerconf","check_network_interface_enabled"),_T("routerconf","check_gateway_setting"),_T("routerconf","check_connect_to_wan"),_T("routerconf","check_dns_setting"),_T("routerconf","check_lan2wan_gateway_hops"),_T("routerconf","detect_router")];return Ext.each(t,function(t){e.push({item:t})},this),e}()},{htmlEncode:!1,xtype:"syno_displayfield",value:n+_T("routerconf","detect_router_not_stop_warn")}]},e)}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.EmptyStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){if(!e.owner)throw Error("EmptyStep constructor failed");this.owner=e.owner,this.hasDetected=!1,this.detectResult={},this.obj=null,this.hasWarning=!1,this.hasError=!1,this.hasNote=!1;var t=this.configForm({module:this.owner,headline:_T("routerconf","detect_router"),description:_T("routerconf","routerconf_setup_router")},e);Ext.apply(t,e),this.callParent([t])},configForm:function(e){var t=new Ext.XTemplate('
    ','','
    ',SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.statusHtml({icon:"{[this.renderStatus(values.status)]}",text:'{[this.renderItems(values.desc)]}, {extra} '}),'
    ',"
    ","
    ","
    ",{renderItems:function(e){var t={check_interface_enable_step:_T("routerconf","check_network_interface_enabled"),check_gateway_setting_step:_T("routerconf","check_gateway_setting"),check_connect_wan_step:_T("routerconf","check_connect_to_wan"),check_dns_setting_step:_T("routerconf","check_dns_setting"),check_hops_lan2wan_step:_T("routerconf","check_lan2wan_gateway_hops"),detect_router_step:_T("routerconf","detect_router")};return e in t?t[e]:"-"},renderStatus:function(e){var t='
    -
    ',i={processing:'
    ',unknown:t,success:'
     
    ',warning:'
     
    ',failed:'
     
    ',stop:t,initial:""};return e in i?i[e]:t}});return SYNO.LayoutConfig.fill(Ext.apply({xtype:"syno_formpanel",trackResetOnLoad:!0,synodefaults:{width:200},items:[{htmlEncode:!1,xtype:"syno_displayfield",value:_T("confbackup","bkp_export_prepare")},{htmlEncode:!1,xtype:"syno_flexcroll_dataview",itemId:"test_list",useARIA:!0,cls:"syno-portforwarding-listitem",autoFlexcroll:!1,tpl:t,height:160,store:new Ext.data.ArrayStore({fields:["status","desc","extra"]})},{htmlEncode:!1,xtype:"syno_displayfield",name:"gateway_setting_warning",value:""},{htmlEncode:!1,xtype:"syno_displayfield",name:"get_hops_warnings",value:""},{htmlEncode:!1,xtype:"syno_displayfield",name:"detect_result"}]},e))},activate:function(){var e=function(){this.owner.setStatusBusy(),this.loadForm()}.bind(this);this.owner.isRouterWizard?e():SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.RouterWizard.prototype.checkAvahiEnabled.call(this,e)},loadForm:function(){this.getComponent("test_list").getContentTarget().setARIA({tabIndex:-1}),this._S("demo_mode")?this.owner.goNext("portfwform",!1):this.hasDetected?this.setupStatusHandler(this.detectResult.opt,this.detectResult.success,this.detectResult.resp):this.sendDetectWebAPI()},sendDetectWebAPI:function(){var e=this;SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.detect.call(this,{success_callback:function(t,i,s){e.strDetectTaskId=i.task_id,e.setupStatusUpdate()}})},setupStatusUpdate:function(){if(!this.setup_status_updater){var e=this.owner,t=e.owner;this.setup_status_updater=new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SetupStatusUpdater({owner:e,module:t||e,setupStatusHandler:this.setupStatusHandler,scope:this})}this.setup_status_updater.isStop()&&this.setup_status_updater.Start(this.strDetectTaskId)},callHelp:function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/connection_routerconf.html"},!1)},replaceStringParamToCallHelp:function(e,t){var i=e;return t&&(i=String.format(e,'',"")),i},getRenderedErrorString:function(e,t){var i=this.replaceStringParamToCallHelp(e,t);return i=''+_T("error","error_error")+": "+i+""},getRenderedWarningString:function(e,t){var i=this.replaceStringParamToCallHelp(e,t);return i=''+_T("log","warn_level")+": "+i+""},getRenderedNoteString:function(e){var t=''+_T("common","note")+_T("common","colon")+" ";return t+=e},getRenderedSuccessString:function(e){return''+_T("report","status_success")+": "+e+""},showResult:function(e,t){this.getForm().findField(e).setValue(t),this.doLayout()},setErrorString:function(e){var t=Ext.id(),i=this.getRenderedErrorString(e,t);this.showResult("detect_result",i),Ext.get(t).on("click",this.callHelp),this.hasError=!0},renderCheckNetworkInterfaceStatus:function(e,t,i){var s="";t.progress.check_interface_enable_step.network_interface?(s=SYNO.SDS.Utils.Network.idToString.call(this,t.progress.check_interface_enable_step.network_interface,""),e.push([t.progress.check_interface_enable_step.status,"check_interface_enable_step",s])):SYNO.Debug("resp.progress.check_interface_enable_step.network_interface is empty"),"failed"==t.progress.check_interface_enable_step.status&&this.setErrorString(_T("routerconf","warn_interface_not_enabled"))},renderCheckGatewaySettingStatus:function(e,t){var i="",s=Ext.id();e.push([t.progress.check_gateway_setting_step.status,"check_gateway_setting_step",t.progress.check_gateway_setting_step.gateway_ip]),"warning"==t.progress.check_gateway_setting_step.status&&(i=this.getRenderedWarningString(_T("routerconf","gateway_setting_not_exist"),s),this.showResult("gateway_setting_warning",i),Ext.get(s).on("click",this.callHelp),this.hasWarning=!0)},renderCheckConnectWANStatus:function(e,t){e.push([t.progress.check_connect_wan_step.status,"check_connect_wan_step"]),"failed"==t.progress.check_connect_wan_step.status&&this.setErrorString(_T("routerconf","network_not_connect_to_wan"))},renderCheckHopsLAN2WAN:function(e,t){var i="",s=Ext.id();e.push([t.progress.check_hops_lan2wan_step.status,"check_hops_lan2wan_step"]),"warning"==t.progress.check_hops_lan2wan_step.status&&"get_hops_fail"==t.progress.check_hops_lan2wan_step.warning_type?(i=this.getRenderedWarningString(_T("routerconf","cant_get_lan2wan_gateway_hops"),s),this.showResult("get_hops_warnings",i),Ext.get(s).on("click",this.callHelp),this.hasWarning=!0):"warning"==t.progress.check_hops_lan2wan_step.status&&"hops_over_one"==t.progress.check_hops_lan2wan_step.warning_type&&(i=this.getRenderedWarningString(_T("routerconf","lan2wan_gateway_hops_over_one"),null),this.showResult("get_hops_warnings",i),this.hasWarning=!0)},renderCheckDNSSetting:function(e,t){e.push([t.progress.check_dns_setting_step.status,"check_dns_setting_step"]),"failed"==t.progress.check_dns_setting_step.status&&this.setErrorString(_T("routerconf","dns_setting_cant_resolve_public_FQDN"))},renderDetectRouter:function(e,t){var i="";e.push([t.progress.detect_router_step.status,"detect_router_step"]),"success"==t.status&&t.support_upnp&&t.support_natpmp&&("unknown"==t.support_upnp||"unknown"===t.support_change_port?(i=this.getRenderedNoteString(_T("routerconf","detect_router_fail_not_in_db")),this.showResult("detect_result",i),this.hasNote=!0):"no"==t.support_upnp&&"no"==t.support_natpmp?t.router_brand||t.router_model||t.router_version?(i=this.getRenderedNoteString(_T("routerconf","detect_router_fail_not_support")),this.showResult("detect_result",i),this.hasNote=!0):(i=this.getRenderedNoteString(_T("routerconf","detect_router_fail_no_resp")),this.showResult("detect_result",i),this.hasNote=!0):"yes"==t.support_upnp||"yes"==t.support_natpmp?this.isAutoJumpToNextStep(t)&&(i=this.getRenderedSuccessString(_T("routerconf","detect_router_success")),this.showResult("detect_result",i)):(SYNO.Debug("renderDetectRouter, impossible here"),this.hasError=!0))},setDisable:function(){var e=this.owner.getButton("back");e&&e.disable(),this.owner.getButton("next").disable(),this.owner.tools.close.setDisplayed(!1)},setEnable:function(){var e=this.owner.getButton("back");e&&e.enable(),this.isAbleToEnableNextButton()&&this.owner.getButton("next").enable(),this.owner.tools.close.setDisplayed(!0)},setupStatusHandler:function(e,t,i){var s,n=[];this.owner.clearStatusBusy(),this.setDisable(),i?i.progress?(this.renderCheckNetworkInterfaceStatus(n,i),this.renderCheckGatewaySettingStatus(n,i),this.renderCheckConnectWANStatus(n,i),this.renderCheckHopsLAN2WAN(n,i),this.renderCheckDNSSetting(n,i),this.renderDetectRouter(n,i),this.getComponent("test_list").getStore().loadData(n,!1),"","success"===(s=i).status&&(this.hasError?(this.setDisable(),this.owner.tools.close.setDisplayed(!0)):this.setEnable(),this.setup_status_updater.Stop(),this.obj=s,this.hasDetected||(this.hasDetected=!0,this.detectResult.opt=e,this.detectResult.success=t,this.detectResult.resp=i),this.owner.getStep("upnpform").getForm().setValues(s),s.upnp_pfpath||(SYNO.ux.Utils.displayFormField(this.owner.getStep("upnpform").getForm(),"router_protocol",!1),SYNO.ux.Utils.displayFormField(this.owner.getStep("upnpform").getForm(),"router_port",!1),SYNO.ux.Utils.displayFormField(this.owner.getStep("upnpform").getForm(),"router_use_custom",!1),SYNO.ux.Utils.displayFormField(this.owner.getStep("upnpform").getForm(),"router_account",!1),SYNO.ux.Utils.displayFormField(this.owner.getStep("upnpform").getForm(),"router_password",!1),SYNO.ux.Utils.displayFormField(this.owner.getStep("upnpform").getForm(),"router_password_confirm",!1)),this.owner.getStep("natpmpform").getForm().setValues(s),this.owner.getStep("radioform").getForm().setValues(s),this.owner.getStep("uradioform").getForm().setValues(s),this.owner.getStep("portfwform").getForm().setValues(s))):SYNO.Debug("resp.progress is empty"):SYNO.Debug("resp is empty")},isAbleToEnableNextButton:function(){return!this.hasError},isAutoJumpToNextStep:function(e){return!(this.hasWarning||this.hasError||this.hasNote)&&("yes"===e.support_natpmp||"yes"===e.support_upnp)},nextStep:function(e){var t;this.owner.clearStatusBusy(),t="yes"===e.support_natpmp?"natpmpform":"unknown"===e.support_change_port||"unknown"===e.support_upnp?"radioform":"yes"===e.support_upnp?"upnpform":"yes"===e.support_change_port?"uradioform":"portfwform",0===this.owner.stepStack.length&&this.owner.getButton("back").hide(),this.owner.goNext(t,!0)},onCancel:function(){this.owner.getStep(this.layout.activeItem.itemId).form.isDirty()?this.owner.getMsgBox().confirm(this.owner.title,_T("common","confirm_lostchange"),function(e){"yes"===e&&this.owner.close()},this):this.owner.close()},ajaxErrorHandler:function(e){this.owner.getMsgBox().alert(this.title,e)},getNext:function(){return this.nextStep(this.obj),!1}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.RadioStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t=Ext.apply({trackResetOnLoad:!0,headline:_T("ezinternet","ezinternet_router_conf_title"),description:_T("routerconf","routerconf_portmapping_method"),labelWidth:200,synodefaults:{width:200},border:!1,items:this.configForm(),listeners:{afterlayout:function(e){SYNO.ux.Utils.DescribeGroup(e.getComponent("compatibility_radio"),[e.getComponent("comp_field1"),e.getComponent("comp_field2"),e.getComponent("comp_field3"),e.getComponent("comp_field4")]),SYNO.ux.Utils.DescribeGroup(e.getComponent("manual_radio"),[e.getComponent("manual_field")])},scope:this,single:!0}},e);this.callParent([t])},configForm:function(e){return[{xtype:"syno_radio",indent:1,boxLabel:_T("routerconf","routerconf_upnp"),name:"portmapping_type",itemId:"compatibility_radio",inputValue:0,checked:!0,scope:this},{xtype:"syno_displayfield",indent:2,value:_T("routerconf","routerconf_test_upnp_router"),itemId:"comp_field1"},{xtype:"syno_displayfield",fieldLabel:_T("routerconf","routerconf_brand"),name:"router_brand",indent:2,width:360,value:"",itemId:"comp_field2"},{xtype:"syno_displayfield",fieldLabel:_T("routerconf","routerconf_model"),name:"router_model",indent:2,width:360,value:"",itemId:"comp_field3"},{xtype:"syno_displayfield",fieldLabel:_T("routerconf","routerconf_version"),name:"router_version",indent:2,width:360,itemId:"comp_field4"},{xtype:"syno_radio",indent:1,boxLabel:_T("routerconf","routerconf_portforward"),name:"portmapping_type",itemId:"manual_radio",inputValue:1,scope:this},{xtype:"syno_displayfield",indent:2,itemId:"manual_field",value:_T("routerconf","routerconf_portforward_long")}]},checkState:function(){SYNO.SDS.Wizard.Step.prototype.checkState.call(this)},getNext:function(){var e=this.getForm().getValues().portmapping_type;return this.nextId[e]}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortFWStep",{extend:"SYNO.ux.FormPanel",initEvents:function(){this.callParent(arguments),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortFWStep.superclass.initEvents.apply(this,arguments),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"router_use_custom",["router_account","router_password","router_password_confirm"]),this.mon(this,"afterlayout",function(){var e=Ext.getCmp(this.updateRouterDBId);SYNO.ux.AddWhiteTipWithMsg(e,_T("routerconf","routerconf_router_warning"))},this,{single:!0})},constructor:function(e){e.owner||SYNO.Debug("PortFWStep constructor failed, due to no owner"),this.owner=e.owner;var t=this.configForm({headline:_T("ezinternet","ezinternet_port_fwd_title"),description:_T("routerconf","routerconf_setup_router_desc"),autoFlexcroll:!1,labelWidth:200});Ext.apply(t,e),this.callParent([t])},activate:function(){this.form.findField("router_list").on("select",function(e,t,i){this.form.findField("router_brand").setValue(t.get("router_brand")),this.form.findField("router_model").setValue(t.get("router_model")),this.form.findField("router_version").setValue(t.get("router_version")),this._S("demo_mode")&&(this.owner.getButton("next").disable(),this.owner.getButton("next").setTooltip(_JSLIBSTR("uicommon","error_demo")))},this),this.loadRouterList(),this.doLayout()},loadRouterList:function(){this.owner.setStatusBusy(),this.router_store.load({callback:function(e,t,i){this.owner.clearStatusBusy(),i||this.owner.reportFailure({yesfn:this.loadRouterList,nofn:this.close,msg:_T("routerconf","routerconf_router_list_error"),scope:this})},scope:this,add:!1})},onAfterLoad:function(e,t,i){for(var s=0;s 

    {0}

    ",String.format(_T("ezinternet","ezinternet_router_info"),'',""))},{xtype:"hidden",name:"support_natpmp"},{xtype:"hidden",name:"support_upnp"},{xtype:"hidden",name:"router_brand"},{xtype:"hidden",name:"router_model"},{xtype:"hidden",name:"router_version"}]},e))},getNext:function(){return!!this.checkData()&&(this.popWarning(this.savePWRouterInfo,this),!1)},checkData:function(){var e=this.getForm();return!!e.isValid()&&(!!e.isDirty()||null)},popWarning:function(e,t){var i=this.getForm();if(!i.findField("router_use_custom").getValue()||!(i.findField("router_use_custom").isDirty()||i.findField("router_account").isDirty()||i.findField("router_password").isDirty()))return e.call(t),void(this.nextId&&this.owner.goNext(this.nextId,!0));this.owner.getMsgBox().confirm(this.owner.title,_T("routerconf","routerconf_custom_warning"),function(i){"yes"===i&&(e.call(t,!0),this.nextId&&this.owner.goNext(this.nextId,!0))},this)},savePWRouterInfo:function(){this.owner.setStatusBusy({text:_T("common","saving")});var e={router_brand:this.form.findField("router_brand").getValue(),router_model:this.form.findField("router_model").getValue(),router_version:this.form.findField("router_version").getValue(),router_protocol:this.form.findField("router_protocol").getValue(),router_port:this.form.findField("router_port").getValue(),support_upnp:"no",support_natpmp:"no"};this.form.findField("router_use_custom").getValue()&&(e.router_account=this.form.findField("router_account").getValue(),e.router_pass=this.form.findField("router_password").getValue()),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.saveRouterConf.call(this,{retryTimes:5,params:e})},updateRouterDB:function(){this.owner.setStatusBusy(),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.updateDb.call(this,{success_callback:function(e,t,i){this.owner.clearStatusBusy(),0===t.router_version?this.owner.getMsgBox().alert(this.title,_T("routerconf","routerconf_update_nochange")):(this.loadRouterList(),this.owner.getMsgBox().alert(this.title,String.format(_T("routerconf","routerconf_update_success"),t.router_version)))},failure_callback:function(e,t,i){this.owner.clearStatusBusy(),this.owner.reportFailure({msg:_T("routerconf","routerconf_update_db_failed"),yesfn:this.updateRouterDB,scope:this})}})}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI",{extend:"Object",constructor:function(){},closeOrFireFailEvent:function(e){this.isRouterWizard||(this.owner.isRouterWizard?this.owner.close():e&&this.fireEvent("disableNextStep",this))},fireSuccess:function(){this.owner.owner?this.owner.close():this.fireEvent("enableNextStep",this)},saveRouterConf:function(e){if(!e)throw Error("SendWebAPI saveRouterConf cfg null");if(void 0===e.retryTimes)throw Error("SendWebAPI saveRouterConf cfg.retryTimes null");this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding.RouterConf",version:1,method:"set",params:e.params,callback:function(t,i,s){if(t)this.owner.clearStatusBusy(),this.owner.callback&&this.owner.cbscope&&this.owner.callback.call(this.owner.cbscope),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.fireSuccess.call(this),SYNO.Debug("save conf success");else{if(1501===i.code){if(0>e.retryTimes)return this.owner.getMsgBox().alert(this.title,_T("common","error_occupied")),this.owner.clearStatusBusy(),void SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.closeOrFireFailEvent.call(this,!0);e.retryTimes--,this.saveRouterConfWebAPI(),SYNO.Debug("retry to save upnp conf")}else{var n=SYNO.API.getErrorString(i.code);this.owner.getMsgBox().alert(this.title,n),this.owner.clearStatusBusy(),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.closeOrFireFailEvent.call(this,!0)}}},scope:this})},detect:function(e){this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding",version:1,method:"detect",params:{auto_save:!1},callback:function(t,i,s){if(t){if(!i||!i.task_id)throw Error("detect webapi shall return data.task_id");e&&e.success_callback&&e.success_callback.call(this,t,i,s),SYNO.Debug("detect success")}else SYNO.Debug("detect failed")},scope:this})},updateDb:function(e){this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding.RouterList",version:1,method:"update",callback:function(t,i,s){if(!t)return e&&e.failure_callback&&e.failure_callback.call(this,t,i,s),void SYNO.Debug("updateDb failed");e&&e.success_callback&&e.success_callback.call(this,t,i,s),SYNO.Debug("updateDb success")},scope:this})},testCompatibility:function(e){this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding.Compatibility",version:1,method:"test",callback:function(t,i,s){if(!t)return e&&e.failure_callback&&e.failure_callback.call(this,t,i,s),void SYNO.Debug("start comptibility failed");e&&e.success_callback&&e.success_callback.call(this,t,i,s),SYNO.Debug("start compatibility success")},scope:this})},stopTestCompatibility:function(e){var t=this;this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding.Compatibility",version:1,method:"stop",callback:function(i,s,n){if(!i)return e&&e.failure_callback&&e.failure_callback.call(t,i,s,n),void SYNO.Debug("stop comptibility failed");e&&e.success_callback&&e.success_callback.call(t,i,s,n),SYNO.Debug("stop compatibility success")},scope:t})},testCompatibilityStatus:function(e){this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding.Compatibility",version:1,method:"test_status",params:{task_id:e.task_id},callback:function(t,i,s){if(!t)return e&&e.failure_callback&&e.failure_callback.call(this,t,i,s),void SYNO.Debug("get comptibility status failed");e&&e.success_callback&&e.success_callback.call(this,t,i,s),SYNO.Debug("get compatibility status success")},scope:this})},uploadCompatibilityResult:function(e){this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding.Compatibility",version:1,method:"upload",callback:function(t,i,s){if(!t)return e&&e.failure_callback&&e.failure_callback.call(this,t,i,s),void SYNO.Debug("upload comptibility status failed");e&&e.success_callback&&e.success_callback.call(this,t,i,s),SYNO.Debug("upload compatibility status success")},scope:this})},getCurrentProcessing:function(e){this.owner.sendWebAPI({api:"SYNO.Core.PortForwarding",version:1,method:"get_current_process",callback:function(t,i,s){if(!t)return e&&e.failure_callback&&e.failure_callback.call(this,t,i,s),void SYNO.Debug("get current process failed");e&&e.success_callback&&e.success_callback.call(this,t,i,s),SYNO.Debug("get current process success")},scope:this})}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.UPnPStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){if(!e.owner)throw Error("UPnPStep constructor failed");this.owner=e.owner;var t=this.configForm({module:this.owner,autoFlexcroll:!1,headline:_T("ezinternet","ezinternet_router_conf_title"),description:_T("routerconf","routerconf_upnp_title")});Ext.apply(t,e),this.callParent([t])},configForm:function(e){return SYNO.LayoutConfig.fill(Ext.apply({xtype:"syno_formpanel",labelWidth:200,border:!1,items:[{fieldLabel:_T("routerconf","routerconf_brand"),name:"router_brand",indent:0,width:360,xtype:"syno_displayfield"},{fieldLabel:_T("routerconf","routerconf_model"),name:"router_model",indent:0,width:360,xtype:"syno_displayfield"},{fieldLabel:_T("routerconf","routerconf_version"),name:"router_version",indent:0,width:360,xtype:"syno_displayfield"},{xtype:"syno_combobox",fieldLabel:_T("routerconf","routerconf_manager_protocol"),name:"router_protocol",store:new Ext.data.JsonStore({fields:["name","value","port"],data:[{name:"HTTP",value:"http",port:80},{name:"HTTPS",value:"https",port:443}]}),value:"http",displayField:"name",valueField:"value",listeners:{select:function(e,t,i){this.ownerCt.getComponent("router_port").setValue(t.get("port"))}}},{xtype:"syno_numberfield",fieldLabel:_T("routerconf","routerconf_manager_port"),name:"router_port",maxlangth:5,itemId:"router_port",value:80,vtype:"port"},{xtype:"syno_checkbox",boxLabel:_T("routerconf","routerconf_custom_account"),name:"router_use_custom"},{xtype:"syno_textfield",indent:1,fieldLabel:_T("routerconf","routerconf_manager_account"),name:"router_account"},{xtype:"syno_textfield",textType:"password",indent:1,fieldLabel:_T("routerconf","routerconf_manager_password"),name:"router_password"},{xtype:"syno_textfield",textType:"password_confirm",indent:1,fieldLabel:_T("service","service_ddns_passwd_confirm"),name:"router_password_confirm",confirmFor:"router_password"},{xtype:"hidden",name:"router_list"},{xtype:"hidden",name:"upnp_pfpath"},{xtype:"hidden",name:"support_natpmp"},{xtype:"hidden",name:"support_upnp"}]},e))},getNext:function(){return this.saveUPnPRouterInfo(),!1},saveUPnPRouterInfo:function(e,t,i){var s=this.getForm();if(!this.getForm().isValid())return!1;if(!i&&s.findField("router_use_custom").getValue()&&(s.findField("router_use_custom").isDirty()||s.findField("router_account").isDirty()||s.findField("router_password").isDirty()))return this.owner.getMsgBox().confirm(this.owner.title,_T("routerconf","routerconf_custom_warning"),function(e){"yes"===e&&this.saveUPnPRouterInfo(e,t,!0)},this),!1;this.owner.setStatusBusy({text:_T("common","saving")});var n={router_brand:this.form.findField("router_brand").getValue(),router_model:this.form.findField("router_model").getValue(),router_version:this.form.findField("router_version").getValue(),support_upnp:"yes",support_natpmp:"no"};this.form.findField("upnp_pfpath").getValue()&&(n.upnp_pfpath=this.form.findField("upnp_pfpath").getValue(),n.router_protocol=this.form.findField("router_protocol").getValue(),n.router_port=this.form.findField("router_port").getValue(),this.form.findField("router_use_custom").getValue()&&(n.router_account=this.form.findField("router_account").getValue(),n.router_pass=this.form.findField("router_password").getValue())),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.saveRouterConf.call(this,{retryTimes:5,params:n})},initEvents:function(){SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.UPnPStep.superclass.initEvents.apply(this,arguments),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"router_use_custom",["router_account","router_password","router_password_confirm"])}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.NatpmpStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){if(!e.owner)throw Error("NatpmpStep constructor failed");this.owner=e.owner;var t=this.configForm({module:this.owner,headline:_T("ezinternet","ezinternet_router_natpmp_conf_title"),description:_T("routerconf","routerconf_natpmp_title")});Ext.apply(t,e),SYNO.LayoutConfig.fill(t),this.callParent([t])},configForm:function(e){return SYNO.LayoutConfig.fill(Ext.apply({xtype:"syno_formpanel",synodefaults:{width:200},border:!1,items:[{fieldLabel:_T("routerconf","routerconf_brand"),name:"router_brand",indent:0,width:360,xtype:"syno_displayfield"},{fieldLabel:_T("routerconf","routerconf_model"),name:"router_user_setting_name",indent:0,width:360,xtype:"syno_displayfield"},{xtype:"hidden",name:"router_model"},{xtype:"hidden",name:"router_version"},{xtype:"hidden",name:"router_protocol"},{xtype:"hidden",name:"router_port"},{xtype:"hidden",name:"support_natpmp"},{xtype:"hidden",name:"support_upnp"},{xtype:"hidden",name:"router_max_rule"}]},e))},getNext:function(e){return this.saveNatpmpRouterInfo(),!1},saveNatpmpRouterInfo:function(){var e={router_brand:this.form.findField("router_brand").getValue(),router_model:this.form.findField("router_model").getValue(),router_version:this.form.findField("router_version").getValue(),support_upnp:"no",support_natpmp:"yes"};this.owner.setStatusBusy({text:_T("common","saving")}),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.SendWebAPI.prototype.saveRouterConf.call(this,{retryTimes:5,params:e})}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.CompatibilityStatusUpdater",{extend:"Object",constructor:function(e){if(!e.owner||!e.scope||!e.pollConf)throw Error("CompatibilityStatusUpdater contructor failed");this.owner=e.owner,this.scope=e.scope,this.pollConf=e.pollConf,this.pollId=null},Start:function(){this.Stop(),this.pollId=this.owner.pollReg(this.pollConf)},Stop:function(){this.pollId&&this.owner.pollUnreg(this.pollId),this.pollId=null}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.TestStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){if(this.strTaskId=null,this.compatibility_status_updater=null,this.hasUpload=!1,!e.owner)throw Error("TestStep constructor failed");this.owner=e.owner;var t=this.configForm({module:this.owner,headline:_T("ezinternet","ezinternet_router_conf_title"),description:_T("routerconf","routerconf_test_upnp_desc")},e);Ext.apply(t,e),this.callParent([t])},initEvents:function(){this.owner.mon(this.owner,"beforeclose",this.onClose,this)},onClose:function(){this===this.owner.getActiveStep()&&this.Stop(!0),this.owner.mun(this.owner,"beforeclose",this.onClose,this)},configForm:function(e){var t=new Ext.XTemplate('','
    ',SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.statusHtml({icon:"{[this.renderStatus(values.status)]}",text:"{[this.formatString(values.desc, values.extra)]}"}),"
    ","
    ",{renderItems:function(e){var t={add:_T("routerconf","routerconf_test_rule_add"),max:_T("routerconf","routerconf_test_max_count")};return e in t?t[e]:"-"},renderStatus:function(e){var t={processing:'
    ',unknown:'
    -
    ',success:'
     
    ',failed:'
     
    '};return e in t?t[e]:'
    -
    '},formatString:function(e,t){return String.format(this.renderItems(e),''+t+"")}});return SYNO.LayoutConfig.fill(Ext.apply({xtype:"syno_formpanel",trackResetOnLoad:!0,synodefaults:{width:200},items:[{xtype:"syno_flexcroll_dataview",itemId:"test_list",useARIA:!0,cls:"syno-portforwarding-listitem",autoFlexcroll:!1,tpl:t,height:100,store:new Ext.data.ArrayStore({fields:["status","desc","extra"]})},{xtype:"syno_displayfield",name:"test_staus",htmlEncode:!1},{xtype:"syno_checkbox",boxLabel:_T("routerconf","routerconf_test_report"),name:"test_report",checked:!0,hidden:!0,hideMode:"visibility",indent:1},{xtype:"syno_displayfield",name:"dummy",htmlEncode:!1}]},e))},activate:function(){this.getComponent("test_list").getContentTarget().setARIA({tabIndex:-1}),this.hasCompatibilityTest?this.testUPnPResult(this.compatibilitTestData):this.compatibility_status_updater||this.testUPnPCompatibility()},testUPnPCompatibility:function(){this.compatibility_status_updater&&SYNO.Debug("testUPnPCompatibility compatibility_status_updater shall not exist"),this.owner.pollList({task_id_prefix:"SYNO.Core.PortForwarding.test_compatibility",extra_group_tasks:["admin"],callback:function(e,t,i,s){e?t.admin&&0this.max&&(i=this.min,this.min=this.max,this.max=i)},isValid:function(){return 0=(s=new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Ports(this.toString()).ports).length)return n;for(s.sort(SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortRange.comparator),t=1,e=s[0].max;t=s[t].min&&(i=ei[a].search("-"))t.push(parseInt(i[a],10));else{(s=i[a].split("-")[0])>(n=i[a].split("-")[1])&&(o=s,s=n,n=o);for(var r=s;r<=n;r++)t.push(parseInt(r,10))}return t},SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.statusHtml=function(e){var t,i;return t=void 0!==(e=e||{}).icon?e.icon:'
     
    ',i=void 0!==e.text?e.text:_T("common","loading"),String.format('
    {0}
    {1}
    ',t,i)},Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.ServiceRuleGrid",{extend:"SYNO.ux.EditorGridPanel",constructor:function(e){if(!e.owner)throw Error("ServiceRuleStep constructor failed");this.owner=e.owner,this.rule_store=e.rule_store,this.serviceDescObj=e.serviceDescObj,this.next_step_callback=e.next_step_callback,this.next_step_callback_scope=e.next_step_callback_scope,this.isSupportChangePort=e.isSupportChangePort||!1,this.allowBlank=!1;var t=Ext.apply(this.createServiceRuleGridConfig(),e),i=SYNO.LayoutConfig.fill(t);this.callParent([i])},activate:function(){this.serviceDescObj.hasInitialized()?this.activateCore():(this.owner.setStatusBusy(),this.serviceDescObj.initAsync(function(){this.owner.clearStatusBusy(),this.activateCore()}.bind(this)))},activateCore:function(){this.getStore().loadData(this.serviceDescObj.getPortInfoArrayData(),!1),this.deleteAddedServices(this.getStore()),this.getColumnModel().setEditable(4,this.isSupportChangePort),this.isSupportChangePort||this.getStore().each(function(e){e.set("router_ports",e.get("dst_port"))})},createServiceRuleGridConfig:function(){var e=new SYNO.ux.EnableColumn({dataIndex:"enabled",width:45,align:"center"}),t=new Ext.data.ArrayStore({fields:["port_id","desc","dst_port","router_ports","protocol","enabled"],listeners:{update:function(e,t,i){Ext.data.Record.EDIT===i&&(this.allowBlank||this.checkState())},scope:this}});return{headline:_T("routerconf","routerconf_systemport_title"),cls:"without-dirty-red-grid",plugins:e,selModel:new Ext.grid.RowSelectionModel({}),autoExpandColumn:"desc",view:new SYNO.ux.FleXcroll.grid.GridView({borderHeight:1,cacheSize:100,scrollDelay:!1,forceFit:!0}),cm:new Ext.grid.ColumnModel([e,{id:"desc",header:_T("routerconf","routerconf_header_service"),dataIndex:"desc",align:"left",width:160,renderer:function(e,t,i){var s=e;return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(s)+'"',s}},{header:_T("routerconf","routerconf_header_protocol"),dataIndex:"protocol",align:"left",width:90,renderer:function(e,t,i){var s=e.toUpperCase();return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(s)+'"',s}},{header:_T("routerconf","routerconf_header_ds_port"),dataIndex:"dst_port",sortable:!0,align:"left",width:160,renderer:function(e,t,i){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e}},{header:_T("routerconf","routerconf_header_router_port"),dataIndex:"router_ports",align:"left",editor:new Ext.grid.GridEditor(new SYNO.ux.TextField({allowBlank:!1,vtype:"portfwd",validator:this.validateRouterPort.createDelegate(this),validationEvent:"keyup"})),width:160,renderer:function(e,t,i){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e}}]),store:t,enableHdMenu:!1,clicksToEdit:1}},validateRouterPort:function(e){var t=this.getSelectionModel().getSelections();if(!t||0>=t.length)return!1;var i=e,s={dsPortsString:t[0].data.dst_port.toString(),routerPortsString:i};return SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortsValidator(s)},deleteAddedServices:function(e){var t,i,s=0,n=function(e){e.get("serviceid").id==i.get("port_id")&&e.get("ds_port")==i.get("dst_port")&&(s=1)};for(t=e.getCount()-1;t>=0;t--)(i=e.getAt(t)).set("router_ports",i.get("dst_port")),s=0,this.rule_store&&(this.rule_store.each(n),1==s&&e.removeAt(t))},deactivate:function(){this.owner.getButton("next").enable()},checkState:function(){if(SYNO.SDS.Wizard.Step.prototype.checkState.call(this),!this.allowBlank){var e,t=this.getStore();for(e=0;e",i=Ext.apply({headline:_T("routerconf","routerconf_customport_title"),synodefaults:{width:275},xtype:"syno_formpanel",items:[{xtype:"syno_combobox",fieldLabel:_T("routerconf","routerconf_header_protocol"),name:"protocol",store:[["tcp","TCP"],["udp","UDP"]],value:"tcp"},{xtype:"syno_textfield",fieldLabel:_T("routerconf","routerconf_header_ds_port"),name:"ds_ports",itemId:"ds_ports",allowBlank:!1,vtype:"portfwd",validator:SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortStringValidator,listeners:{blur:function(e){var t=e.ownerCt.getComponent("router_ports");this.isSupportChangePort?""===t.getValue()&&e.isValid()&&t.setValue(e.getValue()):t.setValue(e.getValue())},scope:this}},{xtype:"syno_textfield",fieldLabel:_T("routerconf","routerconf_header_router_port"),name:"router_ports",itemId:"router_ports",hiddenName:"router_ports",allowBlank:!1,vtype:"portfwd",disabled:!this.isSupportChangePort,validator:SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortStringValidator},{xtype:"syno_displayfield",value:t+_T("routerconf","routerconf_port_hint"),htmlEncode:!1}],getNext:function(){return!!this.owner.addCustomRules(this.getForm())&&(this.next_step_callback&&this.next_step_callback.call(this.next_step_callback_scope),this.nextId)}},e);return SYNO.LayoutConfig.fill(i)},loadUsedPorts:function(){return Ext.isDefined(this.used_ports)?Ext.apply({},this.used_ports):(this.used_ports=this.rule_store.getUsedPortStrings(),Ext.apply({},this.used_ports))},isRuleIdInStore:function(e,t){for(var i=0;i",_T("routerconf","routerconf_port_conflict"))},r=function(e,t,i){n.text+=String.format("[{0} : {1}]
    [{2} : {3}]
     ",t.getServiceName(),t.getProtocol(),i.getServiceName(),i.getProtocol()),e.dsPort.length>0&&(n.text+=String.format(" {0}:{1} ",_T("routerconf","routerconf_header_ds_port"),e.dsPort.toString())),e.routerPort.length>0&&(n.text+=String.format(" {0}:{1} ",_T("routerconf","routerconf_header_router_port"),e.routerPort.toString())),n.text+="
    "};for(t=0;t=i.length)return!1;for(t=0;t 
    ',s,n)}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Checker",{extend:"Object",constructor:function(e){this.previousProcess=null,this.scope=null,this.statusHandler=null,e.appWin?this.appWin=e.appWin:(SYNO.Debug("contructor failed due to no module"),this.appWin=null),e.scope?this.scope=e.scope:(SYNO.Debug("constructor failed due to no scope"),this.scope=null),e.callback?this.statusHandler=e.callback:(SYNO.Debug("constructor failed due to no callback"),this.statusHandler=null),e.interval?this.interval=e.interval:this.interval=1,this.pfConfPollId=null,this.pfConf={interval:this.interval,immediate:!1,webapi:{api:"SYNO.Core.PortForwarding",version:1,method:"get_current_process"},status_callback:function(e,t,i,s){e?(this.previousProcess=this.process,this.process=t.process,this.processTaskId=t.task_id):(this.previousProcess=this.process,this.process="",this.processTaskId=""),this.statusHandler.call(this.scope),SYNO.Debug("pf conf status_callback")},scope:this}},Start:function(){this.Stop(),this.pfConfPollId=this.appWin.pollReg(this.pfConf)},Stop:function(){this.pfConfPollId&&(this.appWin.pollUnreg(this.pfConfPollId),this.pfConfPollId=null)}}),Ext.ns("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util"),SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util.NetworkInfo=function(){var e={},t=function(t){e=t};return{joinCompound:function(e){e.params.push({api:"SYNO.Core.Network",version:1,method:"get"}),e.callbacks.push(t)},getNetworkInfo:function(){return e}}},SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util.RouterConfInfo=function(){var e={},t=function(t){e=""===t.router_brand&&""===t.router_model&&""===t.router_version?{}:t};return{hasRouterConfInfo:function(){return 0!==Object.keys(e).length},sendRouterConfGetWebapi:function(){var e=Ext.apply({callback:function(e,i,s){e&&t(i)},scope:this},{api:"SYNO.Core.PortForwarding.RouterConf",version:1,method:"get"});SYNO.API.Request(e)},joinCompound:function(e){e.params.push({api:"SYNO.Core.PortForwarding.RouterConf",version:1,method:"get"}),e.callbacks.push(t)},getRouterConf:function(){return e}}},SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util.ServiceName=function(e,t){var i=[],s={},n=!1;if(!e)return SYNO.Debug("scope is empty"),{};if(!t)return SYNO.Debug("appWin is empty"),{};if(!t.sendWebAPI)return SYNO.Debug("appWin.sendWebAPI is empty"),{};var o=function(){return function(e){i=[],s={};for(var t=e.port_info,o=0;o",{xtype:"syno_button",itemId:"cancel",text:_T("common","cancel"),scope:this,handler:function(){this.forceApplyConfirmDialog.close()}},{xtype:"syno_button",itemId:"yes",text:_T("routerconf","conflict_force_apply_yes"),btnStyle:"red",scope:this,handler:function(){this.showConfirmDialog=!0,this.commitHandler(),this.close()}}],items:[{xtype:"syno_displayfield",name:"desc",value:_T("routerconf","conflict_force_apply_comfirm")}]}),this.forceApplyConfirmDialog.show()},commitHandler:function(){if(this.confirmCB){let s=Ext.getCmp(this.force_apply_btnid).getValue();var e=this.getComponent("conflict_records").getStore();if(s&&!this.showConfirmDialog)return void this.showForceApplyConfirm();for(var t=0;t=0;t--)i.getAt(t).set("rule_status","");this.getSelectionModel().clearSelections()}else"get"===e&&this.changeState("waiting");return!0},processParams:function(e,t){if("get"===e){this.resetMainPage();var i={params:[],callbacks:[]};this.routerConfInfoObj=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util.RouterConfInfo(),this.networkInfoObj=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util.NetworkInfo(),this.maxAndUsedPortObj=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util.OtherDeviceUsedPortNumber(this.module.appWin),this.serviceDescObj=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Util.ServiceName(this,this.module.appWin),this.getStore().setServiceDescObj(this.serviceDescObj),this.showLoadingForMaxAndUsedPorts(),this.serviceDescObj.joinCompound(i),this.getStore().joinCompound(i),this.routerConfInfoObj.joinCompound(i),this.networkInfoObj.joinCompound(i),t=t.concat(i.params),this.compound=i}else"set"===e&&this.isDirty()&&(this.module.panel.registerProcessReturnData("portforwardingtab"),t.push({api:"SYNO.Core.PortForwarding.Rules",version:1,method:"save",params:{rules:this.getStore().getRules(),task_id_suffix:"PF"}}));return t},processReturnData:function(e,t,i){if("get"===e){var s=this.compound;if(Ext.each(t.result,function(e,t){for(var i=0;i"}),t+=""},showWarningDialog:function(){var e=[];e.push(_T("routerconf","routerconf_overwrite_warning")),e.push(String.format(_T("routerconf","routerconf_wan_warning"),this._D("product"))),e.push(_T("routerconf","routerconf_logout_warning")),new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.ConfirmDialog({owner:this.module.appWin,items:[{xtype:"syno_displayfield",cls:"syno-portforwarding-dialog-title",value:_T("routerconf","apply_rules_desc"),style:"padding-bottom: 12px"},{xtype:"syno_displayfield",htmlEncode:!1,value:this.getListHtml(e)}],onApply:function(e){this.isExceedMaxUsedPorts(!0)?this.showExceedMappableWarningDialog():(this.flag_show_warning_dialog=!0,this.module.panel.applyAllForm(this.module.panel.applyAllFormOptions))}.bind(this)}).show()},showExceedMappableWarningDialog:function(){new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.ConfirmDialog({owner:this.module.appWin,width:700,items:[{xtype:"syno_displayfield",cls:"dialog-title",value:_T("routerconf","routerconf_exceed_max_port_title")},{xtype:"syno_displayfield",value:_T("routerconf","routerconf_exceed_max_port_take_time")+_T("routerconf","routerconf_exceed_max_port_reduce_ports")}],onApply:function(e){this.flag_show_warning_dialog=!0,this.module.panel.applyAllForm(this.module.panel.applyAllFormOptions)}.bind(this)}).show()},createConfig:function(e){this.maxUsedDisplay=new SYNO.ux.DisplayField({itemId:"max_used",htmlEncode:!1,style:"padding: 4px 0px; height: 20px;"}),this.store=new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.RuleStore({owner:this.module.appWin,grid:this,serviceDescObj:this.serviceDescObj});var t=this.createColumnModel();return SYNO.LayoutConfig.fill(Ext.apply({width:600,height:300,title:_T("tree","leaf_routerconf"),cm:t,plugins:t.config[0],autoExpandColumn:"serviceid",enableHdMenu:!1,loadMask:!1,cls:"without-dirty-red-grid syno-portforwarding-main-grid syno-portforwarding-listitem",listeners:{rowcontextmenu:this.onRowCtxMenu,containercontextmenu:this.showCtxMenu,activate:this.onActivate,deactivate:this.onDeactivate,scope:this},clicksToEdit:1,selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:this.checkOnSelectionChanged,scope:this}}),store:this.store,tbar:[{xtype:"syno_button",text:_T("common","create"),handler:this.onCreateRule,scope:this,itemId:"create"},{xtype:"syno_button",text:_T("routerconf","setup_router_button"),handler:this.onSetupRouter,scope:this,itemId:"router"},{xtype:"syno_button",text:_T("common","delete"),handler:this.onDeleteRule,scope:this,itemId:"del"},{disabled:this._S("demo_mode"),xtype:"syno_button",text:_T("routerconf","routerconf_test_conn"),handler:this.onTest,scope:this,itemId:"test"}],bbar:new SYNO.ux.PagingToolbar({store:this.store,displayInfo:!1}),fbar:{xtype:"syno_toolbar",layout:"fit",items:[this.maxUsedDisplay]},footerCfg:{style:"padding: 6px 0px 0px 0px;"},viewConfig:{markDirty:!1,emptyText:this.getGridEmptyText("no_rule")}},e))},updateGridEmptyText:function(e){this.getView().emptyText=this.getGridEmptyText(e),this.getView().refresh()},getGridEmptyText:function(e){let t=['
    ','
    ','
    ','
    ','
    '];switch(e){case"no_router":t.push(_T("routerconf","warn_setup_router"));break;case"no_rule":t.push(_T("routerconf","routerconf_no_rule"));break;default:t.push("")}return t.concat(["
    ","
    ","
    ","
    "]).join("")},updateGridHeight:function(){let e=this.getView().el.query(".contentwrapper")[0];0'+e.port+"":e.port}),d=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortString(function(e){return a(e)?e.port+"("+e.originPort+")":e.port}),l.init(),d.init(),o=0;o'+e+""),t.cellAttr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',m},rule_status_renderer:function(e,t){var i={testing:_T("routerconf","routerconf_status_testing"),waiting:_T("routerconf","routerconf_status_testing"),yes:_T("routerconf","routerconf_status_ok"),fail:_T("routerconf","routerconf_tip_net_cnn_failed"),udp:_T("routerconf","routerconf_tip_udp"),nolisten:_T("routerconf","routerconf_tip_no_service"),notest:_T("routerconf","routerconf_status_ntest"),psuccess:_T("routerconf","routerconf_tip_psuccess"),disabled:_T("common","disabled")},s={testing:'
    ',waiting:'
    ',yes:_T("routerconf","routerconf_status_ok"),fail:_T("routerconf","routerconf_status_failed"),udp:_T("routerconf","routerconf_status_ntest"),nolisten:_T("routerconf","routerconf_status_ntest"),notest:_T("routerconf","routerconf_status_ntest"),psuccess:_T("routerconf","routerconf_status_failed"),disabled:_T("common","disabled")};return t.attr=e in i?String.format('ext:qtip="{0}"',Ext.util.Format.htmlEncode(i[e])):"",e in s?s[e]:"-"},router_protocol_renderer:function(e,t){var i={tcp:_T("routerconf","routerconf_protocol_tcp"),udp:_T("routerconf","routerconf_protocol_udp")};return e in i?i[e]:"-"},serviceid_renderer:function(e,t){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e.desc)+'"',e.desc},createColumnModel:function(){var e={grid:this,columns:[new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.RuleEnableColumn({header:_T("routerconf","routerconf_header_enabled"),dataIndex:"enable",width:80,align:"center",commitChanges:!1}),{header:_T("routerconf","routerconf_header_status"),dataIndex:"rule_status",width:80,align:"center",renderer:this.rule_status_renderer},{header:_T("routerconf","routerconf_header_service"),id:"serviceid",dataIndex:"serviceid",width:150,align:"left",renderer:this.serviceid_renderer},{header:_T("routerconf","routerconf_header_ds_port"),dataIndex:"ds_port",width:120,align:"left",renderer:this.ds_port_renderer},{header:_T("routerconf","routerconf_header_router_port"),dataIndex:"router_port",width:120,align:"left",renderer:this.router_port_renderer,scope:this,editor:new SYNO.ux.TextField({validationEvent:"keyup",validator:this.validateRouterPort.createDelegate(this),allowBlank:!1,vtype:"portfwd"})},{header:_T("routerconf","routerconf_header_protocol"),dataIndex:"router_protocol",width:60,align:"center",renderer:this.router_protocol_renderer}],isCellEditable:function(e,t){return!this.grid.getStore().getAt(t).get("readonly")&&Ext.grid.ColumnModel.prototype.isCellEditable.call(this,e,t)}};return new Ext.grid.ColumnModel(e)},validateRouterPort:function(e){var t=this.getSelectionModel().getSelections();if(!t||0>=t.length)return!1;var i=e,s={dsPortsString:t[0].data.ds_port.toString(),routerPortsString:i};return SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.PortsValidator(s)},changeState:function(e){var t={error:this.maskAll,normal:function(){this.checkOnRuleChanged(),this.checkOnSelectionChanged(this.getSelectionModel()),this.el.unmask(),this.getView().el.unmask()},set_router:function(){this.el.unmask(),0=this.getStore().getCount()?this.getButton("test").disable():e&&(this.getButton("test").disable(),this.getButton("router").disable()),e&&this.getButton("test").setTooltip(_T("routerconf","routerconf_disable_test_btn_reason"))},checkOnSelectionChanged:function(e){let t,i;if(0',red:'',blue:'',orange:''}[t];return i?i+e+"":e},n=function(e,t){var i=e.toString(),n=t.toString();return n=s(n,t/e>=.9?"red":"green"),i=s(i,"blue"),this.getMaxAndUsedPortPrefix()+n.bold()+"/"+i.bold()}.bind(this);0<=e&&0<=t&&(i=n(e,t),this.maxUsedDisplay.setValue(i))},getMaxPortsNumber:function(){return parseInt(this.routerConfInfoObj.getRouterConf().router_max_rule,10)},getOtherDeviceUsedPortsNumber:function(){return this.maxAndUsedPortObj.getOtherDeviceUsedPortsNumber()},getSystemUsedPorts:function(){return this.getStore().getSystemUsedPorts()},showMaxAndUsedPortsTips:function(){var e;""!==(e=function(){var e=_T("routerconf","max_and_used_tip");return 0>=this.getSystemUsedPorts()+this.getOtherDeviceUsedPortsNumber()?"":String.format(e,this.getSystemUsedPorts()+this.getOtherDeviceUsedPortsNumber())}.bind(this)())?Ext.QuickTips.register({target:this.maxUsedDisplay.getEl(),text:e}):Ext.QuickTips.unregister(this.maxUsedDisplay.getEl())},updateUsedPortsAndShow:function(){0<=this.getOtherDeviceUsedPortsNumber()&&this.isUpnpOrNatpmpRouter()&&(this.showMaxAndUsedPortObj(this.getMaxPortsNumber(),this.getOtherDeviceUsedPortsNumber()+this.getStore().countUsedPortsNumber()),this.showMaxAndUsedPortsTips())},showLoadingForMaxAndUsedPorts:function(){var e=this.maxUsedDisplay;e.setValue(this.getMaxAndUsedPortPrefix()+_T("common","loading")),e.show()},hideMaxAndUsedPorts:function(){this.maxUsedDisplay.hide()},isExceedMaxUsedPorts:function(e){var t=function(){var e=this.routerConfInfoObj.getRouterConf();return!!this.isNatpmpRouter()||!!(this.isUpnpRouter()&&e&&e.limit_upnp_portmap_number)}.bind(this);return!(!e&&!t())&&this.getOtherDeviceUsedPortsNumber()+this.getStore().countUsedPortsNumber()>this.getMaxPortsNumber()},isUpnpRouter:function(){var e=this.routerConfInfoObj.getRouterConf();return!!(e&&e.support_natpmp&&e.support_upnp&&"no"==e.support_natpmp&&"yes"==e.support_upnp)},isSynologyRouter:function(){var e=this.routerConfInfoObj.getRouterConf();return!(!e||"Synology Inc."!=e.router_brand)},isNatpmpRouter:function(){var e=this.routerConfInfoObj.getRouterConf();return!!(e&&e.support_natpmp&&e.support_upnp&&"yes"==e.support_natpmp&&"no"==e.support_upnp)},isUpnpOrNatpmpRouter:function(){var e=this.routerConfInfoObj.getRouterConf();return!(!(e&&e.support_natpmp&&e.support_upnp)||"yes"!=e.support_natpmp&&"yes"!=e.support_upnp)},isSupportChangePort:function(){var e=this.routerConfInfoObj.getRouterConf();return!!e&&e.support_change_port},resetMainPage:function(){this.getSelectionModel().clearSelections(),this.el.unmask(),this.getView().el.unmask(),this.statusUpdaterStop(),this.stopPollTestRuleStatus(),this.stopPollSaveRuleStatus(),Ext.QuickTips.unregister(this.maxUsedDisplay.getEl())},onRowCtxMenu:function(e,t,i){var s=e.getSelectionModel();s.isSelected(t)||s.selectRow(t),this.showCtxMenu(e,i)},getCtxMenu:function(){var e=this.getButton("del").initialConfig,t=this.getButton("test").initialConfig;return this.gridCtxMenu=new SYNO.ux.Menu({autoDestroy:!0,items:[{text:e.text,handler:e.handler,scope:e.scope,disabled:this.getButton("del").disabled},{text:t.text,handler:t.handler,scope:t.scope,disabled:this.getButton("test").disabled}]}),this.gridCtxMenu},showCtxMenu:function(e,t){this.getCtxMenu().showAt(t.getXY())},statusUpdaterStart:function(){this.statusUpdaterStop(),this.status_updater=new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Checker({appWin:this.module.appWin,scope:this,callback:this.statusHandler,interval:1}),this.status_updater.Start()},statusUpdaterStop:function(){this.status_updater&&this.status_updater.Stop()},statusHandler:function(){return SYNO.Debug("this.status_updater.process="+this.status_updater.process),"portforwarding"===this.status_updater.process?(this.changeState("waiting"),void(this.status_updater.processTaskId?this.startPollSaveRuleStatus({taskId:this.status_updater.processTaskId}):this.getView().el.mask(_T("routerconf","routerconf_upnp_service_busy"),"syno-ux-mask-info"))):"autotest"===this.status_updater.process||"routerdetect"===this.status_updater.process?(this.status_updater.processTaskId,this.getView().el.mask(_T("routerconf","routerconf_upnp_service_busy"),"syno-ux-mask-info"),void this.changeState("testing")):void("testrule"==this.status_updater.process?this.status_updater.processTaskId?"testrule"!=this.status_updater.previousProcess&&this.getStore().load({callback:function(){"testrule"==this.status_updater.process&&this.startPollTestRuleStatus({taskId:this.status_updater.processTaskId})},scope:this}):(this.getView().el.mask(_T("routerconf","routerconf_upnp_service_busy"),"syno-ux-mask-info"),this.changeState("testing")):("testing"===this.getState()&&this.routerConfInfoObj.sendRouterConfGetWebapi(),this.routerConfInfoObj.hasRouterConfInfo()?this.changeState("normal"):this.changeState("set_router")))},showSaveRuleProgress:function(e){var t="";e.stage&&("add"===e.stage?t=_T("routerconf","routerconf_progress_add"):"del"===e.stage&&(t=_T("routerconf","routerconf_progress_delete"))),this.saveRuleProgressBar=this.module.appWin.getMsgBox(),this.saveRuleProgressBar.show({width:240,progress:!0,closable:!1}),this.saveRuleProgressBar.updateProgress(.01*e.percentage,e.percentage+"%",t)},hideSaveRuleProgress:function(){this.saveRuleProgressBar&&(this.saveRuleProgressBar.hide(),this.saveRuleProgressBar=null)},toSaveRuleErrorStringWithData:function(e,t){var i=SYNO.API.getErrorString(e);return 1521===e?String.format(i,t.errors.append.max_port):1522===e?String.format(i,t.errors.append.max_port):1523===e?String.format(i,t.errors.append.max_port,t.errors.append.max_range):1524===e?String.format(i,t.errors.append.max_port):1525===e?i+" : "+t.errors.append:1526===e?i+" : "+t.errors.append:i},saveRuleErrorHandler:function(e,t){this.statusUpdaterStop(),this.showSaveRuleErrorMessage(t)},confirmToChangeSetting:function(e,t,i,s){var n=e+"
    "+String.format(_T("routerconf","routerconf_goto_module"),_T("tree",i));this.module.appWin.getMsgBox().confirm(_T("tree","leaf_routerconf"),n,function(i){"yes"===i?this.module.appWin.startModule(t,s):this.getView().el.mask(e,"syno-ux-mask-info")},this)},startTestRules:function(e){var t=e.selectedRules,i=e.success_callback;this.module.appWin.sendWebAPI({api:"SYNO.Core.PortForwarding.Rules",version:1,method:"test",params:{selection:t?t.join(","):""},callback:function(e,t,s){e&&this.startPollTestRuleStatus({taskId:t.task_id,success_callback:i})},scope:this})},isPortsInRecord:function(e,t){var i;if(e&&t)return i=e+", "+t.data.router_port,SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.Conflict(i).length>0;SYNO.Debug("[Error] port="+e+" record="+t)},getRecordsInStoreByUserSelectedPorts:function(e){var t,i,s=[],n=this.getStore();if(!e||0>=e.length)return s;for(t=0;t=a.length)for(t=0;t=a.length)){for(t=0;t=e.length?(SYNO.Debug("impossible here: getRuleStatus() out of range"),"unkown"):e[t]},loadTestRuleResult:function(e){var t=this.getStore(),i="";e.rules&&t&&t.each(function(t){"fail"===(i=this.getRuleStatus(e.rules,t.get("rule_id")))&&!1===t.get("enable")&&(i="disabled"),t.set("rule_status",i)},this)},startPollTestRuleStatus:function(e){var t=e.taskId,i=e.success_callback,s={interval:3,immediate:!1,webapi:{api:"SYNO.Core.PortForwarding.Rules",version:1,method:"test_status",params:{task_id:t}},status_callback:function(e,t,s,n){if(e){if("wait"===t.status)return!0;this.loadTestRuleResult(t),"success"==t.status&&(i&&i(),this.testingStop(!0),this.isRuleStatusLoaded=!0)}else SYNO.Debug("polling test port connection, error occur, into error handling"),this.testPortConnErrorHandler(t.code,t)},scope:this};this.statusUpdaterStop(),this.changeState("testing"),this.testPortConnPollId&&(this.module.appWin.pollUnreg(this.testPortConnPollId),this.testPortConnPollId=null),this.testPortConnPollId=this.module.appWin.pollReg(s)},stopPollTestRuleStatus:function(e){this.testPortConnPollId&&(this.module.appWin.pollUnreg(this.testPortConnPollId),this.testPortConnPollId=null),e&&this.status_updater.Start()},getButton:function(e){return this.getTopToolbar().getComponent(e)},enableButton:function(e,t){var i=this.getButton(e);Ext.isObject(i)?t?i.enable():i.disable():SYNO.Debug("enableButton failed: no button object of ",e)},disableAllButton:function(){Ext.each(["router","create","del","test"],function(e){this.getButton(e).disable()},this)},maskAll:function(){this.disableAllButton(),this.el.mask()},onSetupRouter:function(){this.statusUpdaterStop();var e=this.networkInfoObj.getNetworkInfo().gateway,t=SYNO.SDS.Utils.Network.idToString(this.networkInfoObj.getNetworkInfo().gateway_info.ifname);new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.RouterWizard({module:this.module,owner:this.module.appWin,gateway:e,ifname:t}).onOpen({scope:this,callback:function(){this.isRouterChanged=!0,this.module.panel.loadAllForm(),this.doLayout(),this.updateGridEmptyText("no_rule")}})},onCreateRule:function(){new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.AddRuleWizard({module:this.module,owner:this.module.appWin,appWin:this.module.appWin,rule_store:this.getStore(),serviceDescObj:this.serviceDescObj,isSupportChangePort:this.routerConfInfoObj.getRouterConf().support_change_port,next_step_callback:this.updateUsedPortsAndShow,next_step_callback_scope:this}).open()},onDeleteRule:function(){var e=this.getSelectionModel().getSelections(),t=this.getStore(),i=0;for(i=0;i{let s="";e.dsPort.length>0&&(s=_T("routerconf","routerconf_header_ds_port")+_T("common","colon")+e.dsPort.toString()),e.routerPort.length>0&&(s=_T("routerconf","routerconf_header_router_port")+_T("common","colon")+e.routerPort.toString()),o+=String.format('
    {0}

    ',s),o+=String.format(_T("routerconf","routerconf_header_service")+_T("common","colon")+"{0} ({1})
    ",t.getServiceName(),t.getProtocol()),o+=String.format(_T("routerconf","routerconf_header_service")+_T("common","colon")+"{0} ({1})",i.getServiceName(),i.getProtocol())};for(let o=0;o0},isToPopUpOpenUPnPWriteAbilityMsgBox:function(e){var t=0;if(!e)return!1;if(!e.port_status)return!1;if(0===e.port_status.length)return!1;for(var i=0;i=0;l--){var d=o(s,l);r(i,n.getAt(l),d)}this.flag_show_warning_dialog=!0,this.module.panel.applyAllForm(this.module.panel.applyAllFormOptions)}else this.cancelFunction(e)}.bind(this)}).show()},saveSuccess:function(e){var t=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding;if(!(this.module.panel.applyAllFormOptions&&!1===this.module.panel.applyAllFormOptions.blDoSaveSuccessCallback||(this.store.loadRules(),Ext.isDefined(this.confirmLostChangeResolve)))){if(this.isUpnpRouter()&&this.isToPopUpOpenUPnPWriteAbilityMsgBox(e))return this.stopPollSaveRuleStatus(!0),this.changeState("normal"),void this.module.appWin.getMsgBox().alert(this.title,_T("routerconf","routerconf_may_not_enable_upnp_write"));t.Util.GetDisabledSystemServiceMsg(this.module.appWin,this.getStore(),this.showServiceMsg.bind(this)),this.isToPopUpPortStatus(e)?this.popUpPortConflictWindow(e):(this.changeState("normal"),this.onTestRule())}},startPollSaveRuleStatus:function(e){var t=e.taskId,i=e.success_callback;this.saveStatusConf={interval:1,immediate:!0,webapi:{api:"SYNO.Core.PortForwarding.Rules",version:1,method:"save_status",params:{task_id:t}},status_callback:function(e,t,s,n){var o=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.STATUS_SUCCESS,a=SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.STATUS_PROGRESS;e?a===t.status?(this.changeState("waiting"),this.showSaveRuleProgress(t)):o===t.status?(this.isRouterChanged=!1,this.changeState("normal"),i&&i(t),this.stopPollSaveRuleStatus(!0)):(SYNO.Debug("impossible here. data.status = "+t.status),this.changeState("normal"),this.stopPollSaveRuleStatus(!0)):(this.stopPollSaveRuleStatus(!0),this.showSaveRuleErrorMessage(t))},scope:this},this.statusUpdaterStop(),this.saveStatusConfPollId&&(this.module.appWin.pollUnreg(this.saveStatusConfPollId),this.saveStatusConfPollId=null),this.saveStatusConfPollId=this.module.appWin.pollReg(this.saveStatusConf)},showSaveRuleErrorMessage:function(e){var t=this.toSaveRuleErrorStringWithData(e.code,e);if(1528===e.code){var i=[];i.push(t),i.push(_T("routerconf","change_router_warn")),t=_T("routerconf","protocol_on_router_not_enabled_suggest")+this.getListHtml(i),new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.ForceSaveRulesDialog({owner:this.module.appWin,title:this.title,store:this.getStore(),errStr:t}).show()}else t=_T("routerconf","routerconf_apply_failed")+"
    "+t,this.module.appWin.getMsgBox().alert(this.title,t,function(){this.msg="",this.changeState("normal")},this)},stopPollSaveRuleStatus:function(e){this.saveStatusConfPollId&&(this.module.appWin.pollUnreg(this.saveStatusConfPollId),this.saveStatusConfPollId=null),this.hideSaveRuleProgress(),e&&this.status_updater.Start(),this.module.panel.deregisterProcessReturnData("portforwardingtab")},onTest:function(){0!==this.getStore().getCount()&&(0!==this.getSelectionModel().getSelections().length||0!==this.store.getEnabledRules().length?this.onTestRule():this.module.panel.setStatusError({text:_T("routerconf","routerconf_no_enabled_rule_for_test"),clear:!0}))},onTestRule:function(e){var t=this.getSelectionModel().getSelections();this.getStore().load({callback:function(){this.testingStart({selectedRecords:t,success_callback:e})},scope:this})}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.ForceSaveRulesDialog",{extend:"SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.ConfirmDialog",constructor:function(e){var t=Ext.apply({fbar:[{xtype:"syno_button",text:_T("common","ok"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.onClickApply}],items:[{xtype:"syno_displayfield",cls:"dialog-title",value:_T("routerconf","routerconf_apply_failed")},{xtype:"syno_displayfield",htmlEncode:!1,value:e.errStr,style:{"margin-bottom":"6px"}},{xtype:"syno_checkbox",boxLabel:_T("routerconf","force_save_rules"),itemId:"force_save_rules"}]},e);this.callParent([t])},onClickApply:function(){this.getComponent("force_save_rules").getValue()?(this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.PortForwarding.Rules",version:1,method:"force_save",params:{rules:this.store.getRules()},callback:function(e,t,i){this.clearStatusBusy(),e?(this.store.loadRules(),this.close()):this.getMsgBox().alert(this.title,SYNO.API.getErrorString(t.code))},scope:this})):this.close()}}),Ext.ns("SYNO.SDS.AdminCenter.PublicAccess"),SYNO.SDS.AdminCenter.PublicAccess.DEFAULT_PASSWORD="12345678",SYNO.SDS.AdminCenter.PublicAccess.CN_PROVIDER_ORDER=["DNSPod.cn","Oray.com","TencentCloud"],SYNO.SDS.AdminCenter.PublicAccess.CERTIFICATE_PROVIDER={le:"Let's Encrypt",tencent:"Tencent Cloud"},Ext.define("SYNO.SDS.AdminCenter.PublicAccess.DDNSTab",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.module=e.module;var t=this.fillConfig(e);this.callParent([t]),this.getInitInfoArray=[{api:"SYNO.Core.DDNS.Provider",version:1,method:"list"},{api:"SYNO.Core.DDNS.Record",version:1,method:"list"},{api:"SYNO.Core.DDNS.ExtIP",version:2,method:"list"},{api:"SYNO.Core.Certificate.CRT",version:1,method:"list"},{api:"SYNO.Core.DDNS.Ethernet",version:1,method:"list"},{api:"SYNO.Core.Network.PPPoE",version:1,method:"list"}],this.getInfoArray=[{api:"SYNO.Core.DDNS.Provider",version:1,method:"list"},{api:"SYNO.Core.DDNS.Record",version:1,method:"list"},{api:"SYNO.Core.DDNS.ExtIP",version:2,method:"list",retry:!0},{api:"SYNO.Core.DDNS.Synology",version:1,method:"get_myds_account"},{api:"SYNO.Core.Certificate.CRT",version:1,method:"list"},{api:"SYNO.Core.DDNS.Ethernet",version:1,method:"list"},{api:"SYNO.Core.Network.PPPoE",version:1,method:"list"}],this.getRecordInfo=[{api:"SYNO.Core.DDNS.Record",version:1,method:"list"}],this.btnDel=this.getTopToolbar().getComponent("del"),this.btnUpdate=this.getTopToolbar().getComponent("update"),this._S("demo_mode")&&(this.btnDel.setTooltip(_JSLIBSTR("uicommon","error_demo")),this.btnUpdate.setTooltip(_JSLIBSTR("uicommon","error_demo"))),this.getInfoConf={interval:5,immediate:!0,webapi:{api:"SYNO.Entry.Request",version:1,method:"request",params:{mode:"parallel",stopwhenerror:!1,compound:this.getInfoArray}},status_callback:this.getInfoDone,scope:this}},fillConfig:function(e){this.store=new SYNO.SDS.AdminCenter.PublicAccess.DDNSInfoStore(e),this.createActions();var t=[this.getAction("add"),this.getAction("edit"),this.getAction("del"),this.getAction("update"),this.getAction("advanced")],i=new Ext.Toolbar({defaultType:"syno_button",items:t}),s=new Ext.grid.ColumnModel({defaults:{sortable:!1},columns:[{header:_T("service","service_ddns_type"),dataIndex:"display",width:130},{header:_T("service","service_ddns_hostname"),dataIndex:"hostname",width:180},{header:_T("service","service_wanconfig_gateway_addr_out"),dataIndex:"ip",width:270},{header:_T("service","service_wanconfig_status"),dataIndex:"status",useHtmlEncodeRender:!1,width:120},{header:_T("service","service_ddns_last_updated"),dataIndex:"lastupdated",useHtmlEncodeRender:!1,width:150}]}),n={title:_T("tree","leaf_wanconfig"),heigh:400,colModel:s,store:this.store,cls:"syno-publicaccess-ddns-gridpanel",viewConfig:{emptyText:['
    ','
    ','
    ','
    ','
    ',_T("common","no_item"),"
    ","
    ","
    ","
    "].join("")},tbar:i,bbar:this.createBBar(),listeners:{scope:this,activate:this.onActivate,deactivate:this.deactivate,click:this.checkState,rowdblclick:this.editHandler,rowcontextmenu:this.onRowCtxMenu,containercontextmenu:this.showCtxMenu},selModel:new Ext.grid.RowSelectionModel({singleSelect:!1})};return Ext.apply(n,e),n},createBBar:function(){return new SYNO.ux.PageLessToolbar({store:this.store,displayInfo:!0,doRefresh:function(e){this.module.appWin.setStatusBusy(),this.getRecord()}.bind(this)})},getHelpParam:function(){return"AdminCenter/connection_ddns.html"},createActions:function(){var e=function(e,t,i,s,n){return new Ext.Action(Ext.apply({text:e,itemId:t,scope:s,handler:i},n))};return this.actions={add:e(_T("common","add"),"add",this.addHandler,this),edit:e(_T("common","alt_edit"),"edit",this.editHandler,this),del:e(_T("common","delete"),"del",this.deleteHandler,this),update:e(_T("time","ntp_updatenow"),"update",this.refreshHandler,this),advanced:e(_T("service","service_ddns_customize"),"advanced",this.advancedHandler,this)},this.actions},getAction:function(e){return e in this.actions?this.actions[e]:void SYNO.Debug("no this action: "+e)},enableAction:function(e,t){var i=this.getAction(e);i&&i[t?"enable":"disable"]()},checkState:function(){var e=this.store.getCount(),t=this.getSelectionModel().getCount();this.enableAction("edit",1==t),this.enableAction("del",0"),e.push(this.getSelectionModel().getSelections()[i].data.provider),t+=this.getSelectionModel().getSelections()[i].data.hostname;this.pollingTaskStop(),this.module.appWin.getMsgBox().confirmDelete(_T("tree","leaf_wanconfig"),_T("service","service_ddns_delete_warning")+"

    "+t+"

    ",function(t){"yes"==t&&this.sendDelCmd(e)},this)}},refreshHandler:function(){this.module.appWin.setStatusBusy(),this.pollingTaskStop(),this.sendWebAPI({api:"SYNO.Core.DDNS.Record",method:"update_ip_address",version:1,scope:this,params:null,callback:function(e,t,i){this.pollingTaskStart(),this.module.appWin.clearStatusBusy()}})},advancedHandler:function(){var e=new SYNO.SDS.AdminCenter.PublicAccess.DDNSAdvancedDialog({owner:this.module.appWin,module:this,providers:this.providers});this.mon(e,"close",function(){this.pollingTaskStart()},this),this.pollingTaskStop(),e.open({scope:this})},onActivate:function(){this.triggered_onActivate=!0,this.pollingTaskStop(),this.module.appWin.setStatusBusy(),this.myDSAccount="NO_MY_DS_ACCOUNT",this.pollingTaskStart(),this.getInfo()},deactivate:function(){this.triggered_onActivate=!1,this.pollingTaskStop()},providerNameComp:function(e,t){return e.displayt.display?1:0},getRecord:function(){this.sendWebAPI({params:{},scope:this,compound:{stopwhenerror:!1,params:this.getRecordInfo},callback:this.getInfoDone})},getInfo:function(){var e=this;setTimeout(function(){"NO_MY_DS_ACCOUNT"===e.myDSAccount&&e.sendWebAPI({params:{},scope:e,compound:{stopwhenerror:!1,params:e.getInitInfoArray},callback:e.getInfoDone})},3e3)},getInfoDone:function(e,t,i){if(this.myDSAccountLogin=!1,this.myDSAccount="NO_MY_DS_ACCOUNT",void 0!==t&&void 0!==t.result&&void 0!==t.result.length){for(var s=0;s'+_T("myds","error_query_info")+""),this.updateStoreData(),this.checkState(),this.triggered_onActivate&&this.module.appWin.clearStatusBusy()}else this.module.appWin.clearStatusBusy()},updateStoreData:function(){for(var e=this.getSelectionModel(),t=[],i=[],s="-",n=0;n=0&&(o=e.splice(a,1),e.splice(0,0,o[0])),r>=0&&(o=e.splice(r,1),e.splice(0,0,o[0])),e},SYNO.SDS.AdminCenter.PublicAccess.formatIP=function(e){return"0.0.0.0"===e||"0:0:0:0:0:0:0:0"===e||null===e||""===e?"-":e},SYNO.SDS.AdminCenter.PublicAccess.DDNSGetDisplayName=function(e,t){for(var i=0;i'+s+""},Ext.define("SYNO.SDS.AdminCenter.PublicAccess.DDNSInfoStore",{extend:"Ext.data.JsonStore",constructor:function(e){var t=Ext.apply({autoDestroy:!0,fields:["provider","display","hostname","ip","status","lastupdated"],data:[]},e);this.callParent([t])}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.RegisterOrLoginDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.provider=e.provifer,this.isRegister=e.isRegister,this.linkMsg=e.linkMsg,this.webLink=e.webLink;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={title:e.title,width:505,height:e.isRegister?300:260,layout:"fit",items:[this.getFormPanel(e)],buttons:[{text:_T("common","cancel"),scope:this,handler:this.close},this.registerBtn=new SYNO.ux.Button({text:e.isRegister?_T("common","ok"):_T("common","login"),btnStyle:"blue",scope:this,handler:this.onApplyClick})]};return Ext.apply(t,e),t},getFormPanel:function(e){var t={items:[{xtype:"syno_displayfield",value:e.desc},{xtype:"syno_textfield",fieldLabel:_T("user","user_email"),allowBlank:!1,minLength:3,maxLength:256,vtype:"email",vtypeText:_JSLIBSTR("vtype","bad_email"),name:"account"},{xtype:"syno_textfield",fieldLabel:_T("common","password"),textType:"password",minLength:6,maxLength:128,allowBlank:!1,name:"password"},{xtype:"syno_textfield",fieldLabel:_T("login","forget_pass_comfirm_password"),textType:"password_confirm",name:"password_confirm",allowBlank:!1,hidden:!e.isRegister,disabled:!e.isRegister,confirmFor:"password"},{border:!1,layout:{type:"hbox",pack:"end"},items:[{xtype:"syno_button",cls:"myds-link-btn",text:this.linkMsg,scope:this,handler:this.onLinkClick}]}]};return this.formPanel=new SYNO.ux.FormPanel(t),this.formPanel},onLinkClick:function(){this.isRegister?(new SYNO.SDS.AdminCenter.PublicAccess.RegisterOrLoginDialog({owner:this.owner,provider:this.provider,title:_T("common","login"),desc:String.format(_T("service","service_ddns_desc_enter_account"),this.provider),isRegister:!1,linkMsg:_T("service","service_ddns_forget_password"),webLink:this.webLink}).show(),this.close()):window.open(this.webLink,"_blank")},onApplyClick:function(){var e=this.formPanel.getForm();e.isValid()?(this.owner.setUsernameAndPasswd(this.owner,e.findField("account").getValue(),e.findField("password").getValue(),this.provider),this.close()):this.setStatusError({text:_T("common","forminvalid"),clear:!0})}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.DDNSRecordDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){if(this.owner=e.owner,this.module=e.module,this.providers=e.providers,this.records=e.records,this.myDSAccountLogin=e.myDSAccountLogin,this.myDSAccount=e.myDSAccount,this.selected=e.selected,this.action=e.action,this.ipAddrs=e.ipAddrs,this.interfaces=e.interfaces,this.selected_unreg_records=[],this.title=_T("service","service_ddns_add_record"),this.certificates=e.certificates,this.defaultCert=e.defaultCert,this.certServices=e.certServices,this.panel=new SYNO.SDS.AdminCenter.PublicAccess.DDNSRecordForm(e),this.testConBtn=e.testConBtn,this.customBtn=e.customBtn,this.serviceField=this.panel.getForm().findField("enable"),this.serviceFieldWithoutCheckbox=this.panel.getForm().findField("ddns_description"),this.providerField=this.panel.getForm().findField("ddns_provider_list"),this.providerField.getStore().loadData(this.providers,!1),this.selectedProviderField=this.panel.getForm().findField("ddns_selected_provider"),this.hostnameField=this.panel.getForm().findField("hostname"),this.synoHostnameField=this.panel.getForm().findField("syno_hostname"),this.domainList=this.panel.getForm().findField("ddns_domain_list"),this.TWNIC_hostnameField=this.panel.getForm().findField("twnic_hostname"),this.TWNIC_domainList=this.panel.getForm().findField("ddns_twnic_domain_list"),this.usernameField=this.panel.getForm().findField("username"),this.mydsAccountField=this.panel.getForm().findField("mydsAccount"),this.showAccountField=this.panel.getForm().findField("showAccount"),this.passwdField=this.panel.getForm().findField("passwd"),this.netV4Row=this.panel.getForm().findField("ddns_net_IPv4_row"),this.netV6Row=this.panel.getForm().findField("ddns_net_IPv6_row"),this.netField=this.panel.getForm().findField("net"),this.netV4Field=this.panel.getForm().findField("net_ipv4"),this.netV6Field=this.panel.getForm().findField("net_ipv6"),this.interfaceV4Field=this.panel.getForm().findField("interface_v4"),this.interfaceV6Field=this.panel.getForm().findField("interface_v6"),this.certificateField=this.panel.getForm().findField("certificate"),this.certificateNoteField=this.panel.getForm().findField("certificate_note"),this.heartbeatField=this.panel.getForm().findField("heartbeat"),this.providerWebsite=this.panel.getForm().findField("provider_website"),this.statusField=Ext.getCmp("status"),this.note=this.panel.getForm().findField("note_info"),this.synoDomainList=this.getSynoDomainList(),this.oldServiceEnable=null,this.lastSelected=-1,"Synology"===this.providerField.getValue()&&this.myDSAccount){var t=this.myDSAccount.indexOf(">")+1,i=this.myDSAccount.indexOf("<",t);this.myDSAccount=this.myDSAccount.slice(t,i)}"edit"===this.action&&(this.title=_T("service","service_ddns_edit_record")),this.panel.mon(this.providerField,"select",function(e){if(this.oldServiceEnable=this.serviceField.getValue(),this.lastSelected>=0&&(this.records[this.lastSelected].service=this.oldServiceEnable,this.records[this.lastSelected].hostname=this.hostnameField.getValue(),this.records[this.lastSelected].username=this.usernameField.getValue(),this.records[this.lastSelected].passwd=this.passwdField.getValue(),this.records[this.lastSelected].net=this.getNetFieldValue(),this.records[this.lastSelected].netV4=this.getIpFieldValue(this.netV4Field),this.records[this.lastSelected].netV6=this.getIpFieldValue(this.netV6Field),this.records[this.lastSelected].interfaceV4=this.interfaceV4Field.getValue(),this.records[this.lastSelected].interfaceV6=this.interfaceV6Field.getValue(),this.records[this.lastSelected].heartbeat=this.heartbeatField.getValue()),"add"===this.action&&this.selectedProviderRegistered(this.providerField.getValue()))return this.getMsgBox().alert(_T("tree","leaf_wanconfig"),_T("service","service_ddns_one_hostname_for_a_provider")),void this.setFieldAndOriginalValues(this.providerField,"");this.loadSelectedInfo(this.providerField.getValue()),this.netV4Field.isValid(),this.netV6Row.hidden||this.netV6Field.isValid(),this.monitorCertOnHostChange(e.getValue())},this),this.panel.mon(this.domainList,"select",this.checkCertificateFieldDisable.bind(this),this),this.synoHostnameField.on("keyup",this.checkCertificateFieldDisable.bind(this)),this.synoHostnameField.on("blur",this.checkCertificateFieldDisable.bind(this)),this.panel.mon(this.serviceField,"check",function(){this.serviceCheckHandler(),this.changeApplyBtnStatus()},this),this.panel.mon(this.hostnameField,"invalid",function(){"Oray.com"!=this.providerField.getValue()||""===this.hostnameField.getValue()||/[\x20]/.test(this.hostnameField.getValue())||this.hostnameField.clearInvalid()},this),this.initTestConBtn(),this.initCustomBtn();var s=Ext.apply({title:this.title,width:760,height:520,layout:"fit",resizable:!1,items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:function(){this.close()}},{btnStyle:"blue",itemId:"recordApply",text:_T("common","apply"),disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this,handler:this.apply}]},e);this.myDSAccountLogin||this.sendWebAPI({api:"SYNO.Core.DDNS.Synology",method:"get_myds_account",version:1,scope:this,callback:function(e,t,i){e?"NO_MY_DS_ACCOUNT"!==t.email&&(this.myDSAccountLogin=!0,this.myDSAccount=t.email,this.setFieldAndOriginalValues(this.mydsAccountField,this.getAccountFieldLink(this.myDSAccount))):this.getMsgBox().alert(_T("tree","leaf_wanconfig"),_T("service","service_ddns_operation_fail"))}}),SYNO.SDS.AdminCenter.PublicAccess.DDNSRecordDialog.superclass.constructor.call(this,s),this.mon(this,"beforeclose",this.onBeforeClose,this)},showCertificateInfo:function(e){this.certificateField.boxlabelEl.update(String.format(_T("service","service_ddns_syno_create_cert"),e)),this.setFieldAndOriginalValues(this.certificateNoteField,String.format(_T("service","service_ddns_syno_create_cert_note"),e)),this.certificateField.show(),this.certificateNoteField.show()},hideCertificateInfo:function(){this.certificateField.setValue(!1),this.certificateField.hide(),this.certificateNoteField.hide()},onClose:function(){this.SAWebLogin&&this.SAWebLogin.cancel()},onBeforeClose:function(){return this.panel.getForm().isDirty=this.isDirty,this.panel.getForm().isDirty(!0)?(this.getMsgBox().confirm("",_T("common","confirm_lostchange_without_save"),function(e){if("leftCustom"===e){for(var t=0;t'+t+" Support ");this.owner.getMsgBox().alert(_T("tree","leaf_wanconfig"),s)}},this),SYNO.ux.AddTip(this.heartbeatField.getEl(),_T("service","service_ddns_heartbeat_help"));const t=!this.selected||"Synology"===this.selected;this.netV4Field.getStore().loadData(this.getIpStoreData("ip",t),!1),this.netV6Field.getStore().loadData(this.getIpStoreData("ipv6",!0),!1),this.setFieldAndOriginalValues(this.netField,"DEFAULT");var i="";i=SYNO.SDS.AdminCenter.PublicAccess.formatIP(this.ipAddrs.ip),this.setFieldAndOriginalValues(this.netV4Field,i),this.netV4Field.setValue(`${_T("common","auto")} (${this.netV4Field.getValue()})`),"-"==(i=SYNO.SDS.AdminCenter.PublicAccess.formatIP(this.ipAddrs.ipv6))&&this.netV6Row.hide(),this.setFieldAndOriginalValues(this.netV6Field,i),this.netV6Field.setValue(`${_T("common","auto")} (${this.netV6Field.getValue()})`),this.setFieldAndOriginalValues(this.interfaceV4Field,"default"),this.setFieldAndOriginalValues(this.interfaceV6Field,"default"),"edit"==this.action&&(this.serviceField.show(),this.serviceFieldWithoutCheckbox.hide(),this.loadSelectedInfo(this.selected),this.setFieldAndOriginalValues(this.selectedProviderField,this.selected),this.checkCertificateFieldDisable(),this.monitorCertOnHostChange(this.selected)),this.panel.getForm().clearInvalid(),this.hostnameField.clearInvalid()},regAndTest:function(e){this.afterRegMyDSAccount(e),this.testCon()},testCon:function(e,t){if(!this.checkAndDoRegMyDSAccount(this.regAndTest)){var i=this.panel.getForm();if(this.CheckFieldValid(i)){"Synology"===this.providerField.getValue()?this.hostnameField.setValue(this.synoHostnameField.getValue()+"."+this.domainList.getValue()):"TWNIC"===this.providerField.getValue()&&this.hostnameField.setValue(this.TWNIC_hostnameField.getValue()+"."+this.TWNIC_domainList.getValue());var s={enable:!0,provider:this.providerField.getValue(),hostname:this.hostnameField.getValue(),username:this.usernameField.getValue(),net:this.getNetFieldValue(),ip:"-"===this.getIpFieldValue(this.netV4Field)?"0.0.0.0":this.getIpFieldValue(this.netV4Field),ipv6:"-"===this.getIpFieldValue(this.netV6Field)?"0:0:0:0:0:0:0:0":this.getIpFieldValue(this.netV6Field),interface_v4:this.interfaceV4Field.getValue(),interface_v6:this.interfaceV6Field.getValue(),heartbeat:this.heartbeatField.getValue()};"Synology"===this.providerField.getValue()?s.passwd="Synology":this.passwdField.isDirty()&&(s.passwd=this.passwdField.getValue()),this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.DDNS.Record",method:"test",version:1,scope:this,params:s,callback:function(e,t,i){if(this.clearStatusBusy(),e){var s=SYNO.SDS.AdminCenter.PublicAccess.DDNSTransferStatus(this,t.status,t.provider);this.setFieldAndOriginalValues(this.statusField,s),this.doLayout()}else{this.statusField.setValue("--"),this.doLayout();var n=String.format(_T("service","service_ddns_test_connection_fail"),'',"");this.body.mask(),this.getMsgBox().alert(_T("tree","leaf_wanconfig"),n,function(e){this.body.unmask()},this)}}})}else this.setStatusError({text:_T("common","forminvalid"),clear:!0})}},initTestConBtn:function(){this.testConBtn.mon(this.testConBtn,"click",this.testCon,this)},customDialogHandler:function(){var e=new SYNO.SDS.AdminCenter.PublicAccess.DDNSAdvancedDialog({owner:this,module:this.module,providers:this.providers});this.mon(e,"close",function(){this.sendWebAPI({params:{},scope:this,compound:{stopwhenerror:!1,params:[{api:"SYNO.Core.DDNS.Provider",version:1,method:"list"}]},callback:function(e,t,i){e&&(this.providers=t.result[0].data.providers,this.providers=SYNO.SDS.AdminCenter.PublicAccess.DDNSApplyCustomProviders(this.providers,this._S("lang"),this.providerNameComp),this.ddnsProviderList.getStore().loadData(this.providers,!1))}})},this),e.open({scope:this})},initCustomBtn:function(){this.customBtn.mon(this.customBtn,"click",this.customDialogHandler,this)},CheckFieldValid:function(e){var t=!0,i=e.findField("ddns_provider_list").getValue();"Oray.com"!==i&&"Synology"!==i&&"TWNIC"!==i&&(t=t&&e.findField("hostname").isValid()),"Synology"===i&&(t=t&&e.findField("syno_hostname").isValid()),"TWNIC"===i&&("idv.tw"===this.TWNIC_domainList.getValue()?/[a-zA-Z0-9]/.test(e.findField("twnic_hostname").getValue())||(e.findField("twnic_hostname").markInvalid("a-zA-Z0-9"),t=!1):""===e.findField("twnic_hostname").getValue()&&(t=!1)),""!==i&&e.findField("username").isValid()&&e.findField("passwd").isValid()||(t=!1);var s=e.findField("net_ipv4"),n=e.findField("net_ipv6"),o=e.findField("ddns_net_IPv6_row");return s.isValid()||(t=!1),o.hidden||n.isValid()||(t=!1),t},setFieldAndOriginalValues:function(e,t){e.setValue(t),e.originalValue=e.getValue()},getNetFieldValue:function(e){var t=this.interfaceV4Field.getValue(),i="default"===this.interfaceV6Field.getValue();return"default"===t?i?"DEFAULT":"MANUAL_V6":i?"MANUAL_V4":"MANUAL"},getIpFieldValue:function(e){return e.newValue?e.newValue:e.originalValue},getAccountFieldLink:function(e,t){return''+String.format(e,t)+""},setElementTip:function(e,t){Ext.QuickTips.register({target:e,text:t})},checkCertificateFieldDisable:function(){var e=SYNO.SDS.AdminCenter.PublicAccess.CERTIFICATE_PROVIDER,t="Synology"===this.providerField.getValue()?this.synoHostnameField.getValue()+"."+this.domainList.getValue():this.hostnameField.getValue(),i="TencentCloud"===this.providerField.getValue()?e.tencent:"Synology"===this.providerField.getValue()?e.le:"",s=!1;this.certServices.forEach(function(e){e.old_id===this.defaultCert.id||(s=!0)},this),Ext.QuickTips.unregister(this.certificateField.boxlabelEl),this.serviceField.hidden||this.serviceField.getValue()?s||t.toLowerCase()!==this.defaultCert.subject.common_name.toLowerCase()?this.certificateField.setDisabled(!1):(this.certificateField.setDisabled(!0),this.setElementTip(this.certificateField.boxlabelEl,String.format(_T("service","service_ddns_syno_cert_issued"),t,i))):this.certificateField.setDisabled(!0)},setIpFieldInitValue:function(e,t,i){var s="ipv6"===i,n=s?t.interface_v6:t.interface_v4,o=t.ip||"",a=t.ipv6||"",r=s?a:o,l=e.getStore(),d=s?"interfaceV6":"interfaceV4",c=!1,h=SYNO.SDS.AdminCenter.PublicAccess.formatIP(r),u=h;if(""===n){let e=s?"MANUAL_V4":"MANUAL_V6";("DEFAULT"===t.net||t.net===e)&&(n="default",c=!0)}else c=!0;if(c){let e=l.query(d,n);if(0'+_T("service","service_ddns_provider_website")+"";this.setFieldAndOriginalValues(this.providerWebsite,r),this.providerWebsite.show()}else this.providerWebsite.hide();this.changeApplyBtnStatus(),"TWNIC"===e?(this.setFieldAndOriginalValues(this.note,''+_T("service","service_ddns_note")+": "+_T("service","service_ddns_twnic_note")),this.note.show()):this.note.hide(),this.panel.getForm().clearInvalid(),this.hostnameField.clearInvalid()},getSynoDomainList:function(){return["synology.me","DiskStation.me","i234.me","myDS.me","DSCloud.biz","DSCloud.me","DSCloud.mobi","DSmyNAS.com","DSmyNAS.net","DSmyNAS.org","FamilyDS.com","FamilyDS.net","FamilyDS.org"]},getDomainList:function(){var e=this.synoDomainList.map(function(e){return{value:e,display:e}});this.domainList.getStore().loadData(e,!1)},getIpStoreData:function(e,t){const i="ipv6"===e,s=this.ipAddrs&&this.ipAddrs.ip?this.ipAddrs.ip:"-",n=this.ipAddrs&&this.ipAddrs.ipv6?SYNO.SDS.AdminCenter.PublicAccess.formatIP(this.ipAddrs.ipv6):"-",o=i?n:s,a=`${_T("common","auto")} (${SYNO.SDS.AdminCenter.PublicAccess.formatIP(o)})`,r={display:a,value:a,newValue:o,interfaceV4:"default",interfaceV6:"default"},l=this.interfaces.map(e=>{const t=e.ifname||"",s=SYNO.SDS.Utils.Network.idToString(t);let n="-",o="";return i?Array.isArray(e.ipv6)&&00)return!0}return!1},setAndUpdateRec:function(){var e={id:"add"==this.action?null:this.selected,enable:this.serviceField.getValue(),provider:this.providerField.getValue(),hostname:this.hostnameField.getValue(),username:this.usernameField.getValue(),net:this.getNetFieldValue(),ip:"-"===this.getIpFieldValue(this.netV4Field)?"0.0.0.0":this.getIpFieldValue(this.netV4Field),ipv6:"-"===this.getIpFieldValue(this.netV6Field)?"0:0:0:0:0:0:0:0":this.getIpFieldValue(this.netV6Field),interface_v4:this.interfaceV4Field.getValue(),interface_v6:this.interfaceV6Field.getValue(),heartbeat:this.heartbeatField.getValue()};"Synology"===this.providerField.getValue()?e.passwd="Synology":(this.passwdField.isDirty()||"add"==this.action)&&(e.passwd=this.passwdField.getValue()),this.sendWebAPI({params:{},scope:this,compound:{stopwhenerror:!0,params:[{api:"SYNO.Core.DDNS.Record",version:1,method:"add"==this.action?"create":"set",params:e},{api:"SYNO.Core.DDNS.Record",version:1,method:"update_ip_address",params:{id:this.providerField.getValue()}}]},callback:this.applyFunCallback})},isAbleToApply:function(){return this.providerField?!!this.providerField.getValue()&&(!("add"==this.action&&!this.serviceField.getValue())&&("Synology"!==this.providerField.getValue()||!this._S("demo_mode"))):(SYNO.Debug("this.providerField is empty"),!1)},regAndApply:function(e){this.afterRegMyDSAccount(e),this.apply()},isDirty:function(e){for(var t=this.findFields(),i=0;i'+String.format(_T("service","service_ddns_syno_set_default_cert_notification"),i)+"

    ",s+=_T("service","service_ddns_syno_set_default_cert_service_invalid"),this.getMsgBox().confirm(_T("tree","leaf_wanconfig"),s,function(e){"yes"==e?n():this.clearStatusBusy()},this,{yes:{text:_T("common","apply")},no:{text:_T("common","cancel")}})):n()):this.close()):this.setStatusError({text:_T("common","forminvalid"),clear:!0})},isDefaultCertChanged:function(){return!this.certificateField.hidden&&!this.certificateField.disabled&&this.certificateField.checked},applyFunCallback:function(e,t,i){for(var s=0;s{const i={api:"SYNO.Core.DDNS.Record",method:"list",version:1},s=n=>{n&&n.data&&n.data.records&&Ext.each(n.data.records,function(n){if("TencentCloud"===n.id)return"service_ddns_normal"===n.status?(SYNO.SDS.SocketInst.unregister(i,s),e()):"loading"!==n.status&&(SYNO.SDS.SocketInst.unregister(i,s),t(n.status)),!1})};SYNO.SDS.SocketInst.register(i,s,!0),setTimeout(t.bind(this,"timeout"),3e4)}).then(this.createCertificate.bind(this,a)).catch(SYNO.Debug))),o.then(function(){this.clearStatusBusy(),this.mun(this,"beforeclose",this.onBeforeClose,this),this.close()}.bind(this))},selectedProviderRegistered:function(e){for(var t=0;t','','
    ',"
    ",'
    ',"{display}","
    ",""].join("");const c=function(e){const t="ipv6"===e,i=t?"interface_v6":"interface_v4",s=t?"interfaceV6":"interfaceV4";return{scope:this,blur:{fn:function(e){const t=e.getStore(),n=this.getForm().findField(i),o=n.getValue();let a=e.getValue(),r=a;if(t.clearFilter(),""===a&&(a="-",r="-","-"!==e.newValue&&n.setValue("disabled")),""!==o){const e=t.query(s,o);if(01)return _T("service","service_ddns_dup_customized_provider");return!0},listeners:{render:function(e){e.getEl().set({spellcheck:!1})},valid:function(){e.owner.isValid(!0)},invalid:function(){e.owner.isValid(!0)}}}),this.urlField=new SYNO.ux.TextArea({autoFlexcroll:!1,name:"url",minLength:1,maxLength:500,width:480,height:48,style:"margin-right: 6px; overflow: hidden;",value:e.url||"",maskRe:/[a-zA-Z0-9\-._:/\\&#?]/,validator:function(e){return-1===e.indexOf(" ")&&-1===e.indexOf(";")},listeners:{render:function(e){e.getEl().set({spellcheck:!1})},valid:function(){e.owner.isValid(!0)},invalid:function(){e.owner.isValid(!0)}}}),this.removeBtn=new SYNO.ux.Button({cls:"syno-ddns-remove-button",scope:this,handler:function(){e.owner.removeField(this.id)}})]};e.notRemove&&this.removeBtn.setDisabled(!0),this.callParent([Ext.apply(t,e)])},focusTextFiled:function(){this.providerField.focus()},isValid:function(e){var t=this.providerField.isValid(e),i=this.urlField.isValid(e);return t&&this.providerField.clearInvalid(),i&&this.urlField.clearInvalid(),t&&i},isEmpty:function(){var e=this.providerField,t=this.urlField,i=e.rendered?e.getValue():e.value,s=t.rendered?t.getValue():t.value;return""===i||""===s},clearInvalid:function(){this.providerField.clearInvalid(),this.urlField.clearInvalid()}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.ProvidersForm",{extend:"SYNO.ux.Panel",constructor:function(e){var t={border:!1,cls:"syno-ddns-providers-form-wrapper",autoFlexcroll:!0,items:[{xtype:"container",cls:"syno-ddns-providers-header",width:"100%",items:[{xtype:"box",width:200,style:"margin-right: 6px; margin-bottom: 2px; line-height: 20px; padding-top: 4px; padding-bottom: 4px",html:_T("service","service_ddns_type")+_T("common","colon")},{xtype:"box",width:480,style:"margin-bottom: 2px; line-height: 20px; padding-top: 4px; padding-bottom: 4px",html:"Query URL"+_T("common","colon")}]},this.formPanel=new SYNO.ux.FormPanel({cls:"syno-ddns-providers-form",autoHeight:!0,border:!1,frame:!1,width:"100%",items:[new SYNO.SDS.AdminCenter.PublicAccess.ButtonTextField({owner:this,notRemove:!1})]}),this.addFieldButton=new SYNO.ux.Button({style:"margin-top: 6px;",text:_T("common","add_field"),disabled:!0,handler:function(){this.addFieldButton.setDisabled(!1);var e=new SYNO.SDS.AdminCenter.PublicAccess.ButtonTextField({owner:this});this.formPanel.add(e),this.formPanel.doLayout(),this.syncSize(),this.scrollToEnd(),e.focusTextFiled()},scope:this}),{width:"100%",xtype:"box",html:'
    '+_T("service","ddns_available_macros")+'
    '+_T("service","service_ddns_hostname")+_T("common","colon")+'__HOSTNAME__
    '+_T("common","ipv4_addr")+_T("common","colon")+'__MYIP__
    '+_T("service","service_ddns_username")+"/"+_T("service","service_ddns_email")+_T("common","colon")+'__USERNAME__
    '+_T("service","service_ddns_passwd")+"/"+_T("service","service_ddns_auth_key")+_T("common","colon")+'__PASSWORD__
    '+_T("service","example")+'
    Query URL'+_T("common","colon")+'https://ddns.provider.org/update?hostname=__HOSTNAME__&myip=__MYIP__
    '}]};this.callParent([Ext.apply(t,e)])},setValues:function(e){0!==e.length&&(this.formPanel.removeAll(),e.forEach(function(e){var t=new SYNO.SDS.AdminCenter.PublicAccess.ButtonTextField({provider:e.provider,display:e.display,url:e.url,owner:this});this.formPanel.add(t)},this),this.originalCount=e.length,this.setDisabledAdd(!1),this.formPanel.doLayout(),this.syncSize())},scrollToEnd:function(){var e=this.getScrollTarget().dom.fleXcroll;e.formUpdate(),e.updateScrollBars();var t=this.getContentTarget().child(".contentwrapper").getHeight();e.scrollContent(0,t)},isValid:function(e){var t=this.formPanel.items.items;if(0===t.length)return!0;if(this.onValidCheck)return!1;this.onValidCheck=!0;var i=t[t.length-1],s=this.formPanel.getForm().isValid(e);return this.setDisabledAdd(i.isEmpty()||!s),this.onValidCheck=!1,s},setFieldAllowBlank:function(e){for(var t=0;t=0;t--)0===this.providers[t].provider.search("USER_")?this.providers[t].display=this.providers[t].provider.replace("USER_",""):this.providers.splice(t,1);this.providersForm.setValues(this.providers)},apply:function(){if(this.providersForm.isDirty())if(this.providersForm.setFieldAllowBlank(!1),this.providersForm.isValid()){var e=this.providersForm.getValues(),t=[];if(e.provider)for(var i=0;ia?1:o'+_T("common","note")+':
    '+_T("relayservice","inside_tunnel_msg")+""},{xtype:"syno_fieldset",title:_T("relayservice","misc"),cls:"syno_quickconnect_fieldset",collapsible:!1,items:[{xtype:"syno_checkbox",id:this.field_relay_enabled=Ext.id(),name:"relay_enabled",value:!0,boxLabel:_T("relayservice","relay_enabled"),indent:0},{xtype:"syno_displayfield",indent:1,name:"relay_enabled_desc",value:_T("relayservice","relay_enabled_desc")},{xtype:"syno_checkbox",id:this.field_portforward_enabled=Ext.id(),name:"portforward_enabled",value:!this.isInAliDSM,disabled:this.isInAliDSM,boxLabel:_T("relayservice","enable_portforward"),indent:0},{xtype:"syno_displayfield",indent:1,name:"enable_portforward_tip_desc",disabled:this.isInAliDSM,value:_T("relayservice","enable_portforward_tip")}]},{xtype:"syno_fieldset",title:_T("relayservice","permission"),cls:"syno_quickconnect_fieldset",collapsible:!1,items:[{xtype:"syno_displayfield",value:_T("relayservice","permission_desc"),id:this.permission_desc=Ext.id()},{xtype:"syno_gridpanel",id:this.gridpanel=Ext.id(),cm:this.columnModel,store:this.store,selModel:new Ext.grid.RowSelectionModel,height:142,padding:"0 0 0 0",style:{"padding-top":"0px"},enableColumnMove:!1,enableHdMenu:!1,hideMode:"offsets",plugins:[this.columnModel.enable_column]}]}]},beforehide:function(){return this.store.getCount()<=0||(!(this.getPermissionEnableCount()<=0)||(this.appWin.getMsgBox().alert(this.title,_T("relayservice","no_permission_select_warning")),!1))},cancelHandler:function(){this.store.rejectChanges()},getCmpsAsMembers:function(){for(var e=["field_relay_enabled","field_portforward_enabled","gridpanel","permission_desc","field_inside_tunnel_msg"],t=0;t0},getTabPanel:function(e){return this.panel||(this.panel=new SYNO.SDS.AdminCenter.QuickConnect.AdvancePanel({module:e.module,owner:e.owner,window_:this})),this.panel},processParams:function(e,t){return this.quickconnect_panel.stopWatchingStatus(),t=t.concat(this.getWebAPIParams(e))},getWebAPIParams:function(e){var t=[];if("get"===e)t=[{api:"SYNO.Core.Package",method:"list",version:"1",params:{additional:["status"]}},{api:"SYNO.Core.QuickConnect",method:"get_misc_config",version:"3",params:{}},{api:"SYNO.Core.QuickConnect.Upnp",method:"get",version:"1",params:{}},{api:"SYNO.Core.QuickConnect.Permission",method:"get",version:"1"}];else if("set"===e){if(this.getPermissionEnableCount()<=0)return t;t=this.webAPISetMiscSetting(),this.isPermissionDirty()&&t.push(this.webAPISetPermission())}return t},savePermissionInfo:function(){for(var e=this.store.getCount(),t=[],i=0;i"+_T("relayservice","quickconnect_confirm_title")+"";this.isSmartDNS?i+=_T("relayservice","quickconnect_confirm_desc_smartdns"):i+=_T("relayservice","quickconnect_confirm_desc"),e.confirm("",i,function(e){"yes"===e?(this.is_quickconnect_enable_confirm=!0,this.parent_panel.applyAllForm(this.parent_panel.applyAllFormOptions)):this.discardChange()},this,t)},showDisableConfirmMsg:function(){var e={yes:{text:_T("common","agree")},no:{text:_T("common","cancel")}};this.findWindow().getMsgBox().confirm("",_T("relayservice","quickconnect_disable_confirm_desc"),function(e){"yes"==e?(this.is_quickconnect_disable_confirm=!0,this.parent_panel.applyAllForm(this.parent_panel.applyAllFormOptions)):this.discardChange()},this,e)},setFieldsEnabled:function(){var e=this.field_enabled.getValue()&&this.qc_available;this.isInTunnel||(this.adv_setting_btn.setDisabled(!e),this.field_server_alias.setDisabled(!e),this.field_info_box.setDisabled(!e),this.field_info_box.update(this.info_template.getData(e)))},enableChanged:function(e,t){if(!this.isInTunnel)if(!0===t&&""===this.mydsAccount){this.field_enabled.setValue(!1);var i=new SYNO.SDS.MessageBoxV5({owner:this.appWin}),s={yes:{text:_T("common","login")},no:{text:_T("common","cancel")}};i.confirm("",_T("relayservice","login_for_quickconnect"),function(e){"yes"===e&&this.loginMyDsAccount()},this,s)}else this.setFieldsEnabled()},setAvailability:function(e){this.qc_available=e,this.setFieldsEnabled(),this.setInfoItems(),this.realname_validation_required&&(this.field_status.addClass(this.error_msg_cls),""===this.country||"CN"===this.country?this.field_status.setValue(_T("relayservice","need_real_name_valid")):this.field_status.setValue(_T("relayservice","bypass_real_name_valid")))},discardChange:function(){this.field_enabled.setValue(this.field_enabled.originalValue),this.field_server_alias.setValue(this.field_server_alias.originalValue)},addTip:function(){SYNO.ux.AddTip(this.getForm().findField("server_alias").getEl(),_JSLIBSTR("vtype","bad_relay_alias_name"))},addAriaAttirbutes:function(){},hideInfoItems:function(){this.field_status.setVisible(!1),this.field_info_box.setVisible(!1)},setInfoItems:function(){var e="connected"===this.quick_connect_status,t=!(this.dsm_permission||this.cloud_permission||this.mobile_apps_permission),i=!e||t||this.violated;this.field_status.setVisible(i&&this.enabled||this.realname_validation_required),this.field_info_box.setVisible(e&&!t&&this.qc_available),this.privacy_note.setVisible(!e),this.field_info_box.update(this.info_template.getData(!0)),this.doLayout()},onBeforeRequest:function(e){if("set"===e&&!0===this.field_enabled.getValue()){if(!this.getForm().isValid())return this.parent_panel.setStatusError({text:_T("common","forminvalid"),clear:!0}),this.confirmLostChangeReject&&(this.confirmLostChangeReject(),this.confirmLostChangeReject=void 0),!1;if(this.isSmartDNS&&!1===this.is_quickconnect_enable_confirm&&this.isFieldDirty()&&!1===this.field_force.getValue())return this.showEnableConfirmMsg(),!1}return"set"===e&&!1===this.field_enabled.getValue()&&this.isSmartDNS&&!1===this.is_quickconnect_disable_confirm?(this.showDisableConfirmMsg(),!1):(this.is_quickconnect_enable_confirm=!1,this.is_quickconnect_disable_confirm=!1,!0)},processParams:function(e,t){var i,s,n=[];if(this.hideInfoItems(),this.privacy_note.setVisible("connected"===this.quick_connect_status),t.forEach(function(e){"SYNO.Core.QuickConnect"===e.api?"get"===e.method?i=e:"set_server_alias"===e.method&&(s=e):n.push(e)}),"get"===e)n.push(i),n.push(this.createQuickConnectAPI("status",{})),n.push(this.createQuickConnectAPI("get",{},"SYNO.Core.QuickConnect.Permission")),n.push(this.createQuickConnectAPI("check_availability",{}));else if(this.getForm().isDirty()){var o=this.field_enabled.getValue();if(this.isSmartDNS){var a={};a.hostname=window.location.hostname,n.push(this.createQuickConnectAPI("get_ip",a,"SYNO.Core.QuickConnect.Hostname"))}o&&!this.realname_validation_required&&n.push(s),n.push(this.createSetApi(s)),n.push(i),n.push(this.createQuickConnectAPI("status",{})),delete s.enabled}return this.setFieldDisable(!0),n},createSetApi:function(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.method="set",t.params={},t.params.enabled=e.params.enabled,t},createQuickConnectAPI:function(e,t,i){i=void 0===i?"SYNO.Core.QuickConnect":i;var s={};return s.api=i,s.version=this.getQcWebApiVersion(i,e),s.method=e,s.params=t,s},quickConnectSetStatusError:function(e,t,i){var s={2900:_T("error","error_unknown_desc"),2901:_T("error","error_unknown_desc"),2902:_T("relayservice","relayservice_err_resolv"),2903:_T("relayservice","error_alias_server_internal"),2904:String.format(_T("relayservice","relayservice_err_alias_in_use"),i),2905:_T("pkgmgr","myds_error_account"),2906:_T("relayservice","error_alias_used_in_your_own"),2907:_T("relayservice","relayservice_err_bad_dns"),2909:_T("relayservice","error_myds_not_logged_in"),2910:_T("relayservice","violation"),3000:_T("error","error_unknown_desc"),3001:_T("error","error_unknown_desc"),3002:_T("relayservice","relayservice_err_network"),3003:_T("relayservice","myds_server_internal_error"),3004:_T("error","error_auth"),3005:String.format(_T("relayservice","relayservice_err_alias_in_use"),i),3006:_T("relayservice","myds_exceed_max_register_error")};if(e.success)return"";var n=e.error.code,o=n<400?SYNO.API.CheckResponse(!1,e,t):s[n];return this.parent_panel.clearStatus(),2910===n?(this.violated=!0,this.field_status.addClass(this.error_msg_cls),void this.field_status.setValue(o)):this.parent_panel.setStatusError({text:o,clear:!1})},errorHandling:function(e,t){var i,s,n;for(var o in e.result)if(!e.result[o].success){i=e.result[o],s=t.compound[o],n=t.compound[o].server_alias,this.quickConnectSetStatusError(i,s,n),this.status_error="status"===e.result[o].method;break}i&&i.error&&(2906===i.error.code?new SYNO.SDS.MessageBoxV5({draggable:!1,owner:this.appWin}).confirm(_T("relayservice","error_alias_used_in_your_own"),_T("relayservice","alias_change_machine_message"),function(e){"yes"===e&&(this.field_force.setValue(!0),this.parent_panel.clearStatus(),this.parent_panel.applyAllForm())},this):2909===i.error.code&&(this.setMyDsAccount(""),this.field_enabled.setValue(!1)))},setRedirectMask:function(){new SYNO.SDS.MessageBoxV5({modal:!0,draggable:!1,renderTo:document.body}).getWrapper().show({closable:!1,msg:_T("relayservice","redirecting")})},setFieldDisable:function(e){e?(this.field_enabled.setDisabled(!0),this.field_server_alias.setDisabled(!0),this.adv_setting_btn.setDisabled(!0)):(this.field_enabled.setDisabled(this.isInTunnel),this.field_server_alias.setDisabled(this.isInTunnel||!this.field_enabled.getValue()),this.adv_setting_btn.setDisabled(this.isInTunnel||!this.field_enabled.getValue()))},processReturnData:function(e,t,i){var s=this.field_enabled.originalValue,n=this.field_enabled.getValue(),o=n!==s,a=!1,r="",l=0,d=void 0;this.setFieldDisable(!1);var c={has_fail:!1,result:[]},h={compound:[]};for(l in t.result)t.result.hasOwnProperty(l)&&(d=t.result[l]).api.startsWith("SYNO.Core.QuickConnect")&&(c.result.push(t.result[l]),h.compound.push(i.compound[l]),!1===d.success&&(c.has_fail=!0));if(!0===c.has_fail){for(l in c.result)c.result.hasOwnProperty(l)&&"SYNO.Core.QuickConnect"===(d=c.result[l]).api&&"get"===d.method&&d.success&&(this.updateServerInfo(d),this.superclass().processReturnData.apply(this,[e,t,i]));this.errorHandling(c,h)}else{for(l in c.result)if(c.result.hasOwnProperty(l))switch((d=c.result[l]).api){case"SYNO.Core.QuickConnect":switch(d.method){case"get":this.updateServerInfo(d);break;case"status":this.updateStatus(d),this.status_error&&(this.parent_panel.clearStatus(),this.status_error=!1);break;case"check_availability":this.realname_validation_required=2911===d.data.code,this.country=d.data.country,this.setAvailability(d.data.available);break;case"set":a=!0}break;case"SYNO.Core.QuickConnect.Permission":"get"===d.method&&this.updatePermissionInfo(d);break;case"SYNO.Core.QuickConnect.Hostname":"get_ip"===d.method&&(r=null!=d.data.ipv4&&""!=d.data.ipv4?d.data.ipv4:"["+d.data.ipv6+"]")}if(this.superclass().processReturnData.apply(this,[e,t,i]),n&&a){if(this.isSmartDNS){this.confirmLostChangeResolve=void 0,this.setRedirectMask();var u="https://"+this.field_server_alias.getValue()+"."+this.domain;this.waitCertificateReady(60).finally(function(){this.redirectPage(u)}.bind(this))}}else!n&&o&&this.isSmartDNS&&(this.confirmLostChangeResolve=void 0,this.setRedirectMask(),this.redirectPage("https://"+r+":"+window.location.port))}this.enableChanged(this.field_enabled,this.field_enabled.getValue()),this.field_enabled.getValue()&&!1===s&&this.checkServicesFirewall(),""===this.field_server_alias.getValue()&&this.field_server_alias.clearInvalid(),this.field_force.setValue(!1),this.setInfoItems(),this.watchStatus(),!1===c.has_fail&&this.confirmLostChangeResolve&&this.confirmLostChangeResolve(),this.confirmLostChangeResolve=void 0},setMyDsAccount:function(e){void 0!==e&&e.length>0?this.mydsAccount=e:this.mydsAccount="",this.isInTunnel||this.field_server_alias.setDisabled(!this.field_enabled.getValue())},updateServerInfo:function(e){void 0!==e.data&&(this.enabled=e.data.enabled,this.server_alias=e.data.server_alias,this.server_id=e.data.server_id,this.domain=e.data.domain,this.setMyDsAccount(Ext.util.Format.htmlEncode(e.data.myds_account)),void 0!==e.data.ddns_domain&&""!==e.data.ddns_domain&&(this.quickconnect_ddns_domain=e.data.ddns_domain),""===e.data.myds_account&&this.mon(SYNO.SDS.QuickConnect.Utils,"ddns_account_logged_in",e=>{this.setMyDsAccount(Ext.util.Format.htmlEncode(e))}))},updateStatus:function(e){this.quick_connect_status=e.data.status,this.alias_status=e.data.alias_status},updatePermissionInfo:function(e){if(void 0!==e.data)for(var t in this.dsm_permission=!1,this.mobile_apps_permission=!1,this.cloud_permission=!1,this.file_sharing_permission=!1,e.data.services)if(e.data.services.hasOwnProperty(t))switch(e.data.services[t].id){case"dsm_portal":this.dsm_permission=e.data.services[t].enabled;break;case"mobile_apps":this.mobile_apps_permission=e.data.services[t].enabled;break;case"cloudstation":this.cloud_permission=e.data.services[t].enabled;break;case"file_sharing":this.file_sharing_permission=e.data.services[t].enabled}},createObjs:function(e){return[{xtype:"syno_displayfield",id:this.field_inside_tunnel_msg=Ext.id(),hidden:!0,htmlEncode:!1,value:''+_T("common","note")+': '+_T("relayservice","inside_tunnel_msg")+""},{xtype:"syno_displayfield",value:_T("relayservice","quickconnect_desc")},{xtype:"syno_fieldset",title:_T("common","general"),cls:"syno_quickconnect_fieldset",collapsible:!1,items:[{xtype:"syno_checkbox",name:"enabled",id:this.field_enabled=Ext.id(),listeners:{scope:this,check:this.enableChanged},boxLabel:_T("relayservice","enable_quickconnect")},{xtype:"syno_textfield",allowBlank:!1,fieldLabel:_T("relayservice","title_svrid"),id:this.field_server_alias=Ext.id(),name:"server_alias",maxLength:32,regex:/^[a-zA-Z][a-zA-Z\-0-9]*[a-zA-Z0-9]$/,regexText:_JSLIBSTR("vtype","bad_relay_alias_name"),enableKeyEvents:!0,indent:1},{xtype:"syno_checkbox",id:this.field_force=Ext.id(),name:"force",value:!1,hidden:!0},{xtype:"syno_displayfield",id:this.field_status=Ext.id(),hidden:!0,fieldLabel:_T("relayservice","status"),indent:1,htmlEncode:!1},{xtype:"box",id:this.field_info_box=Ext.id(),tpl:this.info_template,selectable:!0},{xtype:"syno_displayfield",id:this.privacy_note=Ext.id(),hideLabel:!0,value:String.format(_T("relayservice","privacy_note"),'',""),indent:1,htmlEncode:!1}]},{xtype:"syno_fieldset",title:_T("relayservice","adv_setting"),cls:"syno_quickconnect_fieldset",collapsible:!1,items:[{xtype:"syno_displayfield",value:_T("relayservice","adv_setting_description")},{xtype:"syno_button",cls:"quickconnect-advance-button",text:_T("common","adv_setting"),id:this.adv_setting_btn=Ext.id(),scope:this,handler:this.advSettingHandler}]}]},advSettingHandler:function(){new SYNO.SDS.AdminCenter.PublicAccess.QuickConnectAdvDialog({owner:this.module.appWin,module:this,quickconnect_panel:this}).open({scope:this})},watchApi:{api:"SYNO.Core.QuickConnect",method:"status",version:1},watchStatus:function(){!0===this.field_enabled.originalValue&&(this.quick_connect_status="",this.alias_status="",this.status_changed=!0,SYNO.SDS.SocketInst.register(this.watchApi,this.OnMessage.createDelegate(this),!0))},OnMessage:function(e){this.statusCheck(e.success,e.data)},stopWatchingStatus:function(){SYNO.SDS.SocketInst.unregister(this.watchApi,this.OnMessage)},statusCheck:function(e,t){var i={disconnect:_T("relayservice","relayservice_disconnected"),direct_connect:_T("relayservice","relayservice_direct_connect"),login:_T("relayservice","relayservice_login"),starting:_T("relayservice","relayservice_starting"),not_running:_T("relayservice","relayservice_disconnected"),logout:_T("relayservice","relayservice_stop"),stoped:_T("relayservice","relayservice_disconnected"),connected:_T("relayservice","relayservice_connected"),unknown:_T("relayservice","relayservice_err_unknown"),no_service:_T("relayservice","no_service_enabled"),network_abnormal:_T("relayservice","relayservice_err_resolv")};if(this.old_alias_status=this.alias_status,this.old_quick_connect_status=this.quick_connect_status,e&&this.status_error&&(this.parent_panel.clearStatus(),this.status_error=!1),this.alias_status=e?t.alias_status:"unknown",this.quick_connect_status=e?t.status:"unknown",this.status_changed=this.old_alias_status!==this.alias_status||this.old_quick_connect_status!==this.quick_connect_status,this.status_changed){var s=!(this.dsm_permission||this.cloud_permission||this.mobile_apps_permission||this.file_sharing_permission),n=!e&&(2902===t.code||2907===t.code),o=2910===t.code,a="unknown";n?a="network_abnormal":o?a="stoped":s?a="no_service":e&&(a=t.status),this.setInfoItems();var r=i[a];this.violated||this.realname_validation_required||(this.field_status.removeClass(this.error_msg_cls),this.field_status.setValue(r))}},isDirty:function(){var e=this.parentPanel;return!(!e.isActivated||!e.abnormalStatus())||e.isFieldDirty()},isFieldDirty:function(){for(var e=[this.field_enabled,this.field_server_alias],t=0;t0&&SYNO.SDS.StatusNotifier.checkServiceBlocked(e)},waitCertificateReady:function(e){return new Promise(function(t,i){this.checkCertificateId=this.pollReg({webapi:{api:"SYNO.Core.Certificate.CRT",version:1,method:"list"},interval:5,immediate:!0,scope:this,status_callback:function(e,i,s,n){if(e||i.code)return this.isCertificateReady(i)?(this.pollUnreg(this.checkCertificateId),void t()):void 0}}),setTimeout(function(){this.pollUnreg(this.checkCertificateId),i()}.bind(this),1e3*e)}.bind(this))},isCertificateReady:function(e){var t=this.field_server_alias.getValue()+"."+this.quickconnect_ddns_domain,i=!1;return e.certificates.forEach(function(e){var s=e.subject,n=e.services;s.common_name.toLowerCase()===t.toLowerCase()&&n.forEach(function(e){"system"===e.subscriber&&"quickconnect"===e.service&&(i=!0)})}),i},redirectPage:function(e){window.location.assign(e)}}),Ext.define("SYNO.SDS.AdminCenter.QuickConnect.InfoTemplate",{extend:"Ext.XTemplate",constructor:function(e){this.parentPanel=e.parentPanel,this.callParent([this.template])},getData:function(e){var t=this.parentPanel,i="connected"===t.quick_connect_status,s=""!==t.server_alias?t.server_alias:t.server_id,n=SYNO.SDS.QuickConnect.Utils.aliasToPortalUrl(s,t.domain),o=void 0===s||-1!==s.indexOf("_")||s.length>63,a=""!==t.server_alias&&""!==t.mydsAccount,r=t.dsm_permission,l=!(t.dsm_permission||t.cloud_permission||t.mobile_apps_permission),d='style="display:none"';return{alias:s,dsm_url:n,description:a?_T("relayservice","welcome_message"):_T("relayservice","welcome_no_alias"),hidden:t.enabled&&i&&!l?"":d,url_hidden:a&&!o&&r?"":d,alias_note_hidden:o?"":d,mobile_hidden:t.mobile_apps_permission||t.cloud_permission?"":d,dsm_hidden:r?"":d,tabindex:e?0:-1}},template:'
    {description}
    '+_T("relayservice","browser_description")+'
    DSM'+_T("common","colon")+'{dsm_url}
    '+_T("relayservice","syno_mobile_apps")+'
    QuickConnect ID'+_T("common","colon")+'{alias}
    '+_T("common","note")+_T("common","colon")+' '+_T("relayservice","alias_new_restriction")+"
    "}),Ext.ns("SYNO.SDS.AdminCenter.PublicAccess"),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin},getHelpParam:function(){return this.panel.getActiveTab().getHelpParam()},getPanel:function(){return this.panel||(this.panel=new SYNO.SDS.AdminCenter.PublicAccess.TabPanel({module:this,appWin:this.appWin})),this.panel},setActivateParams:function(e){e&&e.tab&&this.panel.setActiveTab(e.tab)},confirmCallback:function(e){"no"===e&&this.panel.activeTab===this.panel.DDNSForm&&this.panel.DDNSForm.pollingTaskStart()},activate:function(e){this.panel.clearStatus(),this.panel.DDNSForm.pollingTaskStart(),this.setActivateParams(e),this.panel.loadAllForm()},deactivate:function(){return this.panel.quickconnectTab.stopWatchingStatus(),this.panel.DDNSForm.pollingTaskStop(),!this.panel.quickconnectTab.isFieldDirty()&&(!this.panel.advancedForm.getForm().isDirty()&&(!this.panel.portforwardingTab.isDirty()&&(this.panel.portforwardingTab.resetMainPage(),this.panel.quickconnectTab.SAWebLogin&&this.panel.quickconnectTab.SAWebLogin.cancel(),!0)))},confirmLostCancel:function(){return new Promise(function(e,t){this.panel.quickconnectTab.startPolling(),e()}.bind(this))},confirmLostChangeSave:function(){return new Promise(function(e,t){this.panel.applyAllForm({applyHandlerCallback:e,applyHandlerReject:t,blDoSaveSuccessCallback:!1})}.bind(this))},confirmLostChangeDontSave:function(){return new Promise(function(e,t){this.panel.DDNSForm.pollingTaskStop(),this.panel.portforwardingTab.resetMainPage(),e()}.bind(this))}}),Ext.define("SYNO.SDS.AdminCenter.PublicAccess.TabPanel",{extend:"SYNO.SDS.Utils.TabPanel",constructor:function(e){var t;this.module=e.module,this.appWin=e.appWin;var i=[];i.push(this.quickconnectTab=new SYNO.SDS.AdminCenter.PublicAccess.QuickConnectTab({module:this.module,appWin:e.appWin,isInTunnel:SYNO.SDS.QuickConnect.Utils.isInTunnel(),isSmartDNS:SYNO.SDS.QuickConnect.Utils.isSmartDNS(),itemId:"quickconnecttab",originalFormPanel:this})),i.push(this.DDNSForm=new SYNO.SDS.AdminCenter.PublicAccess.DDNSTab({module:this.module,itemId:"ddnstab"})),SYNO.SDS.Utils.isInC2DSM()||SYNO.SDS.Utils.isInAliDSM()||i.push(this.portforwardingTab=new SYNO.SDS.AdminCenter.PublicAccess.PortForwarding.RuleGrid({module:this.module,itemId:"portforwardingtab",originalFormPanel:this})),i.push(this.advancedForm=new SYNO.SDS.AdminCenter.PublicAccess.AdvancedForm({module:this.module,itemId:"advancetab"})),t=Ext.apply({activeTab:0,items:i},e),this.callParent([t])},getCompoundCfg:function(e){return"set"===e?{stopwhenerror:!0}:{}},onApiSuccess:function(e,t,i){if("set"===e)if(t.has_fail){var s=SYNO.API.getErrorString(t);this.setStatusError({text:s,clear:!0}),this.applyAllFormOptions&&Ext.isFunction(this.applyAllFormOptions.applyHandlerReject)&&this.applyAllFormOptions.applyHandlerReject()}else this.hasQuickConnectSetRequest(i)?this.pfNeedReload=!0:this.setStatusOK();this.processReturnData(e,t,i),this.checkAndNotify()},registerProcessReturnData:function(e){this.applyPages&&(this.applyPages[e]=!0)},deregisterProcessReturnData:function(e){this.applyPages&&(this.applyPages[e]=!1,this.checkAndNotify())},applyAllForm:function(e){this.applyAllFormOptions=e,this.applyPages={},this.callParent([e])},onApiFailure:function(e,t,i){this.callParent([e,t,i]),this.applyPages={},this.checkAndNotify()},onBeforeTabChange:function(e,t,i){var s=!1;if(i===this.advancedForm?s=i.getForm().isDirty():i===this.quickconnectTab?s=i.isFieldDirty():i===this.portforwardingTab&&(s=i.isDirty()),!0===s&&t&&t!=i)return this.showTabChangeConfirm(t,i),!1;this.callParent([e,t,i])},showTabChangeConfirm:function(e,t){this.appWin.confirmLostChangePromise({save:function(){return new Promise(function(e,i){t.confirmLostChangeResolve=e,t.confirmLostChangeReject=i,this.applyAllForm()}.bind(this))},dontSave:function(){return new Promise(function(e,t){this.resetAllForm(),e()}.bind(this))},cancel:Ext.emptyFn},this,Ext.emptyFn,function(){this.setActiveTab(e)})},checkAndNotify:function(){!0===this.checkIfAllApplyPollingDone()&&this.notifyAllApplyPollingDone()},checkIfAllApplyPollingDone:function(){if(this.applyPages){for(var e in this.applyPages)if(!0===this.applyPages[e])return!1;return!0}return!0},notifyAllApplyPollingDone:function(){this.applyAllFormOptions&&this.applyAllFormOptions.applyHandlerCallback&&this.applyAllFormOptions.applyHandlerCallback()},hasQuickConnectSetRequest:function(e){var t=!1;return e.compound.forEach(function(e){"SYNO.Core.QuickConnect"===e.api&&(t=!0)}),t}}),Ext.ns("SYNO.SDS.AdminCenter.Network.Utils"),SYNO.SDS.AdminCenter.Network.Utils.SortFunc=function(e,t){var i=0,s=/^([a-z]+)([0-9]*)(\.?)([0-9]*)$/,n=s.exec(e.ifname),o=s.exec(t.ifname);if(n instanceof Array&&o instanceof Array&&0===(i=n[1]>o[1]?1:n[1]r?1:a'+String.format(_T("network","bond_ip_conflict"),SYNO.SDS.Utils.Network.idToString(r))+""),SYNO.SDS.AdminCenter.Network.Utils.WaitingBox.apply(this,[{times:d/1e3,msg:u}])}else SYNO.Debug("bad parameters")},SYNO.SDS.AdminCenter.Network.Utils.IsInt=function(e){return"number"==typeof e&&e%1==0},SYNO.SDS.AdminCenter.Network.Utils.GetLinkStatus=function(e,t,i,s){var n="--";if(!SYNO.SDS.AdminCenter.Network.Utils.IsInt(e)||"boolean"!=typeof t||!SYNO.SDS.AdminCenter.Network.Utils.IsInt(i)||-1==e)return n;var o=String.format(_T("tcpip","if_speed"),e),a=String.format(_T("tcpip","MTU_value"),i),r=t?_T("tcpip","full_duplex"):_T("tcpip","half_duplex");return r=!0===t?_T("tcpip","full_duplex"):_T("tcpip","half_duplex"),n=String.format("{0}, {1}, {2}",o,r,a),!0===s&&(n+=String.format(', {0}',_T("network","linkaggr_8023ad_error"))),n},SYNO.SDS.AdminCenter.Network.Utils.apiMap={"SYNO.Core.Network":"network","SYNO.Core.Network.Proxy":"proxy","SYNO.Core.Network.Ethernet":"ethernet","SYNO.Core.Network.PPPoE":"pppoe","SYNO.Core.Network.Bond":"bond","SYNO.Core.Network.PPPoE.Relay":"pppoe_relay","SYNO.Core.Network.IPv6":"ipv6","SYNO.Core.Network.IPv6.Router":"ipv6_router","SYNO.Core.Network.IPv6.Router.Prefix":"ipv6_router_prefix","SYNO.Core.Network.UPnPServer":"upnpserver","SYNO.GlusterfsMgmt.Service":"gluster_service","SYNO.Core.Hardware.OOBManagement":"oobmgmt","SYNO.Core.Network.Authentication":"auth"},SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix=function(e){var t=SYNO.SDS.AdminCenter.Network.Utils.apiMap;return t.hasOwnProperty(e)?t[e]+"_":""},SYNO.SDS.AdminCenter.Network.Utils.TC_MAX_RULE=100,SYNO.SDS.AdminCenter.Network.Utils.TC_MAX_PORTS_IN_A_RULE=15,SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH=200,SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_LABEL_WIDTH=200,SYNO.SDS.AdminCenter.Network.Utils.TC_MAX_RATE=125e4,SYNO.SDS.AdminCenter.Network.Utils.TcErrCode={},Ext.apply(SYNO.SDS.AdminCenter.Network.Utils.TcErrCode,{WEBAPI_ERR_NO_REQUIRED_PARAM:114,WEBAPI_CORE_ERR_TC_NOERR:1200,WEBAPI_CORE_ERR_TC_OP_FAIL:1201,WEBAPI_CORE_ERR_TC_CEIL_EXCEED_SYSTEM_UPPER_BOUND:1202,WEBAPI_CORE_ERR_TC_MAX_CEIL_TOO_LARGE:1203,WEBAPI_CORE_ERR_TC_RESTORE_FAIL:1204,WEBAPI_CORE_ERR_TC_MAX:1299,WEBAPI_CORE_ERR_NET_NO_SUCH_INTERFACE:4311}),SYNO.SDS.AdminCenter.Network.Utils.TcRULERecord=Ext.data.Record.create({name:"id"},{name:"enabled"},{name:"port_type"},{name:"port_num"},{name:"port_direction"},{name:"protocol"},{name:"minrate"},{name:"maxrate"}),SYNO.SDS.AdminCenter.Network.Utils.Render_Min_Rate=function(e,t){return t.attr='ext:qtip="'+e+'"',e},SYNO.SDS.AdminCenter.Network.Utils.Render_Max_Rate=function(e,t){var i="";return i=0===e?_T("firewall","firewall_tc_unlimited"):e,t.attr='ext:qtip="'+i+'"',i},SYNO.SDS.AdminCenter.Network.Utils.onClickDirectoryServiceUrl=function(e){e.findAppWindow().startModule("SYNO.SDS.AdminCenter.DirectoryService.Main")},SYNO.SDS.AdminCenter.Network.Utils.GetDSInfo=function(){var e={platform:"",model:""},t=this._D("unique");if(!t)return e;var i=/^synology_([A-Z|a-z|0-9]*)_([a-z|0-9|+]*)$/.exec(t);return 3>i.length?e:(e.platform=i[1],e.model=i[2],e)},SYNO.SDS.AdminCenter.Network.Utils.Strncmp=function(e,t,i){return(e=e.substring(0,i))===(t=t.substring(0,i))?0:e>t?1:-1},SYNO.SDS.AdminCenter.Network.Utils.toYesNo=function(e){return!0===e?_T("common","yes"):_T("common","no")},SYNO.SDS.AdminCenter.Network.Utils.toEmptyDash=function(e){return e&&""!==e?e:"--"},SYNO.SDS.AdminCenter.Network.Utils.toMultiLine=function(e){var t="";return e&&0!==e.length?(Ext.each(e,function(e){t+=e+"
    "},this),t):"--"},SYNO.SDS.AdminCenter.Network.Utils.getLinkStatus=function(e,t){return this.toEmptyDash(SYNO.SDS.AdminCenter.Network.Utils.GetLinkStatus(t.speed,t.duplex,t.mtu,t.error),t)},SYNO.SDS.AdminCenter.Network.Utils.getTitle=function(e,t,i){if("vpnc"==t.type)return"VPN - "+t.confname;var s=t.id?t.id:t.ifname;return SYNO.SDS.Utils.Network.idToString.apply(i,[s,t.type])},SYNO.SDS.AdminCenter.Network.Utils.statusMap={connected:_T("network","status_connected"),disconnected:_T("network","status_disconnected"),connection_failed:_T("download","download_err_network"),connection_lost:_T("download","download_err_network"),preconnecting:_T("pppoe","pppoe_connecting"),disconnecting:_T("bluetooth","state_disconnecting"),connecting:_T("pppoe","pppoe_connecting"),enabled:_T("common","enabled"),disabled:_T("common","disabled")},SYNO.SDS.AdminCenter.Network.Utils.getStatus=function(e){return String.format('{1}',{connected:"blue-status",disconnected:"disable-font",connection_failed:"disable-font",connecting:"blue-status",enabled:"blue-status",disabled:"disable-font"}[e],SYNO.SDS.AdminCenter.Network.Utils.statusMap[e])},SYNO.SDS.AdminCenter.Network.Utils.getStatusStr=function(e){return SYNO.SDS.AdminCenter.Network.Utils.statusMap[e]},SYNO.SDS.AdminCenter.Network.Utils.LinuxBondModeMap={"802.3ad":_T("network","linkaggr_mode_8023ad"),"balance-alb":_T("network","linkaggr_mode_alb"),"balance-xor":_T("network","linkaggr_mode_xor"),"active-backup":_T("network","linkaggr_mode_failover")},SYNO.SDS.AdminCenter.Network.Utils.OvsBondModeMap={"balance-slb":_T("ovs","ovs_linkaggr_mode_slb"),"balance-tcp":_T("ovs","ovs_linkaggr_mode_tcp"),"ovs-active-backup":_T("ovs","ovs_linkaggr_mode_failover")},SYNO.SDS.AdminCenter.Network.Utils.GetBondModeStr=function(e,t){return e?SYNO.SDS.AdminCenter.Network.Utils.OvsBondModeMap[t]:SYNO.SDS.AdminCenter.Network.Utils.LinuxBondModeMap[t]},SYNO.SDS.AdminCenter.Network.Utils.ConvertToReadableIPv6=function(e){return e=(e=e.replace(new RegExp("[0-9a-fA-F]","g"),function(e){return" "+e+" "})).replace(new RegExp("\\:","g")," "+_T("common","colon_str")+" ")},Ext.define("SYNO.SDS.AdminCenter.Network.GeneralTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.owner=e.owner,this.showOldUI=this._S("version")<4966,this.callParent([this.fillConfig(e)]),this.on("afterlayout",function(e,t){this.checkGroupDNS=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"dns_manual",["dns_primary","dns_secondary"]),this.checkGroupProxy=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable",[]),this.checkGroupProxyDiff=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_different_host",["https_host","https_port"]),this.checkGroupProxyAuth=new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_auth",["username","password"]),_S("manage_hostname_in_ha_pkg")&&SYNO.ux.AddTip(this.getForm().findField("server_name").getEl(),_TT("SYNO.SDS.HA.Instance","ui","setting_on_ha_mgr"))},this,{single:!0}),this.customizeForm()},fillConfig:function(e){return Ext.apply({title:_T("common","general"),hideMode:"offsets",module:e.module,trackResetOnLoad:!0,proxy_keys:["enable","http_host","http_port","enable_different_host","https_host","https_port","enable_auth","username","password","enable_bypass"],items:[this.createCommonSetting(),this.createProxySetting()]},e)},isDirty:function(){return this.getForm().isDirty()},customizeForm:function(){var e=this.getForm();e.isDirtyDefault=e.isDirty,e.isDirty=function(){var e=this.isDirtyDefault(),t=this.findField("enable_different_host"),i=this.findField("http_host"),s=this.findField("http_port");return!0===t.getValue()&&(i.enable(),s.enable(),e=e||i.isDirty()||s.isDirty(),i.disable(),s.disable()),e},e.isValidDefault=e.isValid,e.isValid=function(){var e=this.findField("http_host"),t=this.findField("enable_different_host");return!!this.isValidDefault()&&(!0===t.getValue()||e.isValid())}},createCommonSetting:function(){return{xtype:"syno_fieldset",stateId:"SYNO.SDS.AdminCenter.Network.Main::general::general",labelWidth:232,title:_T("common","general"),cls:"syno-network-general-fieldset",collapsible:!0,webapi:{api:"SYNO.Core.Network",methods:{get:"get",set:"set"},version:2},items:[{xtype:"syno_displayfield",value:_T("tcpip","name_dns_gateway_desc"),ctCls:"syno-network-general-single-element"},{xtype:"syno_textfield",fieldLabel:_S("manage_hostname_in_ha_pkg")?_TT("SYNO.SDS.HA.Instance","ui","virtual_server"):_T("tcpip","server_name"),disabled:!0===_S("manage_hostname_in_ha_pkg"),name:"server_name",vtype:"netbiosName",allowBlank:!1,maxlength:15,hidden:"yes"===this._D("dockerdsm")},{xtype:"syno_displayfield",fieldLabel:_T("tcpip","server_name"),name:"server_name",hidden:"yes"!==this._D("dockerdsm")},{xtype:"syno_compositefield",hidden:this.showOldUI,disabled:this.showOldUI,items:[{xtype:"syno_displayfield",fieldLabel:_T("tcpip","tcpip_gateway"),width:200,name:"gateway"},{xtype:"syno_button",text:_T("common","alt_edit"),id:this.btnServiceOrder=Ext.id(),scope:this,handler:this.onServiceOrder}]},{xtype:"syno_textfield",fieldLabel:_T("tcpip","tcpip_gateway"),hidden:!this.showOldUI,disabled:!this.showOldUI,name:"gateway",vtype:"v4ip",maxlength:15,validator:function(e){var t=SYNO.SDS.Utils.Network.GatewayMatchIP,i=!1,s=null;return!(this.ownerCt&&this.ownerCt.ownerCt&&this.ownerCt.ownerCt.module)||(s=this.ownerCt.ownerCt.module.getStore(),""===e||0===s.getCount()||(s.each(function(s){var n=s.get("ip"),o=s.get("mask");if(n&&o&&t(e,n,o))return i=!0,!1},this),!!i||_T("common","error_notmatch")))}},{xtype:"syno_displayfield",fieldLabel:_T("tcpip","tcpip_v6gateway"),hidden:this.showOldUI,name:"v6gateway"},{xtype:"syno_checkbox",boxLabel:_T("network","enable_static_dns"),name:"dns_manual",ctCls:"syno-network-general-single-element"},{xtype:"syno_textfield",fieldLabel:_T("tcpip","primary_dns"),name:"dns_primary",allowBlank:!1,maxlength:"yes"===this._D("ipv4only")?15:39,indent:1,vtype:"yes"===this._D("ipv4only")?"v4ip":"ip"},{xtype:"syno_textfield",fieldLabel:_T("tcpip","secondary_dns"),name:"dns_secondary",allowBlank:!0,maxlength:"yes"===this._D("ipv4only")?15:39,indent:1,vtype:"yes"===this._D("ipv4only")?"v4ip":"ip"},{xtype:"syno_displayfield",value:String.format(''+_T("common","note")+": "+_T("network","goto_directory_service_for_dns_desc"),''+_T("directory_service","directory_service_title")+""),name:"dns_domain_warning",htmlEncode:!1,indent:1,hidden:!0,ctCls:"syno-network-general-single-element"},{xtype:"syno_checkbox",boxLabel:"enable_windomain",name:"enable_windomain",hidden:!0,readOnly:!0,disabled:!0,ctCls:"syno-network-general-single-element"},{xtype:"syno_checkbox",boxLabel:_T("network","arp_ignore"),hidden:!this.showOldUI,name:"arp_ignore",ctCls:"syno-network-general-single-element"},{xtype:"syno_checkbox",boxLabel:_T("network","route_multi_gateway_enable"),hidden:!0,name:"multi_gateway",ctCls:"syno-network-general-single-element"},{xtype:"syno_checkbox",boxLabel:_T("network","ipv4_first"),hidden:!0,name:"ipv4_first",ctCls:"syno-network-general-single-element"},{xtype:"syno_checkbox",boxLabel:_T("network","enable_ip_conflict_detect"),hidden:!0,name:"enable_ip_conflict_detect",ctCls:"syno-network-general-single-element"},{xtype:"syno_button",text:_T("common","adv_setting"),indent:1,hidden:this.showOldUI,scope:this,handler:this.onClickAdvanceSettingsBtn,ctCls:"syno-network-general-single-element"}]}},createProxySetting:function(){return{xtype:"syno_fieldset",stateId:"SYNO.SDS.AdminCenter.Network.Main::general::proxy",title:_T("network","proxy_title"),collapsible:!0,webapi:{api:"SYNO.Core.Network.Proxy",methods:{get:"get",set:"set"},version:1},items:[{xtype:"syno_checkbox",boxLabel:_T("network","proxy_enabled"),name:"enable"},{xtype:"syno_textfield",fieldLabel:_T("network","network_address"),name:"http_host",disabled:!0,allowBlank:!1,maxlength:128,indent:1,vtype:"iporhostname"},{xtype:"syno_textfield",fieldLabel:_T("common","port"),name:"http_port",allowBlank:!0,maxlength:5,indent:1,vtype:"port"},{xtype:"syno_checkbox",name:"enable_different_host",boxLabel:_T("network","proxy_enabled_adv"),hidden:!0},{xtype:"syno_textfield",fieldLabel:_T("network","network_address"),name:"https_host",maxlength:128,indent:1,vtype:"iporhostname",hidden:!0},{xtype:"syno_textfield",fieldLabel:_T("common","port"),name:"https_port",allowBlank:!0,maxlength:5,indent:1,vtype:"port",hidden:!0},{xtype:"syno_checkbox",name:"enable_auth",boxLabel:_T("network","proxy_enabled_auth"),hidden:!0},{indent:1,xtype:"syno_textfield",fieldLabel:_T("common","username"),allowBlank:!1,maxlength:64,name:"username",hidden:!0},{indent:1,xtype:"syno_textfield",fieldLabel:_T("common","password"),maxlength:127,textType:"password",name:"password",hidden:!0},{xtype:"syno_button",text:_T("common","adv_setting"),indent:1,scope:this,handler:this.onClickProxyAdvBtn,id:this.advBtnId=Ext.id()},{xtype:"syno_checkbox",name:"enable_bypass",indent:1,boxLabel:_T("network","proxy_enabled_bypass_local")}]}},onClickProxyAdvBtn:function(){new SYNO.SDS.AdminCenter.Network.ProxyDialog({owner:this.module.appWin,module:this.module,generalSetting:this}).open()},onClickAdvanceSettingsBtn:function(){new SYNO.SDS.AdminCenter.Network.AdvanceSettings({owner:this.module.appWin,module:this.module,generalSetting:this}).open()},isGatewayDirty:function(){return this.getForm().findField("gateway").isDirty()},isGatewayEmpty:function(){return""===this.getForm().findField("gateway").getValue()},processParams:function(e,t){var i=this.getForm(),s=i.findField("enable").getValue(),n=i.findField("password").isDirty(),o=i.findField("enable_different_host").getValue();return this.isServerNameDirty=i.findField("server_name").isDirty(),Ext.each(t,function(e,t,a){var r=a[t].params;if("get"!==e.method)switch(e.api){case"SYNO.Core.Network.Proxy":s&&(o?(r.http_host=i.findField("http_host").getValue(),r.http_port=i.findField("http_port").getValue()):(r.http_host=i.findField("http_host").getValue(),r.http_port=i.findField("http_port").getValue(),r.https_host=i.findField("http_host").getValue(),r.https_port=i.findField("http_port").getValue())),n||delete r.password}},this),t},processReturnData:function(e,t,i){var s,n=!1,o="",a=0,r=0,l="",d=0;"set"===e&&this.isServerNameDirty&&(this.isServerNameDirty=!1,this.module.appWin.getMsgBox().confirm("",_T("network","hostname_change_confirm"),function(e){"yes"===e&&window.location.reload()},this));var c=Ext.get(this.redirectDomainServiceLinkId);c&&(this.mun(c,"click",this.onRedirectDomainServiceClick,this),this.mon(c,"click",this.onRedirectDomainServiceClick,this)),Ext.each(t.result,function(e,t,i){if(!1!==e.success)switch("set"===e.method&&(n=!0),e.api){case"SYNO.Core.Network":"set"===e.method&&e.data.hostname_changed_and_join_domain&&this.module.appWin.getMsgBox().alert(_T("common","general"),_T("tcpip","rejoin_domain_msg")),"get"===e.method&&(this.showOldUI||0!==e.data.v6gateway.length||(e.data.v6gateway="--"));break;case"SYNO.Core.Network.Router.Gateway.List":if("get"===e.method&&0!==e.data.configs.length){var s="";o=e.data.configs[0].gateway,s="vpn-client"===e.data.configs[0].class?"VPN":SYNO.SDS.Utils.Network.idToString(e.data.configs[0].ifname),o=o+" ("+s+")"}}else 4319===(a=e.error.code)&&(r=t)},this);var h=-1;if(Ext.each(t.result,function(e,t){"SYNO.Core.Network"===e.api&&"get"===e.method&&e.success&&(h=t)},this),-1!==h&&""!==o&&(t.result[h].data.gateway=o),this.isFormDirty()&&!1===n)this.showOldUI?this.getForm().findField("gateway").disabled&&this.getForm().setValues({gateway:o}):this.getForm().setValues({gateway:o});else if(this.callParent([e,t,i]),this.updateForm(),this.showOldUI&&this.clearGatewayInvalid(),4319===a){if("hostname_change"===(s=t.result[r].error.errors).type){for(l="",d=0;d{0}",SYNO.SDS.Utils.GetFeasibilityCheckMsg(s.hard[d]));l=String.format('
      {0}
    ',l),this.module.appWin.getMsgBox().alert(_T("controlpanel","leaf_lan"),String.format(_T("network","hostname_feasibility_check_fail"),l))}}else 0!==a&&this.module.appWin.getMsgBox().alert(_T("controlpanel","leaf_lan"),SYNO.API.getErrorString(a))},onRedirectDomainServiceClick:function(){SYNO.SDS.AdminCenter.Network.Utils.onClickDirectoryServiceUrl(this.module.appWin)},clearGatewayInvalid:function(){this.getForm().findField("gateway").clearInvalid()},updateForm:function(){var e=this.getForm();!0===e.findField("enable_windomain").getValue()?(e.findField("dns_manual").disable(),e.findField("dns_secondary").hide(),e.findField("dns_domain_warning").show()):(e.findField("dns_manual").enable(),e.findField("dns_secondary").show(),e.findField("dns_domain_warning").hide()),this.setCheckGroupProxy()},getProxyValues:function(){var e={},t=this.getForm();return Ext.each(this.proxy_keys,function(i){var s=t.findField(i);s&&(e[i]=s.getValue())}),e},setProxyValues:function(e){var t=this.getForm();Ext.each(this.proxy_keys,function(i){var s=t.findField(i),n=e[i];s&&void 0!==n&&s.setValue(n)})},setCheckGroupProxy:function(){var e=this.getForm(),t=["enable_bypass",this.advBtnId],i=!e.findField("enable").getValue();!0===e.findField("enable_different_host").getValue()?(e.findField("http_host").disable(),e.findField("http_port").disable()):(e.findField("http_host").setDisabled(i),e.findField("http_port").setDisabled(i),t.push("http_host"),t.push("http_port")),e.findField("enable_bypass").setDisabled(i),Ext.getCmp(this.advBtnId).setDisabled(i),this.checkGroupProxy.enable_fields=t},afterLoad:function(){var e=!1,t=!0;this.module.getStore().each(function(i){switch(i.get("type")){case"wan":case"lan":case"ovseth":case"ovsbond":case"bond":!0!==i.get("use_dhcp")&&(t=!1);break;case"pppoe":case"vpnc":"connected"!==i.get("status")&&"connecting"!==i.get("status")||(e=!0);break;default:SYNO.Debug("unknowntype:"+i.get("type"))}},this),this.module.getWifiStore().each(function(e){!0!==e.get("use_dhcp")&&(t=!1)},this);var i=this.getForm().findField("gateway");i&&((e||t)&&i.reset(),i.setDisabled(e||t))},loadFormNoMask:function(e){var t;if(!1===this.onBeforeAction(this.getForm(),"get"))return!1;(t=this.getApiArray("get")).push({api:"SYNO.Core.Network.Router.Gateway.List",method:"get",version:1,params:{iptype:"ipv4",type:"wan"}}),t=this.processParams("get",t),this.sendAjaxRequestNoMask("get",t)},sendAjaxRequestNoMask:function(e,t){var i=this.getAjaxCfg(e),s=this.getCompoundCfg(e),n=Ext.apply({fileUpload:!1,clientValidation:!1,compound:{stopwhenerror:!1,params:t},scope:this,callback:function(t,i,s){t?this.onApiSuccess(e,i,s):this.onApiFailure(e,i,s)}},i);n.compound=Ext.apply(n.compound,s),this.getForm().submit(n)},onServiceOrder:function(e,t){new SYNO.SDS.AdminCenter.Network.ServiceOrderDialog({module:this.module,owner:this.module.appWin}).open()}}),Ext.define("SYNO.SDS.AdminCenter.Network.ProxyDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner;var t=this.fillConfig(e),i=e.generalSetting.getProxyValues();this.callParent([t]),this.getComponent("adv_form").getForm().setValues(i),this.checkGroupHost=new SYNO.ux.Utils.EnableCheckGroup(this.getComponent("adv_form").getForm(),"enable_different_host",["http_display","http_host","http_port","https_display","https_host","https_port"]),this.checkGroupAuth=new SYNO.ux.Utils.EnableCheckGroup(this.getComponent("adv_form").getForm(),"enable_auth",["username","password"])},fillConfig:function(e){return Ext.apply({title:_T("network","proxy_title_advanced"),width:480,height:460,padding:"16px 20px 0 20px",resizable:!1,buttons:[{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",text:_T("common","alt_apply"),btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.createAdvSetting()]},e)},onApply:function(){var e=this.getComponent("adv_form").getForm(),t=e.findField("http_host"),i=e.findField("https_host"),s=e.findField("enable_different_host").getValue(),n=""===t.getValue(),o=""===i.getValue();return e.isValid()?s&&n&&o?(this.setStatusError({text:_T("network","proxy_warning_host_blank"),clear:!0}),!1):(this.generalSetting.setProxyValues(e.getValues()),this.generalSetting.updateForm(),void this.close()):(this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1)},onCancel:function(){this.close()},createAdvSetting:function(){return{xtype:"form",border:!1,itemId:"adv_form",labelWidth:200,items:[{xtype:"syno_checkbox",name:"enable_different_host",boxLabel:_T("network","proxy_enabled_adv")},{xtype:"syno_displayfield",name:"http_display",fieldLabel:_T("network","proxy_setting_http"),indent:1},{xtype:"syno_textfield",fieldLabel:_T("network","network_address"),name:"http_host",maxlength:128,indent:1,vtype:"iporhostname"},{xtype:"syno_textfield",fieldLabel:_T("common","port"),name:"http_port",allowBlank:!0,maxlength:5,indent:1,vtype:"port"},{xtype:"syno_displayfield",name:"https_display",fieldLabel:_T("network","proxy_setting_https"),labelWidth:130,indent:1},{xtype:"syno_textfield",fieldLabel:_T("network","network_address"),name:"https_host",maxlength:128,indent:1,vtype:"iporhostname"},{xtype:"syno_textfield",fieldLabel:_T("common","port"),name:"https_port",allowBlank:!0,maxlength:5,indent:1,vtype:"port"},{xtype:"syno_checkbox",name:"enable_auth",boxLabel:_T("network","proxy_enabled_auth")},{indent:1,xtype:"syno_textfield",fieldLabel:_T("common","username"),allowBlank:!1,maxlength:64,name:"username"},{indent:1,xtype:"syno_textfield",fieldLabel:_T("common","password"),maxlength:127,textType:"password",name:"password"}]}}}),Ext.define("SYNO.SDS.AdminCenter.Network.AdvanceSettings",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.generalSetting=e.generalSetting;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){return Ext.apply({title:_T("common","adv_setting"),width:400,height:350,padding:"16px 20px 0 20px",resizable:!1,buttons:[{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",text:_T("common","alt_apply"),btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.createAdvSetting()]},e)},createAdvSetting:function(){return{xtype:"syno_formpanel",border:!1,autoHeight:!0,itemId:"advancesetting_form",items:[{xtype:"syno_checkbox",boxLabel:_T("network","route_policy_route_enable"),name:"arp_ignore"},{xtype:"syno_checkbox",boxLabel:_T("network","route_multi_gateway_enable"),name:"multi_gateway"},{xtype:"syno_checkbox",boxLabel:_T("network","ipv4_first"),name:"ipv4_first"},{xtype:"syno_checkbox",boxLabel:_T("network","enable_ip_conflict_detection"),name:"enable_ip_conflict_detect"}]}},onActivate:function(){var e=this.getComponent("advancesetting_form").getForm(),t=this.generalSetting.getForm();e.findField("arp_ignore").setValue(t.findField("arp_ignore").getValue()),e.findField("multi_gateway").setValue(t.findField("multi_gateway").getValue()),e.findField("ipv4_first").setValue(t.findField("ipv4_first").getValue()),e.findField("enable_ip_conflict_detect").setValue(t.findField("enable_ip_conflict_detect").getValue()),SYNO.SDS.AdminCenter.Network.AdvanceSettings.superclass.onActivate.call(this)},onApply:function(){var e=this.getComponent("advancesetting_form").getForm(),t=this.generalSetting.getForm();t.findField("arp_ignore").setValue(e.findField("arp_ignore").getValue()),t.findField("multi_gateway").setValue(e.findField("multi_gateway").getValue()),t.findField("ipv4_first").setValue(e.findField("ipv4_first").getValue()),t.findField("enable_ip_conflict_detect").setValue(e.findField("enable_ip_conflict_detect").getValue()),this.close()},onCancel:function(){this.close()}}),Ext.ns("SYNO.SDS.AdminCenter.Utils"),SYNO.SDS.AdminCenter.Utils.WaitHttpdRestart=function(e,t){if(!Ext.isObject(e)||!Ext.isFunction(e.IsAllowRelay))return Ext.emptyFn;var i=null,s=null,n=function(){return e.IsAllowRelay()?e.getMsgBox():(i&&!i.isDestroyed||(i=new SYNO.SDS.MessageBoxV5({modal:!0,draggable:!1,renderTo:document.body})),i.getWrapper())};return function(){var i,o;s&&(s.remove(),s=null),i=_T("service","restart_apache"),o=i||_T("common","msg_waiting"),n().show({closable:!1,msg:o}),(s=e.addWebAPITask({interval:5e3,autoJsonDecode:!0,api:"SYNO.Core.AppPortal.Config",method:"get",version:1,scope:this,callback:function(e,i,o,a){e&&(n().hide(),s.remove(),s=null,Ext.isFunction(t)&&t())},appWindow:e})).start(!1)}},Ext.define("SYNO.SDS.AdminCenter.Network.BondModeTab",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t=Ext.apply({trackResetOnLoad:!0,description:_T("network","linkaggr_mode_select")},e);return"ovs"===e.bondType?t.items=this.getOVSBondingConfig():t.items=this.getLinuxBondingConfig(),t},getLinuxBondingConfig:function(){return[{xtype:"syno_radio",boxLabel:_T("network","linkaggr_mode_alb"),name:"mode",disabled:!1===_S("ha_allow_bond_manage")||this._S("version")<5454,hidden:this._S("version")<5454,inputValue:"balance-alb",itemId:"balance-alb",checked:!0},{xtype:"syno_displayfield",indent:1,disabled:!1===_S("ha_allow_bond_manage")||this._S("version")<5454,hidden:this._S("version")<5454,value:_T("network","linkaggr_tip_alb")},{xtype:"syno_radio",boxLabel:_T("network","linkaggr_mode_8023ad"),name:"mode",disabled:!1===_S("ha_allow_bond_manage"),inputValue:"802.3ad",itemId:"802.3ad"},{xtype:"syno_displayfield",indent:1,disabled:!1===_S("ha_allow_bond_manage"),value:_T("network","linkaggr_tip_8023ad")},{xtype:"syno_radio",boxLabel:_T("network","linkaggr_mode_xor"),name:"mode",disabled:!1===_S("ha_allow_bond_manage")||this._S("version")<5454,hidden:this._S("version")<5454,inputValue:"balance-xor",itemId:"balance-xor"},{xtype:"syno_displayfield",indent:1,disabled:!1===_S("ha_allow_bond_manage")||this._S("version")<5454,hidden:this._S("version")<5454,value:_T("network","linkaggr_tip_xor")},{xtype:"syno_radio",boxLabel:_T("network","linkaggr_mode_failover"),name:"mode",disabled:!1===_S("ha_allow_bond_manage"),inputValue:"active-backup",itemId:"active-backup"},{xtype:"syno_displayfield",indent:1,disabled:!1===_S("ha_allow_bond_manage"),value:_T("network","linkaggr_tip_failover")}]},getOVSBondingConfig:function(){return[{xtype:"syno_radio",boxLabel:_T("ovs","ovs_linkaggr_mode_slb"),name:"mode",disabled:!1===_S("ha_allow_bond_manage"),inputValue:"balance-slb",itemId:"balance-slb",checked:!0},{xtype:"syno_displayfield",indent:1,disabled:!1===_S("ha_allow_bond_manage"),value:_T("ovs","ovs_linkaggr_tip_slb")},{xtype:"syno_radio",boxLabel:_T("ovs","ovs_linkaggr_mode_tcp"),name:"mode",disabled:!1===_S("ha_allow_bond_manage"),inputValue:"balance-tcp",itemId:"balance-tcp"},{xtype:"syno_displayfield",indent:1,disabled:!1===_S("ha_allow_bond_manage"),value:_T("ovs","ovs_linkaggr_tip_tcp")},{xtype:"syno_radio",boxLabel:_T("ovs","ovs_linkaggr_mode_failover"),name:"mode",disabled:!1===_S("ha_allow_bond_manage"),inputValue:"ovs-active-backup",itemId:"ovs-active-backup"},{xtype:"syno_displayfield",indent:1,disabled:!1===_S("ha_allow_bond_manage"),value:_T("ovs","ovs_linkaggr_tip_failover")}]},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){this.getComponent("802.3ad")&&SYNO.ux.AddTip(this.getComponent("802.3ad").getEl(),_T("network","linkaggr_tip_8023ad_switch"))},this,{single:!0}),this.mon(this,"afterlayout",function(){this.getComponent("balance-tcp")&&SYNO.ux.AddTip(this.getComponent("balance-tcp").getEl(),_T("network","linkaggr_tip_8023ad_switch"))},this,{single:!0})},fillContent:function(e){this.getForm().setValues(this.getConfig(e))},isDirty:function(){return this.getForm().isDirty()},isValid:function(){return this.getForm().isValid()},getWebAPISetData:function(){return{api:"SYNO.Core.Network.Bond",version:1,method:"set",params:{configs:[{ifname:this.win.ifname,mode:this.getForm().findField("mode").getGroupValue()}]}}},getWebAPIGetData:function(){return[]},getWebAPIName:function(){return this.win.ifname.indexOf("bond")>-1?"SYNO.Core.Network.Bond":""},getConfig:function(e){return{mode:e[SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix(this.getWebAPIName())+"mode"]}}}),Ext.define("SYNO.SDS.AdminCenter.Network.IPv4Tab",{extend:"SYNO.ux.FormPanel",old_config:null,constructor:function(e){this.owner=e.owner,this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t=this;return Ext.apply({module:e.module,trackResetOnLoad:!0,items:[{xtype:"syno_radio",boxLabel:_T("tcpip","tcpip_dhcp"),name:"use_dhcp",indent:0,id:this.useDhcpYesId=Ext.id(),inputValue:"yes",handler:function(e,i){t.onCheckDhcp(e,i,t)}},{xtype:"syno_radio",boxLabel:_T("tcpip","tcpip_manual"),name:"use_dhcp",indent:0,id:this.useDhcpNoId=Ext.id(),inputValue:"no",handler:function(e,i){t.onCheckDhcp(e,i,t)}},{xtype:"syno_textfield",fieldLabel:_T("tcpip","tcpip_ipaddr"),name:"ip",indent:1,allowBlank:!1,maxlength:15,vtype:"v4ip",width:350,validator:function(e){var t=e.split("."),i=this.ownerCt.getForm().findField("mask"),s=i.getValue().split(".");if(4!==t.length||4!==s.length||0!==i.getActiveError().length)return!0;var n=parseInt(t[0],10)<<24|parseInt(t[1],10)<<16|parseInt(t[2],10)<<8|parseInt(t[3],10);if(n==(n|~(parseInt(s[0],10)<<24|parseInt(s[1],10)<<16|parseInt(s[2],10)<<8|parseInt(s[3],10))))return _T("network","error_bad_broadcast_ip");if(_S("ha_running")){if(0<=_S("ha_heartbeat_ip_list").indexOf(e)){var o=_S("ha_heartbeat_ip_list").join(", ");return String.format(_T("network","ipv4_system_preserved"),o)}if("yes"===_D("support_xa")){var a=this.ownerCt.getForm().findField(this.ownerCt.useDhcpYesId).checked;if("yes"===this.ownerCt.old_config.use_dhcp&&!a&&this.ownerCt.old_config.ip===e)return _T("network","dhcp_to_static_warning")}}return!0}},{xtype:"syno_textfield",fieldLabel:_T("tcpip","tcpip_mask"),name:"mask",indent:1,allowBlank:!1,maxlength:15,vtype:"netmask",width:350,listeners:{valid:function(e){this.getForm().findField("ip").validate()},scope:this}},{xtype:"syno_textfield",fieldLabel:_T("network","route_gateway"),name:"gateway",indent:1,allowBlank:!0,vtype:"v4ip",width:350,maxlength:15,disabled:this._S("version")<4966,hidden:this._S("version")<4966,validator:function(e){var t=this.ownerCt.getForm().findField("ip").getValue(),i=this.ownerCt.getForm().findField("mask").getValue();return!(""!==e&&!SYNO.SDS.Utils.Network.GatewayMatchIP(e,t,i))||_T("common","error_notmatch")}},{xtype:"syno_textfield",fieldLabel:_T("network","route_dns"),name:"dns",allowBlank:!0,maxlength:15,indent:1,vtype:"v4ip",disabled:this._S("version")<4966,hidden:this._S("version")<4966,width:350},{xtype:"syno_checkbox",boxLabel:_T("network","usbmodem_set_as_default_gw"),name:"is_default_gateway",disabled:this._S("version")<4966,hidden:this._S("version")<4966,checked:!1},{xtype:"syno_checkbox",boxLabel:_T("tcpip","self_adjust_mtu"),name:"manual_adjust_mtu",hidden:"yes"!==this._D("supportMTU")},{xtype:"syno_combobox",fieldLabel:_T("tcpip","mtu_value_label"),name:"mtu_config",indent:1,editable:!0,width:350,store:this.MtuStore=new Ext.data.JsonStore({fields:["mtu","display"]}),displayField:"display",valueField:"mtu",hidden:"yes"!==this._D("supportMTU"),validator:function(e){return e==="1500 ("+_T("network","apple_default")+")"?(this.setDisabled(!0),this.ownerCt.getForm().findField("manual_adjust_mtu").setValue(!1),!0):-1===e.indexOf(".")&&(e=Number(e),!isNaN(Number(e))&&(!1===this.ownerCt.NetworkConnected?String.format(_T("tcpip","mtu_check_network_status")):!(this.ownerCt.MaxMTUe)||String.format(_T("tcpip","mtu_range_error"),this.ownerCt.MinMTU,this.ownerCt.MaxMTU)))}},{xtype:"syno_checkbox",boxLabel:_T("network","enable_vlan"),name:"enable_vlan",hidden:"yes"===this._D("dockerdsm")||e.win.ifname===this._D("oob_interface")},{xtype:"syno_numberfield",indent:1,fieldLabel:"VLAN ID",name:"vlan_id",allowBlank:!1,maxlength:4,minValue:1,maxValue:4094,hidden:"yes"===this._D("dockerdsm")||e.win.ifname===this._D("oob_interface"),validator:function(e){return!(4094e)}},{xtype:"syno_checkbox",boxLabel:_T("network","pppoe_relay_enabled"),name:"enable_pppoe_relay",hidden:!1},{xtype:"syno_combobox",fieldLabel:_T("network","interface"),name:"pppoe_relay_server_config",indent:1,allowBlank:!1,editable:!1,hidden:!SYNO.SDS.Utils.Network.isMultiLan.apply(this),store:this.PPPoERelayServerStore=new Ext.data.JsonStore({autoDestroy:!0,root:"devs",fields:["ifname","ifstring"]}),displayField:"ifstring",valueField:"ifname"},{xtype:"syno_checkbox",boxLabel:_T("network","upnp_service_enabled"),name:"enable_upnp",hidden:!1},{xtype:"syno_combobox",fieldLabel:_T("network","interface"),name:"upnp_server_config",indent:1,allowBlank:!1,editable:!1,hidden:!1,store:this.UPnPServerStore=new Ext.data.JsonStore({autoDestroy:!0,root:"devs",fields:["ifname","ifstring"]}),scope:this,displayField:"ifstring",valueField:"ifname"}]},e)},getMTUStore:function(){for(var e=[{mtu:1500,display:"1500 ("+_T("network","apple_default")+")"}],t=this.MinMTU;t<=1500;t+=100)e.push({mtu:t,display:t});for(t=2e3;t<=this.MaxMTU;t+=1e3)e.push({mtu:t,display:t});return e},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("enable_vlan").getEl(),_T("network","vlan_notify")),SYNO.ux.AddTip(this.getForm().findField("gateway").getEl(),_T("network","route_gateway_warning"))},this,{single:!0})},fillContent:function(e){var t=SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix(this.getWebAPIName()),i=this.getConfig(e);if(this.MinMTU=1100,this.MaxMTU=9e3,1e3>e[t+"speed"])this.MaxMTU=1500;else if(1e3===e[t+"max_supported_speed"])this.MaxMTU=parseInt(this._D("1g_maxmtu","9000"),10);else if("bond"===e[t+"type"]||"ovsbond"===e[t+"type"])for(var s=0;so.indexOf(e)&&n.push({ifname:e,ifstring:SYNO.SDS.Utils.Network.idToString.apply(s,[e])})}),n},isDirty:function(){return this.getForm().isDirty()},isValid:function(){return!1!==this.checkConfigInHA(this.prepareWebAPISetMainData())&&(!1!==this.checkConfigInAHA(this.prepareWebAPISetMainData())&&this.getForm().isValid())},getWebAPISetData:function(){var e=[this.procWebAPISetMainData()];return!0===this.nat&&(e.push(this.procWebAPISetRelayData()),e.push(this.procWebAPISetUPnPData())),e},getWebAPIGetData:function(){var e=[{api:this.getWebAPIName(),version:1,method:"get",params:{ifname:this.win.ifname}},{api:"SYNO.Core.Network.PPPoE.Relay",method:"get",version:1,params:{ifname:this.win.ifname}},{api:"SYNO.Core.Network.UPnPServer",method:"get",version:1,params:{ifname:this.win.ifname}}];return Ext.isEmpty(this.getKnownAPI("SYNO.GlusterfsMgmt.Service"))||e.push({api:"SYNO.GlusterfsMgmt.Service",method:"get",version:1,params:{}}),e},prepareWebAPISetMainData:function(){var e=this.getForm(),t={ifname:this.win.ifname,use_dhcp:e.findField(this.useDhcpYesId).checked,enable_ha_ip:_S("has_ha_if")&&e.findField(this.enableHAIpYesId).checked};return!1!==t.use_dhcp&&!0!==_S("has_ha_if")||(t.ip=e.findField("ip").getValue(),t.mask=e.findField("mask").getValue(),t.gateway=e.findField("gateway").getValue(),t.dns=e.findField("dns").getValue()),!0===_S("has_ha_if")&&!1===t.enable_ha_ip&&(t.ip=this.old_config.ip,t.mask=this.old_config.mask,t.gateway=this.old_config.gateway,t.dns=this.old_config.dns),t.is_default_gateway=e.findField("is_default_gateway").getValue(),!0===e.findField("manual_adjust_mtu").getValue()?t.mtu=e.findField("mtu_config").getValue():t.mtu=1500,t.enable_vlan=e.findField("enable_vlan").getValue(),!0===t.enable_vlan&&(t.vlan_id=e.findField("vlan_id").getValue()),t},procWebAPISetMainData:function(){var e=this.prepareWebAPISetMainData();return!1!==this.checkConfigInHA(e)&&(!1!==this.checkConfigInAHA(e)&&{api:this.getWebAPIName(),version:1,method:"set",params:{configs:[e]}})},checkConfigInHA:function(e){if(!0!==_S("has_ha_if"))return!0;var t=function(e){var t=e.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);return t?(+t[1]<<24)+(+t[2]<<16)+(+t[3]<<8)+ +t[4]:0},i=SYNO.SDS.Utils.Network.idToString.apply(this,[this.win.ifname]),s=[],n=this.getForm().findField("manual_adjust_mtu").getValue(),o=this.getForm().findField("mtu_config").getValue(),a=this.getForm().findField("enable_vlan").getValue(),r=this.getForm().findField("vlan_id").getValue(),l=t(e.mask);return!0===e.use_dhcp&&this.old_config.gateway!==e.gateway&&s.push(String.format(_TT("SYNO.SDS.HA.Instance","ui","cannot_change_setting_dhcp"),i,_T("network","route_gateway"))),!0===e.use_dhcp&&this.old_config.dns!==e.dns&&s.push(String.format(_TT("SYNO.SDS.HA.Instance","ui","cannot_change_setting_dhcp"),i,_T("network","route_dns"))),!0===this.old_config.is_main_ha_ip&&!1===e.enable_ha_ip&&s.push(String.format(_TT("SYNO.SDS.HA.Instance","config","cannot_disable_main_if"),i)),!0!==this.old_config.is_main_ha_ip||this.old_config.manual_adjust_mtu===n&&this.old_config.mtu_config===o||s.push(String.format(_TT("SYNO.SDS.HA.Instance","ui","cannot_change_mtu_main_if"),i)),(this.old_config.enable_vlan!==a||this.old_config.vlan_id&&this.old_config.vlan_id!==r)&&s.push(String.format(_TT("SYNO.SDS.HA.Instance","ui","not_allow_vlan_setting"),i)),(t(this.old_config.ha_local_ip)&l)!=(t(e.ip)&l)&&s.push(String.format(_T("dhcp_server","option_in_same_subnet_warn"),e.ip,this.old_config.ha_local_ip)),0===s.length||(this.win.getMsgBox().alert(_TT("SYNO.SDS.HA.Instance","app","app_name"),s.join("
    ")),!1)},isInvalidAHAIP:function(e,t){var i=e.split("."),s=t.split(".");if(4!==i.length||4!==s.length)return!1;return-1442906113==(parseInt(i[0],10)<<24|parseInt(i[1],10)<<16|parseInt(i[2],10)<<8|parseInt(i[3],10)|~(parseInt(s[0],10)<<24|parseInt(s[1],10)<<16|parseInt(s[2],10)<<8|parseInt(s[3],10)))},checkConfigInAHA:function(e){if("yes"!==this._D("support_dual_head"))return!0;if(!1===e.use_dhcp&&this.isInvalidAHAIP(e.ip,e.mask)){var t=String.format(_TT("SYNO.SDS.AHA.Instance","uicommon","ip_forbidden"),e.ip,e.mask);return this.win.getMsgBox().alert(_TT("SYNO.SDS.AHA.Instance","uicommon","name"),t),!1}return!0},procWebAPISetRelayData:function(){var e=this.getForm();return{api:"SYNO.Core.Network.PPPoE.Relay",method:"set",version:1,params:{ifname:this.win.ifname,enabled:e.findField("enable_pppoe_relay").getValue(),server_interface:e.findField("pppoe_relay_server_config").getValue()}}},procWebAPISetUPnPData:function(){var e=this.getForm();return{api:"SYNO.Core.Network.UPnPServer",method:"set",version:1,params:{ifname:this.win.ifname,enabled:e.findField("enable_upnp").getValue(),server_interface:e.findField("upnp_server_config").getValue()}}},getWebAPIName:function(){var e="";return this.win.ifname&&(e=this.win.ifname),e.indexOf("eth")>-1?"SYNO.Core.Network.Ethernet":e.indexOf("bond")>-1?"SYNO.Core.Network.Bond":""},hideFields:function(e){var t=this.getForm();Ext.each(e,function(e){t.findField(e).hide()},this)},setGroup:function(){var e=this.getForm();this.isComputingOrStorageNode||(this.checkGroupDHCP=new SYNO.ux.Utils.EnableRadioGroup(e,"use_dhcp",{no:["ip","mask","gateway","dns"]}),this.checkGroupVlan=new SYNO.ux.Utils.EnableCheckGroup(e,"enable_vlan",["vlan_id"])),this.checkGroupMTU=new SYNO.ux.Utils.EnableCheckGroup(e,"manual_adjust_mtu",["mtu_config"]),this.checkGroupPPPoERelay=new SYNO.ux.Utils.EnableCheckGroup(e,"enable_pppoe_relay",["pppoe_relay_server_config"]),this.checkGroupUPNP=new SYNO.ux.Utils.EnableCheckGroup(e,"enable_upnp",["upnp_server_config"])},getConfig:function(e){var t=SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix(this.getWebAPIName()),i={};return 0!==e[t+"vlan_id"]&&(i.vlan_id=e[t+"vlan_id"]),1500===e[t+"mtu_config"]?(i.manual_adjust_mtu=!1,i.mtu_config=1500):(i.manual_adjust_mtu=!0,i.mtu_config=e[t+"mtu_config"]),i.ip=e[t+"ip"],i.mask=e[t+"mask"],i.gateway=e[t+"gateway"],i.dns=e[t+"dns"],i.is_default_gateway=e[t+"is_default_gateway"],i.use_dhcp=e[t+"use_dhcp"]?"yes":"no",i.enable_ha_ip=e[t+"enable_ha_ip"]?"yes":"no",i.is_main_ha_ip=e[t+"is_main_ha_ip"],i.enable_vlan=e[t+"enable_vlan"],i.enable_pppoe_relay=e.pppoe_relay_enabled,i.pppoe_relay_server_config=e.pppoe_relay_server_interface,!i.pppoe_relay_server_config&&e.pppoe_relay_server_list&&(i.pppoe_relay_server_config=e.pppoe_relay_server_list[0]),i.enable_upnp=e.upnpserver_enabled,i.upnp_server_config=e.upnpserver_server_interface,!i.upnp_server_config&&e.upnpserver_server_list&&(i.upnp_server_config=e.upnpserver_server_list[0]),_S("has_ha_if")&&(i.ha_local_ip=e[t+"ha_local_ip"]),this.NetworkConnected="connected"==e[t+"status"],i},loadStoreData:function(e){this.PPPoERelayServerStore.loadData({success:!0,devs:this.getServerInterfaceMappingList(e.pppoe_relay_server_list)},!1),this.UPnPServerStore.loadData({success:!0,devs:this.getServerInterfaceMappingList(e.upnpserver_server_list,this.win.ifname,e.upnpserver_config_list)},!1),this.MtuStore.loadData(this.getMTUStore(),!1)},isNeedConfirm:function(){var e=this.getForm().findField("manual_adjust_mtu").getValue(),t=this.getForm().findField("mtu_config").getValue();return(this.old_config.manual_adjust_mtu!==e||this.old_config.mtu_config!==t)&&(this.confirmMsg=_T("network","mtu_warning_msg"),!0)},getConfirmMsg:function(){return this.confirmMsg},onCheckDhcp:function(e,t,i){e.checked&&Ext.getCmp("oobTabId")&&("yes"===e.value?!0===Ext.getCmp(Ext.getCmp("oobTabId").oobShellEnableCheckBoxId).getValue()?i.win.getMsgBox().confirm("",_T("oob","oob_dhcp_disable_confirm"),function(e){"yes"===e?Ext.getCmp("oobTabId").updateOobEnable(!1):Ext.getCmp(i.useDhcpYesId).setValue("no")},this):Ext.getCmp("oobTabId").updateOobEnable(!1):Ext.getCmp("oobTabId").updateOobEnable(!0))}}),Ext.define("SYNO.SDS.AdminCenter.Network.IPv6Tab",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.callParent([this.fillConfig(e)]),this.on("activate",function(){_S("ha_running")&&this.el.mask(_TT("SYNO.SDS.HA.Instance","ui","ha_not_support_setting"),"syno-ux-mask-info")},this),this.on("deactivate",function(){_S("ha_running")&&this.el.unmask()},this)},fillConfig:function(e){return Ext.apply({title:"IPv6",module:e.module,trackResetOnLoad:!0,defaults:{width:330},items:[{xtype:"syno_combobox",fieldLabel:_T("tcpip","ipv6_setup"),name:"ipv6_type",disabled:!0===_S("ha_running"),allowBlank:!1,valueField:"value",displayField:"display",hiddenName:"ipv6_type",store:new Ext.data.SimpleStore({fields:["value","display"],data:this.getTypeData()}),listeners:{select:function(e){this.onSelect(e.getValue())},beforeselect:this.onBeforeSelect,scope:this}},{xtype:"syno_textfield",fieldLabel:_T("status","status_ipv6addr"),name:"ipv6_ip",disabled:!0===_S("ha_running"),allowBlank:!1,vtype:"v6ip"},{xtype:"syno_numberfield",fieldLabel:_T("tcpip","ipv6_prefixleng"),name:"ipv6_prefix_length",disabled:!0===_S("ha_running"),allowBlank:!1,vtype:"v6prefixLeng",listeners:{focus:function(e){const t=e.getValue();t||0===t||e.setValue(64)}}},{xtype:"syno_textfield",fieldLabel:_T("tcpip","ipv6_router"),name:"ipv6_router",disabled:!0===_S("ha_running"),allowBlank:!0,vtype:"v6ip"},{xtype:"syno_textfield",fieldLabel:_T("tcpip","primary_dns"),disabled:!0===_S("ha_running")||_S("version")<4966,hidden:_S("version")<4966,name:"ipv6_dns",allowBlank:!0,vtype:"v6ip"},{xtype:"syno_textfield",fieldLabel:_T("status","status_ipv6addr"),disabled:!0===_S("ha_running"),name:"ipv6_router_local_addr_v6",allowBlank:!1,vtype:"v6ip"},{xtype:"syno_numberfield",fieldLabel:_T("tcpip","ipv6_prefixleng"),disabled:!0===_S("ha_running"),name:"ipv6_router_prefix_length",allowBlank:!1,vtype:"v6prefixLeng"},new SYNO.ux.CompositeField({name:"prefix_composite",items:[{xtype:"syno_textfield",fieldLabel:_T("tcpip","ipv6_prefix"),name:"ipv6_router_prefix",disabled:!0===_S("ha_running"),allowBlank:!1,vtype:"v6ip",width:250},{xtype:"syno_displayfield",value:"/64"}]}),{xtype:"syno_textfield",fieldLabel:_T("tcpip","remote_ipv4_address"),name:"ipv6_router_remote_addr_v4",disabled:!0===_S("ha_running"),allowBlank:!1,vtype:"v4ip"},{xtype:"syno_checkbox",boxLabel:_T("network","usbmodem_set_as_default_gw"),name:"is_default_gateway",disabled:!0===_S("ha_running")||_S("version")<4966,hidden:_S("version")<4966,checked:!1}]},e)},getTypeData:function(){var e;return e=_S("version")<4966?[["auto",_T("tcpip","ipv6_auto")],["dhcp",_T("tcpip","ipv6_dhcp")],["static",_T("tcpip","ipv6_static")],["off",_T("tcpip","ipv6_off")]]:[["off",_T("tcpip","ipv6_off")],["auto",_T("tcpip","ipv6_auto")],["static",_T("tcpip","ipv6_static")]],_S("version")>4966&&!this.isWifiClient&&(e=e.concat([["6in4",_T("tcpip","ipv6_6in4")],["6to4",_T("tcpip","ipv6_6to4")],["native",_T("tcpip","ipv6_dhcp_pd")]])),e},fillContent:function(e){var t=this.getForm();SYNO.ux.AddTip(t.findField("ipv6_router").getEl(),_T("network","route_gateway_warning")),t.setValues(this.getConfig(e)),this.onSelect(t.findField("ipv6_type").getValue())},getConfig:function(e){var t=SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix("SYNO.Core.Network.IPv6.Router"),i=e[t+"config"],s=this.getIPv6Type(e.ipv6_type,e[t+"type"],i);this.isDefgw=e.ipv6_is_default_gateway,this.isTunDefgw=e[t+"is_default_gateway"];var n={is_default_gateway:this.isTunnelType(s)?this.isTunDefgw:this.isDefgw,ipv6_type:s,ipv6_ip:e.ipv6_ip,ipv6_prefix_length:e.ipv6_prefix_length,ipv6_router:e.ipv6_router,ipv6_dns:e.ipv6_dns};return"6in4"===n.ipv6_type||"6to4"===n.ipv6_type?(n.ipv6_router_local_addr_v6=i.local_addr_v6.substring(0,i.local_addr_v6.indexOf("/")),n.ipv6_router_prefix_length=i.local_addr_v6.substring(i.local_addr_v6.indexOf("/")+1),n.ipv6_router_prefix=i.prefix.substring(0,i.prefix.indexOf("/")),n.ipv6_router_remote_addr_v4=i.remote_addr_v4):"native"===n.ipv6_type&&i.prefix&&(n.ipv6_router_prefix=i.prefix.substring(0,i.prefix.indexOf("/"))),n},getIPv6Type:function(e,t,i){return i&&i.wan&&i.wan===this.win.ifname?"off"===t?e:t:e},isDirty:function(){return this.getForm().isDirty()},isValid:function(){return this.getForm().isValid()},isRouterType:function(e){return"6in4"===e||"6to4"===e||"native"===e},isTunnelType:function(e){return"6in4"===e||"6to4"===e},getWebAPISetData:function(){var e=[],t=this.getForm().findField("ipv6_type").getValue();return this.isRouterType(t)?("native"==t&&e.push(this.getIPv6WebAPISetData()),e.push(this.getIPv6RouterWebAPISetData())):(e.push(this.getIPv6WebAPISetData()),this.isWifiClient||e.push({api:"SYNO.Core.Network.IPv6.Router",version:1,method:"set",params:{type:"off",config:{wan:this.win.ifname}}})),e},getIPv6WebAPISetData:function(){var e=this.getForm(),t=e.findField("ipv6_type").getValue(),i={ifname:this.win.ifname,type:"native"==t?"auto":t,is_default_gateway:e.findField("is_default_gateway").getValue(),force:!0};return"static"===i.type&&(i.ip=e.findField("ipv6_ip").getValue(),i.prefix_length=e.findField("ipv6_prefix_length").getValue(),i.router=e.findField("ipv6_router").getValue(),i.dns=e.findField("ipv6_dns").getValue()),{api:"SYNO.Core.Network.IPv6",version:1,method:"set",params:i}},getIPv6RouterWebAPISetData:function(){var e=this.getForm(),t={wan:this.win.ifname,is_default_gateway:e.findField("is_default_gateway").getValue()};return"6in4"===e.findField("ipv6_type").getValue()&&(t.prefix=e.findField("ipv6_router_prefix").getValue()+"/64",t.remote_addr_v4=e.findField("ipv6_router_remote_addr_v4").getValue(),t.local_addr_v6=e.findField("ipv6_router_local_addr_v6").getValue()+"/"+e.findField("ipv6_router_prefix_length").getValue()),{api:"SYNO.Core.Network.IPv6.Router",version:1,method:"set",params:{type:e.findField("ipv6_type").getValue(),config:t}}},getWebAPIGetData:function(){return[{api:"SYNO.Core.Network.IPv6",version:1,method:"get",params:{ifname:this.win.ifname}},{api:"SYNO.Core.Network.IPv6.Router",version:1,method:"get",params:{wan:this.win.ifname}}]},onBeforeSelect:function(e,t,i){var s=e.getValue(),n=t.get("value");return!(!this.isRouterType(s)&&this.isRouterType(n))||(e.collapse(),this.win.getMsgBox().confirm("",_T("tcpip","ipv6_tunnel_warning"),function(t){"yes"===t&&(e.setValue(n),this.onSelect(n))},this),!1)},onSelect:function(e){var t;t=_S("version")>=4966?["ipv6_ip","ipv6_prefix_length","ipv6_router","ipv6_dns"]:["ipv6_ip","ipv6_prefix_length","ipv6_router"];var i=["ipv6_router_remote_addr_v4","ipv6_router_local_addr_v6","ipv6_router_prefix_length"],s=["prefix_composite"];switch(this.getForm().findField("is_default_gateway").setValue(this.isTunnelType(e)?this.isTunDefgw:this.isDefgw),this.isTunnelType(e)?(this.hideFields(t,!0),this.hideFields(i,!1),this.hideFields(s,!1),this.enableFields(t,!1)):(this.hideFields(t,!1),this.hideFields(i,!0),"native"==e?this.hideFields(s,!1):this.hideFields(s,!0),this.enableFields(i,!1),this.enableFields(s,!1)),e){case"static":this.enableFields(t,!0);break;case"off":case"dhcp":case"auto":case"native":this.enableFields(t,!1),this.getForm().clearInvalid();break;case"6in4":this.enableFields(s,!0),this.enableFields(i,!0);break;case"6to4":this.enableFields(s,!1),this.enableFields(i,!1),this.getForm().clearInvalid();break;default:SYNO.Debug("Unknown type: "+e)}},syncMask:function(e){},enableFields:function(e,t){Ext.each(e,function(e){var i=this.getForm().findField(e);return t?i.enable():i.disable()},this)},hideFields:function(e,t){Ext.each(e,function(e){var i=this.getForm().findField(e);return t?i.hide():i.show()},this)}}),Ext.define("SYNO.SDS.AdminCenter.Network.PPPoEIPv6Tab",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.callParent([this.fillConfig(e)])},fillConfig:function(e){return Ext.apply({title:"IPv6",hideMode:"offsets",module:e.module,trackResetOnLoad:!0,defaults:{width:330},items:[{xtype:"syno_combobox",fieldLabel:_T("tcpip","ipv6_setup"),name:"ipv6_type",allowBlank:!1,valueField:"value",displayField:"display",hiddenName:"ipv6_type",store:new Ext.data.SimpleStore({fields:["value","display"],data:[["off",_T("tcpip","ipv6_auto")],["6in4",_T("tcpip","ipv6_6in4")],["6to4",_T("tcpip","ipv6_6to4")],["native",_T("tcpip","ipv6_dhcp_pd")]]}),listeners:{select:function(e){this.onSelect(e.getValue())},beforeSelect:this.onBeforeSelect,scope:this}},{xtype:"syno_textfield",fieldLabel:_T("status","status_ipv6addr"),name:"ipv6_router_local_addr_v6",allowBlank:!1,vtype:"v6ip"},{xtype:"syno_numberfield",fieldLabel:_T("tcpip","ipv6_prefixleng"),name:"ipv6_router_prefix_length",allowBlank:!1,vtype:"v6prefixLeng"},new SYNO.ux.CompositeField({name:"prefix_composite",items:[{xtype:"syno_textfield",fieldLabel:_T("tcpip","ipv6_prefix"),name:"ipv6_router_prefix",allowBlank:!1,vtype:"v6ip",width:250},{xtype:"syno_displayfield",value:"/64"}]}),{xtype:"syno_textfield",fieldLabel:_T("tcpip","remote_ipv4_address"),name:"ipv6_router_remote_addr_v4",allowBlank:!1,vtype:"v4ip"},{xtype:"syno_checkbox",boxLabel:_T("network","usbmodem_set_as_default_gw"),name:"is_default_gateway",disabled:!0===_S("ha_running"),checked:!1}]},e)},fillContent:function(e){var t=this.getForm();t.setValues(this.getConfig(e)),this.onSelect(t.findField("ipv6_type").getValue())},getConfig:function(e){var t=SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix("SYNO.Core.Network.IPv6.Router"),i=e[t+"config"],s={is_default_gateway:e[t+"is_default_gateway"],ipv6_type:e[t+"type"]};return i&&"pppoe"!==i.wan?s:("6in4"===s.ipv6_type||"6to4"===s.ipv6_type?(s.ipv6_router_local_addr_v6=i.local_addr_v6.substring(0,i.local_addr_v6.indexOf("/")),s.ipv6_router_prefix_length=i.local_addr_v6.substring(i.local_addr_v6.indexOf("/")+1),s.ipv6_router_prefix=i.prefix.substring(0,i.prefix.indexOf("/")),s.ipv6_router_remote_addr_v4=i.remote_addr_v4):"native"===s.ipv6_type&&i.prefix&&(s.ipv6_router_prefix=i.prefix.substring(0,i.prefix.indexOf("/"))),s)},isDirty:function(){return this.getForm().isDirty()},isValid:function(){return this.getForm().isValid()},getWebAPISetData:function(){var e=this.getForm(),t={wan:this.win.ifname,is_default_gateway:e.findField("is_default_gateway").getValue()};return"6in4"===e.findField("ipv6_type").getValue()&&(t.prefix=e.findField("ipv6_router_prefix").getValue()+"/64",t.remote_addr_v4=e.findField("ipv6_router_remote_addr_v4").getValue(),t.local_addr_v6=e.findField("ipv6_router_local_addr_v6").getValue()+"/"+e.findField("ipv6_router_prefix_length").getValue()),{api:"SYNO.Core.Network.IPv6.Router",version:1,method:"set",params:{type:e.findField("ipv6_type").getValue(),config:t}}},getWebAPIGetData:function(){return{api:"SYNO.Core.Network.IPv6.Router",version:1,method:"get",params:{wan:this.win.ifname}}},onBeforeSelect:function(e,t,i){var s=e.getValue(),n=t.get("value");return"off"!==s||"off"===n||(e.collapse(),this.win.getMsgBox().confirm("",_T("tcpip","ipv6_tunnel_warning"),function(t){"yes"===t&&(e.setValue(n),this.onSelect(n))},this),!1)},onSelect:function(e){var t=["prefix_composite","ipv6_router_remote_addr_v4","ipv6_router_local_addr_v6","ipv6_router_prefix_length"];switch(e){case"6in4":this.enableFields(t,!0);break;case"off":case"6to4":case"native":this.enableFields(t,!1),this.getForm().clearInvalid();break;default:SYNO.Debug("Unknown type: "+e)}},enableFields:function(e,t){Ext.each(e,function(e){var i=this.getForm().findField(e);return t?i.enable():i.disable()},this)}}),Ext.define("SYNO.SDS.AdminCenter.Network.EditDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.addListener("destroy",e.module.startPolling,e.module),this.init()},fillConfig:function(e){return this.owner=e.owner,this.ifname=e.ifname,this.getQCInfoAPI={api:"SYNO.Core.QuickConnect",version:this.getQcWebApiVersion(),method:"get"},Ext.apply({title:_T("common","alt_edit"),width:790,height:570,resizable:!1,layout:"fit",items:[this.getTabPanel(e)],buttons:[{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",text:_T("common","alt_apply"),disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",btnStyle:"blue",scope:this,handler:this.onApply}]},e)},getTabPanel:function(e){return this.tabpanel||(this.tabpanel=new SYNO.SDS.AdminCenter.Network.EditTabPanel({module:e.module,owner:e.owner,win:this,tabs:e.tabs,ifname:this.ifname})),this.tabpanel},onApply:function(){if(this.tabpanel.isDirty()){var e=this.tabpanel.getInvalidTab();if(e){var t=_T("common","forminvalid");return"function"==typeof e.getErrorMsg&&(t=e.getErrorMsg()),this.tabpanel.setActiveTab(e),void this.setStatusError({text:t})}if(Ext.isDefined(this.tabpanel.ipv6Panel)){var i=this.tabpanel.ipv6Panel.form.findField("ipv6_type").getValue();SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.Network.DHCPv6",!0),"auto"!==i&&"native"!==i||SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.Network.DHCPv6",!1)}this.doApply()}else this.onCancel()},doApply:function(){var e=this.tabpanel.getConfirmTabs();0"+SYNO.SDS.Utils.GetFeasibilityCheckMsg(t.hard[c]);return a=String.format(_T("network","dhcp_feasibility_check_fail"),i),!1}}return n=SYNO.API.getErrorString(e.error.code),!1}},this),!0===o&&(n=_T("error","nochange_subject"),this.getMsgBox().alert(_T("controlpanel","leaf_lan"),a)),void this.setStatusError({text:n,clear:!0})}var r="SYNO.SDS.CMS.Application"===this.findAppWindow().getOpenConfig("className"),l=!0===this.findAppWindow().getOpenConfig("cms_self");if((!r||l)&&t&&t.result)for(var d=null,c=0;c-1&&(t="ovs"),this.bondModePanel||(this.bondModePanel=new SYNO.SDS.AdminCenter.Network.BondModeTab({title:_T("network","linkaggr_mode"),module:e.module,owner:e.owner,win:e.win,bondType:t})),this.bondModePanel},getIPv4Panel:function(e){var t={title:"IPv4",module:e.module,owner:e.owner,win:e.win,parentPanel:this};return this.ipv4Panel||(this.ipv4Panel=new SYNO.SDS.AdminCenter.Network.IPv4Tab(t)),this.ipv4Panel},getIPv6Panel:function(e){var t={title:"IPv6",module:e.module,owner:e.owner,win:e.win,parentPanel:this};return this.ipv6Panel||("pppoe"===e.win.ifname?this.ipv6Panel=new SYNO.SDS.AdminCenter.Network.PPPoEIPv6Tab(t):this.ipv6Panel=new SYNO.SDS.AdminCenter.Network.IPv6Tab(t)),this.ipv6Panel},getAuthPanel:function(e){return this.authPanel||(this.authPanel=new SYNO.SDS.AdminCenter.Network.AuthTab({module:e.module,owner:e.owner,win:e.win,parentPanel:this})),this.authPanel},getOobPanel:function(e){var t={module:e.module,owner:e.owner,win:e.win,parentPanel:this};return this.oobPanel||(this.oobPanel=new SYNO.SDS.AdminCenter.Network.OobTab(t)),this.oobPanel},fillContent:function(e){this.items.each(function(t){t.fillContent(e)})},isDirty:function(){var e=!1;return this.items.each(function(t){t.isDirty()&&(e=!0)}),e},getInvalidTab:function(){var e;return this.items.each(function(t){t.isValid()||(e=t)}),e},getConfirmTabs:function(){var e=[];return this.items.each(function(t){Ext.isDefined(t.isNeedConfirm)&&t.isNeedConfirm()&&e.push(t)}),e},getWebAPIGetData:function(){var e=[];return this.items.each(function(t){var i=t.getWebAPIGetData();i instanceof Array?Ext.each(i,function(t){e.push(t)}):e.push(i)}),e},getWebAPISetData:function(){var e=[];return this.items.each(function(t){if(t.getWebAPISetData&&t.isDirty()){var i=t.getWebAPISetData();i instanceof Array?Ext.each(i,function(t){e.push(t)}):e.push(i)}}),e}}),Ext.ns("SYNO.SDS.AdminCenter.Network.Ethernet"),SYNO.SDS.AdminCenter.Network.Ethernet.getWebAPI=function(){return{api:"SYNO.Core.Network.Ethernet",method:"list",version:2,callback:function(e){Ext.each(e,function(e,t,i){var s="net-";"wan"===e.type?s+="wan-":s+="lan-","connected"===e.status?s+="connected":s+="disconnected",e.cls=s})}}},SYNO.SDS.AdminCenter.Network.Ethernet.setARIAInfo=function(e){var t=SYNO.SDS.AdminCenter.Network.Utils;if(e.ariaInfo=String.format("{0} {1} ",t.getTitle(e.title,e,this),t.getStatusStr(e.status)),"connected"==e.status||"enabled"==e.status){if("bond"==e.type){e.ariaInfo+=String.format("{0} {1} ",_T("network","interface"),_T("tcpip","link_status"));for(var i=0;i',"
    ",'
    {ifname:this.getTitle}
    ','
    {link_status:this.getLinkStatus}
    ',"
    ",'
    ',"");return new Ext.XTemplate("","
    ",String.format(e,_T("tcpip","tcpip_mask"),!0===_S("has_ha_if")?"{ha_local_mask:this.toEmptyDash}":"{mask:this.toEmptyDash}"),String.format(e,_T("status","status_ipv6addr"),"{ipv6:this.toMultiLine}"),'',String.format(e,_T("tcpip","MTU_setting"),_T("tcpip","MTU_enable")+" {mtu}"),"",'',String.format(e,_T("tcpip","link_status"),"{link_status:this.getLinkStatus}"),"",'',String.format(e,"VLAN ID","{vlan_id}"),"","
    ","",'
    ','
    ',"
    ",String.format('
    {0}
    ',_T("network","interface")),String.format('
    {0}
    ',_T("tcpip","link_status")),"
    ","
    ",'
    ',t.html,"
    ","
    ",'
    ',"
    ","
    {ariaInfo:this.setARIAInfo}
    ","
    ").html},SYNO.SDS.AdminCenter.Network.Ethernet.getIpTpl=function(){return""+(!0===_S("has_ha_if")?"{ha_local_ip:this.toEmptyDash}":"{ip:this.toEmptyDash}")+""},SYNO.SDS.AdminCenter.Network.Ethernet.getBtnConfig=function(){return{editBtn:{isDisabled:!1,handler:SYNO.SDS.AdminCenter.Network.Ethernet.onEdit},deleteBtn:{isDisabled:!0,handler:null},connectBtn:{isDisabled:!0,handler:null}}},SYNO.SDS.AdminCenter.Network.Ethernet.onEdit=function(){if(!0!==_S("manage_eth_in_ha_pkg")){this.module.stopPolling();var e=12&this.selectedRecord.get("block");if(0",String.format(e,_T("pppoe","pppoe_mask"),"{mask:this.toEmptyDash}"),String.format(e,_T("status","status_ipv6addr"),"{ipv6:this.toMultiLine}"),"
    {ariaInfo:this.setARIAInfo}
    ","").html},SYNO.SDS.AdminCenter.Network.PPPoE.getIpTpl=function(){return"{ip:this.toEmptyDash}"},SYNO.SDS.AdminCenter.Network.PPPoE.getBtnConfig=function(){return{editBtn:{isDisabled:function(){return"connecting"===this.selectedRecord.get("status")},handler:SYNO.SDS.AdminCenter.Network.PPPoE.onEdit},deleteBtn:{isDisabled:!0,handler:null},connectBtn:{text:function(){return"disconnected"===this.selectedRecord.get("status")?_T("vpnc","connect"):_T("vpnc","disconnect")},isDisabled:function(){return""===this.selectedRecord.get("username")},handler:SYNO.SDS.AdminCenter.Network.PPPoE.onConnect}}},SYNO.SDS.AdminCenter.Network.PPPoE.onEdit=function(){var e;!0!==_S("ha_running")?(this.module.stopPolling(),(e="disconnected"===this.selectedRecord.get("status")?new SYNO.SDS.AdminCenter.Network.PPPoE.EditDialog({module:this.module,owner:this.module.appWin}):new SYNO.SDS.AdminCenter.Network.EditDialog({module:this.module,owner:this.module.appWin,ifname:"pppoe",tabs:["ipv6"]})).addListener("destroy",function(){this.module.startPolling()},this),e.open()):this.module.getHAMsgBox()},SYNO.SDS.AdminCenter.Network.PPPoE.onConnect=function(){var e=SYNO.SDS.AdminCenter.Network.PPPoE.sendCommand,t=SYNO.SDS.AdminCenter.Network.PPPoE.loadFwStatus;!0!==_S("ha_running")?"disconnected"===this.selectedRecord.get("status")?!0===this.selectedRecord.get("guest_enabled")?this.module.appWin.getMsgBox().confirm(_T("pppoe","pppoe_title"),_T("pppoe","pppoe_close_guest"),function(e){"yes"===e&&t.apply(this)},this):t.apply(this):e.apply(this,["disconnect"]):this.module.getHAMsgBox()},SYNO.SDS.AdminCenter.Network.PPPoE.loadFwStatus=function(){var e=SYNO.SDS.AdminCenter.Network.PPPoE.sendCommand.bind(this),t=SYNO.SDS.AdminCenter.Network.PPPoE.loadFwProfileAndPortInfo.bind(this);this.sendWebAPI({api:"SYNO.Core.Security.Firewall",method:"get",version:1,callback:function(i,s){i&&s.hasOwnProperty("enable_firewall")&&s.profile_name?t({fwEnabled:s.enable_firewall,profileName:s.profile_name}):e("connect")},scope:this})},SYNO.SDS.AdminCenter.Network.PPPoE.loadFwProfileAndPortInfo=function(e){if(e&&e.profileName){var t=SYNO.SDS.AdminCenter.Network.PPPoE.sendCommand.bind(this),i=SYNO.SDS.AdminCenter.Network.PPPoE.showFwConfirmMsgBoxAndOpenWhiteListDialog.bind(this),s=[{api:"SYNO.Core.Security.Firewall.Profile",method:"get",version:1,params:{name:e.profileName}},{api:"SYNO.Core.Service.PortInfo",method:"load",version:1}];this.sendWebAPI({compound:{stopwhenerror:!0,params:s},callback:function(s,n){if(s){e.profile=SYNO.API.Response.GetValByAPI(n,"SYNO.Core.Security.Firewall.Profile","get");var o=SYNO.API.Response.GetValByAPI(n,"SYNO.Core.Service.PortInfo","load");e.profile&&o?(e.portInfo=[],SYNO.SDS.AdminCenter.Utils.Render.ServerPortsParsing(o,e.portInfo,!1),i(e)):t("connect")}else t("connect")},scope:this})}},SYNO.SDS.AdminCenter.Network.PPPoE.showFwConfirmMsgBoxAndOpenWhiteListDialog=function(e){if(e&&e.profile&&e.hasOwnProperty("fwEnabled")&&e.profileName&&e.portInfo){var t=SYNO.SDS.AdminCenter.Network.PPPoE.sendCommand.bind(this),i=e.profile;if(!i.hasOwnProperty("pppoe")||i.pppoe&&"allow"===i.pppoe.policy&&i.pppoe.rules instanceof Array&&0===i.pppoe.rules.length){var s=e.fwEnabled?_T("pppoe","pppoe_firewall_policy_change"):_T("pppoe","pppoe_firewall_enable");this.module.appWin.getMsgBox().confirm("",s,function(i){if("yes"===i){var s=new SYNO.SDS.AdminCenter.Network.PPPoE.WhiteListDialog({module:this.module,owner:this.module.appWin,serverPorts:e.portInfo,settings:e,sendCommand:t});s.setVal(""),s.open()}else t("connect")}.bind(this))}else t("connect")}},SYNO.SDS.AdminCenter.Network.PPPoE.sendCommand=function(e){if(this.sendWebAPI({api:"SYNO.Core.Network.PPPoE",method:e,version:1,params:{ifname:"pppoe"},callback:function(){this.module.connectingFlag=!1,this.module.stopPolling(),this.module.startPolling()},scope:this}),"connect"===e){this.module.connectingFlag=!0;var t=this.getTopToolbar().getComponent("connectBtn"),i=this.getTopToolbar().getComponent("editBtn");t.disable(),i.disable(),t.setText(_T("vpnc","disconnect")),this.selectedRecord.set("status","connecting")}this.module.stopPolling(),this.module.startPolling.defer(500,this.module)},Ext.define("SYNO.SDS.AdminCenter.Network.PPPoE.EditDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner;var t=this.fillConfig(e);this.callParent([t]),this.addListener("activate",this.onActivate,this)},fillConfig:function(e){return Ext.apply({title:_T("common","alt_edit"),width:480,height:340,resizable:!1,layout:"fit",items:[this.getPPPoEForm(e)],buttons:[{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",text:_T("common","alt_apply"),disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",btnStyle:"blue",scope:this,handler:this.onApply}]},e)},getPPPoEForm:function(e){return this.panel||(this.panel=new SYNO.SDS.AdminCenter.Network.PPPoE.FormPanel({module:e.module,win:e})),this.panel},onApply:function(){var e=this.getPPPoEForm().getForm();if(!e.isDirty())return this.setStatusError({text:_T("error","nochange_subject"),clear:!0}),!1;if(!e.isValid())return this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1;this.setStatusBusy(),this.disable();var t={api:"SYNO.Core.Network.PPPoE",method:"set",version:1,encryption:["configs"],params:{configs:[{ifname:"pppoe",real_ifname:e.findField("real_ifname").getValue(),username:e.findField("username").getValue(),password:e.findField("password").getValue(),is_default_gateway:e.findField("is_default_gateway").getValue(),mtu_config:e.findField("mtu_config").getValue()}]},callback:this.afterApply,scope:this};e.findField("password").isDirty()||delete t.params.configs[0].password,this.sendWebAPI(t)},afterApply:function(e,t,i,s){if(this.enable(),this.clearStatusBusy(),!e){SYNO.Debug("Failed to load interface info");var n=_T("common","error_system");return t.error&&t.error.code&&(n=SYNO.API.getErrorString(t.error.code)),this.setStatusError({text:n,clear:!0}),!1}this.close()},onCancel:function(){this.close()},onActivate:function(){this.callParent(arguments),this.setStatusBusy(),this.disable(),this.sendWebAPI({api:"SYNO.Core.Network.PPPoE",method:"get",version:1,params:{ifname:"pppoe"},callback:this.onLoad,scope:this})},onLoad:function(e,t,i,s){var n=this.getPPPoEForm();if(!e||!t)return SYNO.Debug("Failed to load interface info"),!1;n.setData(t),n.updatePanel(),this.enable(),this.clearStatusBusy()}}),Ext.define("SYNO.SDS.AdminCenter.Network.PPPoE.FormPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t=Ext.apply({module:e.module,trackResetOnLoad:!0,items:[{xtype:"syno_displayfield",value:_T("pppoe","pppoe_intr")},{xtype:"syno_combobox",fieldLabel:_T("tcpip","tcpip_lan_port"),name:"real_ifname",editable:!1,store:new Ext.data.SimpleStore({fields:["ifname","ifstring"],data:[]}),displayField:"ifstring",valueField:"ifname",hidden:!0},{xtype:"syno_textfield",fieldLabel:_T("pppoe","pppoe_username"),name:"username",maxlength:255,allowBlank:!1},{xtype:"syno_textfield",textType:"password",fieldLabel:_T("pppoe","pppoe_password"),name:"password",maxlength:255},{xtype:"syno_combobox",vtype:"digit",fieldLabel:_T("tcpip","mtu_value_label"),name:"mtu_config",editable:!0,maxlength:256,store:[["1492","1492"]],validator:function(e){var t=this.ownerCt.getForm().findField("mtu_config").getValue();return!(1492t)||String.format(_T("tcpip","mtu_range_error"),1400,1492)}},{xtype:"syno_checkbox",boxLabel:_T("network","usbmodem_set_as_default_gw"),name:"is_default_gateway",checked:!1},{xtype:"syno_checkbox",name:"guest_enabled",hidden:!0}]},e);this.callParent([t])},setData:function(e){if(e.devs instanceof Array){var t=this.getForm().findField("real_ifname"),i=[];e.devs.sort(SYNO.SDS.AdminCenter.Network.Utils.SortFunc),Ext.each(e.devs,function(e){i.push([e,SYNO.SDS.Utils.Network.idToString.apply(this,[e])])},this),t.getStore().loadData(i)}-1==e.devs.indexOf(e.real_ifname)&&(e.real_ifname=e.devs[0]),this.getForm().setValues(e)},updatePanel:function(){var e=this.getForm().findField("real_ifname");1!==e.getStore().getCount()&&e.show()}}),Ext.define("SYNO.SDS.AdminCenter.Network.PPPoE.WhiteListDialog",{extend:"SYNO.SDS.AdminCenter.Utils.Dialog.ServPortsDialog",constructor:function(e){this.settings=e.settings,this.sendCommand=e.sendCommand;var t={dirty:!0,buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","alt_apply"),itemId:"ruleApply",scope:this,handler:this.saveAndApplyFwProfile}],listeners:{beforeclose:this.onBeforeClose.createDelegate(this)}};Ext.apply(t,e),this.callParent([t])},onBeforeClose:function(){if(this.dirty)return this.confirmLostChangePromise({save:this.saveAndApplyFwProfile,dontSave:function(){this.dirty=!1,this.close()},cancel:Ext.emptyFn},this),!1},onClose:function(){this.sendCommand("connect")},getProfile:function(){return Ext.apply(this.settings.profile,{pppoe:{policy:"drop",rules:[{enable:!0,log:!1,name:"",policy:"allow",port_direction:"destination",port_group:"service",ports:this.grid.getEnabledPorts(),protocol:this.grid.getEnabledPortsProtocol(),source_ip:"all",source_ip_group:"all"}]}})},saveAndApplyFwProfile:function(){this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({webapi:{api:"SYNO.Core.Security.Firewall.Profile",version:1,method:"set",params:{profile:this.getProfile(),profile_applying:!0}},scope:this,callback:function(e,t){if(!e)return this.clearStatusBusy(),void this.owner.getMsgBox().alert("",_T("firewall","firewall_save_failed"));this.applyProfile()}})},applyProfile:function(){this.sendWebAPI({webapi:{api:"SYNO.Core.Security.Firewall.Profile.Apply",version:1,method:"start",params:{name:this.settings.profileName,profile_applying:!0}},scope:this,callback:this.pollingApplyStatus})},pollingApplyStatus:function(e,t){if(!e)return this.clearStatusBusy(),void this.owner.getMsgBox().alert("",_T("firewall","fail_apply_firewall_profile"));this.polling_id=this.pollReg({interval:1,immediate:!0,scope:this,webapi:{api:"SYNO.Core.Security.Firewall.Profile.Apply",method:"status",params:{task_id:t.task_id},version:1},status_callback:function(e,t,i,s){if(void 0!==t.success)return!0===e&&!0===t.success||(this.stopPollingTask(),!0===t.success)?void(!0===t.success&&(this.stopPollingTask(),this.clearStatusBusy(),this.owner.getMsgBox().alert("",_T("firewall","firewall_save_success")),this.dirty=!1,this.close())):(this.clearStatusBusy(),1103===t.error.code?(this.owner.getMsgBox().alert("",_T("pppoe","pppoe_firewall_block_admin_client")),this.dirty=!1,void this.close()):void this.owner.getMsgBox().alert("",SYNO.API.getErrorString(t.error.code)))}})},stopPollingTask:function(){null!==this.polling_id&&this.sendWebAPI({webapi:{api:"SYNO.Core.Security.Firewall.Profile.Apply",version:1,method:"stop"},scope:this,callback:function(e,t,i){this.pollUnreg(this.polling_id),this.polling_id=null}})}}),Ext.define("SYNO.SDS.AdminCenter.Network.VPN.CreateWizard",{extend:"SYNO.SDS.Wizard.ModalWindow",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){return Ext.apply({title:_T("vpnc","create_profile"),resizable:!1,width:650,height:500,fileUpload:!0,activeStep:"prtltype",steps:[this.prtltypeStep=new SYNO.SDS.AdminCenter.Network.VPN.PrtlTypeStep({headline:_T("vpnc","client_type"),itemId:"prtltype",nextId:"basic"}),this.basicStep=new SYNO.SDS.AdminCenter.Network.VPN.BasicStep({headline:_T("vpnc","basic_setting"),itemId:"basic",nextId:"advance"}),this.advanceStep=new SYNO.SDS.AdminCenter.Network.VPN.AdvanceStep({headline:_T("vpnc","adv_setting"),itemId:"advance",disableNextInDemoMode:!0,nextId:null,getNext:function(){return this.owner.onApply(),!1}})]},e)},applySetting:function(){var e;SYNO.Debug("applySetting");var t={},i=this.getStep("prtltype").getValues();Ext.apply(t,this.getStep("basic").getForm().getValues()),Ext.apply(t,this.getStep("advance").getForm().getValues()),"pptp"===i.vpnc_type?e="SYNO.Core.Network.VPN.PPTP":"l2tp"===i.vpnc_type&&(e="SYNO.Core.Network.VPN.L2TP"),this.sendWebAPI({api:e,version:1,method:"create",encryption:["pass","preshared_key"],params:t,callback:function(e,t,i,s){if(this.clearStatusBusy(),!e)return SYNO.Debug(i),void this.setStatusError({text:_T("common","error_system")});this.close()},scope:this})},onApply:function(){if(SYNO.Debug("onApply"),this._S("demo_mode"))this.owner.getMsgBox().alert(this.title,_JSLIBSTR("uicommon","error_demo"));else{this.setStatusBusy({text:_T("common","saving")});var e=this.getStep("prtltype").getValues();"pptp"===e.vpnc_type||"l2tp"===e.vpnc_type?this.applySetting():"ovpn"!==e.vpnc_type&&"ovpn_conf"!==e.vpnc_type||this.createOVPN()}},createOVPN:function(){var e=this.getStep("advance").getForm().getValues();this.getStep("basic").createOVPN(e)},goNext:function(){this.callParent(arguments),this.getActiveStep().doLayout()}}),Ext.define("SYNO.SDS.AdminCenter.Network.VPN.PrtlTypeStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t=Ext.apply({title:_T("vpnc","app_name"),description:_T("vpnc","select_vpnc_type"),trackResetOnLoad:!0,items:[]},e);delete t.title,t.items.push({xtype:"syno_radio",boxLabel:_T("vpnc","type_pptp"),name:"vpnc_type",hidden:SYNO.SDS.Utils.isInC2DSM(),inputValue:"pptp",checked:!SYNO.SDS.Utils.isInC2DSM()}),t.items.push({xtype:"syno_radio",boxLabel:_T("vpnc","type_ovpn_conf"),name:"vpnc_type",inputValue:"ovpn_conf"}),t.items.push({xtype:"syno_radio",boxLabel:_T("vpnc","type_l2tp"),name:"vpnc_type",inputValue:"l2tp"}),this.callParent([t])},getValues:function(){return this.getForm().getValues()}}),Ext.define("SYNO.SDS.AdminCenter.Network.VPN.BasicStep",{extend:"SYNO.SDS.Utils.FormPanel",oriConfName:"",vpnc_type:"",certs_field:"",constructor:function(e){var t=Ext.apply({cls:"syno-network-vpnclient-wizard-basic-step",itemId:"panelCrt",description:_T("vpnc","basic_setting_desc"),trackResetOnLoad:!0,fileUpload:!0,webapi:{api:"SYNO.Core.Network.VPN.OpenVPN",version:1,method:"create",scope:this},items:[{xtype:"syno_textfield",fieldLabel:_T("vpnc","profile_name"),name:"confname",width:350,allowBlank:!1,maxlength:32,vtype:"alphanum"},{xtype:"syno_textfield",fieldLabel:_T("vpnc","vpn_server"),name:"server",width:350,allowBlank:!1,maxlength:256,vtype:"iporhostname"},{xtype:"syno_textfield",fieldLabel:_T("vpnc","user"),name:"user",width:350,allowBlank:!1,maxlength:64,validator:function(e){if(Ext.form.VTypes.username_ext(e)){var t=e.match(/\\/g);return!(t&&1`,""),this.owner.setStatusError({text:i}),Ext.get(s).addListener("click",this.launchHelp,this)}else this.owner.setStatusError({text:i})},launchHelp:function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/connection_network_vpnclient.html"},!1)}}),Ext.define("SYNO.SDS.AdminCenter.Network.VPN.AdvanceStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t=Ext.apply(this.configForm({itemId:"form"}),e);this.callParent([t])},configForm:function(e){return Ext.apply({xtype:"form",description:_T("vpnc","adv_setting_desc"),trackResetOnLoad:!0,synodefaults:{width:250},items:[{xtype:"syno_combobox",width:350,fieldLabel:_T("vpnc","auth"),name:"auth",editable:!1,allowBlank:!1,store:[["pap","PAP"],["chap","CHAP"],["mschap","MS CHAP"],["mschap2","MS CHAP v2"]],listeners:{select:this.onSelectAuth,scope:this}},{xtype:"syno_combobox",width:350,fieldLabel:_T("vpnc","encrypt"),name:"mppe",editable:!1,allowBlank:!1,store:[["none","No MPPE"],["both","Require MPPE (40/128 bit)"],["max","Maximum MPPE (128 bit)"]]},{xtype:"syno_checkbox",boxLabel:_T("vpnc","compress"),name:"compress",checked:!1},{xtype:"syno_checkbox",boxLabel:_T("vpnc","remote_gateway"),name:"defgw",checked:!1},{xtype:"syno_checkbox",boxLabel:_T("vpnc","internet_sharing"),name:"nat",checked:!1,hidden:_S("ha_running")},{xtype:"syno_checkbox",boxLabel:_T("vpnc","server_behind_nat"),name:"behind_nat",checked:!1},{xtype:"syno_checkbox",boxLabel:_T("vpnc","auto_reconnect"),name:"reconnect",checked:!1}]},e)},onSelectAuth:function(e){var t=e.getValue();"mschap"===t||"mschap2"===t?this.getForm().findField("mppe").enable():this.getForm().findField("mppe").disable()},activate:function(){var e=this.getForm();e.setValues({auth:"mschap2",mppe:"both",compress:!0,defgw:!1,behind_nat:!1,nat:!1});var t=this.owner.getStep("prtltype").getValues().vpnc_type;"pptp"===t?(e.findField("auth").enable(),e.findField("auth").show(),e.findField("mppe").enable(),e.findField("mppe").show(),e.findField("behind_nat").disable(),e.findField("behind_nat").hide(),e.findField("compress").disable(),e.findField("compress").hide()):"l2tp"===t?(e.findField("auth").enable(),e.findField("auth").show(),e.findField("mppe").disable(),e.findField("mppe").hide(),e.findField("behind_nat").enable(),e.findField("behind_nat").show(),e.findField("compress").disable(),e.findField("compress").hide()):"ovpn"===t?(e.findField("auth").disable(),e.findField("auth").hide(),e.findField("mppe").disable(),e.findField("mppe").hide(),e.findField("behind_nat").disable(),e.findField("behind_nat").hide(),e.findField("compress").enable(),e.findField("compress").show()):"ovpn_conf"===t&&(e.findField("auth").disable(),e.findField("auth").hide(),e.findField("mppe").disable(),e.findField("mppe").hide(),e.findField("behind_nat").disable(),e.findField("behind_nat").hide(),e.findField("compress").disable(),e.findField("compress").hide())}}),Ext.ns("SYNO.SDS.AdminCenter.Network.VPN"),SYNO.SDS.AdminCenter.Network.VPN.getWebAPI=function(){var e=function(e){var t=function(e){return 10>e?"0"+e:e};Ext.each(e,function(e,i,s){s[i].type="vpnc",s[i].real_status=e.status,"connected"===e.status||"connecting"===e.status?s[i].cls="net-vpnc-connected":s[i].cls="net-vpnc-disconnected",e.err_msg&&("disconnected"===e.status&&(s[i].status="connection_failed"),"error_auth"===e.err_msg?e.err_msg=_T("error","error_auth"):"err_server_timeout"===e.err_msg?e.err_msg=_T("vpnc","err_server_timeout"):"commfail"===e.err_msg?e.err_msg=_T("common","commfail"):"err_invalid_ca"===e.err_msg?e.err_msg=_T("vpnc","err_invalid_ca"):"err_ipsec_fail"===e.err_msg?e.err_msg=_T("vpnc","err_ipsec_fail"):"err_l2tp_fail"===e.err_msg?e.err_msg=_T("vpnc","err_l2tp_fail"):e.err_msg=_T("common","commfail")),"connected"===e.status&&(s[i].uptime=function(e){var i=e,s=Math.floor(i/86400);i%=86400;var n=Math.floor(i/3600);i%=3600;var o=Math.floor(i/60),a=i%60,r=s>0?s+_T("status","status_day")+" ":"";return r+=t(n)+":"+t(o)+":"+t(a)}(e.uptime),s[i].vpn_gateway=e.vpn_gateway,s[i].tx=e.tx+String.format(" bytes"),s[i].rx=e.rx+String.format(" bytes"))})};return[{api:"SYNO.Core.Network.VPN.PPTP",method:"list",version:1,params:{additional:["status"]},callback:e},{api:"SYNO.Core.Network.VPN.OpenVPNWithConf",method:"list",version:1,params:{additional:["status"]},callback:e},{api:"SYNO.Core.Network.VPN.OpenVPN",method:"list",version:1,params:{additional:["status"]},callback:e},{api:"SYNO.Core.Network.VPN.L2TP",method:"list",version:1,params:{additional:["status"]},callback:e}]},SYNO.SDS.AdminCenter.Network.VPN.setARIAInfo=function(e){var t=SYNO.SDS.AdminCenter.Network.Utils;e.ariaInfo=String.format("{0} {1} ",t.getTitle(e.title,e,this),t.getStatusStr(e.status)),"connected"!=e.status&&"enabled"!=e.status||(e.ariaInfo+=String.format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}",_T("tcpip","wimax_connected_time"),t.toEmptyDash(e.uptime),_T("vpnc","client_ip"),t.toEmptyDash(e.virtual_ip),_T("network","route_gateway"),t.toEmptyDash(e.vpn_gateway),_T("vpnc","sent"),t.toEmptyDash(e.tx),_T("vpnc","received"),t.toEmptyDash(e.rx)),e.ariaInfo=Ext.util.Format.stripTags(e.ariaInfo))},SYNO.SDS.AdminCenter.Network.VPN.getTpl=function(e){return'{err_msg}'+String.format(e,_T("tcpip","wimax_connected_time"),"{uptime:this.toEmptyDash}")+String.format(e,_T("network","route_gateway"),"{vpn_gateway:this.toEmptyDash}")+String.format(e,_T("vpnc","sent"),"{tx:this.toEmptyDash}")+String.format(e,_T("vpnc","received"),"{rx:this.toEmptyDash}")+"
    {ariaInfo:this.setARIAInfo}
    "},SYNO.SDS.AdminCenter.Network.VPN.getIpTpl=function(){return"{virtual_ip:this.toEmptyDash}"},SYNO.SDS.AdminCenter.Network.VPN.getBtnConfig=function(){return{editBtn:{isDisabled:function(){switch(this.selectedRecord.get("real_status")){case"connecting":case"connected":return!0;default:return!1}},handler:SYNO.SDS.AdminCenter.Network.VPN.onEdit},deleteBtn:{isDisabled:!1,handler:SYNO.SDS.AdminCenter.Network.VPN.onDelete},connectBtn:{text:function(){return"disconnected"===this.selectedRecord.get("real_status")?_T("vpnc","connect"):_T("vpnc","disconnect")},isDisabled:!1,handler:SYNO.SDS.AdminCenter.Network.VPN.onConnect}}},SYNO.SDS.AdminCenter.Network.VPN.onCreate=function(){this.module.stopPolling();for(var e=0,t=0;t`,""),this.owner.getMsgBox().alert(_T("vpnc","app_name"),i),Ext.get(s).addListener("click",this.launchHelp,this)}else this.owner.setStatusError({text:i})},launchHelp:function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/connection_network_vpnclient.html"},!1)},uploadCert:function(){"ovpn_conf"===this.prtl||this.getForm().findField("ca_file").getValue()?this.getForm().findField("ca_file").getValue()||this.getForm().findField("client_crt_file").getValue()||this.getForm().findField("client_key_file").getValue()||this.getForm().findField("pem_file").getValue()||this.getForm().findField("ta_file").getValue()?(this.owner.setStatusBusy(),this.upload()):this.owner.setStatusError({text:_T("error","error_nochoosefile"),clear:!0}):this.owner.setStatusError({text:_T("vpnc","ca_no_file"),clear:!0})}}),Ext.define("SYNO.SDS.AdminCenter.Network.Bond.CreateWizard",{extend:"SYNO.SDS.Wizard.ModalWindow",constructor:function(e){this.ifname="wizard",this.owner=e.owner,this.module=e.module,this.callParent([this.fillConfig(e)]),this.addListener("destroy",this.module.startPolling,this.module)},fillConfig:function(e){return this.store=new SYNO.SDS.AdminCenter.Network.InterfaceStore({module:this.module,autoDestroy:!0,data:[],fields:["enabled","id","status","ip","mask","mtu","mtu_config","vlan_id","use_dhcp","enable_vlan","link_status","speed","duplex","ifname","gateway","dns","is_default_gateway","max_supported_speed"],getWebAPIs:function(){return[Ext.apply(SYNO.SDS.AdminCenter.Network.Ethernet.getWebAPI(),{callback:function(e){e[0]&&(e[0].enabled=!0),e[1]&&(e[1].enabled=!0),SYNO.SDS.AdminCenter.Network.Ethernet.getWebAPI().callback(e)}})]},listeners:{update:function(e,t,i){Ext.data.Record.EDIT===i&&this.checkState()},scope:this}}),Ext.apply({cls:"syno-network-bond-wizard",title:_T("network","linkaggr_enable"),resizable:!1,width:700,height:580,layout:"fit",steps:[this.modeStep=new SYNO.SDS.AdminCenter.Network.Bond.ModeStep({module:this.module,win:this,bondType:e.bondType}),this.linkStep=new SYNO.SDS.AdminCenter.Network.Bond.LinkStep({module:this.module,win:this}),this.ipconfigStep=new SYNO.SDS.AdminCenter.Network.Bond.IPConfigStep({module:this.module,win:this,bondType:e.bondType})]},e)},onOpen:function(){this.callParent(arguments),SYNO.Debug("onOpen"),this.store.load({scope:this,afterload:this.onLoad})},onApply:function(){SYNO.Debug("onApply"),this.getMsgBox().confirm("",_T("network","create_bond_confirm"),function(e){"yes"===e&&(this.setStatusBusy({text:_T("common","saving")}),this.SendAPI())},this)},DoSet:function(){this.sendWebAPI({api:"SYNO.Core.Network.Bond",version:1,method:"create",params:{ipconfig:this.getIPConfig(),mode:this.modeStep.getForm().findField("mode").getGroupValue(),slaves:this.getEnabledSlaves()},callback:function(e,t,i,s){if(e){var n="SYNO.SDS.CMS.Application"===this.findAppWindow().getOpenConfig("className"),o=!0===this.findAppWindow().getOpenConfig("cms_self");n&&!o||!t||(this.removeListener("destroy",this.module.startPolling,this.module),SYNO.SDS.AdminCenter.Network.Utils.Redirect.apply(this,[t.redirect,t.secure,t.ip_list,t.port,t.auth_key,"SYNO.SDS.AdminCenter.Network.Main",6e4])),this.clearStatusBusy(),this.enable(),this.close()}else{var a=SYNO.API.getErrorString(t.code);if(this.clearStatusBusy(),4318==t.code){var r=t.errors.ifname,l=t.errors.block,d="";0<(8&l)?d="MailPlus Server":0<(4&l)&&(d="Virtual Machine Manager"),a=String.format(_T("network","interface_block_msg"),SYNO.SDS.Utils.Network.idToString(r),d)}this.getMsgBox().alert(_T("network","linkaggr_enable"),a,function(e){this.close()},this)}},scope:this})},SendAPI:function(){this.sendWebAPI({api:"SYNO.Core.Network.Bond",version:1,method:"create_check",params:{ipconfig:this.getIPConfig(),slaves:this.getEnabledSlaves()},callback:function(e,t,i,s){if(e)this.DoSet();else{var n="",o=0;if(this.clearStatusBusy(),4319==t.code)if(t.errors.hard){for(o=0;o"+SYNO.SDS.Utils.GetFeasibilityCheckMsg(t.errors.hard[o]);this.getMsgBox().alert("",_T("network","net_iface_change_stop")+"
    "+n,function(e){this.close()},this)}else if(t.errors.soft){for(o=0;o"+SYNO.SDS.Utils.GetFeasibilityCheckMsg(t.errors.soft[o]);this.getMsgBox().confirm("",_T("network","net_iface_change_confirm")+"
    "+n,function(e){"yes"===e?this.DoSet():"no"===e&&this.close()},this)}else this.module.appWin.getMsgBox().alert(_T("network","remove_bond"),SYNO.API.getErrorString(t.code));else this.module.appWin.getMsgBox().alert(_T("network","remove_bond"),SYNO.API.getErrorString(t.code))}},scope:this})},onClose:function(){SYNO.Debug("onClose")},onLoad:function(){this.store.removeAt(this.store.find("id",_D("oob_interface"))),SYNO.Debug("onLoad")},checkState:function(){this.isSelectTwo()?this.getButton("next").enable():this.getButton("next").disable()},isSelectTwo:function(){for(var e=0,t=0;tthis.store.getAt(t).data.max_supported_speed)&&(e=this.store.getAt(t));return e},getEnabledSlaves:function(){var e=[];return this.store.each(function(t){!0===t.get("enabled")&&e.push(t.get("ifname"))},this),e},getIPConfig:function(){var e=this.ipconfigStep.getForm(),t={use_dhcp:e.findField("use_dhcp").getValue(),enable_vlan:e.findField("enable_vlan").getValue(),is_default_gateway:e.findField("is_default_gateway").getValue()};return!1===t.use_dhcp&&(t.ip=e.findField("ip").getValue(),t.mask=e.findField("mask").getValue(),t.gateway=e.findField("gateway").getValue(),t.dns=e.findField("dns").getValue()),!0===e.findField("manual_adjust_mtu").getValue()?t.mtu=e.findField("mtu_config").getValue():t.mtu=1500,!0===t.enable_vlan&&(t.vlan_id=e.findField("vlan_id").getValue()),t}}),Ext.define("SYNO.SDS.AdminCenter.Network.Bond.ModeStep",{extend:"SYNO.SDS.AdminCenter.Network.BondModeTab",constructor:function(e){this.owner=e.owner,this.module=e.module;var t=Ext.apply({headline:_T("network","linkaggr_mode"),itemId:"ModeStep",nextId:"LinkStep"},e);this.callParent([t])}}),Ext.define("SYNO.SDS.AdminCenter.Network.Bond.LinkStep",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.owner=e.owner,this.module=e.module,this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t=this,i=new SYNO.ux.EnableColumn({dataIndex:"enabled",width:40,align:"center",isIgnore:function(e,t){return t.get("id")===_D("oob_interface")},bindRowClick:!0});return Ext.apply({headline:_T("network","bond_slaves"),itemId:"LinkStep",getNext:function(){var e,t=!1,i=this.store.getRange(),s=this.win.modeStep.getForm().findField("mode").getGroupValue();if("active-backup"===s||"ovs-active-backup"===s)return"IPConfigStep";for(var n=0;n'+_T("common","note")+_T("common","colon")+"
    "+_T("oob","oob_link_aggregation_not_support_note"),height:60}]}):void 0,store:e.win.store},e)}}),Ext.define("SYNO.SDS.AdminCenter.Network.Bond.IPConfigStep",{extend:"SYNO.SDS.AdminCenter.Network.IPv4Tab",constructor:function(e){this.owner=e.owner,this.module=e.module;var t=Ext.apply({headline:_T("setupwizard","netinfo_title"),itemId:"IPConfigStep",nextId:null,disableNextInDemoMode:!0,getNext:function(){return this.isValid()?(this.win.onApply(),!1):(this.win.setStatusError({text:_T("common","forminvalid")}),!1)}},e);this.callParent([t])},activate:function(){var e=this.win.getMinSupSpeedEnabled();this.fillContent(e.data)}}),Ext.ns("SYNO.SDS.AdminCenter.Network.Bond"),SYNO.SDS.AdminCenter.Network.Bond.getWebAPI=function(){return{api:"SYNO.Core.Network.Bond",method:"list",version:2,callback:function(e){Ext.each(e,function(e,t,i){"connected"===e.status?i[t].cls="net-bond-connected":i[t].cls="net-bond-disconnected",i[t].slaves.sort(SYNO.SDS.AdminCenter.Network.Utils.SortFunc)})}}},SYNO.SDS.AdminCenter.Network.Bond.getBtnConfig=function(){return{editBtn:{isDisabled:!1,handler:SYNO.SDS.AdminCenter.Network.Bond.onEdit},deleteBtn:{isDisabled:!0===_S("ha_runnign"),handler:SYNO.SDS.AdminCenter.Network.Bond.onDelete},connectBtn:{isDisabled:!0,handler:null}}},SYNO.SDS.AdminCenter.Network.Bond.onCreate=function(){!1!==_S("ha_allow_bond_manage")?!0!==this.module.glusterComputingOrStorage?(this.module.stopPolling(),new SYNO.SDS.AdminCenter.Network.Bond.CreateWizard({owner:this.module.appWin,module:this.module,bondType:this.module.bondType}).open()):this.module.getGlusterBox():this.module.getHAMsgBox()},SYNO.SDS.AdminCenter.Network.Bond.onEdit=function(){if(!1!==_S("ha_allow_bond_manage")){this.module.stopPolling();var e=12&this.selectedRecord.get("block");if(0"+SYNO.SDS.Utils.GetFeasibilityCheckMsg(t.errors.hard[o]);this.module.appWin.getMsgBox().alert("",_T("network","net_iface_change_stop")+"
    "+n,this)}else if(t.errors.soft){for(o=0;o"+SYNO.SDS.Utils.GetFeasibilityCheckMsg(t.errors.soft[o]);this.module.appWin.getMsgBox().confirm("",_T("network","net_iface_change_confirm")+"
    "+n,function(e){"yes"===e&&SYNO.SDS.AdminCenter.Network.Bond.DoDelete.createDelegate(this)()},this)}else this.module.appWin.getMsgBox().alert(_T("network","remove_bond"),SYNO.API.getErrorString(t.code))}},scope:this})):this.module.getGlusterBox():this.module.getHAMsgBox()},Ext.define("SYNO.SDS.AdminCenter.Network.InterfaceStore",{extend:"Ext.data.JsonStore",constructor:function(e){this.owner=e.owner;var t=Ext.apply({fields:["ariaInfo","title","status","ifname","type","cls","iconCls","id","block","ip","ipv6","mask","mtu","mtu_config","vlan_id","use_dhcp","enable_ha_ip","enable_vlan","link_status","speed","duplex","max_supported_speed","mode","error","slaves","ha_local_ip","ha_local_mask","real_ifname","username","guest_enabled","confname","prtl","uptime","virtual_ip","vpn_gateway","tx","rx","err_msg","real_status"]},e);this.callParent([t])},getWebAPIs:function(){return this.webapis||(this.webapis=[SYNO.SDS.AdminCenter.Network.Bond.getWebAPI(),SYNO.SDS.AdminCenter.Network.Ethernet.getWebAPI()],SYNO.SDS.Utils.isInC2DSM()||SYNO.SDS.Utils.isInAliDSM()||_S("ha_not_support_pppoe")||this.webapis.push(SYNO.SDS.AdminCenter.Network.PPPoE.getWebAPI()),this.webapis=this.webapis.concat(SYNO.SDS.AdminCenter.Network.VPN.getWebAPI())),this.webapis},load:function(e){this.callback=e,e.scope?(e.scope.ifname&&"wizard"===e.scope.ifname?e.scope:e.scope.appWin).sendWebAPI({compound:{stopwhenerror:!1,params:this.getWebAPIs()},callback:this.onLoad,scope:this}):SYNO.Debug("no scope")},onLoad:function(e,t,i,s){if(!this.module.connectingFlag){var n=this.getWebAPIs(),o=[];if(!e||!t||!t.result)return SYNO.Debug("Failed to load interface info"),!1;Ext.each(t.result,function(e,t,i){e.data?(n[t].callback(e.data),Ext.each(e.data,function(e,t,i){e.id||(e.ifname?i[t].id=e.ifname:e.interface_name&&(i[t].id=e.interface_name))},this),o=o.concat(e.data)):e.api?SYNO.Debug("Failed to get data from ["+e.api+"]"):SYNO.Debug("Failed to get data from ["+t+"]")},this),this.loadData(o,!0),this.singleSort("id","ASC"),this.each(function(e){var t=!1;Ext.each(o,function(i,s,n){i.id===e.get("id")&&(t=!0)},this),t||(SYNO.Debug("Remove "+e.get("id")),this.remove(e))},this),this.callback&&this.callback.afterload&&this.callback.afterload instanceof Function&&this.callback.afterload.apply(this.callback.scope)}},createSortFunction:function(e,t){var i="DESC"===(t=t||"ASC").toUpperCase()?-1:1;return function(t,s){var n=0,o=/^(ovs_)?([a-z]+)([0-9]*)(\.?)([0-9]*)$/,a=o.exec(t.data[e]),r=o.exec(s.data[e]);if(a instanceof Array&&r instanceof Array&&0===(n=a[2]>r[2]?1:a[2]d?1:l','","",'
    ')},getInnerTpl:function(e){var t=""+('{0}'+_T("common","colon")+"")+'{1}';return new Ext.XTemplate('
    ','',SYNO.SDS.AdminCenter.Network.Ethernet.getTpl(t),SYNO.SDS.AdminCenter.Network.PPPoE.getTpl(t),SYNO.SDS.AdminCenter.Network.VPN.getTpl(t),"
    ","
    ")},addTplRenderer:function(){var e=this.tpl,t=this;e.setARIAInfo=function(e,i){switch(i.type){case"lan":case"wan":case"bond":SYNO.SDS.AdminCenter.Network.Ethernet.setARIAInfo.apply(t,[i]);break;case"pppoe":SYNO.SDS.AdminCenter.Network.PPPoE.setARIAInfo.apply(t,[i]);break;case"vpnc":SYNO.SDS.AdminCenter.Network.VPN.setARIAInfo.apply(t,[i])}return""},e.toYesNo=function(e,t){return SYNO.SDS.AdminCenter.Network.Utils.toYesNo(e)},e.toEmptyDash=function(e,t){return SYNO.SDS.AdminCenter.Network.Utils.toEmptyDash(e)},e.toMultiLine=function(e,t){return SYNO.SDS.AdminCenter.Network.Utils.toMultiLine(e)},e.getLinkStatus=function(e,t){return SYNO.SDS.AdminCenter.Network.Utils.getLinkStatus(e,t)},e.getTitle=function(e,i){return SYNO.SDS.AdminCenter.Network.Utils.getTitle(e,i,t)},e.getStatus=function(e,t){return SYNO.SDS.AdminCenter.Network.Utils.getStatus(e)},e.getSignal=function(e,t){return SYNO.SDS.AdminCenter.Network.Utils.getSignal(e)}}}),Ext.define("SYNO.SDS.AdminCenter.Network.ServiceOrderGridPanel",{extend:"SYNO.ux.DDGridPanel",constructor:function(e){this.module=e.module,this.owner=e.owner,this.IpType="ipv4",this.GridStore=this.createGridStore(),this.tbar=new Ext.Toolbar({defaultType:"syno_button",items:this.configToolBar()});var t=Ext.apply({tbar:this.tbar,store:this.GridStore,viewConfig:{markDirty:!1,ddGroup:"ServiceOrderDD"},columns:[{header:_T("network","interface"),dataIndex:"ifname",align:"left",fixed:!0,width:252,renderer:function(e,t,i,s,n,o){return"vpn-client"===i.data.class?"VPN":SYNO.SDS.Utils.Network.idToString(e)}},{header:_T("network","route_gateway"),dataIndex:"gateway",align:"left",fixed:!0,width:252}],enableDragDrop:!0,enableColumnMove:!1,enableHdMenu:!1,monitorWindowResize:!0,selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),listeners:{scope:this,resize:this.adjustColumnWidth}},e);this.callParent([t])},adjustColumnWidth:function(){var e=(this.getWidth()-17)/2,t=this.getColumnModel();t&&(t.setColumnWidth(0,e),t.setColumnWidth(1,e))},onActivate:function(e){this.parentDialog.setStatusBusy({text:_T("common","loading")}),this.GridStore.load(),this.parentDialog.clearStatusBusy()},configToolBar:function(){return["->",{xtype:"syno_combobox",id:this.ipTypeId=Ext.id(),editable:!1,allowBlank:!1,store:this.getIPTypeStore(),value:"ipv4",listeners:{scope:this,select:this.onTypeChange}}]},createGridStore:function(){return new SYNO.SDS.AdminCenter.Network.ServiceOrderStore({module:this.module,owner:this})},onMoveRow:function(e){var t=this.getStore(),i=this.getSelectionModel().getSelected(),s=t.indexOf(i);this.getView().focusRow(s),(s+=e?-1:1)<0||s>t.getCount()-1||(t.remove(i),t.insert(s,i),this.getView().focusRow(s),this.getSelectionModel().selectRecords([i]))},onTypeChange:function(e){this.IpType=e.getValue(),this.parentDialog.setStatusBusy({text:_T("common","loading")}),this.getStore().load({params:{iptype:this.IpType,type:"wan"},scope:this}),this.parentDialog.clearStatusBusy()},getButton:function(e){var t,i=this.getTopToolbar();return i&&(t=i.getComponent(e)),t},getIPTypeStore:function(){return!0===_S("ha_not_support_ipv6")?[["ipv4","IPv4"]]:[["ipv4","IPv4"],["ipv6","IPv6"]]},setButton:function(e,t){var i=this.getButton(e);i&&i[t?"enable":"disable"]()},isDirty:function(){return this.GridStore.isDirty()},onApply:function(){var e=this.GridStore.getRange(),t=[];this.isDirty()?(this.parentDialog.setStatusBusy({text:_T("common","saving")}),Ext.each(e,function(e){t.push(e.data.ifname)}),this.sendWebAPI({api:"SYNO.Core.Network.Router.Gateway.List",method:"set",version:1,scope:this,params:{iptype:this.IpType,ifnames:t},callback:this.onSaveDone})):this.parentDialog.setStatusError({text:_T("error","nochange_subject"),clear:!0})},onSaveDone:function(e,t,i){this.parentDialog.clearStatusBusy();var s=_T("common","error_system");if(!e)return t&&t.code&&(s=SYNO.API.getErrorString(t.code)),void this.parentTab.setStatusError({text:s,clear:!0});this.parentDialog.close()}}),Ext.define("SYNO.SDS.AdminCenter.Network.ServiceOrderStore",{extend:"SYNO.API.JsonStore",constructor:function(e){this.module=e.module,this.owner=e.owner;var t=Ext.apply({api:"SYNO.Core.Network.Router.Gateway.List",appWindow:this.owner,method:"get",baseParams:{iptype:"ipv4",type:"wan"},version:1,autoDestroy:!0,root:"configs",fields:["ifname","gateway","class"],listeners:{load:this.onAfterLoad}},e);this.callParent([t])},onAfterLoad:function(e,t,i){0>=t.length?this.owner.getView().el.mask(_T("network","route_gateway_order_intro")):this.owner.getView().el.unmask()},isDirty:function(){return this.getModifiedRecords().length>0}}),Ext.define("SYNO.SDS.AdminCenter.Network.ServiceOrderDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.ServiceOrderGridPanel=new SYNO.SDS.AdminCenter.Network.ServiceOrderGridPanel({module:this.module,appWin:this.module.appWin,owner:this.owner,itemId:"ServiceOrderGridPanel",parentDialog:this});var t=Ext.apply({title:_T("network","edit_route_gateway_order"),autoDestroy:!0,width:560,height:350,layout:"fit",border:!1,padding:"16px 20px 0 20px",items:[this.ServiceOrderGridPanel],buttons:[{xtype:"syno_button",btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",btnStyle:"blue",text:_T("common","apply"),scope:this,handler:this.onApply}]},e);this.callParent([t]),this.onActivate()},onActivate:function(){this.callParent(arguments),this.ServiceOrderGridPanel.onActivate()},onApply:function(){this.ServiceOrderGridPanel.onApply()},onCancel:function(){this.close()}}),Ext.define("SYNO.SDS.AdminCenter.Network.InterfaceTab",{extend:"Ext.Panel",constructor:function(e){e.module&&(this.module=e.module),this.owner=e.module.appWin,this.sendWebAPI({api:"SYNO.Core.Network.Ethernet.External",method:"check",params:{},version:1,scope:this,callback:this.loadErrors}),this.callParent([this.fillConfig(e)]),this.getView().addListener("afterrender",function(){0===this.module.getStore().getCount()&&this.el.mask(_T("common","loading"),"x-mask-loading")},this),this.addListener("activate",function(){this.activated=!0,this.module.stopPolling(),this.module.startPolling()},this),this.addListener("deactivate",function(){this.activated=!1},this)},loadErrors:function(e,t,i){var s;e&&(Ext.each(t,function(e){"exceed_max_num_ifaces"===e.error&&(s=e)},this),s?(Ext.getCmp(this.errorMessageId).setValue(String.format(_T("network","warning_num_nic_limit"),s.max_num,s.slot_IDs.join(" "))),this.bbar.removeClass("off-error-message"),this.doLayout()):(this.bbar.addClass("off-error-message"),this.doLayout()))},fillConfig:function(e){return Ext.apply({cls:"syno-network-interfacetab",title:_T("network","interface"),layout:"fit",tbar:this.getToolbar(),bbar:this.getBottombar(),items:[this.getView()]},e)},getToolbar:function(){return this.tbar||(this.tbar=new Ext.Toolbar({defaultType:"syno_button",items:[{xtype:"syno_button",text:_T("common","create"),itemId:"create_dropdown",name:"create_dropdown",disabled:!0,btnStyle:"grey",menu:new SYNO.ux.Menu({cls:"syno-network-interface-menu",items:[{iconCls:"syno-network-interface-menu-item",text:_T("network","create_bond"),scope:this,id:this.createBondBtnId=Ext.id(),handler:SYNO.SDS.AdminCenter.Network.Bond.onCreate,disabled:!0,hidden:!SYNO.SDS.Utils.Network.isMultiLan.apply(this)||SYNO.SDS.Utils.isInVirtualDSM()},{iconCls:"syno-network-interface-menu-item",text:_T("vpnc","create_vpn"),scope:this,id:this.createVPNBtnId=Ext.id(),handler:SYNO.SDS.AdminCenter.Network.VPN.onCreate,hidden:!1}]})},{text:_T("common","alt_edit"),itemId:"editBtn",scope:this,disabled:!0,handler:null},{text:_T("common","delete"),itemId:"deleteBtn",scope:this,disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:null},{text:_T("vpnc","connect"),itemId:"connectBtn",scope:this,disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:null},{xtype:"syno_button",text:_T("network","network_manage"),itemId:"create_dropdown_network_man",name:"create_dropdown_network_man",disabled:!0,hidden:SYNO.SDS.Utils.isInC2DSM()||SYNO.SDS.Utils.isInAliDSM(),menu:new SYNO.ux.Menu({cls:"syno-network-interface-menu",items:[{text:_T("network","route_gateway_order"),scope:this,handler:this.onServiceOrder,iconCls:"syno-network-interface-menu-item",hidden:this._S("version")<4966},{text:_T("ovs","ovs_setting"),scope:this,handler:this.onOvsSetting,iconCls:"syno-network-interface-menu-item",hidden:SYNO.SDS.Utils.isInVirtualDSM()||"yes"===this._D("dockerdsm")||"yes"!==this._D("support_ovs")}]})}]})),this.tbar},getBottombar:function(){return this.bbar||(this.bbar=new Ext.Toolbar({height:76,cls:"syno-network-interfacelist-bottombar-show",items:[{xtype:"syno_displayfield",cls:"error-message",id:this.errorMessageId=Ext.id()}]})),this.bbar},getView:function(){return this.view||(this.view=new SYNO.SDS.AdminCenter.Network.ExpandableListView({panel:this,owner:this.owner,store:this.module.getStore()}),this.view.mon(this.view,"selectionchange",function(e){this.updateSelectedRecord(),this.updateToolbarStatus()},this),this.view.mon(this.view,"containercontextmenu",this.onContainerContextMenu,this),this.view.mon(this.view,"contextmenu",this.onContextMenu,this)),this.view},onContextMenu:function(e,t,i,s){e.isSelected(i)||e.select(i),this.showContextMenu(s)},onContainerContextMenu:function(e,t){0!==e.getSelectionCount()&&this.showContextMenu(t)},showContextMenu:function(e){var t,i=[];((t=this.getTopToolbar().getComponent("editBtn")).disabled||i.push({text:t.getText(),scope:this,itemId:"editBtn",handler:t.handler}),(t=this.getTopToolbar().getComponent("deleteBtn")).disabled||i.push({text:t.getText(),scope:this,itemId:"deleteBtn",handler:t.handler}),(t=this.getTopToolbar().getComponent("connectBtn")).disabled||i.push({text:t.getText(),scope:this,itemId:"connectBtn",handler:t.handler}),0!==i.length)&&new SYNO.ux.Menu({autoDestroy:!0,items:i}).showAt(e.getXY());e.preventDefault()},afterLoad:function(){this.updateSelectedRecord(),this.updateToolbarStatus(),this.enableTopToolbar(),this.el.unmask()},enableTopToolbar:function(){var e=this.getTopToolbar();e?Ext.each(["create_dropdown","create_dropdown_network_man"],function(t){var i=e.getComponent(t);i&&i.enable()},this):SYNO.Debug("failed to get toptoolbar")},updateSelectedRecord:function(){var e=this.getView().getSelectedRecords();e&&e[0]?this.selectedRecord=e[0]:this.selectedRecord=null},updateToolbarStatus:function(){var e=this.getBtnTable(),t=null;t=this.selectedRecord?this.selectedRecord.get("type"):"default",this.updateCreateBondBtnStatus(),this.updateCreateVPNBtnStatus(),Ext.each(["editBtn","deleteBtn","connectBtn"],function(i){var s=this.getTopToolbar().getComponent(i);if(s){var n=!1,o="";switch(typeof e[t][i].isDisabled){case"boolean":n=e[t][i].isDisabled;break;case"function":n=e[t][i].isDisabled.apply(this);break;default:return void SYNO.Debug("no isDisabled")}switch((SYNO.SDS.Utils.isInC2DSM()||SYNO.SDS.Utils.isInAliDSM())&&"vpnc"!==t&&(n=!0),typeof e[t][i].text){case"string":o=e[t][i].text;break;case"function":o=e[t][i].text.apply(this)}""!==o&&s.setText(o),s.setDisabled(n),s.handler=e[t][i].handler}},this)},getBtnTable:function(){return this.btnTable?this.btnTable:(this.btnTable={default:{editBtn:{isDisabled:!0,handler:null},deleteBtn:{isDisabled:!0,handler:null},connectBtn:{isDisabled:!0,handler:null}},lan:SYNO.SDS.AdminCenter.Network.Ethernet.getBtnConfig(),wan:SYNO.SDS.AdminCenter.Network.Ethernet.getBtnConfig(),ovseth:SYNO.SDS.AdminCenter.Network.Ethernet.getBtnConfig(),ovsbond:SYNO.SDS.AdminCenter.Network.Bond.getBtnConfig(),bond:SYNO.SDS.AdminCenter.Network.Bond.getBtnConfig(),vpnc:SYNO.SDS.AdminCenter.Network.VPN.getBtnConfig(),pppoe:SYNO.SDS.AdminCenter.Network.PPPoE.getBtnConfig()},this._S("demo_mode")&&Ext.iterate(this.btnTable,function(e,t,i){var s=i[e].deleteBtn,n=i[e].connectBtn;s.isDisabled=!0,n.isDisabled=!0},this),this.btnTable)},updateCreateBondBtnStatus:function(){var e=Ext.getCmp(this.createBondBtnId),t=0;this.module.store.each(function(e){switch(e.get("type")){case"lan":case"wan":case"ovseth":t+=1}},this),e.setDisabled(2>t)},updateCreateVPNBtnStatus:function(){},onServiceOrder:function(e,t){new SYNO.SDS.AdminCenter.Network.ServiceOrderDialog({module:this.module,owner:this.module.appWin}).open()},onOvsSetting:function(){new SYNO.SDS.AdminCenter.Network.OvsSettingDialog({module:this.module,owner:this.module.appWin}).open()}}),Ext.define("SYNO.SDS.AdminCenter.Network.SimpleIFStore",{extend:"Ext.data.JsonStore",constructor:function(e){this.module=e.module,this.owner=e.owner,this.apiGetIFArray=this.createAPIGetIFArray();var t=Ext.apply({fields:["id","type","status","display"]},e);this.callParent([t])},createAPIGetIFArray:function(){return[{webapi:{api:"SYNO.Core.Network.Interface",method:"list",version:1}}]},loadInterface:function(){for(var e=[],t=0;t0}}),Ext.ns("SYNO.SDS.AdminCenter.Utils.Validator"),SYNO.SDS.AdminCenter.Utils.Validator.MarkPortsExceed=function(e,t,i){var s=e.findField(t).getValue().split(","),n=SYNO.SDS.AdminCenter.Security.Utils.FW_MAX_PORTS_IN_A_RULE;if("TC"===i&&(n=SYNO.SDS.AdminCenter.Network.Utils.TC_MAX_PORTS_IN_A_RULE),s.length>n){var o=String.format(_T("firewall","firewall_field_exceed_multiports"),n);return e.findField(t).markInvalid(o),!1}return!0},SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField=function(e,t){for(var i=0;i=n&&(e.findField(t).setValue(n),e.findField(i).setValue(s))},SYNO.SDS.AdminCenter.Utils.Validator.FQDNConflictChecker=function(){var e=[];this.FindListFQDNPortPair=function(t,i){t.module.appWin.setStatusBusy(),"SYNO.Core.Web.DSM"!==i&&t.sendWebAPI({api:"SYNO.Core.Web.DSM",method:"get",version:2,callback:function(t,i){Ext.isEmpty(i.fqdn)||(e.push({fqdn:i.fqdn.toLowerCase(),port:80}),e.push({fqdn:i.fqdn.toLowerCase(),port:443}))},scope:this}),"SYNO.Core.AppPortal"!==i&&t.sendWebAPI({api:"SYNO.Core.AppPortal",method:"list",version:2,callback:function(t,i){Ext.each(i.portal,function(t){Ext.isEmpty(t.fqdn)||(e.push({fqdn:t.fqdn.toLowerCase(),port:80}),e.push({fqdn:t.fqdn.toLowerCase(),port:443}))},this)},scope:this}),"SYNO.Core.AppPortal.ReverseProxy"!==i&&t.sendWebAPI({api:"SYNO.Core.AppPortal.ReverseProxy",method:"list",version:1,callback:function(t,i){Ext.each(i.entries,function(t){Ext.isEmpty(t.frontend.fqdn)||e.push({fqdn:t.frontend.fqdn.toLowerCase(),port:t.frontend.port})},this)},scope:this}),"SYNO.WebStation.HTTP.VHost"!==i&&t.getKnownAPI("SYNO.WebStation.HTTP.VHost")&&t.sendWebAPI({api:"SYNO.WebStation.HTTP.VHost",method:"list",version:1,callback:function(t,i){Ext.each(i.hosts,function(t){if(!Ext.isEmpty(t.fqdn)){var i=t.fqdn.toLowerCase();t.port.http&&Ext.each(t.port.http,function(t){e.push({fqdn:i,port:t})},this),t.port.https&&Ext.each(t.port.https,function(t){e.push({fqdn:i,port:t})},this)}},this)},scope:this}),t.module.appWin.clearStatusBusy()},this.IsConflict=function(t,i){var s=!1;return t=t.toLowerCase(),Ext.each(e,function(e){if(e.fqdn===t&&e.port===i)return s=!0,!1},this),s}},Ext.define("SYNO.SDS.AdminCenter.Network.TcCustomPortsDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.panel=this.createPanel(),this.form=this.panel.getForm();var t={width:560,height:335,title:_T("firewall","firewall_ports_self_defined"),layout:"fit",items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","alt_apply"),itemId:"ruleApply",scope:this,handler:this.onApply}]};Ext.apply(t,e),this.callParent([t]),this.DefineBehaviors()},createPanel:function(){var e={padding:"0",border:!1,items:[{xtype:"syno_combobox",name:"port_type",hiddenName:"port_type",fieldLabel:_T("firewall","firewall_port_type"),displayField:"display",labelWidth:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_LABEL_WIDTH+50,width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,valueField:"value",value:"src",store:new Ext.data.ArrayStore({autoDestroy:!0,fields:["value","display"],data:[["src",_T("firewall","firewall_port_type_source")],["dest",_T("firewall","firewall_port_type_dest")]]})},{xtype:"syno_combobox",name:"protocol",labelWidth:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_LABEL_WIDTH+50,fieldLabel:_T("firewall","firewall_protocol"),fields:["value","display"],width:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,displayField:"display",valueField:"value",value:"tcp",scope:this,store:new Ext.data.ArrayStore({autoDestroy:!0,fields:["value","display"],data:[["tcp",_T("firewall","firewall_protocol_tcp")],["udp",_T("firewall","firewall_protocol_udp")],["gre",_T("firewall","firewall_protocol_gre_extend")],["esp",_T("firewall","firewall_protocol_esp_extend")],["all",_T("firewall","firewall_ports_all")]]}),listeners:{scope:this,select:function(e,t,i){this.disableComponents(this.owner.isVpnProtocol(t.get("value")))}}},{xtype:"syno_compositefield",hideLabel:!0,name:"firewall_port_composite",labelWidth:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_LABEL_WIDTH,fieldLabel:_T("firewall","firewall_ports")+_T("firewall","firewall_split_by_common"),itemId:"firewall_ports_container",defaultMargins:"0 0 0 0",items:[{xtype:"syno_radio",name:"self_port_choose",boxLabel:_T("firewall","firewall_ports")+_T("firewall","firewall_split_by_common")+_T("common","colon"),itemId:"firewall_ports",id:this.firewall_ports_id=Ext.id(),width:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_LABEL_WIDTH+50,inputValue:"ports"},{xtype:"syno_textfield",name:"self_ports_value",width:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,validateOnBlur:!0,vtype:"fwports"}]},{xtype:"syno_radio",boxLabel:_T("firewall","firewall_ports_range"),name:"self_port_choose",width:2*SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_LABEL_WIDTH,itemId:"firewall_ports_range",id:this.firewall_ports_range_id=Ext.id(),inputValue:"ports_range"},{xtype:"syno_numberfield",width:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,indent:1,labelWidth:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_LABEL_WIDTH+50,fieldLabel:_T("ftp","ftp_port_from"),validateOnBlur:!0,name:"self_ports_range_from",maxlength:5,vtype:"port"},{xtype:"syno_numberfield",width:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,indent:1,labelWidth:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_LABEL_WIDTH+50,fieldLabel:_T("ftp","ftp_port_to"),validateOnBlur:!0,name:"self_ports_range_to",maxlength:5,vtype:"port"}]};return new SYNO.ux.FormPanel(e)},DefineBehaviors:function(){this.enableRadioGroipDummy=new SYNO.ux.Utils.EnableRadioGroup(this.form,"self_port_choose",{ports_range:["self_ports_range_from","self_ports_range_to"],ports:["self_ports_value"]}),this.radioPortsRange=Ext.getCmp(this.firewall_ports_range_id),this.radioPorts=Ext.getCmp(this.firewall_ports_id),this.comboPortType=this.form.findField("port_type")},onApply:function(){this.validateForm(this.form)&&(this.owner.setCustom(this.getValue()),this.close())},validateForm:function(e){if(this.owner.isVpnProtocol(e.findField("protocol").getValue()))return!0;var t=e.findField("self_port_choose").getGroupValue();if(!e.isValid())return!1;if("ports"==t){if(!SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["self_ports_value"])||!SYNO.SDS.AdminCenter.Utils.Validator.MarkPortsExceed(e,"self_ports_value","TC"))return!1}else if("ports_range"==t&&(SYNO.SDS.AdminCenter.Utils.Validator.ExchgLessThanField(e,"self_ports_range_from","self_ports_range_to"),!SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["self_ports_range_from","self_ports_range_to"])))return!1;return!0},getSelfPorts:function(){var e=this.form.findField("self_port_choose").getGroupValue(),t="";return"ports"==e?t=this.form.findField("self_ports_value").getValue():"ports_range"==e&&(t=String.format("{0}-{1}",this.form.findField("self_ports_range_from").getValue(),this.form.findField("self_ports_range_to").getValue())),t},getValue:function(){var e={protocol:"",port_num:"",port_direction:""};return e.protocol=this.form.findField("protocol").getValue(),e.port_direction=this.comboPortType.getValue(),this.owner.isVpnProtocol(e.protocol)||(e.port_num=this.getSelfPorts()),e},setValue:function(e,t,i){var s="",n="";e.indexOf("-")>0?(s=e.split("-")[0],n=e.split("-")[1],this.form.findField("self_port_choose").setValue("ports_range"),this.form.findField("self_ports_range_from").setValue(s),this.form.findField("self_ports_range_to").setValue(n)):(this.form.findField("self_port_choose").setValue("ports"),this.form.findField("self_ports_value").setValue(e)),this.form.findField("port_type").setValue(t),this.form.findField("protocol").setValue(i),this.disableComponents(this.owner.isVpnProtocol(i))},disableComponents:function(e){this.comboPortType.setDisabled(e),this.radioPorts.setDisabled(e),this.radioPortsRange.setDisabled(e),this.form.findField("self_ports_value").setDisabled(e),this.form.findField("self_ports_range_from").setDisabled(e),this.form.findField("self_ports_range_to").setDisabled(e)}}),Ext.define("SYNO.SDS.AdminCenter.Network.TcRuleDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.portInfo=e.portInfo,this.direction=e.direction,this.winHeight=e.winHeight,this.panel=this.createPanel(),this.form=this.panel.getForm(),this.tips={tc_rate_max:{info:_T("firewall","firewall_tc_rate_desc")}};var t={dsmStyle:"v5",width:630,height:this.winHeight,resizable:!1,title:_T("firewall","firewall_tc_rule_add"),items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","alt_apply"),itemId:"ruleApply",scope:this,handler:this.onUpdateRuleGrid}],tips:this.tips};Ext.apply(t,e),this.callParent([t]),this.DefineBehaviors()},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){for(var e in this.tips)this.tips.hasOwnProperty(e)&&SYNO.ux.AddTip(this.form.findField("tc_rate_max").getEl(),this.tips[e].info)},this,{single:!0})},DefineBehaviors:function(){this.btnChoose=Ext.getCmp(this.btnChooseId),this.btnSelfDefine=Ext.getCmp(this.btnSelfDefineId),this.btnSrcDefine=Ext.getCmp(this.btnSrcDefineId)},createPanel:function(){var e=[{xtype:"syno_radio",itemId:"firewall_ports_all",boxLabel:_T("firewall","firewall_ports_all"),name:"ports",inputValue:"all",checked:!0,scope:this,handler:this.onCheckPorts},{xtype:"syno_compositefield",hideLabel:!0,id:this.servPortFieldID=Ext.id(),items:[{xtype:"syno_radio",itemId:"firewall_ports_system",boxLabel:_T("firewall","firewall_ports_system"),name:"ports",width:1.7*SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,inputValue:"system",checked:!1,scope:this,handler:this.onCheckPorts},{xtype:"syno_button",text:_T("common","choose"),scope:this,autoWidth:!0,id:this.btnChooseId=Ext.id(),handler:function(e,t){var i=new SYNO.SDS.AdminCenter.Utils.Dialog.ServPortsDialog({module:this.module,owner:this,serverPorts:this.portInfo});i.setVal(this.serviceChoose),i.open()}}]},{xtype:"syno_compositefield",itemId:"custom_ports_fieldset",hideLabel:!0,items:[{xtype:"syno_radio",boxLabel:_T("firewall","firewall_ports_self_defined"),name:"ports",width:1.7*SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,checked:!1,inputValue:"self-defined",scope:this,handler:this.onCheckPorts},{xtype:"syno_button",id:this.btnSelfDefineId=Ext.id(),text:_T("firewall","firewall_ports_self_defined"),scope:this,autoWidth:!0,handler:function(e,t){var i=new SYNO.SDS.AdminCenter.Network.TcCustomPortsDialog({module:this.module,owner:this});i.setValue(this.customVal.port_num,this.customVal.port_direction,this.customVal.protocol),i.open()}}]}],t={xtype:"syno_fieldset",title:_T("firewall","firewall_ports"),itemId:"firewall_ports",hideLabel:!0,items:e},i={xtype:"syno_fieldset",title:_T("firewall","firewall_tc_bandwidth_settings"),itemId:"bandwidth_settings",items:[{xtype:"syno_numberfield",width:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH-10,labelWidth:1.7*SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,fieldLabel:_T("firewall","firewall_tc_rate_min"),name:"tc_rate_min",itemId:"tc_rate_min",maxlength:7,vtype:"number"},{xtype:"syno_numberfield",width:SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH-10,labelWidth:1.7*SYNO.SDS.AdminCenter.Network.Utils.TC_DEFAULT_INPUT_WIDTH,fieldLabel:_T("firewall","firewall_tc_rate_max"),name:"tc_rate_max",itemId:"tc_rate_max",maxlength:7}]},s={border:!1,width:590,height:450,padding:"0 0 0 0",items:[t,{xtype:"syno_fieldset",title:_T("firewall","firewall_source"),itemId:"firewall_source",id:this.ipFieldID=Ext.id(),items:[{xtype:"syno_radio",name:"source",itemId:"firewall_ports_all",boxLabel:_T("firewall","firewall_ports_all"),inputValue:"all",scope:this,checked:!0,handler:this.onCheckSrc},{xtype:"syno_compositefield",itemId:"specific_source_fieldset",hideLabel:!0,items:[{xtype:"syno_radio",name:"source",boxLabel:_T("firewall","firewall_specific_ip"),inputValue:"specific_source",width:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,scope:this,handler:this.onCheckSrc},{xtype:"syno_button",id:this.btnSrcDefineId=Ext.id(),text:_T("common","choose"),scope:this,width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,handler:function(e,t){new SYNO.SDS.AdminCenter.Network.TcSrcIpDialog({module:this.module,owner:this,GridStore:this.GridStore}).open(this.source_ip)}}]}]},i]};return new SYNO.ux.FormPanel(s)},onOpen:function(){var e;this.setStatusBusy();var t=this.module.getPanel().getActiveTab().GridPanel;this.setDefault(),"add"==this.mode?this.setTitle(_T("firewall","firewall_tc_rule_add")):"edit"==this.mode&&(this.setTitle(_T("firewall","firewall_tc_rule_edit")),e=t.getSelectionModel().getSelected(),this.setValue(e)),this.onCheckPorts(),this.onCheckSrc(this.panel.getForm().findField("source")),this.gridRules=t,this.clearStatusBusy(),this.callParent(arguments)},setDefault:function(){this.customVal={port_num:"",port_direction:"src",protocol:"tcp"},this.source_ip="",this.source_subnet_mask="",this.serviceChoose="",this.ruleRecord=new SYNO.SDS.AdminCenter.Network.Utils.TcRULERecord({id:0,enabled:!0,port_type:"",port_num:"",port_direction:"src",protocol:"",minrate:-1,maxrate:-1}),this.ipDirection="dest",Ext.getCmp(this.ipFieldID).hide()},getRecordInForm:function(){var e,t,i,s;return e=this.getPorts(),t=this.getRate(),i=this.getIpDirection(),s=this.getSrc(),new SYNO.SDS.AdminCenter.Network.Utils.TcRULERecord({id:this.ruleRecord.get("id"),enabled:this.ruleRecord.get("enabled"),port_type:e.port_type,port_num:e.port_num,port_direction:e.port_direction,protocol:e.protocol,minrate:t.min,maxrate:t.max,source:s,ip_direction:i})},onUpdateRuleGrid:function(){var e,t,i=this.gridRules.GridStore;this.validateForm(this.form)&&(e=this.getRecordInForm(),"add"==this.mode?i.add(e):"edit"==this.mode&&((t=this.gridRules.getSelectionModel().getSelected()).set("enabled",e.get("enabled")),t.set("port_type",e.get("port_type")),t.set("port_num",e.get("port_num")),t.set("port_direction",e.get("port_direction")),t.set("protocol",e.get("protocol")),t.set("minrate",e.get("minrate")),t.set("maxrate",e.get("maxrate")),t.set("source",e.get("source")),t.set("ip_direction",e.get("ip_direction")),t.set("port_direction",e.get("port_direction"))),this.close())},setValue:function(e){this.ruleRecord=e,this.setPorts(e.get("port_type"),e.get("port_num"),e.get("port_direction"),e.get("protocol")),this.setRate(e.get("minrate"),e.get("maxrate")),this.setSrc(e.get("source"))},setRate:function(e,t){this.form.findField("tc_rate_min").setValue(e),this.form.findField("tc_rate_max").setValue(t)},getRate:function(){var e={min:"",max:""};return e.min=this.form.findField("tc_rate_min").getValue(),e.max=this.form.findField("tc_rate_max").getValue(),e},setPorts:function(e,t,i,s){var n="";if("ALL"==e)n="all";else if("SYS"==e)n="system",this.serviceChoose=t;else{if("SELF"!=e)return;n="self-defined",this.customVal={port_num:t,port_direction:i,protocol:s}}this.form.findField("ports").setValue(n),this.setServicesProtocol(s)},getPorts:function(){var e=this.form.findField("ports").getGroupValue(),t={port_type:"",port_num:"",port_direction:"src",protocol:""},i="";return t.protocol="","all"==e?(t.port_type="ALL",t.protocol="all"):"system"==e?(t.port_type="SYS",t.port_num=this.getServices(),t.protocol=this.getServicesProtocol()):"self-defined"==e&&(i=this.getCustom(),t.port_type="SELF",t.port_num=i.port_num,t.port_direction=i.port_direction,t.protocol=i.protocol),t},getSrc:function(){var e=this.form.findField("source").getGroupValue();return"all"==e?"all":"subnet"==e?String.format("{0}/{1}",this.srouce_ip,this.source_subnet_mask):this.source_ip},setSrc:function(e){var t="",i="";if(e||(e="all"),"all"===e)this.source_ip="all",i="all";else if(e.indexOf("-")>0)this.source_ip=e,i="specific_source";else if(e.indexOf("/")>0){var s=e.split("/");s[0],t=s[1],this.source_ip=e,this.source_subnet_mask=t,i="specific_source"}else this.source_ip=e,i="specific_source";this.form.findField("source").setValue(i)},onCheckSrc:function(e){e.checked&&("specific_source"===e.value?this.btnSrcDefine.enable():this.btnSrcDefine.disable())},getIpDirection:function(){return this.ipDirection},getServices:function(){return this.serviceChoose},setServices:function(e){this.serviceChoose=e},getServicesProtocol:function(){return this.servicesProtocol},setServicesProtocol:function(e){this.servicesProtocol=e},getCustom:function(){return this.customVal},setCustom:function(e){this.customVal=e},onCheckPorts:function(){var e=this.panel.getForm().findField("ports").getGroupValue();"system"==e?this.btnChoose.enable():this.btnChoose.disable(),"self-defined"==e?this.btnSelfDefine.enable():this.btnSelfDefine.disable()},isVpnProtocol:function(e){return-1!==["gre","esp"].indexOf(e)},validateBlank:function(e){var t=e.findField("ports").getGroupValue(),i=e.findField("source").getGroupValue();return"system"==t&&""===this.serviceChoose?(this.getMsgBox().alert(_T("firewall","firewall_tc"),_T("firewall","firewall_no_choose_service")),!1):"self-defined"!=t||""!==this.customVal.port_num||this.isVpnProtocol(this.getCustom().protocol)?"all"===i||""!==this.source_ip||(this.getMsgBox().alert(_T("firewall","firewall_tc"),_T("firewall","firewall_no_set_ip")),!1):(this.getMsgBox().alert(_T("firewall","firewall_tc"),_T("firewall","firewall_no_set_ports")),!1)},validateForm:function(e){var t=e.findField("tc_rate_min").getValue(),i=e.findField("tc_rate_max").getValue();return!!e.isValid()&&(!!this.validateBlank(e)&&(0!==i&&t>i?(this.getMsgBox().alert(_T("firewall","firewall_tc"),_T("firewall","firewall_tc_warning")),!1):SYNO.SDS.AdminCenter.Network.Utils.TC_MAX_RATE','
    ','
    ','
    ','
    ',_T("common","no_item"),"
    ","
    ","
    ",""].join("")},plugins:[this.enableColumn],columns:[this.enableColumn,{id:"tc_service",header:_T("firewall","firewall_ports"),dataIndex:"port_num",width:150,align:"center",tooltip:_T("firewall","firewall_ports"),renderer:SYNO.SDS.AdminCenter.Utils.Render.Render_Ports},{header:_T("firewall","firewall_protocol"),dataIndex:"protocol",width:120,align:"center",tooltip:_T("firewall","firewall_protocol"),renderer:SYNO.SDS.AdminCenter.Utils.Render.Render_Protocol},{header:_T("firewall","firewall_tc_header_rate_min"),dataIndex:"minrate",width:165,align:"center",tooltip:_T("firewall","firewall_tc_header_rate_min"),renderer:SYNO.SDS.AdminCenter.Network.Utils.Render_Min_Rate},{header:_T("firewall","firewall_tc_header_rate_max"),dataIndex:"maxrate",width:140,align:"center",tooltip:_T("firewall","firewall_tc_header_rate_max"),renderer:SYNO.SDS.AdminCenter.Network.Utils.Render_Max_Rate}],enableDragDrop:!0,ddGroup:"TcRulesDD",enableColumnMove:!1,enableHdMenu:!1,autoExpandColumn:"tc_service",monitorWindowResize:!0,selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:{fn:this.onChgButtonStatus,buffer:50,scope:this}}}),ddText:_T("firewall","firewall_rules_drag_drop_text"),listeners:{rowdblclick:function(){this.openRuleDialog("edit")},rowcontextmenu:this.onRowContextMenu,containercontextmenu:this.onContainerContextMenu,scope:this}},e);this.callParent([t]),this.clearDirty()},initEvents:function(){this.callParent(arguments),this.mon(this.IFStore,"load",this.onIFAfterLoad,this),this.mon(this.GridStore,"load",this.onGridAfterLoad,this),this.mon(this.GridStore,"update",this.onChgButtonStatus,this),this.mon(this.GridStore,"add",this.onStoreAdd,this),this.mon(this.GridStore,"remove",this.onStoreRemove,this),this.mon(this,"afterlayout",function(){this.ddrow=new Ext.dd.DropTarget(this.getView().mainBody,{ddGroup:"TcRulesDD",copy:!1,scope:this,notifyDrop:function(e,t,i){return this.scope.mvRules(e.getDragData(t).rowIndex,i.selections,i.grid.getStore())}})},this,{single:!0})},onIFAfterLoad:function(e,t,i){this.ifname=t[0].id,this.ifnamebak=this.ifname,Ext.getCmp(this.IFComboId).setValue(this.ifname),this.GridStore.load({params:{adapter:this.ifname},scope:this})},onGridAfterLoad:function(e,t,i){this.onChgButtonStatus(),this.clearDirty()},onStoreAdd:function(e,t,i){this.isRuleUpdated=!0,this.onChgButtonStatus()},onStoreRemove:function(e,t,i){this.isRuleUpdated=!0,this.onChgButtonStatus()},configToolBar:function(){return[{text:_T("common","create"),itemId:"create",tooltip:_T("common","create"),scope:this,handler:function(e,t){this.openRuleDialog("add")}},{text:_T("common","alt_edit"),itemId:"edit",tooltip:_T("common","alt_edit"),scope:this,handler:function(e,t){this.openRuleDialog("edit")}},{text:_T("common","delete"),itemId:"remove",tooltip:_T("common","delete"),scope:this,handler:function(){var e=this.getSelectionModel().getSelections(),t=this.getStore(),i=0;for(i=0;i",{xtype:"syno_combobox",id:this.IFComboId=Ext.id(),displayField:"display",valueField:"id",store:this.IFStore,listeners:{select:this.onIFSelect,scope:this}}]},createGridStore:function(){return new SYNO.SDS.AdminCenter.Network.TcStore({module:this.module,owner:this})},onIFSelect:function(e,t,i){t.id!=this.ifname&&(this.isDirty()?this.module.appWin.confirmLostChangePromise({save:function(){this.applyChanges().then(e=>{this.module.appWin.clearStatusBusy(),this.loadInterfaceRules(t.id)}).catch(e=>{this.module.appWin.clearStatusBusy(),this.module.appWin.setStatusError()})},dontSave:function(){this.loadInterfaceRules(t.id)},cancel:function(){Ext.getCmp(this.IFComboId).setValue(this.IFStore.getById(this.ifname).data.display)}},this):this.loadInterfaceRules(t.id))},clearIFSelect:function(){Ext.getCmp(this.IFComboId).clearValue(),this.getSelectionModel().clearSelections(),this.getStore().removeAll(),this.clearDirty(),this.onChgButtonStatus()},processReturnData:function(e,t,i){!0===t.has_fail&&this.module.appWin.clearStatusBusy(),"set"===e&&(this.clearDirty(),this.getStore().load({params:{adapter:this.ifname},scope:this}))},openRuleDialog:function(e){new SYNO.SDS.AdminCenter.Network.TcRuleDialog({owner:this.module.appWin,module:this.module,portInfo:this.portInfo,winHeight:380,mode:e}).open()},onContainerContextMenu:function(e,t){e.getSelectionModel().hasSelection()&&this.showContextMenu(t)},onRowContextMenu:function(e,t,i){var s=e.getSelectionModel();s.suspendEvents(!1),s.selectRow(t,s.isSelected(t)),this.onChgButtonStatus(),s.resumeEvents(),this.showContextMenu(i)},showContextMenu:function(e){var t=[],i=this.getButton("edit"),s=this.getButton("remove");i&&!i.disabled&&t.push({text:_T("common","alt_edit"),scope:this,handler:function(e,t){this.openRuleDialog("edit")}}),s&&!s.disabled&&t.push({text:_T("common","delete"),scope:this,handler:function(){for(var e=this.getSelectionModel(),t=e.getSelections(),i=this.getStore(),s=0;s=i.getCount()?this.getView().focusEl.focus():(e.selectFirstRow(),this.getView().focusRow(0))}}),new SYNO.ux.Menu({autoDestroy:!0,items:t}).showAt(e.getXY()),e.preventDefault()},mvRules:function(e,t,i){if(void 0===e)return!1;for(var s=0;s=i.getCount()?i.add(t):i.insert(e,t),this.isRuleUpdated=!0,!0},clearDirty:function(){this.isRuleUpdated=!1,this.getStore().commitChanges()},onChgButtonStatus:function(){if(!0!==this.isMoveRow){var e=this.getStore().getCount(),t=this.getSelectionModel().getCount();this.setButton("create",e0}}),Ext.define("SYNO.SDS.AdminCenter.Network.RoutingTable.RuleGrid",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=e.appWin,this.ifClass=e.ifClass,this.width=600,this.height=300,this.frame=!1,this.border=!1,this.title=_T("network","route_table"),this.tables=[],this.TableStore=new Ext.data.SimpleStore({fields:["value","display"],data:[]});var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={colModel:new Ext.grid.ColumnModel({defaults:{width:120,sortable:!0},columns:[{header:_T("network","route_network"),dataIndex:"ip"},{header:_T("network","route_gateway"),dataIndex:"gateway"},{header:_T("network","route_mask"),dataIndex:"mask"},{header:_T("network","route_metric"),dataIndex:"metric"},{header:_T("network","route_interface"),dataIndex:"ifname",width:150,renderer:{fn:function(e){var t=SYNO.SDS.Utils.Network.idToString.apply(this,[e]);return"vpn-client"===this.ifClass[e]&&(t="VPN"),t},scope:this}}]}),store:new SYNO.SDS.AdminCenter.Network.RoutingTable.RuleStore({module:this.module,appWin:this.appWin}),tbar:{items:[{xtype:"syno_combobox",id:this.TableComboId=Ext.id(),displayField:"display",valueField:"value",store:this.TableStore,listeners:{select:this.onTableSelect,scope:this}}]},listeners:{scope:this,activate:this.onActivate}};return Ext.apply(t,e),t},onTableSelect:function(e,t,i){Ext.each(this.tables,function(e){e.name===t.data.value&&this.getStore().loadData(e.rules)},this)},loadTables:function(e,t,i){this.parentDialog.clearStatusBusy(),e&&(!0===_S("ha_hide_ntb")?(this.tables=[],Ext.each(t.tables,function(e){var t=e.rules.filter(function(e,t,i){return-1===e.ifname.indexOf("ntb")});e.rules=t,this.tables.push(e)},this)):this.tables=t.tables,this.TableStore.loadData(this.getDisplayedTableString()),Ext.getCmp(this.TableComboId).setValue(this.tables[0].name),this.getStore().loadData(this.tables[0].rules))},getDisplayedTableString:function(){var e=[];return Ext.each(this.tables,function(t){var i=t.name.indexOf("-");if(1>i)return SYNO.Debug("error on getting table"),!1;var s,n=t.name.substring(0,i);s="static"===n?_T("network","route_static_table"):"main"===n?_T("network","route_main_table"):"vpn-client"===t.class?"VPN "+_T("network","route_table_prefix"):SYNO.SDS.Utils.Network.idToString(n)+" "+_T("network","route_table_prefix"),e.push([t.name,s])},this),e},onActivate:function(){this.parentDialog.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({api:"SYNO.Core.Network.Router.Static.Route",method:"tablesget",params:{type:"ipv4"},version:1,scope:this,callback:this.loadTables})}}),Ext.define("SYNO.SDS.AdminCenter.Network.RoutingTableV6.RuleGrid",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=e.appWin,this.ifClass=e.ifClass,this.width=600,this.height=300,this.frame=!1,this.border=!1,this.title=_T("network","route_table"),this.tables=[],this.TableStore=new Ext.data.SimpleStore({fields:["value","display"],data:[]});var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={colModel:new Ext.grid.ColumnModel({defaults:{width:120,sortable:!0},columns:[{header:_T("network","route_network"),dataIndex:"ip"},{header:_T("network","route_next_hop"),dataIndex:"gateway"},{header:_T("network","route_metric"),dataIndex:"metric"},{header:_T("network","route_interface"),dataIndex:"ifname",width:150,renderer:{fn:function(e){var t=SYNO.SDS.Utils.Network.idToString.apply(this,[e]);return"vpn-client"===this.ifClass[e]&&(t="VPN"),t},scope:this}}]}),store:new SYNO.SDS.AdminCenter.Network.RoutingTable.RuleStore({module:this.module,appWin:this.appWin}),tbar:{items:[{xtype:"syno_combobox",id:this.TableComboId=Ext.id(),displayField:"display",valueField:"value",store:this.TableStore,listeners:{select:this.onTableSelect,scope:this}}]},listeners:{scope:this,activate:this.onActivate}};return Ext.apply(t,e),t},onTableSelect:function(e,t,i){Ext.each(this.tables,function(e){e.name===t.data.value&&this.getStore().loadData(e.rules)},this),this.getStore().filterBy(function(e){return 0!==e.get("ifname").indexOf("tap")})},loadTables:function(e,t,i){if(this.parentDialog.clearStatusBusy(),e){var s=[];!0===_S("ha_hide_ntb")?(this.tables=[],Ext.each(t.tables,function(e){var t=e.rules.filter(function(e,t,i){return-1===e.ifname.indexOf("ntb")});e.rules=t,this.tables.push(e)},this)):this.tables=t.tables,Ext.each(this.tables,function(e){s.push([e.name,e.name])},this),this.TableStore.loadData(this.getDisplayedTableString()),Ext.getCmp(this.TableComboId).setValue(this.tables[0].name),this.getStore().loadData(this.tables[0].rules)}},getDisplayedTableString:function(){var e=[];return Ext.each(this.tables,function(t){var i=t.name.indexOf("-");if(1>i)return SYNO.Debug("error on getting table"),!1;var s,n=t.name.substring(0,i);s="static"===n?_T("network","route_static_table"):"main"===n?_T("network","route_main_table"):"vpn-client"===t.class?"VPN "+_T("network","route_table_prefix"):SYNO.SDS.Utils.Network.idToString(n)+" "+_T("network","route_table_prefix"),e.push([t.name,s])},this),e},onActivate:function(){this.parentDialog.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({api:"SYNO.Core.Network.Router.Static.Route",method:"tablesget",params:{type:"ipv6"},version:1,scope:this,callback:this.loadTables})}}),Ext.define("SYNO.SDS.AdminCenter.Network.RoutingTable.RuleStore",{extend:"SYNO.API.JsonStore",constructor:function(e){if(this.module=e.module,this.ruleFields=["gateway","mask","ifname","ip","metric"],!Ext.isDefined(e.module))throw Error("module is undefined");var t=Ext.apply({method:"get",version:1,autoDestroy:!0,idProperty:"destination",fields:this.ruleFields,listeners:{}},e);this.callParent([t])}}),Ext.define("SYNO.SDS.AdminCenter.Network.RoutingTable.Window",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.ip_type=e.ip_type,this.ifClass=e.ifClass,"ipv4"===this.ip_type?this.StaticRoutingTab=new SYNO.SDS.AdminCenter.Network.RoutingTable.RuleGrid({parentDialog:this,module:this.module,appWin:this.module.appWin,owner:this.owner,ifClass:this.ifClass,itemId:"RoutingTableGrid"}):"ipv6"===this.ip_type&&(this.StaticRoutingTab=new SYNO.SDS.AdminCenter.Network.RoutingTableV6.RuleGrid({parentDialog:this,module:this.module,appWin:this.module.appWin,owner:this.owner,ifClass:this.ifClass,itemId:"RoutingTableGrid"}));var t=Ext.apply({title:_T("network","route_table"),autoDestroy:!0,width:600,height:400,layout:"fit",border:!1,items:[this.StaticRoutingTab],listeners:{scope:this,activate:this.onActivate},buttons:[{text:_T("common","close"),scope:this,handler:this.onCancel}]},e);this.callParent([t])},onActivate:function(){this.callParent(arguments),this.StaticRoutingTab.onActivate()},onCancel:function(){this.close()}}),Ext.define("SYNO.SDS.AdminCenter.Network.StaticRouting.AddRuleDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.ifClass=e.ifClass,this.rule_store=e.rule_store,this.selectModel=e.selectModel,this.ip_type=e.ip_type,this.isRuleValid=!1;var t=Ext.apply({title:_T("network","route_static"),autoDestroy:!0,width:450,height:290,layout:"fit",border:!1,items:[this.configForm({border:!1,itemId:"formpanel"})],buttons:[{text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{disabled:this._S("demo_mode"),text:_T("common","create"),btnStyle:"blue",scope:this,handler:this.onAddRule}]},e);this.callParent([t])},configForm:function(e){return SYNO.LayoutConfig.fill(Ext.apply({xtype:"syno_formpanel",padding:"0",trackResetOnLoad:!0,synodefaults:{width:200},items:[{xtype:"syno_textfield",fieldLabel:_T("network","route_network"),name:"ip",allowBlank:!1,vtype:"ipv4"===this.ip_type?"v4ip":"v6ip"},{xtype:"syno_textfield",fieldLabel:"ipv4"===this.ip_type?_T("network","route_mask"):_T("network","route_prefix_length"),name:"mask",allowBlank:!1,vtype:"ipv4"===this.ip_type?"netmask":null},{xtype:"syno_textfield",fieldLabel:_T("network","route_gateway"),name:"gateway",allowBlank:!1,validator:function(e){return"ipv4"===this.ip_type?"0.0.0.0"===e||(!!Ext.form.VTypes.v4ipVal.test(e)||Ext.form.VTypes.v4ipText):!!Ext.form.VTypes.v6ipVal.test(e)||Ext.form.VTypes.v6ipText}.createDelegate(this)},{xtype:"syno_combobox",name:"ifname",width:200,valueField:"value",displayField:"display",store:new Ext.data.SimpleStore({fields:["value","display"],data:[]}),fieldLabel:_T("network","route_interface")}]},e))},getForm:function(){return this.getComponent("formpanel").getForm()},addRuleCallback:function(e,t,i){this.clearStatusBusy();var s=this.getForm(),n=function(e){var t=s.findField(e);return t?t.getValue():void 0};return e?(this.rule_store.add(new this.rule_store.recordType({enable:!0,ip:t.ip,mask:n("mask"),gateway:n("gateway"),ifname:n("ifname")})),this.close(),!0):(this.setStatusError({text:_T("network","route_static_rule_error"),clear:!0}),!1)},onAddRule:function(){var e=this.getForm(),t={},i=function(t){var i=e.findField(t);return i?i.getValue():void 0};return e.isDirty()?!!e.isValid()&&(t.enable=!0,t.ip=i("ip"),"ipv4"===this.ip_type?t.mask=i("mask"):"ipv6"===this.ip_type&&(t.prefix_length=i("mask")),t.gateway=i("gateway"),t.ifname=i("ifname"),this.setStatusBusy({text:_T("common","saving")}),void this.sendWebAPI({api:"SYNO.Core.Network.Router.Static.Route",method:"test",params:{rule:t,type:this.ip_type},version:1,scope:this,callback:this.addRuleCallback})):(this.close(),!0)},onCancel:function(){this.getForm().isDirty()?this.confirmLostChangePromise({save:this.onAddRule,dontSave:this.close,cancel:Ext.emptyFn},this):this.close()},onOpen:function(){var e=[],t={};for(var i in this.ifClass)this.ifClass.hasOwnProperty(i)&&("vpn-client"===this.ifClass[i]?e.push([i,"VPN"]):e.push([i,SYNO.SDS.Utils.Network.idToString(i)]));this.getForm().findField("ifname").store.loadData(e),t.ifname=this.getForm().findField("ifname").store.getAt(0).get("value"),this.getForm().setValues(t),this.callParent([arguments])}}),Ext.define("SYNO.SDS.AdminCenter.Network.StaticRouting.RuleStore",{extend:"SYNO.API.JsonStore",constructor:function(e){if(this.ruleFields=["enable","ip","mask","gateway","ifname","active"],!Ext.isDefined(e.module))throw Error("module is undefined");var t=Ext.apply({api:"SYNO.Core.Network.Router.Static.Route",appWindow:e.appWin,method:"get",version:1,autoDestroy:!0,baseParams:{type:"ipv4"},root:"rules",fields:this.ruleFields,listeners:{load:this.onLoad,exception:this.onStoreException,add:this.onRuleChanged,update:this.onUpdate,remove:this.onRuleChanged,scope:this}},e);this.callParent([t])},onLoad:function(){this.module.appWin.clearStatusBusy()},onStoreException:function(e,t,i,s,n,o){SYNO.Debug("Store exception: options:",s),this.module.appWin.unmask(),this.module.appWin.setStatusError()},onRuleChanged:function(e,t,i){this.isRuleChanged=!0,this.grid.getView().onLayout()},onUpdate:function(e,t,i){},onSelectAll:function(){},getRules:function(){var e=[],t=0,i={};for(t=0;t0},clearDirty:function(){this.commitChanges(),this.isRuleChanged=!1},reset:function(){Ext.isDefined(this.reader.jsonData)&&this.loadData(this.reader.jsonData),this.isRuleChanged=!1}}),Ext.define("SYNO.SDS.AdminCenter.Network.StaticRoutingTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.appWin=e.appWin;var t=Ext.apply(e,{owner:this}),i=Ext.apply({layout:"fit",padding:"0 0 0 0",cls:"syno-network-staticroutetab",title:_T("network","route_static"),items:[this.GridPanel=new SYNO.SDS.AdminCenter.Network.StaticRoutingGrid(t)],listeners:{scope:this.GridPanel,activate:this.GridPanel.onActivate,deactivate:this.GridPanel.onDeactivate,rowcontextmenu:this.GridPanel.onRowContextMenu,containercontextmenu:this.GridPanel.onContainerContextMenu}},e);this.callParent([i]),this.setCustomFormFunc()},setCustomFormFunc:function(){Ext.isDefined(this.GridPanel.ipTypeCombo)||(this.GridPanel.ipTypeCombo=this.GridPanel.getTopToolbar().getComponent("ip_type_combobox")),this.getForm().items.items.push(this.GridPanel)},isDirty:function(){return this.GridPanel.isDirty()},getApiArray:function(e){return"set"===e?[this.GridPanel.getApiSaveRules()]:[]},processParams:function(e,t){return"set"===e?this.GridPanel.getApiSaveRules():[]},processReturnData:function(e,t,i){this.GridPanel.processReturnData(e,t,i),"set"===e&&this.getComponent(this.itemId).unmask()}}),Ext.define("SYNO.SDS.AdminCenter.Network.StaticRoutingGrid",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.module=e.module,this.appWin=e.appWin,this.owner=e.owner,this.enableColumn=new SYNO.ux.EnableColumn({header:_T("common","commit"),dataIndex:"enable",width:80,align:"center",enableFastSelectAll:!0,listeners:{selectall:{fn:function(){this.getStore().onSelectAll()},scope:this}},commitChanges:!1}),this.renderer={qtip:function(e,t){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e},qtip_interface:function(e,t){var i=SYNO.SDS.Utils.Network.idToString(e);return"vpn-client"===this.ifClass[e]&&(i="VPN"),t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(i)+'"',i},status:function(e,t){var i="Enabled"===e?_T("common","enabled"):_T("common","disabled");return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(i)+'"',i}};var t=Ext.apply({padding:"0 0 0 0",width:600,height:300,frame:!1,border:!1,plugins:this.enableColumn,viewConfig:{emptyText:['
    ','
    ','
    ','
    ','
    ',_T("common","no_item"),"
    ","
    ","
    ","
    "].join("")},columns:[this.enableColumn,{header:_T("network","route_network"),dataIndex:"ip",width:120,align:"left",renderer:this.renderer.qtip},{header:_T("network","route_mask"),dataIndex:"mask",width:120,align:"left",renderer:this.renderer.qtip},{header:_T("network","route_gateway"),dataIndex:"gateway",width:120,align:"left",renderer:this.renderer.qtip},{header:_T("network","route_interface"),dataIndex:"ifname",width:120,align:"left",scope:this,renderer:this.renderer.qtip_interface},{header:_T("common","status"),dataIndex:"active",width:120,align:"left",renderer:this.renderer.status}],enableHdMenu:!1,loadMask:!1,cls:"without-dirty-red-grid syno-network-staticroutetab-gridpanel",selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:this.checkOnSelectionChanged,scope:this}}),store:new SYNO.SDS.AdminCenter.Network.StaticRouting.RuleStore({module:this.module,appWin:this.appWin,grid:this}),tbar:[{xtype:"syno_button",text:_T("common","create"),handler:this.onCreateRule,scope:this,itemId:"create"},{xtype:"syno_button",text:_T("common","delete"),handler:this.onDeleteRule,scope:this,itemId:"del"},{xtype:"syno_button",text:_T("network","route_table"),handler:this.onRouteTable,scope:this,itemId:"routingTable"},"->",{xtype:"syno_combobox",itemId:"ip_type_combobox",editable:!1,allowBlank:!1,store:this.getIPTypeStore(),value:"ipv4",listeners:{scope:this,beforeselect:this.onBeforeSelect,select:this.onTypeChange}}]},e);this.callParent([t])},onRowContextMenu:function(e,t,i){var s=e.getSelectionModel();s.isSelected(t)||s.selectRow(t),this.showContextMenu(i)},onContainerContextMenu:function(e,t){e.getSelectionModel().hasSelection()&&this.showContextMenu(t)},showContextMenu:function(e){new SYNO.ux.Menu({autoDestroy:!0,items:[{text:_T("common","delete"),scope:this,handler:function(){for(var e=this.getSelectionModel(),t=e.getSelections(),i=this.getStore(),s=0;s=i.getCount()?this.getView().focusEl.focus():(e.selectFirstRow(),this.getView().focusRow(0))}}]}).showAt(e.getXY())},getButton:function(e){return this.getTopToolbar().getComponent(e)},getIPTypeStore:function(){return!0===_S("ha_not_support_ipv6")?[["ipv4","IPv4"]]:[["ipv4","IPv4"],["ipv6","IPv6"]]},enableButton:function(e,t){var i=this.getButton(e);Ext.isObject(i)?t?i.enable():i.disable():SYNO.Debug("enableButton failed: no button object of ",e)},disableAllButton:function(){Ext.each(["del"],function(e){this.getButton(e).disable()},this)},checkOnSelectionChanged:function(e){0{this.module.appWin.clearStatusBusy(),this.clearDirty(),e.setValue(e.getStore().getAt(i).get(e.valueField)),e.fireEvent("select",e)}).catch(e=>{this.module.appWin.clearStatusBusy(),this.module.appWin.setStatusError()})},dontSave:function(){this.clearDirty(),e.setValue(e.getStore().getAt(i).get(e.valueField)),e.fireEvent("select",e)},cancel:Ext.emptyFn},this),!1)},isDirty:function(){return this.getStore().isDirty()},clearDirty:function(){this.getStore().clearDirty()},validate:function(){return!0},reset:function(){this.getStore().reset()},onTypeChange:function(e){this.disableAllButton(),this.module.appWin.setStatusBusy({text:_T("common","loading")}),this.getStore().load({params:{type:e.getValue()},scope:this}),this.getColumnModel().setColumnHeader(2,"ipv4"===e.getValue()?_T("network","route_mask"):_T("network","route_prefix_length"))},processReturnData:function(e,t,i){!0===t.has_fail&&this.module.appWin.clearStatusBusy(),"set"===e&&(this.clearDirty(),this.getStore().load())},applyChanges:function(){var e=this.owner.getForm().getValues("set"),t=this.owner.constructApplyParams(e);return t=t.concat(this.owner.getApiArray("get",!0)),t=this.owner.processParams("set",t),this.module.appWin.setStatusBusy({text:_T("common","saving")}),this.owner.sendWebAPIPromise({compound:{stopwhenerror:!1,params:t}})}}),Ext.define("SYNO.SDS.AdminCenter.LoginPortal.Network.ConnectivityTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.DSMSettingsConfig={};var t={trackResetOnLoad:!0,border:!1,defaults:{labelWidth:272},items:this.getItems(),webapi:{api:"SYNO.Core.Web.DSM",methods:{get:"get",set:"set"},version:2},listeners:{scope:this,afterlayout:this.onAfterlayout}};this.callParent([Ext.apply(t,e)]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_max_connections",["max_connections"]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_server_header",["server_header"])},getItems:function(){return[{xtype:"syno_checkbox",boxLabel:_T("service","enable_http2"),name:"enable_spdy"},{xtype:"syno_displayfield",indent:1,name:"enable_spdy_desc",value:_T("service","enable_http2_desc")},{xtype:"syno_checkbox",boxLabel:_T("service","enable_customized_max_http_connections"),name:"enable_max_connections"},{xtype:"syno_numberfield",name:"max_connections",width:240,indent:1,fieldLabel:_T("service","http_connections")},{xtype:"syno_checkbox",name:"enable_server_header",boxLabel:_T("service","enable_server_header")},{xtype:"syno_textfield",name:"server_header",width:240,fieldLabel:_T("service","server_header"),allowBlank:!1,emptyText:"nginx",indent:1},{xtype:"syno_checkbox",name:"enable_reuseport",boxLabel:_T("service","enable_reuseport")}]},loadDataAndSetFormValues:function(){this.owner.setStatusBusy(),this.sendWebAPI({api:this.webapi.api,method:this.webapi.methods.get,version:this.webapi.version,scope:this,callback:function(e,t){this.owner.clearStatusBusy(),e&&this.setFormValues(t)}})},setFormValues:function(e){this.DSMSettingsConfig=e;let t={enable_spdy:!1,enable_max_connections:!1,max_connections:0,enable_server_header:!1,server_header:"nginx",remove_banner:!1,enable_reuseport:!1};t.enable_spdy=e.enable_spdy,t.enable_max_connections=e.enable_max_connections,t.max_connections=e.max_connections,t.enable_server_header=e.enable_server_header,t.server_header=e.server_header,t.enable_reuseport=e.enable_reuseport,this.getForm().setValues(t);let i=this.getForm().findField("max_connections"),s=this.getForm().findField("enable_max_connections");if(null===i||null===s)return;void 0!==e.max_connections?(i.setMinValue(e.max_connections_limit.lower),i.setMaxValue(e.max_connections_limit.upper)):(i.hide(),s.hide());let n=this.getForm().findField("enable_reuseport");e.support_reuseport||n.hide()},needWaitHttpdRestart:function(e,t){return e.enable_spdy!==t.enable_spdy||void 0!==e.enable_max_connections&&e.enable_max_connections!==t.enable_max_connections||e.enable_server_header!==t.enable_server_header||e.enable_reuseport!==t.enable_reuseport||(void 0!==t.max_connections&&e.max_connections!==t.max_connections||void 0!==t.server_header&&e.server_header!==t.server_header)},prepareSetDSMSettingParams:function(e){let t={};return delete(t=JSON.parse(JSON.stringify(e))).remove_banner,t},processReturnData:function(e,t,i){const s=t.result.find(e=>e.api===this.webapi.api&&e.method===this.webapi.methods.set);if(s)if(s.success){const e=this.getForm().getValues(),t=this.prepareSetDSMSettingParams(e);if(this.needWaitHttpdRestart(this.DSMSettingsConfig,t)){SYNO.SDS.AdminCenter.Utils.WaitHttpdRestart(this.owner.owner)()}}else{let e=_T("common","error_system");t.error&&t.error.code&&(e=SYNO.API.getErrorString(t.error.code)),this.owner.setStatusError({text:e,clear:!0})}},onAfterlayout:function(){this.maxConnectionsTip||(this.maxConnectionsTip=SYNO.ux.AddTip(this.getForm().findField("max_connections").getEl(),_T("service","http_connections_hint")))}}),Ext.define("SYNO.SDS.AdminCenter.Network.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(){this.glusterComputingOrStorage=!1,this.bondType="",this.callParent(arguments)},getPanel:function(){return this.panel||(this.panel=new SYNO.SDS.AdminCenter.Network.TabPanel({module:this,owner:this.appWin})),this.panel},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"GeneralTab":return"AdminCenter/connection_network_general.html";case"InterfaceTab":return"AdminCenter/connection_network_desc.html";case"TcTab":return"AdminCenter/connection_network_trafficcontrol.html";case"ConnectivityTab":return"AdminCenter/connection_network_connectivity.html";default:return"AdminCenter/connection_network_desc.html"}},getWebAPIs:function(){return this.webAPIs?this.webAPIs:(this.webAPIs=[],this.webAPIs.push({api:"SYNO.Core.CMS.Info",method:"get",version:1,additional:["gluster_role"]}),this.webAPIs.push({api:"SYNO.Core.Network.OVS",method:"get",version:1}),Ext.each(this.getStore().getWebAPIs(),function(e){this.webAPIs.push(Ext.apply({api:e.api,method:e.method,version:e.version},e.params))},this),this.webAPIs)},confirmCallback:function(e){this.panel.StaticRoutingTab.onChangeConfirm(e)},activate:function(e){this.panel.resetAllForm(),this.startPolling(),this.panel.connectivityTab.loadDataAndSetFormValues(),"yes"===this.panel._D("supportTc")&&(this.panel.loadPortInfo(),this.panel.IFStore.loadInterface()),e&&e.tab&&this.panel.setActiveTab(e.tab)},deactivate:function(){if(this.stopPolling(),"yes"===this.appWin._D("supportTc")){if(this.panel.getComponent("TcTab").isDirty())return!1;this.panel.portInfo_request&&Ext.Ajax.abort(this.panel.portInfo_request)}return!this.panel.generalTab.isDirty()&&(!this.panel.connectivityTab.isFormDirty()&&!(this.appWin._S("version")>=4966&&this.panel.StaticRoutingTab.isDirty()))},startPolling:function(){this.pollMainId||(this.pollMainId=this.appWin.pollReg({scope:this,webapi:{api:"SYNO.Entry.Request",version:1,method:"request",params:{stopwhenerror:!1,compound:this.getWebAPIs()}},interval:5,immediate:!0,status_callback:function(e,t,i,s){var n=!0,o={has_fail:!1,result:[]};Ext.each(t.result,function(e,i,s){if("SYNO.Core.Network.OVS"!==e.api)if("SYNO.Core.CMS.Info"===e.api){if(!e.success){var a=_T("common","error_system");return t.error&&t.error.code&&(a=SYNO.API.getErrorString(t.error.code)),this.appWin.setStatusError({text:a,clear:!0}),void(this.glusterComputingOrStorage=!1)}1&e.data.additional.gluster_role||2&e.data.additional.gluster_role?this.glusterComputingOrStorage=!0:this.glusterComputingOrStorage=!1}else n=n&&e.success,o.result.push(e);else{if(!e.success)return;e.data.enable_ovs?this.bondType="ovs":this.bondType=""}},this),o&&(o.has_fail=n,this.getStore().onLoad.call(this.getStore(),n,o,i.compound,s.params),o=void 0),this.panel.generalTab.loadFormNoMask()}}))},stopPolling:function(){this.pollMainId&&(this.appWin.pollUnreg(this.pollMainId),this.pollMainId=null)},getStore:function(){return this.store?this.store:(this.store=new SYNO.SDS.AdminCenter.Network.InterfaceStore({owner:this.appWin,module:this,callback:{afterload:function(){this.appWin&&!this.appWin.isVisible()||(this.appWin._S("version")<4966&&this.panel.generalTab.afterLoad(),this.panel.interfaceTab.activated&&this.panel.interfaceTab.afterLoad())},scope:this}}),this.store)},getGoToHAMsgBox:function(){var e=_T("mainmenu","leaf_control_panel"),t=_TT("SYNO.SDS.HA.Instance","ui","confirm_setting_net_on_ha_mgr");this.appWin.getMsgBox().confirm(e,t,function(e){"ok"===e&&SYNO.SDS.AppLaunch("SYNO.SDS.HA.Instance",{fn:"SYNO.SDS.HA.Network.Main"})},this,Ext.MessageBox.OKCANCEL)},getHAMsgBox:function(){var e=_T("mainmenu","leaf_control_panel"),t=_TT("SYNO.SDS.HA.Instance","ui","ha_not_support_setting");this.appWin.getMsgBox().alert(e,t)},getGlusterBox:function(){var e=_T("status","status_gluster"),t=_T("network","need_disjoin_gluster");this.appWin.getMsgBox().alert(e,t)},confirmLostChangeSave:function(){return new Promise(function(e,t){this.confirmSaveLostResolve=e,this.confirmSaveLostReject=t,this.panel.applyHandler()}.bind(this))}}),Ext.define("SYNO.SDS.AdminCenter.Network.TabPanel",{extend:"SYNO.SDS.Utils.TabPanel",constructor:function(e){var t=[];this.module=e.module,this.owner=e.owner,this.showOldUI=this._S("version")<4966,this.IFStore=this.createIFStore(),this.portInfo=[],t.push(this.generalTab=new SYNO.SDS.AdminCenter.Network.GeneralTab({module:e.module,owner:this,itemId:"GeneralTab"})),t.push(this.interfaceTab=new SYNO.SDS.AdminCenter.Network.InterfaceTab({module:e.module,owner:this,itemId:"InterfaceTab"})),"yes"===this._D("supportTc")&&(this.TcTab=new SYNO.SDS.AdminCenter.Network.TcTab({module:e.module,title:_T("firewall","firewall_tc"),owner:this,itemId:"TcTab",IFStore:this.IFStore}),t.push(this.TcTab)),this.showOldUI||(this.StaticRoutingTab=new SYNO.SDS.AdminCenter.Network.StaticRoutingTab({module:e.module,appWin:e.module.appWin,owner:this,itemId:"StaticRoutingTab"}),t.push(this.StaticRoutingTab)),t.push(this.connectivityTab=new SYNO.SDS.AdminCenter.LoginPortal.Network.ConnectivityTab({module:e.module,appWin:e.module.appWin,owner:this,itemId:"ConnectivityTab",title:_T("controlpanel","connectivity")}));var i=Ext.apply({activeTab:0,applyDirtyOnly:!0,deferredRender:!1,module:e.module,items:t},e);this.callParent([i])},applyHandler:function(e,t){this.showOldUI&&this.generalTab.isGatewayDirty()&&this.generalTab.isGatewayEmpty()?this.module.appWin.getMsgBox().confirm("",_T("common","error_nogate"),function(e){if("yes"!==e)return!1;this.module.stopPolling(),this.applyAllForm()},this):(this.module.stopPolling(),this.applyAllForm())},getFeasibilityCheckResult:function(e){var t=!0;return Ext.each(e,function(e,i,s){if(!1===e.success&&4319===e.error.code)return t=!1,!1}),t},getAjaxCfg:function(e){return{encryption:["password"]}},onApiSuccess:function(e,t,i){if("set"===e)if(t.has_fail)if(!1===this.getFeasibilityCheckResult(t.result))this.module.confirmSaveLostReject&&this.module.confirmSaveLostReject(),this.setStatusError({text:_T("error","nochange_subject"),clear:!0});else{this.module.confirmSaveLostReject&&this.module.confirmSaveLostReject();var s=SYNO.API.getErrorString(t);this.setStatusError({text:s,clear:!0})}else this.setStatusOK(),this.module.startPolling(),this.module.confirmSaveLostResolve&&this.module.confirmSaveLostResolve();this.processReturnData(e,t,i);const n=t.result.find(e=>"SYNO.Core.Web.DSM"===e.api&&"get"===e.method);n&&this.connectivityTab.setFormValues(n.data)},createIFStore:function(){return new SYNO.SDS.AdminCenter.Network.SimpleIFStore({module:this.module,owner:this})},loadPortInfo:function(){this.setStatusBusy({text:_T("common","loading")}),this.portInfo_request=this.sendWebAPI({api:"SYNO.Core.Service.PortInfo",method:"load",params:{target:["traffic_control"]},version:1,scope:this,callback:function(e,t,i){e?(SYNO.SDS.AdminCenter.Utils.Render.ServerPortsParsing(t,this.portInfo,!0),this.TcTab.GridPanel&&this.TcTab.GridPanel.getView&&this.TcTab.GridPanel.getView().refresh()):this.module.appWin.getMsgBox().alert(_T("firewall","firewall_tc"),_T("common","commfail")),this.clearStatusBusy()}})}}),Ext.define("SYNO.SDS.AdminCenter.Security.DSM.WhitelistDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t=Ext.apply({dialog:this},e),i={width:620,height:540,layout:"fit",title:_T("dsmsetting","allowurls"),items:[this.grid=new SYNO.SDS.AdminCenter.Security.DSM.WhitelistGrid(t)],buttons:[{text:_T("common","cancel"),btnStyle:"grey",scope:this,handler:this.close},{text:_T("common","ok"),btnStyle:"blue",scope:this,handler:this.onOkClick}],listeners:{beforeclose:this.onBeforeClose.createDelegate(this)}};return Ext.apply(i,e),i},onOkClick:function(){var e=this.module.whitelist,t=this.grid.store.collect("hostname").sort();if(this.isWhitelistChanged(e,t)){var i=Ext.applyIf({method:"set",params:{whitelist:t},callback:function(){var e=this.module.getForm().findField("whitelist");this.clearStatusBusy(),e.setValue(t),e.originalValue=e.getValue(),this.module.whitelist=t,this.module.ownerCt.restartHttpd=!0,this.close()},scope:this},this.module.embedAPI);this.setStatusBusy(),this.sendWebAPI(i)}else this.close()},isWhitelistChanged:function(e,t){if(e.length!==t.length)return!0;for(var i=0;i[e])),this.close()},cancel:Ext.emptyFn},this),!1}}),Ext.define("SYNO.SDS.AdminCenter.Security.DSM.WhitelistGrid",{extend:"SYNO.ux.EditorGridPanel",clicksToEdit:2,constructor:function(e){this.module=e.module,this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.store=this.createStore(),this.actionAdd=new Ext.Action({text:_T("common","add"),itemId:"btn_add",handler:this.addUrl,scope:this}),this.actionDelete=new Ext.Action({text:_T("common","delete"),itemId:"btn_del",handler:this.deleteUrl,disabled:!0,scope:this}),this.readWhitelist(this.module.whitelist),this.store.loadData(this.whitelist),this.gridCtxMenu=new SYNO.ux.Menu(this.actionDelete);var t={border:!1,store:this.store,autoFlexcroll:!0,enableHdMenu:!1,tbar:{xtype:"syno_toolbar",defaultType:"syno_button",items:[this.actionAdd,this.actionDelete]},colModel:new Ext.grid.ColumnModel({columns:[{header:_T("service","service_host_name"),dataIndex:"hostname",editor:new Ext.grid.GridEditor({revertInvalid:!1,field:{xtype:"syno_textfield",vtype:"url"}}),allowBlank:!1}],defaults:{sortable:!0}}),selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:this.onSelectionChange,scope:this}}),listeners:{scope:this,rowcontextmenu:this.onClickCtxMenu,containercontextmenu:this.onKeyCtxMenu}};return Ext.apply(t,e),t},onClickCtxMenu:function(e,t,i){var s=e.getSelectionModel();s.isSelected(t)||s.selectRow(t),this.gridCtxMenu.showAt(i.getXY())},onKeyCtxMenu:function(e,t){e.getSelectionModel().hasSelection()&&this.gridCtxMenu.showAt(t.getXY())},onSelectionChange:function(){0===this.getSelectionModel().getSelections().length?this.actionDelete.disable("delete"):this.actionDelete.enable("delete")},createStore:function(){var e=new Ext.data.ArrayStore({autoDestroy:!0,fields:["hostname"]});return this.addManagedComponent(e),e},addUrl:function(){var e=this.store.getCount(),t=new this.store.recordType;this.stopEditing(),this.store.insert(e,t),this.startEditing(e,0)},deleteUrl:function(){this.store.remove(this.getSelectionModel().getSelections())},readWhitelist:function(e){for(var t=[],i=0;i=this.grid.store.getCount()),this.close()},validateURL:function(e){var t=e.replace(/\s/g,"");return!(!Ext.isString(t)||Ext.isEmpty(t))&&(!(-1!==e.indexOf(",")||!t.match(/^((https?|wss?):\/\/)?(\*\.)?(-\.)?({HOSTNAME}|([^\s\/?\.#-*]+\.)+)[^\s\/?\.#-*]+(\/[^\s*#\?]+)*$/))||_T("smsnotify","invalid_url"))}}),Ext.define("SYNO.SDS.AdminCenter.Security.DSM.ProxyListDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module;var t=this.fillConfig(e);this.callParent([t]),this.setStatusBusy(),this.sendWebAPI({webapi:{api:"SYNO.Core.Security.DSM.Proxy",method:"get",version:1},scope:this,callback:function(e,t){this.clearStatusBusy(),e?(this.proxylist=t.proxylist.sort(),this.panel.store.loadData(this.proxylist.map(function(e){return[e]}))):this.panel.store.loadData([])}})},fillConfig:function(e){this.panel=new SYNO.SDS.AdminCenter.Security.DSM.ProxyListGrid(Ext.apply({dialog:this},e));var t={width:620,height:540,minWidth:620,minHeight:540,layout:"fit",title:_T("dsmsetting","trusted_proxies"),items:[this.panel],buttons:[{text:_T("common","cancel"),btnStyle:"grey",scope:this,handler:this.close},{text:_T("common","ok"),btnStyle:"blue",scope:this,handler:this.onOkClick}],listeners:{beforeclose:this.onBeforeClose.createDelegate(this)}};return Ext.apply(t,e),t},onOkClick:function(){var e=this.proxylist,t=this.panel.store.collect("cidr").sort();this.isProxyListChanged(e,t)?(this.setStatusBusy(),this.sendWebAPI({webapi:{api:"SYNO.Core.Security.DSM.Proxy",method:"set",version:1,params:{proxylist:t}},scope:this,callback:function(e,i){if(this.clearStatusBusy(),e)this.proxylist=t,SYNO.SDS.AdminCenter.Utils.WaitHttpdRestart(this.module.appWin)(),this.panel.store.commitChanges(),this.close();else if(void 0!==i.errors){var s=this.panel.store.findExact("cidr",i.errors[0]);this.setStatusError({text:_T("vtype","bad_cidr"),clear:!0}),this.panel.startEditing(s,0)}else this.setStatusError()}})):this.close()},onBeforeClose:function(){var e=this.proxylist,t=this.panel.store.collect("cidr").sort();if(this.isProxyListChanged(e,t))return this.confirmLostChangePromise({save:this.onOkClick,dontSave:function(){this.panel.store.loadData(this.proxylist.map(e=>[e])),this.close()},cancel:Ext.emptyFn},this),!1},isProxyListChanged:function(e,t){if(e.length!==t.length)return!0;for(var i=0;i=1||this._S("majorversion")>=6)&&e.push({xtype:"syno_checkbox",boxLabel:_T("dsmsetting","restart_clean_session"),name:"restart_clean_session"}),[{xtype:"syno_fieldset",title:_T("common","general"),collapsible:!1,items:e},{xtype:"syno_fieldset",title:_T("dsmsetting","trusted_proxies"),collapsible:!1,items:[{xtype:"syno_displayfield",name:"proxylist_desc",value:_T("dsmsetting","trusted_proxies_desc")},{xtype:"syno_button",text:_T("dsmsetting","trusted_proxies"),handler:this.showProxyListDialog.createDelegate(this)}]}]},showWhitelistDialog:function(){var e=new SYNO.SDS.AdminCenter.Security.DSM.WhitelistDialog({owner:this.module.appWin,module:this});this.addManagedComponent(e),e.show()},showProxyListDialog:function(){var e=new SYNO.SDS.AdminCenter.Security.DSM.ProxyListDialog({owner:this.module.appWin,module:this});this.addManagedComponent(e),e.show()},processParams:function(e,t){if("get"===e)return this.callParent(arguments);var i=Ext.applyIf({method:"set"},this.embedAPI);return Ext.each(t,function(e){SYNO.ux.Utils.checkApiConsistency(e,i)&&(this.getForm().findField("enable_block").isDirty()&&(this.ownerCt.restartHttpd=!0),e.params.whitelist=this.whitelist)},this),t},processReturnData:function(e,t,i){if(t&&Ext.isArray(t.result)){var s=Ext.applyIf({method:"get"},this.embedAPI);Ext.each(t.result,function(e){if(SYNO.ux.Utils.checkApiConsistency(e,s))return this.ownerCt.restartHttpd=!1,this.whitelist=e.data.whitelist.sort(),!1},this)}this.callParent(arguments)},isDirty:function(){return this.getForm().isDirty()}}),Ext.define("SYNO.SDS.AdminCenter.Security.DSM.OTPEnforceEditDialog",{extend:"SYNO.SDS.ModalWindow",DEFAULT_ROLES:[["local_user",_T("share","share_local_user")],["local_group",_T("share","share_local_group")]],DOMAIN_ROLES:[["domain_user",_T("share","share_domain_user")],["domain_group",_T("share","share_domain_group")]],LDAP_ROLES:[["ldap_user",_T("share","ldap_user")],["ldap_group",_T("share","ldap_group")]],pageSize:20,constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=e.appWin,this.grid=this.createPanel();var t={width:750,height:420,minWidth:750,minHeight:420,closeAction:"onCancel",layout:"fit",title:_T("otp_enforcement","specific_usrgrp_title"),buttons:[{text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{text:_T("common","save"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.grid]};Ext.apply(t,e),this.callParent([t])},createPanel:function(e){this.store=this.createStore();var t=new SYNO.ux.EnableColumn({enableFastSelectAll:!0,header:_T("otp_enforcement","enforce_otp"),tooltip:_T("otp_enforcement","enforce_otp"),dataIndex:"is_enforced",width:100,align:"center"}),i=function(e,t){var i=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(i)+'"',i},s={cm:new Ext.grid.ColumnModel([{id:"name",header:_T("user","user_account"),dataIndex:"name",renderer:i,width:80},{id:"desc",header:_T("user","user_fullname"),dataIndex:"desc",renderer:i,width:140},t]),ds:this.store,plugins:[t],autoExpandColumn:"name",enableColLock:!1,enableHdMenu:!1,cls:"without-dirty-red-grid",tbar:this.createTopToolbar(e),bbar:new SYNO.ux.PagingToolbar({store:this.store,pageSize:this.pageSize,displayInfo:!0}),listeners:{scope:this,afterrender:{fn:this.onAfterRender}}};return new SYNO.ux.GridPanel(s)},createStore:function(){return new SYNO.API.JsonStore({appWindow:this,autoDestroy:!0,api:"SYNO.Core.OTP.EnforcePolicy",method:"list",version:1,baseParams:{offset:0,limit:this.pageSize},fields:[{name:"id"},{name:"name"},{name:"desc"},{name:"is_enforced",type:"boolean"}],root:"data",idProperty:"name",remoteSort:!0,listeners:{scope:this,exception:{fn:this.onStoreException},beforeload:{fn:this.onBeforeLoad},load:{fn:this.onLoad}}})},onAfterRender:function(){this.getDomainLDAPInfo()},getDomainLDAPInfo:function(){var e=[{api:"SYNO.Core.Directory.LDAP",method:"get",version:1}];this.getKnownAPI("SYNO.Core.Directory.Domain")&&(e.push({api:"SYNO.Core.Directory.Domain",method:"get",version:1}),e.push({api:"SYNO.Core.Directory.Domain",method:"test_dc",version:1}),"yes"===this._D("supportdomain")&&e.push({api:"SYNO.Core.Directory.Domain",method:"get_domain_list",version:2})),this.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:e},callback:function(e,t){this.clearStatusBusy(),this.loadDomainLDAPInfo(t)},scope:this})},loadDomainLDAPInfo:function(e){var t,i,s,n,o;if(t=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.LDAP","get","enable_client"),i=2702===SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.LDAP","get","error"),s=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.Domain","get","enable_domain"),n=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.Domain","test_dc","test_join_success"),o=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.Domain","get_domain_list","domain_list"),this.roleFilter.getStore().loadData(this.DEFAULT_ROLES),t&&i&&this.roleFilter.getStore().loadData(this.LDAP_ROLES,!0),s&&n&&o&&0
    {domain}
    ',listeners:{scope:this,select:{fn:this.onDomainSelect}}}),this.nameFilter=new SYNO.ux.SearchField({iconStyle:"search",itemId:"search",emptyText:_T("share","share_filter_text"),width:180,store:this.store,pageSize:this.pageSize,menu:new SYNO.ux.Menu({cls:"syno-ux-check-menu",items:[{checked:!0,value:"all",text:_T("common","show_all")},{value:"enforced",text:_T("otp_enforcement","type_enforced")},{value:"unenforced",text:_T("otp_enforcement","type_unenforced")}],defaults:{group:"enforce_type",checked:!1},listeners:{scope:this,itemclick:this.onTypeFilterSelect}}),getMenu:function(){return this.menu}}),new SYNO.ux.Toolbar({items:[this.roleFilter,"->",this.domainListLabel,this.domainFilter,this.nameFilter]})},onRoleSelect:function(e,t){var i=t.data.role;this.prevRole=e.getValue(),this.store.baseParams.type=i,this.setDomainFilterVisible(0<=i.indexOf("domain")),this.store.load()},onDomainSelect:function(e,t){this.store.baseParams.domain=t.data.value,this.store.load()},onTypeFilterSelect:function(e){this.store.baseParams.enforce_type=e.value,this.store.load()},setDomainFilterVisible:function(e){this.domainListLabel.setVisible(e),this.domainFilter.setVisible(e)},onCancel:function(){var e=this;this.isDirty()?e.confirmLostChangePromise({cancel:Ext.emptyFn,save:function(){e.onApply()},dontSave:function(){e.close()}}):this.close()},getWebAPIParams:function(){var e=[];return this.store.getModifiedRecords().forEach(function(t){e.push({id:t.data.id,is_enforced:t.data.is_enforced})}),{api:"SYNO.Core.OTP.EnforcePolicy",method:"custom_set",version:1,params:{type:this.prevRole||this.roleFilter.getValue(),settings:e}}},confirmSave:function(e){this.setStatusBusy(),this.sendWebAPI(Ext.apply(this.getWebAPIParams(),{callback:function(t,i){this.clearStatusBusy(),t?(this.store.commitChanges(),this.store.load(e)):this.getMsgBox().alert(this.title,SYNO.API.Erros.core[i.code]||_T("common","commfail"))},scope:this}))},onApply:function(){this.isDirty()?(this.setStatusBusy(),this.sendWebAPI(Ext.apply(this.getWebAPIParams(),{callback:function(e,t){this.clearStatusBusy(),e?this.close():this.getMsgBox().alert(this.title,SYNO.API.Erros.core[t.code]||_T("common","commfail"))},scope:this}))):this.close()}}),Ext.define("SYNO.SDS.AdminCenter.Security.SigninPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t=this.fillConfig(e);SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.SecureSignIn.Instance")&&SYNO.SDS.JSLoader.JSLoadFn("SYNO.SDS.SecureSignIn.Instance"),this.callParent([t]),this.mon(this,"afterlayout",function(){this.createEnableGroup()},this,{single:!0})},fillConfig:function(e){this.owner=e.owner,this.module=e.module;var t={title:_T("secure_signin","authentication"),autoFlexcroll:!0,trackResetOnLoad:!0,items:this.getSigninItems(),listeners:{activate:this.onActivate,deactivate:this.onDeactivate}};return Ext.apply(t,e),t},onActivate:function(){if(!_S("is_admin"))return;let e=this.form.findField("enable_otp_enforcement");const t=e.getValue();if(this.mon(this.form.findField("enable_otp_enforcement"),"check",this.Enforce2faCheck,this),t&&!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.SecureSignIn.Instance"))return void this.confirmSecureSignInService(e);const i=this.form.findField("otp_enforce_option"),s=i.getGroupValue();t?i.ownerCt.getComponent("otp_enforce_custom_setting").setDisabled("custom"!==s):i.ownerCt.getComponent("otp_enforce_custom_setting").setDisabled(!0)},onDeactivate:function(){this.mun(this.form.findField("enable_otp_enforcement"),"check",this.Enforce2faCheck,this)},createEnableGroup:function(){_S("is_admin")&&new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_otp_enforcement",["otp_enforce_option"]),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),this.SBEnableID,["untrust_try","untrust_minute","untrust_lock","trust_try","trust_minute","trust_lock"])},getSigninItems:function(){return _S("is_admin")?[this.getOTPEnforceConfig(),this.getSmartBlockConfig()]:[this.getSmartBlockConfig()]},Enforce2faCheck:function(e,t){if(t){if(!this.enable_mail)return void this.confirmMailService(e);if(!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.SecureSignIn.Instance"))return void this.confirmSecureSignInService(e);this.form.setValues({otp_enforce_option:"admin"})}else e.ownerCt.getComponent("otp_enforce_custom_setting").setDisabled(!0)},getOTPEnforceConfig:function(){return{xtype:"syno_fieldset",title:_T("personal_settings","otp_settings"),collapsible:!0,webapi:{api:"SYNO.Core.OTP.EnforcePolicy",version:1,methods:{get:"get",set:"set"}},items:[{xtype:"syno_checkbox",name:"enable_otp_enforcement",boxLabel:_T("otp_enforcement","enforce_option_desc")},{xtype:"syno_radio",indent:1,boxLabel:_T("common","admin_group_user"),name:"otp_enforce_option",inputValue:"admin"},{xtype:"syno_radio",indent:1,boxLabel:_T("mount","everyone"),name:"otp_enforce_option",inputValue:"user"},{xtype:"syno_radio",indent:1,boxLabel:_T("otp_enforcement","specific_usrgrp"),name:"otp_enforce_option",inputValue:"custom",listeners:{scope:this,check:function(e,t){e.ownerCt.getComponent("otp_enforce_custom_setting").setDisabled(!t)}}},{xtype:"syno_button",indent:2,itemId:"otp_enforce_custom_setting",text:_T("common","common_settings"),disabled:!0,handler:function(){new SYNO.SDS.AdminCenter.Security.DSM.OTPEnforceEditDialog({owner:this.module.appWin,module:this.module,appWin:this.module.appWin}).open()},scope:this},{xtype:"syno_displayfield",htmlEncode:!1,value:String.format('{0}{1} ',_T("common","note"),_T("common","colon"))+String.format(_T("otp_enforcement","note_set_up_otp"),''+_T("common","user_setting")+"")}]}},getSmartBlockConfig:function(){return{xtype:"syno_fieldset",title:_T("tree","leaf_smartblock"),itemId:"fieldset_smartblock",cls:"smartblock_fieldset",webapi:{api:"SYNO.Core.SmartBlock",methods:{get:"get",set:"set"},version:1},collapsible:!0,collapsed:!0,labelWidth:300,items:[{xtype:"syno_displayfield",value:_T("smartblock","smartblock_desc")},{xtype:"syno_checkbox",name:"enabled",id:this.SBEnableID=Ext.id(),boxLabel:_T("smartblock","smartblock_enable"),disabled:!this._S("is_admin"),listeners:{check:{scope:this,fn:this.onSmartBlockEnable}}},{xtype:"syno_fieldset",header:!1,itemId:"fieldset_account_protection",collapsible:!1,items:[{xtype:"syno_displayfield",indent:1,cls:"fieldset_subtitle",value:_T("smartblock","fieldset_untrust_title")},{xtype:"syno_displayfield",indent:1,value:_T("smartblock","smartblock_untrust_rule_desc")},{xtype:"syno_numberfield",name:"untrust_try",fieldLabel:_T("smartblock","smartblock_try"),disabled:!this._S("is_admin"),vtype:"number",indent:1,minValue:1,maxlength:3},{xtype:"syno_numberfield",name:"untrust_minute",fieldLabel:_T("smartblock","smartblock_minute"),disabled:!this._S("is_admin"),vtype:"number",indent:1,minValue:1,maxlength:3},{xtype:"syno_displayfield",value:_T("smartblock","smartblock_untrust_lock_desc"),indent:1},{xtype:"syno_numberfield",name:"untrust_lock",fieldLabel:_T("smartblock","smartblock_untrust_lock_minute"),disabled:!this._S("is_admin"),vtype:"number",indent:1,maxlength:3},{xtype:"syno_button",text:_T("smartblock","smartblock_untrust_manage"),indent:1,handler:this.onSmartBlockUntrustManage,scope:this},{xtype:"syno_displayfield",indent:1,cls:"fieldset_subtitle",value:_T("smartblock","fieldset_trust_title")},{xtype:"syno_displayfield",indent:1,value:_T("smartblock","smartblock_trust_rule_desc")},{xtype:"syno_numberfield",name:"trust_try",fieldLabel:_T("smartblock","smartblock_try"),disabled:!this._S("is_admin"),vtype:"number",indent:1,minValue:1,maxlength:3},{xtype:"syno_numberfield",name:"trust_minute",fieldLabel:_T("smartblock","smartblock_minute"),disabled:!this._S("is_admin"),vtype:"number",indent:1,minValue:1,maxlength:3},{xtype:"syno_displayfield",value:_T("smartblock","smartblock_trust_lock_desc"),indent:1},{xtype:"syno_numberfield",name:"trust_lock",fieldLabel:_T("smartblock","smartblock_trust_lock_minute"),disabled:!this._S("is_admin"),vtype:"number",indent:1,maxlength:3},{xtype:"syno_button",text:_T("smartblock","smartblock_trust_manage"),indent:1,handler:this.onSmartBlockTrustManage,scope:this}]}]}},confirmMailService:function(e){this.module.appWin.getMsgBox().confirm(this.title,_T("otp_enforcement","enforce_mail_notification_service"),function(t){"yes"===t?(this.getForm().reset(),this.module.appWin.startModule("SYNO.SDS.AdminCenter.Notification.Main")):e&&e.setValue(!1)},this)},confirmSecureSignInService:function(e){this.module.appWin.getMsgBox().confirm(null,String.format(_T("secure_signin","abnormal_service_admin"),"",""),function(t){"yes"===t?(this.getForm().reset(),SYNO.SDS.AppLaunch("SYNO.SDS.PkgManApp.Instance",{action:"open",packages:["SecureSignIn"]})):e&&e.setValue(!1)},this)},checkOTPSetting:function(){if(!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.SecureSignIn.Instance"))return;if(!this.form.findField("enable_otp_enforcement").getValue())return;let e=!1,t=this.form.findField("enable_otp_enforcement").isDirty();this.form.findFields("otp_enforce_option").forEach(t=>{e|=t.isDirty()}),(e||t)&&this.getOTPSetting().then(e=>{e||this.module.appWin.getMsgBox().confirm("",_T("otp_enforcement","query_setting_otp_desc"),function(e){"yes"==e&&this.launchOTPWizard()},this,{yes:{text:_T("otp_enforcement","query_setting_otp_now")},no:{text:_T("otp_enforcement","query_setting_otp_later")}})}).catch(e=>{SYNO.Debug("Get OTP failed",e)})},getOTPSetting:function(){return synowebapi.promises.request({api:"SYNO.Core.OTP",version:2,method:"get_one"}).then(e=>e&&e.otp_set)},launchOTPWizard:function(){this.appWin.openVueWindow(SYNO.SDS.SecureSignIn.Register.TwoFactorWizard,{isOtp:!0})},processParams:function(e,t){return"get"===e?this.callParent(arguments):(Ext.each(t,function(e){"SYNO.Core.OTP.EnforcePolicy"===e.api&&"set"===e.method&&!1===e.params.enable_otp_enforcement&&(e.params.otp_enforce_option="none")},this),t)},processReturnData:function(e,t,i){"set"===e&&this.checkOTPSetting(),this.callParent(arguments);var s=Ext.get(this.set2fa_link);s&&this.mon(s,"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.App.PersonalSettings.Instance")},this),this.getMailSetting().then(()=>{var e;(e=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.OTP.EnforcePolicy","get"))&&this.otpDataHandler(e)}),this.processSmartBlockReturnData(t,i)},processSmartBlockReturnData:function(e,t){var i={api:"SYNO.Core.SmartBlock",method:"get",version:1};if(!1!==e.has_fail&&e.result instanceof Array)for(var s=0;s{e.has_fail||(this.enable_mail=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Notification.Mail.Conf","get","enable_mail"),this.current_user_mail=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.NormalUser","get","email"))})}}),Ext.define("SYNO.SDS.AdminCenter.Security.SmartBlock.UntrustManagePanel",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.module=e.module,this.owner=e.owner,this.parentDialog=e.parentDialog;var t=this.fillConfig(e);this.callParent([t]),this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this)},fillConfig:function(e){this.actionUnlock=new Ext.Action({text:_T("smartblock","action_untrusted_unlock"),scope:this,disabled:!0,handler:this.onUnlock}),this.store=new SYNO.API.JsonStore({api:"SYNO.Core.SmartBlock.Untrusted",method:"list",version:1,listeners:{scope:this,exception:this.onException},appWindow:this.owner,root:"users",idProperty:"uid",totalProperty:"total",id:"name",fields:[{name:"uid"},{name:"name",sortType:"asNaturalUCString"},{name:"time",type:"int"},{name:"ip",type:"string"},{name:"agent",type:"string"}],defaultSortable:!0});var t={ds:this.store,cm:new Ext.grid.ColumnModel({defaults:{sortable:!0},columns:[{header:_T("user","user_account"),headerHtmlEncode:!1,dataIndex:"name",renderer:function(e,t,i){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e},width:50},{header:_T("smartblock","untrusted_locked_time"),headerHtmlEncode:!1,dataIndex:"time",renderer:function(e,t,i){var s=SYNO.SDS.DateTimeFormatter(new Date(1e3*e),{type:"datetime"});return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(s)+'"',s},width:100},{header:_T("common","ip_addr"),headerHtmlEncode:!1,dataIndex:"ip",renderer:function(e,t,i){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e},width:70},{header:_T("smartblock","user_agent"),headerHtmlEncode:!1,dataIndex:"agent",renderer:function(e,t,i){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e},width:230}]}),loadMask:!0,autoExpandColumn:"name",enableDragDrop:!1,enableColumnMove:!1,enableHdMenu:!1,selModel:new Ext.grid.RowSelectionModel({singleSelect:!1}),tbar:[this.actionBtn=new SYNO.ux.Button(this.actionUnlock)],bbar:{xtype:"syno_paging",store:this.store,displayButtons:!0,displayInfo:!0,pageSize:SYNO.SDS.AdminCenter.USER_PAGING_SIZE}};return Ext.apply(t,e),t},afterRender:function(){this.callParent(arguments),this.mask(_T("common","loading")),this.store.load(),this.unmask()},onException:function(){this.owner.getMsgBox().alert(this.owner.title,_T("common","commfail")),this.store.loadData({},!1)},onUnlock:function(){var e=this.getSelectionModel().getSelections().map(function(e){return e.data.uid});e.length<=0||this.sendWebAPI({api:"SYNO.Core.SmartBlock.Untrusted",version:1,method:"pardon",params:{users:e},scope:this,callback:this.onWebapiDone})},onWebapiDone:function(e,t,i){e||this.getMsgBox().alert("",SYNO.API.getErrorString(t.code)),this.store.load()},onClose:function(){this.parentDialog.close()},onSelectionChange:function(e){00?(s=e.split("-")[0],n=e.split("-")[1],this.form.findField("self_port_choose").setValue("ports_range"),this.form.findField("self_ports_range_from").setValue(s),this.form.findField("self_ports_range_to").setValue(n)):(this.form.findField("self_port_choose").setValue("ports"),this.form.findField("self_ports_value").setValue(e)),"icmp"!=i&&"igmp"!=i||(t="destination"),this.form.findField("port_type").setValue(t),this.form.findField("protocol").setValue(i),this.onCheckCustomPort()}}),Ext.define("SYNO.SDS.AdminCenter.Security.FwSrcIpDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.panel=this.createPanel(),this.form=this.panel.getForm();var t={width:600,height:345,title:_T("firewall","firewall_source"),layout:"fit",items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","alt_apply"),itemId:"ruleApply",scope:this,handler:this.onApply}]};this.setDefault(),Ext.apply(t,e),this.callParent([t]),this.OnSourceRadioClick(this.form.findField("source"),!0)},createPanel:function(){var e={padding:"0",xtype:"syno_fieldset",title:_T("firewall","firewall_source"),itemId:"firewall_source",items:[{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_radio",name:"source",itemId:"nfs_fieldtitle_host",width:1.5*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH-6,boxLabel:_T("nfs","nfs_fieldtitle_host"),inputValue:"single",scope:this,checked:!0,handler:this.OnSourceRadioClick},{xtype:"syno_radio",name:"source",itemId:"firewall_source_network",width:1.5*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,boxLabel:_T("firewall","firewall_source_network"),inputValue:"subnet",scope:this,handler:this.OnSourceRadioClick}]},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.5*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("tcpip","tcpip_ipaddr"),name:"source_ip",itemId:"tcpip_ipaddr",vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)&&(this.nextSibling().validate(),!0)}},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.5*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("tcpip","tcpip_mask")+"/"+_T("tcpip","ipv6_prefixleng"),name:"source_subnet_mask",itemId:"tcpip_mask",maskRe:/[.0-9]/,invalidText:_JSLIBSTR("vtype","bad_mask"),allowBlank:!1,validator:function(e){var t=this.previousSibling().getValue();return Ext.form.VTypes.fwLoosev6ipVal.test(t)?e>=0&&e<=128||_JSLIBSTR("vtype","bad_ipv6prefixLeng"):!!Ext.form.VTypes.netmaskVal.test(e)}},{xtype:"syno_radio",boxLabel:_T("firewall","firewall_ip_range"),name:"source",width:1.5*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_LABEL_WIDTH,itemId:"firewall_source_range",inputValue:"range",scope:this,handler:this.OnSourceRadioClick},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.5*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("ftp","ftp_port_from"),name:"source_ip_begin",itemId:"tcpip_ipaddr_begin",vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)}},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.5*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("ftp","ftp_port_to"),name:"source_ip_end",itemId:"tcpip_ipaddr_end",vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)}}]};return new SYNO.ux.FormPanel(e)},onApply:function(){if(this.validateBlank(this.form))if(this.form.isValid()){var e=this.getSrc();this.setSource(e.source_ip,e.source_ip_group),this.owner.setSrc(e.source_ip,e.source_ip_group),this.close()}else this.setStatusError({text:_T("common","forminvalid"),clear:!0});else"range"===this.form.findField("source").getGroupValue()?this.getMsgBox().alert(_T("tree","leaf_firewall"),_T("firewall","firewall_error_ip_range")):this.getMsgBox().alert(_T("tree","leaf_firewall"),_T("common","forminvalid"))},getSrc:function(){var e,t=this.form.findField("source").getGroupValue();if("single"===t)e={source_ip:this.form.findField("source_ip").getValue(),source_ip_group:"ip"};else if("range"===t){e={source_ip:this.form.findField("source_ip_begin").getValue()+"-"+this.form.findField("source_ip_end").getValue(),source_ip_group:"iprange"}}else"subnet"===t&&(e={source_ip:String.format("{0}/{1}",this.form.findField("source_ip").getValue(),this.form.findField("source_subnet_mask").getValue()),source_ip_group:"netmask"});return e},onOpen:function(e,t){this.setStatusBusy(),this.setSource(e,t),this.clearStatusBusy(),this.callParent(arguments)},setDefault:function(){this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable()},setSource:function(e,t){var i="",s="",n="single",o="",a="",r="";"iprange"===t?(a=(o=e.split("-"))[0],r=o[1],n="range",this.form.findField("source_ip_begin").setValue(a),this.form.findField("source_ip_end").setValue(r)):"netmask"===t?(i=(o=e.split("/"))[0],s=o[1],n="subnet",this.form.findField("source_ip").setValue(i),this.form.findField("source_subnet_mask").setValue(s)):"ip"===t&&(this.form.findField("source_ip").setValue(e),n="single"),this.form.findField("source").setValue(n)},OnSourceRadioClick:function(e,t){if(e.checked)switch(e.value){case"single":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable();break;case"subnet":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").enable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable();break;case"range":this.form.findField("source_ip").disable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").enable(),this.form.findField("source_ip_end").enable();break;default:this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable()}},validateBlank:function(e){var t,i,s,n,o,a=!0,r=0,l=0,d="",c=e.findField("source").getGroupValue();if("single"==c)a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip"]);else if("subnet"==c)(a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip"]))&&(a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_subnet_mask"]));else if(SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip_begin"])&&SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip_end"]))if(i=e.findField("source_ip_begin").getValue().toString(),s=e.findField("source_ip_end").getValue().toString(),0parseInt(n[r],10)){a=!0;break}if(parseInt(o[r],10)parseInt(n[r],16)){a=!0;break}if(parseInt(o[r],16)",new SYNO.ux.TextFilter({iconStyle:"search",itemId:"search",localFilter:!0,localFilterField:"country_search_name",store:this.store,queryParam:"filter",pageSize:SYNO.SDS.AdminCenter.USER_PAGING_SIZE})]}},e);this.callParent([i])},contryShow:function(e,t){return e=_T("Country",e),t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e},getSrc:function(){var e=[];return this.getStore().query("enabled",!0).each(function(t){e.push(t.get("country_code"))}),e.join(",")},setVal:function(e){""===e?this.enabledCountries.length=0:this.enabledCountries=e.split(","),this.getStore().load()},onEnableCountries:function(e){for(var t,i=this.getStore(),s=i.getCount(),n=0;n=i))for(t=0;t','
    ','
    ','
    ','
    ',_T("common","no_item"),"
    ","
    ","
    ",""].join("")},cls:"syno-firewall-gridpanel",plugins:[this.enableColumn],columns:[this.enableColumn,{id:"fw_ports",header:_T("firewall","firewall_ports"),dataIndex:"ports",width:150,tooltip:_T("firewall","firewall_ports"),renderer:SYNO.SDS.AdminCenter.Security.Utils.Render_Ports},{header:_T("firewall","firewall_protocol"),dataIndex:"protocol",width:100,tooltip:_T("firewall","firewall_protocol"),renderer:SYNO.SDS.AdminCenter.Utils.Render.Render_Protocol},{header:_T("firewall","firewall_source"),dataIndex:"source_ip",width:150,tooltip:_T("firewall","firewall_source"),renderer:SYNO.SDS.AdminCenter.Security.Utils.Render_Source},{header:_T("firewall","firewall_allow"),dataIndex:"policy",width:80,tooltip:_T("firewall","firewall_allow"),renderer:SYNO.SDS.AdminCenter.Security.Utils.Render_Allow}],enableDragDrop:!0,enableColumnMove:!1,enableHdMenu:!1,autoExpandColumn:"fw_ports",monitorWindowResize:!0,selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:{fn:this.updateButtonStatus,buffer:50,scope:this}}}),listeners:{rowdblclick:function(){1===this.getSelectionModel().getCount()&&this.openRuleDialog("edit")},rowcontextmenu:this.onRowContextMenu,containercontextmenu:this.onContainerContextMenu,scope:this},store:this.profileData.adapterRuleStore},e);this.callParent([t])},onContainerContextMenu:function(e,t){e.getSelectionModel().hasSelection()&&this.showContextMenu(t)},onRowContextMenu:function(e,t,i){var s=e.getSelectionModel();s.suspendEvents(!1),s.selectRow(t,s.isSelected(t)),this.updateButtonStatus(),s.resumeEvents(),this.showContextMenu(i)},showContextMenu:function(e){var t=[],i=this.getSelectionModel().getCount();1===i&&t.push({text:_T("common","alt_edit"),scope:this,handler:function(e,t){this.openRuleDialog("edit")}},{text:_T("common","up"),scope:this,handler:function(){this.onMoveRow(!0)}},{text:_T("common","down"),scope:this,handler:function(){this.onMoveRow(!1)}}),1<=i&&t.push({text:_T("common","delete"),scope:this,handler:function(){var e=this.getSelectionModel(),t=e.getSelections(),i=this.profileData.adapterRuleStore,s=0;for(s=0;s=i.getCount()?this.getView().focusEl.focus():(e.selectFirstRow(),this.getView().focusRow(0))}});var s=new SYNO.ux.Menu({autoDestroy:!0,items:t});s.showAt(e.getXY()),e.preventDefault(),this.addManagedComponent(s)},initEvents:function(){this.callParent(arguments),this.mon(this.owner,"show",this.onShow,this),this.mon(this.profileData.adapterRuleStore,"load",this.updateGridView,this),this.mon(this.profileData.adapterRuleStore,"add",this.onUpdateRuleStore,this),this.mon(this.profileData.adapterRuleStore,"remove",this.onUpdateRuleStore,this),this.mon(this,"afterDrop",this.onUpdateRuleStore,this)},onMoveRow:function(e){var t=this.profileData.adapterRuleStore,i=this.getSelectionModel().getSelected(),s=t.indexOf(i),n=s+(e?-1:1);n<0||n>t.getCount()-1?this.getView().focusRow(s):(t.remove(i),t.insert(n,i),this.getSelectionModel().selectRecords([i]),this.getView().focusRow(n))},newTopToolBar:function(){return new Ext.Toolbar({defaultType:"syno_button",items:[{text:_T("common","create"),itemId:"create",tooltip:_T("common","create"),scope:this,handler:function(e,t){this.openRuleDialog("add")}},{text:_T("common","alt_edit"),itemId:"edit",tooltip:_T("common","alt_edit"),disabled:!0,scope:this,handler:function(e,t){1===this.getSelectionModel().getCount()&&this.openRuleDialog("edit")}},{text:_T("common","delete"),itemId:"delete",tooltip:_T("common","delete"),disabled:!0,scope:this,handler:function(){var e=this.getSelectionModel().getSelections(),t=0;for(t=0;t",{xtype:"syno_combobox",id:this.adapterComboID=Ext.id(),displayField:"display",valueField:"id",value:"global",store:this.adapterNameStore,listeners:{select:this.onAdapterSelect,scope:this}}]})},setTabNavigation:function(e){var t=!0===e?0:-1,i=this.getTopToolbar(),s=this.getBottomToolbar().getComponent("adapterBbar");i.getComponent("create").btnEl.set({tabIndex:t}),i.getComponent("edit").btnEl.set({tabIndex:t}),i.getComponent("edit").arrowBtnEl.set({tabIndex:t}),i.getComponent("setting").btnEl.set({tabIndex:t}),i.getComponent(this.profileComboID).getEl().set({tabIndex:t}),i.getComponent(this.adapterComboID).getEl().set({tabIndex:t}),s.getComponent("globalAdapterBbar").getEl().set({tabIndex:t}),s.getComponent("generalAdapterBbar").items.each(function(e){e.getEl().set({tabIndex:t})})},updateButtonStatus:function(){var e=this.getSelectionModel().getCount();this.setButton("edit",1===e),this.setButton("delete",1<=e)},setButton:function(e,t){var i=this.getTopToolbar().getComponent(e);i&&i[t?"enable":"disable"]()},openRuleDialog:function(e){new SYNO.SDS.AdminCenter.Security.FwRuleDialog({owner:this.owner,module:this.module,portInfo:this.profileData.adapterRuleStore.servicePortInfo,gridRules:this,mode:e}).open()},onUpdateRuleStore:function(){this.profileData.setDirty(),this.updateButtonStatus(),this.updateGridView()},updateComboSelectValue:function(){Ext.getCmp(this.adapterComboID).setValue(this.selectedAdapter)},updateGridView:function(){var e=this.getView().el.query(".contentwrapper")[0];0===this.profileData.adapterRuleStore.getCount()?e.style.height="100%":(e.style.height="",this.getView().refresh())},onAdapterSelect:function(e,t,i){var s=t.get("id");if(s!==this.selectedAdapter){this.profileData.storeToData(this.selectedAdapter),this.profileData.setAdapterPolicy(this.selectedAdapter,this.getBbarPolicy()),this.selectedAdapter=s,this.profileData.dataToStore(s);var n=this.profileData.getAdapterPolicy(s);this.setBbarPolicy(n),this.updateBbarLayout(),this.updateButtonStatus()}},newBottomToolBar:function(){var e=new SYNO.SDS.AdminCenter.Security.FwRuleGridPageLessToolBar({store:this.profileData.adapterRuleStore,showRefreshBtn:!1}),t=new Ext.Panel({itemId:"adapterBbar",cls:"syno-footer",bwrapCfg:{border:!1},items:[{xtype:"syno_compositefield",itemId:"globalAdapterBbar",items:[{xtype:"syno_displayfield",cls:"syno-note-label",value:_T("common","note")+_T("common","colon")},{xtype:"syno_displayfield",value:_T("firewall","firewall_global_no_match_desc")}]},{xtype:"syno_compositefield",itemId:"generalAdapterBbar",hidden:!0,items:[{xtype:"syno_displayfield",value:_T("firewall","firewall_policy_remind")+_T("common","colon")},{xtype:"syno_radio",boxLabel:_T("firewall","firewall_no_match_allow"),name:"policy",id:this.adapterPolicyAllowRadioID=Ext.id(),inputValue:"allow",listeners:{check:{scope:this,fn:this.onPolicyRadioCheck}}},{xtype:"syno_radio",boxLabel:_T("firewall","firewall_no_match_drop"),id:this.adapterPolicyDropRadioID=Ext.id(),name:"policy",inputValue:"drop",listeners:{check:{scope:this,fn:this.onPolicyRadioCheck}}}]},{xtype:"syno_compositefield",items:[{xtype:"syno_displayfield",cls:"syno-note-label",value:_T("common","note")+_T("common","colon")},{xtype:"syno_displayfield",value:_T("firewall","firewall_drag_drop_hint")}]}]});return new Ext.Container({items:[e,t]})},setBbarPolicy:function(e){var t=this.getBottomToolbar().getComponent("adapterBbar");switch(e){case"allow":t.getComponent("generalAdapterBbar").setValue(!0),Ext.getCmp(this.adapterPolicyAllowRadioID).setValue(e);break;case"drop":t.getComponent("generalAdapterBbar").setValue(!0),Ext.getCmp(this.adapterPolicyDropRadioID).setValue(e);break;case"none":t.getComponent("generalAdapterBbar").setValue(!1)}},getBbarPolicy:function(){return this.getBottomToolbar().getComponent("adapterBbar").getComponent("generalAdapterBbar").getValue()?Ext.getCmp(this.adapterPolicyAllowRadioID).getValue()?"allow":Ext.getCmp(this.adapterPolicyDropRadioID).getValue()?"drop":void 0:"none"},updateBbarLayout:function(){var e=this.getBottomToolbar().getComponent("adapterBbar");"global"===Ext.getCmp(this.adapterComboID).getValue()?(e.getComponent("globalAdapterBbar").show(),e.getComponent("generalAdapterBbar").hide()):(e.getComponent("globalAdapterBbar").hide(),e.getComponent("generalAdapterBbar").show()),e.doLayout()},onPolicyRadioCheck:function(e,t){t&&this.profileData.setAdapterPolicy(this.selectedAdapter,e.inputValue)},onShow:function(){this.loadFwData()},loadFwData:function(){this.owner.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!0,params:[{api:"SYNO.Core.Network.Interface",version:1,method:"list"},{api:"SYNO.Core.Service.PortInfo",method:"load",version:1}]},scope:this,callback:function(e,t,i,s){e?(Ext.each(t.result,function(e,t,i){if(e.success)if("SYNO.Core.Network.Interface"===e.api){var s=[];s.push(["global",_T("firewall","firewall_global_interface")]),Ext.each(e.data,function(e){if(!0!==_S("ha_not_support_pppoe")||"pppoe"!==e.ifname){var t={};t.id=e.ifname,t.display=SYNO.SDS.Utils.Network.idToString.apply(this.module.appWin,[e.ifname,e.type]),s.push([t.id,t.display])}},this),s.push(["vpn","VPN"]),this.adapterNameStore.loadData(s),Ext.getCmp(this.adapterComboID).setValue("global"),this.updateBbarLayout()}else"SYNO.Core.Service.PortInfo"===e.api&&SYNO.SDS.AdminCenter.Utils.Render.ServerPortsParsing(e.data,this.profileData.adapterRuleStore.servicePortInfo,!1)},this),this.profileData.loadData(this.fwOrigProfileName,this.selectedAdapter),this.owner.clearStatusBusy()):this.getMsgBox().alert("",_T("common","commfail"))}})},getRules:function(){return this.profileData.storeToData(this.selectedAdapter),this.profileData.setAdapterPolicy(this.selectedAdapter,this.getBbarPolicy()),this.profileData.getData()},isDirty:function(){return this.profileData.isDirty()},clearDirty:function(){this.profileData.clearDirty()},resetForm:function(){this.profileData.resetForm()}}),Ext.define("SYNO.SDS.AdminCenter.Security.FwRuleGridPageLessToolBar",{extend:"SYNO.ux.PageLessToolbar",constructor:function(){this.callParent(arguments)},bindStore:function(e,t){!t&&this.store&&(this.store.un("add",this.onDataChanged,this),this.store.un("remove",this.onDataChanged,this)),e&&(e=Ext.StoreMgr.lookup(e)).on({scope:this,add:this.onDataChanged,remove:this.onDataChanged}),this.callParent(arguments)},updateInfo:function(){Ext.isEmpty(this.displayItem)||this.displayItem.setText(`${this.store.getCount()} ${_JSLIBSTR("uicommon","items")}`)}}),Ext.define("SYNO.SDS.AdminCenter.Security.FwProfileCombobox",{extend:"SYNO.ux.ComboBox",constructor:function(e){this.callParent([this.fillConfig(e)]),this.mon(this,"select",this.setOwnerValue,this)},fillConfig:function(e){return Ext.apply({mode:"local",listClass:"syno-firewall-profile-combobox syno-ux-combobox-list",htmlEncode:!0,valueField:"profileName",displayField:"profileNameDisplay",store:new SYNO.API.JsonStore({api:"SYNO.Core.Security.Firewall.Profile",version:1,method:"list",autoLoad:!0,remoteSort:!1,appWindow:e.owner.findAppWindow(),root:"profile_names",fields:[{name:"profileName",convert:function(e,t){return t}},{name:"profileNameDisplay",convert:function(e,t){return t}}],sortInfo:{field:"profileNameDisplay",direction:"ASC"}})},e)},setOwnerValue:function(e,t){this.owner.selectedProfile=t.get("profileName")},openDialog:function(){new SYNO.SDS.AdminCenter.Security.FwProfileDialog({owner:this.owner.findAppWindow(),store:this.store,module:this.module,fwFormPanel:this.owner}).open()},initList:function(){this.callParent(arguments),this.view.getTemplateTarget().dom.style.padding="0 0 8px 0",this.createFooter()},createFooter:function(){this.footer=this.list.createChild({cls:"x-combo-list-ft"}),this.customTb=new SYNO.ux.Toolbar({cls:"syno-network-firewall-profile-footer",renderTo:this.footer,layout:"column",items:[this.text=new Ext.Toolbar.TextItem({html:_T("firewall","manage_firewall_profile"),cls:"x-combo-list-item",columnWidth:1,listeners:{scope:this,render:function(e){e.getEl().on("mouseover",function(){e.addClass("x-combo-selected"),this.view.clearSelections()},this),e.getEl().on("mouseout",function(){e.removeClass("x-combo-selected")},this),e.getEl().on("click",function(){this.openDialog(),this.collapse()},this)}}})]}),this.assetHeight+=this.customTb.getHeight(),this.restrictHeight()}}),Ext.define("SYNO.SDS.AdminCenter.Security.FwProfileDialog",{extend:"SYNO.SDS.ModalWindow",title:_T("firewall","manage_firewall_profile"),constructor:function(e){this.callParent([this.fillConfig(e)]),this.mon(this,"afterlayout",this.updateToolbar,this,{single:!0})},fillConfig:function(e){return Ext.apply({layout:"fit",width:500,height:500,buttons:[{btnStyle:"grey",text:_T("common","close"),scope:this,handler:function(){""===this.fwFormPanel.selectedProfile&&(this.fwFormPanel.selectedProfile=this.fwFormPanel.activeProfile,this.fwFormPanel.profileCombo.setValue(this.fwFormPanel.activeProfile)),this.close()}.createDelegate(this)}],items:[this.gridPanel=new SYNO.ux.GridPanel({region:"center",enableHdMenu:!1,enableColumnMove:!1,store:e.store,colModel:new Ext.grid.ColumnModel({columns:[{sortable:!0,header:_T("firewall","firewall_profile"),dataIndex:"profileNameDisplay",renderer:function(e,t,i){return i.get("profileName")===this.fwFormPanel.activeProfile&&(e+=" ("+_T("firewall","firewall_active_profile_note")+")"),e}.createDelegate(this)}]}),listeners:{scope:this,viewready:function(e){var t=e.store.find("profileName",this.fwFormPanel.selectedProfile);e.getSelectionModel().selectRow(t),this.updateToolbar()},rowClick:function(e,t,i){i&&-1i?this.setStatusError({text:_T("common","forminvalid"),clear:!0}):(this.setStatusBusy({text:_T("common","msg_waiting")}),t.push(n.source_ip),this.sendWebAPICreate({type:this.launcher,block_days:i,overwrite:!0,ip:t}))}else this.setStatusError({text:_T("common","forminvalid"),clear:!0})},sendWebAPICreate:function(e){this.getEl().mask(_T("common","saving")),this.sendWebAPI({api:"SYNO.Core.Security.AutoBlock.Rules",method:"create",version:1,params:e,scope:this,callback:this.onCreateDone})},onCreateDone:function(e,t,i){this.getEl().isMasked()&&this.getEl().unmask(),this.clearStatusBusy(),e||this.getMsgBox().alert(_T("autoblock","create_ip"),_T("error","error_unknown")),this.close()},onRemoteValidateComplete:function(e,t,i){var s,n=i.ip,o=this.panel.getForm();e?o&&(s=o.findField("source_ip"))&&n===s.getValue()&&("deny"===t.type?this.setStatusError({text:String.format(_T("autoblock","ip_in_blockedlist"),n),clear:!1}):"allow"===t.type?this.setStatusError({text:String.format(_T("autoblock","ip_in_allowlist"),n),clear:!1}):this.setStatusOK({text:String.format(_T("autoblock","ip_is_validated"),n),clear:!1}),this.getFooterToolbar().get("apply").enable()):this.getMsgBox().alert(_T("autoblock","create_ip"),_T("common","commfail"),this.close,this)}}),Ext.define("SYNO.SDS.AdminCenter.Security.AutoBlock.UploadFileDialog",{extend:"SYNO.SDS.ModalWindow",store:null,btnUpload:null,constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.btnUpload=this.getFooterToolbar().getComponent("apply"),new SYNO.ux.Utils.EnableRadioGroup(this.panel.getForm(),"expire_time",{forever:[],by_days:["expire_day"]})},fillConfig:function(e){var t;return this.owner=e.owner,this.appWin=e.appWin,this.ruleWin=e.ruleWin,this.panel=this.createPanel(e),t={title:_T("autoblock","import_ip"),width:650,height:"deny"===e.launcher?577:483,resizable:!1,layout:"fit",items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","alt_apply"),itemId:"apply",scope:this,disabled:!0,handler:this.onSubmit}]},Ext.apply(t,e),t},createPanel:function(e){var t,i=this;return this.grid=this.createPreviewGrid(e),this.grid.setAutoScroll(!0),this.fileField=new SYNO.ux.FileButton({scope:this,name:"upload_file",hiddenName:"upload_file",fieldLabel:_T("user","user_file"),value:"",listeners:{change:{fn:this.onImportFilePathChanged,scope:this}}}),t={border:!1,padding:0,fileUpload:!0,webapi:{api:"SYNO.Core.Security.AutoBlock.Rules",method:"allow"===e.launcher?"upload":"upload_deny_list",version:1},items:[{xtype:"syno_displayfield",hidden:"allow"===e.launcher,value:_T("autoblock","autoblock_expire_time")},{xtype:"syno_radio",indent:1,hidden:"allow"===e.launcher,name:"expire_time",inputValue:"forever",boxLabel:_T("autoblock","forever"),checked:!0},{xtype:"syno_compositefield",hideLabel:!0,hidden:"allow"===e.launcher,indent:1,items:[{xtype:"syno_radio",name:"expire_time",inputValue:"by_days",boxLabel:_T("autoblock","autoblock_expired_day")},{xtype:"box",width:10},{xtype:"syno_numberfield",name:"expire_day",vtype:"number",minValue:1,maxlength:3,disabled:!0}]},{xtype:"syno_checkbox",name:"overwrite",value:!1,boxLabel:_T("autoblock","check_overwrite")},i.fileField,i.grid],onApiSuccess:function(e,t,s){i.clearStatusBusy(),i.store.loadData(t)},onApiFailure:function(e,t,s){var n=t.errors,o=_T("error","error_invalid");switch(i.clearStatusBusy(),i.store.removeAll(),i.btnUpload.disable(),t.code){case 116:o=_T("common","error_demo");break;case 5103:o=Ext.isDefined(n)&&Ext.isDefined(n.err_line)?String.format(_T("autoblock","upload_format_failed"),n.err_line):_T("error","error_invalid");break;case 5105:o=_T("user","user_file_open_fail");break;default:o=_T("error","error_invalid")}i.getMsgBox().alert(_T("user","user_upload"),o)}},new SYNO.SDS.Utils.FormPanel(t)},createPreviewGrid:function(e){return this.store=new SYNO.API.JsonStore({root:"ip_info",totalProperty:"total",fields:[{name:"ip",mapping:"ip"}],listeners:{load:{scope:this,fn:this.onLoad}}}),new SYNO.ux.GridPanel({store:this.store,padding:0,columns:[{header:"deny"===e.launcher?_T("autoblock","autoblock_ip"):_T("autoblock","autoblock_allow_ip"),dataIndex:"ip",menuDisabled:!0}],height:270,enableHdMenu:!1,bodyStyle:"padding-top: 2px;",view:new SYNO.ux.FleXcroll.grid.BufferView({borderHeight:1,cacheSize:100,scrollDelay:!1,forceFit:!0})})},onLoad:function(){0i?this.setStatusError({text:_T("common","forminvalid"),clear:!0}):(this.setStatusBusy({text:_T("common","msg_waiting")}),this.store.each(function(e){t.push(e.data.ip)}),0>t.length?this.close():this.sendWebAPICreate({type:this.launcher,block_days:i,overwrite:s.findField("overwrite").getValue(),ip:t}))}else this.setStatusError({text:_T("common","forminvalid"),clear:!0})},sendWebAPICreate:function(e){this.getEl().mask(_T("common","saving")),this.sendWebAPI({api:"SYNO.Core.Security.AutoBlock.Rules",method:"create",version:1,params:e,scope:this,callback:this.onCreateDone})},onCreateDone:function(e,t,i){this.getEl().isMasked()&&this.getEl().unmask(),this.clearStatusBusy(),e||this.getMsgBox().alert(_T("user","user_upload"),_T("common","commfail")),this.close()}}),Ext.define("SYNO.SDS.AdminCenter.Security.AutoBlock.AddWhiteListDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=e.appWin,this.ruleWin=e.ruleWin,this.panel=this.createPanel(),this.form=this.panel.getForm();var t={width:580,height:360,title:_T("autoblock","create_ip"),layout:"fit",items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","save"),itemId:"ruleApply",scope:this,handler:this.onApply}]};this.setDefault(),Ext.apply(t,e),this.callParent([t]),this.OnSourceRadioClick(this.form.findField("source"),!0)},createPanel:function(){var e={xtype:"syno_fieldset",title:_T("autoblock","create_ip"),itemId:"whitelist_source",padding:0,items:[{xtype:"syno_compositefield",hideLabel:!0,defaults:{flex:1},items:[{xtype:"syno_radio",name:"source",itemId:"whitelist_singlehost",boxLabel:_T("nfs","nfs_fieldtitle_host"),inputValue:"single",scope:this,checked:!0,handler:this.OnSourceRadioClick},{xtype:"syno_radio",margins:"0 0 0 26px",name:"source",itemId:"whitelist_subnet",boxLabel:_T("firewall","firewall_source_network"),inputValue:"subnet",scope:this,handler:this.OnSourceRadioClick}]},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("tcpip","tcpip_ipaddr")+"/"+_T("dhcp_server","domain_name"),name:"source_ip",itemId:"whitelist_ip",indent:1,validator:function(e){return!(!Ext.form.VTypes.fwLooseip(e)&&!Ext.form.VTypes.hostname(e))&&(this.nextSibling().validate(),!0)}},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("tcpip","tcpip_mask")+"/"+_T("tcpip","ipv6_prefixleng"),name:"source_subnet_mask",itemId:"whitelist_mask",indent:1,maskRe:/[.0-9]/,invalidText:_JSLIBSTR("vtype","bad_mask"),allowBlank:!1,validator:function(e){var t=this.previousSibling().getValue();return Ext.form.VTypes.fwLoosev6ipVal.test(t)?e>=0&&e<=128||_JSLIBSTR("vtype","bad_ipv6prefixLeng"):!!Ext.form.VTypes.netmaskVal.test(e)||e>=0&&e<=32}},{xtype:"syno_displayfield",height:12},{xtype:"syno_radio",boxLabel:_T("firewall","firewall_ip_range"),name:"source",width:2*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_LABEL_WIDTH,itemId:"whitelist_source_range",inputValue:"range",scope:this,handler:this.OnSourceRadioClick},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("ftp","ftp_port_from"),name:"source_ip_begin",itemId:"whitelist_ip_begin",indent:1,vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)}},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("ftp","ftp_port_to"),name:"source_ip_end",itemId:"whitelist_ip_end",indent:1,vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)}}]};return new SYNO.ux.FormPanel(e)},onApply:function(){if(this.validateBlank(this.form))if(this.form.isValid()){var e={type:"allow",block_days:0,overwrite:!0,ip:[this.getSrc().source_ip]};this.setStatusBusy({text:_T("common","msg_waiting")}),this.sendWebAPI({api:"SYNO.Core.Security.AutoBlock.Rules",method:"create",version:1,params:e,scope:this,callback:function(e,t,i){this.clearStatusBusy(),e||this.getMsgBox().alert(_T("autoblock","create_ip"),_T("error","error_unknown")),this.close()}})}else this.setStatusError({text:_T("common","forminvalid"),clear:!0});else"range"===this.form.findField("source").getGroupValue()?this.getMsgBox().alert(_T("tree","leaf_firewall"),_T("firewall","firewall_error_ip_range")):this.getMsgBox().alert(_T("tree","leaf_firewall"),_T("common","forminvalid"))},getSrc:function(){var e,t=this.form.findField("source").getGroupValue();if("single"===t)e={source_ip:this.form.findField("source_ip").getValue(),source_ip_group:"ip"};else if("range"===t){e={source_ip:this.form.findField("source_ip_begin").getValue()+"~"+this.form.findField("source_ip_end").getValue(),source_ip_group:"iprange"}}else"subnet"===t&&(e={source_ip:String.format("{0}/{1}",this.form.findField("source_ip").getValue(),this.form.findField("source_subnet_mask").getValue()),source_ip_group:"netmask"});return e},setDefault:function(){this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable()},setSource:function(e,t){var i="",s="",n="single",o="",a="",r="";"iprange"===t?(a=(o=e.split("~"))[0],r=o[1],n="range",this.form.findField("source_ip_begin").setValue(a),this.form.findField("source_ip_end").setValue(r)):"netmask"===t?(i=(o=e.split("/"))[0],s=o[1],n="subnet",this.form.findField("source_ip").setValue(i),this.form.findField("source_subnet_mask").setValue(s)):"ip"===t&&(this.form.findField("source_ip").setValue(e),n="single"),this.form.findField("source").setValue(n)},OnSourceRadioClick:function(e,t){if(e.checked)switch(e.value){case"single":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable();break;case"subnet":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").enable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable();break;case"range":this.form.findField("source_ip").disable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").enable(),this.form.findField("source_ip_end").enable();break;default:this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable()}},validateBlank:function(e){var t,i,s,n,o,a=!0,r=0,l=0,d="",c=e.findField("source").getGroupValue();if("single"==c)a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip"]);else if("subnet"==c)(a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip"]))&&(a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_subnet_mask"]));else if(SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip_begin"])&&SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip_end"]))if(i=e.findField("source_ip_begin").getValue().toString(),s=e.findField("source_ip_end").getValue().toString(),0parseInt(n[r],10)){a=!0;break}if(parseInt(o[r],10)parseInt(n[r],16)){a=!0;break}if(parseInt(o[r],16)0})},fillAutoBlockConfig:function(){return this.viewRule=new SYNO.ux.Button({xtype:"syno_button",text:_T("autoblock","autoblock_view_rules"),scope:this,handler:this.showAutoBlockRuleWindow}),{xtype:"syno_fieldset",title:_T("tree","leaf_autoblock"),itemId:"fieldset_autoblock",webapi:{api:"SYNO.Core.Security.AutoBlock",methods:{get:"get",set:"set"},version:1},collapsible:!0,items:[{xtype:"syno_displayfield",value:_T("autoblock","autoblock_desc")},{xtype:"syno_checkbox",name:"enable",disabled:!this._S("is_admin"),boxLabel:_T("autoblock","autoblock_enable"),listeners:{check:{scope:this,fn:this.onAutoBlockEnable}}},{xtype:"syno_displayfield",indent:1,name:"autoblock_rule_desc",value:_T("autoblock","autoblock_rule_desc")},{xtype:"syno_numberfield",name:"attempts",fieldLabel:_T("autoblock","autoblock_attempts"),disabled:!this._S("is_admin"),vtype:"number",cls:"syno-ux-numberfield",indent:1,minValue:1,maxlength:4},{xtype:"syno_numberfield",name:"within_mins",fieldLabel:_T("autoblock","autoblock_within_mins"),disabled:!this._S("is_admin"),cls:"syno-ux-numberfield",vtype:"number",indent:1,minValue:1,maxlength:7},{xtype:"syno_checkbox",name:"enable_expire",boxLabel:_T("autoblock","autoblock_expired_enable"),disabled:!this._S("is_admin"),indent:1,listeners:{check:{scope:this,fn:this.onAutoBlockEnableExpreDay}}},{xtype:"syno_displayfield",value:_T("autoblock","autoblock_expired_desc"),name:"autoblock_expired_desc",indent:1},{xtype:"syno_numberfield",name:"expire_day",fieldLabel:_T("autoblock","autoblock_expired_day"),disabled:!this._S("is_admin"),cls:"syno-ux-numberfield",vtype:"number",indent:1,maxlength:3},{xtype:"syno_displayfield",height:10},{xtype:"syno_displayfield",value:_T("autoblock","autoblock_rules_desc")},this.viewRule]}},onAutoBlockEnable:function(e,t){this.updateAutoBlockDescField(t?0:-1)},onAutoBlockEnableExpreDay:function(e,t){this.updateAutoBlockExpiredDescField(t?0:-1)},updateAutoBlockExpiredDescField:function(e){this.form.findField("autoblock_expired_desc").el.dom.tabIndex=e},updateAutoBlockDescField:function(e){var t=this.form.findField("autoblock_rule_desc");0===e?this.viewRule.enable():this.viewRule.disable(),t.el.dom.tabIndex=e,-1===e&&this.updateAutoBlockExpiredDescField(-1)},showAutoBlockRuleWindow:function(e,t){new SYNO.SDS.AdminCenter.Security.AutoBlock.RuleWindow({appWin:this.module.appWin,owner:this.appWin}).show()},fillDosConfig:function(){return this.mapping_dos_protect_enable={},this.mapping_dos_protect_enable_origin={},{xtype:"syno_fieldset",title:_T("tree","leaf_dos"),itemId:"fieldset_dos",collapsible:!0,collapsed:!0,labelWidth:300,items:[{xtype:"syno_combobox",fieldLabel:_T("network","interface"),id:this.IFComboId=Ext.id(),displayField:"display",valueField:"id",labelStyle:"width:180px",isDirty:function(){return!1},store:this.IFStore=this.owner.IFStore,listeners:{select:this.onIFSelect,scope:this}},{xtype:"syno_displayfield",value:_T("firewall","firewall_dos_protect_enable_desc")},{xtype:"syno_checkbox",name:"dos_protect_enable",isDirty:function(){return!1},boxLabel:_T("firewall","firewall_dos_protect_enable"),listeners:{check:this.onDosCheck,scope:this}},{xtype:"syno_displayfield",hidden:!0,value:" "},{xtype:"syno_textfield",hidden:!0,name:"check_form_dirty",isDirty:this.isMappingRelationDirty.createDelegate(this),webapi:{api:"SYNO.Core.Security.DoS",methods:{get:"get",set:"set"},version:2}}]}},initEvents:function(){this.callParent(arguments),this._S("is_admin")&&"yes"===this._D("support_fw_security")&&this.initDosEvent()},initDosEvent:function(){this.mon(this.IFStore,"load",this.onIFAfterLoad,this)},onIFAfterLoad:function(e,t,i){Ext.getCmp(this.IFComboId).setValue(t[0].id)},onIFSelect:function(e,t,i){this.updateDosCheckBox()},onDosCheck:function(e,t,i){var s=Ext.getCmp(this.IFComboId).getValue();this.mapping_dos_protect_enable[s]=t},updateDosCheckBox:function(){var e=Ext.getCmp(this.IFComboId).getValue(),t=this.mapping_dos_protect_enable[e];this.getForm().findField("dos_protect_enable").setValue(t)},getAllIfnames:function(){var e=[];return Ext.each(this.IFStore.getRange(),function(t){e.push(t.id)},this),e},isMappingRelationDirty:function(){return Ext.encode(this.mapping_dos_protect_enable)!==Ext.encode(this.mapping_dos_protect_enable_origin)}}),Ext.define("SYNO.SDS.AdminCenter.Security.AutoBlock.RuleWindow",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t,i;return this.blackListTab=new SYNO.SDS.AdminCenter.Security.AutoBlock.RuleList({appWin:e.appWin,ruleWin:this,itemId:"deny",title:_T("autoblock","autoblock_view_list"),columns:[{header:_T("autoblock","autoblock_ip"),id:"ip",dataIndex:"ip",width:160,sortable:!0,menuDisabled:!0,renderer:function(e,t,i){var s=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(s)+'"',s}},{header:_T("autoblock","autoblock_time"),dataIndex:"record_date",width:200,sortable:!0,menuDisabled:!0},{header:_T("autoblock","autoblock_expire_time_cap"),dataIndex:"expire_date",width:200,sortable:!0,menuDisabled:!0},{header:_T("common","country"),dataIndex:"place",width:200,sortable:!1,menuDisabled:!0,renderer:function(e,t,i){var s=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(s)+'"',s}}]}),this.whiteListTab=new SYNO.SDS.AdminCenter.Security.AutoBlock.RuleList({appWin:e.appWin,ruleWin:this,title:_T("autoblock","autoblock_white_list"),itemId:"allow",columns:[{header:_T("autoblock","autoblock_allow_ip"),id:"ip",dataIndex:"ip",sortable:!0,menuDisabled:!0}]}),i={xtype:"syno_tabpanel",activeTab:0,items:[this.whiteListTab,this.blackListTab]},t={ruleWin:this,title:_T("autoblock","autoblock_view_rules"),width:700,height:440,items:[i],layout:"fit",buttons:[{btnStyle:"grey",text:_T("common","close"),scope:this,handler:function(){this.close()}}]},Ext.apply(t,e),t},resetAllList:function(){this.blackListTab.dataReady=!1,this.whiteListTab.dataReady=!1}}),Ext.define("SYNO.SDS.AdminCenter.Security.AutoBlock.RuleList",{extend:"SYNO.ux.GridPanel",pageSize:250,dataReady:!1,constructor:function(e){var t=this.fillConfig(e);this.callParent([t]),this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this)},fillConfig:function(e){this.appWin=e.appWin,this.ruleWin=e.ruleWin,this.store=new SYNO.API.JsonStore({api:"SYNO.Core.Security.AutoBlock.Rules",method:"list",version:1,baseParams:{offset:0,limit:this.pageSize,type:e.itemId},root:"ip_info",totalProperty:"total",fields:["ip",{name:"record_date",convert:function(e,t){var i=new Date(1e3*t.record_date);return SYNO.SDS.DateTimeFormatter(i,{type:"datetimesec"})}},{name:"expire_date",convert:function(e,t){if(0===t.expire_date)return _T("autoblock","forever");var i=new Date(1e3*t.expire_date);return SYNO.SDS.DateTimeFormatter(i,{type:"datetimesec"})}},{name:"place",convert:function(e,t){return t.is_public_ip?Ext.isEmpty(t.country)?_T("personal_settings","geoip_lookup_failed"):_T("Country",t.country):_T("personal_settings","private_ip")}}],scope:this,autoLoad:!1,remoteSort:!0,listeners:{load:{scope:this,fn:this.onStoreLoad},exception:{scope:this,fn:this.onStoreException}},appWindow:e.appWin}),this.createBtn=new SYNO.ux.SplitButton({itemId:"btn_create",text:_T("common","create"),scope:this,handler:this.launchAddIPDialog,menu:[{text:_T("autoblock","create_ip"),scope:this,handler:this.launchAddIPDialog},{text:_T("autoblock","import_ip"),scope:this,handler:this.launchFileDialog}]}),this.delBtn=new SYNO.ux.Button({itemId:"btn_del",text:_T("common","remove"),scope:this,handler:this.deleteItem,disabled:!0}),this.exportBtn=new SYNO.ux.Button({itemId:"btn_export",text:_T("autoblock","autoblock_export_ip_list"),scope:this,handler:this.exportIpList}),this.setBtn(this.createBtn,!0);var t={ds:this.store,loadMask:!0,height:300,enableHdMenu:!1,tbar:{items:[this.createBtn,this.delBtn,this.exportBtn,"->",{xtype:"syno_textfilter",itemId:"search",emptyText:_T("user","search_user"),enumAction:"load",queryAction:"load",store:this.store,pageSize:this.pageSize}]},bbar:{xtype:"syno_paging",pageSize:this.pageSize,displayInfo:!0,store:this.store,showRefreshBtn:!0},listeners:{activate:function(){!1===this.dataReady&&this.store.reload(),this.dataReady=!0},scope:this}};return Ext.apply(t,e),t},onSelectionChange:function(e){0=t.length)return this.ruleWin.getMsgBox().alert(_T("tree","leaf_autoblock"),_T("error","error_rmvnone")),!1;this.ruleWin.getMsgBox().confirmDelete(_T("tree","leaf_autoblock"),_T("common","remove_cfrmrmv"),function(e,i){"yes"===e&&this.sendWebAPIDelete({type:this.itemId,ip:t})},this)},sendWebAPIDelete:function(e){this.getEl().mask(_T("common","msg_waiting"),"x-mask-loading"),this.sendWebAPI({api:"SYNO.Core.Security.AutoBlock.Rules",method:"delete",version:1,params:e,scope:this,callback:this.onDeleteDone})},onDeleteDone:function(e,t,i){this.getEl().isMasked()&&this.getEl().unmask(),e?this.store.load():SYNO.Debug("Error : onDeleteDone")},exportIpList:function(){this.downloadWebAPI({scope:this,webapi:{api:"SYNO.Core.Security.AutoBlock.Rules",method:"download",version:1,params:{type:this.itemId}}})},launchAddIPDialog:function(){var e;this._S("demo_mode")?this.ruleWin.getMsgBox().alert(this.title,_JSLIBSTR("uicommon","error_demo")):((e="allow"===this.itemId?new SYNO.SDS.AdminCenter.Security.AutoBlock.AddWhiteListDialog({owner:this.ruleWin,appWin:this.appWin,ruleWin:this.ruleWin,launcher:this.itemId}):new SYNO.SDS.AdminCenter.Security.AutoBlock.AddIPDialog({owner:this.ruleWin,appWin:this.appWin,ruleWin:this.ruleWin,launcher:this.itemId})).open(),this.mon(e,"close",this.reloadAll,this,{single:!0}))},launchFileDialog:function(){var e;this._S("demo_mode")?this.ruleWin.getMsgBox().alert(this.title,_JSLIBSTR("uicommon","error_demo")):((e=new SYNO.SDS.AdminCenter.Security.AutoBlock.UploadFileDialog({owner:this.ruleWin,appWin:this.appWin,ruleWin:this.ruleWin,launcher:this.itemId})).open(),this.mon(e,"close",this.reloadAll,this,{single:!0}))},reloadAll:function(){this.ruleWin.resetAllList(),this.store.reload(),this.dataReady=!0},onStoreLoad:function(){0===this.store.getTotalCount()?this.setBtn(this.exportBtn,!1):this.setBtn(this.exportBtn,!0)},onStoreException:function(e,t,i,s,n,o){SYNO.Debug("Store exception: options:",e,t,i,s,n,o),this.ruleWin.clearStatusBusy()},setBtn:function(e,t){t?e.enable():e.disable()}}),SYNO.SDS.AdminCenter.Security.AutoBlock.Util={dateRender:function(e){var t=new Date(1e3*e);return 0===e?_T("autoblock","forever"):t.toLocaleString()},getSuccessRespCompoundData:function(e,t){if(!(t.result instanceof Array))return null;for(var i=0;i{0}{1}',_T("common","note")+_T("common","colon"),_T("certificate","lets_encrypt_china_stable_hint")),hidden:"CN"!==_S("ip_country")}]};Ext.apply(t,e),this.callParent([t])},activate:function(){var e,t,i,s=this;if(""!==(t=s.owner.getReplacedCertId()))for(e=0;e'+_T("common","note")+': '+_T("certificate","import_cert_format_tips")+""},{xtype:"syno_displayfield",htmlEncode:!1,value:''+_T("common","note")+': '+_T("certificate","import_key_format_tips")+""},{xtype:"hidden",name:"id",value:""},{xtype:"hidden",name:"desc",value:""},{xtype:"hidden",name:"as_default",value:""}]};Ext.apply(t,e),this.callParent([t])},initComponent:function(){var e=this;e.callParent(arguments),e.mon(e.getForm(),"actioncomplete",e.onFormSuccess,e),e.mon(e.getForm(),"actionfailed",e.onFormFailed,e)},checkState:function(){this.owner.getButton("next").setText(_T("common","ok"))},getNext:function(){var e=this.owner.getAddTypeValues(),t=this.owner.getAddMethodValues(),i=this.getForm(),s=function(e,t){i.findField(e).setValue(t)};return"replace"===e.addType&&s("id",e.certId),s("desc",t.desc),t.asDefault&&s("as_default",!0),this.owner.setStatusBusy({text:_T("common","msg_waiting"),iconCls:"x-mask-loading"}),this.getForm().doAction("apply"),!1},onFormSuccess:function(e,t){var i=this,s=Ext.util.JSON.decode(t.response.responseText);i.owner.clearStatusBusy(),s.data.restart_httpd?(i.owner.setStatusBusy({text:_T("service","restart_apache"),iconCls:"x-mask-loading"}),i.owner.checkProgress.defer(3e4,i)):i.owner.close()},onFormFailed:function(e,t){this.owner.clearStatusBusy(),this.owner.getMsgBox().alert(_T("tree","leaf_service"),SYNO.SDS.AdminCenter.Security.Certificate.Err2Msg(t.result.error.code))}}),Ext.define("SYNO.SDS.AdminCenter.Security.Certificate.RootCrtInfoStep",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.owner=e.owner,this.module=e.module;var t=SYNO.SDS.AdminCenter.Security.Certificate.Util,i={headline:_T("certificate","create_root_crt"),isWizardMode:!0,labelWidth:250,synodefaults:{width:200}};Ext.apply(i,t.getCertFormItems(!0,!0)),Ext.apply(i,e),this.callParent([i])},getNext:function(){var e=this.owner.getStep(this.nextId),t=this.getForm();return!!t.isValid()&&(e.fillFields(t.getValues()),this.nextId)}}),Ext.define("SYNO.SDS.AdminCenter.Security.Certificate.CrtInfoStep",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.isSet=!1;var t=SYNO.SDS.AdminCenter.Security.Certificate.Util,i={headline:_T("certificate","create_crt"),isWizardMode:!0,labelWidth:250,synodefaults:{width:200}};Ext.apply(i,t.getCertFormItems(!1,!1)),Ext.apply(i,e),this.callParent([i])},fillFields:function(e){if(!this.isSet){for(var t in e)if(e.hasOwnProperty(t)){if("common_name"==t)continue;this.getForm().findField(t).setValue(e[t])}this.isSet=!0}},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("alias").getEl(),_T("certificate","alias_tip"))},this,{single:!0})},chompArray:function(e){for(var t=e.replace(/"/,"").split(/;/),i=0;i0?this.signCrtSelector.enable():this.signCrtSelector.disable()},scope:this}}),{xtype:"syno_displayfield",width:100,value:"",tabIndex:-1}]},{xtype:"syno_displayfield",indent:1,tabIndex:-1,value:_T("certificate","sign_csr_desc")},i.signCrtSelector]},Ext.apply(t,e),i.callParent([t])},activate:function(){var e,t=this,i=[];for(e=0;e=new Date(t.valid_till).getTime()-i.getTime()?"cert-other-expire":t.is_broken?"cert-other-expire":"cert-other"},statusIconClsRenderer:function(e,t){var i=new Date;return 0>=new Date(t.valid_till).getTime()-i.getTime()?"cert-expired":t.is_broken?"cert-expired":""},descRenderer:function(e,t){var i=Ext.util.Format.htmlEncode(t.desc);return t.key_types&&"RSA"!=t.key_types&&(i=String.format("({1}) {0}",i,t.key_types)),t.is_default&&(i=String.format("({1}) {0}",i,_T("certificate","def_crt"))),i},validDateRenderer:function(e,t){var i=new Date,s=new Date(t.valid_till),n=SYNO.SDS.DateTimeFormatter(s,{type:"date"});return 2592e6'+n+"":0'+n+"":''+_T("certificate","expired")+""},certStatusRenderer:function(e,t){return t.is_broken?' - '+_T("error","error_error")+"":""},commonNameRenderer:function(e,t){return t.subject?t.subject.common_name:""},issuerRenderer:function(e,t){var i=t.issuer?t.issuer.common_name:"";return t.self_signed_cacrt_info&&(i=String.format("{0} ({1})",i,_T("certificate","self_signed_crt"))),i},sanRenderer:function(e,t){var i,s=[];for(i=0;i5545?(i.mon(i.store,"load",function(){var e=Ext.fly(s);i.mon(e,"click",i.recreateCRT,i)},i,{single:!0}),_T("certificate","warning_sha1_crt")+" "+String.format(' {1}',s,_T("certificate","fast_recreate_crt"),t.id)):""},recreateCRT:function(e,t){var i=this,s=new Ext.Element(t).getAttribute("crt_id");i.appWin.setStatusBusy({text:_T("certificate","creating_crt"),iconCls:"x-status-busy"}),i.sendWebAPI({webapi:{api:"SYNO.Core.Certificate.CRT",method:"recreate",version:1,params:{id:s}},scope:i,callback:function(e,t){var s=_T("common","error_system");if(i.appWin.clearStatusBusy(),!e)return s=SYNO.API.getErrorString(t),i.appWin.getMsgBox().alert(_T("tree","leaf_notification"),s),!1;t.restart_httpd?(i.appWin.setStatusBusy({text:_T("service","restart_apache"),iconCls:"x-mask-loading"}),i.checkProgress.defer(3e4,this)):i.store.load()}})},checkProgress:function(){var e=this;"https:"===location.protocol&&location.reload(),e.register_id=e.appWin.pollReg({webapi:{api:"SYNO.Core.Certificate.CRT",method:"list",version:1},interval:3,immediate:!0,status_callback:function(t,i,s,n){(t||i.code)&&(i.code&&e.appWin.getMsgBox().alert(_T("tree","leaf_service"),SYNO.SDS.AdminCenter.Security.Certificate.Err2Msg(i.code)),e.appWin.pollUnreg(e.register_id),e.store.load(),e.appWin.clearStatusBusy())}})},onActivate:function(){this.appWin.setStatusBusy(),this.store.load()},onSelectChange:function(){var e=this.view.getSelectedRecords(),t=!0;this.setBtn(this.toolbar_actions[1].menu.getComponent("delete"),!1),0!==e.length&&(t=t&&!e[0].get("is_default")&&e[0].get("user_deletable"),this.setBtn(this.toolbar_actions[1].menu.getComponent("delete"),t))},onContainerContextMenu:function(e,t){var i=this.view.getSelectedIndexes(),s=this.view.getSelectedNodes();this.onContextMenu(e,i[0],s[0],t)},onContextMenu:function(e,t,i,s){var n,o=this.view.getSelectedRecords();n=new SYNO.ux.Menu({autoDestroy:!0,items:this.actionItems}),0!==o.length&&!o[0].get("is_default")&&o[0].get("user_deletable")||this.setBtn(n.getComponent("delete"),!1),n.showAt(s.getXY()),s.preventDefault()},loadCrts:function(e){e&&this.sendWebAPI({webapi:{api:"SYNO.Core.Certificate.CRT",method:"list",version:1},callback:function(t,i){t&&e(i.certificates)}})},onAddCrt:function(){var e,t=this;t.loadCrts(function(i){e=new SYNO.SDS.AdminCenter.Security.Certificate.AddCrtWizard({owner:t.appWin,module:t.module,certificates:i}),t.mon(e,"close",t.onActivate,t,{single:!0}),e.open()})},onDelete:function(){var e=this,t=e.view.getSelectedItemIds();0!==t.length&&e.appWin.getMsgBox().confirmDelete(_T("certificate","certificate"),_T("certificate","confirm_del_crt"),function(i,s,n){"yes"===i&&e.deleteCrt(t)},e)},onEdit:function(){var e,t=this,i=t.view.getSelectedRecords();0!==i.length&&(e=new SYNO.SDS.AdminCenter.Security.Certificate.EditDialog({owner:t.appWin,module:t.module,cert:i[0].data}),t.mon(e,"close",t.onActivate,t,{single:!0}),e.open())},onConfig:function(){var e,t=this;t.sendWebAPI({webapi:{api:"SYNO.Core.Certificate.CRT",method:"list",version:1},scope:t,callback:function(i,s){e=new SYNO.SDS.AdminCenter.Security.Certificate.Config.Dialog({owner:t.appWin,module:t.module,certificates:i?s.certificates:[]}),t.mon(e,"close",t.onActivate,t,{single:!0}),e.open()}})},deleteCrt:function(e){var t=this;t.appWin.setStatusBusy(),t.sendWebAPI({webapi:{api:"SYNO.Core.Certificate.CRT",method:"delete",version:1,params:{ids:e}},scope:t,callback:function(e,i){var s=_T("common","error_system");if(t.appWin.clearStatusBusy(),!e)return s=SYNO.API.getErrorString(i),t.appWin.getMsgBox().alert(_T("tree","leaf_notification"),s),!1;i.restart_httpd?(t.appWin.setStatusBusy({text:_T("service","restart_apache"),iconCls:"x-mask-loading"}),t.checkProgress.defer(3e4,this)):t.store.load()}})},onRenew:function(){var e=this.view.getSelectedRecords();if(0!==e.length){var t=e[0].data;t.renewable||t.self_signed_cacrt_info?this.module.appWin.getMsgBox().confirm("",_T("certificate","renew_letsencrypt_requirement"),function(e){"yes"==e&&this.renewCertificate(t)},this,{yes:{text:_T("certificate","renew_crt")},no:{text:_T("common","cancel")}}):this.module.appWin.getMsgBox().confirm("",_T("certificate","renew_crt_desc"),function(e){"yes"==e&&this.genRenewCsr(t.id)},this,{yes:{text:_T("certificate","renew_crt")},no:{text:_T("common","cancel")}})}},onExport:function(){var e=this.view.getSelectedRecords();0!==e.length&&this.module.appWin.findAppWindow().downloadWebAPI({webapi:{api:"SYNO.Core.Certificate",version:1,method:"export",params:{id:e[0].data.id,file:"archive"}},scope:this})},renewCertificate:function(e){this.appWin.setStatusBusy({text:_T("common","msg_waiting"),iconCls:"x-mask-loading"});var t={"TrustAsia Technologies, Inc.":{api:"SYNO.Core.Certificate.Tencent",name:_T("service","service_ddns_provider_tencent_cloud")},"Let's Encrypt":{api:"SYNO.Core.Certificate.LetsEncrypt",name:"Let's Encrypt"}}[e.issuer.organization],i=t?t.api:"SYNO.Core.Certificate.CRT",s=t?t.name:_T("certificate","certificate");this.sendWebAPI({api:i,method:"renew",version:1,params:{id:e.id,force:!0},timeout:36e4,scope:this,callback:function(e,t){var i=_T("common","error_system");if(this.appWin.clearStatusBusy(),!e)return i=Ext.isObject(t)&&504===t.status?String.format(_T("common","operations_error"),s):SYNO.API.getErrorString(t),this.appWin.getMsgBox().alert(_T("tree","leaf_notification"),i),!1;t.restart_httpd&&(this.appWin.setStatusBusy({text:_T("service","restart_apache"),iconCls:"x-mask-loading"}),this.checkProgress.defer(3e4,this))}})},genRenewCsr:function(e){this.appWin.setStatusBusy({text:_T("certificate","creating_csr"),iconCls:"x-mask-loading"}),this.appWin.sendWebAPI({api:"SYNO.Core.Certificate.CSR",method:"renew",version:"1",params:{id:e},callback:function(e,t,i){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("tree","leaf_notification"),_T("common","error_system"));this.downloadCSR()},scope:this})},downloadCSR:function(){this.appWin.findAppWindow().downloadWebAPI({webapi:{api:"SYNO.Core.Certificate",version:1,method:"export",params:{file:"csr_set"}}}),this.appWin.clearStatusBusy()}}),Ext.define("SYNO.SDS.AdminCenter.Security.Certificate.ListView",{extend:"SYNO.ux.ExpandableListView",constructor:function(e){var t;t={cls:"syno-certitficate-listview",innerTpl:this.getInnerTpl()},this.callParent([Ext.apply(t,e)])},createTpl:function(e){var t=e.toggleWrapCls||this.toggleWrapCls;return new Ext.XTemplate('','","",'
    ')},getInnerTpl:function(){return new Ext.XTemplate('',"
    ",'
    ',_T("certificate","issuer")+_T("common","colon"),"
    ",'
    {issuerDisplayName}
    ',"
    ",'
    ',"
    ",'
    ',_T("certificate","alias")+_T("common","colon"),"
    ",'
    {san}
    ',"
    ",'
    ',"
    ",'
    ',_T("certificate","used_by")+_T("common","colon"),"
    ",'
    {user}
    ',"
    ",'
    ',"","
    ",'
    ',_T("common","recommend")+_T("common","colon"),"
    ",'
    {warn}
    ',"
    ",'
    ',"
    ","
    ")}}),Ext.define("SYNO.SDS.AdminCenter.Security.TLSService.MappingConfigDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t;this.owner=e.owner,this.module=e.module;var i=[];this.prepareData(e.services,i),this.gridStore=new Ext.data.JsonStore({fields:["service","serviceName","profile_level"],autoDestroy:!0}),this.gridStore.loadData(i),t={title:_T("tls_profile","customize_setting"),layout:"fit",width:600,height:400,items:new SYNO.ux.EditorGridPanel({ds:this.gridStore,clicksToEdit:1,enableColumnMove:!1,selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),columns:[{header:_T("tls_profile","services"),dataIndex:"serviceName",width:200,sortable:!1},{header:_T("tls_profile","profile_level"),dataIndex:"profile_level",width:200,editor:this.crtEditor=new SYNO.SDS.AdminCenter.Security.TLSService.TLSProfileComboBox({name:"profile-level",displayField:"profile_level_string",valueField:"profile_level",hideLabel:!0,editable:!1,mode:"local"}),renderer:function(e,t,i){return Ext.util.Format.htmlEncode(this.getEditor().store.getById(e).get("profile_level_string"))}}]}),buttons:[{btnStyle:"grey",text:_T("common","cancel"),handler:this.close,scope:this},{btnStyle:"blue",text:_T("common","apply"),handler:this.onSave,scope:this}],listeners:{beforeclose:this.onBeforeClose.createDelegate(this)}},Ext.apply(t,e),this.callParent([t])},onOpen:function(){var e={data:[{profile_level:0,profile_level_string:_T("tls_profile","default_profile")},{profile_level:1,profile_level_string:_T("tls_profile","modern")},{profile_level:2,profile_level_string:_T("tls_profile","intermediate")},{profile_level:3,profile_level_string:_T("tls_profile","old")}]};this.crtEditor.getStore().loadData(e),this.callParent(arguments)},onSave:function(){for(var e=!1,t=0;t',"");this.module.appWin.getMsgBox().alert(_T("tree","leaf_notification"),s);const t=Ext.get(e);this.module.appWin.mon(t,"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/connection_security_advanced.html"},!1)})}this.onApply()},onApply:function(){var e,t,i=[];for(e=0;e','
    ','
    {values.profile_level_string}
    ',"
    ",""),store:new Ext.data.JsonStore({autoDestroy:!0,idProperty:"profile_level",root:"data",fields:["profile_level","profile_level_string"]})},Ext.apply(t,e),this.callParent([t])}}),Ext.namespace("SYNO.SDS.AdminCenter.Security.AdvancedTab"),Ext.define("SYNO.SDS.AdminCenter.Security.AdvancedTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t=this.fillConfig(e);this.confirmSetMitigation=!1,this.mitigationModified=!1,this.rebootLaterChecked=!1,this.currentMitigationStatus=!1,this.callParent([t]),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("default-level").getEl(),_T("tls_profile","incompatible_client_for_modern"))},this,{single:!0})},fillConfig:function(e){var t={title:_T("common","advanced"),forceLayout:!0,autoScroll:!0,items:[this.createHTTPCompressionItems(),this.createTLSProfileItems()]};return"yes"===_D("support_spectre_meltdown_mitigation","no")&&t.items.push(this.createSpecreMeltdownItems()),Ext.apply(t,e),t},createHTTPCompressionItems:function(){var e=[];return e.push({xtype:"syno_displayfield",value:_T("http_compression","description")}),e.push({xtype:"syno_checkbox",name:"http_compression",boxLabel:_T("http_compression","enable"),"aria-label":_T("http_compression","enable")}),{xtype:"syno_fieldset",title:_T("http_compression","title"),collapsible:!1,webapi:{api:"SYNO.Core.Web.Security.HTTPCompression",methods:{get:"get",set:"set"},version:1},items:e}},createTLSProfileItems:function(){var e=[];return e.push({xtype:"syno_displayfield",htmlEncode:!1,value:String.format(_T("tls_profile","description"),'',""),listeners:{afterrender:function(e){this.mon(Ext.get(this.string_description_id),"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/connection_security_advanced.html"},!1)})},scope:this}}),e.push({xtype:"syno_radio",name:"default-level",inputValue:1,boxLabel:_T("tls_profile","modern"),"aria-label":_T("tls_profile","modern")+" "+_T("tls_profile","modern_desc"),handler:function(e,t){if(t&&this.owner.activeTab===this){const e=Ext.id(),t=String.format(_T("tls_profile","notify_modern_level"),'',"");this.appWin.getMsgBox().alert(_T("tree","leaf_notification"),t);const i=Ext.get(e);this.mon(i,"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/connection_security_advanced.html"},!1)})}}.bind(this)}),e.push({xtype:"syno_displayfield",indent:1,value:_T("tls_profile","modern_desc"),tabIndex:-1}),e.push({xtype:"syno_radio",name:"default-level",inputValue:2,boxLabel:_T("tls_profile","intermediate"),"aria-label":_T("tls_profile","intermediate")+" "+_T("tls_profile","intermediate_desc")}),e.push({xtype:"syno_displayfield",indent:1,value:_T("tls_profile","intermediate_desc"),tabIndex:-1}),e.push({xtype:"syno_radio",name:"default-level",inputValue:3,boxLabel:_T("tls_profile","old"),"aria-label":_T("tls_profile","old")+" "+_T("tls_profile","old_desc")}),e.push({xtype:"syno_displayfield",indent:1,value:_T("tls_profile","old_desc"),tabIndex:-1}),e.push({xtype:"syno_button",text:_T("tls_profile","customize_setting"),scope:this,handler:this.onTLSAdvancedButtonClick}),{xtype:"syno_fieldset",title:_T("tls_profile","title"),collapsible:!1,webapi:{api:"SYNO.Core.Web.Security.TLSProfile",methods:{get:"get",set:"set"},version:1},items:e}},onTLSAdvancedButtonClick:function(){this.sendWebAPI({api:"SYNO.Core.Web.Security.TLSProfile",method:"get",version:1,scope:this,callback:function(e,t){var i=_T("common","error_system");if(this.getEl().unmask(),!e)return i=SYNO.API.getErrorString(t),this.getMsgBox().alert(_T("tree","leaf_notification"),i),!1;new SYNO.SDS.AdminCenter.Security.TLSService.MappingConfigDialog({owner:this.appWin,module:this.module,services:t.services}).open()}})},createSpecreMeltdownItems:function(){var e,t,i,s,n=[],o='';return"yes"===_D("support_spectre_meltdown_mitigation_full","no")?(e=_T("spectre_meltdown_mitigation","enable_for_LK4.4_model"),t=_T("spectre_meltdown_mitigation","enable_for_LK4.4_model"),i=_T("spectre_meltdown_mitigation","title_for_LK4.4"),s=String.format(_T("spectre_meltdown_mitigation","description_for_LK4.4_model"),'',"",o,"")):(e=_T("spectre_meltdown_mitigation","enable"),t=_T("spectre_meltdown_mitigation","enable"),i=_T("spectre_meltdown_mitigation","title"),s=String.format(_T("spectre_meltdown_mitigation","description_for_LK3.10_model"),'',"",o,"")),n.push({xtype:"syno_checkbox",name:"enable_spectre_meltdown_mitigation",boxLabel:e,"aria-label":t}),n.push({xtype:"syno_displayfield",value:s,htmlEncode:!1}),{xtype:"syno_fieldset",title:i,collapsible:!1,webapi:{api:!0===_S("ha_running")?"SYNO.SHA.Hardware.SpectreMeltdown":"SYNO.Core.Hardware.SpectreMeltdown",methods:{get:"get",set:"set"},version:1},items:n}},processParams:function(e,t){return"get"===e?this.callParent(arguments):(t.services={},t)},onBeforeRequest:function(e){if("get"===e)return!0;if("yes"===_D("support_spectre_meltdown_mitigation","no")){var t=this.getForm().findField("enable_spectre_meltdown_mitigation");if(!this.confirmSetMitigation&&t.isDirty()){SYNO.Debug("enable_spectre_meltdown_mitigation changed");var i=!0===_S("ha_running")?SYNO.SDS.HA.T("ui","confirm_reboot_cluster"):_T("spectre_meltdown_mitigation","confirm_reboot");return this.module.appWin.getMsgBox().confirm(this.title,i,function(e){"yes"===e?(this.confirmSetMitigation=!0,this.module.panel.applyAllForm(),this.mitigationModified=!0,this.rebootLaterChecked=!1,this.currentMitigationStatus=t.getValue(),this.confirmSetMitigation=!1):t.reset()},this),!1}}return!0},checkHA:function(e){var t=e.find(function(e){return!0===SYNO.ux.Utils.checkApiConsistency({api:"SYNO.SHA.Hardware.SpectreMeltdown",method:"set",version:1},e)});if(t)if(t.data&&!1===t.data.success){if(Ext.isArray(t.data.errinfo)&&0!==t.data.errinfo.length)return this.owner.setStatusError({text:_T("error","error_invalid"),clear:!0}),void SYNO.SDS.HA.ShowErrMsg(this.owner,t.data.errinfo,_T("error","error_unknown"));this.owner.setStatusError({text:_T("error","error_unknown"),clear:!0})}else SYNO.SDS.HA.RebootHA(this);else this.owner.setStatusError({text:_T("error","error_unknown"),clear:!0})},processReturnData:function(e,t,i){var s=this.getForm(),n=s.findField("enable_spectre_meltdown_mitigation");i&&Ext.isArray(i.compound)&&s.loadRecords(t.result,i.compound),this.mitigationModified&&!this.rebootLaterChecked&&(SYNO.Debug("enable_spectre_meltdown_mitigation changed. Need to restart"),!0===_S("ha_hw_spectre_meltdown")?this.checkHA(t.result):"yes"===_D("support_dual_head")?SYNO.SDS.AppLaunch("SYNO.SDS.AHA.Instance",{action:"reboot_cluster"}):SYNO.SDS.System.RebootWithMsg(),this.rebootLaterChecked=!0),this.mitigationModified&&(n.setValue(this.currentMitigationStatus),n.originalValue=this.currentMitigationStatus)}}),Ext.define("SYNO.SDS.AdminCenter.Security.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.panel=new SYNO.SDS.AdminCenter.Security.TabPanel({module:this,appWin:e.appWin})},getPanel:function(){return this.panel},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"DSMTab":return"AdminCenter/connection_security_security.html";case"SigninTab":return"AdminCenter/connection_security_account.html";case"FirewallTab":return"AdminCenter/connection_security_firewall.html";case"AccountTab":return"AdminCenter/connection_security_protection.html";case"CertificateTab":return"AdminCenter/connection_certificate.html";case"AdvancedTab":return"AdminCenter/connection_security_advanced.html";default:return"AdminCenter/connection_security_desc.html"}},setActivateParams:function(e){e&&e.tab&&this.panel.setActiveTab(e.tab)},activate:function(e){this.setActivateParams(e),this.panel.loadInterface()},deactivate:function(){for(var e=this.panel.getAllForms(),t=0;t=this.FwGlobalLayoutVer?new SYNO.SDS.AdminCenter.Security.FwIFStore({module:this.module,owner:this.module.appWin}):new SYNO.SDS.AdminCenter.Network.SimpleIFStore({module:this.module,owner:this.module.appWin})},loadInterface:function(){_S("is_admin")?(this.mon(this.IFStore,"load",this.onIFAfterLoad,this),this.IFStore.loadInterface()):this.onIFAfterLoad()},onIFAfterLoad:function(e,t,i){this.loadAllForm()},onApiSuccess:function(e,t,i){if("set"===e)if(_S("is_admin")&&!t.has_fail)this.fwFormPanel.needApplyProfile()?this.fwFormPanel.applyProfile():this.fwFormPanel.needDisableFirewall()?this.fwFormPanel.disableFirewall():this.setStatusOK(),this.checkHttpdRestart(),this.module.confirmSaveLostResolve&&this.module.confirmSaveLostResolve();else{this.module.confirmSaveLostReject&&this.module.confirmSaveLostReject();var s=SYNO.API.getErrorString(t);this.setStatusError({text:s,clear:!0})}this.processReturnData(e,t,i)},checkHttpdRestart:function(){this.restartHttpd&&SYNO.SDS.AdminCenter.Utils.WaitHttpdRestart(this.module.appWin)()}}),Ext.define("SYNO.SDS.AdminCenter.Security.FwIFStore",{extend:"SYNO.SDS.AdminCenter.Network.SimpleIFStore",loadInterface:function(e){this.globalFwRecs=[];for(var t=[],i=0;i,.?]+$/;return[{itemId:"desc",xtype:"syno_displayfield",hideLabel:!0,value:_T("snmp","snmp_desc")},{xtype:"syno_checkbox",name:"enable_snmp",boxLabel:_T("snmp","snmp_enable")},{xtype:"syno_checkbox",name:"enable_snmp_v1v2",boxLabel:_T("snmp","snmp_desc_v1_v2c"),indent:1},{xtype:"syno_textfield",name:"rocommunity",maxLength:64,indent:2,width:200,allowBlank:!1,maskRe:e,regex:e,fieldLabel:_T("snmp","snmp_rocommunity")},{xtype:"syno_checkbox",name:"enable_snmp_v3",boxLabel:_T("snmp","snmp_desc_v3"),indent:1},{xtype:"syno_textfield",name:"rouser",maxLength:64,allowBlank:!1,indent:2,width:200,maskRe:e,regex:e,fieldLabel:_T("common","username")},{xtype:"syno_combobox",fieldLabel:_T("snmp","snmp_protocol"),name:"auth_type",itemId:"auth_type",indent:2,width:200,store:new Ext.data.ArrayStore({fields:["value","display"],data:[["MD5","MD5"],["SHA","SHA"]]}),value:"MD5",valueField:"value",displayField:"display"},{xtype:"syno_textfield",name:"password",textType:"password",allowBlank:!1,maxLength:127,minLength:8,indent:2,width:200,maskRe:e,regex:e,fieldLabel:_T("common","password")},{xtype:"syno_checkbox",name:"enable_privacy",itemId:"enable_privacy",indent:2,boxLabel:_T("snmp","snmp_privacy")},{xtype:"syno_combobox",fieldLabel:_T("snmp","snmp_protocol"),name:"privacy_type",itemId:"privacy_type",indent:3,width:200,store:new Ext.data.ArrayStore({fields:["value","display"],data:[["DES","DES"],["AES","AES"]]}),value:"DES",valueField:"value",displayField:"display"},{xtype:"syno_textfield",name:"privacy_key",itemId:"privacy_key",textType:"password",allowBlank:!1,maxLength:127,minLength:8,indent:3,width:200,maskRe:e,regex:e,fieldLabel:_T("common","password")},{xtype:"syno_displayfield",name:"info",indent:1,value:_T("snmp","snmp_device_info")},{xtype:"syno_textfield",name:"name",maxLength:255,indent:2,width:200,fieldLabel:_T("snmp","snmp_sysName")},{xtype:"syno_textfield",name:"location",maxLength:255,indent:2,width:200,fieldLabel:_T("snmp","snmp_sysLocation")},{xtype:"syno_textfield",name:"contact",maxLength:255,indent:2,width:200,fieldLabel:_T("snmp","snmp_sysContact")},{xtype:"syno_displayfield",htmlEncode:!1,value:_T("snmp","MIB_desc")}]},onBeforeRequest:function(e){return this.webapi.methods.set!==e||(this.getForm().isValid()?!!this.checkFormComplete(this.getForm())||(this.module.panel.setStatusError({text:_T("snmp","warnning_select_v1v2_or_v3"),clear:!0}),this.ownerCt.setActiveTab(this.itemId),!1):(this.module.panel.setStatusError({text:_T("common","forminvalid"),clear:!0}),this.ownerCt.setActiveTab(this.itemId),!1))},sendServiceEvent:function(e){for(var t={api:this.webapi.api,method:this.webapi.methods.set,version:this.webapi.version},i=this.getForm(),s=0;st.name?1:0}},constructor:function(e){var t=0,i=0;this.cls=SYNO.SDS.AdminCenter.TerminalSNMP.SSHCrypto,this.map={},this.hash={},this.hwSupportForLevel={},this.nowLevel="custom",this.nowHw=!1,Ext.each(this.cls.type,function(i){for(this[i]=e[i].sort(this.cls.compareCrypto),t=0;t=i&&(t.hardware_support&&this.map[e][this.cls.level[i]].hw.push(t.name),this.map[e][this.cls.level[i]].nonhw.push(t.name))},this)},this),Ext.each(this.cls.level,function(e){var t="",i=[];this.hwSupportForLevel[e]=this.hasHwSupportForLevel(e),this.hwSupportForLevel[e]&&(Ext.each(this.cls.type,function(t){i=0"),r}}],defaults:{sortable:!1,menuDisabled:!0}}),autoExpandColumn:"name",store:i,plugins:[s]})}}),Ext.define("SYNO.SDS.AdminCenter.TerminalSNMP.SSHAdvSettingDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.panel=this.configForm(),this.customBtn=Ext.getCmp(this.customBtnId);var t=Ext.apply({title:_T("common","adv_setting"),autoDestroy:!0,width:500,height:430,layout:"fit",items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","save"),scope:this,handler:this.onApply}]},e);this.callParent([t]),this.mon(this,"show",this.load,this),this.on("afterlayout",function(e,t){SYNO.ux.AddTip(this.panel.getForm().findField("hw_acc_cipher_only").getEl(),_T("terminal","ssh_crypto_level_hw_acc_desc"));for(var i=SYNO.ux.Utils.getRadioGroup(this.panel.getForm(),"security_level"),s=0;s'+_T("helptoc","terminal")+""),listeners:{render:function(e){var t=e.el.first("a");t&&this.mon(t,"click",function(e){e.preventDefault(),SYNO.SDS.AdminCenter.TerminalSNMP.TerminalTab.Utils.onClickTerminalHelpUrl(this.module.appWin)},this)},scope:this,buffer:80}}),e.push({xtype:"syno_checkbox",name:"enable_telnet",boxLabel:_T("terminal","telnet_enable")}),"yes"===this._D("supportssh")&&(e.push({xtype:"syno_checkbox",name:"enable_ssh",boxLabel:_T("terminal","ssh_enable")}),2<=this.apiMaxVersion&&(e.push({xtype:"syno_numberfield",indent:1,name:"ssh_port",vtype:"port",maxlength:5,fieldLabel:_T("common","port")}),2==this.apiMaxVersion&&e.push({xtype:"syno_displayfield",hidden:!0,itemId:"ssh_hw_acc_cipher_only_desc",name:"ssh_hw_acc_cipher_only_desc",value:_T("terminal","ssh_hw_acc_cipher_only_desc")},{xtype:"syno_checkbox",hidden:!0,itemId:"ssh_hw_acc_cipher_only",name:"ssh_hw_acc_cipher_only",boxLabel:_T("terminal","ssh_hw_acc_cipher_only")}),3==this.apiMaxVersion&&e.push({xtype:"syno_button",indent:1,style:{marginBottom:"12px"},text:_T("common","adv_setting"),itemId:"advBtnId",handler:function(){new SYNO.SDS.AdminCenter.TerminalSNMP.SSHAdvSettingDialog({module:this.module,owner:this.module.appWin}).open()},scope:this}))),"yes"===this._D("support_console_port")&&e.push({xtype:"syno_checkbox",name:"forbid_console",boxLabel:_T("terminal","forbid_console")}),e.push({xtype:"syno_displayfield",htmlEncode:!1,fieldLabel:"Note",hideLabel:!0,value:''+_T("common","note")+_T("common","colon")+" "+String.format(_T("terminal","terminal_security_suggest"),''+_T("controlpanel","leaf_autoblock")+""),listeners:{render:function(e){var t=e.el.first("a");t&&this.mon(t,"click",function(e){e.preventDefault(),SYNO.SDS.AdminCenter.TerminalSNMP.TerminalTab.Utils.onClickAutoblockUrl(this.module.appWin)},this)},scope:this,buffer:80}}),e},processReturnData:function(e,t,i){for(var s={api:"SYNO.Core.Terminal",method:"get",version:2},n=0;n
    • '+_T("terminal","telnet_warning")+"
    • "+_T("terminal","terminal_disclaimer")+"
    ":_T("terminal","terminal_disclaimer"):""},errorHandling:function(e){2403==e&&this.getForm().findField("ssh_port").markInvalid(SYNO.API.Erros.core[e]),this.module.appWin.getMsgBox().alert(this.title,_T("error","error_bad_field"))}}),Ext.define("SYNO.SDS.AdminCenter.TerminalSNMP.TerminalTab.Utils",{statics:{onClickTerminalHelpUrl:function(e){e.findAppWindow().onClickHelp()},onClickAutoblockUrl:function(e){e.findAppWindow().startModule("SYNO.SDS.AdminCenter.Security.Main",{tab:"AccountTab"})}}}),Ext.ns("SYNO.SDS.AdminCenter.TerminalSNMP"),Ext.define("SYNO.SDS.AdminCenter.TerminalSNMP.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.panel=new SYNO.SDS.AdminCenter.TerminalSNMP.TabPanel({module:this})},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"terminal":return"AdminCenter/system_terminal.html";case"snmp":return"AdminCenter/system_snmp.html";default:return"AdminCenter/system_terminal_snmp_desc.html"}},getPanel:function(){return this.panel},setActivateParams:function(e){e&&e.tab&&this.panel.setActiveTab(e.tab)},activate:function(e){this.setActivateParams(e),this.panel.loadAllForm()},deactivate:function(){for(var e=this.panel.getAllForms(),t=0;t'+e+""},selectableRenderer:function(e,t,i){var s,n,o;return e.match(/^{1}',o=String.format(s,SYNO.SDS.Utils.SelectableCLS,e)):(s='
    {1}
    ',n="USB"===i.data.subcategory?e+"
    "+i.data.devinfo+"
    ":"editLink"===i.data.subcategory?i.data.devinfo:e,o=String.format(s,SYNO.SDS.Utils.SelectableCLS,e,n)),o}}),Ext.define("SYNO.SDS.AdminCenter.InfoCenter.OverviewTab",{extend:"SYNO.SDS.AdminCenter.InfoCenter.GridView",title:_T("status","sysinfo_overview_tab"),api:[{api:"SYNO.Core.System",version:3,method:"info"},{api:"SYNO.Core.QuickConnect",version:2,method:"get"},{api:"SYNO.Core.Hardware.FanSpeed",version:1,method:"get"}],constructor:function(e){this.module=e.module,this.replaceWebapiIfXA(),this.makeCompoundRequest();var t=this.fillConfig(e);this.callParent([t])},replaceWebapiIfXA:function(){if(this.supportXA()){this.api.push({api:"SYNO.SHA.Util",version:1,method:"send_remote_webapi",params:{remote_api:"SYNO.Core.System",remote_version:3,remote_method:"info"}})}},makeCompoundRequest:function(){this.api={compound:{stopwhenerror:!1,params:this.api}}},loadGridData:function(e,t,i,s){var n,o,a,r,l,d=[],c=[],h=[];let u={},p={},_={};const m=this.getSelectedRowIdx(),f=_T("home","home_info_title"),S=_T("controlpanel","leaf_hardware"),g=_T("status","status_time");if(!e)return void SYNO.Debug("[Polling] action Failed.");let y=this.processQuickConnectInfo(t);if(_=this.processFanInfo(t),this.supportXA()){if(this.checkXAActiveFailure(t))return void SYNO.Debug("[Polling] XA active webapi Failed");[u,p]=this.processXAInfo(t)}t=this.getActiveApi(t);let b=this.showServerName(t,d,f);this.supportXA()?d=d.concat(this.getXADataSection(_T("status","status_version"),u.firmware_ver,p.firmware_ver,f)):d.push([_T("status","status_version"),t.firmware_ver,f]);let v=this.showSynologyAccount(y,d,f),x=this.showQuickConnectId(y,d,f);if("yes"==this._D("support_mtd_serial"))if(this.supportXA())d.push([_T("common","ds_serial"),String.format("{0} - {1}",t.serial,_T("common","chassis"))]),d=d.concat(this.getXADataSection("",u.origin_serial,p.origin_serial,S));else if(!0===_S("ha_running")){const e=String.format('
    {0}
    ',t.serial,_T("common","more_sn_detail_on_sha"));d.push([_T("common","cluster_serial"),e])}else d.push([_T("common","ds_serial"),t.serial]);if(Ext.isDefined(t.model_customized)?d.push([_T("common","ds_model"),t.model_customized]):d.push([_T("common","ds_model"),t.model]),Ext.isDefined(t.cpu_vendor)&&Ext.isDefined(t.cpu_family)&&Ext.isDefined(t.cpu_series)&&d.push([_T("status","cpu_model_name"),String.format("{0} {1} {2}",t.cpu_vendor,t.cpu_family,t.cpu_series)]),Ext.isDefined(t.cpu_clock_speed)&&(t.cpu_clock_speed<1e3?(l=Math.round(t.cpu_clock_speed),d.push([_T("status","cpu_clock_speed"),l+" MHz"])):(l=Math.round(t.cpu_clock_speed/10)/100,d.push([_T("status","cpu_clock_speed"),l+" GHz"]))),Ext.isDefined(t.cpu_num)&&d.push([_T("status","cpu_num"),t.cpu_num]),Ext.isDefined(t.cpu_cores)&&d.push([_T("status","cpu_cores"),t.cpu_cores]),Ext.isDefined(t.cpu1_core)&&d.push([_T("status","cpu1_core"),t.cpu1_core]),Ext.isDefined(t.cpu2_core)&&d.push([_T("status","cpu2_core"),t.cpu2_core]),Ext.isDefined(t.ram_size)&&(this.supportXA()?d=d.concat(this.getXADataSection(_T("status","ramsize"),u.ram_size,p.ram_size,S,this.processRamSize)):d.push([_T("status","ramsize"),this.processRamSize(t.ram_size)])),this.supportNvidiaGPU()){var w=_T("status","no_device_detected");d.push([_T("status","gpu"),t.gpu&&t.gpu.name||w],[_T("status","gpu_clock_rate"),t.gpu&&t.gpu.clock||w],[_T("status","gpu_total_memory"),t.gpu&&t.gpu.memory||w])}if(t.support_rp&&!SYNO.SDS.Utils.isInVirtualDSM()&&"yes"!==this._D("dockerdsm")&&d.push([_T("system","power_supply")+"1",1===t.rp1?_T("volume","volume_status_normal"):''+_T("common","status_abnormal")+""],[_T("system","power_supply")+"2",1===t.rp2?_T("volume","volume_status_normal"):''+_T("common","status_abnormal")+""]),Ext.isDefined(t.support_esata)&&(this.support_esata=t.support_esata),t.eunit)for(n=0;n'+_T("common","status_abnormal")+""],[a+_T("system","power_supply")+"2",1===o.rp2?_T("volume","volume_status_normal"):''+_T("common","status_abnormal")+""]);if("yes"===this._D("supportsystempwarning")&&null!==t.sys_tempwarn&&(this.supportXA()?d=d.concat(this.getXADataSection(_T("status","CPU_temperature"),{sys_temp:u.sys_temp,sys_tempwarn:u.sys_tempwarn},{sys_temp:p.sys_temp,sys_tempwarn:p.sys_tempwarn},S,this.getSysTemperature.bind(this))):d.push([_T("status","CPU_temperature"),this.getSysTemperature({sys_temp:t.sys_temp,sys_tempwarn:t.sys_tempwarn})])),this.supportNvidiaGPU())if(t.gpu&&[t.gpu.temperature_c,t.gpu.tempwarn].every(Ext.isDefined)){var T=this.renderTempFromC(t.gpu.temperature_c),C=t.gpu.tempwarn?"syno-temperature-color-overheat":"syno-temperature-color-normal",D=t.gpu.tempwarn?_T("system","over_temperature"):_T("helpbrowser","font_normal"),N=String.format('
    {2}
    ','ext:qtip="'+T+'"',C,D);d.push([_T("status","gpu_thermal_status"),N])}else d.push([_T("status","gpu_thermal_status"),_T("status","no_device_detected")]);Ext.each(d,function(e){2===e.length&&e.push(S)}),"yes"===this._D("dockerdsm")||SYNO.SDS.Utils.isInVirtualDSM()||(c=this.formatExternalDeviceInfo(t,_));var A=d.concat(c);r=t.hasOwnProperty("time_zone_desc")?t.time_zone_desc:t.time_zone,"yes"===this._D("support_sys_time")&&(this.SupSysTime=!0),this.SupSysTime&&h.push([_T("time","ntp_server"),t.enabled_ntp?t.ntp_server:t.ntp_server+" "+_T("status","status_not_enabled"),g]),h.push([_T("status","status_timezone"),r,g]),h.push([_T("status","sys_time"),SYNO.SDS.DateTimeFormatter(Date.parseDate(t.time,"Y-n-j G:i:s"),{type:"datetimesec"}),g]),this.supportXA()?h=h.concat(this.getXADataSection(_T("status","uptime"),u.up_time,p.up_time,g,this.formatUpTime)):h.push([_T("status","uptime"),this.formatUpTime(t.up_time),g]),A=A.concat(h),this.store.loadData(A),_S("is_admin")&&(this.mon(Ext.get(b),"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Network.Main"})},this),this.mon(Ext.get(v),"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.SynologyAccount.Main"})},this),this.mon(Ext.get(x),"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.PublicAccess.Main"})},this)),this.selectRow(m)},C2F:function(e){return 9*e/5+32},renderTempFromC:function(e){var t=this.C2F(e);return String.format("{0} {1} / {2} {3}",Math.round(e),_T("status","celsius"),Math.round(t),_T("status","fahrenheit"))},supportNvidiaGPU:function(){return"yes"===_D("support_nvidia_gpu")},formatUpTime:function(e){if(!e)return null;var t="",i=e.indexOf(":",0),s=e.substring(0,i),n=e.indexOf(":",i+1),o=parseInt(e.substring(i+1,n),10),a=parseInt(e.substring(n+1,e.length),10),r=((s=parseInt(s,10))-s%24)/24;return s%=24,t=r?String.format("{0} {1} ",r,_T("status","status_day")):"",t+=s||""!==t?String.format("{0} {1} ",s,_T("status","status_hour")):"",t+=o||""!==t?String.format("{0} {1} ",o,_T("status","status_minute")):"",t+=a||""!==t?String.format("{0} {1}",a,_T("status","status_second")):""},formatExternalDeviceInfo:function(e,t){var i=[],s=_T("controlpanel","leaf_hardware"),n="";i=(i=(i=this.formatUSBInfo(e.usb_dev,s)).concat(this.formatESATAInfo(e.sata_dev,s))).concat(this.formatSDInfo(e.sd_dev,s)),e.external_pci_slot_info.sort(function(e,t){var i=parseInt(e.slot,10),s=parseInt(t.slot,10);return i>s?1:i{2}',t,i,s)},processRamSize:function(e){if(!e)return null;let t=0;return 10240<=e?(t=Math.round(10*e/1024)/10)+" "+_T("common","size_gb"):(t=e)+" "+_T("common","size_mb")},supportXA:function(){return"yes"===this._D("support_xa")},checkXAActiveFailure:function(e){if(!this.supportXA())return!1;const t=(e=>{if(Ext.isObject(e)&&Ext.isBoolean(e.has_fail)&&e.has_fail&&Ext.isArray(e.result))return e.result.find(e=>Ext.isObject(e)&&!e.success)})(e);return!!t&&"SYNO.Core.System"===t.api},processFanInfo:function(e){return SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Hardware.FanSpeed","get")||{}},getActiveApi:function(e){return SYNO.API.Response.GetValByAPI(e,"SYNO.Core.System","info")},getXAPassiveApi:function(e){return SYNO.API.Response.GetValByAPI(e,"SYNO.SHA.Util","send_remote_webapi")||{}},processXAInfo:function(e){const t=this.getActiveApi(e),i=this.getXAPassiveApi(e);return 0===t.controller_location?[t,i]:[i,t]},processQuickConnectInfo:function(e){return SYNO.API.Response.GetValByAPI(e,"SYNO.Core.QuickConnect","get")},getXADataSection:function(e,t,i,s,n=(e=>e)){const o=(e,t)=>e?String.format("{0} - {1}",e,String.format(_T("volume","controller_i"),t)):String.format(_T("common","offline_controller_i"),t);return[[e,o(n(t),"A"),s],["",o(n(i),"B"),s]]},pushEditLink:function(e,t,i,s,n){let o=Ext.id(),a="";return a=_S("is_admin")?String.format('{0} ({2})',n,o,_T("common","alt_edit")):String.format("{0}",n),e.push([t,a,i,s,n]),o},showServerName:function(e,t,i){return this.pushEditLink(t,Ext.util.Format.htmlEncode(_T("tcpip","server_name")),i,"editLink",_S("hostname"))},showSynologyAccount:function(e,t,i){let s="-";return Ext.isObject(e)&&Ext.isString(e.myds_account)&&!Ext.isEmpty(e.myds_account)&&(s=e.myds_account),this.pushEditLink(t,_T("controlpanel","synology_account"),i,"editLink",s)},showQuickConnectId:function(e,t,i){let s="-";return Ext.isObject(e)&&Ext.isBoolean(e.enabled)&&!0===e.enabled&&Ext.isString(e.server_alias)&&!Ext.isEmpty(e.server_alias)&&(s=e.server_alias),this.pushEditLink(t,_T("welcome","welcome_quickcnt_id"),i,"editLink",s)}}),Ext.define("SYNO.SDS.AdminCenter.InfoCenter.NetworkTab",{extend:"SYNO.SDS.AdminCenter.InfoCenter.GridView",title:_T("tree","leaf_lan"),api:[{api:"SYNO.Core.System",version:1,params:{type:"network"},method:"info"},{api:"SYNO.Core.DDNS.Record",version:1,method:"list"}],constructor:function(e){this.module=e.module,this.owner=e.owner,this.makeCompoundRequest();var t=this.fillConfig(e);this.callParent([t])},makeCompoundRequest:function(){this.api={compound:{stopwhenerror:!1,params:this.api}}},loadGridData:function(e,t,i){var s,n,o,a=this,r=this.getSelectedRowIdx(),l=(n=_T("status","status_empty_config"),o=[],{append:function(e,t){if(!s)throw Error("group name is not set");o.push([e,t||n,s])},start:function(e){s=e},getData:function(){return o}});if(!e)return void SYNO.Debug("[Polling] action Failed.");let d=this.getSystemApiVal(t);Ext.isArray(d.nif)?(l.start(_T("home","home_info_title")),l.append(_T("status","status_name"),d.hostname),l.append(_T("status","status_dns"),d.dns),l.append(_T("status","status_gateway"),d.gateway),l.append(d.enabled_samba&&d.enabled_domain?_T("network","wnds_domain"):_T("network","wnds_group"),d.enabled_samba?d.workgroup:void 0),l.append(_T("status","status_wins"),d.enabled_samba?d.wins:void 0),this.processDDNSInfo(t,l),Ext.each(d.nif,function(e){var t=SYNO.SDS.AdminCenter.Network.Utils.getStatus(e.status),i=SYNO.SDS.AdminCenter.Network.Utils.GetLinkStatus(e.speed,e.duplex,e.mtu),s=e.addr;e.use_dhcp?s+=` (${_T("network","ip_assign_dhcp")})`:s+=` (${_T("network","ip_assign_static")})`,l.start(SYNO.SDS.Utils.Network.idToString.apply(a,[e.id,e.type])),l.append(_T("tunnel","tunnel_status"),t),l.append(_T("status","status_addr"),e.mac),l.append(_T("status","status_ipaddr"),s),l.append(_T("status","status_mask"),e.mask),Ext.isArray(e.ipv6)&&!0!==_S("ha_not_support_ipv6")&&Ext.each(e.ipv6,function(e){l.append(_T("status","status_ipv6addr"),String.format("{0}/{1}\t{2}:{3}",e.addr,e.prefix_len,_T("tcpip","ipv6_scope"),_T("tcpip","ipv6_scope_"+e.scope)))}),0{if(Ext.isObject(e)&&Ext.isBoolean(e.enable)&&!0===e.enable){let i=function(e){let t=""+e.hostname+"";"service_ddns_normal"===e.status&&(t=''+e.hostname+"");return t}(e),s=SYNO.SDS.AdminCenter.PublicAccess.DDNSTransferStatus(this,e.status,this.provider);t.append(_T("service","service_ddns_legend"),i+" ("+s+")")}})},getSystemApiVal:function(e){return SYNO.API.Response.GetValByAPI(e,"SYNO.Core.System","info")},getDDNSApiVal:function(e){return SYNO.API.Response.GetValByAPI(e,"SYNO.Core.DDNS.Record","list")}}),Ext.define("SYNO.SDS.AdminCenter.InfoCenter.StorageTab",{extend:"Ext.Panel",title:_T("status","sysinfo_storage_tab"),padding:"0",isUSBStation:null,supportBuildinStorage:null,numPerPage:3,pageIndex:1,pollingInterval:30,constructor:function(e){this.module=e.module,this.isUSBStation="yes"===this._D("usbstation","no"),this.supportBuildinStorage="yes"===this._D("support_buildin_storage","no");var t=this.fillConfig(e);this.callParent([t])},needHDDField:function(){return!SYNO.SDS.Utils.isInVirtualDSM()&&"yes"!==_D("dockerdsm")},fillConfig:function(e){this.emptyPanel=new SYNO.ux.Panel({height:188}),this.isUSBStation?this.hddGridPanel=this.createHDDGrid_USBStation():this.hddGridPanel=this.createHDDGrid(),this.volGridPanel=this.createVolumeGrid(),this.volPrevId=Ext.id(void 0,"sysinfo_vol_prev_"),this.volNextId=Ext.id(void 0,"sysinfo_vol_next_"),this.volId=Ext.id(void 0,"sysinfo_vol_"),this.volChartId=Ext.id(void 0,"sysinfo_vol_chart_"),this.volNameId=Ext.id(void 0,"sysinfo_vol_name_"),this.volHlId=Ext.id(void 0,"sysinfo_vol_hl_"),this.volDescId=Ext.id(void 0,"sysinfo_vol_desc_"),this.volTextId=Ext.id(void 0,"sysinfo_vol_text_"),this.volField=new SYNO.ux.FieldSet({stateId:"SYNO.SDS.AdminCenter.InfoCenter.Main::storage::volume",title:_T("volume","volume_info"),collapsible:!1,cls:"syno-sysinfo-fieldset",style:{"margin-top":"8px"},items:[this.emptyPanel,this.volGridPanel]}),this.hddField=new SYNO.ux.FieldSet({stateId:"SYNO.SDS.AdminCenter.InfoCenter.Main::storage::hdd",title:this.isUSBStation?_T("tree","node_device"):_T("status","status_hdd"),collapsible:!1,cls:"syno-sysinfo-fieldset",items:this.hddGridPanel});var t={layout:"form",listeners:{scope:this,resize:this.onResize,activate:this.onActivate,deactivate:this.onDeactivate},items:[this.volField]};return this.needHDDField()&&t.items.push(this.hddField),Ext.apply(t,e),t},getMidHeight:function(){var e=this.module.appWin.getHeight()-155;return this.needHDDField()?e/2:e},onResize:function(){var e=this.getMidHeight();this.emptyPanel.hide(),this.volGridPanel.setHeight(e),this.hddGridPanel.isVisible()&&(this.volGridPanel.isVisible()?this.hddGridPanel.setHeight(e):this.hddGridPanel.setHeight(this.module.appWin.getHeight()-379)),this.doLayout()},onActivate:function(){this.owner=this.module.appWin,void 0===this.pollingID&&(this.pollingID=this.owner.pollReg({interval:this.pollingInterval,immediate:!0,webapi:{api:"SYNO.Core.System",version:1,method:"info",params:{type:"storage_v2"}},status_callback:this.loadStorageInfo,scope:this}))},onDeactivate:function(){void 0!==this.pollingID&&(this.owner.pollUnreg(this.pollingID),this.pollingID=void 0)},getHddSelectedRowIdx:function(){return this.hddStore.indexOf(this.hddSelModel.getSelected())},selectHddRow:function(e){this.hddSelModel.selectRow(e)},loadStorageInfo:function(e,t,i,s){var n,o,a,r,l,d=null,c=null,h=null,u=0;if(e){if(n=t,l=this.getHddSelectedRowIdx(),this.isUSBStation){for(d=[],o=0;n.devices&&o0)for(a=0;ah?1:cr.length?-1:a.lengthd?1:lo?1:ns?1:i{model}',SYNO.SDS.Utils.SelectableCLS)}];"no"!=this._D("showdisktemperature")&&t.push({header:_T("status","temperature"),align:"left",dataIndex:"temp"}),"yes"===this._D("supportsas","no")&&t.push({header:_T("volume","volume_disk"),align:"left",dataIndex:"diskType"}),t.push({header:_T("volume","volume_diskcapacity"),align:"left",dataIndex:"capacity"},{header:_T("volume","volume_diskstatus"),align:"left",dataIndex:"status"},{header:_T("volume","volume_storage_pool"),align:"left",dataIndex:"volume",tpl:'{volume}'});var i=new Ext.grid.ColumnModel({defaults:{align:"center",useHtmlEncodeRender:!1,sortable:!1},columns:t});return new SYNO.ux.GridPanel({store:this.hddStore,enableColumnHide:!1,enableColumnMove:!1,enableColumnResize:!0,enableHdMenu:!1,selModel:this.hddSelModel,colModel:i})},createVolumeGrid:function(){var e=new Ext.data.ArrayStore({fields:["id","total","used","percent","desc"],autoDestroy:!0});return new SYNO.ux.GridPanel({store:e,enableColumnHide:!1,enableColumnMove:!1,enableColumnResize:!0,enableHdMenu:!1,hidden:!0,colModel:new Ext.grid.ColumnModel({defaults:{sortable:!1,align:"center",width:100},columns:[{header:_T("common","name"),align:"left",dataIndex:"id"},{header:_T("share","share_comment"),align:"left",dataIndex:"desc",renderer:function(e,t,i){return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(e)+'"',e||"-"}},{header:String.format("{0} (%)",_T("volume","volume_usedsize")),align:"left",dataIndex:"percent",width:130,css:"vertical-align: middle;",renderer:function(e,t,i,s,n,o){var a=Math.ceil(i.data.percent),r=new SYNO.SDS.Utils.PercentageBar({barWidth:120,barHeight:0,lineHeight:28,showValueText:!0});return new Ext.XTemplate("{progressBar}").apply({progressBar:r.fill(a)})}},{header:_T("volume","volume_usedsize"),align:"left",dataIndex:"used"},{header:_T("volume","volume_totalsize"),align:"left",dataIndex:"total",width:130}]})})},loadVolumes:function(e,t){var i;if(0===t)return this.showVolPanel("empty"),void this.emptyPanel.body.mask(_T("volume","volume_no_volumes"),"syno-ux-mask-info");e.sort(this.sortVolume),i=this.formatVolumeInfo(e,[]),this.showVolPanel("grid"),this.volIsChg(e,this.orgVolInfo)&&(this.volGridPanel.getStore().loadData(i),this.orgVolInfo=e)},sortVolume:function(e,t){var i,s;if(-1parseInt(t.name.replace("volume_",""),10)?1:-1;for(i=e.name.replace("usbshare","").replace("-",""),s=t.name.replace("usbshare","").replace("-","");i.length<4;)i+="0";for(;s.length<4;)s+="0";return i>s?1:-1},formatVolumeInfo:function(e,t){var i,s,n,o,a,r,l,d,c,h=[],u=SYNO.SDS.Utils.StorageUtils;for(this.pageCount=Math.ceil(e.length/this.numPerPage),r=0;r0)for(i=0;i{const i=Ext.util.Format.htmlEncode(t),s=Ext.util.Format.htmlEncode(e);return String.format('
    {1}
    ',i,s)};var i=new Ext.grid.ColumnModel({defaults:{width:100,align:"left"},columns:[{header:_T("service","enabled_service"),width:80,dataIndex:"display_name",align:"left",menuDisabled:!0,renderer:function(e){return'
    '+e+"
    "}},{header:_T("routerconf","routerconf_header_ds_port"),dataIndex:"ds_port",align:"left",menuDisabled:!0,renderer:function(e,i,s){return""===s.data.fwInfo?t("-",_T("service","service_port_config_not_specify")):t(e,e)}},{header:_T("service","configured_router_port"),dataIndex:"router_port",align:"left",menuDisabled:!0,renderer:function(e,i,s){return""===s.data.fwInfo?t("-",_T("service","service_port_config_not_specify")):"-"===e||"router_not_configured"===e?t("-",_T("app_port_alias","not_configured")):t(e,e)}},{header:_T("service","service_allow_on_firewall"),dataIndex:"firewall",renderer:function(e,i,s){const n={true:_T("nfs","nfs_nonprivileged_port_allow"),false:_T("nfs","nfs_nonprivileged_port_deny"),gray:_T("service","service_partial_netif_allow")};return""===s.data.fwInfo?t("-",_T("service","service_port_config_not_specify")):t(n[e],s.data.fwDesc)},scope:this},{header:_T("mediaservice","type"),dataIndex:"service_type",hideable:!1,hidden:!0,renderer:function(e){return"internal_service"===e?_T("service","internal_service"):"packages"===e?_T("pkgmgr","title_packages"):void 0}}]}),s={title:_T("service","service_subject"),colModel:i,store:this.store,view:new SYNO.ux.GroupingView({showGroupName:!1,enableGroupingMenu:!1})};return Ext.apply(s,e),s},setAPIName:function(){this.GetRouterConfAPI={api:"SYNO.Core.PortForwarding.RouterConf",method:"get",version:1},this.ListServieAPI={api:"SYNO.Core.Service",method:"get",version:3,params:{additional:["active_status"]}},this.ListPackageAPI={api:"SYNO.Core.Package",method:"list",version:1,params:{additional:["status"]}},this.CheckFwRuleAPI={api:"SYNO.Core.Security.Firewall.Rules.Serv",method:"policy_check",version:1,params:{adapter:"",service_id:[]}},this.GetFwSecPortAPI={api:"SYNO.Core.Service.PortInfo",method:"load",version:1,params:{service_id:[]}},this.CheckPfRuleAPI={api:"SYNO.Core.PortForwarding.Rules.Serv",method:"check",version:1,params:{service_id:[]}},this.ListNetIFAPI={api:"SYNO.Core.Network.Interface",method:"list",version:1}},createAPICheckPortArray:function(){return[this.CheckFwRuleAPI,this.GetFwSecPortAPI,this.CheckPfRuleAPI]},createAPIEnumArray:function(){return[this.ListServieAPI,this.ListPackageAPI]},getNetAPIArray:function(){return[this.ListNetIFAPI,this.GetRouterConfAPI]},createStore:function(e){return new SYNO.SDS.AdminCenter.InfoCenter.ServiceList.Store},loadNetIF:function(){this.sendWebAPI({compound:{stopwhenerror:!1,params:this.getNetAPIArray(),mode:"parallel"},callback:this.loadNetIFCB,scope:this})},getModelIndex:function(e){var t=this.getColumnModel().columns,i=0;return Ext.each(t,function(t){if(t.dataIndex===e)return i=t.id,!1},this),i},loadNetIFCB:function(e,t,i){var s,n,o={};if(this.IFRecords=[],this.hidePfcolumn=!1,!e||t.has_fail)for(var a=t.result,r=0;rthis.errRetryCount?(this.errRetryCount=this.errRetryCount+1,void this.enumServ.defer(3e3,this)):(this.errRetryCount=0,!e||t.has_fail?(this.module.appWin.getMsgBox().alert(this.title,SYNO.API.getErrorString(t.code)),void this.module.appWin.clearStatusBusy()):void 0===(s=SYNO.API.Response.GetValByAPI(t,this.ListServieAPI.api,"get"))?(this.module.appWin.getMsgBox().alert(this.title,_T("common","commfail")),void this.module.appWin.clearStatusBusy()):void 0===(n=SYNO.API.Response.GetValByAPI(t,this.ListPackageAPI.api,"list"))?(this.module.appWin.getMsgBox().alert(this.title,_T("common","commfail")),void this.module.appWin.clearStatusBusy()):(this.fillServRecord(s),this.fillPkgRecord(n),this.initializePortInfo(),this.loadPortInfo(),void this.module.appWin.clearStatusBusy()))},fillServRecord:function(e){e.service&&(this.records=e.service,this.updateServInfo())},getDisplayNameByID:function(e){var t;return Ext.each(this.records,function(i){e===i.service_id&&(t=i.display_name)},this),t},i18nRenderer:function(e){if(!Ext.isString(e))return SYNO.Debug("not string format"),"";var t=e.split(":");return 1===t.length?t[0]:2===t.length?_T(t[0],t[1]):(SYNO.Debug("unexpected string format"),e)},updateServInfo:function(){Ext.each(this.records,function(e){if(e.additional){var t=e.additional.active_status;e.status=t,e.enable=function(e,t){return"failed"===t?"gray":"static"===e?"active"===t:"enabled"===e}(e.enable_status,t),e.service_type="internal_service",e.display_name=this.i18nRenderer(e.display_name_section_key),"failed"===t&&(e.serv_desc=_T("pkgmgr","pkgmgr_pkg_broken"))}},this),this.records=this.records.filter(e=>!0===e.enable)},fillPkgRecord:function(e){if(e.packages)for(var t=0;t
    "+_T("router_connection","pppoe_service_name")+": "+t.join(", ");this.module.appWin.getMsgBox().alert(this.title,i)}this.rgSetPfServID=[],this.setPortSuccess=!1},getFwSectionTable:function(e){return e.reduce((e,{port_id:t,dst_port:i})=>Ext.apply(e,{[t]:i}),{})},fillRecordByData:function(e){this.fwPortInfo={},this.pfPortInfo={},this.rgPfChgServID=[];for(var t={},i=0;i"},this)},this)},getIFTypeByName:function(e){var t;return Ext.each(this.IFRecords,function(i){i.value===e&&(t=i.type)},this),t},getFirewallStatus:function(e){return"allow"===e?_T("nfs","nfs_nonprivileged_port_allow"):"deny"===e?_T("nfs","nfs_nonprivileged_port_deny"):_T("service","service_partial_network_allow")},getServiceRouterPorts:function(e){var t=[],i=null,s=function(e,t,i){void 0!==t&&Ext.isArray(t)&&Ext.isArray(e)&&Ext.each(t,function(t){0<=t[i]&&0>e.indexOf(t[i])&&e.push(t[i])},this)};for(var n in e.port_info_detail)e.port_info_detail.hasOwnProperty(n)&&(s(t,(i=e.port_info_detail[n]).tcp,"router_port"),s(t,i.udp,"router_port"));return t.sort(function(e,t){return e-t})},portsToStr:function(e){var t="",i=-1;return 0===e.length?"-":(t+=e[0],i=e[0],e.shift(),Ext.each(e,function(e){return 1===Math.abs(e-i)?(i=e,"-"===t[t.length-1]||(t+="-",!0)):("-"===t[t.length-1]&&(t+=i),t+=", "+e,i=e,!0)}),"-"===t[t.length-1]&&(t+=i),t)},getServDSPorts:function(e,t){return[...new Set([].concat(...e.map(({port_id:e})=>t[e])))].sort((e,t)=>e-t)},updateDSPortField:function(e){Ext.each(this.records,function(t){return Ext.isArray(t.fwInfo)&&Ext.isArray(t.fwInfo[0].port_info)?(t.ds_port=this.portsToStr(this.getServDSPorts(t.fwInfo[0].port_info,e)),!0):(t.ds_port="-",!0)},this)},updateRouterPortField:function(e){void 0!==e.port_info_detail&&Ext.each(this.records,function(t){return t.service_id!==e.service_id||(t.router_port=this.portsToStr(this.getServiceRouterPorts(e)),!1)},this)},updatePfField:function(e){for(var t in e&&e.status_detail&&!0===e.status_detail.has_change_port&&this.rgPfChgServID.push(e.service_id),Ext.each(this.records,function(t){if(t.service_id===e.service_id)switch(e.status){case"allow":t.port_forward=!0;break;case"deny":t.port_forward=!1;break;case"unknown":t.port_forward="unknown";break;default:t.port_forward="unknown"}},this),e.port_info)e.port_info.hasOwnProperty(t)&&(this.pfPortInfo[t]="allow"===e.port_info[t])},storeLoadRecords:function(){this.records&&this.store.loadData(this.records)},getFwTargetIF:function(){var e=[];return Ext.each(this.IFRecords,function(t){"all"!==t.value&&e.push(t.value)},this),e},getAPITaskID:function(e,t){for(var i=0;i0}}),Ext.define("SYNO.SDS.AdminCenter.InfoCenter.DiagnosisTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.support_register_ip=parseInt(e.module.appWin._S("version"),10)>=5498;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={title:_T("user_data_collection","title"),autoScroll:!0,webapi:this.getWebApi(),items:[this.createDataCollectionItems()]};return this.support_register_ip&&t.items.push(this.createRegisterIPItems()),Ext.apply(t,e),t},createDataCollectionItems:function(){return{xtype:"syno_fieldset",title:_T("user_data_collection","data_collection"),collapsible:!1,items:[{xtype:"syno_displayfield",value:_T("user_data_collection","desc")},{xtype:"syno_checkbox",name:"enable",itemId:"enable",boxLabel:_T("user_data_collection","join"),scope:this},{xtype:"syno_displayfield",htmlEncode:!1,value:_T("user_data_collection","privacy_about_data_collection")}]}},createRegisterIPItems:function(){return{xtype:"syno_fieldset",title:_T("user_data_collection","share_network_location"),collapsible:!1,items:[{xtype:"syno_checkbox",name:"register_ip",itemId:"register_ip",htmlEncode:!1,boxLabel:_T("user_data_collection","enable_web_assistant"),scope:this,listeners:{render:{fn:function(e){var t;t=e,SYNO.ux.AddWhiteTipWithMsg(t,_T("user_data_collection","enable_web_assistant_tip"),436)},single:!0}}},{xtype:"syno_displayfield",htmlEncode:!1,value:_T("user_data_collection","privacy_about_share_network_location")}]}},isDirty:function(){return this.isFormDirty()},discardChange:function(){this.getForm().reset()},getAllForms:function(){return this.forms},getAppWin:function(){return this.ownerCt.module.appWin},processParams:function(e,t){return"get"===e?t:"set"===e?(this.support_register_ip&&(t[0].params.compound[0].enable=!!t[0].params.enable,t[0].params.compound[1].service=[{action:t[0].params.register_ip?"start":"stop",service_id:"synoagentregisterd"}],delete t[0].params.register_ip,delete t[0].params.enable),t):t},processReturnData:function(e,t,i){this.support_register_ip&&Ext.isDefined(t.result)&&Ext.isArray(t.result)&&Ext.each(t.result,function(e){if(!Ext.isDefined(e.data)||!Ext.isDefined(e.data.result)||!Ext.isArray(e.data.result))return!0;Ext.each(e.data.result,function(t){if(!Ext.isDefined(t.method))return!1;"get"===t.method&&"SYNO.Core.DataCollect"===t.api&&Ext.isDefined(t.data.enable)&&(e.data.enable=t.data.enable),"get"===t.method&&"SYNO.Core.Service"===t.api&&Ext.isDefined(t.data.service)&&Ext.isArray(t.data.service)&&Ext.isDefined(t.data.service[0].enable_status)&&(e.data.register_ip="enabled"==t.data.service[0].enable_status)})}),this.callParent(arguments)},getWebApi:function(){return this.support_register_ip?{api:"SYNO.Entry.Request",methods:{get:"request",set:"request"},version:1,params:{get:{stopwhenerror:!1,compound:[{api:"SYNO.Core.DataCollect",version:1,method:"get"},{api:"SYNO.Core.Service",version:2,method:"get",service_id:"synoagentregisterd"}]},set:{stopwhenerror:!1,compound:[{api:"SYNO.Core.DataCollect",version:1,method:"set"},{api:"SYNO.Core.Service",version:1,method:"control"}]}}}:{api:"SYNO.Core.DataCollect",methods:{get:"get",set:"set"},version:1}}}),Ext.define("SYNO.SDS.AdminCenter.InfoCenter.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.appWin=e.appWin,this.callParent(arguments),this.panel=new SYNO.SDS.AdminCenter.InfoCenter.TabPanel({module:this})},getPanel:function(){return this.panel},getHelpParam:function(){return"AdminCenter/system_info_center.html"},setActivateParams:function(e){e&&e.tab&&this.panel.setActiveTab(e.tab)},activate:function(e){this.setActivateParams(e),this.panel.loadAllForm()},confirmCallback:function(e){"no"===e||this.panel.ServiceListTab.onLeave()},deactivate:function(){if(_S("is_admin")){if(this.panel.ServiceListTab.isDirty()||this.panel.DiagnosisTab.isDirty())return!1;this.panel.ServiceListTab.onLeave()}return!0},confirmLostChangeSave:function(){return new Promise(function(e,t){this.panel.applyAllForm({applyHandlerCallback:e})}.bind(this))},confirmLostChangeDontSave:function(){return new Promise(function(e,t){this.panel.DiagnosisTab.discardChange(),this.panel.ServiceListTab.onLeave(),e()}.bind(this))}}),Ext.define("SYNO.SDS.AdminCenter.InfoCenter.TabPanel",{extend:"SYNO.SDS.Utils.TabPanel",constructor:function(e){var t=Ext.apply({activeTab:0,module:e.module,items:this.getitems(e)},e);this.callParent([t])},getitems:function(e){var t=[new SYNO.SDS.AdminCenter.InfoCenter.OverviewTab({module:e.module,itemId:"overview"}),new SYNO.SDS.AdminCenter.InfoCenter.NetworkTab({module:e.module,itemId:"network"}),new SYNO.SDS.AdminCenter.InfoCenter.StorageTab({module:e.module,itemId:"storage"})];return _S("is_admin")&&t.push([this.ServiceListTab=new SYNO.SDS.AdminCenter.InfoCenter.ServiceListTab({module:e.module,itemId:"servicelisttab"}),this.DiagnosisTab=new SYNO.SDS.AdminCenter.InfoCenter.DiagnosisTab({module:e.module,itemId:"diagnosistab"})]),t},applyAllForm:function(e){this.applyAllFormOptions=e,this.applyPages={},this.callParent([e])},onApiSuccess:function(e,t,i){this.callParent([e,t,i]),this.checkAndNotify()},onApiFailure:function(e,t,i){this.callParent([e,t,i]),this.applyPages={},this.checkAndNotify()},checkAndNotify:function(){!0===this.checkIfAllApplyPollingDone()&&this.notifyAllApplyPollingDone()},checkIfAllApplyPollingDone:function(){if(this.applyPages){for(var e in this.applyPages)if(!0===this.applyPages[e])return!1;return!0}return!0},notifyAllApplyPollingDone:function(){this.applyAllFormOptions&&this.applyAllFormOptions.applyHandlerCallback&&this.applyAllFormOptions.applyHandlerCallback()}}),Ext.namespace("SYNO.SDS.AdminCenter.LoginPortal"),Ext.define("SYNO.SDS.AdminCenter.LoginPortal.Utils",{statics:{defaultInputWidth:120,getLocalAppDfValueMap:function(){var e,t={};e=SYNO.SDS.AdminCenter.LoginPortal.Utils.listAllowAltPortApp();for(var i=0;i{0}',p):String.format('{1}',u,p):p}},FQDNLinkMaker:function(e,t,i){var s="https";Ext.form.VTypes.netbiosName(e)&&(s="http",navigator.platform.match(/^(Linux|Mac|iPad|iPod|iPhone)/i)&&(e+=".local"));var n=String.format("{0}://{1}",s,e);return t&&i?String.format('{0}',n):i?String.format('{1}',n,e):String.format('{0}',n)},FQDNLinkMaker2:function(e){let t="https",i=e;return Ext.form.VTypes.netbiosName(i)&&(t="http",navigator.platform.match(/^(Linux|Mac|iPad|iPod|iPhone)/i)&&(i=`${i}.local`)),`${t}://${i}`}}}),Ext.namespace("SYNO.SDS.AdminCenter.Login"),Ext.define("SYNO.SDS.AdminCenter.Login.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.createPanel()},createPanel:function(){this.panel=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.AdminCenter.LoginPortal.Main_vue,owner:this,module:this})},getPanel:function(){return this.panel},getMainApp:function(){return this.mainApp||(this.mainApp=this.panel.components[0].$children[0]),this.mainApp},getHelpParam:function(){switch(this.getMainApp().tabKey){case"dsm":return"AdminCenter/system_login_portal_dsm.html";case"applications":return"AdminCenter/system_login_portal_applications.html";case"advanced":return"AdminCenter/system_login_portal_advanced.html";default:return"AdminCenter/system_login_portal_dsm.html"}},activate:function(e){this.getMainApp().load(e||{})},deactivate:function(){return!this.getMainApp().isDirty()},confirmLostChangeSave:function(){this.getMainApp().onApply()}}),Ext.define("SYNO.SDS.AdminCenter.Region.TimezoneStore",{extend:"Ext.data.JsonStore",constructor:function(e){this.module=e.module,this.owner=e.owner,this.hasLoaded=!1;var t=Ext.apply({fields:["value","offset","display"]},e);this.callParent([t])},loadTimezone:function(){if(!this.hasLoaded){var e=this;this.owner.sendWebAPIPromise({api:"SYNO.Core.Region.NTP",version:1,method:"listzone"}).then(function(t){e.loadData(t.zonedata),e.hasLoaded=!0},function(e){SYNO.Debug("failed to call WebAPI correctly with error: "),SYNO.Debug(e)})}}}),Ext.ns("SYNO.SDS.AdminCenter.Region.Utils"),SYNO.SDS.AdminCenter.Region.Utils.trySendSyncAPI=function(e,t,i){var s=3,n=function(o){0>--s?t(!1,o||{}):i.sendWebAPIPromise({api:"SYNO.Core.Region.NTP",method:"sync",version:1,params:{server:e}}).then(e=>t(!0,e)).catch(e=>n(e))};n()},SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateSuccessMsg=function(e){return String.format(_T("time","ntp_update_success"),e)},SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateFailedMsg=function(e,t){return String.format(_T("time","ntp_update_failed"),e,t)},SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateProgressMsg=function(e,t){return String.format(_T("time","ntp_update_progress"),e,t)},Ext.ns("SYNO.SDS.AdminCenter.Region.NTP.Utils"),SYNO.SDS.AdminCenter.Region.NTP.Utils.NTPStatusErrorCode={INTERNAL:0,REQUEST_TIME_OUT:1,CONNECTION_REFUSED:2,NO_SYSPEER:3,NO_SYNC_LAST_5_TIMES:4,NO_ID_RETURNED:5},SYNO.SDS.AdminCenter.Region.NTP.Utils.getNTPStatusErrorString=function(e){const t=SYNO.SDS.AdminCenter.Region.NTP.Utils.NTPStatusErrorCode;switch(e){case t.REQUEST_TIME_OUT:return _T("time","ntp_status_time_out");case t.CONNECTION_REFUSED:return _T("time","ntp_status_connection_refused");case t.NO_SYSPEER:case t.NO_SYNC_LAST_5_TIMES:case t.NO_ID_RETURNED:return _T("time","ntp_status_network_issue");default:return _T("time","ntp_status_unknown_error")}},Ext.define("SYNO.SDS.AdminCenter.Region.NTPTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.tzStore=new SYNO.SDS.AdminCenter.Region.TimezoneStore({module:e.module,owner:e.appWin}),this.hideSysTime=parseInt(e.module.appWin._S("version"),10)>=5910,this.ntpRetry=0,this.ntpStatusClass="",this.otpEnabled=!1,this.successGetOtpBeforeSet=!1,this.NTPApiTimestamp=0;var t=this.fillConfig(e);this.callParent([t]),this.mon(this,"afterlayout",function(e,t){new SYNO.ux.Utils.EnableRadioGroup(e.getForm(),"enable_ntp",{manual:["date","hour","minute","second"],ntp:["server","ntp_status",this.updateBtnId]})},this,{single:!0}),this.mon(this.tzStore,"load",this.onTZAfterLoad,this)},fillConfig:function(e){"yes"===this._D("support_sys_time")&&(this.hideSysTime=!1);var t={itemId:"NTPTab",title:_T("tree","leaf_time"),autoScroll:!0,webapi:{api:"SYNO.Core.Region.NTP",methods:{get:"get",set:"set"},version:2},items:[{xtype:"syno_fieldset",collapsible:!1,title:_T("time","time_zone_and_format_title"),items:this.getNowItems()},{xtype:"syno_fieldset",collapsible:!1,title:_T("time","time_zone_title"),items:this.getTimezoneItems()},{xtype:"syno_fieldset",collapsible:!1,cls:"ntp-fieldset",title:_T("time","subtitle1"),hidden:this.hideSysTime,items:this.getTimeSettingItems()}]};return Ext.apply(t,e),t},initEvents:function(){this.tzStore.loadTimezone()},onTZAfterLoad:function(){Ext.getCmp(this.tzComboBoxId).reset()},getNowItems:function(){return[{xtype:"syno_displayfield",htmlEncode:!1,fieldLabel:_T("time","time_now"),name:"now"},{xtype:"syno_combobox",name:"date_format",width:300,id:this.dateFormatComboBoxId=Ext.id(),fieldLabel:_T("personal_settings","date_format"),displayField:"display",valueField:"value",store:SYNO.SDS.DateTimeUtils.CreateDateFormatStore()},{xtype:"syno_combobox",name:"time_format",width:300,id:this.timeFormatComboBoxId=Ext.id(),fieldLabel:_T("personal_settings","time_format"),displayField:"display",valueField:"value",store:SYNO.SDS.DateTimeUtils.CreateTimeFormatStore()}]},getTimezoneItems:function(){return[{xtype:"syno_combobox",name:"timezone",id:this.tzComboBoxId=Ext.id(),fieldLabel:_T("time","time_zone"),indent:0,width:300,displayField:"display",valueField:"value",tpl:'
    {display}
    ',store:this.tzStore}]},getTimeSettingItems:function(){var e=[];return e.push({xtype:"syno_radio",boxLabel:_T("time","time_manual"),"aria-label":_T("time","time_manual"),name:"enable_ntp",inputValue:"manual"},{xtype:"syno_datetimefield",isAllDay:!0,fieldLabel:_T("time","time_date"),name:"date",width:300,indent:1,allowBlank:!1,editable:!1,hideClearButton:!0,maxValue:new Date((new Date).getFullYear()+5,11,31),minValue:new Date((new Date).getFullYear()-5,0,1)},{xtype:"syno_compositefield",indent:1,width:300,fieldLabel:_T("time","time_time"),items:[{xtype:"syno_combobox",name:"hour",width:88,displayField:"display",valueField:"value","aria-label":_T("common","time_hour"),store:SYNO.SDS.Utils.createTimeItemStore("hour")},{xtype:"syno_displayfield",value:":",tabindex:"-1",width:6},{xtype:"syno_combobox",name:"minute",width:88,displayField:"display",valueField:"value","aria-label":_T("common","time_minute"),store:SYNO.SDS.Utils.createTimeItemStore("min")},{xtype:"syno_displayfield",value:":",tabindex:"-1",width:6},{xtype:"syno_combobox",name:"second",width:88,displayField:"display",valueField:"value","aria-label":_T("common","time_second"),store:SYNO.SDS.Utils.createTimeItemStore("sec")}]},{xtype:"syno_radio",boxLabel:_T("time","ntpdate_enable"),"aria-label":_T("time","ntpdate_enable"),name:"enable_ntp",inputValue:"ntp"},{xtype:"syno_combobox",name:"server",hiddenId:Ext.id(),width:300,indent:1,fieldLabel:_T("time","ntpdate_server"),store:this.getNTPServerStore(),displayField:"value",valueField:"value",vtype:"iporhostname",allowBlank:!1,typeAhead:!0,editable:!0,selectOnFocus:!0,listeners:{scope:this,change:this.onChangeServer,select:this.onChangeServer}},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,cls:"",fieldLabel:_T("time","ntp_status"),name:"ntp_status",value:_T("time","ntp_status_checking"),isDirty:()=>!1,reset:Ext.emptyFn},{xtype:"syno_button",indent:1,id:this.updateBtnId=Ext.id(),text:_T("time","ntp_updatenow"),scope:this,handler:this.onUpdateNTPClick}),e},getNTPRadio(e){const t=e.findFields("enable_ntp");for(let e of t)if("ntp"===e.getInputValue())return e},getNTPServerStore:function(){return new Ext.data.SimpleStore({fields:["value"],data:[["time.google.com"],["pool.ntp.org"],["time.nist.gov"]]})},onChangeServer:function(e){Ext.getCmp(this.updateBtnId).enable()},onUpdateNTPClick:function(){this._S("demo_mode")?this.appWin.getMsgBox().alert(this.title,_JSLIBSTR("uicommon","error_demo")):this.getForm().findField("server").isValid(!1)&&this.syncToNTPServer(function(){this.applyForm(),this.getNTPStatus()}.bind(this))},onBeforeRequest:function(e){if("set"!==e||!this.getForm().isDirty())return!0;if(!(this.successGetOtpBeforeSet||this.confirmedManualChangeTime||this.successSyncNTPBeforeSet||this.confirmedNTPChangeTime))return this.appWin.setStatusBusy(),synowebapi.promises.request({api:"SYNO.Core.OTP.Admin",version:1,method:"get_otp_status"}).then(e=>{this.otpEnabled=e.is_enabled}).catch(e=>{SYNO.Debug(e)}).finally(()=>{this.successGetOtpBeforeSet=!0,this.appWin.clearStatusBusy(),this.module.panel.applyAllForm(),this.successGetOtpBeforeSet=!1}),!1;var t,i=this.getForm().getValues();if("manual"===i.enable_ntp&&0===this.module.panel.Retry&&!this.confirmedManualChangeTime&&!1===this.hideSysTime)return t=this.otpEnabled?String.format("{0}

    {1}",_T("time","change_manual_time_setting_warning"),_T("time","logout_comfirm")):_T("time","logout_comfirm"),this.appWin.getMsgBox().confirm("",t,function(e){"yes"===e&&(this.confirmedManualChangeTime=!0,this.module.panel.applyAllForm(),this.confirmedManualChangeTime=!1)},this),!1;var s=this.getForm().findField("server"),n=this.getForm().findField("enable_ntp");return this.otpEnabled&&n.isDirty()&&!this.successSyncNTPBeforeSet&&!this.confirmedNTPChangeTime&&"ntp"===i.enable_ntp?(this.appWin.getMsgBox().confirm("",_T("time","ntpdate_enable_warning"),function(e){"yes"===e&&(this.confirmedNTPChangeTime=!0,this.module.panel.applyAllForm(),this.confirmedNTPChangeTime=!1)},this),!1):!("ntp"===i.enable_ntp&&0===this.module.panel.Retry&&!this.successSyncNTPBeforeSet&&(s.isDirty()||n.isDirty()))||(this.syncToNTPServer(function(){this.successSyncNTPBeforeSet=!0,this.module.panel.applyAllForm(),this.successSyncNTPBeforeSet=!1}.bind(this)),!1)},getNTPStatus:async function(){if(!this.isEnableNTP())return void this.setNTPStatus(_T("time","ntp_not_enable"),"");this.setNTPStatus(_T("time","ntp_status_checking"),"processing-status"),this.setNTPApiTimestamp();const e=this.NTPApiTimestamp,t=SYNO.SDS.AdminCenter.Region.NTP.Utils.NTPStatusErrorCode.INTERNAL,i=await synowebapi.promises.request({api:"SYNO.Core.Region.NTP",method:"status",version:1}).then(({ntp_status:e,ntp_status_error_code:i})=>e?void 0:i||t,()=>t);if(e===this.NTPApiTimestamp)if(Ext.isDefined(i)){const e="https://kb.synology.com/DSM/tutorial/Troubleshooting_issues_syncing_with_NTP_server";this.setNTPStatus(`${String.format(SYNO.SDS.AdminCenter.Region.NTP.Utils.getNTPStatusErrorString(i),``,"")}`,"fail-status")}else this.setNTPStatus(_T("time","ntp_status_success"),"success-status")},setNTPStatus:function(e,t){this.isEnableNTP()||(e=_T("time","ntp_not_enable"),t="");const i=this.getForm().findField("ntp_status");i.setValue(e),i.removeClass(this.ntpStatusClass).addClass(t),this.ntpStatusClass=t},resetNTPStatus:function(){this.setNTPStatus(_T("time","ntp_status_checking"),"processing-status")},isEnableNTP:function(){const e=this.getNTPRadio(this.getForm());return!(!e||!e.getValue())},setNTPApiTimestamp:function(){this.NTPApiTimestamp=Date.now()},syncToNTPServer:function(e){var t=this.getForm().findField("server").getRawValue(),i=this._D("product"),s=SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateSuccessMsg(t),n=SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateFailedMsg(i,t),o=SYNO.SDS.AdminCenter.Region.Utils.ntpUpdateProgressMsg(i,t);this.appWin.setStatusBusy({text:o},.1,100),this.SyncWithNtp=!0;var a=function(t,i){this.SyncWithNtp=!1,this.appWin.clearStatusBusy(),t?(this.ownerCt.setStatusOK({text:s}),Ext.isFunction(e)&&e()):(this.ownerCt.setStatusError({text:_T("error","unable_to_perform_operation"),clear:!0}),this.appWin.getMsgBox().alert(this.title,n))}.bind(this);SYNO.SDS.AdminCenter.Region.Utils.trySendSyncAPI(t,a,this.appWin)},alertMessage:function(e){const t=SYNO.API.Response.GetFirstError(e);let i=_T("common","commfail");[5711,5712].includes(t.code)?i=this.getFeasibilityCheckMsg(t.errors):SYNO.API.Errors.core[t.code]&&(i=SYNO.API.Errors.core[t.code]),this.module.appWin.getMsgBox().alert(this.title,i)},processReturnData:function(e,t,i){if(t.has_fail&&this.alertMessage(t),i&&Ext.isArray(i.compound)){var s=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Region.NTP","get");if(s.date){var n=Date.parseDate(s.date,"Y/n/j");s.date=SYNO.SDS.DateTimeFormatter(n,{type:"date"})}this.getForm().loadRecords(t.result,i.compound)}this.getNTPStatus(),this.updateCurrentTime(),this.doLayout(),"set"!==e||!0===this.SyncWithNtp||t.has_fail||this.ownerCt.setStatusOK()},updateCurrentTime:function(){var e=new Date(this.getForm().findField("now").getValue());"Invalid Date"===e.toString()&&(e=new Date);var t=e.format(SYNO.SDS.DateTimeUtils.GetSystemDateFormat()+" "+SYNO.SDS.DateTimeUtils.GetSystemTimeFormat());this.getForm().setValues({now:t})},getFeasibilityCheckMsg:function(e){const t=_T("time","ntp_client_feasibility_check")+" {0} ";try{const i=JSON.parse(e.error).reduce((e,t)=>e+=String.format("
    {0}",SYNO.SDS.Utils.GetFeasibilityCheckMsg(t)),"");return String.format(t,i)}catch(e){return SYNO.Debug("Can't parse json"),_T("common","commfail")}}}),Ext.define("SYNO.SDS.AdminCenter.Region.LanguageTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={itemId:"LanguageTab",title:_T("tree","leaf_language"),autoScroll:!0,webapi:{api:"SYNO.Core.Region.Language",methods:{get:"get",set:"set"},version:1},items:[{xtype:"syno_fieldset",collapsible:!1,title:_T("language","lang_display"),items:this.getLanguageItems()},{xtype:"syno_fieldset",collapsible:!1,title:_T("language","lang_email"),items:this.getMaillangItems()},{xtype:"syno_fieldset",collapsible:!1,title:_T("language","lang_codepage"),items:this.getCodepageItems()}]};return Ext.apply(t,e),t},getLanguageItems:function(){var e=[];return e.push({xtype:"syno_displayfield",value:_T("language","lang_display_hint")}),e.push({xtype:"syno_combobox",name:"language",fieldLabel:_T("language","lang_display_field"),width:300,displayField:"display",valueField:"value",store:this.getLanguageStore(),listeners:{select:{scope:this,fn:function(){var e=this.getForm(),t=e.findField("codepage"),i=e.findField("maillang"),s=e.findField("language").getValue();"def"!=s&&(i.setValue(s),t.setValue(s))}}}}),e},getMaillangItems:function(){var e=[];return e.push({xtype:"syno_displayfield",value:_T("language","lang_email_hint")}),e.push({xtype:"syno_combobox",name:"maillang",fieldLabel:_T("language","lang_email_field"),width:300,displayField:"display",valueField:"value",store:this.getMailLangStore()}),e},getCodepageItems:function(){var e=[];return e.push({xtype:"syno_displayfield",value:_T("language","lang_codepage_hint")}),e.push({xtype:"syno_combobox",name:"codepage",fieldLabel:_T("language","lang_codepage"),width:300,displayField:"display",valueField:"value",store:this.getCodePageStore()}),e},getLanguageStore:function(){return new Ext.data.SimpleStore({fields:["value","display"],data:SYNO.SDS.Utils.getSupportedLanguage(1)})},getMailLangStore:function(){return new Ext.data.SimpleStore({fields:["value","display"],data:SYNO.SDS.Utils.getSupportedLanguage(0)})},getCodePageStore:function(){return new Ext.data.SimpleStore({fields:["value","display"],data:SYNO.SDS.Utils.getSupportedLanguageCodepage(0)})}}),Ext.define("SYNO.SDS.AdminCenter.Region.NTPServerTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t=SYNO.SDS.Utils.isInVirtualDSM()||"yes"===_D("dockerdsm")?_T("time","ntp_service_note_no_sha"):_T("time","ntp_service_note"),i={itemId:"NTPServerTab",title:_T("time","ntp_service"),autoScroll:!0,webapi:{api:"SYNO.Core.Region.NTP.Server",methods:{get:"get",set:"set"},version:1},items:[{xtype:"syno_displayfield",value:_T("time","ntp_service_desc"),"aria-label":String.format("{0} {1}",_T("time","ntp_service_desc"),t)},{xtype:"syno_checkbox",name:"enable",boxLabel:_T("time","ntp_service_enable")},{xtype:"syno_displayfield",htmlEncode:!1,value:String.format(''+_T("common","note")+_T("common","colon")+" "+t),tabindex:"-1"}]};return Ext.apply(i,e),i}}),Ext.define("SYNO.SDS.AdminCenter.Region.Main",{extend:"SYNO.SDS.AdminCenter.Module",appWin:null,constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.panel=new SYNO.SDS.AdminCenter.Region.TabPanel({module:this,appWin:this.appWin})},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"NTPTab":return"AdminCenter/system_time.html";case"LanguageTab":return"AdminCenter/system_language.html";case"NTPServerTab":return"AdminCenter/system_ntpservice.html";default:return"AdminCenter/system_region_desc.html"}},getPanel:function(){return this.panel},setActivateParams:function(e){e&&e.tab&&this.panel.setActiveTab(e.tab)},activate:function(e){return this.setActivateParams(e),this.panel.loadAllForm(),!0},deactivate:function(){for(var e=this.panel.getAllForms(),t=0;tthis.Retry++?this.module.panel.applyAllForm():this.Retry=0},onDeactivate:function(){this.NTPForm.resetNTPStatus()},processReturnData:function(e,t,i){t.has_fail?this.applyHandlerReject():this.applyHandlerResolve(),this.applyHandlerResolve=Ext.emptyFn,this.applyHandlerReject=Ext.emptyFn,this.callParent(arguments)},applyHandlerPromise:function(){var e=this;return new Promise(function(t,i){e.applyHandlerResolve=t,e.applyHandlerReject=i,e.applyHandler()})}}),Ext.define("SYNO.SDS.AdminCenter.Notification.MailSettingPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.refresh_token=null,this.expires_in=null,this.enable_oauth=!1,this.support_oauth=this._S("version")>4994,this.oauth_challenge=null,this.used_oauth_challenge=null,this.maxProfiles=3,this.profiles=[],this.profileNumber=0,this.profileIndexes=[],this.addBtn=new SYNO.ux.Button({xtype:"syno_button",name:"add_profile_btn",text:_T("notification","add_rule"),style:"margin-left: 240px",handler:this.addMailRecipient.createDelegate(this,[]),listeners:{scope:this,enable:this._onAddBtnEnable,disable:this._onAddBtnDisable}}),this.mailRecipientPanel=new SYNO.ux.FieldSet({layout:"form",items:[],buttonAlign:"left",buttons:[this.addBtn]}),this.addMailRecipient(0);var t=Ext.apply({itemId:"mailSettingTab",title:_T("helptoc","notification_email"),autoScroll:!0,labelWidth:240,items:[{xtype:"syno_displayfield",hideLabel:!0,value:_T("notification","alert_intro")},{xtype:"syno_checkbox",name:"enable_mail",boxLabel:_T("notification","mail_notification_enable")},{xtype:"syno_displayfield",cls:"syno-sds-cp-notification-field-header",hideLabel:!0,indent:1,value:_T("notification","mail_sender_header")},{xtype:"syno_combobox",name:"smtp_provider",indent:1,width:300,fieldLabel:_T("notification","label_smtp_provider"),value:"gmail",valueField:"value",displayField:"display",store:new Ext.data.SimpleStore({fields:["value","display"],data:[["gmail",_T("notification","smtp_provider_gmail")],["outlook",_T("notification","smtp_provider_outlook")],["qq",_T("notification","smtp_provider_qq")],["custom",_T("notification","smtp_provider_custom")]]}),listeners:{scope:this,select:this.onSMTPProviderSelect}},{xtype:"syno_textfield",name:"smtpserver",hidden:!0,vtype:"iporhostname",maxlength:255,indent:1,width:300,fieldLabel:_T("notification","alert_smtp"),allowBlank:!1},{xtype:"syno_numberfield",name:"smtpport",hidden:!0,maxlength:5,vtype:"port",value:25,indent:1,width:300,fieldLabel:_T("notification","alert_port"),allowBlank:!1},{xtype:"syno_checkbox",name:"smtp_enable_auth",hidden:!0,boxLabel:_T("notification","alert_smtp_need_auth"),indent:1},{xtype:"syno_textfield",name:"smtp_user",hidden:!0,maxlength:256,indent:2,width:300,fieldLabel:_T("notification","alert_smtp_user"),allowBlank:!1,validator:this.validateSMTPUserField.createDelegate(this),enableKeyEvents:!0,listeners:{scope:this,keypress:this.cleanPasswd,keydown:this.cleanPasswd}},{xtype:"syno_textfield",textType:"password",name:"smtp_pass",maxlength:256,hidden:!0,indent:2,width:300,fieldLabel:_T("notification","alert_smtp_pass"),allowBlank:!1,enableKeyEvents:!0,listeners:{scope:this,keyup:this.updateTestMailBtn}},{xtype:"syno_compositefield",cls:"syno-sds-cp-notification-gmail-composite",indent:1,name:"smtp_oauth_composite",id:this.oauthCompositeId=Ext.id(),fieldLabel:"Gmail",hidden:!0,items:[{xtype:"syno_displayfield",cls:"syno-sds-cp-notification-gmail-composite-mail",name:"smtp_oauth_mail_address",id:this.oauthAddressFieldId=Ext.id(),setText:function(e){this.setValue(e),this.originalValue=e}},{xtype:"syno_button",cls:"syno-sds-cp-notification-gmail-composite-login-btn",name:"smtp_oauth",id:this.oauthLoginBtnId=Ext.id(),indent:1,text:_T("common","login"),handler:this.onClickOAuth,scope:this}]},{xtype:"syno_displayfield",name:"refresh_token_status",indent:1,htmlEncode:!1,fieldLabel:_T("common","status")},{xtype:"syno_checkbox",name:"smtpssl",hidden:!0,indent:1,boxLabel:_T("notification","alert_use_ssl")},{xtype:"syno_textfield",name:"smtp_sender_name",maxlength:64,hidden:!0,indent:1,width:300,fieldLabel:_T("notification","label_smtp_sender_name"),allowBlank:!0,validator:this.validateSMTPSenderNameField.createDelegate(this)},{xtype:"syno_textfield",name:"smtp_sender_mail",vtype:"email",maxlength:255,hidden:!0,indent:1,width:300,fieldLabel:_T("notification","label_smtp_sender_mail"),allowBlank:!0},{xtype:"syno_displayfield",height:6},{xtype:"syno_displayfield",cls:"syno-sds-cp-notification-field-header",hideLabel:!0,indent:1,value:_T("notification","mail_recipient_header")},{xtype:"syno_displayfield",name:"mail_recipient_description",hideLabel:!0,htmlEncode:!1,indent:1,value:_T("notification","mail_recipient_description")},{xtype:"syno_textfield",name:"subject_prefix",maxlength:32,indent:1,width:300,fieldLabel:_T("notification","alert_subject_prefix")},this.mailRecipientPanel,{xtype:"hidden",name:"mail_recipient_panel_hash"},{xtype:"syno_checkbox",name:"send_welcome_mail",indent:1,boxLabel:_T("notification","welcome_mail_to_new_user")},{xtype:"syno_displayfield"},{disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",xtype:"syno_button",text:_T("notification","alert_test"),id:this.mailTestBtnId=Ext.id(),scope:this,handler:this.onClickTestMailBtn}],listeners:{beforedestroy:this.onBeforeDestroy,scope:this}},e);this.callParent([t]),this.mon(this,"afterlayout",this.enableCheckGroup,this,{single:!0}),this.mon(this,"afterlayout",this.enableSMTPFields,this,{single:!0}),this.mon(this,"afterlayout",this.enableTestMailBtn,this,{single:!0}),this.mon(this,"afterlayout",this.enableOAuthBtn,this,{single:!0}),this.mon(this,"afterlayout",this.addRecipientTip,this,{single:!0}),this.mon(this,"afterlayout",this.addSenderMailTip,this,{single:!0}),this.mon(this,"afterlayout",this.autoFillSubjectPrefix,this,{single:!0})},addMailRecipient:function(e){var t;if(e)t=e;else for(var i=0;ithis.profileIndexes.indexOf(i)){t=i;break}this.profileNumber++,this.profileIndexes.push(t);var s="recv_mail_panel_"+t;this.mailRecipientPanel.add({xtype:"syno_compositefield",indent:1,itemId:s,fieldLabel:0===t?_T("mail","mail_to_email_address"):"",items:[{xtype:"syno_textfield",name:"profile_name_"+t,itemId:"profile_name_"+t,width:120,emptyText:_T("notification","profile_name_placeholder"),allowBlank:!1,scope:this,maxlength:64,listeners:{scope:this,change:function(){this.updateHash(),this.updateTestMailBtn()},select:this.refreshBtnStatus}},{xtype:"syno_textfield",name:"mail_recipient_"+t,itemId:"mail_recipient_"+t,width:240,emptyText:_T("notification","email_recipient_placeholder"),allowBlank:!1,scope:this,validator:this.validateMailRecipientField,listeners:{scope:this,change:function(){this.updateHash(),this.updateTestMailBtn()},select:this.refreshBtnStatus}},{xtype:"syno_button",id:"profile_delete_btn_"+t,iconCls:"syno-sds-cp-notification-minus",scope:this,hidden:0===t,handler:this.removeMailRecipient}],listeners:{addMailRecipient:this.addMailRecipient.bind(this)}}),this.refreshBtnStatus()},removeMailRecipient:function(e){const t=new RegExp("^recv_mail_panel_([0-9]+)$");var i=e.ownerCt.ownerCt.itemId,s=this.profileIndexes.indexOf(parseInt(i.match(t)[1]));-1=this.maxProfiles&&this.addBtn.disable();for(var t=0;t=this.maxProfiles&&this.addBtn.setTooltip(_T("notification","profile_limit"))},updateHash:function(){this.form.findField("mail_recipient_panel_hash").setValue(JSON.stringify(this.getProfiles())),this.refreshBtnStatus()},refreshBtnStatus:function(){var e,t=null===(e=this.form)||void 0===e?void 0:e.findField("enable_mail").getValue();this.addBtn&&t&&this.addBtn.enable(),this.doLayout()},onBeforeDestroy:function(){this.doClosePopup()},onClickOAuth:function(e){_T("common","login")===e.getText()?this.onLoginOAuth():this.onLogoutOAuth()},onLoginOAuth:function(){let e=this.form.findField("smtp_provider").getValue(),t=`_mailFormOAuthCallback_${e}`;this.register(this.oauthCallback.createDelegate(this),t);let i={gmail:{client_id:"832519452450-e86hokkg6vb4vu02duf69vdebpnj4cet.apps.googleusercontent.com",scope:"email https://www.googleapis.com/auth/gmail.send",response_type:"code",access_type:"offline",approval_prompt:"force",redirect_uri:"https://update.synology.com/gmail_notification/redirect.php",state:`${t}@${window.location.origin}/webman/modules/PersonalSettings/index_ds.php@use_pkce`,code_challenge:this.oauth_challenge,code_challenge_method:"S256"},outlook:{client_id:"9ebf428a-cb97-487c-b2b1-ed3de62e2275",response_type:"code",redirect_uri:"https://update.synology.com/gmail_notification/redirect.php",scope:"openid Mail.Send User.Read profile offline_access",response_mode:"query",state:`${t}@${window.location.origin}/webman/modules/PersonalSettings/index_ds.php@use_pkce`,code_challenge:this.oauth_challenge,code_challenge_method:"S256"}},s="outlook"===e?new URL("https://login.microsoftonline.com/common/oauth2/v2.0/authorize"):new URL("https://accounts.google.com/o/oauth2/auth");s.search=new URLSearchParams(i[e]).toString(),this.used_oauth_challenge=this.oauth_challenge,this.popup=window.open(s.toString(),"mywindow","scrollbars=yes,menubar=1,resizable=0,width=600,height=520, top=100, left=300"),this.addPopupTimer(this)},oauthCallback:async function(e,t){const i=await synowebapi.promises.request({api:"SYNO.Core.Notification.Mail.Oauth",method:-1!=t.indexOf("outlook")?"outlook":"gmail",params:{code_challenge:this.used_oauth_challenge,code:e.code},version:1}).catch(e=>{SYNO.Debug(e)});var s=new Date,n=(parseInt(s.getTime()/1e3,10)+parseInt(i.expires_in,10)-1800).toString();if(this.expires_in=n,this.refresh_token=i.refresh_token,this.enable_oauth=!0,this.nonce=i.nonce,this.form.findField("smtp_user").setValue(i.email),this.form.findField("smtp_pass").setValue(i.access_token),Ext.getCmp(this.oauthAddressFieldId).show(),Ext.getCmp(this.oauthAddressFieldId).setText(i.email),Ext.getCmp(this.oauthLoginBtnId).setText(_T("common","logout")),Ext.getCmp(this.oauthCompositeId).syncSize(),this.doLayout(),this.form.isValid()){var o=[];o=this.processParams("set",o),this.ownerCt.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:o},encryption:["smtp_auth"],scope:this,callback:function(e,t,i){this.isDestroyed||(e?(this.processReturnData(e,t,i),this.ownerCt.setStatusOK()):this.ownerCt.setStatusError(),this.module.appWin.clearStatusBusy())}})}else this.ownerCt.setStatusError({text:_T("common","forminvalid"),clear:!0})},onLogoutOAuth:function(){this.enable_oauth=!1,this.expires_in=null,this.refresh_token=null,this.form.findField("smtp_user").setValue(""),this.form.findField("smtp_pass").setValue(""),this.form.findField("enable_mail").setValue(!1),Ext.getCmp(this.oauthLoginBtnId).setText(_T("common","login")),Ext.getCmp(this.oauthAddressFieldId).hide(),Ext.getCmp(this.oauthAddressFieldId).setText(""),this.doLayout();var e=[];e=this.processParams("set",e),this.ownerCt.setStatusBusy(),this.module.appWin.sendWebAPI({compound:{stopwhenerror:!1,params:e},scope:this,callback:function(e,t,i){this.isDestroyed||(e?(this.processReturnData(e,t,i),this.ownerCt.setStatusOK()):this.ownerCt.setStatusError(),this.module.appWin.clearStatusBusy())}})},enableCheckGroup:function(){new SYNO.ux.Utils.EnableCheckGroup(this.form,"enable_mail",["profile_name_0","mail_recipient_0","subject_prefix","smtp_provider","send_welcome_mail"])},enableSMTPFields:function(){this.mon(this.form.findField("enable_mail"),"check",this.updateSMTPFields,this),this.mon(this.form.findField("smtp_enable_auth"),"check",this.onSMTPEnableAuthCheck,this)},enableOAuthBtn:function(){this.mon(this.form.findField("enable_mail"),"check",this.updateOAuthBtn,this)},autoFillSubjectPrefix:function(){var e=this.form.findField("enable_mail"),t=this.form.findField("subject_prefix");this.mon(e,"check",function(){e.getValue()&&""===t.getValue()&&t.emptyText&&" "!==t.emptyText&&(t.setValue(t.emptyText),t.emptyText=" ",t.applyEmptyText())},this)},enableTestMailBtn:function(){if(!this._S("demo_mode")){this.mon(this.form.findField("enable_mail"),"check",this.updateTestMailBtn,this);for(var e=0;e{t.setValue(`${SYNO.API.getErrorString(e.code)}`),t.originalValue=t.getValue(),t.show()}).finally(()=>{this.clearStatusBusy()}))},onSMTPEnableAuthCheck:function(e,t){this.setFieldDisable(["smtp_user","smtp_pass"],!this.checkSMTPUserPassEnable())},onSMTPProviderSelect:function(e,t,i){this.updateSMTPFields()},updateSMTPFields:function(){var e,t=["smtpserver","smtpport","smtp_enable_auth","smtpssl","smtp_sender_name","smtp_sender_mail"],i=["smtp_user","smtp_pass"],s=this.form.findField("enable_mail").getValue(),n=this.form.findField("smtp_provider").getValue(),o="custom"===n,a=Ext.getCmp(this.oauthCompositeId);this.setFieldVisible(t,o),e=s&&o,this.setFieldDisable(t,!e),["gmail","outlook"].includes(n)&&this.support_oauth?("outlook"===n&&this.form.findField("smtp_oauth_composite").label.update("Outlook:"),this.setFieldVisible(i,!1),this.setFieldDisable(["refresh_token_status"],!s),a.show()):(this.setFieldVisible(i,!0),a.hide()),this.setFieldDisable(["send_welcome_mail"],!s),this.setFieldDisable(i,!this.checkSMTPUserPassEnable()),this.form.findField("smtp_user").validate()},updateMailRecipientStatus:function(){for(var e=this.form.findField("enable_mail").getValue(),t=0;t0)Ext.getCmp("profile_delete_btn_"+this.profileIndexes[t]).setDisabled(!e);this.setFieldDisable(i,!e)}this.setFieldDisable(["mail_recipient_description"],!e),this.form.findField("mail_recipient_description").originalValue=this.form.findField("mail_recipient_description").getValue(),e?this.addBtn.enable():this.addBtn.disable()},checkSMTPUserPassEnable:function(){var e=this.form.findField("enable_mail").getValue(),t=this.form.findField("smtp_provider").getValue(),i=this.form.findField("smtp_enable_auth").getValue();return!!e&&("custom"!==t||!!i)},onClickTestMailBtn:function(){this._S("demo_mode")||this.form.findField("enable_mail").getValue()&&(this.form.isDirty()?this.updateTestMailBtn():this.form.isValid()?this.sendSMTPTestMail():this.module.appWin.getMsgBox().alert(_T("notification","notification_email"),_T("common","forminvalid")))},sendSMTPTestMail:function(){var e=this.form.findField("subject_prefix").getValue(),t=this.form.findField("smtpserver").getValue(),i=this.form.findField("smtpport").getValue(),s=this.form.findField("smtpssl").getValue();this.module.appWin.setStatusBusy();var n={smtp_info:{server:t,port:i,ssl:s},mail:this.getRecipientArray(),subject_prefix:e};this.module.appWin.sendWebAPI({api:"SYNO.Core.Notification.Mail",version:1,method:"send_test",params:n,scope:this,callback:function(e,t,i){var s;e?s=_T("notification","mail_test_success"):(s=_T("notification","mail_test_failed"),4602===t.code?s=_T("notification","mail_test_failed")+"
    "+SYNO.API.getErrorString(t):t&&t.errors&&t.errors.err_msg&&(s=''+_T("notification","mail_test_failed")+"
    "+t.errors.err_msg+"
    ")),this.module.appWin.getMsgBox().alert(_T("notification","notification_email"),s),this.module.appWin.clearStatusBusy()}})},getRecipientArray:function(){for(var e=[],t=0;te.trim()),(t=arr.filter(e=>!!e).join(";"))===e?null:t},validateMailRecipientField:function(e){var t=[],i=new Set,s=0;if(""===e)return _JSLIBSTR("extlang","fieldblank");var n=this.ownerCt.ownerCt.ownerCt.ownerCt;(a=n.trimValue(e))&&(e=a);for(const i of e.split(";")){if(!Ext.form.VTypes.email(i)||i.length>320)return _JSLIBSTR("vtype","bad_email");t.push(i)}if(t.filter((e,i)=>i!==t.indexOf(e)).length>0)return _T("pushservice","pushservice_account_the_same");t=[];for(s=0;s0&&i.isDirty()&&!1===i.getValue()){var s=_T("notification","mail_in_use");this.module.appWin.getMsgBox().confirm("",s,function(i){"yes"===i?e():t()},this)}else e()}.bind(this))},processParams:function(e,t){return"get"===e?(this.push_verified_status_done=!1,t=t.concat(this.getMailConfGetWebAPI())):"set"===e&&this.isDirty()&&(t=(t=t.concat(this.getMailConfSetWebAPI())).concat(this.getMailConfGetWebAPI())),t},processSMTPReturnData:function(e){var t=SYNO.SDS.AdminCenter.Notification.MailUtil,i=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Notification.Mail.Conf","get"),s={};if(!Ext.isDefined(i)||Ext.isDefined(i.code))return s;for(Ext.apply(s,i),this.in_use=i.in_use?i.in_use:[],s.enable_mail=i.enable_mail,s.smtp_enable_mail=!!s.enable_mail&&s.enable_mail,s.smtp_subject_prefix=s.subject_prefix?s.subject_prefix:"",s.smtp_enable_auth=s.smtp_auth.enable,s.smtp_user=s.smtp_auth.user,s.smtp_pass=s.smtp_enable_auth?"12345678":"",s.smtp_sender_name=s.sender_name,s.smtp_sender_mail=s.sender_mail,Ext.apply(this.profiles,s.profiles);this.profileIndexes.length>1;){var n=Ext.getCmp("profile_delete_btn_"+this.profileIndexes[this.profileIndexes.length-1]);this.removeMailRecipient(n)}for(var o=0;o=this.maxProfiles)){var a=s.profiles[o].profile_id;0>this.profileIndexes.indexOf(a)&&this.addMailRecipient(a),s["profile_name_"+a]=s.profiles[o].name,this.trimValue(s.profiles[o].config.mail)?s["mail_recipient_"+a]=this.trimValue(s.profiles[o].config.mail):s["mail_recipient_"+a]=s.profiles[o].config.mail}return""!==s.smtp_sender_name?s.smtp_provider="custom":s.smtp_sender_mail!==s.smtp_user?s.smtp_provider="custom":s.smtp_provider=t.matchSMTPProvider(s.smtp_info,s.enable_oauth||!this.support_oauth),s.smtp_enable_mail||(s.smtp_subject_prefix="["+window.location.hostname+"]",this.form.findField("subject_prefix").emptyText="["+window.location.hostname+"]",this.form.findField("subject_prefix").applyEmptyText()),s.smtp_info&&(s.smtpserver=s.smtp_info.server,s.smtpport=s.smtp_info.port,s.smtpssl=s.smtp_info.ssl),this.enable_oauth=s.enable_oauth,this.enable_oauth?(Ext.getCmp(this.oauthAddressFieldId).show(),Ext.getCmp(this.oauthAddressFieldId).setText(s.smtp_sender_mail),Ext.getCmp(this.oauthLoginBtnId).setText(_T("common","logout"))):(Ext.getCmp(this.oauthAddressFieldId).hide(),Ext.getCmp(this.oauthAddressFieldId).setText(""),Ext.getCmp(this.oauthLoginBtnId).setText(_T("common","login"))),s.has_new_data=!0,delete s.subject_prefix,delete s.smtp_auth,s},onLoad:function(e){e.mail_server="smtp",e.subject_prefix=e.smtp_subject_prefix},processReturnData:function(e,t,i){var s={};Ext.apply(s,this.processSMTPReturnData(t)),s.has_new_data&&(delete s.has_new_data,this.onLoad(s)),this.mun(this.form.findField("enable_mail"),"check",this.updateSMTPFields,this),this.form.setValues(s),this.updateSMTPFields(),this.mon(this.form.findField("enable_mail"),"check",this.updateSMTPFields,this),this.updateOAuthBtn(),this.updateRefreshTokenStatus(),this.updateMailRecipientStatus(),this.mon(this.form.findField("enable_mail"),"check",this.updateMailRecipientStatus,this),this.updateHash(),this.form.findField("mail_recipient_panel_hash").originalValue=JSON.stringify(this.getProfiles()),this.updateTestMailBtn()},reset:function(){this.form.isDirty()&&this.form.reset()},isDirty:function(){return this.form.isDirty()},register:function(e,t){if(Ext.isIE||Ext.isIE11)window[t]=e;else{var i=this;this.receiveMessage=async function(s){var n=s.browserEvent;if("https://synooauth.synology.com"===n.origin&&!/setImmediate/.test(n.data)){var o=JSON.parse(n.data);o.callback===t&&(Ext.apply(o,o.resp),e.call(i,o,t))}},Ext.EventManager.addListener(window,"message",this.receiveMessage)}},unregister:function(){Ext.isIE||Ext.isIE11||Ext.EventManager.removeListener(window,"message",this.receiveMessage)},addPopupTimer:function(e){if(e.popup&&!e.popup.closed)var t=window.setInterval(function(){e.popup.closed&&(e.unregister(),window.clearInterval(t),t=null)},1e3)},doClosePopup:function(){this.popup&&!this.popup.closed&&this.popup.close()}}),SYNO.SDS.AdminCenter.Notification.MailUtil={defaultSMTPProvider:"gmail",providers:[{name:"gmail",server:"smtp.gmail.com",port:465,ssl:!0,oauth:!0},{name:"yahoo",server:"smtp.mail.yahoo.com",port:587,ssl:!0,oauth:!1},{name:"outlook",server:"smtp.office365.com",port:587,ssl:!0,oauth:!0},{name:"qq",server:"smtp.qq.com",port:465,ssl:!0,oauth:!1}],matchSMTPProvider:function(e,t){var i,s,n,o,a;if(void 0===e)return this.defaultSMTPProvider;if(i=e.server,s=e.port,n=e.ssl,void 0===i||""===i)return this.defaultSMTPProvider;for(o=0;o0?e.chk_msg_interval=!0:e.chk_msg_interval=!1},processReturnData:function(e,t,i){this.formData={};for(var s=0;s(function(e,t,i,s,n,o){this.getMsgBox().alert(this.title,SYNO.API.getErrorString(n)),this.clearStatusBusy()}),beforeload:function(){this.isVisible()&&this.setStatusBusy({text:_T("common","loading")})},load:function(e,t,i){this.isVisible()&&this.clearStatusBusy(),this.layout.setActiveItem(0===t.length?"empty":"grid")},scope:this}})},addStatusBar:function(e){if(!e.useStatusBar)return e;var t={xtype:"statusbar",defaultText:" ",statusAlign:"left",buttonAlign:"left",items:[]};return e.buttons&&(t.items=t.items.concat(e.buttons),delete e.buttons),Ext.applyIf(e,{fbar:t}),e},getGridPanel:function(){return this.grid=new SYNO.ux.GridPanel({itemId:"grid",layout:"fit",store:this.store,colModel:new Ext.grid.ColumnModel({defaults:{width:120,sortable:!0},columns:[{id:"name",header:_T("common","name"),dataIndex:"provider"},{header:_T("pushservice","prefix"),dataIndex:"prefix"}]}),stripeRows:!0,sm:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{scope:this,selectionchange:{fn:this.onSelectionChange}}}),tbar:new Ext.Toolbar({items:[{xtype:"syno_button",text:_T("common","add"),scope:this,handler:this.onClickAdd,id:this.addBtnId=Ext.id()},{xtype:"syno_button",text:_T("common","alt_edit"),scope:this,handler:this.onClickEdit,id:this.editBtnId=Ext.id(),disabled:!0},{xtype:"syno_button",text:_T("common","remove"),scope:this,handler:this.onClickRemove,id:this.removeBtnId=Ext.id(),disabled:!0},{xtype:"syno_button",text:_T("pushservice","pushservice_send_test_notification"),scope:this,handler:this.onClickSendTest,id:this.sendTestBtnId=Ext.id(),disabled:!0}]}),listeners:{rowdblclick:this.onClickEdit,scope:this}}),this.grid},getEmptyPanel:function(){return this.emptyPanel=new SYNO.ux.Panel({itemId:"empty",items:[{xtype:"box",data:{},id:this.infoBoxId=Ext.id(),cls:"syno-sds-cp-notification-webhook-add-btn",tpl:new Ext.XTemplate('
    ','
    ','
    ','
    ','
    ',_T("common","no_item"),"
    ",'
    ',"
    ","
    ","
    ")}],listeners:{afterlayout:{fn:()=>{this.addBtnInEmpty||(this.addBtnInEmpty=new SYNO.ux.Button({text:_T("common","add"),scope:this,btnStyle:"blue",renderTo:"empty-grid-add-item",handler:this.onClickAdd}))},scope:this},beforedestroy:()=>{this.addBtnInEmpty&&delete this.addBtnInEmpty}}}),this.emptyPanel},getSelections:function(){if(null===this.grid.getSelectionModel().getSelected())return void this.getMsgBox().alert(_T("tree","leaf_notification"),_T("mediaservice","select_one"));let e,t=this.grid.getSelectionModel().getSelections(),i=[];for(e=0;e{this.store.reload()})}catch(e){SYNO.Debug.error(e)}},onClickEdit:function(){let e=this.getSelections();try{let{window:t}=this.openVueWindow(SYNO.SDS.AdminCenter.Notification.WebhookEditDialog,{selectedProvider:e[0]});t.$on("close",()=>{this.store.reload()})}catch(e){SYNO.Debug.error(e)}},onClickRemove:function(){let e=this.getSelections();this.getMsgBox().confirm(_T("pushservice","delete_webhook_title"),_T("pushservice","delete_webhook_desc"),t=>{"yes"===t&&this.sendProviderWebapi("delete",e)},this,null,{useMessageTitle:!0})},onClickSendTest:function(){let e=this.getSelections();this.sendProviderWebapi("send_test",e,()=>{this.getToastBox(_T("pushservice","pushservice_test_notification_sent"),!1),this.clearStatusBusy()})},sendProviderWebapi:function(e,t=this.getSelections(),i){this.setStatusBusy(),synowebapi.promises.request({api:"SYNO.Core.Notification.Push.Webhook.Provider",method:e,version:1,params:{provider:t}}).then(()=>{i&&i()}).catch(e=>{this.getMsgBox().alert(this.title,SYNO.API.getErrorString(e.code),()=>{this.clearStatusBusy()})}).finally(()=>{this.store.reload(),this.clearStatusBusy()})},onSelectionChange:function(e){let t=e.getCount();Ext.getCmp(this.editBtnId).setDisabled(1!==t),Ext.getCmp(this.removeBtnId).setDisabled(0===t),Ext.getCmp(this.sendTestBtnId).setDisabled(0===t)}}),Ext.define("SYNO.SDS.AdminCenter.Notification.PushSettingPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.push_mail_verified=[],this.push_mail_unverified=[],this.push_mail_check_status_done=!1;var t=Ext.apply({itemId:"pushSettingTab",title:_T("notification","pushservice"),cls:"syno-sds-cp-notification-push-panel",autoScroll:!0,items:[{xtype:"syno_displayfield",hideLabel:!0,value:_T("pushservice","pushservice_desc")},{xtype:"syno_fieldset",collapsible:!1,cls:"syno-push-fieldset",title:_T("pushservice","mobile_fieldset"),defaultType:"syno_displayfield",items:[{value:_T("pushservice","mobile_setup_prefix")},{value:_T("pushservice","mobile_setup_step_one")},{cls:"syno-push-qr-div",html:'\n\t\t\t\t\t
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    iOS
    \n\t\t\t\t\t
    \x3c!--\n\t\t\t\t\t--\x3e
    \n\t\t\t\t\t\t
    \n\t\t\t\t\t\t
    Android
    \n\t\t\t\t\t
    \n\t\t\t\t\t',htmlEncode:!1},{value:_T("pushservice","mobile_setup_step_two")}]},{disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",xtype:"syno_button",text:_T("pushservice","pushservice_manage_mobile_device"),cls:"syno-push-manage-btn",id:this.mobileManBtnId=Ext.id(),scope:this,handler:this.onClickManMobileBtn},{xtype:"syno_fieldset",collapsible:!1,cls:"syno-push-fieldset",title:_T("pushservice","browser_fieldset"),defaultType:"syno_displayfield",items:[{value:_T("pushservice","browser_setup_prefix")},{xtype:"syno_button",text:_T("pushservice","enable_browser_push"),id:this.browserPairBtn=Ext.id(),disabled:!("safari"in window&&"pushNotification"in window.safari||Ext.isChrome),scope:this,handler:this.onClickBrowserPairBtn},{disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",xtype:"syno_button",text:_T("pushservice","pushservice_manage_mobile_device"),cls:"syno-push-manage-btn",id:this.browserManBtnId=Ext.id(),scope:this,handler:this.onClickManBrowserBtn}]},{xtype:"syno_fieldset",collapsible:!1,cls:"syno-push-fieldset",title:_T("pushservice","webhook_title"),defaultType:"syno_displayfield",items:[{value:_T("pushservice","webhook_desc")},{xtype:"syno_button",text:_T("pushservice","manage_webhook"),id:this.webhookManBtnId=Ext.id(),scope:this,handler:this.onClickManageWebhookBtn}]}]},e);this.callParent([t])},createManDialog:function(e){this.mgrDialog=new SYNO.SDS.AdminCenter.Notification.PairedMobileDialog({owner:this.module.appWin,type:e}),this.mgrDialog.open(),this.mon(this.mgrDialog,"close",()=>{this.mgrDialog=null})},onClickManMobileBtn:function(){this.createManDialog("mobile")},onClickManBrowserBtn:function(){this.createManDialog("browser")},onClickBrowserPairBtn:function(){var e,t=window.open("about:blank");this.sendWebAPI({api:"SYNO.Core.Notification.Push.AuthToken",method:"get",version:1,params:{},scope:this,callback:function(i,s,n){if(!i)return t.close(),void this.ownerCt.setStatusError("Couldn't get auth token");e=Ext.urlEncode({register_token:s.register_token,oauth_id:s.oauth_id,event_category:"system"}),t.location.replace(String.format("{0}?{1}",s.pushbrowser_server,e))}})},onClickManageWebhookBtn:function(){this.webhookDialog=new SYNO.SDS.AdminCenter.Notification.WebhookDialog({owner:this.module.appWin}),this.webhookDialog.open(),this.mon(this.webhookDialog,"close",()=>{this.webhookDialog=null})},reset:function(){return!0},isDirty:function(){return!1}}),Ext.namespace("SYNO.SDS.AdminCenter.Notification"),SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_OTHER=0,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_USER=1,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PASSWORD=2,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PHONE=3,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_MSG=4,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_API_KEY=5,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_SENDER=6,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_MAX=7,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_USER="@@USER@@",SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_PASSWORD="@@PASS@@",SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_PHONE="@@PHONE@@",SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_MSG="@@TEXT@@",SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_API_KEY="@@APIKEY@@",SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_SENDER="@@SENDER@@",SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_INPUT=2,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_MAX_TYPE_COUNT=10,SYNO.SDS.AdminCenter.Notification.g_smsPatternUrl=/^(http|https):\/\/([A-Za-z0-9.-]+)(:\d+)?[^?]*(\?.+)?/,SYNO.SDS.AdminCenter.Notification.g_smsPatternParamList=/&?(\w*)=([^&]*)&?(.*)?/,SYNO.SDS.AdminCenter.Notification.g_smsPatternHelloWorld=/[\w]{5}(.){1}[\w]{5}/,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_INVALID_PARAM=-1,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_INVALID_PROTOCOL=-2,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_TOO_FEW_PARAM=-3,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_TOO_MANY_PARAM=-4,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_DUPLICATED_TYPE=-5,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NO_SEP_CHAR=-6,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NO_MSG_CONTENT=-7,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NO_RECIPIENT=-8,SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NEED_BOTH_USER_AND_PASS=-9,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_STORE=new Ext.data.SimpleStore({fields:["value","display"],data:[[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_SENDER,_T("smsnotify","sender")],[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_USER,_T("smsnotify","camera_attr_user")],[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PASSWORD,_T("smsnotify","camera_attr_password")],[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PHONE,_T("smsnotify","url_param_phone")],[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_MSG,_T("smsnotify","url_param_content")],[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_API_KEY,_T("smsnotify","api_key")],[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_OTHER,_T("smsnotify","url_param_other")]]}),SYNO.SDS.AdminCenter.Notification.SMS_StringMap=[],SYNO.SDS.AdminCenter.Notification.SMS_StringMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_SENDER]=_T("smsnotify","sender"),SYNO.SDS.AdminCenter.Notification.SMS_StringMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_USER]=_T("smsnotify","camera_attr_user"),SYNO.SDS.AdminCenter.Notification.SMS_StringMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PASSWORD]=_T("smsnotify","camera_attr_password"),SYNO.SDS.AdminCenter.Notification.SMS_StringMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PHONE]=_T("smsnotify","url_param_phone"),SYNO.SDS.AdminCenter.Notification.SMS_StringMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_MSG]=_T("smsnotify","url_param_content"),SYNO.SDS.AdminCenter.Notification.SMS_StringMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_API_KEY]=_T("smsnotify","api_key"),SYNO.SDS.AdminCenter.Notification.SMS_StringMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_OTHER]=_T("smsnotify","url_param_other"),SYNO.SDS.AdminCenter.Notification.SMS_TagMap=[],SYNO.SDS.AdminCenter.Notification.SMS_TagMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_USER]=SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_USER,SYNO.SDS.AdminCenter.Notification.SMS_TagMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PASSWORD]=SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_PASSWORD,SYNO.SDS.AdminCenter.Notification.SMS_TagMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_PHONE]=SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_PHONE,SYNO.SDS.AdminCenter.Notification.SMS_TagMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_MSG]=SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_MSG,SYNO.SDS.AdminCenter.Notification.SMS_TagMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_API_KEY]=SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_API_KEY,SYNO.SDS.AdminCenter.Notification.SMS_TagMap[SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_SENDER]=SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TAG_SENDER,Ext.define("SYNO.SDS.AdminCenter.Notification.ProviderEditDialog",{extend:"SYNO.SDS.Wizard.ModalWindow",constructor:function(e){this.dsSMSProvider=e.dsSMSProvider,this.isEditAction=void 0!==e.smsProvider,this.smsProvider=e.smsProvider,this.providerSepChar=" ",this.pairCount=0,this.headerString="",this.paramString="",this.apikey="",this.paramCategoryStore=this.getCategoryStore(),Ext.apply(e,{title:this.isEditAction?_T("smsnotify","provider_edit"):_T("smsnotify","provider_new"),width:590,height:480,closable:!0,steps:[this.getBasicPanelConfig({itemId:"step_1",nextId:"stepEditHeader"}),this.getRequestPanelConfig({itemId:"stepEditHeader",nextId:"stepEditBodyParam"}),this.getRequestPanelConfig({itemId:"stepEditBodyParam",nextId:"stepEditVarType"}),this.getParamPanelConfig({itemId:"stepEditVarType",nextId:null})]}),this.callParent([e])},getBasicPanelConfig:function(e){var t=this.dsSMSProvider,i=this.isEditAction,s=this.smsProvider,n=!1;return Ext.apply({headline:_T("smsnotify","provider_descript"),xtype:"syno_formpanel",border:!1,labelWidth:200,items:[{xtype:"syno_textfield",fieldLabel:_T("smsnotify","provider_name"),name:"provider_name",maxlength:32,allowBlank:!1,width:300,validator:function(e){if(0===(e=Ext.util.Format.trim(e)).length)return _JSLIBSTR("extlang","fieldblank");if("synosms"==e)return _T("smsnotify","smsnotify_preserve_provider");for(var n=0;n{0}',_T("service","service_howto")),listeners:{scope:this,afterrender:function(e){var t=e.el.query("span"),i=Ext.fly(t[0]),s=function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/system_notification_sms.html"},!1)};i.addKeyListener(Ext.EventObject.SPACE,s,this),i.addKeyListener(Ext.EventObject.ENTER,s,this),this.mon(i,"click",s,this)}}}],activate:function(){!0===this.owner.isEditAction&&!1===n&&(this.owner.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({api:"SYNO.Core.Notification.SMS.Provider",version:2,method:"get",params:{provider_id:this.owner.smsProvider},scope:this,callback:function(e,t){if(this.owner.clearStatusBusy(),!e)return this.owner.setStatusError(),void this.owner.getMsgBox().alert(_T("tree","leaf_smsnotify"),String.format(_T("error","error_unexpected_load_settings"),'',""));""===t.req_method&&(t.req_method="get"),""===t.sep_char&&(t.req_method=" "),this.owner.providerSepChar=t.sep_char,this.form.setValues(t),"get"===t.req_method?this.form.findField("req_method").items.get(0).setValue(!0):this.form.findField("req_method").items.get(1).setValue(!0),this.owner.loadReqParams(t.req_header,t.req_param),this.owner.EditTemplate=t.template,n=!0}}))},getNext:function(){return!!this.getForm().isValid()&&this.nextId}},e)},getRequestPanelConfig:function(e){var t=new Ext.grid.ColumnModel({defaults:{sortable:!0},columns:[{header:_T("smsnotify","request_parameter"),dataIndex:"param"},{header:_T("smsnotify","request_value"),dataIndex:"value"}]}),i=new Ext.grid.RowSelectionModel({singleSelect:!0,listeners:{scope:this,selectionchange:function(t){var i=this.getStep(e.itemId).getTopToolbar(),s=i.items.get("editBtn"),n=i.items.get("removeBtn");s.setDisabled(0===t.length),n.setDisabled(0===t.length)}}});return Ext.apply({headline:"stepEditHeader"===e.itemId?_T("smsnotify","header_req_header"):_T("smsnotify","header_req_parameter"),xtype:"syno_gridpanel",cls:"syno-sds-cp-notification-provider-gridpanel",enableHdMenu:!1,tbar:new Ext.Toolbar({cls:"syno-sds-cp-notification-provider-gridpanel-toolbar",items:[{xtype:"syno_button",disabled:!1,text:_T("common","add"),scope:this,handler:function(){this.onClickAddParam(e.itemId)}},{xtype:"syno_button",itemId:"editBtn",disabled:!0,text:_T("common","alt_edit"),scope:this,handler:function(){this.onClickEditParam(e.itemId)}},{xtype:"syno_button",itemId:"removeBtn",disabled:!0,text:_T("common","remove"),scope:this,handler:function(){this.onClickRemoveParam(e.itemId)}}]}),colModel:t,sm:i,store:this.paramCategoryStore,listeners:{celldblclick:function(){this.stepId=e.itemId,this.onClickEditParam(this.stepId)},scope:this},activate:function(){this.owner.paramCategoryStore.clearFilter(),"stepEditHeader"===e.itemId?this.owner.paramCategoryStore.filter("type","header"):this.owner.paramCategoryStore.filter("type","param")},getNext:function(){if("stepEditBodyParam"===e.nextId){var t=this.owner.getStep("step_1").getForm().findField("req_method").getValue().getInputValue();this.nextId="get"===t?"stepEditVarType":"stepEditBodyParam"}return this.owner.paramCategoryStore.clearFilter(),this.nextId}},e)},getParamPanelConfig:function(e){var t=new Ext.grid.ColumnModel({columns:[{header:_T("smsnotify","request_parameter"),dataIndex:"param"},{header:_T("smsnotify","category"),dataIndex:"category",editor:new SYNO.ux.ComboBox({store:SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_STORE,lazyRender:!0,mode:"local",displayField:"display",valueField:"value",triggerAction:"all",editable:!1}),renderer:function(e){return SYNO.SDS.AdminCenter.Notification.SMS_StringMap[e]}}]}),i=new Ext.grid.RowSelectionModel({selModel:new Ext.grid.RowSelectionModel({singleSelect:!0})});return Ext.apply({headline:_T("smsnotify","provider_param_descript"),xtype:"syno_editorgrid",cls:"syno-sds-cp-notification-param-category-gridpanel",enableHdMenu:!1,enableColumnMove:!1,colModel:t,sm:i,store:this.paramCategoryStore,clicksToEdit:1,activate:function(){this.owner.genParamList()},getNext:function(){return this.owner.createTemplate().then(()=>(this.owner.processApplyAction(),!1)).catch(e=>(this.owner.printErrorMsg(e),!1)),!1},disableNextInDemoMode:!0},e)},onSaveParam:function(e,t,i,s,n,o){if(void 0===n)this.paramCategoryStore.loadData([[this.pairCount,i,s,o,SYNO.SDS.AdminCenter.Notification.SMS_PARAM_TYPE_OTHER]],!0),this.pairCount++;else{let e;(e=this.paramCategoryStore.getById(n)).set("param",i),e.set("value",s)}},onClickAddParam:function(e){this.stepId=e;var t=new SYNO.SDS.AdminCenter.Notification.SMSRequestEditor({owner:this,type:"stepEditHeader"===e?"header":"param"});this.mon(t,"save_param",this.onSaveParam,this),t.open()},onClickEditParam:function(e){this.stepId=e;var t,i=this.getStep(e).getSelectionModel().getSelected().id;if(void 0!==(t=this.paramCategoryStore.getById(i))){var s=new SYNO.SDS.AdminCenter.Notification.SMSRequestEditor({owner:this,recId:i,param:t.get("param"),value:t.get("value"),type:t.get("type")});this.mon(s,"save_param",this.onSaveParam,this),s.open()}else this.getMsgBox().alert(_T("tree","leaf_notification"),_T("notification","select_one_notification"))},onClickRemoveParam:function(e){var t=this.getStep(e),i=t.getSelectionModel().getSelected(),s=t.getTopToolbar(),n=s.items.get("editBtn"),o=s.items.get("removeBtn");void 0!==i?(this.paramCategoryStore.remove(i),n.setDisabled(!0),o.setDisabled(!0)):this.getMsgBox().alert(_T("tree","leaf_notification"),_T("notification","select_one_notification"))},getCategoryStore:function(){return new Ext.data.ArrayStore({autoDestroy:!0,storeId:"paramCategory",idIndex:0,fields:[{name:"id",type:"int"},{name:"param",type:"string"},{name:"value",type:"string"},{name:"type",type:"string"},{name:"category",type:"int"}]})},loadReqParams:function(e,t){0{if("url"!==e.get("type"))return;let t=e.get("param"),s=e.get("value");if(void 0===i[t])return this.paramCategoryStore.remove(e);i[t]!==s&&e.set("value",i[t]),delete i[t]});for(let e in i){let t=i[e],n=this.checkParams(s[e]);this.paramCategoryStore.loadData([[this.pairCount,e,t,"url",n]],!0),this.pairCount++}return 0},parseQuery:function(e){if("string"!=typeof e||0==e.length)return{};let t=e;return e.split("?").length>0&&(t=e.split("?")[1]),void 0===t?{}:Ext.urlDecode(t)},printErrorMsg:function(e){var t="";switch(e){case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_INVALID_PARAM:case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_INVALID_PROTOCOL:t=_T("smsnotify","url_err_invalid_param");break;case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NO_SEP_CHAR:t=_T("smsnotify","url_err_need_sep_char");break;case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NO_MSG_CONTENT:t=_T("smsnotify","url_err_need_message_content");break;case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NO_RECIPIENT:t=_T("smsnotify","url_err_need_recipient");break;case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_NEED_BOTH_USER_AND_PASS:t=_T("smsnotify","url_err_need_user_pass");break;case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_TOO_FEW_PARAM:t=_T("smsnotify","url_err_too_few_param");break;case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_TOO_MANY_PARAM:t=_T("smsnotify","url_err_too_many_param");break;case SYNO.SDS.AdminCenter.Notification.SMS_URL_ERR_DUPLICATED_TYPE:t=_T("smsnotify","url_err_duplicated_type");break;default:t="Unknown return type ("+e+")"}this.getMsgBox().alert(_T("smsnotify","provider_new"),t)},createTemplate:function(){return new Promise((e,t)=>{var i=[],s=0,n="",o="";this.headerString="",this.paramString="";for(var a={},r=SYNO.SDS.AdminCenter.Notification,l=0;ls&&t(r.SMS_URL_ERR_TOO_FEW_PARAM),e()})},checkParams:function(e){var t=SYNO.SDS.AdminCenter.Notification;return t.SMS_PARAM_TAG_PHONE===e?t.SMS_PARAM_TYPE_PHONE:t.SMS_PARAM_TAG_MSG===e?t.SMS_PARAM_TYPE_MSG:t.SMS_PARAM_TAG_USER===e?t.SMS_PARAM_TYPE_USER:t.SMS_PARAM_TAG_PASSWORD===e?t.SMS_PARAM_TYPE_PASSWORD:t.SMS_PARAM_TAG_API_KEY===e?t.SMS_PARAM_TYPE_API_KEY:t.SMS_PARAM_TAG_SENDER===e?t.SMS_PARAM_TYPE_SENDER:t.SMS_PARAM_TYPE_OTHER},processApplyAction:function(){var e=this.isEditAction?"set":"create",t=this.getStep("step_1").getForm(),i=t.findField("url").getValue(),s=t.findField("req_method").getValue().getInputValue(),n={provider_name:t.findField("provider_name").getValue(),url:i,template:this.providerTemplate,sep_char:this.providerSepChar,req_header:this.headerString,req_param:this.paramString,req_method:s,api_key:this.apikey};"set"==e&&Ext.apply(n,{provider_id:this.smsProvider}),this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({api:"SYNO.Core.Notification.SMS.Provider",version:2,method:e,params:n,scope:this,callback:function(e,t){if(!e)return this.clearStatusBusy(),this.setStatusError(),void this.getMsgBox().alert(_T("tree","leaf_smsnotify"),4634===t.code?SYNO.API.Errors.core[t.code]:_T("error","error_unable_conduct_setting"));this.parentModule.queryProviderInfo(),this.parentModule.form.findField("provider_name").setValue(t.provider_id),this.parentModule.form.findField("provider_name").fireEvent("select"),this.close()}})}}),SYNO.SDS.AdminCenter.Notification.onClickSmsUrlHowTo=function(){return SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/system_notification_sms.html"},!1),!1},Ext.define("SYNO.SDS.AdminCenter.Notification.SMSRequestEditor",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.recId=e.recId,this.origParam=e.param,this.origValue=e.value,this.type=e.type;var t={title:_T("smsnotify","header_edit_param"),width:400,height:205,resizable:!1,autoScroll:!1,layout:"fit",items:[this.getFormConfig()],buttons:[{xtype:"syno_button",text:_T("common","close"),scope:this,handler:this.onClickCancel},{xtype:"syno_button",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",text:_T("common","save"),btnStyle:"blue",scope:this,handler:this.onClickSave}],listeners:{scope:this,afterrender:this.onAfterrender}};Ext.apply(t,e),this.callParent([t])},onAfterrender:function(){var e=this.items.get("editorForm").getForm(),t=e.findField("param"),i=e.findField("value");this.origParam&&t.setValue(this.origParam),this.origValue&&i.setValue(this.origValue)},onClickSave:function(){var e=this.items.get("editorForm").getForm(),t=e.findField("param").getValue(),i=e.findField("value").getValue();if(!e.isValid())return!1;this.fireEvent("save_param",this.origParam,this.origValue,t,i,this.recId,this.type),this.close()},onClickCancel:function(){this.close()},getFormConfig:function(){return{xtype:"syno_formpanel",itemId:"editorForm",border:!1,trackResetOnLoad:!0,labelWidth:100,autoFlexcroll:!0,minButtonWidth:30,items:[{xtype:"syno_textfield",name:"param",width:230,emptyText:"",fieldLabel:_T("smsnotify","request_parameter"),allowBlank:!1,maxLength:32},{xtype:"syno_textfield",name:"value",width:230,emptyText:"",fieldLabel:_T("smsnotify","request_value"),allowBlank:!0,maxLength:256}]}}}),Ext.define("SYNO.SDS.AdminCenter.Notification.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.appWin=e.appWin,this.callParent(arguments),this.createPanel()},createPanel:function(){this.panel=new SYNO.SDS.AdminCenter.Notification.TabPanel({module:this})},getPanel:function(){return this.panel},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"mailSettingTab":return"AdminCenter/system_notification_email.html";case"smsSettingTab":return"AdminCenter/system_notification_sms.html";case"pushSettingTab":return"AdminCenter/system_notification_pushservice.html";case"filterTab":return"AdminCenter/system_notification_filter.html";default:return"AdminCenter/system_notification_desc.html"}},setActivateParams:function(e){if(e&&e.tab){this.panel.setActiveTab(e.tab);var t=this.panel.getItem(e.tab);t&&e.evt&&t.fireEvent(e.evt.name,e.evt.args)}},activate:function(e){return this.setActivateParams(e),this.panel.loadAllForm(),!0},deactivate:function(){return!(this.panel.mailSettingPanel.isDirty()||this.panel.smsSettingPanel.isDirty()||this.panel.pushSettingPanel.isDirty()||this.panel.filterPanel._$vueInst.isDirty())&&(Ext.isFunction(this.panel.pushSettingPanel.pollingMailStatusStop)&&this.panel.pushSettingPanel.pollingMailStatusStop(),!0)},confirmLostChangeSave:function(){return new Promise(function(e,t){this.panel.applyHandler(),this.confirmSaveLostResolve=e,this.confirmSaveLostReject=t}.bind(this))},confirmLostChangeDontSave:function(){},confirmLostChangeCancel:function(){}}),Ext.define("SYNO.SDS.AdminCenter.Notification.TabPanel",{extend:"SYNO.SDS.Utils.TabPanel",constructor:function(e){var t;this.module=e.module,this.support_oauth=this.module.appWin._S("version")>4994,t=Ext.apply({activeTab:0,cls:"syno-sds-cp-notification",items:[this.mailSettingPanel=new SYNO.SDS.AdminCenter.Notification.MailSettingPanel({module:this.module}),this.smsSettingPanel=new SYNO.SDS.AdminCenter.Notification.SMSSettingPanel({module:this.module}),this.pushSettingPanel=new SYNO.SDS.AdminCenter.Notification.PushSettingPanel({module:this.module}),this.filterPanel=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.AdminCenter.Notification.FilterPanel,title:_T("notification","notification_filter"),appWindow:this.module.appWin,owner:this,module:this})],useDefaultBtn:!0,listeners:{beforetabchange:function(e,t,i){if(!i||!i.form||i.form.isValid())return i&&this.filterPanel._$vueInst&&this.isAnyFormDirty()?(this.module.appWin.confirmLostChangePromise({save:()=>{this.applyHandler()},dontSave:()=>{this.resetAllForm()},cancel:()=>!1},this),!1):void 0},tabchange:function(e,t){t&&t.activate&&t.activate()}}},e),this.callParent([t])},onApiSuccess:function(e,t,i){"set"===e&&(t.has_fail?(this.module.confirmSaveLostReject&&this.module.confirmSaveLostReject(),this.setErrorMsg(t.result)):(this.module.confirmSaveLostResolve&&this.module.confirmSaveLostResolve(),this.setStatusOK())),this.processReturnData(e,t,i)},setErrorMsg:function(e){for(var t=_T("common","commfail"),i=0;i "+_T("status","status_need_reboot")+" ",hidden:!this.needReboot,htmlEncode:!1}),e},onBeforeRequest:function(e){if(this.webapi.methods.set!==e)return!0;var t=this.parent.getForm().findField("enable_zram");if(!this.confirmSetZram&&this.enableZram!=t.getValue()){SYNO.Debug("enable_zram changed");var i=!0===_S("ha_running")?SYNO.SDS.HA.T("ui","confirm_reboot_cluster"):_T("zram","zram_confirm");return this.module.appWin.getMsgBox().confirm(this.title,i,function(e){"yes"===e?(this.confirmSetZram=!0,this.module.panel.applyAllForm(),this.confirmSetZram=!1,this.setNeedRebootState()):t.setValue(this.enableZram)},this),!1}return!0},processReturnData:function(e,t,i){for(var s={api:this.webapi.api,method:this.webapi.methods.get,version:this.webapi.version},n=0;n{1}',_TT("SYNO.SDS.HA.Instance","ui","ha_not_support_setting"),_T("rcpower","rcpower_title")):_T("rcpower","rcpower_title"),items:this.getItemList()},e),SYNO.LayoutConfig.fill(t),this.callParent([t])},getItemList:function(){var e=[];if("yes"==this._D("supportrcpower")&&e.push({xtype:"syno_checkbox",name:"rc_power_config",disabled:!0,id:this.rcPowerBlockcheckboxId=Ext.id(),boxLabel:_T("rcpower","rcpower_config")}),"yes"===this._D("support_wol")&&"no"===this._D("support_wol_but_not_enable_ui","no")){for(var t=parseInt(this._D("maxlanport"),10)||1,i=1;i<=t;i++){var s=1===t?String.format(_T("network","wol_single_enable")):String.format(_T("network","wol_mulitple_enable"),SYNO.SDS.Utils.Network.idToString("eth"+(i-1)));e.push({xtype:"syno_checkbox",name:"wol"+i,boxLabel:s,disabled:_S("ha_running"),hideLabel:!0,hidden:!0,listeners:{scope:this,check:this.WOLChange}})}if("yes"===this._D("support_oob_ctl")){var n=(parseInt(this._D("oob_interface").replace("eth",""),10)||-1)+1;if(0!==n){var o=String.format(_T("network","wol_mulitple_enable"),SYNO.SDS.Utils.Network.idToString(this._D("oob_interface")));e.push({xtype:"syno_checkbox",name:"wol"+n,boxLabel:o,disabled:_S("ha_running"),hideLabel:!0,hidden:!0,listeners:{scope:this,check:this.WOLChange}})}}}return"yes"===this._D("supportrcpower")&&"yes"===this._D("support_wol")&&"no"===this._D("support_dual_head","no")&&e.push({xtype:"syno_displayfield",htmlEncode:!1,id:this.noteId=Ext.id(),value:''+_T("common","note")+_T("common","colon")+" "+_T("rcpower","wol_note")}),e},WOLChange:function(e,t,i,s){for(var n=parseInt(this._D("maxlanport"),10)||1,o=!1,a=1;a<=n&&!0!==(o=this.parent.getForm().findField("wol"+a).getValue());a++);if("yes"===this._D("support_oob_ctl")){var r=(parseInt(this._D("oob_interface").replace("eth",""),10)||-1)+1;0!==r&&!1===o&&(o=this.parent.getForm().findField("wol"+r).getValue())}this.ownerCt.ownerCt.HibernationTab&&this.ownerCt.ownerCt.HibernationTab.updateAutoPoweroff("wol",o),"yes"===this._D("supportrcpower")&&Ext.getCmp(this.rcPowerBlockcheckboxId).isValid()&&(0'+i+""),this.setBeepReason(t+i)},setBeepReason:function(e){var t=Ext.getCmp(this.beepReasonId);t.setValue(e),t.originalValue=t.getValue()},updateBeepControl:function(e,t){if(e&&t&&t.data){var i=function(e,t){SYNO.ux.Utils.displayFormField(e,t,!1),e.findField(t).disable()},s=this.parent.getForm(),n=t.data;n.support_fan_fail||i(s,"fan_fail"),n.support_volume_crash||i(s,"volume_crash"),n.support_volume_or_cache_crash||i(s,"volume_or_cache_crash"),n.support_sas_link_fail||i(s,"sas_link_fail"),n.support_poweron_beep||i(s,"poweron_beep"),n.support_poweroff_beep||i(s,"poweroff_beep"),n.support_reset_beep||i(s,"reset_beep"),n.support_enc_module_fail||i(s,"enc_module_fail"),n.support_redundant_power_fail||i(s,"redundant_power_fail"),n.support_eunit_redundant_power_fail||i(s,"eunit_redundant_power_fail"),this.updateBeepReason(t.data)}},onBeepOff:function(){var e=Ext.getCmp(this.btnBeepOffId);this.module.appWin.sendWebAPI({api:"SYNO.Core.Hardware.BeepControl",method:"stop_beep",params:{},version:1,callback:function(t,i,s,n){t?(e.disable(),this.setBeepReason(_T("beep","beep_reason")+" "+_T("common","none"))):this.module.appWin.getMsgBox().alert(_T("volume","volume_beepoff"),_T("volume","volume_beepoff")+": "+SYNO.API.getErrorString(i.code))},scope:this})}}),Ext.ns("SYNO.SDS.AdminCenter.HardwareControl"),Ext.define("SYNO.SDS.AdminCenter.HardwareControl.GeneralTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.mainPanelFieldSets=[],this.module=e.module;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){this.settingFormList=[],this._D("support_release_transcoding_memory")?this.settingFormList.push({id:"video_transcoding",name:"_video_transcoding_",api:"SYNO.Core.Hardware.VideoTranscoding"}):"synology_monaco_ds216play"===this._D("unique")&&this.settingFormList.push({id:"memory_layout",name:"_memory_layout_",api:"SYNO.Core.Hardware.MemoryLayout"}),"yes"===this._D("support_zram")&&"no"!==this._D("disk_swap")&&this.settingFormList.push({id:"zram",name:_T("zram","zram"),api:"SYNO.Core.Hardware.ZRAM"}),"no"!==this._D("support_dual_head","no")||"yes"!==this._D("supportrcpower")&&"yes"!==this._D("support_wol")||_S("ha_hide_hw_setting")||this.settingFormList.push({id:"recovery",name:_T("rcpower","rcpower_title"),api:"SYNO.Core.Hardware.PowerRecovery"}),"yes"===this._D("support_buzzer")&&this.settingFormList.push({id:"beepcontrol",name:_T("beep","beep_title"),api:"SYNO.Core.Hardware.BeepControl"}),"yes"===this._D("support_fan")&&this.settingFormList.push({id:"fanspeed",name:_T("rcpower","rcfancontrol_desc"),api:"SYNO.Core.Hardware.FanSpeed"}),"yes"===this._D("support_led_brightness_adjustment")&&this.settingFormList.push({id:"ledBrightness",name:_T("led_brightness","led_brightness_desc"),api:"SYNO.Core.Hardware.Led.Brightness"});var t=0;for(t=0;t'+_T("common","note")+_T("common","colon")+" "+_T("rcpower","schpoweron_note"));break;case"off":t=''+_T("common","note")+_T("common","colon")+" "+_T("rcpower","schpoweroff_note");break;default:t=""}Ext.getCmp(this.noteId).setValue(t)}}),Ext.ns("SYNO.SDS.AdminCenter.HardwareControl"),SYNO.SDS.AdminCenter.HardwareControl.MAX_POWER_SCHEDULE_TASKS=200,Ext.define("SYNO.SDS.AdminCenter.HardwareControl.ScheduleTab",{extend:"SYNO.SDS.Utils.FormPanel",panel:null,constructor:function(e){var t,i=this;i.owner=e.owner,i.module=e.module,t=i.fillConfig(e),i.callParent([t]),i.getForm().items.items.push(i.panel)},fillConfig:function(e){this.panel=new SYNO.SDS.AdminCenter.HardwareControl.ScheduleTabGrid({module:this.module,formPanel:this});var t={title:_T("rcpower","power_schedule"),layout:"fit",style:{paddingLeft:"0px",paddingRight:"0px"},items:this.panel};return Ext.apply(t,e),t},isDirty:function(){return this.panel.isDirty()},getHelpParam:function(){return this.panel.getHelpParam()}}),Ext.define("SYNO.SDS.AdminCenter.HardwareControl.ScheduleTabGrid",{extend:"SYNO.ux.EditorGridPanel",taskAddOrRemoved:!1,constructor:function(e){var t;this.formPanel=e.formPanel,this.module=e.module,this.taskData=null,t={autoScroll:!0,webapi:{api:"SYNO.Core.Hardware.PowerSchedule",methods:{get:"load",set:"save"},version:1}},this.isSupportAutoPowerOn="yes"===this._D("support_auto_poweron"),Ext.apply(t,e),t=this.fillConfig(t),this.callParent([t]),this.mon(this.getSelectionModel(),"selectionchange",this.onChgButtonStatus,this,{buffer:50}),this.mon(this.getStore(),"update",this.onChgButtonStatus,this),this.mon(this.getStore(),"remove",function(e,t,i){this.taskAddOrRemoved=!0,this.onChgButtonStatus()},this),this.mon(this.getStore(),"add",function(e,t,i){this.taskAddOrRemoved=!0,this.onChgButtonStatus()},this),this.mon(this,"celldblclick",function(e,t,i,s){this.openTaskDialog("edit")},this)},fillConfig:function(e){var t=new Ext.data.ArrayStore({autoDestroy:!0,fields:["enabled","triggertime","action"],data:[]}),i={header:_T("common","enabled"),dataIndex:"enabled",width:80,menuDisabled:!0,align:"center"},s=new SYNO.ux.EnableColumn(i),n=new SYNO.ux.ComboBox({store:new Ext.data.ArrayStore({fields:["value","display"],data:[["on",_T("system","poweron_opt")],["off",_T("system","poweroff_opt")]]}),lazyRender:!0,mode:"local",displayField:"display",valueField:"value",triggerAction:"all",editable:!1}),o={ds:t,cm:new Ext.grid.ColumnModel([s,{width:150,header:_T("rcpower","trigger_time"),dataIndex:"triggertime",sortable:!0,scope:this,renderer:function(e,t){var i=e.split(":");return String.format("{0} {1}:{2}",function(e){var t="",i=[];return"0,1,2,3,4,5,6"==e?t=_T("schedule","schedule_daily"):"0,6"==e?t=_T("schedule","schedule_weekend"):"1,2,3,4,5"==e?t=_T("schedule","schedule_weekdays"):(i=(t=(t=(t=(t=(t=(t=(t=(t=e).replace("0",_T("schedule","schedule_sun"))).replace("1",_T("schedule","schedule_mon"))).replace("2",_T("schedule","schedule_tue"))).replace("3",_T("schedule","schedule_wed"))).replace("4",_T("schedule","schedule_thu"))).replace("5",_T("schedule","schedule_fri"))).replace("6",_T("schedule","schedule_sat"))).split(","),t=i.join(", ")),t}(i[0]),i[1],this.convert2Digits(i[2]))}},{header:_T("rcpower","action"),dataIndex:"action",sortable:!0,renderer:function(e,t){return"on"==e?_T("system","poweron_opt"):_T("system","poweroff_opt")},editable:this.isSupportAutoPowerOn,editor:n,scope:this,width:100}]),loadMask:!1,hideMode:"offsets",enableHdMenu:!1,cls:"without-dirty-red-grid sm-test-schedule-tctab hc-toolbar-without-border-bottom",selModel:new Ext.grid.RowSelectionModel({singleSelect:!1}),plugins:[s],tbar:this.configTopToolbar(),style:{paddingTop:"0px"},listeners:{cellclick:{delay:100,fn:function(e,t,i,s){2==i&&e.startEditing(t,2)}},rowcontextmenu:this.onRowCtxMenu,containercontextmenu:this.showCtxMenu,scope:this}};return SYNO.LayoutConfig.fill(Ext.apply(o,e))},configTopToolbar:function(){return this.actionCreate=new Ext.Action({text:_T("common","create"),itemId:"create",scope:this,handler:function(e,t){this.openTaskDialog("add")}}),this.actionEdit=new Ext.Action({text:_T("common","alt_edit"),itemId:"edit",scope:this,handler:function(e,t){this.openTaskDialog("edit")}}),this.actionDel=new Ext.Action({text:_T("common","delete"),itemId:"delete",scope:this,handler:function(){for(var e=this.getSelectionModel().getSelections(),t=this.getStore(),i=0;i0?s.enable():s.disable()},isScheduleModified:function(){return"yes"===this._D("support_power_schedule")&&!!(this.getStore().getModifiedRecords().length>0||this.taskAddOrRemoved)},handlerChgTasks:function(e){e.commitChanges(),e.fireEvent("update",e,e.getModifiedRecords(),Ext.data.Record.EDIT)},getSubmitData:function(){for(var e=this.getStore(),t=[],i=[],s=0;se?"0"+e:e};return this.colModel=new Ext.grid.ColumnModel([new SYNO.ux.EnableColumn({header:_T("common","enabled"),width:80,align:"center",menuDisabled:!0,id:"enabled",dataIndex:"enabled"}),{header:_T("rcpower","trigger_time"),width:150,align:"center",menuDisabled:!0,renderer:function(t,i,s){return String.format("{0} {1}:{2}",(n=s.get("weekdays"),"0,1,2,3,4,5,6"===(o=n.sort().join(","))?_T("schedule","schedule_daily"):"0,6"===o?_T("schedule","schedule_weekend"):"1,2,3,4,5"===o?_T("schedule","schedule_weekdays"):o=(o=(o=(o=(o=(o=(o=o.replace("0",_T("schedule","schedule_sun"))).replace("1",_T("schedule","schedule_mon"))).replace("2",_T("schedule","schedule_tue"))).replace("3",_T("schedule","schedule_wed"))).replace("4",_T("schedule","schedule_thu"))).replace("5",_T("schedule","schedule_fri"))).replace("6",_T("schedule","schedule_sat"))),e(s.get("hour")),e(s.get("minute")));var n,o},scope:this},{header:_T("rcpower","action"),width:100,align:"center",sortable:!0,dataIndex:"action",renderer:function(e){return _T("schedule","dcoutput_"+e)||e.toUpperCase()},scope:this}]),this.colModel},fillConfig:function(){return SYNO.LayoutConfig.fill({title:_T("schedule","dcoutput_title")||"DC Output",autoScroll:!0,loadMask:!0,hideMode:"offsets",cls:"without-dirty-red-grid",ds:this.getStore(),cm:this.getColumnModel(),plugins:[this.getColumnModel().getColumnById("enabled")],selModel:new Ext.grid.RowSelectionModel({singleSelect:!1}),tbar:[{xtype:"syno_button",text:_T("common","create"),itemId:"create",scope:this,handler:function(e,t){this.openTaskDialog("create")}},{xtype:"syno_button",text:_T("common","alt_edit"),itemId:"edit",disabled:!0,scope:this,handler:function(e,t){this.openTaskDialog("edit")}},{xtype:"syno_button",text:_T("common","delete"),itemId:"delete",disabled:!0,scope:this,handler:function(e,t){this.deleteHandler()}},{xtype:"syno_button",disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",text:_T("common","save"),itemId:"save",scope:this,handler:this.saveTasks}]})},deleteHandler:function(){Ext.each(this.getSelectionModel().getSelections(),function(e){this.store.remove(e),this.updateEditStatus("delete",e.get("task_id"))},this)},resetEditStatus:function(){this.nextTaskId=-1,this.createTasks=[],this.deleteTasks=[],this.store.commitChanges(),this.updateButtons()},updateEditStatus:function(e,t){if("create"===e)this.createTasks.push(t),this.nextTaskId=t-1;else if("delete"===e)if(00)return e=!0,!1}),0'+_T("dcoutput","dcoutput_status_on")+"",hidden:!0},{xtype:"syno_displayfield",name:"status_off",htmlEncode:!1,value:_T("dcoutput","dcoutput_status_title")+': '+_T("dcoutput","dcoutput_status_off")+"",hidden:!0}]})},processReturnData:function(e,t,i){var s={api:"SYNO.Core.Hardware.DCOutput",method:"get",version:1};Ext.each(t.result,function(e){if(e.success&&SYNO.ux.Utils.checkApiConsistency(s,e)){var t=this.getForm();"on"===e.data.status?(t.findField("status_on").show(),t.findField("status_off").hide()):(t.findField("status_on").hide(),t.findField("status_off").show())}},this),this.callParent(arguments)},openScheduleDialog:function(){new SYNO.SDS.AdminCenter.HardwareControl.DCOutputDialog({module:this.module,owner:this.findAppWindow()}).open()},getHelpParam:function(){return"AdminCenter/system_hardware_dc_output.html"}}),Ext.ns("SYNO.SDS.AdminCenter.HardwareControl"),Ext.define("SYNO.SDS.AdminCenter.HardwareControl.HibernationTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module;var t=this.fillConfig(e);this.callParent([t]),this.on("activate",function(){_S("ha_running")&&this.el.mask(_TT("SYNO.SDS.HA.Instance","ui","ha_not_support_setting"),"syno-ux-mask-info")},this),this.on("deactivate",function(){_S("ha_running")&&this.el.unmask()},this)},fillConfig:function(e){var t={title:0<=this._D("unique").indexOf("qoriq")?_T("hibernation","hibernation_title"):_T("helptoc","power_hibernation"),autoScroll:!0,webapi:{api:"SYNO.Core.Hardware.Hibernation",methods:{get:"get",set:"set"},version:1},labelWidth:250,items:this.getItemList()};return Ext.apply(t,e),SYNO.LayoutConfig.fill(t)},getItemList:function(){var e=[];return this.getSATASleepCfg(e),e.push({xtype:"syno_checkbox",name:"eunit_deep_sleep",boxLabel:_T("hddsleep","eunit_deep_sleep_subject"),id:this.eunitDeepSleepBtnId=Ext.id(),disabled:!0,hideLabel:!0,hidden:!0}),e.push({xtype:"syno_displayfield",fieldLabel:_T("hddsleep","hddsleep_not_support"),value:"",id:this.incompatibleId=Ext.id(),hidden:!1}),e.push({xtype:"syno_displayfield",value:_T("hddsleep","usb_hddsleep_desc")}),e.push({xtype:"syno_combobox",name:"usb_idletime",id:this.usbIdleTimeComboId=Ext.id(),disabled:_S("ha_running"),fieldLabel:_T("time","time_time"),store:this.getUSBSleepStore(),displayField:"display",valueField:"value",width:200,listeners:{scope:this,select:this.onUSBIdleTimeSelect}}),e.push({xtype:"syno_displayfield",value:_T("hddsleep","hdd_wakeup_log_desc")}),e.push({xtype:"syno_checkbox",name:"enable_log",boxLabel:_T("hddsleep","hdd_wakeup_log_subject"),id:this.wakeUpLogCheckBoxId=Ext.id(),disabled:!0,hideLabel:!0}),this.getAutoPoweroffCfg(e),e},getSATASleepCfg:function(e){e.push({xtype:"syno_displayfield",value:_T("hddsleep","hddsleep_desc"),id:this.hddSleepDesc=Ext.id(),hidden:!0}),e.push({xtype:"syno_combobox",name:"internal_hd_idletime",id:this.hddIdleTimeComboId=Ext.id(),disabled:_S("ha_running"),fieldLabel:_T("time","time_time"),store:this.getHDDSleepStore(),displayField:"display",valueField:"value",width:200,hidden:!0,listeners:{scope:this,select:this.onHDDIdleTimeSelect}}),"yes"===this._D("sata_deep_sleep_en")&&(e.push({xtype:"syno_checkbox",name:"sata_deep_sleep",boxLabel:0<=this._D("unique").indexOf("qoriq")?_T("hibernation","hibernation_system_deepsleep_statement"):String.format(_T("hddsleep","sata_deep_sleep_subject"),this._D("upnpmodelname")),id:this.sataDeepSleepBtnId=Ext.id(),disabled:!0,hideLabel:!0,hidden:!0,listeners:{scope:this,check:function(e,t){t?Ext.getCmp(this.ignoreNetbiosBroadcastCheckBoxId).enable():Ext.getCmp(this.ignoreNetbiosBroadcastCheckBoxId).disable()},enable:function(e){var t=Ext.getCmp(this.ignoreNetbiosBroadcastCheckBoxId);e.getValue()?t.enable():t.disable()},disable:function(){Ext.getCmp(this.ignoreNetbiosBroadcastCheckBoxId).disable()}}}),e.push({xtype:"syno_checkbox",name:"ignore_netbios_broadcast",boxLabel:_T("hibernation","hibernation_ignore_netbios_broadcast"),id:this.ignoreNetbiosBroadcastCheckBoxId=Ext.id(),disabled:!0,hideLabel:!0,hidden:!0}))},getAutoPoweroffCfg:function(e){this.isSupportAutoPoweroff()&&(e.push({xtype:"syno_displayfield",itemId:"autopoweroffNoteId",hideLabel:!0,htmlEncode:!1,value:String.format(_T("autopoweroff","autopoweroff_desc"),''+_T("autopoweroff","str_autopoweroff_wol")+""),listeners:{render:function(e){var t=e.el.first("a");t&&this.mon(t,"click",function(e){e.preventDefault(),SYNO.SDS.AdminCenter.HardwareControl.HibernationTab.Utils.onClickShareUrl(this.module.appWin)},this)},scope:this,single:!0,buffer:80}}),e.push({xtype:"syno_checkbox",name:"auto_poweroff_enable",boxLabel:_T("autopoweroff","autopoweroff_service"),id:this.autoPoweroffCheckBoxId=Ext.id(),disabled:!0,hideLabel:!0,listeners:{scope:this,check:function(e,t){var i=Ext.getCmp(this.autoPoweroffComboBoxId);t?(i.enable(),i.setValue(10)):i.disable()}}}),e.push({xtype:"syno_combobox",name:"auto_poweroff_time",id:this.autoPoweroffComboBoxId=Ext.id(),disabled:!0,fieldLabel:_T("time","time_time"),store:this.getAutoPoweroffStore(),displayField:"display",valueField:"value",width:200}))},getHDDSleepStore:function(){return new Ext.data.SimpleStore({fields:["value","display"],data:[[0,_T("hddsleep","hddsleep_none")],[10,"10 "+_T("hddsleep","hddsleep_min")],[15,"15 "+_T("hddsleep","hddsleep_min")],[20,"20 "+_T("hddsleep","hddsleep_min")],[30,"30 "+_T("hddsleep","hddsleep_min")],[60,"1 "+_T("hddsleep","hddsleep_hour")],[120,"2 "+_T("hddsleep","hddsleep_hours")],[180,"3 "+_T("hddsleep","hddsleep_hours")],[240,"4 "+_T("hddsleep","hddsleep_hours")],[300,"5 "+_T("hddsleep","hddsleep_hours")]]})},getUSBSleepStore:function(){return new Ext.data.SimpleStore({fields:["value","display"],data:[[0,_T("hddsleep","hddsleep_none")],[10,"10 "+_T("hddsleep","hddsleep_min")],[15,"15 "+_T("hddsleep","hddsleep_min")],[20,"20 "+_T("hddsleep","hddsleep_min")],[30,"30 "+_T("hddsleep","hddsleep_min")],[60,"1 "+_T("hddsleep","hddsleep_hour")],[120,"2 "+_T("hddsleep","hddsleep_hours")],[180,"3 "+_T("hddsleep","hddsleep_hours")],[240,"4 "+_T("hddsleep","hddsleep_hours")],[300,"5 "+_T("hddsleep","hddsleep_hours")]]})},getAutoPoweroffStore:function(){return new Ext.data.SimpleStore({fields:["value","display"],data:[[10,"10 "+_T("hddsleep","hddsleep_min")],[15,"15 "+_T("hddsleep","hddsleep_min")],[20,"20 "+_T("hddsleep","hddsleep_min")],[30,"30 "+_T("hddsleep","hddsleep_min")],[60,"1 "+_T("hddsleep","hddsleep_hour")],[120,"2 "+_T("hddsleep","hddsleep_hours")],[180,"3 "+_T("hddsleep","hddsleep_hours")],[240,"4 "+_T("hddsleep","hddsleep_hours")],[300,"5 "+_T("hddsleep","hddsleep_hours")]]})},onHDDIdleTimeSelect:function(e,t,i){var s=t.get("value");"yes"!==this.enable_eunit_deep_sleep||_S("ha_running")||(0!==s&&this.support_eunit_deep_sleep&&"none"===this.eunit_dsleep_blacklist?Ext.getCmp(this.eunitDeepSleepBtnId).enable():(Ext.getCmp(this.eunitDeepSleepBtnId).disable(),Ext.getCmp(this.eunitDeepSleepBtnId).setValue(!1))),"yes"!==this._D("sata_deep_sleep_en")||_S("ha_running")||"none"!==this.sata_dsleep_blacklist||(0!==s?Ext.getCmp(this.sataDeepSleepBtnId).enable():(Ext.getCmp(this.sataDeepSleepBtnId).disable(),Ext.getCmp(this.sataDeepSleepBtnId).setValue(!1))),0!==s||0!==Ext.getCmp(this.usbIdleTimeComboId).getValue()?Ext.getCmp(this.wakeUpLogCheckBoxId).enable():(Ext.getCmp(this.wakeUpLogCheckBoxId).disable(),Ext.getCmp(this.wakeUpLogCheckBoxId).setValue(!1)),0!==s?this.updateAutoPoweroff("internal_hibernation",!0):this.updateAutoPoweroff("internal_hibernation",!1)},onUSBIdleTimeSelect:function(e,t,i){0!==t.get("value")||0!==Ext.getCmp(this.hddIdleTimeComboId).getValue()?Ext.getCmp(this.wakeUpLogCheckBoxId).enable():(Ext.getCmp(this.wakeUpLogCheckBoxId).disable(),Ext.getCmp(this.wakeUpLogCheckBoxId).setValue(!1))},processReturnData:function(e,t,i){this.callParent(arguments);var s,n,o,a,r={api:this.webapi.api,method:this.webapi.methods.get,version:this.webapi.version};for(n=0;nthis._D("unique").indexOf("qoriq")?Ext.getCmp(this.ignoreNetbiosBroadcastCheckBoxId).setVisible(!1):Ext.getCmp(this.ignoreNetbiosBroadcastCheckBoxId).setVisible(!0)))},updateDeepSleepControl:function(e,t){if(this.enable_eunit_deep_sleep=t.data.enable_eunit_deep_sleep,this.eunit_dsleep_blacklist=t.data.eunit_dsleep_blacklist,this.sata_dsleep_blacklist=t.data.sata_dsleep_blacklist,this.support_esata=t.data.support_esata,Ext.QuickTips.init(),"no"!==this.esataSupport)if("yes"===t.data.enable_eunit_deep_sleep){this.support_eunit_deep_sleep=t.data.support_eunit_deep_sleep,Ext.getCmp(this.eunitDeepSleepBtnId).setVisible(!0),t.data.support_eunit_deep_sleep&&t.data.internal_hd_idletime&&"none"===t.data.eunit_dsleep_blacklist?Ext.getCmp(this.eunitDeepSleepBtnId).enable():Ext.getCmp(this.eunitDeepSleepBtnId).disable();var i=Ext.getCmp(this.eunitDeepSleepBtnId).boxlabelEl;if("none"!==t.data.eunit_dsleep_blacklist){var s=String.format(_T("hddsleep","eunit_dsleep_disable_tip"),t.data.eunit_dsleep_blacklist);i&&i.dom.setAttribute("ext:qtip",s)}else if(t.data.support_eunit_deep_sleep)i&&i.dom.getAttribute("ext:qtip")&&i.dom.removeAttribute("ext:qtip");else if(i){var n="";n=t.data.support_eunit_switch_mode?_T("hddsleep","eunit_dsleep_manual_disable_tip"):_T("common","not_support"),i.dom.setAttribute("ext:qtip",n)}}else Ext.getCmp(this.eunitDeepSleepBtnId).setVisible(!1);if("yes"===this._D("sata_deep_sleep_en")){var o=0<=this._D("unique").indexOf("qoriq")?_T("hibernation","hibernation_system_deepsleep_statement").replace("_MODEL_",this._D("upnpmodelname")):String.format(_T("hddsleep","sata_deep_sleep_subject"),this._D("upnpmodelname")),a=Ext.getCmp(this.sataDeepSleepBtnId).boxlabelEl;if(a)if(a.update(o),"none"!==t.data.sata_dsleep_blacklist){var r=String.format(_T("hddsleep","sata_dsleep_disable_tip"),t.data.sata_dsleep_blacklist);a.dom.setAttribute("ext:qtip",r)}else a.dom.getAttribute("ext:qtip")&&a.dom.removeAttribute("ext:qtip");t.data.internal_hd_idletime&&"none"===t.data.sata_dsleep_blacklist?Ext.getCmp(this.sataDeepSleepBtnId).enable():Ext.getCmp(this.sataDeepSleepBtnId).disable()}},updateAutoPoweroff:function(e,t){this.isSupportAutoPoweroff()&&("internal_hibernation"===e?this.internal_hibernation_enable=t:"wol"===e&&(this.wol_enable=t),this.internal_hibernation_enable&&this.wol_enable?Ext.getCmp(this.autoPoweroffCheckBoxId).enable():(Ext.getCmp(this.autoPoweroffCheckBoxId).disable(),Ext.getCmp(this.autoPoweroffCheckBoxId).setValue(!1),Ext.getCmp(this.autoPoweroffComboBoxId).disable()))},getHelpParam:function(){return"AdminCenter/system_hardware_hibernation.html"},isSupportAutoPoweroff:function(){return 0>this._D("unique").indexOf("qoriq")&&0t.onBeforeRequest(...e))},switchLayout:function(){this.getUPSForms().forEach(function(e){e.updateFleXcroll();var t=e.getScrollTarget();t&&t.dom.fleXdata&&e.setHeight(t.dom.fleXdata.cntSize[1])}),this.updateFleXcroll()},isDirty:function(){return!1},isValid:function(){return!0},getValues:function(){return{}},reset:function(){},isHAUpsTabDirty:function(){return this.getUPSForms().some(e=>!!e.checkFormDirty&&e.isFormDirty())}}),Ext.define("SYNO.SDS.AdminCenter.HardwareControl.UPSTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){if(this.module=e.module,"yes"===this._D("supportups")){this.verSupportSNMPV3=4936,this.module=e.module;var t=this.fillConfig(e);this.callParent([t]),this.setEnableService=!1,this.update=!1,this.mode_field=this.getForm().findField("mode"),this.mon(this.getForm().findField("enable"),"check",this.switchLayout,this),this.mon(this.getForm().findField("ACL_enable"),"check",this.switchLayout,this),this.mon(this.getForm().findField("ups_set_safemode_until_lowbatt"),"check",this.switchLayout,this),this.mon(this.getForm().findField("ups_set_safemode_customize_time"),"check",this.switchLayout,this),this.mon(this.getForm().findField("ups_time_unit_list"),"select",this.clearWaittimeInvalid,this),this._S("version")>this.verSupportSNMPV3&&(this.mon(this.getForm().findField("snmp_version"),"select",this.switchLayout,this),this.mon(this.getForm().findField("snmp_auth"),"check",this.setSNMPAuthPrivacy,this),this.mon(this.getForm().findField("snmp_privacy"),"check",this.setSNMPPrivacy,this)),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("mode").getEl(),_T("ups","ups_type_tips")),SYNO.ux.AddTip(this.getForm().findField("ups_safemode_waittime_label").getEl(),_T("ups","ups_safemode_tips")),SYNO.ux.AddTip(this.getForm().findField("shutdown_device").getEl(),_T("ups","ups_shutdown_tips")),SYNO.ux.Utils.setFormItemIndent(this.getForm().findField("ups_safemode_waittime_label"))},this,{single:!0}),this.mode_field.addEvents("ups_type_reset"),this.mode_field.resetOrigin=this.mode_field.reset,this.mode_field.reset=function(){this.resetOrigin(),this.fireEvent("ups_type_reset",this)},this.mon(this.mode_field,"select",this.modeChange,this),this.mon(this.mode_field,"ups_type_reset",this.modeChange,this),this.snmp_ver_field=this.getForm().findField("snmp_version"),this.snmp_ver_field.resetOrigin=this.snmp_ver_field.reset,this.snmp_ver_field.reset=function(){this.resetOrigin(),this.fireEvent("snmp_version_reset",this)},this.mon(this.snmp_ver_field,"snmp_version_reset",this.switchLayout,this);var i={api:"SYNO.Core.ExternalDevice.UPS",version:1,method:"get"};"passive_form"===this.getItemId()&&(i={api:"SYNO.SHA.UPS",version:1,method:"get",params:{remote_api:"SYNO.Core.ExternalDevice.UPS",remote_method:"get",remote_version:1}}),this.UPSPollingConf={interval:5,immediate:!0,webapi:i,status_callback:function(e,t){var i=!1;if("passive_form"===this.getItemId()){if(!e){if(6601===t.code){if(this.disabled)return;SYNO.Debug(t);var s="{0} ({1})({2})",n=String.format(s,this.owner.passive_hostname,_TT("SYNO.SDS.HA.Instance","ui","passive"),_TT("SYNO.SDS.HA.Instance","status","offline"));return this.owner.getComponent("passive_title").setValue(n),void this.setDisabled(!0)}return}this.disabled&&(SYNO.Debug(t),s="{0} ({1})",n=String.format(s,this.owner.passive_hostname,_TT("SYNO.SDS.HA.Instance","ui","passive")),this.owner.getComponent("passive_title").setValue(n),this.setDisabled(!1),i=!0)}(i||this.UPSInfo.mode!=t.mode)&&(this.__processUPSGetInfo(t),this.switchLayout())},scope:this}}},pollingTaskStart:function(){void 0===this.UPSPollingID&&(this.UPSPollingID=this.module.appWin.pollReg(this.UPSPollingConf))},pollingTaskStop:function(){void 0!==this.UPSPollingID&&(this.module.appWin.pollUnreg(this.UPSPollingID),this.UPSPollingID=void 0)},setSNMPAuthPrivacy:function(){!1===this.getForm().findField("snmp_auth").getValue()?this.setCompEnable(["snmp_auth_type","snmp_auth_key","snmp_privacy","snmp_privacy_type","snmp_privacy_key"],!1):(this.setCompEnable(["snmp_auth_type","snmp_auth_key","snmp_privacy"],!0),this.setSNMPPrivacy())},setSNMPPrivacy:function(){!1===this.getForm().findField("snmp_privacy").getValue()?this.setCompEnable(["snmp_privacy_type","snmp_privacy_key"],!1):this.setCompEnable(["snmp_privacy_type","snmp_privacy_key"],!0)},clearWaittimeInvalid:function(){this.getForm().findField("ups_customized_waittime").clearInvalid()},modeChange:function(){this.disabled||(this.processWaitTimeItem(this.getForm().findField("mode").getValue()),this.switchLayout())},switchLayout:function(){if(!this.disabled){var e=this.update?this.getForm().findField("enable").getValue():this.UPSInfo.enable,t=this.update?this.getForm().findField("mode").getValue():this.UPSInfo.mode,i=this.UPSInfo.mode,s=this.update?this.getForm().findField("ACL_enable").getValue():this.UPSInfo.ACL_enable,n=this.getForm().findField("ups_set_safemode_customize_time").getValue();if(this.setFieldVisible(["networkups_choose_hint"],!1),this.setFieldVisible(["usbups_choose_hint"],!1),"USB"===t?(this.setFieldUsed(["ups_set_safemode_until_lowbatt","ups_set_safemode_customize_time","shutdown_device","ACL_enable","mode"],!0),this.setFieldUsed(["net_server_ip","snmp_server_ip","snmp_version","snmp_community","snmp_mib","ups_set_safemode_same_as_server"],!1),this.setFieldUsed(["snmp_user","snmp_auth","snmp_auth_type","snmp_auth_key","snmp_privacy","snmp_privacy_type","snmp_privacy_key"],!1),this.getForm().findField("mode").enable(),this.getComponent("ups_waittime").enable(),this.getComponent("ACL_list_btn").setVisible(!0)):"SNMP"===t?(this.setFieldUsed(["mode","ups_set_safemode_until_lowbatt","ups_set_safemode_customize_time","snmp_server_ip","snmp_version","snmp_community","snmp_mib","ACL_enable"],!0),this.setFieldUsed(["shutdown_device","net_server_ip","ups_set_safemode_same_as_server"],!1),this.getComponent("ups_waittime").enable(),this.getComponent("ACL_list_btn").setVisible(!0),"yes"===this._D("support_xa","no")&&(this.setFieldAndOriginalValues(this.getForm().findField("shutdown_device"),!1),this.setFieldUsed(["ACL_enable"],!1),this.getComponent("ACL_list_btn").setVisible(!1)),this._S("version")>this.verSupportSNMPV3&&("v3"===this.getForm().findField("snmp_version").getValue()?(this.setFieldUsed(["snmp_user","snmp_auth","snmp_auth_type","snmp_auth_key","snmp_privacy","snmp_privacy_type","snmp_privacy_key"],!0),this.setFieldUsed(["snmp_community"],!1),this.setSNMPAuthPrivacy()):(this.setFieldUsed(["snmp_user","snmp_auth","snmp_auth_type","snmp_auth_key","snmp_privacy","snmp_privacy_type","snmp_privacy_key"],!1),this.setFieldUsed(["snmp_community"],!0)),""===this.UPSInfo.snmp_auth_type&&this.getForm().findField("snmp_auth_type").setValue("MD5"),""===this.UPSInfo.snmp_privacy_type&&this.getForm().findField("snmp_privacy_type").setValue("DES"),this.doLayout())):"SLAVE"===t&&(this.setFieldUsed(["mode","ups_set_safemode_customize_time","net_server_ip","ups_set_safemode_same_as_server"],!0),this.setFieldUsed(["shutdown_device","ACL_enable","snmp_server_ip","snmp_version","snmp_community","snmp_mib"],!1),this.setFieldUsed(["snmp_user","snmp_auth","snmp_auth_type","snmp_auth_key","snmp_privacy","snmp_privacy_type","snmp_privacy_key","ups_set_safemode_until_lowbatt"],!1),this.getComponent("ups_waittime").enable(),this.getComponent("ACL_list_btn").setVisible(!1),"localhost"===this.getForm().findField("net_server_ip").getValue()&&this.getForm().findField("net_server_ip").setValue("")),n?this.getComponent("ups_waittime").enable():this.getComponent("ups_waittime").disable(),s&&"no"===this._D("support_xa","no")?this.getComponent("ACL_list_btn").enable():this.getComponent("ACL_list_btn").disable(),!e)return this.setCompEnable(["mode","shutdown_device","net_server_ip","snmp_server_ip","snmp_version","snmp_community","snmp_mib","snmp_user","snmp_auth","snmp_auth_type","snmp_auth_key","snmp_privacy","snmp_privacy_type","snmp_privacy_key","ACL_list_btn","ACL_enable","ups_waittime","ups_set_safemode_until_lowbatt","ups_set_safemode_customize_time","ups_set_safemode_same_as_server"],!1),this.UPSInfo.usb_ups_connect?(this.setFieldVisible(["no_ups_message"],!1),this.setFieldVisible(["usb_ups_connect_msg"],!0)):(this.setFieldVisible(["no_ups_message"],!0),this.setFieldVisible(["usb_ups_connect_msg"],!1)),this.setFieldVisible(["networkups_noconn"],!1),void this.getComponent("device_info").setVisible(!1);"USB"==t||t==i&&this.UPSInfo.enable?(this.setFieldVisible(["no_ups_message"],!1),this.setFieldVisible(["usb_ups_connect_msg"],!1),void 0!==this.UPSInfo.manufacture&&""!==this.UPSInfo.manufacture?(this.setFieldVisible(["networkups_noconn"],!1),this.getComponent("device_info").setVisible(!0)):(this.setFieldVisible(["networkups_noconn"],!0),this.getComponent("device_info").setVisible(!1))):(this.UPSInfo.usb_ups_connect?(this.setFieldVisible(["no_ups_message"],!1),this.setFieldVisible(["usb_ups_connect_msg"],!0)):(this.setFieldVisible(["no_ups_message"],!0),this.setFieldVisible(["usb_ups_connect_msg"],!1)),this.setFieldVisible(["networkups_noconn"],!1),this.getComponent("device_info").setVisible(!1)),"USB"==t&&"USB"!=i?(this.setFieldVisible(["networkups_choose_hint"],!0),this.setFieldVisible(["networkups_noconn"],!1),this.getComponent("ups_waittime").disable(),this.getComponent("ups_set_safemode_until_lowbatt").disable(),this.getComponent("ups_set_safemode_customize_time").disable(),this.getComponent("ACL_enable").disable(),this.getComponent("shutdown_device").disable(),this.setCompEnable(["ups_waittime","ups_set_safemode_same_as_server","ups_set_safemode_until_lowbatt","ups_set_safemode_customize_time","ACL_enable","shutdown_device"],!1)):this.setFieldVisible(["networkups_choose_hint"],!1),"USB"!=t&&"USB"==i?(this.setFieldVisible(["usbups_choose_hint"],!0),this.setFieldVisible(["networkups_noconn"],!1),this.getComponent("ups_waittime").disable(),this.setCompEnable(["ups_waittime","ups_set_safemode_same_as_server","ups_set_safemode_until_lowbatt","ups_set_safemode_customize_time","shutdown_device","net_server_ip","snmp_server_ip","snmp_version","snmp_community","snmp_mib","snmp_user","snmp_auth","snmp_auth_type","snmp_auth_key","snmp_privacy","snmp_privacy_type","snmp_privacy_key","ACL_list_btn","ACL_enable"],!1),e&&this.setFieldVisible(["usb_ups_connect_msg"],!1)):this.setFieldVisible(["usbups_choose_hint"],!1),i!=t&&this.getComponent("device_info").setVisible(!1),this.doLayout()}},getHelpParam:function(){return"AdminCenter/system_hardware_ups.html"},setFieldUsed:function(e,t){this.setFieldVisible(e,t),this.setCompEnable(e,t)},setFieldVisible:function(e,t){for(var i=0;i,.?]+$/;return[{xtype:"syno_displayfield",hideLabel:!0,value:_T("ups","ups_desc")},{xtype:"syno_checkbox",name:"enable",boxLabel:_T("ups","usb_ups_enable")},{xtype:"syno_combobox",fieldLabel:_T("ups","ups_type"),labelWidth:this.labelWidth,name:"mode",itemId:"mode",indent:1,width:this.comboboxWidth,store:this.getModeStore(),value:this.mode_select[0][0],valueField:"value",displayField:"display",tpl:'
    {display}
    '},{xtype:"syno_displayfield",cls:"hc-ups-safemode-waittime-label",name:"ups_safemode_waittime_label",itemId:"ups_safemode_waittime_label",indent:1,hideLabel:!0,value:_T("ups","ups_wait_time_desc"),htmlEncode:!1,isDirty:function(){return!1}},{indent:1,xtype:"syno_radio",name:"ups_set_safemode_waittime",itemId:"ups_set_safemode_same_as_server",boxLabel:_T("ups","ups_safemode_same_as_server")},{indent:1,xtype:"syno_radio",name:"ups_set_safemode_waittime",itemId:"ups_set_safemode_until_lowbatt",boxLabel:_T("ups","ups_safemode_until_lowbatt")},{indent:1,xtype:"syno_radio",name:"ups_set_safemode_waittime",itemId:"ups_set_safemode_customize_time",boxLabel:_T("ups","ups_safemode_customize_time")},{indent:2,fieldLabel:"Custom Set Time",hideLabel:!0,xtype:"syno_compositefield",itemId:"ups_waittime",items:[{xtype:"syno_numberfield",width:80,allowBlank:!1,value:"0",name:"ups_customized_waittime"},{xtype:"syno_displayfield",width:3,hidden:!0,name:"delay_time"},{xtype:"syno_combobox",width:100,hiddenName:"ups_time_unit_list",valueField:"id",displayField:"display",value:1,store:new Ext.data.ArrayStore({fields:["id","display"],idProperty:"id",data:[[1,_T("status","status_second")],[60,_T("status","status_minute")],[3600,_T("status","status_hour")]]})}]},{xtype:"syno_textfield",vtype:"ip",fieldLabel:_T("ups","upsmon_server"),labelWidth:this.labelWidth,name:"net_server_ip",itemId:"net_server_ip",maxLength:64,indent:1,width:this.fieldWidth,allowBlank:!1,maskRe:e,regex:e},{xtype:"syno_textfield",vtype:"ip",fieldLabel:_T("ups","snmpups_ip"),labelWidth:this.labelWidth,name:"snmp_server_ip",itemId:"snmp_server_ip",maxLength:64,indent:1,width:this.fieldWidth,allowBlank:!1,maskRe:e,regex:e},{xtype:"syno_combobox",fieldLabel:"SNMP MIB",labelWidth:this.labelWidth,name:"snmp_mib",itemId:"snmp_mib",indent:1,hidden:this._S("version")<4935,width:this.comboboxWidth,store:this.getSNMPMibStore(),value:this.snmp_mib_select[0][0],valueField:"value",displayField:"display"},{xtype:"syno_combobox",fieldLabel:_T("ups","snmpups_version"),labelWidth:this.labelWidth,name:"snmp_version",itemId:"snmp_version",indent:1,width:this.comboboxWidth,store:this.getSNMPVersionStore(),value:this.snmp_version_select[1][0],valueField:"value",displayField:"display"},{xtype:"syno_textfield",fieldLabel:_T("ups","snmpups_community"),labelWidth:this.labelWidth,name:"snmp_community",itemId:"snmp_community",maxLength:64,indent:1,width:this.fieldWidth,allowBlank:!1},{xtype:"syno_textfield",fieldLabel:_T("common","owner"),labelWidth:this.labelWidth,name:"snmp_user",itemId:"snmp_user",minLength:1,maxLength:64,indent:1,width:this.fieldWidth,allowBlank:!1},{xtype:"syno_checkbox",name:"snmp_auth",itemId:"snmp_auth",indent:1,boxLabel:_T("snmp","snmp_auth")},{xtype:"syno_combobox",fieldLabel:_T("snmp","snmp_protocol"),labelWidth:this.labelWidth,name:"snmp_auth_type",itemId:"snmp_auth_type",indent:2,width:this.comboboxWidth,store:new Ext.data.ArrayStore({fields:["value","display"],data:[["MD5","MD5"],["SHA","SHA"]]}),value:"MD5",valueField:"value",displayField:"display"},{xtype:"syno_textfield",fieldLabel:_T("common","password"),textType:"password",labelWidth:this.labelWidth,name:"snmp_auth_key",itemId:"snmp_auth_key",minLength:8,maxLength:64,indent:2,width:this.fieldWidth},{xtype:"syno_checkbox",name:"snmp_privacy",itemId:"snmp_privacy",indent:1,boxLabel:_T("snmp","snmp_privacy")},{xtype:"syno_combobox",fieldLabel:_T("snmp","snmp_protocol"),labelWidth:this.labelWidth,name:"snmp_privacy_type",itemId:"snmp_privacy_type",indent:2,width:this.comboboxWidth,store:new Ext.data.ArrayStore({fields:["value","display"],data:[["DES","DES"],["AES","AES"]]}),value:"DES",valueField:"value",displayField:"display"},{xtype:"syno_textfield",fieldLabel:_T("common","password"),textType:"password",labelWidth:this.labelWidth,name:"snmp_privacy_key",itemId:"snmp_privacy_key",minLength:8,maxLength:64,indent:2,width:this.fieldWidth},{xtype:"syno_checkbox",name:"shutdown_device",itemId:"shutdown_device",boxLabel:_T("ups","ups_safemode_shutdown"),indent:1},{xtype:"syno_checkbox",name:"ACL_enable",itemId:"ACL_enable",boxLabel:_T("ups","networkups_enable"),indent:1},{xtype:"syno_button",name:"ACL_list_btn",btnStyle:"default",itemId:"ACL_list_btn",autoWidth:!0,indent:2,id:this.ACLListBtnId=Ext.id(),disabled:!0,text:_T("ups","networkups_desc"),scope:this,handler:function(){new SYNO.SDS.AdminCenter.HardwareControl.ACLListDialog({owner:this.module.appWin,module:this,UPSInfo:this.UPSInfo}).show()}},{xtype:"syno_displayfield",htmlEncode:!1,name:"no_ups_message",value:_T("ups","usb_ups_status_title")+": "+_T("ups","usb_noups")+"",hidden:!0},{xtype:"syno_displayfield",htmlEncode:!1,name:"usb_ups_connect_msg",value:_T("ups","usb_ups_status_title")+": "+_T("ups","usb_ups_connect")+"",hidden:!0},{xtype:"syno_displayfield",htmlEncode:!1,name:"networkups_noconn",value:_T("ups","usb_ups_status_title")+": "+_T("ups","networkups_noconn")+"",hidden:!0},{xtype:"syno_displayfield",htmlEncode:!1,name:"networkups_choose_hint",value:_T("ups","usb_ups_status_title")+": "+_T("ups","networkups_select_hint")+"",hidden:!0},{xtype:"syno_displayfield",htmlEncode:!1,name:"usbups_choose_hint",value:_T("ups","usb_ups_status_title")+": "+_T("ups","usbups_select_hint")+"",hidden:!0},{xtype:"syno_displayfield",name:"next_line"},{xtype:"syno_displayfield",name:"ACL_modified",value:"",hidden:!0},{xtype:"syno_button",name:"device_info",btnStyle:"default",itemId:"device_info",id:this.deviceInfoBtnId=Ext.id(),autoWidth:!0,text:_T("ups","usb_ups_status_title"),scope:this,handler:this.onClickStatusButton}]},onClickStatusButton:function(){var e,t,i=[],s=new Ext.data.ArrayStore({fields:["name","value"]});e="usb_ups_status_online"==this.UPSInfo.status?_T("ups",this.UPSInfo.status):"usb_ups_status_unknown"===this.UPSInfo.status?_T("common","not_support"):""+_T("ups",this.UPSInfo.status)+"",t=-1==this.UPSInfo.runtime?_T("status","status_not_available"):this.UPSInfo.runtime+" "+_T("time","time_second"),i.push([_T("ups","usb_ups_manufacture"),this.UPSInfo.manufacture]),i.push([_T("ups","usb_ups_model"),this.UPSInfo.model]),i.push([_T("usb","usb_status"),e]),-1==this.UPSInfo.charge?i.push([_T("ups","usb_ups_charge"),_T("common","not_support")]):i.push([_T("ups","usb_ups_charge"),this.UPSInfo.charge+"%"]),i.push([_T("ups","usb_ups_runtime"),t]),s.loadData(i),new SYNO.SDS.AdminCenter.HardwareControl.DetailsDialog({owner:this.module.appWin,store:s,width:500,height:260}).open()},getModeStore:function(){return"yes"===this._D("support_xa","no")?this.mode_select=[["SNMP",_T("ups","networkups_type_snmp")],["SLAVE",_T("ups","networkups_type_syno")]]:this.mode_select=[["USB",_T("ups","usb_ups")],["SNMP",_T("ups","networkups_type_snmp")],["SLAVE",_T("ups","networkups_type_syno")]],new Ext.data.ArrayStore({fields:["value","display"],data:this.mode_select})},getSNMPVersionStore:function(){return this.snmp_version_select=[["v1","v1"],["v2c","v2c"],["v3","v3"]],new Ext.data.ArrayStore({fields:["value","display"],data:this.snmp_version_select})},getSNMPMibStore:function(){var e=["auto","ietf","mge","apcc","netvision","pw","aphel_genesisII","aphel_revelation","raritan","baytech","cpqpower","cyberpower"];this.snmp_mib_select=[];for(var t=0;t259200||t<0)return e=1===i?"0 - 259200":60===i?"0 - 4320":"0 - 72",this.getForm().findField("ups_customized_waittime").markInvalid(e),!1;this.getForm().findField("delay_time").setValue(t)}else this.getForm().findField("delay_time").setValue(-1);return!0},checkModeValid:function(){var e=this.getForm().findField("mode").getValue(),t=this.getForm().findField("enable").getValue();if(this.current_mode!=e&&t){if("USB"==this.current_mode&&"USB"!=e)return this.getForm().findField("mode").markInvalid(_T("ups","usbups_select_hint")),!1;if("USB"!=this.current_mode&&"USB"==e)return this.getForm().findField("mode").markInvalid(_T("ups","ups_disable_network_ups_hint")),!1}return!0},checkIpValid:function(){var e=this.getForm().findField("mode").getValue(),t="";return"USB"==e||(t="SNMP"==e?"snmp_server_ip":"net_server_ip","127"!=this.getForm().findField(t).getValue().split(".")[0]||(this.getForm().findField(t).markInvalid(_T("common","error_badip")),!1))},onBeforeRequest:function(e){return this.webapi.methods.set!==e||(!!this.disabled||(!!(this.getForm().isValid()&&this.checkWaittimeValid()&&this.checkModeValid()&&this.checkIpValid())||(this.module.panel.setStatusError({text:_T("common","forminvalid"),clear:!0}),this.module.panel.setActiveTab("UpsTab"),!1)))},onServiceAction:function(e){for(var t={api:this.webapi.api,method:this.webapi.methods.set,version:this.webapi.version},i=0;i=0?(this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_customize_time"),!0),this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_until_lowbatt"),!1),this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_same_as_server"),!1)):(this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_customize_time"),!1),"SLAVE"===e?(this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_until_lowbatt"),!1),this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_same_as_server"),!0)):(this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_until_lowbatt"),!0),this.setFieldAndOriginalValues(this.getForm().findField("ups_set_safemode_same_as_server"),!1))))},processGetData:function(e,t){this.update=!1,this.processUPSGetInfo(e,t),this.update=!0,this.disabled||(this.onServiceAction(e),this.switchLayout())},processSetData:function(e){var t=e,i={api:this.webapi.api,method:this.webapi.methods.set,version:this.webapi.version};this.pollingTaskStop();for(var s=0;se.success||e.error&&6601===e.error.code)},onApiSuccess:function(e,t,i){var s=this;"set"===e&&(!t.has_fail||this.checkOnlyHAPassiveOfflineError(t.result)?(s.module.confirmSaveLostResolve&&s.module.confirmSaveLostResolve(),s.setStatusOK()):(s.module.confirmSaveLostReject&&s.module.confirmSaveLostReject(),s.setErrorMsg(t.result))),s.processReturnData(e,t,i)}}),Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.EnterIPStep",{extend:"SYNO.SDS.Utils.FormPanel",originIP:null,constructor:function(e){var t=Ext.apply({headline:_T("usb","net_prntr_welcome"),border:!1,trackResetOnLoad:!0,items:[{xtype:"syno_displayfield",value:_T("usb","net_prntr_intro")},{xtype:"syno_displayfield",value:_T("usb","net_prntr_enter_ip")},{xtype:"syno_displayfield",height:30},{xtype:"syno_textfield",width:300,allowBlank:!1,fieldLabel:_T("common","ip_addr"),name:"ip",enableKeyEvents:!0,maxlength:15,vtype:"v4ip"},{name:"ip_dup",hidden:!0,xtype:"syno_textfield",enableKeyEvents:!0,maxlength:15,vtype:"v4ip"}]},e);this.callParent([t])},activate:function(){this.owner.getStep("np_conf").isSet=!1,this.originIP=this.getForm().findField("ip").getValue()},getNext:function(){var e;return this.getForm().isValid()?this._S("demo_mode")?(this.owner.goNext(this.nextId),!1):(e=this.getForm().findField("ip").getValue(),this.originIP!=e?(this.owner.el.mask(_T("common","searching"),"x-mask-loading"),this.owner.sendWebAPI({api:"SYNO.Core.ExternalDevice.Printer.Network.Host",version:1,method:"get",params:{ip:e},scope:this,callback:function(e,t,i,s){if(!this.isDestroyed){var n;if(!e)return n=SYNO.API.getErrorString(t.code),void this.owner.getMsgBox().alert(_T("usb","net_prntr_wizard_title"),n);this.owner.conf=t,this.owner.goNext(this.nextId),this.owner.el.unmask()}}})):this.owner.goNext(this.nextId),!1):(this.owner.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1)}}),Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.NPConfStep",{extend:"SYNO.SDS.Utils.FormPanel",isSet:!1,constructor:function(e){var t=Ext.apply({headline:_T("usb","net_prntr_detail"),border:!1,trackResetOnLoad:!0,items:[{xtype:"syno_displayfield",value:_T("usb","net_prntr_enter_info")},{xtype:"syno_displayfield",height:15},{xtype:"syno_textfield",width:300,name:"cups_name",id:this.NameId=Ext.id(),fieldLabel:_T("usb","net_prntr_name"),maxlength:32,validationEvent:"blur",validator:function(){var e=!1,t=this.getValue();return""===t?_JSLIBSTR("extlang","fieldblank"):0<=t.search(/[^a-zA-Z0-9_]/)?_T("error","error_bad_field"):(this.ownerCt.owner.printerStore.each(function(i){t==i.get("cups_name")&&(e=!0)}),e?_T("usb","net_prntr_name_exist_error"):(this.clearInvalid(),!0))}},{xtype:"syno_combobox",width:300,name:"protocol",fieldLabel:_T("usb","net_prntr_ptl"),id:this.ProtocolId=Ext.id(),autoSelect:!0,allowBlank:!1,store:this.backendList=new Ext.data.ArrayStore({fields:["protocol_id","protocol_text"],data:[["lpd",_T("usb","net_prntr_lpr")],["ipp",_T("usb","net_prntr_ipp")],["socket",_T("usb","net_prntr_socket")],["bjnp",_T("usb","net_prntr_bjnp")]]}),displayField:"protocol_text",valueField:"protocol_id"},{xtype:"syno_textfield",width:300,name:"qname",id:this.QueueNameId=Ext.id(),fieldLabel:_T("usb","net_prntr_qname"),enableKeyEvents:!0,maxlength:32,validationEvent:"keyup",validator:function(){var e=this.getValue();return""===e?_JSLIBSTR("extlang","fieldblank"):0<=e.search("usbprinter")?_T("error","error_bad_field"):this.originalValue===e||""===this.originalValue||(0<=e.search(/[^a-zA-Z0-9_]/)?_T("error","error_bad_field"):(this.clearInvalid(),!0))}},{xtype:"syno_displayfield",width:300,name:"mfg",id:this.BrandId=Ext.id(),fieldLabel:_T("usb","usb_printer_brand")},{xtype:"syno_displayfield",width:300,name:"mdl",id:this.ModelId=Ext.id(),fieldLabel:_T("usb","net_prntr_mdl")},{xtype:"syno_textfield",name:"stringid",hidden:!0}]},e);this.callParent([t]),this.mon(this,"afterlayout",function(){SYNO.ux.AddTip(this.getForm().findField("qname").getEl(),_T("usb","net_qname_tip"))},this,{single:!0})},activate:function(){this.owner.mon(this.getForm().findField("protocol"),"select",function(){"bjnp"===this.getForm().findField("protocol").getValue()||"socket"===this.getForm().findField("protocol").getValue()?(this.getForm().findField("qname").disable(),this.getForm().findField("qname").clearInvalid()):this.getForm().findField("qname").enable()},this),!1===this.isSet&&(this.getForm().setValues(this.owner.conf),this.getForm().findField("protocol").fireEvent("select"),this.isSet=!0),""===this.getForm().findField("mfg").getValue()&&this.getForm().findField("mfg").setValue(_T("usb","info_not_found")),""===this.getForm().findField("mdl").getValue()&&this.getForm().findField("mdl").setValue(_T("usb","info_not_found"))},getNext:function(){return this.getForm().isValid()?this._S("demo_mode")?(this.owner.goNext(this.nextId),!1):(this.getForm().findField("cups_name").clearInvalid(),this.supportOAuth?(this.owner.el.mask(_T("common","msg_waiting"),"x-mask-loading"),this.owner.sendWebAPI({api:"SYNO.Core.ExternalDevice.Printer.OAuth",version:1,method:"get",scope:this,callback:function(e,t,i,s){if(!this.isDestroyed){var n;if(!e)return n=SYNO.API.getErrorString(t.code),void this.owner.getMsgBox().alert(_T("usb","net_prntr_wizard_title"),n);this.owner.needLogin=0===t.account.length,this.owner.goNext(this.nextId),this.owner.el.unmask()}}})):this.owner.goNext(this.nextId),!1):(this.owner.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1)}}),Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.NPSettingStep",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.owner=e.owner,this.module=e.module;var t=Ext.apply({headline:_T("usb","prntr_ap_gcp_setting"),border:!1,trackResetOnLoad:!0,items:[{xtype:"syno_displayfield",value:_T("usb","net_prntr_set_func")},{xtype:"syno_checkbox",name:"enable_airprint",boxLabel:_T("usb","usb_printer_airprint_enable")},{xtype:"syno_checkbox",name:"fit_to_page",boxLabel:_T("usb","fit_to_page")},{xtype:"syno_combobox",width:300,name:"driver_brand",fieldLabel:_T("usb","usb_printer_brand"),displayField:"value",autoSelect:!0,store:this.brandList=new Ext.data.ArrayStore({fields:["value"]}),listeners:{scope:this,select:function(e){var t=this.getForm().findField("driver_model");t.getStore().loadData(this.owner.module.driverList[e.getValue()]),t.setValue(t.getStore().getAt(0).get("value"))}}},{xtype:"syno_combobox",width:300,name:"driver_model",fieldLabel:_T("usb","usb_printer_driver"),displayField:"value",valueField:"value",autoSelect:!0,store:new Ext.data.ArrayStore({fields:["value"]})},{xtype:"syno_displayfield",name:"np_loading_status",value:_T("usb","usb_printer_driver_loading")}]},e);this.callParent([t])},activate:function(){this.mon(this,"afterlayout",function(e,t){this.getForm().findField("driver_brand").disable(),this.getForm().findField("driver_model").disable(),this.getForm().findField("enable_airprint").on("check",this.CheckBrandDriver,this),this.CheckBrandDriver()},this)},CheckBrandDriver:function(){this.getForm().findField("enable_airprint").getValue()?(this.getForm().findField("driver_brand").enable(),this.getForm().findField("driver_model").enable(),this.getForm().findField("fit_to_page").enable()):(this.getForm().findField("driver_brand").disable(),this.getForm().findField("driver_model").disable(),this.getForm().findField("fit_to_page").disable())},getNext:function(){return this._S("demo_mode")?(this.owner.getMsgBox().alert(_T("usb","net_prntr_wizard_title"),_JSLIBSTR("uicommon","error_demo")),!1):(this.owner.onApply(),!1)},checkState:function(){SYNO.SDS.Wizard.Step.prototype.checkState.apply(this,arguments),this.owner.checkDriverList()},register:function(e,t){if(Ext.isIE||Ext.isIE11)window[t]=e;else{var i=this;this.receiveMessage=function(s){var n=s.browserEvent;if(n.origin===window.location.origin&&!/setImmediate/.test(n.data)){var o=JSON.parse(n.data);o.callback===t&&e.call(i,o)}},Ext.EventManager.addListener(window,"message",this.receiveMessage)}},unregister:function(){Ext.isIE||Ext.isIE11||Ext.EventManager.removeListener(window,"message",this.receiveMessage)},addPopupTimer:function(e){if(e.popup&&!e.popup.closed)var t=window.setInterval(function(){e.popup.closed&&(e.unregister(),window.clearInterval(t),t=null)},1e3)},doClosePopup:function(){this.popup&&!this.popup.closed&&this.popup.close()}}),Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.AddNetPrinterWizardDialog",{extend:"SYNO.SDS.Wizard.ModalWindow",conf:null,blHasUsbshare:!1,loadDriverFailed:!1,mfgList:[],mdlList:[],constructor:function(e){this.owner=e.owner,this.module=e.module,this.blHasUsbshare=e.blHasUsbshare,this.loadDriverFailed=e.loadDriverFailed,this.printerStore=e.printerStore,this.supportOAuth=this._S("version")>4995;var t=[this.IPFormPanel=new SYNO.SDS.AdminCenter.ExternalDevices.EnterIPStep({itemId:"np_ip",nextId:"np_conf"}),this.ConfFormPanel=new SYNO.SDS.AdminCenter.ExternalDevices.NPConfStep({itemId:"np_conf",nextId:"np_setting",supportOAuth:this.supportOAuth}),this.SettingFormPanel=new SYNO.SDS.AdminCenter.ExternalDevices.NPSettingStep({itemId:"np_setting",nextId:null,supportOAuth:this.supportOAuth,owner:this.appWin,module:this.module})],i=Ext.apply({title:_T("usb","net_prntr_wizard_title"),resizable:!1,width:760,height:580,steps:t,listeners:{beforeclose:this.onBeforeClose,scope:this}},e);this.IPForm=this.IPFormPanel.getForm(),this.ConfForm=this.ConfFormPanel.getForm(),this.SettingForm=this.SettingFormPanel.getForm(),this.callParent([i]),this.IPFormPanel.mon(this.IPForm.findField("ip"),"keyup",function(){this.IPForm.findField("ip_dup").setValue(this.IPForm.findField("ip").getValue()),this.IPForm.findField("ip_dup").isValid()?this.getButton("next").enable():this.getButton("next").disable()},this)},onBeforeClose:function(){this.SettingFormPanel.doClosePopup()},onApply:function(){var e=this.IPForm.getValues();e=Ext.apply(e,this.ConfForm.getValues()),e=Ext.apply(e,this.SettingForm.getValues()),(e=Ext.apply({google_cloud_print:{}},e)).mfg=this.ConfForm.findField("mfg").getValue(),e.mdl=this.ConfForm.findField("mdl").getValue(),void 0===e.qname&&(e.qname=""),e.google_cloud_print.enable=!1,delete e.enable_gcp,delete e.gcp_account,delete e.gcp_passwd,delete e.ip_dup,this.SettingForm.findField("enable_airprint").getValue()&&this.SettingForm.findField("fit_to_page").getValue()?e.fit_to_page=!0:e.fit_to_page=!1,this.setStatusBusy({text:_T("common","saving")}),this.module.appWin.sendWebAPI({api:"SYNO.Core.ExternalDevice.Printer.Network",version:1,method:"create",params:e,callback:function(e,t,i,s){if(!this.isDestroyed){var n;if(this.clearStatusBusy(),!e)return n=SYNO.API.getErrorString(t.code),void this.getMsgBox().alert(_T("usb","net_prntr_wizard_title"),n);SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.favor_lpr",!1),i.enable_airprint&&SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.airprint",!1),this.close()}},scope:this})},onOpen:function(){this.callParent(arguments),this.getButton("next").disable()},checkDriverList:function(){var e=null!==this.module.driverList,t=[],i=this.getStep("np_setting").getForm().findField("np_loading_status");this.loadDriverFailed&&i.setValue(_T("usb","usb_printer_driver_loading_fail")),i.originalValue=i.getValue(),SYNO.ux.Utils.displayFormField(this.getStep("np_setting").getForm(),"enable_airprint",e),SYNO.ux.Utils.displayFormField(this.getStep("np_setting").getForm(),"fit_to_page",e),SYNO.ux.Utils.displayFormField(this.getStep("np_setting").getForm(),"driver_brand",e),SYNO.ux.Utils.displayFormField(this.getStep("np_setting").getForm(),"driver_model",e),SYNO.ux.Utils.displayFormField(this.getStep("np_setting").getForm(),"np_loading_status",!e),e&&0===this.getStep("np_setting").brandList.getCount()&&(Ext.iterate(this.module.driverList,function(e){t.push([e])},this),this.getStep("np_setting").brandList.loadData(t),this.getStep("np_setting").getForm().findField("driver_brand")),e&&this.checkDriver()},checkDriver:function(){var e,t,i=null,s=null,n=!1,o=function(e,t){var i=e.split(" "),s=i.length-1,n=i[s].toLowerCase(),o=t.toLowerCase();for(0<=i[s].search(/(ser|printer)/i)&&0o.search(n))};e=this.getStep("np_conf").getForm().findField("mfg").getValue(),t=this.getStep("np_conf").getForm().findField("mdl").getValue(),null===(i=function(e,t){for(var i in e)if(i.toLowerCase()===t.toLowerCase())return i;return null}(this.module.driverList,e))?Ext.iterate(this.module.driverList,function(e,a){return Ext.each(a,function(a){return!o(t,a[0])||(s=a[0],i=e,n=!0,!1)},this),!n},this):Ext.each(this.module.driverList[i],function(e){return!o(t,e[0])||(s=e[0],n=!0,!1)},this);var a=this.getStep("np_setting").getForm().findField("driver_brand"),r=this.getStep("np_setting").getForm().findField("driver_model");null!==i?(a.findRecord("value",i)&&a.onSelect(a.findRecord("value",i)),a.originalValue=a.getValue(),n&&(r.setValue(s),r.originalValue=r.getValue())):a.onSelect(a.getStore().getAt(0))}}),Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.ShareGrid",{extend:"SYNO.ux.GridPanel",DEFAULT_ROLES:[["system",_T("share","share_system_user")],["local_user",_T("share","share_local_user")]],GROUP_ROLES:[["local_group",_T("share","share_local_group")]],DOMAIN_ROLES:[["domain_user",_T("share","share_domain_user")],["domain_group",_T("share","share_domain_group")]],LDAP_ROLES:[["ldap_user",_T("share","ldap_user")],["ldap_group",_T("share","ldap_group")]],constructor:function(e){this.pageSize=50,this.store=this.createStore(e);var t={header:_T("share","share_permission_readonly"),dataIndex:"is_readonly",disableSelectAll:!0,width:120};this.colRo=new SYNO.ux.EnableColumn(t),this.colRw=new SYNO.ux.EnableColumn({header:_T("share","share_permission_writable"),dataIndex:"is_writable",disableSelectAll:!0,width:120,id:"is_writable"}),this.colNa=new SYNO.ux.EnableColumn({header:_T("share","share_permission_none"),dataIndex:"is_deny",disableSelectAll:!0,width:120});var i=[{id:"name",header:_T("share","share_name"),dataIndex:"name",width:100,align:"left",renderer:function(e,t){return"ftp"===e.toLowerCase()?"Anonymous FTP/Presto/WebDAV":e}},this.colNa,this.colRw,this.colRo];e.colCu&&(this.colCu=e.colCu,i.push(this.colCu));var s=Ext.apply({title:_T("share","share_rights"),layout:"fit",cls:"without-dirty-red-grid",store:this.store,width:700,autoExpandMax:160,autoExpandMin:160,autoExpandColumn:"name",enableColumnMove:!1,enableHdMenu:!1,hideMode:"offsets",colModel:new Ext.grid.ColumnModel({defaults:{align:"center"},columns:i}),selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),plugins:[this.colRo,this.colRw,this.colNa],tbar:this.createTopToolbar(e),bbar:new SYNO.ux.PagingToolbar({store:this.store,pageSize:this.pageSize,displayInfo:!0})},e);this.callParent([s]),this.mon(this,"cellclick",this.onGridCellClick,this),this.mon(this,"afterlayout",function(e,t){this.mon(this.getSelectionModel(),"spacepressed",this.onGridCellSpacePressed,this)},this,{single:!0}),this.mon(this,"afterlayout",function(e,t){e.getView().updateScroller()},this)},joinRenderer:function(e,t,i,s,n,o){return i.data.is_readonly||i.data.is_writable||i.data.is_deny||i.data.is_custom?'
    ':""},createStore:function(e){return new SYNO.API.JsonStore({autoDestroy:!0,remoteSort:!0,appWindow:e.owner,api:"SYNO.Core.ExternalDevice.DefaultPermission",method:"get",version:1,baseParams:{offset:0,limit:this.pageSize},listeners:{exception:{scope:this,fn:this.onStoreException},beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:this.onLoad}},root:"items",idProperty:"name",totalProperty:"total",fields:["name","is_writable","is_readonly","is_deny","is_custom","is_admin"]})},createTopToolbar:function(e){var t=new SYNO.ux.Toolbar({style:{"border-bottom":"none"},items:[{xtype:"syno_combobox",itemId:"roleFilter",valueField:"role",displayField:"display",store:{xtype:"arraystore",autoDestroy:!0,fields:["role","display"]},mode:"local",triggerAction:"all",editable:!1,forceSelection:!0,width:210,tpl:'
    {display}
    ',listeners:{beforeselect:{scope:this,fn:this.onRoleFilterSelect}}},"->",{xtype:"syno_displayfield",value:_T("helptoc","directory_service_domain")+": ",hidden:!0,itemId:"domainListLabel"},{xtype:"syno_combobox",itemId:"domainFilter",valueField:"value",displayField:"domain",store:{xtype:"arraystore",autoDestroy:!0,fields:["domain","value","comment"]},hidden:!0,resizable:!0,mode:"local",triggerAction:"all",editable:!1,value:"",forceSelection:!0,tpl:'
    {domain}
    ',listeners:{beforeselect:{scope:this,fn:this.onDomainFilterSelect}}},this.nameFilter=new SYNO.ux.TextFilter({iconStyle:"filter",itemId:"search",emptyText:_T("share","share_filter_text"),store:this.store,queryParam:"substr",pageSize:this.pageSize})]});return this.roleFilter=t.getComponent("roleFilter"),this.domainFilter=t.getComponent("domainFilter"),this.domainListLabel=t.getComponent("domainListLabel"),t},showDomainFilter:function(e){this.domainListLabel.setVisible(e),this.domainFilter.setVisible(e)},onDomainFilterSelect:function(e,t){this.store.baseParams.domain=t.data.value,this.store.load({params:{offset:0}})},onGridCellSpacePressed:function(e,t){var i=e.grid,s=i.getStore().indexOf(e.getSelected()),n=e.getColIdx();0<=n&&this.onGridCellClick(i,s,n,t)},onGridCellClick:function(e,t,i,s){var n=e.getStore().getAt(t),o=e.getColumnModel().getDataIndex(i);(function(e){return"is_readonly"===e||"is_writable"===e||"is_deny"===e})(o)&&!0===n.get(o)&&function(e,t,i){"is_readonly"!==e&&(t.set("is_readonly",!1),i.colRo.checkSelectAll(i.getStore())),"is_writable"!==e&&(t.set("is_writable",!1),i.colRw.checkSelectAll(i.getStore())),"is_deny"!==e&&(t.set("is_deny",!1),i.colNa.checkSelectAll(i.getStore()))}(o,n,e)},isChanged:function(){return 0!==this.store.getModifiedRecords().length},getModifiedPermissions:function(){var e=this.getWebAPI(),t=[];return 1===e.length&&Ext.each(e[0].params.permissions,function(e){t.push({is_readonly:e.is_readonly,is_deny:e.is_deny,is_writable:e.is_writable,is_custom:!!e.is_custom})}),t},onStoreException:function(e,t,i,s,n,o){this.owner.clearStatusBusy(),SYNO.Debug("Store exception: options:",e,t,i,s,n,o),this.owner.getMsgBox().alert(this.title,SYNO.API.Erros.core[n.code]||_T("common","commfail"))},onBeforeLoad:function(e,t){return this.owner.setStatusBusy({text:_T("common","loading")}),!this.isChanged()||(this.owner.clearStatusBusy(),this.owner.getMsgBox().confirm(this.title,_T("share","share_save_chg_before_reload"),function(e){if("yes"===e){var i=this.getWebAPI();this.sendApplyRequest(i,t)}else this.store.rejectChanges(),this.store.load(t)},this),!1)},onLoad:function(){this.prevRole=void 0,this.owner.clearStatusBusy(),this.getSelectionModel().selectFirstRow()},onException:function(e,t,i,s,n,o){this.owner.clearStatusBusy(),this.owner.getMsgBox().alert(this.title,SYNO.API.Erros.core[n.code]||_T("common","commfail"))},onRoleFilterSelect:function(e,t){var i=t.data.role;this.prevRole=e.getValue(),this.store.baseParams.user_group_type=i,"domain_user"===i||"domain_group"===i?this.showDomainFilter(!0):this.showDomainFilter(!1),this.store.load({params:{offset:0}})},loadPermissions:function(e){var t=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.LDAP","get","enable_client"),i=2702===SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.LDAP","get","error"),s=!1,n=!1,o=!1;this.getKnownAPI("SYNO.Core.Directory.Domain")&&(s=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.Domain","get","enable_domain"),n=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.Domain","test_dc","test_join_success"),o="yes"===this._D("supportdomain")&&SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.Domain","get_domain_list","domain_list"));var a=this.roleFilter.getStore(),r=this.domainFilter.getStore(),l=[];a.loadData(this.DEFAULT_ROLES),a.loadData(this.GROUP_ROLES,!0),t&&i&&a.loadData(this.LDAP_ROLES,!0),s&&n&&0!==o.length&&(a.loadData(this.DOMAIN_ROLES,!0),Ext.each(o,function(e){"object"==typeof e?e[1]?l.push(e):l.push([_T("directory_service","domainou_list_all_items"),e[1],e[2]]):l.push([e,e,e])},this),r.loadData(l),this.domainFilter.getValue()||this.domainFilter.setValue(l[0][1]||""),this.store.baseParams.domain=this.domainFilter.getValue(),1===SYNO.API.Response.GetValByAPI(e,"SYNO.Core.Directory.Domain","get","manage_mode")?this.domainListLabel.setValue(_T("directory_service","organizational_unit")+": "):this.domainListLabel.setValue(_T("helptoc","directory_service_domain")+": ")),this.showDomainFilter(!1),this.roleFilter.setValue("local_user"),this.nameFilter.reset(),this.store.baseParams.user_group_type=this.roleFilter.getValue(),this.store.load()},getOpenConfig:function(){var e=this.getSelectionModel().getSelected().get("name"),t="user",i=this.roleFilter.getValue();return"local_group"===i||"domain_group"===i||"ldap_group"===i?t="group":"http"===e&&(t="group"),{userName:e.toLowerCase(),userType:t}},getWebAPI:function(){var e=[];Ext.each(this.store.getModifiedRecords(),function(t){e.push({name:t.data.name,is_readonly:t.data.is_readonly,is_writable:t.data.is_writable,is_deny:t.data.is_deny,is_custom:t.data.is_custom})},this);var t={user_group_type:this.prevRole||this.roleFilter.getValue(),permissions:e};return 0===e.length?void 0:{api:"SYNO.Core.ExternalDevice.DefaultPermission",method:"set",version:1,params:t}},sendApplyRequest:function(e,t){this.owner.setStatusBusy({text:_T("common","saving")}),this.owner.sendWebAPI(Ext.apply(e,{scope:this,callback:function(e,i){if(this.owner.clearStatusBusy(),e)return this.store.commitChanges(),void this.store.load(t);this.owner.getMsgBox().alert(this.title,SYNO.API.Erros.core[i.code]||_T("common","commfail"))}}))}}),Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.ExternalSettingDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e,t){this.option=t,this.defaulPermissionGrid=new SYNO.SDS.AdminCenter.ExternalDevices.ShareGrid({style:{padding:"4px 0px 0px 0px"},module:e.module,owner:this,cls:"external-sharegrid",padding:0,flex:1}),this.externalDefaultPermissionTab=new SYNO.SDS.Utils.FormPanel({module:e.module,owner:this,title:_T("externaldevice","externaldevice_default_permission"),itemId:"ExternalDefaultPermissionTab",layout:"vbox",layoutConfig:{align:"stretch"},items:[this.defaulPermissionGrid,{xtype:"panel",border:!1,items:[{xtype:"syno_displayfield",htmlEncode:!1,value:''+_T("common","note")+_T("common","colon")+" "+_T("externaldevice","externaldevice_default_permission_dialog_desc")}]}]}),this.externalAdvancedTab=new SYNO.SDS.AdminCenter.ExternalDevices.StorageSettingTab({module:e.module,owner:this,itemId:"StorageSettingTab"},t);var i=Ext.apply({width:800,height:570,minWidth:780,minHeight:370,layout:"fit",title:_T("externaldevice","externaldevice_global_settings"),items:[{xtype:"syno_tabpanel",padding:"0px 0px 0px 0px",plain:!0,itemId:"tab",activeTab:0,items:[this.externalDefaultPermissionTab,this.externalAdvancedTab]}],buttons:[{text:_T("common","cancel"),scope:this,handler:this.onCancel},{text:_T("common","apply"),scope:this,btnStyle:"blue",disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",handler:this.onApply}],listeners:{beforeclose:this.onBeforeClose.bind(this)},forceClose:!1},e);this.callParent([i]),this.loadDefaultPermission()},loadDefaultPermission:function(){var e=[{api:"SYNO.Core.Directory.LDAP",method:"get",version:1}];this.getKnownAPI("SYNO.Core.Directory.Domain")&&(e.push({api:"SYNO.Core.Directory.Domain",method:"get",version:1}),e.push({api:"SYNO.Core.Directory.Domain",method:"test_dc",version:1}),"yes"===this._D("supportdomain")&&e.push({api:"SYNO.Core.Directory.Domain",method:"get_domain_list",version:2})),this.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:e},scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),e&&!t.has_fail)this.defaulPermissionGrid.loadPermissions(t);else{var s=SYNO.API.Response.GetFirstError(t);this.getMsgBox().alert("share",SYNO.API.Erros.core[s.code]||_T("common","commfail"))}}})},isChanged:function(){return this.defaulPermissionGrid.isChanged()||this.externalAdvancedTab.getForm().isDirty()},onApply:function(){if(!this.isChanged())return this.forceClose=!0,void this.close();var e,t,i=this,s=this.defaulPermissionGrid.getWebAPI(),n=this.externalAdvancedTab.getWebAPI(),o=[];s&&o.push(s),n&&o.push(n);var a=this.externalAdvancedTab.getDirtyField();a.forbid_usb&&a.delalloc?this.option.needReboot?(t=_T("hddsleep","dcache_title"),e=_T("usb","apply_delalloc_warning")+"
    ",e+=_T("backup","are_you_sure_to_continue")):(t=_T("common","advanced"),e="1. "+_T("usb","forbid_confirm_reboot")+"
    ",e+="2. "+_T("usb","apply_delalloc_warning")+"
    ",e+=_T("backup","are_you_sure_to_continue")):a.forbid_usb?this.option.needReboot||(t=_T("common","advanced"),e=_T("usb","forbid_confirm_reboot")+"
    ",e+=_T("backup","are_you_sure_to_continue")):a.delalloc?(t=_T("hddsleep","dcache_title"),e=_T("usb","apply_delalloc_warning")+"
    ",e+=_T("backup","are_you_sure_to_continue")):(t=void 0,e=void 0),e?this.getMsgBox().confirm(t,e,function(e){"yes"==e&&(Ext.getCmp(i.option.btnSettingId).disable(),Ext.getCmp(i.option.btnFormatId).disable(),Ext.getCmp(i.option.btnEjectId).disable(),i.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:o},scope:this,callback:this.onApplyCallback}))},i):(n&&(Ext.getCmp(this.option.btnSettingId).disable(),Ext.getCmp(this.option.btnFormatId).disable(),Ext.getCmp(this.option.btnEjectId).disable()),this.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:o},scope:this,callback:this.onApplyCallback}))},onApplyCallback:function(e,t,i){if(e&&!t.has_fail)return this.externalAdvancedTab.getDirtyField().forbid_usb&&(this.option.needReboot=!this.option.needReboot,this.option.needReboot&&SYNO.SDS.System.RebootWithMsg()),this.forceClose=!0,void this.close();var s=SYNO.API.Response.GetFirstError(t),n=SYNO.API.Erros.core[s.code]||_T("common","error_system");this.getMsgBox().alert("warning_msg",n)},onCancel:function(){this.close()},onBeforeClose:function(){var e=this;return!(!e.forceClose&&this.isChanged())||(e.confirmLostChangePromise({save:function(){e.onApply()},dontSave:function(){e.forceClose=!0,e.close()},cancel:Ext.emptyFn}),!1)}}),Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.StorageSettingTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e,t){var i=Ext.apply({border:!1,owner:this.appWin,title:_T("common","advanced"),webapi:{api:"SYNO.Core.ExternalDevice.Storage.Setting",version:1,method:"set"},items:[{xtype:"syno_checkbox",boxLabel:_T("usb","delalloc_opt"),name:"delalloc",checked:t.delalloc},{xtype:"syno_displayfield",value:_T("usb","delalloc_desc")}]},e);i.items.push(this.createUSBItems(t)),this.callParent([i])},createUSBItems:function(e){var t=[];return t.push({xtype:"syno_checkbox",boxLabel:_T("usb","forbid_usb"),name:"forbid_usb",checked:e.forbid_usb,hidden:"0"==_D("usbportnum")}),t.push({xtype:"syno_displayfield",value:_T("usb","forbid_usb_explain"),hidden:"0"==_D("usbportnum")}),t.push({xtype:"syno_displayfield",name:"reboot_warning",id:this.needRebootWarnId=Ext.id(),value:" "+_T("status","status_need_reboot")+" ",hidden:"0"==_D("usbportnum")||!e.needReboot,htmlEncode:!1}),t},getWebAPI:function(){var e={},t=this.getForm();return t.isDirty()?(e.delalloc=t.getValues().delalloc,e.forbid_usb=t.getValues().forbid_usb,{api:"SYNO.Core.ExternalDevice.Storage.Setting",method:"set",version:1,params:e}):void 0},getDirtyField:function(){return{forbid_usb:!!this.getForm().findField("forbid_usb").isDirty(),delalloc:!!this.getForm().findField("delalloc").isDirty()}}}),SYNO.SDS.AdminCenter.ExternalDevices.EXT_FORMAT_MIN_MB_SIZE=100,SYNO.SDS.AdminCenter.ExternalDevices.FAT_FORMAT_MAX_MB_SIZE=2097152,SYNO.SDS.AdminCenter.ExternalDevices.onClickExfatPkg=function(){SYNO.SDS.AppLaunch("SYNO.SDS.PkgManApp.Instance",{action:"open",packages:["exFAT-Free"]})},Ext.define("SYNO.SDS.AdminCenter.ExternalDevices.Main",{extend:"SYNO.SDS.AdminCenter.Module",appWin:null,deviceStore:null,printerStore:null,deviceList:[],printerList:[],driverList:null,mfgList:[],mdlList:[],brandList:null,backendList:null,bonjourPrinterEnabled:!1,loadDriverFailed:!1,printerSetupDialog:null,printerForm:null,blHasUsbshare:!1,isUsbPrntr:!0,npWizard:null,hasVolume:!0,constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.isUsbStation="yes"===this.appWin._D("usbstation"),this.exFATPkgRunning=!1,this.deviceStore=new SYNO.API.CompoundStore({compound:{stopwhenerror:!1,params:[{api:"SYNO.Core.ExternalDevice.Storage.USB",version:1,method:"list",params:{additional:["all"]}},{api:"SYNO.Core.ExternalDevice.Storage.eSATA",version:1,method:"list",params:{additional:["all"]}}]},idProperty:"dev_id",fields:["title","status","cls","iconCls","dev_id","dev_title","total_size_mb","dev_type","formatable","producer","product","status","progress","partitions","share_name"],root:"devices",blReloadMask:!1,appWindow:this.appWin,listeners:{scope:this,beforeload:function(){this.gotoPkgManId&&(this.gotoPkgManId.forEach(function(e){var t=Ext.get(e);Ext.isObject(t)&&t.un("click",this.onClickExfatPkg,this)},this),delete this.gotoPkgManId)},load:function(e){this.deviceStore.blReloadMask&&(this.appWin.clearStatusBusy(),this.appWin.unmask(),this.deviceStore.blReloadMask=!1),this.gotoPkgManId&&this.gotoPkgManId.forEach(function(e,t){var i=Ext.get(e);Ext.isObject(i)&&i.on("click",this.onClickExfatPkg)},this)}},onCompoundResponse:this.processDeviceStore(),reload_withmask:function(){this.deviceStore.blReloadMask=!0,this.appWin.setStatusBusy({text:_T("common","loading")},.4,1),this.deviceStore.reload()}}),this.printerStore=new SYNO.API.JsonStore({api:"SYNO.Core.ExternalDevice.Printer",method:"list",version:1,baseParams:{additional:["all"]},idProperty:"printer_id",fields:["printer_id","cups_name","printer_mode","mfg","mdl","driver_brand","driver_model","enable_airprint","google_cloud_print","fit_to_page","printer_cmd_set","lockby","print_queue","ip","status","protocol","qname"],root:"printers",blReloadMask:!1,appWindow:this.appWin,listeners:{scope:this,load:function(e,t){this.processPrinterStore(t),this.printerStore.blReloadMask&&(this.appWin.clearStatusBusy(),this.appWin.unmask(),this.printerStore.blReloadMask=!1)}},reload_withmask:function(){this.printerStore.blReloadMask=!0,this.appWin.setStatusBusy({text:_T("common","loading")},.4,1),this.printerStore.reload()}}),this.backendList=new Ext.data.ArrayStore({fields:["protocol_id","protocol_text"],data:[["lpd",_T("usb","net_prntr_lpr")],["ipp",_T("usb","net_prntr_ipp")],["socket",_T("usb","net_prntr_socket")],["bjnp",_T("usb","net_prntr_bjnp")]]}),this.createPanel(),this.deviceView.mon(this.deviceView,"selectionchange",function(e,t){var i=this.deviceView.getSelectedRecords();if(i&&i[0]){var s=this.panel.getActiveTab();if(!s)return;"deviceTab"===s.itemId&&(this.lastSelectedRecord=i[0],this.printerView.clearSelections())}this.dataViewSelectionChange(t)},this),this.deviceView.mon(this.deviceStore,"beforeload",this.reloadExfatPkgStatus,this),this.printerView.mon(this.printerView,"selectionchange",function(e,t){var i=this.printerView.getSelectedRecords();if(i&&i[0]){var s=this.panel.getActiveTab();if(!s)return;"printerTab"===s.itemId&&(this.lastSelectedRecord=i[0],this.deviceView.clearSelections())}this.dataViewSelectionChange(t)},this),this.hasVolPollingConf={interval:5,immediate:!0,webapi:{api:"SYNO.Core.Storage.Volume",version:1,method:"list",params:{offset:0,limit:-1,location:this.isUsbStation?"external":"internal"}},status_callback:function(e,t,i,s){var n;e&&(t.code?this.appWin.getMsgBox().alert(this.title,_T("common","commfail"),function(){this.deactivate()},this):(this.blHasUsbshare=!1,this.deviceStore.reload(),this.printerStore.reload(),this.hasVolume=t.total>0,this.isUsbStation&&(n=this.panel.getComponent("printerTab"),this.hasVolume?n.el.unmask():n.el.mask(_T("volume","volume_share_noexternal"),"syno-ux-mask-info")),Ext.getCmp(this.btnAddNPId).enable()))},scope:this},this.BonjourSharingPollingConf={interval:5,immediate:!0,webapi:{api:"SYNO.Core.ExternalDevice.Printer.BonjourSharing",version:1,method:"get"},status_callback:function(e,t,i,s){e&&(this.bonjourPrinterEnabled=t.enable_bonjour_support)},scope:this},this.isUsbStation&&(this.SystemDBPollingConf={interval:5,immediate:!0,webapi:{api:"SYNO.Core.SystemDB",version:1,method:"get"},status_callback:function(e,t,i,s){e&&(this.systemdb_share=t.systemdb_shares)},scope:this}),this.extDevSettingPollingConf={interval:5,immediate:!0,webapi:{api:"SYNO.Core.ExternalDevice.Storage.Setting",version:1,method:"get"},status_callback:function(e,t,i,s){e&&(this.delalloc=t.delalloc,this.forbid_usb=t.forbid_usb,this.needReboot=t.needReboot,this.support_exfat_mkfs=t.support_exfat_mkfs,t.setting?Ext.getCmp(this.btnSettingId).disable():Ext.getCmp(this.btnSettingId).enable())},scope:this}},renderDeviceAriaInfo:function(e){var t=[];return t.push(e.get("title")),t.push(e.get("status")),t.push(_T("usb","usb_producer"),e.get("producer")),t.push(_T("usb","usb_productname"),e.get("product")),Ext.isArray(e.get("partitions"))&&e.get("partitions").forEach(function(e){t.push(_T("common","name"),e.partition_title),t.push(_T("tree","leaf_sharefolder"),e.share_name),t.push(_T("usb","usb_size"),e.usage),t.push(_T("usb","usb_FStype"),e.filesystem)}),t.join(" ")},processDeviceStore:function(){var e=this;return function(t,i){return 0>=i.totalRecords?i:(i.records.forEach(function(t){var i=SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice(t.data.status);t.set("status",i),t.set("title",t.data.dev_title),"usbDisk"==t.get("dev_type")?(t.set("cls","usb-normal-status"),SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("corrupt")==t.get("status")?t.set("cls","usb-error-status"):SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating")!=t.get("status")&&SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("init")!=t.get("status")||t.set("cls","usb-format-status")):"sdCard"==t.get("dev_type")?(t.set("cls","sd-normal-status"),SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("corrupt")==t.get("status")?t.set("cls","sd-error-status"):SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating")!=t.get("status")&&SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("init")!=t.get("status")||t.set("cls","sd-format-status")):"eSataDisk"==t.get("dev_type")&&(t.set("cls","esata-normal-status"),SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("corrupt")==t.get("status")?t.set("cls","esata-error-status"):SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating")!=t.get("status")&&SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("init")!=t.get("status")||t.set("cls","esata-format-status")),void 0!==t.get("producer")&&""!==t.get("producer")||t.set("producer","-"),void 0!==t.get("product")&&""!==t.get("product")||t.set("product","-"),void 0!==t.get("partitions")&&Ext.isArray(t.get("partitions"))&&t.get("partitions").forEach(function(s){if(void 0===s.filesystem||""===s.filesystem)if("exfat"==s.dev_fstype&&"no"==e.appWin._D("disable_exfat","no"))if(e.exFATPkgRunning)s.filesystem=_T("usb","usb_mount_fail");else{var n=Ext.id(),o="<"+_T("usb","usb_install_exfat_link")+">";e.gotoPkgManId?e.gotoPkgManId.push(n):e.gotoPkgManId=[n],s.filesystem=String.format("{2}",n,_T("usb","usb_exfat_not_supported"),o)}else s.filesystem=_T("usb","usb_fs_other");void 0!==s.share_name&&""!==s.share_name||(s.share_name=_T("usb","usb_notmounted")),void 0===s.used_size_mb?s.usage="-- / --":s.total_size_mb>1024?s.usage=Ext.util.Format.round(s.used_size_mb/1024,2)+"/"+Ext.util.Format.round(s.total_size_mb/1024,2)+" GB":s.usage=s.used_size_mb+"/"+s.total_size_mb+" MB","formating"===s.status&&t.set("status",s.partition_title+" "+i+" "+t.get("progress"))},this),t.set("ariaInfo",e.renderDeviceAriaInfo(t))},this),i)}},reloadExfatPkgStatus:function(){var e=this;this.appWin.sendWebAPI({api:"SYNO.Core.Package",version:1,method:"get",params:{id:"exFAT-Free",additional:["status"]},scope:this,callback:function(t,i,s,n){t&&"running"===i.additional.status?e.exFATPkgRunning=i.additional.status:e.exFATPkgRunning=!1}})},onClickExfatPkg:function(e){e.preventDefault(),SYNO.SDS.AdminCenter.ExternalDevices.onClickExfatPkg()},renderPrinterAriaInfo:function(e){var t=[];return t.push(e.get("title")),t.push(e.get("status")),t.push(_T("common","name"),e.get("cups_name")),e.get("ip")&&(t.push(_T("status","status_ipaddr"),e.get("ip")),t.push(_T("usb","net_prntr_ptl"),e.get("protocol")),t.push(_T("usb","net_prntr_qname"),e.get("qname"))),t.push(_T("usb","usb_producer"),e.get("mfg")),t.push(_T("usb","usb_productname"),e.get("mdl")),t.push(_T("usb","usb_printer_command_set"),e.get("printer_cmd_set")),e.get("lockby")&&t.push(_T("usb","usb_printer_wait_queue"),e.get("print_queue")),t.join(" ")},processPrinterStore:function(e){0>=e.length||e.forEach(function(e){if(e.set("title",_T("usb","usb_printer_lpr")),e.set("iconCls","default"),e.set("cls","default"),"usbip"==e.get("printer_mode")){var t=SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbPrinter(e.data.lockby);e.set("title",_T("usb","usb_printer_usbip")),e.set("cls","usbip"),e.set("status",t)}else"netPrinter"==e.get("printer_mode")?"Offline"==e.get("status")?(e.set("cls","np-badstatus"),e.set("status",_T("usbbackup","usbbkp_offline"))):(e.set("cls","np-goodstatus"),e.set("status",_T("usbbackup","usbbkp_online"))):e.set("status",_T("bluetooth","bluetooth_connected"));e.set("ariaInfo",this.renderPrinterAriaInfo(e))},this)},getHelpParam:function(){return"deviceTab"===this.panel.activeTab.itemId?"AdminCenter/system_externaldevice_devicelist.html":"printerTab"===this.panel.activeTab.itemId?"AdminCenter/system_externaldevice_printer.html":"AdminCenter/system_externaldevice_desc.html"},getPanel:function(){return this.panel},activate:function(e){return this.panel.loadAllForm(),e&&e.tab&&this.panel.setActiveTab(e.tab),this.appWin.sendWebAPI({api:"SYNO.Core.ExternalDevice.Printer.Driver",version:1,method:"list",scope:this,callback:function(e,t,i,s){if(!e)return this.loadDriverFailed=!0,this.checkPrinterDriverList(),void(null!==this.npWizard&&this.npWizard.checkDriverList());this.driverList=t,this.loadDriverFailed=!1,this.checkPrinterDriverList(),this.createDeviceId(),null!==this.npWizard&&this.npWizard.checkDriverList()}}),this.pollingTaskStart(),!0},pollingTaskStart:function(){void 0===this.hasVolPollingID&&(this.hasVolPollingID=this.appWin.pollReg(this.hasVolPollingConf)),void 0===this.BonjourSharingPollingID&&(this.BonjourSharingPollingID=this.appWin.pollReg(this.BonjourSharingPollingConf)),this.isUsbStation&&void 0===this.SystemDBPollingID&&(this.SystemDBPollingID=this.appWin.pollReg(this.SystemDBPollingConf)),void 0===this.extDevSettingPollingID&&(this.extDevSettingPollingID=this.appWin.pollReg(this.extDevSettingPollingConf))},pollingTaskStop:function(){void 0!==this.hasVolPollingID&&(this.appWin.pollUnreg(this.hasVolPollingID),this.hasVolPollingID=void 0),void 0!==this.BonjourSharingPollingID&&(this.appWin.pollUnreg(this.BonjourSharingPollingID),this.BonjourSharingPollingID=void 0),this.isUsbStation&&void 0!==this.SystemDBPollingID&&(this.appWin.pollUnreg(this.SystemDBPollingID),this.SystemDBPollingID=void 0),void 0!==this.extDevSettingPollingID&&(this.appWin.pollUnreg(this.extDevSettingPollingID),this.extDevSettingPollingID=void 0)},deactivate:function(){return this.pollingTaskStop(),this.printerForm=null,this.driverList=null,this.brandList=null,!0},createPanel:function(){var e=new SYNO.ux.Panel(this.createDeviceTabObj()),t=new SYNO.ux.Panel(this.createPrinterTabObj()),i=[];this.appWin._D("unique");SYNO.SDS.Utils.isInVirtualDSM()||i.push(e),"yes"===this.appWin._D("support_printer")&&i.push(t),this.panel=new SYNO.SDS.Utils.TabPanel({module:this,padding:"4px 0px 0px 0px",title:_T("controlpanel","devices_and_printers"),activeTab:0,items:i}),this.panel.mon(this.printerStore,"load",this.checkPrinterPort,this)},createDeviceViewTpl:function(e){var t='
    {0}
    ',i='
    {0}
    ',s=new Ext.XTemplate('',"
    ",'
    {partition_title}
    ','
    {share_name}
    ','
    {usage}
    ','
    {filesystem}
    ',"
    ",'
    ',"
    ");return new Ext.XTemplate('',"
    ",String.format(t,_T("usb","usb_producer")+_T("common","colon")),String.format(i,"{producer}"),"
    ",'
    ',"
    ",String.format(t,_T("usb","usb_productname")+_T("common","colon")),String.format(i,"{product}"),"
    ",'
    ',"
    ",'','
    ','
    ',"
    ",String.format('
    {0}
    ',_T("common","name")),String.format('
    {0}
    ',_T("tree","leaf_sharefolder")),String.format('
    {0}
    ',_T("usb","usb_size")),String.format('
    {0}
    ',_T("usb","usb_FStype")),"
    ",'
    ',"
    ",'
    ',s.html,"
    ","
    ",'
    ',"
    ")},createDeviceTabObj:function(){var e=[{xtype:"syno_button",text:_T("smart","smart_toolbar_smart_info"),id:this.btnInfoId=Ext.id(),disabled:!0,hidden:!1,scope:this,handler:this.onClickInfoBtn},{xtype:"syno_button",text:_T("smart","smart_toolbar_smart_test"),id:this.btnTestId=Ext.id(),disabled:!0,hidden:!1,scope:this,handler:this.onClickTestBtn},{xtype:"syno_button",text:_T("usb","usb_btnformat"),id:this.btnFormatId=Ext.id(),disabled:!0,scope:this,handler:this.onClickFormatBtn},{xtype:"syno_button",text:_T("usb","usb_eject"),id:this.btnEjectId=Ext.id(),disabled:!0,tooltip:String.format(_T("usb","usb_ejectnote"),_T("usb","usb_eject")),scope:this,handler:this.onClickEjectBtn},{xtype:"syno_button",text:_T("download","download_table_heading_setting"),id:this.btnSettingId=Ext.id(),disabled:!0,scope:this,handler:this.onClickSettingBtn}],t=new Ext.Toolbar({style:{"padding-bottom":"8px"},items:e});return this.deviceView=new SYNO.ux.ExpandableListView({useARIA:!0,store:this.deviceStore,innerTpl:this.createDeviceViewTpl(),trackResetOnLoad:!1,cls:"ex-dev-storage-listview"}),{itemId:"deviceTab",title:_T("tree","node_device"),trackResetOnLoad:!0,layout:"fit",hideMode:"offsets",tbar:t,items:[this.deviceView]}},createPrinterViewTpl:function(){var e='
    {0}
    ',t='
    {0}
    ';return new Ext.XTemplate("","
    ",String.format(e,_T("common","name")+_T("common","colon")),String.format(t,"{cups_name}"),'
    ','',"
    ",String.format(e,_T("status","status_ipaddr")+_T("common","colon")),String.format(t,"{ip}"),'
    ',"
    ",String.format(e,_T("usb","net_prntr_ptl")+_T("common","colon")),String.format(t,"{protocol}"),'
    ',"
    ",String.format(e,_T("usb","net_prntr_qname")+_T("common","colon")),String.format(t,"{qname}"),'
    ',"
    ","
    ",String.format(e,_T("usb","usb_producer")+_T("common","colon")),String.format(t,"{mfg}"),'
    ',"
    ",String.format(e,_T("usb","usb_productname")+_T("common","colon")),String.format(t,"{mdl}"),'
    ',"
    ",String.format(e,_T("usb","usb_printer_command_set")+_T("common","colon")),String.format(t,"{printer_cmd_set}"),'
    ','',"
    ",String.format(e,_T("usb","usb_printer_wait_queue")+_T("common","colon")),String.format(t,"{print_queue}"),'
    ',"
    ","
    ")},createPrinterTabObj:function(){var e=[{xtype:"syno_button",text:_T("usb","net_prntr_add"),id:this.btnAddNPId=Ext.id(),disabled:!0,scope:this,handler:this.onClickAddNPBtn},{xtype:"syno_button",text:_T("common","remove"),id:this.btnPEjectId=Ext.id(),disabled:!0,scope:this,handler:this.onClickEjectBtn}],t=[{text:_T("usb","usb_printer_usbip_setup"),id:this.btnSetupId=Ext.id(),disabled:!0,scope:this,handler:this.onClickSetupBtn},{text:_T("usb","usb_cleannote").replace("_CLEAN_",_T("usb","usb_clean")),id:this.printerCleanSpoolBtnId=Ext.id(),disabled:!0,scope:this,disableClearLastDom:!0,handler:this.printerCleanSpool},{text:_T("usb","usb_print_test_page"),id:this.printTestPageId=Ext.id(),disabled:!0,scope:this,disableClearLastDom:!0,handler:this.printTestPage},{text:_T("usb","usb_printer_usbip_release_lock"),id:this.btnPrinterReleaseLockId=Ext.id(),disabled:!0,scope:this,disableClearLastDom:!0,handler:this.printerReleaseLock}];"yes"!==this.appWin._D("supportMFP")&&t.pop(),e.push(new Ext.Action({xtype:"syno_button",text:_T("usb","prntr_mgr"),scope:this,id:this.btnPrintmgrId=Ext.id(),disabled:!0,menu:new SYNO.ux.Menu({items:t})}));var i=new Ext.Toolbar({style:{"padding-bottom":"8px"},items:e,defaultType:"syno_button"});return this.printerView=new SYNO.ux.ExpandableListView({useARIA:!0,store:this.printerStore,innerTpl:this.createPrinterViewTpl(),cls:"ex-dev-printer-listview"}),{itemId:"printerTab",title:_T("usb","prntr_device"),trackResetOnLoad:!0,layout:"fit",hideMode:"offsets",tbar:i,listeners:{activate:function(e){this.printerView.refresh()},scope:this},items:[this.printerView]}},checkPrinterPort:function(){var e=!1,t=!1,i=!1;this.printerStore.each(function(s){switch(s.get("printer_mode")){case"usbip":e=!0;break;case"favor_lpr":case"netPrinter":t=!0}"on"===s.get("airprint_enabled")&&(i=!0)},this),e&&SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.usbip",!1),t&&SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.favor_lpr",!1),i&&SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.airprint",!1)},dataViewSelectionChange:function(e){var t;if(Ext.getCmp(this.btnInfoId).disable(),Ext.getCmp(this.btnInfoId).hide(),Ext.getCmp(this.btnTestId).disable(),Ext.getCmp(this.btnTestId).hide(),Ext.getCmp(this.btnFormatId).disable(),Ext.getCmp(this.btnEjectId).disable(),Ext.getCmp(this.btnPEjectId).disable(),Ext.getCmp(this.printerCleanSpoolBtnId).disable(),Ext.getCmp(this.printTestPageId).disable(),Ext.getCmp(this.btnSetupId).disable(),Ext.getCmp(this.btnPrintmgrId).disable(),"yes"===this.appWin._D("supportMFP")&&Ext.getCmp(this.btnPrinterReleaseLockId).disable(),!(e.length<=0)){"deviceTab"==this.panel.getActiveTab().itemId?t=this.lastSelectedRecord.get("dev_type"):"printerTab"==this.panel.getActiveTab().itemId&&(t=this.lastSelectedRecord.get("printer_mode"));var i=this.lastSelectedRecord.get("status");switch(t){case"usbDisk":case"sdCard":if(-1==i.indexOf(SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating"))&&i!==SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating")&&i!==SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("init")&&Ext.getCmp(this.btnEjectId).enable(),this.lastSelectedRecord.get("formatable"))switch(i){case SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("normal"):case SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("hddfail"):case SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("corrupt"):Ext.getCmp(this.btnFormatId).enable()}break;case"eSataDisk":Ext.getCmp(this.btnInfoId).show(),Ext.getCmp(this.btnTestId).show(),i==SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("normal")&&Ext.getCmp(this.btnFormatId).enable(),-1==i.indexOf(SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating"))&&i!=SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating")&&i!=SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("init")&&(Ext.getCmp(this.btnEjectId).enable(),Ext.getCmp(this.btnInfoId).enable(),Ext.getCmp(this.btnTestId).enable());break;case"usbip":case"lpr":case"favor_lpr":var s=this.lastSelectedRecord;Ext.getCmp(this.btnPEjectId).enable(),Ext.getCmp(this.btnSetupId).enable(),Ext.getCmp(this.btnPrintmgrId).enable(),"yes"===this.appWin._D("supportMFP")&&"usbip"===this.lastSelectedRecord.get("printer_mode")?"Free"===s.get("lockby")?Ext.getCmp(this.btnPrinterReleaseLockId).disable():Ext.getCmp(this.btnPrinterReleaseLockId).enable():Ext.getCmp(this.printerCleanSpoolBtnId).enable(),""!==s.get("driver_model")&&s.get("enable_airprint")&&Ext.getCmp(this.printTestPageId).enable();break;case"netPrinter":var n=this.lastSelectedRecord;Ext.getCmp(this.btnPEjectId).enable(),Ext.getCmp(this.btnSetupId).enable(),Ext.getCmp(this.btnPrintmgrId).enable(),Ext.getCmp(this.printerCleanSpoolBtnId).enable(),""!==n.get("driver_model")&&n.get("enable_airprint")&&Ext.getCmp(this.printTestPageId).enable()}}},getFormatDataList:function(e){var t=[];return Ext.each(e.json.partitions,function(e){var i=[];i.push(e.name_id,e.partition_title),t.push(i)},this),t},onClickInfoBtn:function(){var e="/dev/"+this.lastSelectedRecord.get("dev_id"),t=this.lastSelectedRecord.get("dev_title");this.InfoFormPanel=new SYNO.SDS.StorageManager.SmartInfo({owner:this.appWin,appWin:this.appWin,style:"padding: 0px 20px;",height:450}),this.InfoDialog=new SYNO.SDS.ModalWindow({owner:this.appWin,dsmStyle:"v5",resizable:!1,width:700,height:510,hideLabel:!1,title:_T("smart","smart_toolbar_smart_info")+" "+t,buttons:[{text:_T("common","alt_close"),scope:this,handler:function(){this.InfoDialog.close()}}],items:this.InfoFormPanel}),this.InfoDialog.open(),this.appWin.sendWebAPI({api:"SYNO.Core.Storage.Disk",version:1,method:"get_smart_info",params:{device:e},callback:function(e,t,i,s){e?this.InfoFormPanel.getComponent("grid").getStore().loadData(t):this.appWin.getMsgBox().alert(_T("tree","node_device"),_T("common","error_system"))},scope:this})},onClickTestBtn:function(){var e="/dev/"+this.lastSelectedRecord.get("dev_id");this.TestDialog=new SYNO.SDS.StorageManager.Wizard.SmartTest({owner:this.appWin,device:e,blExternal:!0}),this.TestDialog.open()},onClickFormatBtn:function(){if(0!==this.deviceView.getSelectionCount()){this.pollingTaskStop();var e=this.lastSelectedRecord.get("dev_type"),t=this.lastSelectedRecord.get("dev_title"),i=this.getFormatDataList(this.lastSelectedRecord),s=_T("sata","sata_format_wizard_fs_type");"usbDisk"!=e&&"sdCard"!=e||(s=_T("usb","usb_format_wizard_fs_type"));var n={border:!1,owner:this.appWin,webapi:{methods:{set:"format"},version:1},items:[{xtype:"syno_fieldset",title:_T("externaldevice","externaldevice_format_option"),items:[{xtype:"syno_radio",name:"formatopt",inputValue:"entiredisk",boxLabel:_T("externaldevice","externaldevice_format_entire_disk"),checked:!0},{xtype:"syno_displayfield",indent:1,value:_T("externaldevice","externaldevice_format_entire_disk_desc")},{xtype:"syno_radio",name:"formatopt",inputValue:"selectpartition",boxLabel:_T("externaldevice","externaldevice_format_selected_partition"),disabled:i.length<2,checked:!1},{xtype:"syno_combobox",indent:1,width:250,hideLabel:!0,value:i.length?i[0][0]:"",name:"partitions",displayField:"display",valueField:"value",autoDestroy:!0,triggerAction:"all",editable:!1,mode:"local",disabled:!0,store:new Ext.data.ArrayStore({fields:["value","display"],data:i})}]},{xtype:"syno_fieldset",title:s,items:this.support_exfat_mkfs?[{xtype:"syno_radio",name:"filesystem",inputValue:"ext4",boxLabel:_T("volume","volume_ext4"),checked:!0},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,value:_T("volume","volume_ext4_desc")},{xtype:"syno_radio",name:"filesystem",inputValue:"fat",boxLabel:_T("usb","usb_fat32")},{xtype:"syno_radio",name:"filesystem",inputValue:"exfat",boxLabel:_T("usb","usb_exfat")},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,value:''+_T("common","note")+_T("common","colon")+" "+_T("usb","usb_exfat_fat32_descr")}]:[{xtype:"syno_radio",name:"filesystem",inputValue:"ext4",boxLabel:_T("volume","volume_ext4"),checked:!0},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,value:_T("volume","volume_ext4_desc")},{xtype:"syno_radio",name:"filesystem",inputValue:"fat",boxLabel:_T("usb","usb_fat32")},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,value:''+_T("common","note")+_T("common","colon")+" "+_T("usb","usb_fat32_descr")}]}]};this.formatFormPanel=new SYNO.SDS.Utils.FormPanel(n),this.formatDialog=new SYNO.SDS.ModalWindow({owner:this.appWin,layout:"fit",width:600,height:520,resizable:!1,hideLabel:!1,title:_T("usb","usb_btnformat")+" "+t,buttons:[{text:_T("common","cancel"),scope:this,handler:function(){this.formatDialog.close(),this.pollingTaskStart()}},{btnStyle:"blue",text:_T("common","ok"),scope:this,handler:this.formatHandler}],items:this.formatFormPanel,listeners:{scope:this,afterrender:function(){new SYNO.ux.Utils.EnableRadioGroup(this.formatFormPanel.getForm(),"formatopt",{entiredisk:[],selectpartition:["partitions"]})}}}),this.formatDialog.open()}},formatHandler:function(){var e=this.formatFormPanel.getForm(),t=this.lastSelectedRecord.get("share_name"),i=e.findField("partitions"),s="",n=this.lastSelectedRecord.get("dev_id"),o=this.lastSelectedRecord.get("dev_type"),a=this.lastSelectedRecord.get("dev_title"),r=0,l="";if(""===t||t==_T("usb","usb_inactive_disk")){if("selectpartition"===e.findField("formatopt").getGroupValue()){a=i.findRecord(i.valueField,i.getValue()).get(i.displayField);var d=i.store.find("display",a);r=this.lastSelectedRecord.json.partitions[d].total_size_mb}else r=this.lastSelectedRecord.get("total_size_mb");s=(s=String.format(_T("usb","usb_formatwarn_noshare"),a))+" "+_T("usb","format_disk_confirm")}else s=_T("volume","volume_adddisk_type_two_warning");var c=e.findField("filesystem").getGroupValue();("ext3"===c||"ext4"===c)&&rSYNO.SDS.AdminCenter.ExternalDevices.FAT_FORMAT_MAX_MB_SIZE?(l=String.format(_T("usb","usb_format_fat_size_warning"),a),this.formatDialog.getMsgBox().alert(_T("usb","usb_btnformat"),l)):this.formatDialog.getMsgBox().confirm(_T("usb","usb_btnformat"),s,function(t,s){if("yes"==t){var a,r=e.getValues();"entiredisk"===e.findField("formatopt").getGroupValue()?r.dev_id=n:r.dev_id=i.getValue(),a="usbDisk"==o||"sdCard"==o?"SYNO.Core.ExternalDevice.Storage.USB":"SYNO.Core.ExternalDevice.Storage.eSATA",e.webapi.api=a,e.doAction("apply",{method:"POST",params:r}),this.lastSelectedRecord.set("status",SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice("formating")),"usbDisk"==this.lastSelectedRecord.get("dev_type")?this.lastSelectedRecord.set("cls","usb-format-status"):"sdCard"==this.lastSelectedRecord.get("dev_type")?this.lastSelectedRecord.set("cls","sd-format-status"):"eSataDisk"==this.lastSelectedRecord.get("dev_type")&&this.lastSelectedRecord.set("cls","esata-format-status"),Ext.getCmp(this.btnFormatId).disable(),Ext.getCmp(this.btnEjectId).disable(),Ext.getCmp(this.btnInfoId).disable(),Ext.getCmp(this.btnTestId).disable(),this.pollingTaskStart(),this.formatDialog.close()}},this)},onClickExternalDefaultPermission:function(){new SYNO.SDS.AdminCenter.ExternalDevices.ExternalDefaultPermissionDialog({owner:this.appWin,module:this.module}).loadPermissionData()},onClickEjectBtn:function(){if(0!==this.deviceView.getSelectionCount()||0!==this.printerView.getSelectionCount()){var e=_T("usb","usb_ejectwarn");if(this.isUsbStation)this.deviceView.getSelectedRecords().forEach(function(t){t.data.partitions.forEach(function(t){this.systemdb_share===t.share_name&&(e=_T("system","eject_sys_database_warning"))},this)},this);this.appWin.getMsgBox().confirm(_T("tree","node_device"),e,function(e,t){"yes"==e&&(this.pollingTaskStop(),this.doEjectAction(),this.pollingTaskStart())},this)}},doEjectAction:function(){var e,t="SYNO.SDS.CMS.Application"===this.appWin.getOpenConfig("className"),i=!1,s=_T("tree","node_device"),n={method:"eject",version:1,params:{}};if("deviceTab"==this.panel.getActiveTab().itemId?e=this.lastSelectedRecord.get("dev_type"):"printerTab"==this.panel.getActiveTab().itemId&&(e=this.lastSelectedRecord.get("printer_mode")),"usbDisk"==e||"sdCard"==e?(n.api="SYNO.Core.ExternalDevice.Storage.USB",n.params.dev_id=this.lastSelectedRecord.get("dev_id")):"eSataDisk"==e?(n.api="SYNO.Core.ExternalDevice.Storage.eSATA",n.params.dev_id=this.lastSelectedRecord.get("dev_id")):"netPrinter"==e?(n.api="SYNO.Core.ExternalDevice.Printer.Network",n.params.printer_id=this.lastSelectedRecord.get("printer_id"),i=!0):(n.api="SYNO.Core.ExternalDevice.Printer.USB",n.params.printer_id=this.lastSelectedRecord.get("printer_id"),i=!0),i&&!1===this.hasVolume)return t?void this.appWin.getMsgBox().alert(s,_T("cms","cms_no_volumes")):void this.appWin.getMsgBox().alert(s,this.isUsbStation?_T("volume","volume_share_volumeno"):_T("error","volume_no_volumes"),function(e){"ok"===e&&SYNO.SDS.AppLaunch("SYNO.SDS.StorageManager.Instance")},this);this.appWin.setStatusBusy({text:_T("common","loading")},.4,1),this.appWin.sendWebAPI({api:n.api,version:n.version,method:n.method,params:n.params,timeout:36e5,scope:this,callback:function(e,t,i,n){var o;if(!e)return o=SYNO.API.getErrorString(t.code),this.appWin.getMsgBox().alert(s,o),void this.appWin.clearStatusBusy();SYNO.SDS.StatusNotifier.fireEvent("externaldeviceactivity","ejectdevice"),"printerTab"===this.panel.getActiveTab().getItemId()?(this.printerView.deselect(this.lastSelectedRecord),this.printerStore.reload_withmask.call(this)):(this.deviceView.deselect(this.lastSelectedRecord),this.deviceStore.reload_withmask.call(this))}})},onClickSettingBtn:function(){this.pollingTaskStop(),this.settingDialog=new SYNO.SDS.AdminCenter.ExternalDevices.ExternalSettingDialog({owner:this.appWin,module:this.module},{delalloc:this.delalloc,forbid_usb:this.forbid_usb,needReboot:this.needReboot,support_exfat_mkfs:this.support_exfat_mkfs,btnSettingId:this.btnSettingId,btnFormatId:this.btnFormatId,btnEjectId:this.btnEjectId}),this.settingDialog.mon(this.settingDialog,"close",function(){this.pollingTaskStart.defer(1e3,this)},this,{single:!0}),this.settingDialog.open()},checkBonjourPrinter:function(e,t){t&&!this.bonjourPrinterEnabled&&this.appWin.getMsgBox().confirm(_T("usb","usb_printer_airprint"),String.format(_T("usb","usb_printer_airprint_notice"),_T("network","bonjourPrinter_subject")),function(t){"no"===t&&e.setValue(!1)},this)},fillPrinterItems:function(e){if(this.isUsbPrntr=!0,e.push({xtype:"syno_fieldset",title:_T("usb","prntr_ap_gcp_setting"),name:"airprint_field",items:[{xtype:"syno_checkbox",name:"enable_airprint",boxLabel:_T("usb","usb_printer_airprint_enable")},{xtype:"syno_checkbox",name:"fit_to_page",boxLabel:_T("usb","fit_to_page")},{xtype:"syno_combobox",name:"driver_brand",fieldLabel:_T("usb","usb_printer_brand"),displayField:"value",autoSelect:!0,width:250,store:this.brandList=new Ext.data.ArrayStore({fields:["value"]}),listeners:{scope:this,select:function(e){var t=this.printerForm.findField("driver_model");t.getStore().loadData(this.driverList[e.getValue()]),t.setValue(t.getStore().getAt(0).get("value"))}}},{xtype:"syno_combobox",name:"driver_model",fieldLabel:_T("usb","usb_printer_driver"),displayField:"value",valueField:"value",autoSelect:!0,width:250,store:new Ext.data.ArrayStore({fields:["value"]})},{xtype:"syno_displayfield",name:"loading_status",value:_T("usb","usb_printer_driver_loading")}]},{xtype:"syno_textfield",name:"printer_id",hidden:!0}),"netPrinter"==this.lastSelectedRecord.json.printer_mode)this.isUsbPrntr=!1,this.fillNetPrinterItems(e);else{if("yes"!=this.appWin._D("supportMFP"))return;this.fillUsbPrinterItems(e)}},fillNetPrinterItems:function(e){e.unshift({xtype:"syno_fieldset",itemId:"ptl_setting",title:_T("usb","net_prntr_conf"),items:[{xtype:"syno_displayfield",name:"ip",width:250,fieldLabel:_T("common","ip_addr")},{xtype:"syno_textfield",name:"cups_name",id:this.NameId=Ext.id(),fieldLabel:_T("usb","net_prntr_name"),enableKeyEvents:!0,allowBlank:!1,maxlength:32,width:250,validationEvent:"keyup",validator:function(){return 0<=this.getValue().search(/[^a-zA-Z0-9_]/)?_T("error","error_bad_field"):(this.clearInvalid(),!0)}},{xtype:"syno_combobox",name:"protocol",width:250,fieldLabel:_T("usb","net_prntr_ptl"),autoSelect:!0,allowBlank:!1,store:this.backendList,displayField:"protocol_text",valueField:"protocol_id"},{xtype:"syno_textfield",allowBlank:!1,fieldLabel:_T("usb","net_prntr_qname"),name:"qname",width:250,enableKeyEvents:!0,maxlength:32,validationEvent:"keyup",validator:function(){var e=this.getValue();return 0<=e.search("usbprinter")?_T("error","error_bad_field"):this.originalValue===e||""===this.originalValue||(0<=e.search(/[^a-zA-Z0-9_]/)?_T("error","error_bad_field"):(this.clearInvalid(),!0))}}]})},fillUsbPrinterItems:function(e){e.unshift({xtype:"syno_fieldset",itemId:"mode_setting",title:_T("usb","usb_printer_mode"),items:[{xtype:"syno_radio",name:"printer_mode",inputValue:"favor_lpr",boxLabel:_T("usb","usb_printer_lpr_prefer_title")},{xtype:"syno_displayfield",indent:1,value:_T("usb","usb_printer_lpr_prefer_desc")},{xtype:"syno_radio",name:"printer_mode",inputValue:"usbip",boxLabel:_T("usb","usb_printer_usbip_prefer_title")},{xtype:"syno_displayfield",indent:1,value:_T("usb","usb_printer_usbip_prefer_desc")}]},{xtype:"syno_textfield",name:"cups_name",hidden:!0},{xtype:"syno_textfield",name:"mdl",hidden:!0},{xtype:"syno_textfield",name:"mfg",hidden:!0})},CheckBrandDriver:function(){this.printerForm.findField("enable_airprint").getValue()?(this.printerForm.findField("driver_brand").enable(),this.printerForm.findField("driver_model").enable(),this.printerForm.findField("fit_to_page").enable()):(this.printerForm.findField("driver_brand").disable(),this.printerForm.findField("driver_model").disable(),this.printerForm.findField("fit_to_page").disable())},onClickSetupBtn:function(){var e=null;if(0!==this.printerView.getSelectionCount())if(this.hasVolume){var t;this.pollingTaskStop();var i=[];this.fillPrinterItems(i),t={border:!1,trackResetOnLoad:!0,items:i},this.printerSetupDialog=new SYNO.SDS.ModalWindow({owner:this.appWin,layout:"fit",module:this,width:580,height:!1===this.isUsbPrntr?580:"yes"===this.appWin._D("supportMFP")?580:520,resizable:!0,hideLabel:!1,title:_T("usb","usb_printer_usbip_setup"),savePrinterMode:function(){if(this.printerForm.isValid())if(this.printerForm.isDirty()){var t,i=e.getForm().getValues();(i=Ext.apply({google_cloud_print:{}},i)).google_cloud_print.enable=!1,delete i.enable_gcp,delete i.gcp_account,delete i.gcp_passwd,delete i.mfg,delete i.mdl,this.isUsbPrntr?t="SYNO.Core.ExternalDevice.Printer.USB":(t="SYNO.Core.ExternalDevice.Printer.Network",void 0===i.qname&&(i.qname="")),this.printerForm.findField("enable_airprint").getValue()&&this.printerForm.findField("fit_to_page").getValue()?i.fit_to_page=!0:i.fit_to_page=!1,this.printerSetupDialog.setStatusBusy({text:_T("common","saving")}),this.appWin.sendWebAPI({api:t,version:1,method:"set",scope:this,params:i,timeout:3e5,callback:function(e,t,i,s){var n;if(this.printerSetupDialog.clearStatusBusy(),this.printerSetupDialog.unmask(),!e)return n=SYNO.API.getErrorString(t.code),void this.printerSetupDialog.getMsgBox().alert(_T("tree","node_device"),n);this.printerSetupDialog.setStatusOK({text:_T("common","setting_applied")});var o=this.printerForm.getValues(),a=this.printerForm.findField("enable_airprint");if(this.printerForm.setValues(o),a.originalValue=a.getValue(),"SYNO.Core.ExternalDevice.Printer.Network"==s.params.api){var r="",l="";this.printerForm.findField("printer_id")&&(l=(r=this.printerForm.findField("printer_id").getValue()).substr(0,r.indexOf("-")+1),l+=this.printerForm.findField("cups_name").getValue(),this.printerForm.findField("printer_id").setValue(l))}switch(this.printerSetupDialog.blNeedReload=!0,s.params.printer_mode){case"usbip":SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.usbip",!1);break;case"favor_lpr":case"netPrinter":SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.favor_lpr",!1)}s.params.enable_airprint&&SYNO.SDS.StatusNotifier.setServiceDisabled("SYNO.SDS.AdminCenter.ExternalDevices.airprint",!1)}})}else this.printerSetupDialog.setStatusError({text:_T("error","nochange_subject"),clear:!0});else this.printerSetupDialog.setStatusError({text:_T("common","forminvalid"),clear:!0})},buttons:[{text:_T("common","close"),scope:this,handler:this.onClose},{btnStyle:"blue",text:_T("common","save"),scope:this,handler:this.onSave}],items:e=new SYNO.SDS.Utils.FormPanel(t)}),this.printerForm=e.getForm(),this.printerSetupDialog.blNeedReload=!1,this.panel.mon(e,"afterlayout",function(e,t){this.afterLayout(e,t)},this),this.printerSetupDialog.open()}else this.appWin.getMsgBox().alert(this.title,this.isUsbStation?_T("volume","volume_share_volumeno"):_T("error","volume_no_volumes"))},onSave:function(){this.printerSetupDialog.savePrinterMode.call(this)},onClose:function(){var e=this;this.printerSetupDialog.blNeedReload&&this.printerStore.reload_withmask.call(this),this.printerForm.isDirty()?this.printerSetupDialog.confirmLostChangePromise({save:function(){e.onSave()},dontSave:function(){e.printerSetupDialog.close(),e.pollingTaskStart()},cancel:Ext.emptyFn}):(e.printerSetupDialog.close(),e.pollingTaskStart())},afterLayout:function(e,t){if(this.printerForm.findField("enable_airprint").on("check",this.CheckBrandDriver,this),"netPrinter"==this.lastSelectedRecord.json.printer_mode&&(this.panel.mon(this.printerForm.findField("protocol"),"select",function(){"bjnp"===this.printerForm.findField("protocol").getValue()||"socket"===this.printerForm.findField("protocol").getValue()?(this.printerForm.findField("qname").disable(),this.printerForm.findField("qname").clearInvalid()):this.printerForm.findField("qname").enable()},this),SYNO.ux.AddTip(this.printerForm.findField("qname").getEl(),_T("usb","net_qname_tip"))),0!==this.printerView.getSelectionCount()){var i=this.lastSelectedRecord.data;this.printerForm.setValues(i),"netPrinter"==this.lastSelectedRecord.json.printer_mode&&this.printerForm.findField("protocol").fireEvent("select")}this.panel.mon(this.printerForm.findField("enable_airprint"),"check",this.checkBonjourPrinter,this),this.checkPrinterDriverList(),this.CheckBrandDriver()},detectDriver:function(){var e,t,i,s=null,n=null,o=!1,a=function(e,t){var i=e.split(" "),s=i.length-1,n=i[s].toLowerCase(),o=t.toLowerCase();for(0<=i[s].search(/(ser|printer)/i)&&0o.search(n))};t=this.lastSelectedRecord.get("mfg"),i=this.lastSelectedRecord.get("mdl"),e=this.lastSelectedRecord.get("mdl"),""!==(n=this.lastSelectedRecord.get("driver_model"))?s=this.lastSelectedRecord.get("driver_brand"):""!==t&&""!==i&&(s=this.mfgList[t],n=this.mdlList[i]),s&&n?o=!0:null===(s=function(e,t){for(var i in e)if(i.toLowerCase()===t.toLowerCase())return i;return null}(this.driverList,this.lastSelectedRecord.get("driver_brand")))?Ext.iterate(this.driverList,function(t,i){return Ext.each(i,function(i){return!a(e,i[0])||(n=i[0],s=t,o=!0,!1)},this),!o},this):Ext.each(this.driverList[s],function(t){return!a(e,t[0])||(n=t[0],o=!0,!1)},this);var r=this.printerForm.findField("driver_brand"),l=this.printerForm.findField("driver_model");null!==s?(r.onSelect(r.findRecord("value",s)),r.originalValue=r.getValue(),o&&(l.setValue(n),l.originalValue=l.getValue())):r.onSelect(r.getStore().getAt(0))},checkPrinterDriverList:function(){if(null!==this.printerForm){var e=null!==this.driverList,t=[],i=this.printerForm.findField("loading_status");this.loadDriverFailed&&i.setValue(_T("usb","usb_printer_driver_loading_fail")),i.originalValue=i.getValue(),SYNO.ux.Utils.displayFormField(this.printerForm,"enable_airprint",e),SYNO.ux.Utils.displayFormField(this.printerForm,"fit_to_page",e),SYNO.ux.Utils.displayFormField(this.printerForm,"driver_brand",e),SYNO.ux.Utils.displayFormField(this.printerForm,"driver_model",e),SYNO.ux.Utils.displayFormField(this.printerForm,"loading_status",!e),e&&0===this.brandList.getCount()&&(Ext.iterate(this.driverList,function(e){t.push([e])},this),this.brandList.loadData(t)),e&&this.detectDriver()}},createDeviceId:function(){this.driverList&&Ext.iterate(this.driverList,function(e,t){Ext.each(t,function(t){if(""===t[3]||""===t[2])return!0;this.mfgList[t[2]]=e,this.mdlList[t[3]]=t[0]},this)},this)},printTestPage:function(){var e=this.appWin;this.hasVolume?(e.setStatusBusy({text:_T("common","msg_waiting")}),this.appWin.sendWebAPI({api:"SYNO.Core.ExternalDevice.Printer",version:1,method:"print_test",params:{printer_id:this.lastSelectedRecord.get("printer_id")},callback:function(t,i,s,n){e.clearStatusBusy(),t?e.setStatusOK({text:_T("common","completed")}):this.appWin.getMsgBox().alert(_T("tree","node_device"),_T("common","error_system"))},scope:this})):this.appWin.getMsgBox().alert(this.title,this.isUsbStation?_T("volume","volume_share_volumeno"):_T("error","volume_no_volumes"))},printerCleanSpool:function(){var e=this.appWin;e.setStatusBusy({text:_T("common","msg_waiting")}),this.appWin.sendWebAPI({api:"SYNO.Core.ExternalDevice.Printer",version:1,method:"clean",callback:function(t,i,s,n){e.clearStatusBusy(),t?e.setStatusOK({text:_T("common","completed")}):this.appWin.getMsgBox().alert(_T("tree","node_device"),_T("common","error_system"))},scope:this})},printerReleaseLock:function(){var e=this.appWin;this.appWin.getMsgBox().confirm(_T("usb","usb_printer_usbip_release_lock"),_T("usb","usb_printer_usbip_release_lock_warning"),function(t,i){"yes"==t&&(e.setStatusBusy({text:_T("common","msg_waiting")}),this.appWin.sendWebAPI({api:"SYNO.Core.ExternalDevice.Printer.USB",version:1,method:"release_mfp",params:{printer_id:this.lastSelectedRecord.get("printer_id")},callback:function(t,i,s,n){e.clearStatusBusy(),t?(e.setStatusOK({text:_T("common","completed")}),Ext.getCmp(this.btnPrinterReleaseLockId).disable()):this.appWin.getMsgBox().alert(_T("tree","node_device"),_T("common","error_system"))},scope:this}))},this)},onClickAddNPBtn:function(){var e="SYNO.SDS.CMS.Application"===this.appWin.getOpenConfig("className");if(!1===this.hasVolume)return e?void this.appWin.getMsgBox().alert(this.title,this.isUsbStation?_T("volume","volume_share_volumeno"):_T("cms","cms_no_volumes")):void this.appWin.getMsgBox().alert(_T("tree","node_device"),this.isUsbStation?_T("volume","volume_share_volumeno"):_T("error","volume_no_volumes"),function(e){"ok"!==e||this.isUsbStation||SYNO.SDS.AppLaunch("SYNO.SDS.StorageManager.Instance")},this);this.npWizard=new SYNO.SDS.AdminCenter.ExternalDevices.AddNetPrinterWizardDialog({owner:this.appWin,module:this,blHasUsbshare:this.blHasUsbshare,loadDriverFailed:this.loadDriverFailed,printerStore:this.printerStore}),this.npWizard.mon(this.npWizard,"close",function(){this.npWizard=null},this,{single:!0}),this.npWizard.open()}}),SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbPrinter=function(e){return"Free"===e?_T("usb","usb_printer_usbip_free"):-1!=e.indexOf("CUPS")?_T("usb","usb_printer_lpr_printing"):String.format(_T("usb","usb_printer_usbip_lockby"),e)},SYNO.SDS.AdminCenter.ExternalDevices.getStatusForUsbDevice=function(e){switch(e.toLowerCase()){case"normal":return _T("usb","usb_st_normal");case"formating":return _T("usb","usb_st_format");case"hddfail":return _T("usb","usb_st_fail");case"corrupt":return _T("usb","usb_st_needfsck");case"init":return _T("usb","usb_st_init");case"fsck":return _T("usb","usb_st_fsck");case"usbbackup":return _T("usb","usb_st_backingup");default:return _T("bluetooth","bluetooth_connected")}},Ext.ns("SYNO.SDS.AdminCenter.Update"),Ext.define("SYNO.SDS.AdminCenter.Update.UploadDialog",{extend:"SYNO.SDS.ModalWindow",mainFileButtonID:null,passiveFileButtonID:null,constructor:function(e){this.uploadInfo=null,this.activePatchInfo=null,this.passivePatchInfo=null,this.owner=e.owner,this.mainModel=e.mainModel,this.passiveModel=e.passiveModel;var t=Ext.apply({dsmStyle:"v5",title:_T("update","update_dsm_manually"),resizable:!1,closable:!0,width:600,height:350,useStatusBar:!0,padding:"16px 20px 0px 20px",items:this.getItems(),layout:{type:"vbox",align:"stretch"},listeners:{show:this.updateFileTextField,scope:this},buttons:[{text:_T("common","cancel"),scope:this,handler:function(){this.close()}},{text:_T("common","apply"),scope:this,btnStyle:"blue",handler:this.onSubmit}]},e);this.callParent([t])},isHybridHA:function(){return!(!_S("ha_running")||!this._S("is_hybrid_ha"))},updateFileTextField:function(){this.isHybridHA()&&(Ext.getCmp(this.mainFileButtonID).fileTextField.setValue(String.format(_T("update","patch_for_model"),this.mainModel)),Ext.getCmp(this.passiveFileButtonID).fileTextField.setValue(String.format(_T("update","patch_for_model"),this.passiveModel)))},getItems:function(){var e=[];return e.push(this.createMainUploadForm()),this.isHybridHA()&&e.push(this.createPassiveUploadForm()),e.push({xtype:"box",flex:1}),e.push({xtype:"syno_displayfield",htmlEncode:!1,value:_T("update","update_notice")}),e},createMainUploadForm:function(){return new SYNO.SDS.Utils.FormPanel({itemId:"upload_main",fileUpload:!0,trackResetOnLoad:!0,frame:!1,border:!1,padding:"0px",webapi:{api:"SYNO.Core.Upgrade.Patch",method:"upload",version:1},items:[{xtype:"syno_displayfield",value:_T("update","update_notice_manual")},{xtype:"textfield",name:"target",value:"active",hidden:!0},{xtype:"syno_filebutton",fieldLabel:this.isHybridHA()?_T("update","patch_for_active"):_T("itunes","itunes_path"),id:this.mainFileButtonID=Ext.id(),name:"file"}],onApiSuccess:Ext.createDelegate(this.onMainUploadSuccess,this),onApiFailure:Ext.createDelegate(this.onUploadFailed,this)})},createPassiveUploadForm:function(){return new SYNO.SDS.Utils.FormPanel({itemId:"upload_passive",fileUpload:!0,trackResetOnLoad:!0,frame:!1,border:!1,padding:"0px",webapi:{api:"SYNO.Core.Upgrade.Patch",method:"upload",version:1},items:[{xtype:"textfield",name:"target",value:"passive",hidden:!0},{xtype:"syno_filebutton",fieldLabel:_T("update","patch_for_passive"),id:this.passiveFileButtonID=Ext.id(),name:"file"}],onApiSuccess:Ext.createDelegate(this.onPassiveUploadSuccess,this),onApiFailure:Ext.createDelegate(this.onUploadFailed,this)})},onSubmit:function(){var e=this.get("upload_main"),t=this.get("upload_passive");this.validFileName(e.getForm().findField("file"))&&(Ext.isDefined(t)&&!this.validFileName(t.getForm().findField("file"))||(this.setStatusBusy({text:_T("update","update_uploading")}),e.upload()))},validFileName:function(e){if(!e)return!1;if(!e.isDirty())return this.getMsgBox().alert(_T("tree","leaf_update"),_T("error","error_nochoosefile")),!1;var t=e.getValue();return".pat"==t.substr(t.length-4,4)||(this.getMsgBox().alert(_T("tree","leaf_update"),_T("update","error_filename")),!1)},onMainUploadSuccess:function(e,t,i){var s=this.get("upload_passive");this.activePatchInfo=t,this.isHybridHA()?s.upload():(this.clearStatusBusy(),this.readyForUpgrade())},onPassiveUploadSuccess:function(e,t,i){this.passivePatchInfo=t,this.clearStatusBusy(),this.readyForUpgrade()},getMergedInfo:function(){return this.activePatchInfo&&this.passivePatchInfo&&("dsm"===this.passivePatchInfo.upgradetype&&(this.activePatchInfo.reboot="now",this.activePatchInfo.restart_all=!1,this.activePatchInfo.restart_some=!1),"smallupdate"===this.passivePatchInfo.upgradetype&&(this.activePatchInfo.upgradetype="smallupdate")),this.activePatchInfo},onUploadFailed:function(e,t,i){var s=this;s.clearStatusBusy(),s.getMsgBox().alert(_T("tree","leaf_update"),SYNO.API.getErrorString(t.code),function(){s.close()})},readyForUpgrade:function(){this.uploadInfo=this.getMergedInfo(),this.close()},getPathInfo:function(){return this.uploadInfo},isPatchReady:function(){return!Ext.isEmpty(this.uploadInfo)}}),Ext.ns("SYNO.SDS.AdminCenter.Update"),Ext.define("SYNO.SDS.AdminCenter.Update.NotificationSettingDisplayField",{extend:"SYNO.ux.DisplayField",xtype:"admincenter_update_notificationsettingdisplayfield",htmlEncode:!1,value:''+_T("common","note")+": "+String.format(_T("update","autoupdate_time_notify_notice"),''+_T("controlpanel","leaf_notification")+""),initEvents:function(){this.callParent(arguments),this.addEvents("navigate_to_notification_page")},afterRender:function(){this.callParent(arguments);var e=this.el.first("a");this.mon(e,"click",function(e){this.fireEvent("navigate_to_notification_page",this)},this)}}),Ext.define("SYNO.SDS.AdminCenter.Update.Seperator",{extend:"SYNO.ux.CompositeField",xtype:"admincenter_update_seperator",width:16,items:[{xtype:"box",width:1},{xtype:"syno_displayfield",value:":"}]}),Ext.define("SYNO.SDS.AdminCenter.Update.ScheduleField",{extend:"SYNO.ux.CompositeField",xtype:"admincenter_update_schedulefield",items:[{xtype:"syno_panel",padding:0,items:[{xtype:"syno_schedulefield",ref:"../../weekDayField",width:295,allowBlank:!1,editable:!1},{xtype:"syno_panel",padding:"4px 0 0 0",layout:"hbox",items:[{xtype:"syno_combobox",ref:"../../../hourField",width:80,store:SYNO.SDS.Utils.createTimeItemStore("hour"),displayField:"display",valueField:"value"},{xtype:"admincenter_update_seperator"},{xtype:"syno_combobox",ref:"../../../minuteField",width:80,store:SYNO.SDS.Utils.createTimeItemStore("min"),displayField:"display",valueField:"value"}]}]}],setValue:function(e){this.weekDayField.setValue(e.week_day),this.hourField.setValue(e.hour),this.minuteField.setValue(e.minute)},getValue:function(){return{week_day:this.weekDayField.getValue(),hour:this.hourField.getValue(),minute:this.minuteField.getValue()}},isDirty:function(){return!!Ext.isDefined(this.originalValue)&&!(this.originalValue.week_day===this.weekDayField.getValue()&&this.originalValue.hour===this.hourField.getValue()&&this.originalValue.minute===this.minuteField.getValue())}}),Ext.define("SYNO.SDS.AdminCenter.Update.RadioGroup",{extend:"SYNO.ux.RadioGroup",xtype:"admincenter_update_radiogroup",isDirty:function(){return!!Ext.isDefined(this.originalValue)&&(null===this.originalValue&&null!==this.getValue()||(null!==this.originalValue||null!==this.getValue())&&this.originalValue.value!==this.getValue().value)}}),Ext.define("SYNO.SDS.AdminCenter.Update.SettingForm",{extend:"SYNO.ux.FormPanel",initComponent:function(){this.items=[{xtype:"syno_displayfield",value:_T("update","setting_option_type_desc")},{xtype:"admincenter_update_radiogroup",name:"updateBehaviour",columns:1,vertical:!0,items:[{name:"update_behaviour",inputValue:"autoInstallSecurity",boxLabel:String.format(_T("update","setting_option_type_auto_install_security"),"","")},{name:"update_behaviour",inputValue:"autoInstall",boxLabel:_T("update","setting_option_type_auto_install")},{name:"update_behaviour",inputValue:"notifyOnly",boxLabel:_T("update","setting_option_type_notify_me"),checked:!0}]},{xtype:"admincenter_update_schedulefield",name:"updateSchedule",cls:"schedule-field",fieldLabel:_T("update","setting_checking_schedule")}],this.callParent(arguments)},initEvents:function(){this.callParent(arguments),this.addEvents(["loadsuccess","savesuccess","loadfailed","savefailed"])},loadData:function(){this.getUpgradeSetting(function(e){this.applyUpgradeSetting(e),this.fireEvent("loadsuccess",this)}.bind(this),function(e){this.fireEvent("loadfailed",this,SYNO.API.getErrorString(e.status))}.bind(this))},saveData:function(){var e=this.form.getFieldValues(),t=e.updateBehaviour.value;switch(t){case"autoInstallSecurity":t="hotfix-security";break;case"notifyOnly":t="notify";break;case"autoInstall":t="hotfix"}this.setUpgradeSetting(t,e.updateSchedule,function(){this.fireEvent("savesuccess",this)}.bind(this),function(e){this.fireEvent("savefailed",this,SYNO.API.getErrorString(e.status))}.bind(this))},applyUpgradeSetting:function(e){var t="";switch(e.autoupdate_type){case"hotfix-security":t="autoInstallSecurity";break;case"hotfix":t="autoInstall";break;case"notify":t="notifyOnly";break;default:t=""}this.form.setValues({updateBehaviour:t,updateSchedule:e.schedule}),this.clearDirty()},getUpgradeSetting:function(e,t){this.sendWebAPI({api:"SYNO.Core.Upgrade.Setting",method:"get",version:4,callback:function(i,s,n){i?e(s,n):t(s,n)}})},setUpgradeSetting:function(e,t,i,s){var n={autoupdate_type:e,schedule:t};this.sendWebAPI({api:"SYNO.Core.Upgrade.Setting",method:"set",version:4,params:n,callback:function(e,t,n){e?i(t,n):s(t,n)}})},clearDirty:function(){this.items.each(function(e){e.originalValue=e.getValue()})}}),Ext.define("SYNO.SDS.AdminCenter.Update.SettingDialog",{extend:"SYNO.SDS.ModalWindow",title:_T("update","update_adv_setting"),layout:"fit",resizable:!1,confirmedToClose:!1,constructor:function(e){var t=Ext.create({xtype:"container",items:[new SYNO.SDS.AdminCenter.Update.SettingForm({ref:"../formPanel",autoHeight:!0,padding:0}),{xtype:"admincenter_update_notificationsettingdisplayfield",ref:"../notificationDisplayField"}]}),i=Ext.apply({width:580,autoHeight:!0,padding:"16px 20px 12px 20px",closable:!0,buttons:[{xtype:"syno_button",btnStyle:"grey",text:_T("common","cancel"),handler:()=>this.cancelAndExit()},{xtype:"syno_button",btnStyle:"blue",text:_T("common","ok"),handler:()=>this.saveAndExit()}],items:[t]},e);this.callParent([i])},initEvents:function(){this.callParent(arguments),this.addEvents(["navigate_to_notification_page","setting_save"]),this.mon(this.notificationDisplayField,"navigate_to_notification_page",function(){const e=function(){this.fireEvent("navigate_to_notification_page",this),this.closeWithoutConfirm()}.bind(this);this.formPanel.form.isDirty()?this.confirmLostChangePromise({save:()=>{this.saveAndExit(!0)},dontSave:()=>{e()},cancel:Ext.emptyFn},this):e()},this)},afterRender:function(){this.callParent(arguments),this.setStatusBusy({text:_T("common","loading")}),this.mon(this.formPanel,"loadsuccess",function(){this.clearStatusBusy()},this,{single:!0}),this.mon(this.formPanel,"loadfailed",function(e,t){this.clearStatusBusy(),this.setStatusError({text:t})},this,{single:!0}),this.formPanel.loadData()},saveAndExit:function(e=!1){this.setStatusBusy({text:_T("common","saving")}),this.mon(this.formPanel,"savesuccess",function(){this.fireEvent("setting_save",this),e&&this.fireEvent("navigate_to_notification_page",this),this.closeWithoutConfirm()},this,{single:!0}),this.mon(this.formPanel,"savefailed",function(e,t){this.clearStatusBusy(),this.setStatusError({text:t})},this,{single:!0}),this.formPanel.saveData()},cancelAndExit:function(){this.close()},closeWithoutConfirm:function(){this.confirmedToClose=!0,this.close()},onClose:function(){return!!this.confirmedToClose||(!this.formPanel.form.isDirty()||(this.confirmLostChangePromise({save:this.saveAndExit,dontSave:this.closeWithoutConfirm,cancel:Ext.emptyFn},this),!1))}}),Ext.ns("SYNO.SDS.AdminCenter.Update"),Ext.define("SYNO.SDS.AdminCenter.Update.VersionIcon",{extend:"Ext.BoxComponent",xtype:"admincenter_update_version_icon",cls:"update-promotion-version-icon",versionClass:null,versionMajor:null,versionMinor:null,afterRender:function(){this.callParent(arguments),this.setVersion(this.versionMajor,this.versionMinor)},setVersion:function(e,t){var i="v"+e+t;this.el&&(this.el.removeClass(this.versionClass),this.el.addClass(i)),this.versionMajor=e,this.versionMinor=t,this.versionClass=i}}),Ext.define("SYNO.SDS.AdminCenter.Update.PromotionButton",{extend:"Ext.BoxComponent",xtype:"admincenter_update_promotion_button",tooltipType:"qtip",cls:"try-it-button",text:"",initComponent:function(){this.callParent(arguments),this.setText(this.text),this.addEvents(["click"])},afterRender:function(){this.callParent(arguments),this.on({enable:function(){this.el.removeClass("disabled")}.bind(this),disable:function(){this.el.addClass("disabled")}.bind(this)}),this.mon(this.el,"click",function(){this.disabled||this.fireEvent("click",this)}.bind(this))},setText:function(e){this.text=e,this.html=e,this.el&&this.el.update(e)},clearTip:function(){this.btnEl=this.el,SYNO.ux.Button.prototype.clearTip.apply(this)},setTooltip:function(e,t){this.btnEl=this.el,SYNO.ux.Button.prototype.setTooltip.apply(this,[e,t])}}),Ext.define("SYNO.SDS.AdminCenter.Update.ClickableLink",{extend:"SYNO.ux.DisplayField",xtype:"admincenter_update_clickable_link",cls:"clickable-link",htmlEncode:!1,setLink:function(e){var t=String.format('{1}',e,_T("update","update_dsm_whats_new_with_question_mark"));this.setValue(t)}}),Ext.define("SYNO.SDS.AdminCenter.Update.PromotionPanel",{extend:"SYNO.ux.Panel",xtype:"admincenter_update_promotion_panel",cls:"update-promotion",layout:{type:"hbox",align:"middle"},initComponent:function(){this.items=[{xtype:"syno_panel",cls:"icon-section",items:[{xtype:"admincenter_update_version_icon",ref:"../versionIcon"},{xtype:"admincenter_update_clickable_link",ref:"../whatsNewLink"}]},{xtype:"syno_panel",cls:"desc-section",flex:1,autoHeight:!0,items:[{xtype:"syno_displayfield",cls:"promotion-info",ref:"../promotionDescDisplayField"},{xtype:"syno_panel",cls:"action-n-status",layout:"hbox",items:[{xtype:"admincenter_update_promotion_button",ref:"../../actionButton",disabled:!0,hidden:!0},{xtype:"syno_displayfield",cls:"action-status",ref:"../../actionStatus"}]}]}],this.callParent(arguments)},doLayout:function(){this.callParent(arguments),this.callParent(arguments)},initEvents:function(){this.callParent(arguments),this.addEvents(["action_button_click"]);var e=this;e.on({resize:function(){e.doLayout()},afterlayout:function(){var t=e.items.getRange().map(function(e){return e.getHeight()}).reduce(function(e,t){return Math.max(e,t)});e.suspendEvents(),e.setHeight(t),e.resumeEvents()}}),this.mon(this.actionButton,"click",function(){this.fireEvent("action_button_click",this)}.bind(this))},setState:function(e){switch(e.type){case SYNO.SDS.AdminCenter.Update.UpdateState.SYSTEM_BUSY:case SYNO.SDS.AdminCenter.Update.UpdateState.CHECKING:this.hide();break;case SYNO.SDS.AdminCenter.Update.UpdateState.WAIT_FOR_WEBAPI_RESPONSE:this.show(),this.updateVersion(e.version),this.actionButton.setVisible(!0),this.actionButton.disable();break;case SYNO.SDS.AdminCenter.Update.UpdateState.READY_TO_DOWNLOAD:case SYNO.SDS.AdminCenter.Update.UpdateState.THE_OTHER_ONE_IS_DOWNLOADED:this.show(),this.updateVersion(e.version),this.actionButton.enable(),this.actionButton.setVisible(!0),this.actionButton.setText(_T("update","update_btn_download")),this.actionStatus.setValue();break;case SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOADING:this.show(),this.updateVersion(e.version),this.actionButton.enable(),this.actionButton.setVisible(!0),this.actionButton.setText(_T("common","cancel")),this.actionStatus.setValue(this.progressString(e.progress));break;case SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOADED:this.show(),this.updateVersion(e.version),this.actionButton.enable(),this.actionButton.setVisible(!0),this.actionButton.setText(_T("backup","upgrade")),this.actionStatus.setValue();break;case SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOAD_FAILED:this.show(),this.updateVersion(e.version),this.actionButton.enable(),this.actionButton.setVisible(!0),this.actionButton.setText(_T("update","update_btn_retry")),this.actionStatus.setValue(_T("update","update_dsm_download_err"));break;case SYNO.SDS.AdminCenter.Update.UpdateState.UPGRADING:case SYNO.SDS.AdminCenter.Update.UpdateState.THE_OTHER_ONE_IS_DOWNLOADING:this.show(),this.updateVersion(e.version),this.actionButton.disable(),this.actionButton.setVisible(!0),this.actionButton.setText(_T("update","update_btn_download")),this.actionStatus.setValue();break;default:SYNO.Debug("Unhandled promotion state: "+e.type),this.hide()}if(_S("ha_running")&&_S("is_hybrid_ha")){this.actionButton.setText(_T("update","update_btn_download")),this.actionButton.setTooltip(_TT("SYNO.SDS.HA.Instance","upgrade","hybrid_ha_not_support_auto_download")),this.actionButton.disable();var t=SYNO.SDS.AdminCenter.Update.UpdateState;[t.DOWNLOADING,t.DOWNLOADED,t.DOWNLOAD_FAILED,t.THE_OTHER_ONE_IS_DOWNLOADING].includes(e.type)&&SYNO.Debug.error("Unexpected state type in Hybrid HA")}this.doLayout()},updateVersion:function(e){try{var t=e.match(/^(.*) (\d+)\.(\d+)(?:\.(\d+))?-(\d+)(?: [uU]pdate (\d+))?$/);if(null===t)return void SYNO.Debug("Invalid version string: "+e);var i=t[1],s=Number(t[2]),n=Number(t[3]),o=Number(t[4]),a=Number(t[5]),r=Number(t[6]);this.updateWhatsNewLink(a,r),this.versionIcon.setVersion(s,n);var l=i+" "+s+"."+n+(o?"."+o:""),d=String.format(_T("update","promotion_desc"),l);this.promotionDescDisplayField.setValue(d)}catch(t){SYNO.Debug("trying to show promotion panel but error happends"),SYNO.Debug(t),SYNO.Debug("version argument:"),SYNO.Debug(e)}},updateWhatsNewLink:function(e,t){var i={model:_D("upnpmodelname"),type:"promotion",update_version:e+(t?"-"+t:"")},s=_D("rss_server").replace("genRSS","whatsnew")+"?"+Ext.urlEncode(i);this.whatsNewLink.setLink(s)},progressString:function(e){return _T("update","update_dsm_downloading")+" ("+Math.round(e)+"%)"},handleWebAPIError:function(e,t){SYNO.Debug.warn("failed to call WebAPI correctly: "+t),SYNO.Debug.warn("error code:"),SYNO.Debug.warn(e)}}),Ext.ns("SYNO.SDS.AdminCenter.Update"),Ext.define("SYNO.SDS.AdminCenter.Update.DialogTitle",{extend:"Ext.BoxComponent",xtype:"syno_update_reset_dialog_title",cls:"syno-update-reset-dialog-title",value:null,initComponent:function(){this.html=this.value,this.callParent(arguments)}}),Ext.ns("SYNO.SDS.AdminCenter.Update"),SYNO.SDS.AdminCenter.Update.SECONDS_REBOOT=600,Ext.define("SYNO.SDS.AdminCenter.Update.UpdateService",{statics:{startDownload:function(e,t,i){SYNO.API.Request({api:"SYNO.Core.Upgrade.Server.Download",method:"start",version:2,params:{target:e},callback:function(e,s,n){e?t(s):i(s)}})},cancelDownload:function(e,t){SYNO.API.Request({api:"SYNO.Core.Upgrade.Server.Download",method:"cancel",version:1,callback:function(i,s,n){i?e(s):t(s)}})}}}),Ext.define("SYNO.SDS.AdminCenter.Update.UpdateState",{statics:{CHECKING:"checking",NO_UPDATE:"no_update",WAIT_FOR_WEBAPI_RESPONSE:"wait_for_webapi_response",READY_TO_DOWNLOAD:"ready_to_download",DOWNLOADING:"downloading",DOWNLOADED:"downloaded",DOWNLOAD_FAILED:"download_failed",THE_OTHER_ONE_IS_DOWNLOADING:"other_is_downloading",THE_OTHER_ONE_IS_DOWNLOADED:"other_is_downloaded",UPGRADING:"upgrading",SYSTEM_BUSY:"systemBusy"}}),Ext.define("SYNO.SDS.AdminCenter.Update.UpdateStore",{extend:"Ext.Component",statics:{PROMOTION_PANEL:"promotion",UPDATE_PANEL:"update"},subscribe:function(e){this.mon(this,"update",e)},getUpdateState:function(){},getPromotionState:function(){if(!this.state||Ext.isEmpty(this.promotionVersion))return{type:SYNO.SDS.AdminCenter.Update.UpdateState.CHECKING};if(this.isWaitingForWebAPIResponse)return{type:SYNO.SDS.AdminCenter.Update.UpdateState.WAIT_FOR_WEBAPI_RESPONSE,version:this.promotionVersion};if("upgrading"===this.state)return{type:SYNO.SDS.AdminCenter.Update.UpdateState.UPGRADING};if("system_busy"===this.state)return{type:SYNO.SDS.AdminCenter.Update.UpdateState.SYSTEM_BUSY};switch(this.target){case SYNO.SDS.AdminCenter.Update.UpdateStore.PROMOTION_PANEL:return this.getState(this.promotionVersion);case SYNO.SDS.AdminCenter.Update.UpdateStore.UPDATE_PANEL:switch(this.state){case"downloading":return{type:SYNO.SDS.AdminCenter.Update.UpdateState.THE_OTHER_ONE_IS_DOWNLOADING,version:this.promotionVersion,otherVersion:this.updateVersion};case"ready_upgrade":case"downloaded":return{type:SYNO.SDS.AdminCenter.Update.UpdateState.THE_OTHER_ONE_IS_DOWNLOADED,version:this.promotionVersion,otherVersion:this.updateVersion}}}return this.promotionDownloadFailed?{type:SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOAD_FAILED,version:this.promotionVersion}:{type:SYNO.SDS.AdminCenter.Update.UpdateState.READY_TO_DOWNLOAD,version:this.promotionVersion}},updateStateWithTarget:function(e,t){return this.state=e,this.target=t,this.fireEvent("update",this),this},updateCurrentVersion:function(e){return this.currentVersion=e,this.fireEvent("update",this),this},updateUpdateVersion:function(e){return this.updateVersion=e,this.fireEvent("update",this),this},updatePromotionVersion:function(e){return this.promotionVersion=e,this.fireEvent("update",this),this},setDownloadFailed:function(e){switch(e){case SYNO.SDS.AdminCenter.Update.UpdateStore.UPDATE_PANEL:this.updateDownloadFailed=!0,this.promotionDownloadFailed=!1;break;case SYNO.SDS.AdminCenter.Update.UpdateStore.PROMOTION_PANEL:this.updateDownloadFailed=!1,this.promotionDownloadFailed=!0;break;default:return this}return this.fireEvent("update",this),this},clearDownloadFailed:function(e){switch(e){case SYNO.SDS.AdminCenter.Update.UpdateStore.UPDATE_PANEL:this.updateDownloadFailed=!1;break;case SYNO.SDS.AdminCenter.Update.UpdateStore.PROMOTION_PANEL:this.promotionDownloadFailed=!1;break;default:return this}return this.fireEvent("update",this),this},updateDownloadProgress:function(e){return this.progress=e,this.fireEvent("update",this),this},updatePatchInfo:function(e){return this.patchInfo=e,this.fireEvent("update",this),this},updateWaitForWebAPIResponse:function(e){return this.isWaitingForWebAPIResponse=e,this.fireEvent("update",this),this},getState:function(e){switch(this.state){case"none":return{type:SYNO.SDS.AdminCenter.Update.UpdateState.READY_TO_DOWNLOAD,version:e};case"downloading":return{type:SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOADING,progress:this.progress,version:e};case"ready_upgrade":return{type:SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOADED,patchInfo:this.patchInfo,version:e};case"upgrading":return{type:SYNO.SDS.AdminCenter.Update.UpdateState.UPGRADING,version:e};default:return{type:SYNO.SDS.AdminCenter.Update.UpdateState.READY_TO_DOWNLOAD,version:e}}},state:void 0,currentVersion:void 0,updateVersion:void 0,updateDownloadFailed:!1,promotionVersion:void 0,promotionDownloadFailed:!1,isWaitingForWebAPIResponse:!1,target:void 0,progress:0,patchInfo:void 0}),Ext.define("SYNO.SDS.AdminCenter.Update.StyledMsgBox",{statics:{fixedWidth:420,confirm:function(e,t,i,s,n,o){const a={title:t,msg:i,fn:s,scope:n,width:this.fixedWidth,minWidth:this.fixedWidth,maxWidth:this.fixedWidth,buttons:o||Ext.MessageBox.YESNO};e.show(a)},alert:function(e,t,i,s,n){const o={title:t,msg:i,fn:s,scope:n,width:this.fixedWidth,minWidth:this.fixedWidth,maxWidth:this.fixedWidth,buttons:Ext.MessageBox.OK};e.show(o)}}}),Ext.define("SYNO.SDS.AdminCenter.Update.UpdateTab",{extend:"SYNO.SDS.Utils.FormPanel",overallPollingInterval:2,mainModel:"DSM",passiveModel:"DSM",cls:"syno-update-reset-update-tab",updateStore:void 0,constructor:function(e){this.updateStore=new SYNO.SDS.AdminCenter.Update.UpdateStore,this.overAllStatus=null,this.lastDSMInfo=null,Ext.isDefined(SYNO.API.GetKnownAPI("SYNO.Virtualization.Cluster"))?this.sendWebAPI({api:"SYNO.Virtualization.Cluster",method:"check_exist",version:1,scope:this,callback:function(e,t,i){this.cluster_exist=!!e&&t.exist}}):this.cluster_exist=!1,this.module=e.module;var t=this.fillConfig(e);this.callParent([t]),this.setStatusBar(this.highlightText(_T("update","check_new_dsm"),"green"))},getDSMUpdateItems:function(e){var t=e?"../":"";return[{xtype:"syno_displayfield",value:_T("update","update_desc1")},{xtype:"syno_displayfield",cls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:_T("common","ds_model"),name:"model"},{xtype:"syno_displayfield",cls:SYNO.SDS.Utils.SelectableCLS,fieldLabel:_T("update","update_version"),htmlEncode:!1,name:"firmware_ver"},{xtype:"syno_displayfield",fieldLabel:_T("tcpip","wimax_status"),ref:t+"statusBar",htmlEncode:!1,value:this.highlightText(_T("update","check_new_dsm"),"green")},{xtype:"syno_compositefield",width:575,items:[{xtype:"syno_button",text:_T("update","update_btn_download"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):_S("ha_running")&&this._S("is_hybrid_ha")?_TT("SYNO.SDS.HA.Instance","upgrade","hybrid_ha_not_support_auto_download"):"",id:this._downloadBtnID,scope:this},{xtype:"syno_displayfield",id:this._downloadMsgID,htmlEncode:!1,value:""}]},{xtype:"box",height:"5px"},{xtype:"panel",cls:"function-buttons",layout:"column",border:!1,padding:0,itemId:"buttons",items:[{xtype:"syno_button",tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",disabled:this._S("demo_mode"),text:_T("update","update_dsm_manually"),scope:this,ref:t+"../upload_btn",handler:this.openUploadDialog},{xtype:"box",height:"10px",width:"10px"},{xtype:"syno_button",text:_T("update","update_adv_setting"),scope:this,disabled:this.isHybridHA(),handler:this.preOpenSettingDialog,tooltip:this.isHybridHA()?_TT("SYNO.SDS.HA.Instance","upgrade","hybrid_ha_not_support_auto_download_and_install"):""}]},{xtype:"admincenter_update_promotion_panel",ref:t+"promotionPanel",hidden:!0}]},isHybridHA:function(){return!(!_S("ha_running")||!_S("is_hybrid_ha"))},getDSMUpdateItemsWithFieldSet:function(){return this.getDSMUpdateItems(!0)},getSASExpFWUpdateItems:function(){return[{xtype:"syno_displayfield",htmlEncode:!1,value:_T("update","exp_fw_ctrl_panel_update_desc")},{xtype:"syno_displayfield",fieldLabel:_T("tcpip","wimax_status"),htmlEncode:!1,itemId:"sas_exp_fw_staus",value:this.highlightText(_T("update","exp_fw_ctrl_panel_up_to_date_desc"),"green")},{xtype:"syno_displayfield",id:this._sasExpListDisplayId,htmlEncode:!1,hidden:!0,style:"margin-left: 185px",value:""},{xtype:"syno_button",id:this._sasExpFwUpdBtnId,text:"",hidden:!0,style:"margin-left: 185px",scope:this}]},supportExpansionUnitsUpdate:function(){return"yes"===this._D("supportsas","no")&&"yes"!==this._D("disable_sas_exp_fw_upd","no")},fillConfig:function(e){var t,i;this._downloadBtnID=Ext.id(),this._downloadMsgID=Ext.id(),this._sasExpListDisplayId=Ext.id(),this._sasExpFwUpdBtnId=Ext.id(),this.supportExpansionUnitsUpdate()?(t=_T("tree","leaf_3update"),i={xtype:"syno_fieldset",itemId:"dsm_upd_fieldset",title:_T("tree","leaf_update"),items:this.getDSMUpdateItemsWithFieldSet()}):(t=_T("tree","leaf_update"),i=this.getDSMUpdateItems());var s={title:t,itemId:"UpdateTab",autoScroll:!0,items:[i,{xtype:"syno_fieldset",itemId:"sas_exp_fw_upd_fieldset",title:_T("update","exp_fw_ctrl_panel_update_fieldset"),items:this.getSASExpFWUpdateItems(),hidden:!this.supportExpansionUnitsUpdate()}],listeners:{afterrender:function(){var t=e.module.appWin,i=[];t.setStatusBusy();var s=t.getKnownAPI("SYNO.Core.System"),n=s.maxVersion>=2?"firmware":"overview",o={api:"SYNO.Core.System",method:"info",version:s.maxVersion,params:{type:n},scope:this};i.push(o);var a={api:"SYNO.SHA.Panel.Overview",version:1,method:"load",scope:this};_S("ha_running")&&_S("is_hybrid_ha")&&i.push(a);var r={api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_update_list_get":"exp_fw_update_list_get",version:1,params:{},scope:this};this.supportExpansionUnitsUpdate()&&i.push(r);var l={api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_fail_get":"exp_fw_fail_get",version:1,params:{},scope:this};this.supportExpansionUnitsUpdate()&&i.push(l);var d={api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_update_status_get":"exp_fw_update_status_get",version:1,params:{},scope:this};this.supportExpansionUnitsUpdate()&&i.push(d);var c={api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_is_exp_connected":"is_exp_connected",version:1,params:{},scope:this};this.supportExpansionUnitsUpdate()&&i.push(c),this.sendWebAPI({compound:{stopwhenerror:!1,mode:"parallel",params:i},scope:this,callback:function(e,i,s,n){t.clearStatusBusy(),e&&i&&i.result&&Ext.each(i.result,function(e){if(e&&e.api&&e.success&&e.data)if(!0===SYNO.ux.Utils.checkApiConsistency(o,e)){var t=e.data;this.getForm().findField("model").setValue(Ext.isDefined(t.model_customized)?t.model_customized:t.model),this.updateStore.updateCurrentVersion(t.firmware_ver),this.enableCurrentVersionFieldTooltip(!1)}else if(!0===SYNO.ux.Utils.checkApiConsistency(a,e)){var i=e.data,s=String(i.lnode.model),n=String(i.rnode.model),h="active"===i.lnode.role;this.mainModel=h?s:n,this.passiveModel=h?n:s}else!0===SYNO.ux.Utils.checkApiConsistency(r,e)?0!==e.data.enclosures.length&&this.sasFwUpdNeedUpdateStatusRender(e.data.enclosures):!0===SYNO.ux.Utils.checkApiConsistency(l,e)?0!==e.data.enclosures.length&&this.sasFwUpdFailListStatusRender(e.data.enclosures):!0===SYNO.ux.Utils.checkApiConsistency(d,e)?!0!==e.data.finished&&this.startSASExpFwUpdPollingProgress(this):!0===SYNO.ux.Utils.checkApiConsistency(c,e)&&!0!==e.data.has_enc_exp&&(this.getForm().findField("sas_exp_fw_staus").setValue(_T("update","no_expansion_connected")),Ext.getCmp(this._sasExpListDisplayId).hide(),Ext.getCmp(this._sasExpFwUpdBtnId).hide())},this)}})},scope:this}};return Ext.apply(s,e),s},handlePromotionButtonClick:function(e){var t=SYNO.SDS.AdminCenter.Update.UpdateService,i=e.getPromotionState(),s=function(){e.updateWaitForWebAPIResponse(!0),this.getDownloadBtn().disable(),this.getPatchUploadBtn().disable();t.startDownload("promotion",function(){this.isDestroyed||this.startDownloadPolling("promotion")}.bind(this),function(){this.isDestroyed||(e.setDownloadFailed("promotion").updateWaitForWebAPIResponse(!1),this.updateOverallStatus())}.bind(this))}.bind(this);switch(i.type){case SYNO.SDS.AdminCenter.Update.UpdateState.READY_TO_DOWNLOAD:case SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOAD_FAILED:s();break;case SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOADED:this.precheckUpgrade("server",i.patchInfo);break;case SYNO.SDS.AdminCenter.Update.UpdateState.DOWNLOADING:this.updateStore.updateWaitForWebAPIResponse(!0),this.getDownloadBtn().disable(),this.getPatchUploadBtn().disable(),t.cancelDownload(function(){this.isDestroyed||this.updateOverallStatus()}.bind(this),function(t){SYNO.Debug("Canceling promotion download failed:"),SYNO.Debug(t),this.isDestroyed||(e.updateWaitForWebAPIResponse(!1),this.updateOverallStatus())}.bind(this));break;case SYNO.SDS.AdminCenter.Update.UpdateState.THE_OTHER_ONE_IS_DOWNLOADED:this.showReplaceConfirmMsgBox(e.promotionVersion,e.updateVersion,s);break;default:SYNO.Debug("state: "+i.type+" has no handler")}},initEvents:function(){var e=this;e.callParent(arguments),e.mon(e.ownerCt,"activate",e.startOverallStatusPolling,e),e.mon(e,"activate",e.startOverallStatusPolling,e),e.mon(e.ownerCt,"deactivate",e.stopOverallStatusPolling,e),e.mon(e,"deactivate",e.stopOverallStatusPolling,e),e.updateStore.subscribe(function(t){e.promotionPanel.setState(t.getPromotionState())}),e.mon(e.promotionPanel,{action_button_click:function(){e.handlePromotionButtonClick(e.updateStore)}})},checkGlusterUpgradable:function(e,t,i){var s=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.CMS.Info","get");if(s&&"no"===_D("gfssupportmanupdate","no")&&!0===s.joined&&s.additional&&0{1}',t,e):String.format('{1}',t,e)},openUploadDialog:function(){var e=this,t=new SYNO.SDS.AdminCenter.Update.UploadDialog({owner:e.module.appWin,module:e.module,updateTab:e,mainModel:this.mainModel,passiveModel:this.passiveModel});e.mon(t,"close",function(t){t.isPatchReady()&&e.precheckUpgrade("patch",t.getPathInfo())},e,{single:!0}),t.open()},preOpenSettingDialog:function(){var e=this.module.appWin.getMsgBox();this.sendWebAPI({api:"SYNO.Core.Upgrade.AutoUpgrade",method:"status",version:1,scope:this,callback:function(t,i,s,n){t&&i&&i.autoupdate_status&&"preparing"===i.autoupdate_status?e.confirm(_T("update","autoupdate_title"),_T("update","autoupdate_cancel_confirm_text"),this.cancelAutoUpdate,this):this.openSettingDialog()}})},cancelAutoUpdate:function(e){if("yes"===e){var t=this.module.appWin.getMsgBox(),i=_T("update","autoupdate_cancel_failed");this.sendWebAPI({api:"SYNO.Core.Upgrade.AutoUpgrade",method:"cancel",version:1,scope:this,callback:function(e,s,n,o){e?i=_T("update","autoupdate_cancel_success"):s&&s.code&&(i=SYNO.API.getErrorString(s.code)),t.alert(_T("update","autoupdate_title"),i,this.openSettingDialog,this)}})}else this.openSettingDialog()},openSettingDialog:function(){var e=new SYNO.SDS.AdminCenter.Update.SettingDialog({owner:this.module.appWin});this.mon(e,"navigate_to_notification_page",function(){this.findAppWindow().startModule("SYNO.SDS.AdminCenter.Notification.Main")},this,{single:!0}),this.mon(e,"setting_save",function(){this.cleanOverallStatus(),this.CheckLastDSMInfo(!0)},this,{single:!0}),e.open()},CheckLastDSMInfo:function(e){var t=this;(Ext.isEmpty(t.lastDSMInfo)||e)&&(t.lastDSMInfo=null,t.setStatusBar(t.highlightText(_T("update","check_new_dsm"),"green")),t.dsmInfoReq=t.sendWebAPI({compound:{stopwhenerror:!0,params:[{api:"SYNO.Core.Upgrade.Server",method:"check",params:{user_reading:!0,need_auto_smallupdate:!0,need_promotion:!0},version:3},{api:"SYNO.Core.Upgrade.Server.Download",version:2,method:"progress",params:{need_download_target:!0}},{api:"SYNO.Core.Upgrade.Setting",version:1,method:"get"}]},scope:t,callback:function(e,i,s){if(!this.isDestroyed){if(!e||i.has_fail)return t.lastDSMInfo={check_success:!1},void t.updateFailStatus();var n=i.result[0].data.promotion,o=n&&n.version,a=i.result[0].data.update,r=i.result[1].data,l=i.result[2].data,d=a&&a.version;t.lastDSMInfo=a,t.lastDSMInfo.check_success=!0,t.lastDSMInfo.upgrade_type=l.upgrade_type,t.updateStore.updatePromotionVersion(o).updateUpdateVersion(d);var c=r.target;"failed"===r.status?t.updateStore.setDownloadFailed(c):t.updateStore.clearDownloadFailed(c),t.updateOverallStatus()}}}))},getStatusBar:function(){return this.statusBar},getDownloadBtn:function(){return Ext.getCmp(this._downloadBtnID)},getPatchUploadBtn:function(){return this.upload_btn},getDownloadMsgField:function(){return Ext.getCmp(this._downloadMsgID)},enableCurrentVersionFieldTooltip:function(e){var t=this.updateStore.currentVersion;if(t){var i=this.getForm().findField("firmware_ver"),s=String.format("{0} ({1})",t,this.getWhatsNew(t,_T("update","update_dsm_release_note")));if(e){i.setValue(s+"");var n=i.el?i.el.query(".tooltip-anchor")[0]:null;n&&SYNO.ux.AddTip(n,_T("update","status_latest_version_desc"))}else i.setValue(s)}},setStatusBar:function(e,t,i){var s=this.getStatusBar();if(s.setValue(e+""),Ext.isDefined(i)){var n=s.el?s.el.query(".tooltip-anchor")[0]:null;n&&SYNO.ux.AddTip(n,i)}this.updateDownloadMsg(t),this.updateDownloadBtn(t),this.doLayout()},updateDownloadMsg:function(e){var t=this.getDownloadMsgField();e&&e.desc?t.setValue(e.desc):t.setValue("")},updateDownloadBtn:function(e){var t=this.getDownloadBtn();Ext.isDefined(e)?(t.show(),_S("ha_running")&&this._S("is_hybrid_ha")||this._S("demo_mode")?t.disable():t.enable(),t.setText(e.text),Ext.isEmpty(t.click_callback)||this.mun(t,"click",t.click_callback,this),t.click_callback=function(t){e.callback(t)}.bind(this),this.mon(t,"click",t.click_callback,this)):t.hide()},openConfirmDialog:function(e,t,i,s,n){let o=this,a=new SYNO.SDS.AdminCenter.Update.UpdateTab.ConfirmDialog({owner:o.module.appWin,module:o.module,displayMsg:t,leadingNote:i,checkType:e});o.mon(a,"close",function(e){e.getIsNext()?s():o.cancelUpgrade(n)},o,{single:!0}),a.open()},ShowWarningBeforeUpgrade:function(e,t,i,s,n,o){var a,r,l=this,d="",c="",h=_T("update","update_confirm_upgrade_none"),u=!1,p=!1,_=!1,m=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Upgrade","status"),f=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Upgrade.PreCheck","start");const S=SYNO.SDS.AdminCenter.Update.StyledMsgBox;if(m&&"hard"===m.check_type){const e=m.poweroff?m.poweroff.check_msg.map(e=>SYNO.SDS.Utils.GetFeasibilityCheckMsg(e)):[],t=m.upgrade?m.upgrade.check_msg.map(e=>SYNO.SDS.Utils.GetFeasibilityCheckMsg(e)):[];return SYNO.SDS.WindowMgr.getMsgBox(SYNO.SDS.SystemFeasibilityWindow,{actionStrs:[...e,...t],desc:_T("update","update_alert_hardcheck")}).alert(_T("update","update_alert_hardcheck_title")),void l.cancelUpgrade(s)}const g=this.cluster_exist?20:10;if("smallupdate"===n.upgradetype)if("now"===n.reboot)h=String.format(_T("update","update_confirm_upgrade_reboot_now"),g,2*g),p=!0;else if(n.restart_all)h=_T("update","update_confirm_upgrade_restart_all");else if(n.restart_some){let e=n.restart_servs||[],t=n.restart_pkgs||[];e=e.map(e=>_T(e.section,e.key)||e.key),h=_T("update","update_confirm_upgrade_restart_some"),h+="
    "+e.concat(t).join(", ")}else h=_T("update","update_confirm_upgrade_none");else h=String.format(_T("update","update_confirm_upgrade"),g,2*g),p=!0;if(f&&5223===f.code&&f.errors){if("pre-defined"===f.errors.error_type&&!Ext.isEmpty(_T("update",f.errors.error_key)))return S.alert(o.getMsgBox(),_T("tree","leaf_update"),String.format(_T("update",f.errors.error_key),f.code)),void l.cancelUpgrade(s);if("customized"===f.errors.error_type&&!0!==f.errors.can_continue&&f.errors.message)return d=f.errors.message+"
    ",c=f.errors.leading_note,void l.openConfirmDialog("hardCheckFailed",d,c,r,s);if("customized"!==f.errors.error_type||!0!==f.errors.can_continue||!f.errors.message)return S.alert(o.getMsgBox(),_T("tree","leaf_update"),SYNO.API.getErrorString(f.code)),void l.cancelUpgrade(s);u=!0,d=f.errors.message+"
    ",c=f.errors.leading_note}else if(f&&0!==f.code)return S.alert(o.getMsgBox(),_T("tree","leaf_update"),SYNO.API.getErrorString(f.code)),void l.cancelUpgrade(s);const y=[];if(m&&"soft"===m.check_type){const e=m.poweroff?m.poweroff.check_msg.map(e=>SYNO.SDS.Utils.GetFeasibilityCheckMsg(e)):[],t=m.upgrade?m.upgrade.check_msg.map(e=>SYNO.SDS.Utils.GetFeasibilityCheckMsg(e)):[];y.push(...e,...t)}if(_S("ha_running")){var b=SYNO.API.Response.GetValByAPI(t,"SYNO.SHA.Upgrade","need_show_progress_ui");if(_=b.success&&b.need_show_progress_ui,p&&_){var v=SYNO.API.Response.GetValByAPI(t,"SYNO.SHA.Upgrade","get_keep_role"),x=SYNO.API.Response.GetValByAPI(t,"SYNO.SHA.Panel.Overview","load"),w="unknown";x.success&&v.success&&!v.keep_role&&(w="passive"===x.lnode.role?x.lnode.hostname:x.rnode.hostname,h+=String.format('{0} {1} : {2}',m.upgrade?"
    ":"

    ",_T("common","note"),String.format(_TT("SYNO.SDS.HA.Instance","upgrade","notice_role_change"),w)))}}a=function(e){"yes"===e?l.performUpgrade(s,n):l.cancelUpgrade(s)},r=function(){S.confirm(o.getMsgBox(),_T("tree","leaf_update"),h,a,o)},0===y.length?u?l.openConfirmDialog("softCheckFailed",d,c,r,s):r():SYNO.SDS.WindowMgr.getMsgBox(SYNO.SDS.SystemFeasibilityWindow,{actionStrs:y,desc:_T("update","update_confirm_softcheck")}).confirm(_T("update","update_confirm_softcheck_title")).then(e=>{"confirm"===e?u?l.openConfirmDialog("softCheckFailed",d,c,r,s):r():l.cancelUpgrade(s)})},startOverallStatusPolling:function(){var e=this;Ext.isEmpty(e.overallstatus_pollId)&&(e.overallstatus_pollId=this.pollReg({webapi:{api:"SYNO.Core.Upgrade",version:1,method:"status"},interval:this.overallPollingInterval,immediate:!0,status_callback:function(t,i){if(!e.isDestroyed)if(t){if(e.updateStore.updateStateWithTarget(i.status,i.target).updatePatchInfo(i.patch_info),"promotion"===i.target)switch(i.status){case"downloading":i.status="promotion_is_downloading";break;case"ready_upgrade":i.status="promotion_is_downloaded"}e.overAllStatus&&(e.overAllStatus.status!==i.status||e.overAllStatus.target!==i.target)&&e.updateStore.updateWaitForWebAPIResponse(!1),e.overAllStatus=i,e.updateOverallStatus()}else e.updateFailStatus()}}))},stopOverallStatusPolling:function(){Ext.isEmpty(this.overallstatus_pollId)||(this.pollUnreg(this.overallstatus_pollId),this.overallstatus_pollId=null)},cleanOverallStatus:function(){this.overAllStatus=null},updateOverallStatus:function(){var e=this,t=e.getUpdateVersion(),i=e.overAllStatus,s=e.getPatchUploadBtn(),n=e.getDownloadBtn();if(!Ext.isEmpty(i)){if(e.updateStore.isWaitingForWebAPIResponse)return s.disable(),void n.disable();switch(i.allow_upgrade&&!this._S("demo_mode")?s.enable():s.disable(),SYNO.SDS.Utils.isInC2DSM()&&s.setVisible(!1),this.enableCurrentVersionFieldTooltip(!this.hasUpdate()),i.status){case"none":e.updateOverAllNone();break;case"downloading":null!==t&&e.startDownloadPolling("update",t);break;case"ready_upgrade":null!==t&&e.updateOverAllReadyUpgrade(t);break;case"upgrading":e.setStatusBar(e.highlightText(_T("update","dsm_busy_updating"),"red"));break;case"system_busy":e.updateOverAllSystemBusy(i);break;case"promotion_is_downloading":e.startDownloadPolling("promotion",t),e.updateOverAllNone(),n.disable(),s.disable();break;case"promotion_is_downloaded":if(e.updateOverAllNone(),n.enable(),s.enable(),null===t)break;e.setStatusBar(e.getDownloadStatusText("update_dsm_download",t),{text:_T("update","update_btn_download"),callback:function(i){var s=e.updateStore;s.promotionVersion?e.showReplaceConfirmMsgBox(s.updateVersion,s.promotionVersion,function(){e.startDownload(i,t)}):e.startDownload(i,t)}},_T("update","status_update_available_desc"))}}},getUpdateVersion:function(){return Ext.isEmpty(this.lastDSMInfo)?null:Ext.isDefined(this.lastDSMInfo.autosmallupdate_version)?this.lastDSMInfo.autosmallupdate_version:Ext.isDefined(this.lastDSMInfo.version)?this.lastDSMInfo.version:null},renderRSSResult:function(e){switch(e){case"license_expired":this.setStatusBar(this.highlightText(_T("update","license_expire_err"),"red"));break;case"server_error":this.setStatusBar(this.highlightText(_T("update","check_new_dsm_err"),"red"));break;case"server_maintenance":this.setStatusBar(this.highlightText(_T("update","update_dsm_no_new_dsm"),"green"));break;case"internal_error":this.setStatusBar(this.highlightText(_T("update","internal_err"),"red"));break;case"unknown":default:this.setStatusBar(this.highlightText(_T("update","unknown_err"),"red"))}},updateOverAllNone:function(){var e=this,t=e.lastDSMInfo;Ext.isEmpty(t)||(!1!==t.check_success?"success"===t.rss_result?!1!==t.available?e.updateStore.updateDownloadFailed?e.setStatusBar(e.getDownloadStatusText("update_dsm_download",t.version),{text:_T("update","update_btn_retry"),callback:function(i){e.startDownload(i,t.version)},desc:_T("update","update_dsm_download_err")},_T("update","status_update_available_desc")):e.setStatusBar(e.getDownloadStatusText("update_dsm_download",t.version),{text:_T("update","update_btn_download"),callback:function(i){e.startDownload(i,t.version)}},_T("update","status_update_available_desc")):e.setStatusBar(e.highlightText(_T("update","update_dsm_no_new_dsm"),"green")):e.renderRSSResult(t.rss_result):e.updateFailStatus())},updateOverAllReadyUpgrade:function(e){var t=this;t.StopDownloadPolling(),t.setStatusBar(t.getDownloadStatusText("update_dsm_upgrade",e),{text:_T("update","update_btn_upgrade"),callback:function(){t.precheckUpgrade("server",t.overAllStatus.patch_info)}},_T("update","status_update_available_desc"))},updateOverAllSystemBusy:function(e){var t;"no enough volume space."===e.reason?(t="yes"===this._D("supportraid","no")?String.format(_T("update","update_error_no_root"),e.require_volume_size):String.format(_T("update","update_error_no_vol"),e.require_volume_size),this.setStatusBar(this.highlightText(t,"red"))):this.setStatusBar(this.highlightText(_T("error","error_system_busy"),"red"))},startDownload:function(e,t){var i=this,s=i.getPatchUploadBtn();e.disable(),s.disable(),i.updateStore.updateWaitForWebAPIResponse(!0),i.sendWebAPI({api:"SYNO.Core.Upgrade.Server.Download",method:"start",version:2,params:{target:"update",need_auto_smallupdate:!0},callback:function(e,s,n,o){i.isDestroyed||(e?i.startDownloadPolling("update",t):i.updateStore.setDownloadFailed("update"))}})},startDownloadPolling:function(e,t){var i=this;i.isDestroyed||Ext.isEmpty(i.download_pollId)&&(i.updateStore.updateDownloadProgress(0),i.download_pollId=this.pollReg({webapi:{api:"SYNO.Core.Upgrade.Server.Download",version:2,method:"progress",params:{need_download_target:!0}},interval:5,immediate:!0,status_callback:function(s,n){if(!i.isDestroyed){if(!s)return i.StopDownloadPolling(),void i.updateStore.setDownloadFailed(e);var o=n.status,a=n.target,r=n.percent;i.updateDownloadProgress(a,o,r,t)}}}))},StopDownloadPolling:function(){Ext.isEmpty(this.download_pollId)||(this.pollUnreg(this.download_pollId),this.download_pollId=null)},updateDownloadProgress:function(e,t,i,s){switch("failed"===t?this.updateStore.setDownloadFailed(e):this.updateStore.clearDownloadFailed(e),t){case"downloading":this.updateStore.updateDownloadProgress(i),"update"===e&&this.updateDownloadingStatus(s,i);break;case"failed":this.StopDownloadPolling(),this.updateStore.updateWaitForWebAPIResponse(!1).setDownloadFailed(e),this.updateOverallStatus();break;case"finished":case"stopped":this.StopDownloadPolling();break;case"none":break;default:SYNO.Debug("Skip unknown download status: "+t)}},getDownloadStatusText:function(e,t){var i=String.format(_T("update",e),t);return String.format("{0} ({1})",this.highlightText(i,"green"),this.getWhatsNew(t,_T("update","update_dsm_release_note")))},getWhatsNew:function(e,t){var i,s,n,o=this.getForm();if(!e)return"";if(2>(s=e.split(" ")).length)return"";if(2>(i=s[1].split("-")).length)return"";n=i[1],4==s.length&&(n+="-"+s[3]);return function(e){var i={href:_SYNOINFODEF.rss_server.replace("genRSS","whatsnew")+"?"+Ext.urlEncode(e),target:"blank",text:t};return String.format("{2}",Ext.isDefined(i.href)?' href="'+i.href+'"':"",Ext.isDefined(i.target)?' target="_'+i.target+'"':"",i.text)}({model:o.findField("model").getValue(),update_version:n})},updateFailStatus:function(){this.setStatusBar(this.highlightText(_T("update","check_new_dsm_err"),"red"))},updateDownloadingStatus:function(e,t){if(null!==e){var i=this,s=String.format("{0} ({1}%)",_T("update","update_dsm_downloading"),t);i.setStatusBar(i.getDownloadStatusText("update_dsm_download",e),{text:_T("common","cancel"),callback:function(e){i.StopDownloadPolling(),e.disable(),i.sendWebAPI({api:"SYNO.Core.Upgrade.Server.Download",method:"cancel",version:1,params:{},callback:function(t,s,n,o){t?i.StopDownloadPolling():e.enable()}})},desc:this.highlightText(s,"#78828c")},_T("update","status_update_available_desc"))}},updateFailedStatus:function(e){this.StopDownloadPolling(),this.updateOverallStatus()},precheckUpgrade:function(e,t){var i=this,s=i.module.appWin,n=[];n.push({api:"SYNO.Core.Upgrade",version:1,method:"status",params:{feasibility_check:!0}}),parseInt(s._S("version"),10)>=7278&&"dsm"===t.upgradetype&&n.push({api:"SYNO.Core.Upgrade.PreCheck",method:"start",version:1,params:{lang:_S("lang"),type:e},scope:i}),_S("ha_running")&&(n.push({api:"SYNO.SHA.Upgrade",version:1,method:"get_keep_role"}),n.push({api:"SYNO.SHA.Upgrade",version:1,method:"need_show_progress_ui"}),n.push({api:"SYNO.SHA.Panel.Overview",version:1,method:"load"})),i.sendWebAPI({compound:{stopwhenerror:!1,mode:"parallel",params:n},scope:i,callback:function(n,o,a){s.clearStatusBusy(),i.ShowWarningBeforeUpgrade(n,o,a,e,t,s)}}),s.setStatusBusy()},cancelUpgrade:function(e){SYNO.SDS.Desktop.hotkeyPlugin.setHotkeySuspended(!1),"patch"===e&&(this.sendWebAPI({api:"SYNO.Core.Upgrade.Patch",method:"clean",version:1}),_S("ha_running")&&this.sendWebAPI({api:"SYNO.SHA.Util",method:"send_remote_webapi",version:1,params:{remote_api:"SYNO.Core.Upgrade.Patch",remote_method:"clean",remote_version:1}}),this.Reload())},performUpgrade:function(e,t){SYNO.SDS.Desktop.hotkeyPlugin.setHotkeySuspended(!0);var i=this,s=i.module.appWin;i.module.appWin.setStatusBusy(),i.stopOverallStatusPolling(),i.sendWebAPIPromise({api:"SYNO.Core.Upgrade",method:"start",version:1,params:{force:!0,type:e}}).then(()=>{SYNO.SDS.StatusNotifier.fireEvent("halt"),SYNO.SDS.AppLaunch("SYNO.SDS.App.DesktopProgress.Instance",{},!0,e=>{e.$root.startHandlingUpdateProgress(t)})},t=>{i.startOverallStatusPolling(),i.module.appWin.clearStatusBusy(),i.cancelUpgrade(e),s.getMsgBox().alert(_T("tree","leaf_update"),SYNO.API.getErrorString(t.code))})},Reload:function(){this.overAllStatus=null,this.lastDSMInfo=null,this.module.activate(),this.startOverallStatusPolling()},sasFwUpdNeedUpdateStatusRender:function(e){this.getForm().findField("sas_exp_fw_staus").setValue(this.highlightText(_T("update","exp_fw_ctrl_panel_need_update_desc"),"green")),Ext.getCmp(this._sasExpListDisplayId).setValue(String.format(_T("update","exp_fw_ctrl_panel_update_model_desc"),e)),Ext.getCmp(this._sasExpListDisplayId).show(),Ext.getCmp(this._sasExpFwUpdBtnId).setText(_T("update","update_btn_upgrade")),Ext.getCmp(this._sasExpFwUpdBtnId).setHandler(this.sasFwUpdHandler,this),Ext.getCmp(this._sasExpFwUpdBtnId).show(),Ext.getCmp(this._sasExpFwUpdBtnId).enable()},sasFwUpdFailListStatusRender:function(e){this.getForm().findField("sas_exp_fw_staus").setValue(this.highlightText(_T("update","exp_fw_ctrl_panel_update_failed_desc"),"red")),Ext.getCmp(this._sasExpListDisplayId).setValue(String.format(_T("update","exp_fw_critical_update_failed_model_desc"),e)),Ext.getCmp(this._sasExpListDisplayId).show(),Ext.getCmp(this._sasExpFwUpdBtnId).setText(_T("support_center","support_form")),Ext.getCmp(this._sasExpFwUpdBtnId).setHandler(this.sasFwUpdFailHandler,this),Ext.getCmp(this._sasExpFwUpdBtnId).show(),Ext.getCmp(this._sasExpFwUpdBtnId).enable()},sasFwUpdIsUpToDateStatusRender:function(){this.getForm().findField("sas_exp_fw_staus").setValue(this.highlightText(_T("update","exp_fw_ctrl_panel_up_to_date_desc"),"green")),Ext.getCmp(this._sasExpListDisplayId).hide(),Ext.getCmp(this._sasExpFwUpdBtnId).hide()},sasFwUpdHandler:function(){var e=this;e.sendWebAPI({api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_update_list_get":"exp_fw_update_list_get",version:1,params:{},scope:e,callback:function(t,i){t&&0!==i.enclosures.length&&0!==i.update_sec&&(e.updateMins=Math.ceil(i.update_sec/60),e.module.appWin.getMsgBox().confirm("",String.format(_T("update","exp_fw_ctrl_panel_update_window_desc"),e.updateMins),function(t){"yes"===t&&(e.startSASExpFwUpdate(),e.module.appWin.setStatusBusy())}))}})},startSASExpFwUpdate:function(){this.sendWebAPI({api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_update":"exp_fw_update",version:1,params:{},scope:this,callback:function(e,t){this.module.appWin.clearStatusBusy(),e?(SYNO.SDS.App.SASExpFwUpdateApp.SASFwUpdProgressBar.startFWUpdProgress(this.owner,this.updateMins),this.startSASExpFwUpdPollingProgress()):504==t.code?this.module.appWin.getMsgBox().alert("",_T("update","exp_fw_upd_already_in_progress")):this.module.appWin.getMsgBox().alert("",_T("common","error_system"))}})},startSASExpFwUpdPollingProgress:function(){var e=this;Ext.getCmp(e._sasExpFwUpdBtnId).disable(),e.SASExpFwUpdPollingId=e.pollReg({webapi:{api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_update_status_get":"exp_fw_update_status_get",version:1,params:{}},interval:5,immediate:!0,scope:e,status_callback:function(t,i,s,n){var o="",a=[];if(!t){e.pollUnreg(e.SASExpFwUpdPollingId),e.SASExpFwUpdPollingId=void 0;var r={api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_update_list_get":"exp_fw_update_list_get",version:1,params:{},scope:e};a.push(r);var l={api:"SYNO.Storage.CGI.Enclosure",method:_S("ha_running")?"sha_exp_fw_fail_get":"exp_fw_fail_get",version:1,params:{},scope:e};return a.push(l),e.sendWebAPI({compound:{stopwhenerror:!1,mode:"parallel",params:a},scope:e,callback:function(t,i,s,n){t&&i&&i.result&&Ext.each(i.result,function(t){t&&t.api&&t.success&&t.data&&(!0===SYNO.ux.Utils.checkApiConsistency(r,t)?0!==t.data.enclosures.length&&e.sasFwUpdNeedUpdateStatusRender(t.data.enclosures):!0===SYNO.ux.Utils.checkApiConsistency(l,t)&&0!==t.data.enclosures.length&&e.sasFwUpdFailListStatusRender(t.data.enclosures))},e)}}),!1}if(i.finished)return e.pollUnreg(e.SASExpFwUpdPollingId),e.SASExpFwUpdPollingId=void 0,e.sasFwUpdIsUpToDateStatusRender(),!1;o=String.format("{0}%",Math.floor(100*i.progress)),e.getForm().findField("sas_exp_fw_staus").setValue(e.highlightText(String.format("{0} ...({1})",_T("update","exp_fw_ctrl_panel_updating_desc"),o),"blue"))}})},sasFwUpdFailHandler:function(){SYNO.SDS.AppLaunch("SYNO.SDS.SupportForm.Application",{extra:{pkg_id:"SASExpFWUpdate"}})},showReplaceConfirmMsgBox:function(e,t,i){var s=function(e){return""+e+""},n=String.format(_T("update","download_replace_info"),s(e),s(t))+"
    "+_T("update","download_replace_question");this.findAppWindow().getMsgBox().confirm("",n,function(e){"yes"===e&&i()})},hasUpdate:function(){return null!==this.getUpdateVersion()}}),Ext.define("SYNO.SDS.AdminCenter.Update.UpdateTab.ConfirmDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.isNext=!1;const{displayMsg:t,leadingNote:i,checkType:s}=e,n=[{xtype:"syno_displayfield",cls:"dialog-precheck-msg",htmlEncode:!1,value:t}],o=[];"softCheckFailed"===s?(n.push({xtype:"syno_checkbox",itemId:"confirmChechbox",htmlEncode:!1,boxLabel:String.format('{0}',_T("update","update_confirm_continue")),listeners:{check:{fn:function(e,t){this.getFooterToolbar().getComponent("nextBtn").setDisabled(!t)},scope:this}}}),o.push([{xtype:"syno_button",text:_T("common","cancel"),scope:this,handler:function(){this.isNext=!1,this.close()}},{xtype:"syno_button",text:_T("backup","addon_update"),itemId:"nextBtn",btnStyle:"blue",disabled:!0,tooltip:_T("update","please_click_checkbox_desc"),scope:this,handler:function(){this.isNext=!0,this.close()}}])):o.push({xtype:"syno_button",text:_T("common","ok"),itemId:"nextBtn",btnStyle:"blue",scope:this,handler:function(){this.isNext=!1,this.close()}}),this.displayFieldWithWrapper=new SYNO.ux.Panel({autoFlexcroll:!0,items:n});let a=Ext.apply({cls:"syno-admin-center-confirm-dialog x-window-dlg",closable:!1,draggable:!1,elements:"body",resizable:!1,width:600,autoHeight:!0,popupStyle:"emphasized",fbar:o,items:[{xtype:"syno_update_reset_dialog_title",value:_T("update","update_notice_title")},{xtype:"syno_displayfield",cls:"dialog-precheck-msg",htmlEncode:!1,value:i},this.displayFieldWithWrapper],listeners:{scope:this,activate:{fn:function(){const e=this.displayFieldWithWrapper.getHeight(),t=this.getHeight(),i=t-e;t>=480?this.displayFieldWithWrapper.setHeight(480-i):t<280?this.displayFieldWithWrapper.setHeight(280-i):this.displayFieldWithWrapper.setHeight(e)}}}},e);this.callParent([a])},getIsNext:function(){return this.isNext}}),Ext.define("SYNO.SDS.AdminCenter.Config.TypeStep",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t={fileUpload:!0,trackResetOnLoad:!0,frame:!1,webapi:{api:"SYNO.Backup.Config.Restore",method:"upload",version:1},items:[{xtype:"syno_displayfield",value:_T("confbackup","select_restore_config_source")},{xtype:"syno_radio",boxLabel:_T("confbackup","restore_from_synoaccount"),name:"restore_type",checked:!0,inputValue:"cloud"},{xtype:"syno_displayfield",value:_T("confbackup","restore_from_synoaccount_desc"),indent:1},{xtype:"syno_radio",boxLabel:_T("confbackup","restore_from_local_upload"),name:"restore_type",inputValue:"local"},{xtype:"syno_filebutton",fieldLabel:_T("itunes","itunes_path"),name:"dss_file",indent:1}],onApiSuccess:Ext.createDelegate(this.onUploadSuccess,this),onApiFailure:Ext.createDelegate(this.onUploadFailed,this)};Ext.apply(t,e),this.callParent([t])},activate:function(){this.isActivated||(new SYNO.ux.Utils.EnableRadioGroup(this.getForm(),"restore_type",{local:["dss_file"]}),this.isActivated=!0)},getNext:function(){var e=this.getForm();if(!e.isValid())return!1;if("local"===e.findField("restore_type").getGroupValue()){var t=e.findField("dss_file").getValue();if(Ext.isEmpty(t))return this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),_T("confbackup","please_select_dss")),!1;if(!this.validFileName(t))return!1;this.setStatusBusy({text:_T("confbackup","uploading")}),this.upload()}else"cloud"===e.findField("restore_type").getGroupValue()&&this.checkSynoAccountLogin();return!1},checkSynoAccountLogin:function(){this.myDSAccount?this.owner.goNext(this.nextId.cloud):this.owner.getMsgBox().confirm("",_T("confbackup","login_synoaccount_enable_restore"),function(e){if("yes"===e){this.owner.configTab.openSynoAccountLogin(this.owner,function(e,t){this.owner.clearStatusBusy(),this.owner.updateGlobalEvent("syno_account",e),this.owner.goNext(this.nextId.cloud)},this)}},this,{yes:{text:_T("common","login")},no:{text:_T("common","cancel")}})},validFileName:function(e){return".dss"===e.substr(e.length-4,4)||(this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),_T("confbackup","error_filename")),!1)},onUploadSuccess:function(e,t,i){this.owner.clearStatusBusy(),this.owner.updateGlobalEvent("dsm_task_id",t.dss_id),this.owner.updateGlobalEvent("dss_version",t.dss_version),this.owner.getStep(this.nextId.local).reload(),this.owner.goNext(this.nextId.local)},onUploadFailed:function(e,t,i){this.owner.clearStatusBusy(),this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(t))},observerUpdate:function(e,t){"syno_account"===e&&(this.myDSAccount=t)}}),Ext.define("SYNO.SDS.AdminCenter.Config.VersionlistPanel",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.owner=e.owner,this.module=e.module;var t={cls:"version-list-panel",store:this.getStore(),colModel:this.getColumnModel(),sm:new Ext.grid.RowSelectionModel({singleSelect:!0,listeners:{beforerowselect:function(e,t,i,s,n){return!s.get("error")}}}),enableHdMenu:!1,bbar:this.pagingBar=new SYNO.ux.PagingToolbar({store:this.getStore(),pageSize:20,displayInfo:!0,showRefreshBtn:!0}),viewConfig:{getRowClass:function(e,t,i,s){if(e.get("error"))return"versionstep-disabled-row"}}};Ext.apply(t,e),this.callParent([t])},getStore:function(){return this.store?this.store:(this.store=new SYNO.API.Store({api:"SYNO.Backup.Config.AutoBackup",version:1,method:"list",appWindow:this.module.appWin,autoLoad:!1,hasMultiSort:!0,multiSortInfo:{sorters:[{field:"error",direction:"ASC"},{field:"backup_time",direction:"DESC"}]},reader:new Ext.data.JsonReader({idProperty:"name",root:"versions",totalProperty:"total",fields:[{name:"name",mapping:"name"},{name:"host",mapping:"host"},{name:"model",mapping:"model"},{name:"serial",mapping:"serial"},{name:"dsm_version",mapping:"dsm_version"},{name:"checksum",mapping:"checksum"},{name:"backup_time",mapping:"backup_time",convert:function(e,t){return SYNO.SDS.DateTimeFormatter(new Date(e))}},{name:"error",mapping:"error",sortType:function(e){return e?1:0}}]}),baseParams:{offset:0,limit:20},listeners:{scope:this,beforeload:function(){this.owner.setStatusBusy()},load:function(e,t){this.owner.clearStatusBusy(),0===t.length?(this.bwrap.mask(_T("confbackup","no_dss_version"),"syno-ux-mask-info"),this.owner.getButton("next").disable()):(this.bwrap.unmask(),this.owner.getButton("next").enable(),this.getStore().multiSort(this.getStore().multiSortInfo.sorters))},exception:function(e,t,i,s,n,o){this.owner.clearStatusBusy(),this.getStore().removeAll(),this.owner.getButton("next").disable(),this.owner.getMsgBox().alert("",SYNO.SDS.ConfigBackup.getErrorString(n))}}}),this.store)},getColumnModel:function(){var e=function(e,t,i,s,n,o){return i.get("error")?t.attr=String.format('ext:qtip="{0}"',SYNO.SDS.ConfigBackup.getErrorString(i.get("error"))):t.attr=String.format('ext:qtip="{0}"',e),e};return new Ext.grid.ColumnModel([{header:_T("tcpip","server_name"),tooltip:_T("tcpip","server_name"),dataIndex:"host",sortable:!0,renderer:function(e,t,i,s,n,o){return i.get("error")?t.attr=String.format('ext:qtip="{0}"',SYNO.SDS.ConfigBackup.getErrorString(i.get("error"))):t.attr=String.format('ext:qtip="{0}: {1}
    {2}: {3}"',_T("tcpip","server_name"),e,_T("confbackup","model_name"),i.get("model")),e}},{header:_T("confbackup","serial_number"),tooltip:_T("confbackup","serial_number"),dataIndex:"serial",sortable:!0,renderer:e},{header:_T("localbkpwizard","localbkp_time"),tooltip:_T("localbkpwizard","localbkp_time"),dataIndex:"backup_time",sortable:!0,renderer:e},{header:_T("confbackup","dsm_version"),tooltip:_T("confbackup","dsm_version"),dataIndex:"dsm_version",sortable:!0,renderer:e}])}}),Ext.define("SYNO.SDS.AdminCenter.Config.VersionStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t={layout:"fit",items:[new SYNO.ux.Panel({height:320,itemId:"version_panel",cls:"version-list-panel-wrapper",items:[new SYNO.SDS.AdminCenter.Config.VersionlistPanel({height:320,itemId:"version_grid_panel",owner:e.owner,module:e.module})]})]};Ext.apply(t,e),this.callParent([t])},activate:function(){var e=this.getComponent("version_panel").getComponent("version_grid_panel").pagingBar;if(0===e.getWidth()){var t=this.getComponent("version_panel").getComponent("version_grid_panel").getWidth();e.container.setWidth(t),e.setWidth(t),this.doLayout()}this.getComponent("version_panel").getComponent("version_grid_panel").getStore().load()},getNext:function(){var e=this.getComponent("version_panel").getComponent("version_grid_panel").getSelectionModel().getSelected();return e?(this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Config.AutoBackup",method:"get_meta",version:1,params:{dss_name:e.get("name")},scope:this,callback:function(t,i,s,n){if(!t)return this.owner.clearStatusBusy(),void this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(i));"manual"===i.enc_type?(this.owner.clearStatusBusy(),this.owner.updateGlobalEvent("dss_name",e.get("name")),this.owner.updateGlobalEvent("checksum",e.get("checksum")),this.owner.goNext(this.nextId.manual)):"auto"===i.enc_type?this.sendWebAPI({api:"SYNO.Backup.Config.AutoBackup",method:"restore",version:1,params:{dss_name:e.get("name"),checksum:e.get("checksum")},scope:this,callback:function(e,t,i,s){this.owner.clearStatusBusy(),e?(this.owner.updateGlobalEvent("dsm_task_id",t.dsm_task_id),this.owner.updateGlobalEvent("dss_version",t.dss_version),this.owner.getStep(this.nextId.auto).reload(),this.owner.goNext(this.nextId.auto)):this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(t))}}):this.owner.clearStatusBusy()}}),!1):(this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),_T("confbackup","select_one_version")),!1)}}),Ext.define("SYNO.SDS.AdminCenter.Config.PasswordStep",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t={cls:"password-enckey-panel",fileUpload:!0,trackResetOnLoad:!0,frame:!1,webapi:{api:"SYNO.Backup.Config.AutoBackup",method:"upload_private_key",version:1,scope:this},items:[{xtype:"syno_displayfield",value:_T("confbackup","password_input_title")},{xtype:"container",layout:"column",hideLabel:!0,cls:"password-row",items:[{xtype:"syno_radio",name:"decrypt_method",inputValue:"password",boxLabel:_T("common","password"),width:200,checked:!0},{xtype:"syno_textfield",itemId:"pwd",textType:"password",allowBlank:!1,minLength:8,maxLength:64}]},{xtype:"container",layout:"column",hideLabel:!0,cls:"enckey-row",items:[{xtype:"syno_radio",name:"decrypt_method",inputValue:"prikey_file",boxLabel:_T("share","share_encryption_key"),width:200,check:!1},{xtype:"syno_filebutton",name:"private_key"}]}],onApiSuccess:Ext.createDelegate(this.onPrikeyUploadSuccess,this),onApiFailure:Ext.createDelegate(this.onPrikeyUploadFailed,this)};Ext.apply(t,e),this.callParent([t])},activate:function(){this.isActivated||(new SYNO.ux.Utils.EnableRadioGroup(this.getForm(),"decrypt_method",{password:["pwd"],prikey_file:["private_key"]}),this.isActivated=!0)},getNext:function(){var e=this.getForm();if(!e.isValid())return!1;if("prikey_file"===e.findField("decrypt_method").getGroupValue())return Ext.isEmpty(e.findField("private_key").getValue())?(this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),_T("confbackup","please_select_enckey")),!1):(this.upload(),!1);var t=e.findField("pwd").getValue();return this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Config.AutoBackup",method:"restore",version:1,params:{pwd:t,dss_name:this.dssName,checksum:this.checksum},encryption:["pwd"],scope:this,callback:function(t,i,s,n){if(this.owner.clearStatusBusy(),t)this.owner.updateGlobalEvent("dsm_task_id",i.dsm_task_id),this.owner.updateGlobalEvent("dss_version",i.dss_version),this.owner.getStep(this.nextId).reload(),this.owner.goNext(this.nextId);else{var o=i&&i.code;this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(i),function(){SYNO.SDS.ConfigBackup.ERR_AUTOCONF_PASSWORD_INVALID===o&&e.findField("pwd").markInvalid(_T("confbackup","invalid_password"))})}}}),!1},onPrikeyUploadSuccess:function(e,t,i){this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Config.AutoBackup",method:"restore",version:1,params:{prikey_session_id:t.prikey_session_id,dss_name:this.dssName,checksum:this.checksum},scope:this,callback:function(e,t,i,s){this.owner.clearStatusBusy(),e?(this.owner.updateGlobalEvent("dsm_task_id",t.dsm_task_id),this.owner.updateGlobalEvent("dss_version",t.dss_version),this.owner.getStep(this.nextId).reload(),this.owner.goNext(this.nextId)):this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(t))}})},onPrikeyUploadFailed:function(e,t,i){this.owner.clearStatusBusy(),this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.API.getErrorString(t.code))},observerUpdate:function(e,t){"dss_name"===e?this.dssName=t:"checksum"===e&&(this.checksum=t)}}),Ext.define("SYNO.SDS.AdminCenter.Config.RestoreDetailStep",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.module=e.module,this.checkBox=new SYNO.ux.Checkbox({boxLabel:_T("confbackup","bkp_overwrite"),itemCls:"overwrite-checkbox"});var t=Ext.apply({cls:"restore-detail-step",items:[this.createTreePanel(),this.checkBox]},e);this.callParent([t])},setDsmTaskId:function(e){this.dsmTaskId=e,this.treePanel.dss_id=e},getDsmTaskId:function(){return this.dsmTaskId},setDssVersion:function(e){this.treePanel.dss_version=e},reload:function(){this.treePanel.root.reload()},createTreePanel:function(){var e=this.module.appWin._S("version"),t=e>=4980;this.treePanel=new SYNO.SDS.ConfigBackup.Restore.ConfigTreePanel({dsm_version:e,loader:new SYNO.SDS.ConfigBackup.TreeLoader,rootVisible:!0,height:293});var i=new SYNO.SDS.ConfigBackup.TreeLoader({sendWebAPI:this.treePanel.sendWebAPI.createDelegate(this.treePanel),webapi:{api:"SYNO.Backup.Config.Restore",method:"list",version:t?2:1},parseWebApiResponse:function(e,i){return t?i.config_info_list:i},createNodeFn:this.treePanel.createConfigNodeFn,createNodeScope:this});i.on("beforeload",function(e,i,s){this.owner.setStatusBusy(),e.baseParams.dss_id=this.getDsmTaskId(),t&&(e.baseParams.is_show_shared_folder=!0)},this),i.on("loadexception",function(e,t,i){this.owner.clearStatusBusy(),this.owner.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(i),function(){this.owner.close()})},this),i.on("load",function(e,t,i){this.owner.clearStatusBusy()},this);var s=_T("confbackup","confbkp_all"),n=new Ext.tree.AsyncTreeNode({expanded:!1,hidden:""===s,id:"config_root",allowDrop:!1,text:s,qtip:s,leaf:!1,checked:!1,loader:i,uiProvider:SYNO.SDS.ConfigBackup.TriTreeNodeUI});return this.treePanel.setRootNode(n),this.treePanel},isOverwrite:function(){return this.checkBox.getValue()},isRestoreConfig:function(){return this.treePanel.isRestoreConfig()},observerUpdate:function(e,t){"dsm_task_id"===e?this.setDsmTaskId(t):this.setDssVersion(t)}}),Ext.define("SYNO.SDS.AdminCenter.Config.WizardBaseWindow",{extend:"SYNO.SDS.Wizard.ModalWindow",goNext:function(e,t){null!==e?this.callParent(arguments):this.doWizardCommit()},doWizardCommit:function(){}}),Ext.define("SYNO.SDS.AdminCenter.Config.RestoreWizard",{extend:"SYNO.SDS.AdminCenter.Config.WizardBaseWindow",globalEvent:{},constructor:function(e){var t={width:600,height:500,cls:"confautobkp-restore-wizard",title:_T("confbackup","restore_configuration"),steps:[new SYNO.SDS.AdminCenter.Config.TypeStep({headline:_T("confbackup","select_restore_source"),itemId:"type_step",owner:this,module:e.module,nextId:{cloud:"version_step",local:"restore_detail_step"}}),new SYNO.SDS.AdminCenter.Config.VersionStep({headline:_T("confbackup","select_restore_config_version"),itemId:"version_step",owner:this,module:e.module,nextId:{auto:"restore_detail_step",manual:"password_step"}}),new SYNO.SDS.AdminCenter.Config.PasswordStep({headline:_T("confbackup","decrypt_dss_title"),itemId:"password_step",owner:this,module:e.module,nextId:"restore_detail_step"}),new SYNO.SDS.AdminCenter.Config.RestoreDetailStep({headline:_T("confbackup","select_restore_items"),itemId:"restore_detail_step",owner:this,module:e.module,nextId:null})]};Ext.apply(t,e),this.callParent([t])},initEvents:function(){this.callParent(arguments),this.createGlobalEvent(),this.subscribe("type_step","syno_account"),this.subscribe("password_step","dss_name"),this.subscribe("password_step","checksum"),this.subscribe("restore_detail_step","dss_version"),this.subscribe("restore_detail_step","dsm_task_id"),this.updateGlobalEvent("syno_account",this.myDSAccount)},createGlobalEvent:function(){this.globalEvent={dss_name:{subscribers:[]},checksum:{subscribers:[]},dsm_task_id:{subscribers:[]},dss_version:{subscribers:[]},syno_account:{subscribers:[]}}},updateGlobalEvent:function(e,t){this.globalEvent.hasOwnProperty(e)?("syno_account"===e&&this.fireEvent("synoaccount_update",[t]),this.publish(e,t)):SYNO.Debug(String.format("event {0} does not exist",e))},subscribe:function(e,t){this.globalEvent[t].subscribers.push(e)},publish:function(e,t){var i=this.globalEvent[e].subscribers;Ext.each(i,function(i){this.getStep(i).observerUpdate(e,t)},this)},doWizardCommit:function(){var e=this.getStep("restore_detail_step");if(e.isRestoreConfig()){var t=e.getDsmTaskId(),i=e.isOverwrite(),s=e.treePanel.getRestoreServiceList();e.treePanel.checkUGConflict(i,this.readyForImport.createDelegate(this,[t,i,s]),this,!0)}else this.getMsgBox().alert(_T("tree","leaf_bkp"),_T("confbackup","confbkp_no_service_select"))},readyForImport:function(e,t,i){this.restoreParams={dss_id:e,overwrite:t,category_or_service_ids:i},this.close()},getRestoreParam:function(){return this.restoreParams},isRestoreParamReady:function(){return void 0!==this.restoreParams},onClose:function(){if(!this.isRestoreParamReady()){var e=this.getStep("restore_detail_step").getDsmTaskId();e&&this.sendWebAPI({api:"SYNO.Backup.Config.Restore",method:"delete",version:1,params:{dss_id:e}})}this.callParent(arguments)}}),SYNO.SDS.AdminCenter.Config.SetDesktop=function(e){SYNO.SDS.UserSettings.setProperty("Desktop","restoreParams",Ext.apply({className:"SYNO.SDS.AdminCenter.Application",params:{fn:"SYNO.SDS.AdminCenter.Update_Reset.Main",tab:"ConfigTab",task_id:e}}))},SYNO.SDS.AdminCenter.Config.RedirectUrl=function(e){if(Array.isArray(e)&&0!==e.length){var t=function(e){var t=String.format("{0}//{1}",window.location.protocol,e),i=new XMLHttpRequest;i.open("GET",String.format("{0}:{1}/webman/pingpong.cgi?action=cors",t,window.location.port)),i.onload=(()=>{window.onbeforeunload=null,window.location=t}),i.timeout=5e3,i.send()};this.intervals=[];for(var i=0;i{1}',n,o)},downloadEncKey:function(e){this.module.appWin.getMsgBox().alert("",_T("confbackup","automatically_download_privatekey"),function(){this.module.appWin.findAppWindow().downloadWebAPI({webapi:{api:"SYNO.Backup.Config.AutoBackup",version:1,method:"download_private_key",params:{prikey_session_id:e}},scope:this,callback:function(e,t,i,s){!1===i&&this.module.appWin.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(s))}})},this)},setInstantBkpBtnStatus:function(e){var t=this.getForm(),i=Ext.getCmp(this.instantBkpBtn),s=t.findField("enable").getValue();if(i.setTooltip(""),s){if("backingup"===this.status)return i.setTooltip(_T("confbackup","backup_is_processing")),void i.disable();var n=void 0!==e?e:t.findField("enc_method").getValue()!==t.findField("enc_method").originalValue;t.findField("enable").isDirty()||(s&&"manual"===t.findField("enc_method").getGroupValue()?t.findField("pwd").getValue()!==t.findField("pwd").originalValue||t.findField("confirm_pwd").getValue()!==t.findField("confirm_pwd").originalValue:t.findField("pwd").isDirty()||t.findField("confirm_pwd").isDirty())||!0===n?(i.setTooltip(_T("confbackup","apply_before_backup")),i.disable()):i.enable()}else i.disable()},cancelHandler:function(){this.callParent(arguments),this.setInstantBkpBtnStatus()},bkpStatusToUIStatus:function(e,t,i){return!0===i?e:"backingup"===e?e:t?"last_backup":"none"},addBackupStatusTip:function(e,t,i,s){var n="",o=e&&SYNO.SDS.DateTimeFormatter(new Date(e),{type:"datetimesec"}),a=t&&SYNO.SDS.DateTimeFormatter(new Date(t),{type:"datetimesec"});switch(this.bkpStatusToUIStatus(i,e,s)){case"success":n=_T("confbackup","last_check_time")+": "+a;break;case"fail":o&&(n=_T("confbackup","last_successful_bkp_time")+": "+o),a&&(n=n?n+"
    ":n,n+=_T("confbackup","last_check_time")+": "+a)}n&&SYNO.ux.AddTip(this.getForm().findField("backup_time_status").getEl(),n)},processReturnData:function(e,t,i){if(!0===t.has_fail)return Ext.each(t.result,function(e){if(!e.success)return this.module.appWin.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(e.error)),!1},this),void this.callParent([e,t,i]);var s=null,n=null;Ext.each(t.result,function(e){"SYNO.Backup.Config.AutoBackup"===e.api&&"get"===e.method&&(s=e.data.last_success_time,n=e.data.last_check_time,this.enable=e.data.enable,this.myDSAccount=e.data.myds_account,this.status=e.data.last_status,e.data.backup_time_status=this.convertBackupTimeStatus(e.data.last_success_time,e.data.last_status,e.data.fail_reason_code,e.data.enable),e.data.confirm_pwd=e.data.pwd),"SYNO.Backup.Config.AutoBackup"===e.api&&"set"===e.method&&(Ext.isEmpty(e.data.prikey_session_id)||this.downloadEncKey(e.data.prikey_session_id))},this),this.callParent([e,t,i]),this.setInstantBkpBtnStatus(),this.addBackupStatusTip(s,n,this.status,this.enable)},processParams:function(e,t){return"set"===e&&Ext.each(t,function(e){"SYNO.Backup.Config.AutoBackup"===e.api&&"set"===e.method&&(e.params.overwrite=!0,e.params.enc_method=this.getForm().findField("enc_method").getGroupValue(),delete e.params.confirm_pwd,e.params.enable&&"auto"!==e.params.enc_method&&this.getForm().findField("pwd").isDirty()||delete e.params.pwd)},this),t},openSynoAccountLogin:async function(e,t,i){this.webLogin||(this.webLogin=await SYNO.SDS.SynologyAccount.WebLogin.create()),this.webLogin.loginUrl&&(this.webLogin.popLoginWeb(),this.webLogin.on("resolve",t.bind(i)),this.webLogin.on("reject",function(t){SYNO.Debug("Login Failed",t),e.clearStatusBusy()}),this.webLogin.on("processing",function(){e.setStatusBusy({text:_T("login","waiting")})}))},autoExportConfig:function(){this.sendWebAPI({api:"SYNO.Backup.Config.AutoBackup",method:"backup",version:1,params:{instant:!0},scope:this,callback:function(e,t,i,s){if(!e){if(SYNO.SDS.ConfigBackup.ERR_AUTOCONF_ACCOUNT_INVALID===t.code)return this.myDSAccount="",void this.module.appWin.getMsgBox().confirm("",_T("confbackup","login_synoaccount_enable_autobkp"),function(e){if("yes"===e){this.openSynoAccountLogin(this.module.appWin,function(e){this.module.appWin.clearStatusBusy(),this.myDSAccount=e.account,this.autoExportConfig()},this)}},this,{yes:{text:_T("common","login")},no:{text:_T("common","cancel")}});this.module.appWin.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(t))}}})},openRestoreWizard:function(e){if(!Ext.getCmp(this.wizardId)){var t=new SYNO.SDS.AdminCenter.Config.RestoreWizard({configTab:this,module:this.module,owner:this.module.appWin,myDSAccount:this.myDSAccount,id:this.wizardId=Ext.id()});this.mon(t,"synoaccount_update",function(e){this.myDSAccount=e},this),this.mon(t,"close",function(e){e.isRestoreParamReady()&&(this.updateStatus("initializing"),this.sendWebAPI({api:"SYNO.Backup.Config.Restore",method:"start",version:1,params:e.getRestoreParam(),scope:this,callback:function(e,t,i,s){e?(this.preprocessNetwork(t.network,t.task_id),this.onStartImportPolling(t.task_id)):this.unmaskDesk(SYNO.SDS.ConfigBackup.getErrorString(t))}}))},this,{single:!0}),t.open()}},requestExportServiceList:async function(){this.module.appWin.setStatusBusy();var e=!_S("ha_running");try{var t=await this.sendWebAPIPromise({api:"SYNO.Core.Network.OVS",method:"get",version:1});e=e&&!t.enable_ovs}catch(e){}this.sendWebAPI({api:"SYNO.Backup.Config.Backup",method:"list",version:1,params:{},scope:this,callback:function(t,i,s,n){if(this.module.appWin.clearStatusBusy(),t){var o=_T("confbackup","confbkp_bkp_item_desc")+"
    ",a=[],r=[];if(e)a=i.services;else{var l=["network_interface","static_route","tc","firewall","dos"];r=i.services.filter(e=>l.includes(e.id)),a=i.services.filter(e=>!l.includes(e.id))}if(o+=this.getGroupedServicesText(a),0!=r.length){var d=[];Ext.each(r,function(e){d.push(SYNO.SDS.ConfigBackup.converLanString(e.text))}),(this.isOVSRunning()||_S("ha_running"))&&(o+=''+_T("common","note")+_T("common","colon")+" "+_T("confbackup","confbkp_bkp_not_support_network_items")+_T("common","colon")+d.join(", ")+"")}this.module.appWin.getMsgBox().confirm(_T("tree","leaf_bkp"),o,this.exportConfig,this)}else this.module.appWin.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(i))}})},isOVSRunning:async function(){return(await this.sendWebAPIPromise({api:"SYNO.Core.Network.OVS",method:"get",version:1})).enable_ovs},exportConfig:function(e){"yes"===e&&(this.module.appWin.setStatusBusy({text:_T("confbackup","bkp_export_prepare")}),this.sendWebAPI({api:"SYNO.Backup.Config.Backup",method:"start",version:1,params:{},scope:this,callback:function(e,t,i,s){if(!e)return this.module.appWin.clearStatusBusy(),void this.module.appWin.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(t));this.onStartExportPolling(t.task_id)}}))},onStartExportPolling:function(e){this.exportPollingID=this.pollReg({webapi:{api:"SYNO.Backup.Config.Backup",method:"status",version:1,params:{task_id:e}},interval:1,immediate:!0,scope:this,status_callback:this.onExportPollingDone})},onExportPollingDone:function(e,t,i,s){if(!e)return this.module.appWin.clearStatusBusy(),this.pollUnreg(this.exportPollingID),void this.module.appWin.getMsgBox().alert(_T("tree","leaf_bkp"),SYNO.SDS.ConfigBackup.getErrorString(t));t.finish&&(this.module.appWin.clearStatusBusy(),this.pollUnreg(this.exportPollingID),this.module.appWin.findAppWindow().downloadWebAPI({webapi:{api:"SYNO.Backup.Config.Backup",version:1,method:"download",params:{task_id:t.task_id}},scope:this}))},unmaskDesk:function(e,t){this.getDeskMsgBox().hide(),this.module.appWin.getMsgBox().alert(_T("tree","leaf_bkp"),e,t,this)},onStartImportPolling:function(e){this.importPollingID=this.pollReg({webapi:{api:"SYNO.Backup.Config.Restore",method:"status",version:1,params:{task_id:e}},interval:1,immediate:!0,scope:this,status_callback:this.onImportPollingDone})},preprocessNetwork:function(e,t){Ext.isObject(e)&&e.need_redirect&&Ext.form.VTypes.v4ip(window.location.hostname)&&Array.isArray(e.redirect_ips)&&0!==e.redirect_ips.length&&!e.redirect_ips.includes(window.location.hostname)&&(SYNO.SDS.AdminCenter.Config.SetDesktop.apply(this,[t]),this.onStartRedirectPolling(e.redirect_ips))},onStartRedirectPolling:function(e){this.ajaxTask=this.addAjaxTask({autoJsonDecode:!0,interval:3e3,preventHalt:!0,scope:this,startTime:(new Date).getTime(),timeLimit:1e5,timeout:1e4,url:"webman/pingpong.cgi",failure:function(){SYNO.SDS.AdminCenter.Config.RedirectUrl.apply(this,[e]),this.stopAjaxTask()}}),this.ajaxTask.start()},stopAjaxTask(){this.ajaxTask&&this.ajaxTask.stop()},clearRedirectInterval(){Array.isArray(this.intervals)&&(this.intervals.forEach(function(e){window.clearInterval(e)}),delete this.intervals)},getServicesText:function(e){var t="";return Ext.each(e,function(e){""!==t&&(t+=", "),t+=SYNO.SDS.ConfigBackup.converLanString(e.text)}),t},getGroupedServicesText:function(e){var t={};Ext.iterate(SYNO.SDS.ConfigBackup.ConfigurationField,function(e,i){t[i]=[]}),Ext.each(e,function(e){if(!t.hasOwnProperty(e.field))return!0;t[e.field].push(SYNO.SDS.ConfigBackup.converLanString(e.text))});var i={};i[SYNO.SDS.ConfigBackup.ConfigurationField.FILE_SHARING]=0,i[SYNO.SDS.ConfigBackup.ConfigurationField.CONNECTIVITY]=1,i[SYNO.SDS.ConfigBackup.ConfigurationField.SYSTEM]=2,i[SYNO.SDS.ConfigBackup.ConfigurationField.SERVICE]=3;var s=[];return Ext.iterate(t,function(e,t){s[i[e]]="
  • "+SYNO.SDS.ConfigBackup.getConfigurationFieldString(e)+_T("common","colon")+""+t.join(", ")+"
  • "}),s.join("")},getImportErrText:function(e){var t=SYNO.SDS.ConfigBackup.getErrorString(e);return SYNO.SDS.ConfigBackup.ERR_CONFIG_SERVICE_FAIL===e.code&&(t+=this.getServicesText(e.errors.failed_services)),e.errors&&!0===e.errors.detail_in_log&&(t+="

    "+_T("confbackup","verify_log_center")),t},onImportPollingDone:function(e,t,i,s){e?t.finish?(this.stopAjaxTask(),this.clearRedirectInterval(),this.pollUnreg(this.importPollingID),this.module.panel.loadAllForm(),this.unmaskDesk(_T("confbackup","bkp_done"),this.refreshConfirmDialog)):this.updateStatus(t.status,t):(t.isAbort||t.errors)&&(this.stopAjaxTask(),this.clearRedirectInterval(),this.pollUnreg(this.importPollingID),this.unmaskDesk(this.getImportErrText(t)))},refreshConfirmDialog:function(){this.module.appWin.getMsgBox().confirm("",_T("personal_settings","refresh_confirm"),e=>{"yes"===e&&(window.onbeforeunload=null,location.reload())})},updateStatus:function(e,t){var i,s,n=0,o=this.getDeskMsgBox();if("initializing"===e)n=0,s=_T("confbackup","confbkp_st_init");else if("stopping_system_service"===e)s=_T("confbackup","confbkp_st_service_stop");else if("restoring_service"===e)s=SYNO.SDS.ConfigBackup.converLanString(t.current_service.text);else{if("starting_system_service"!==e)return;s=_T("confbackup","confbkp_st_service_start")}t&&(n=t.percentage),i=_T("confbackup","confbkp_footer_desc")+" "+s,o.isVisible()||o.show({progress:!0,maxWidth:300,title:_T("tree","leaf_bkp"),msg:i}),o.updateProgress(n/100,Math.floor(n)+"%",i)},getDeskMsgBox:function(){return this.DeskmsgBox&&!this.DeskmsgBox.isDestroyed||(this.DeskmsgBox=new SYNO.SDS.MessageBoxV5({modal:!0,draggable:!1,renderTo:document.body})),this.DeskmsgBox.getWrapper()}}),Ext.define("SYNO.SDS.AdminCenter.Reset.ResetTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.canRetainPassword=!SYNO.SDS.Utils.isInVirtualDSM();var t=this.fillConfig(e);this.callParent([t]),this.canRetainPassword&&this.mon(this,"afterlayout",this.createEnableGroup,this,{single:!0})},fillConfig:function(e){var t={title:_T("helptoc","restoredefaults"),itemId:"ResetTab",useDefaultBtn:this.canRetainPassword,webapi:{api:"SYNO.Core.System.ResetButton",methods:{get:"get",set:"set"},version:1},items:[{xtype:"syno_fieldset",title:_T("tree","leaf_default"),items:this.getFactoryReset()}]};return this.canRetainPassword&&t.items.push({xtype:"syno_fieldset",title:_T("default1","reset_button_setting"),items:this.getResetButtonSetting()}),Ext.apply(t,e),t},getFactoryReset:function(){var e=_S("ha_running")&&"yes"!==_D("support_xa")||this._S("demo_mode");return[{xtype:"syno_displayfield",hideLabel:!0,value:_T("default1","default_opt2")},{xtype:"syno_button",text:_T("default1","default_btn_apply"),btnStyle:e?"grey":"red",disabled:e,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):_S("ha_running")?_TT("SYNO.SDS.HA.Instance","ui","ha_not_support_setting"):"",scope:this,handler:this.onClickResetBtn}]},getResetButtonSetting:function(){return[{xtype:"syno_checkbox",name:"retain_admin_pwd",boxLabel:_T("default1","retain_admin_pwd")},{xtype:"syno_displayfield",indent:1,name:"retain_admin_pwd_desc",value:_T("default1","retain_admin_pwd_desc")}]},createEnableGroup:function(){new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"retain_admin_pwd",["retain_admin_pwd_desc"])},onClickResetBtn:function(){new SYNO.SDS.AdminCenter.Reset.ResetTab.ConfirmDialog({owner:this.module.appWin,module:this.module}).show()}}),Ext.define("SYNO.SDS.AdminCenter.Reset.ResetTab.ConfirmDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.buttonCounter=0;var t=Ext.apply({cls:"syno-admin-center-confirm-dialog x-window-dlg confirm-delete-icon",draggable:!1,elements:"body",header:!1,resizable:!1,width:480,minHeight:120,autoHeight:!0,padding:"34px 30px 0 30px",popupStyle:"emphasized",fbar:[{xtype:"syno_button",text:_T("common","no"),scope:this,handler:this.onClickNo},{xtype:"syno_button",text:_T("default1","default_btn_apply"),itemId:"apply",btnStyle:"red",disabled:!0,scope:this,handler:this.onClickDelete}],items:[{xtype:"syno_update_reset_dialog_title",value:_T("tree","leaf_default")},{xtype:"syno_displayfield",cls:"dialog-msg",value:_T("default1","default_confirm")},{xtype:"syno_checkbox",cls:"dialog-checkbox",boxLabel:_T("default1","default_confirm_check"),listeners:{check:{fn:function(e,t){t?(this.buttonCounter=5,this.countDownButtonTask=new Ext.util.DelayedTask(this.countDownButtonEnable,this),this.countDownButtonEnable()):this.countDownButtonDisable()},scope:this}}}]},e);SYNO.SDS.AdminCenter.Reset.ResetTab.ConfirmDialog.superclass.constructor.call(this,t)},countDownButtonEnable:function(){var e=_T("default1","default_btn_apply"),t=this.getFooterToolbar().getComponent("apply");if(this.countDownButtonTask){if(0===this.buttonCounter)return t.setText(e),void t.setDisabled(!1);this.countDownButtonTask&&this.countDownButtonTask.delay(1e3),t.setText(e+" ("+this.buttonCounter+")"),this.buttonCounter--}},countDownButtonDisable:function(){var e=this.getFooterToolbar().getComponent("apply");this.countDownButtonTask&&delete this.countDownButtonTask,e.setText(_T("default1","default_btn_apply")),e.setDisabled(!0)},onClickDelete:function(){SYNO.SDS.Utils.PasswordConfirmDialog.openDialog(this,this.sendResetRequest)},sendResetRequest:function(e){var t=this,i={};this.setStatusBusy(),t.sendWebAPI({api:"SYNO.Core.System",method:"reset",version:1,params:{force:e||!1},callback:function(e,s,n,o){this.clearStatusBusy(),e?t.IsCMSMode()?t.owner.getMsgBox().alert(_T("tree","leaf_default"),_JSLIBSTR("uicommon","system_reboot_timeout"),function(){t.module.appWin.close()}):(SYNO.SDS.Desktop.getMsgBox().show({maxWidth:300,title:this._D("product"),msg:_JSLIBSTR("uicommon","system_reboot_timeout"),canClose:!1}),SYNO.SDS.StatusNotifier.fireEvent("halt"),SYNO.SDS.SocketInst.disconnect(),synowebapi.request({url:"webapi/entry.cgi?api=SYNO.API.Auth",requestFormat:"raw",responseFormat:"raw",method:"GET",params:{version:7,method:"logout"}})):this.isFeasibilityFail(s,i)&&this.confirmFeasibilityFail(this,i,this.sendResetRequest,!0)},scope:this})},onClickNo:function(){this.countDownButtonDisable(),this.close()},IsCMSMode:function(){return void 0!==this.owner.getOpenConfig("cms_id")},isFeasibilityFail:function(e,t){return!!(e.errors&&e.errors.feasibility&&(t.soft=e.errors.feasibility.soft||[],t.hard=e.errors.feasibility.hard||[],t.soft.length>0||t.hard.length>0))},confirmFeasibilityFail:function(e,t,i){var s,n,o,a=[],r=e.getMsgBox||e.owner.getMsgBox;if(void 0===r)throw Error("Does not found 'getMsgBox'");0
    {1}",_T("volume","hard_check_fail"),a.join("
    ")),r.call(e).alert(e.title,s)):0
    {1}",_T("volume","soft_check_fail"),a.join("
    ")),n=[].slice.call(arguments,this.confirmFeasibilityFail.length),r.call(e).confirm(e.title,s,function(e){"yes"==e&&i.apply(this,n)},e))}}),Ext.define("SYNO.SDS.AdminCenter.SystemRecovery.SystemRecoveryTab",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={title:_T("helptoc","system_recovery"),itemId:"SystemRecoveryTab",items:this.getRestoreItem()};return Ext.apply(t,e),t},getRestoreItem:function(){var e=_S("ha_running")&&"yes"!==_D("support_xa")||this._S("demo_mode");return[{xtype:"syno_displayfield",hideLabel:!0,value:_T("system_recovery","description")},{xtype:"syno_button",text:_T("system_recovery","restore_system"),btnStyle:e?"grey":"red",disabled:e,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):_S("ha_running")?_TT("SYNO.SDS.HA.Instance","ui","ha_not_support_setting"):"",scope:this,handler:this.onClickSystemRecoveryBtn}]},onClickSystemRecoveryBtn:function(){SYNO.SDS.Packages.getInfoByPkgId("BackupRestoreManager")?this._appWindow.getMsgBox().confirmDelete(_T("helptoc","system_recovery"),_T("system_recovery","default_confirm"),function(e){"no"!==e&&SYNO.SDS.AppLaunch("SYNO.SDS.App.BRM.Restore.Instance",{entry:"admin_center"})},this,{yes:{text:_T("system_recovery","default_btn_apply"),btnStyle:"red"},no:{text:_T("common","no")}}):this._appWindow.getMsgBox().confirm(_T("helptoc","system_recovery"),_T("system_recovery","desc_ask_install_brm_pkg"),function(e){"no"!==e&&SYNO.SDS.AppLaunch("SYNO.SDS.PkgManApp.Instance",{action:"open",packages:["BackupRestoreManager"]})},this)}}),Ext.ns("SYNO.SDS.AdminCenter.Update_Reset"),Ext.define("SYNO.SDS.AdminCenter.Update_Reset.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.panel=new SYNO.SDS.AdminCenter.Update_Reset.TabPanel({module:this})},getHelpParam:function(){switch(this.panel.getActiveTab().itemId){case"ResetTab":return"AdminCenter/system_restoredefaults.html";case"ConfigTab":return"AdminCenter/system_configbackup.html";case"UpdateTab":return"AdminCenter/system_dsmupdate.html";case"SystemRecoveryTab":return"AdminCenter/system_recovery.html";default:return"AdminCenter/system_update_reset_desc.html"}},getPanel:function(){return this.panel},setActivateParams:function(e){if(e&&e.tab&&(this.panel.setActiveTab(e.tab),"ConfigTab"===e.tab)){var t=this.getPanel().getItem("ConfigTab");!0===e.is_login&&(t.myDSAccount="user"),!0===e.open_wizard&&t.openRestoreWizard(),e.task_id&&t.onStartImportPolling(e.task_id,!0)}},focus:function(e){if(e&&e.tab&&"ConfigTab"===e.tab){this.panel.setActiveTab(e.tab);var t=this.getPanel().getItem("ConfigTab");!0===e.is_login&&(t.myDSAccount="user"),!0===e.open_wizard&&t.openRestoreWizard()}},activate:function(e){this.setActivateParams(e),this.panel.loadAllForm()},deactivate:function(){return this.panel.getAllForms().filter(function(e){return"UpdateTab"!==e.itemId}).every(function(e){return!e.isDirty()})},confirmLostChangeSave:function(){return this.getPanel().applyHandlerPromise()}}),Ext.define("SYNO.SDS.AdminCenter.Update_Reset.TabPanel",{extend:"SYNO.SDS.Utils.TabPanel",applyHandlerResolve:Ext.emptyFn,applyHandlerReject:Ext.emptyFn,constructor:function(e){this.module=e.module;var t=Ext.apply({activeTab:0,useDefaultBtn:!1,items:[new SYNO.SDS.AdminCenter.Update.UpdateTab({module:this.module}),new SYNO.SDS.AdminCenter.Config.ConfigTab({module:this.module})]},e);"yes"==this.module.appWin._D("dockerdsm")||SYNO.SDS.Utils.isInC2DSM()||SYNO.SDS.Utils.isInAliDSM()||(t.items.push(new SYNO.SDS.AdminCenter.Reset.ResetTab({module:this.module})),"yes"===_D("support_synorbd_vspace")&&t.items.push(new SYNO.SDS.AdminCenter.SystemRecovery.SystemRecoveryTab({module:this.module}))),this.callParent([t])},processReturnData:function(e,t,i){t.has_fail?this.applyHandlerReject():this.applyHandlerResolve(),this.applyHandlerResolve=Ext.emptyFn,this.applyHandlerReject=Ext.emptyFn,this.callParent(arguments)},applyHandlerPromise:function(){var e=this;return new Promise(function(t,i){e.applyHandlerResolve=t,e.applyHandlerReject=i,e.applyHandler()})}}),Ext.ns("SYNO.SDS.AdminCenter.ExtendWarranty"),Ext.define("SYNO.SDS.AdminCenter.ExtendWarranty.FieldSet",{extend:"SYNO.ux.FieldSet",labelWidth:220,saLink:[``,""],scLink:['',""],saRegisterLink:`${_D("ew20_website_url")}extended-warranty-plus/registration/`,ewInfoBase64:"",constructor:function(e){let t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){let t={collapsible:!1,cls:"ew-fieldset",hidden:!e.isSupportEW,title:_T("extend_warranty","synology_care"),items:this.getItems()};return Ext.apply(t,e),t},getEWStatus(e,t){const i=e=>{if(!e)return;return new Date(e).format(SYNO.SDS.DateTimeUtils.GetSystemDateFormat())},s=e=>{if(0==e.length)return;const t=String.format(''+_T("common","note")+_T("common","colon")+" ");return e.length>1?t+'

      '+e.map(e=>"
    • "+e+"
    • ").join("")+"
    ":t+e[0]},n=t?[this.saLinkFormat(_T("extend_warranty","check_expansion"))]:[];switch(e.status){case"registrable":return{status:"not_registered",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),btn:_T("extend_warranty","register_now"),serviceStatus:_T("extend_warranty","not_registered"),note:s([_T("extend_warranty","eligible_only_90_days"),this.saLinkFormat(_T("extend_warranty","cant_register_for_ew201")),...n])};case"review_in_progress":return{status:"not_registered",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),serviceStatus:_T("extend_warranty","not_registered"),detailDesc:this.saLinkFormat(_T("extend_warranty","being_verified_desc")),note:s([_T("extend_warranty","eligible_only_90_days"),this.saLinkFormat(_T("extend_warranty","cant_register_for_ew201")),...n])};case"payment_not_completed":return{status:"not_registered",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),btn:_T("extend_warranty","register_now"),serviceStatus:_T("extend_warranty","not_registered"),detailDesc:this.saLinkFormat(_T("extend_warranty","waiting_for_payment_desc")),note:s([_T("extend_warranty","eligible_only_90_days"),this.saLinkFormat(_T("extend_warranty","cant_register_for_ew201")),...n])};case"accepted":return{status:"not_registered",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),btn:_T("extend_warranty","register_now"),serviceStatus:_T("extend_warranty","not_registered"),detailDesc:this.saLinkFormat(_T("extend_warranty","verified_but_not_complete_desc")),note:s([_T("extend_warranty","eligible_only_90_days"),this.saLinkFormat(_T("extend_warranty","cant_register_for_ew201")),...n])};case"rejected":return{status:"not_registered",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),btn:_T("extend_warranty","register_again"),serviceStatus:_T("extend_warranty","not_registered"),detailDesc:this.scLinkFormat(_T("extend_warranty","exceed_period_desc")),note:s([_T("extend_warranty","eligible_only_90_days"),this.saLinkFormat(_T("extend_warranty","cant_register_for_ew201")),...n])};case"activated":return{status:"registered",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),serviceStatus:String.format(''+_T("extend_warranty","registered"),NaN),expiryDate:i(e.expired_at),location:e.drma_region?_T("Country",e.drma_region.toUpperCase()):void 0,note:s([...n])};case"out_of_warranty":return{status:"expired",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),serviceStatus:_T("extend_warranty","expired"),expiryDate:i(e.expired_at),note:s([...n])};case"ew10":return{status:"not_eligible",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),serviceStatus:_T("extend_warranty","not_eligible"),detailDesc:this.saLinkFormat(_T("extend_warranty","have_registered_ew201_desc")),note:s([...n])};case"phaseout_model":case"unsupported_model":return{status:"not_eligible",desc:this.scLinkFormat(_T("extend_warranty","register_sc_from_now")),serviceStatus:_T("extend_warranty","not_eligible"),detailDesc:this.scLinkFormat(_T("extend_warranty","doesnot_support")),note:s([...n])};case"none":default:return{status:"not_registered",desc:String.format(_T("extend_warranty","register_and_sign_in_desc"),...this.scLink,...this.saLink),btn:_T("extend_warranty","register_now"),serviceStatus:_T("extend_warranty","not_registered"),note:s([_T("extend_warranty","eligible_only_90_days"),this.saLinkFormat(_T("extend_warranty","cant_register_for_ew201")),...n])}}},getItems(){const e=this;return[{xtype:"syno_displayfield",htmlEncode:!1,ref:"ewDesc",value:this.scLinkFormat(_T("extend_warranty","register_sc_from_now"))},{xtype:"syno_button",btnStyle:"grey",hidden:!0,cls:"ew-button",handler:this.onRegisterNowBtnClick.bind(this),ref:"ewBtn"},{xtype:"syno_displayfield",htmlEncode:!1,fieldLabel:_T("extend_warranty","service_status"),labelWidth:this.labelWidth,ref:"ewServiceStatus",value:""},{xtype:"syno_displayfield",htmlEncode:!1,hidden:!0,fieldLabel:_T("extend_warranty","desc"),labelWidth:this.labelWidth,ref:"ewDetailDesc"},{xtype:"syno_displayfield",htmlEncode:!1,hidden:!0,fieldLabel:_T("extend_warranty","expiry_date"),labelWidth:this.labelWidth,ref:"ewExpiryDate"},{xtype:"syno_displayfield",htmlEncode:!1,hidden:!0,fieldLabel:_T("extend_warranty","service_location"),labelWidth:this.labelWidth,ref:"ewLocation",listeners:{show:function(){SYNO.ux.AddTip(this.getEl(),e.scLinkFormat(_T("extend_warranty","service_location_tooltip")))}}},{xtype:"syno_displayfield",htmlEncode:!1,hidden:!0,tabindex:"-1",ref:"ewNote"}]},loadData(e={},t=!1,i=""){const s=(e,t)=>{Ext.isFunction(e.setValue)?e.setValue(t):Ext.isFunction(e.setText)&&e.setText(t),e.setVisible(void 0!==t)},n=this.getEWStatus(e,t),o=_D("unique").split("_").pop();this.ewInfoBase64=btoa(JSON.stringify({sn:e.sn,model:o,userEmail:i})),s(this.ewDesc,n.desc),s(this.ewBtn,n.btn),s(this.ewServiceStatus,n.serviceStatus),s(this.ewDetailDesc,n.detailDesc),s(this.ewExpiryDate,n.expiryDate),s(this.ewLocation,n.location),s(this.ewNote,n.note)},saLinkFormat(e){return String.format(e,...this.saLink)},scLinkFormat(e){return String.format(e,...this.scLink)},onRegisterNowBtnClick(){window.open(this.saRegisterLink+`?ew=${this.ewInfoBase64}`,"_blank")}}),Ext.ns("SYNO.SDS.AdminCenter.SynologyAccount"),Ext.define("SYNO.SDS.AdminCenter.SynologyAccount.LogoutDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.panel=e.panel,this.reasons=e.reasons;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t="logout_confirm";this.reasons.length>1&&(t="logout_confirm_multiple");var i={autoHeight:!0,width:480,resizable:!1,draggable:!1,header:!1,cls:"x-window-dlg",elements:"body",padding:"24px 30px 0",fbar:["->",{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.close},{xtype:"syno_button",text:_T("common","logout"),btnStyle:"blue",scope:this,handler:this.confirmLogout}],items:[{xtype:"syno_displayfield",name:"title",cls:"account-logout-dialog-title",value:_T("myds","logout_confirm_title")},{xtype:"syno_displayfield",name:"message",cls:"account-logout-dialog-msg",value:_T("myds",t)},{xtype:"syno_displayfield",name:"reasons",cls:"account-logout-dialog-reasons",indent:1,htmlEncode:!1,value:"
      "+this.reasons.join("")+"
    "}]};return Ext.apply(i,e),i},confirmLogout:function(){this.panel.doLogout(!0),this.close()}}),Ext.ns("SYNO.SDS.AdminCenter.SynologyAccount"),Ext.define("SYNO.SDS.AdminCenter.SynologyAccount.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.panel=new SYNO.SDS.AdminCenter.SynologyAccount.Panel({module:this})},getPanel:function(){return this.panel},getHelpParam:function(){return"AdminCenter/system_synology_account.html"},activate:function(){},setActivateParams:function(e){},confirmLostChangeSave:function(){return new Promise(function(e,t){this.confirmSaveLostResolve=e,this.confirmSaveLostReject=t}.bind(this))},deactivate:function(){return!this.panel.isDirty()&&(this.panel.webLogin&&this.panel.webLogin.cancel(),!0)}}),Ext.define("SYNO.SDS.AdminCenter.SynologyAccount.Panel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.appWin=this.module.appWin;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={title:_T("myds","myds_account"),itemId:"account",cls:"synology-account-panel",items:this.createItems(),listeners:{scope:this,activate:this.onActivate,deactivate:this.onDeactivate}};return Ext.apply(t,e),t},createItems:function(){var e=[];return e.push({xtype:"syno_fieldset",collapsible:!1,title:_T("myds","myds_account"),items:[{xtype:"syno_displayfield",cls:"synology-account-desc",htmlEncode:!1,value:String.format(_T("myds","myds_desc"),'',"")},{xtype:"container",cls:"synology-account-container",items:[{xtype:"syno_displayfield",cls:"synology-account-label",value:_T("myds","myds_account")+":"},this.displayAccount=new SYNO.ux.DisplayField({cls:"synology-account-mail",htmlEncode:!1,hidden:!0}),this.displayLoginOrSignUp=new SYNO.ux.DisplayField({cls:"synology-account-login-or-sign-up",hidden:!0,htmlEncode:!1,value:''+_T("myds","login_or_register_myds_account")+"",listeners:{scope:this,afterrender:function(e){e.el.on("click",this.onLoginClicked,this)}}}),{xtype:"syno_button",cls:"synology-account-logout-account-btn",hidden:!0,text:_T("common","logout"),scope:this,id:this.logoutAccountBtnId=Ext.id(),handler:this.onLogoutAccountClicked}]}]},new SYNO.SDS.AdminCenter.ExtendWarranty.FieldSet({ref:"extendWarranty",isSupportEW:this.isSupportEW()})),e},processEWWebapiResp:function(e){const t=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.EW.Info","get");t&&t.info&&Ext.isBoolean(t.have_applied_eunit||!Ext.isString(t.mail))?this.extendWarranty.loadData(t.info,t.have_applied_eunit,t.mail):this.appWin.getMsgBox().alert("",SYNO.API.getErrorString(t))},processMyDSCenterWebapiResp:function(e){const t=SYNO.API.Response.GetValByAPI(e,"SYNO.Core.MyDSCenter","query");t&&(t.is_logged_in?this.onLoggedIn(t):this.showLoginInfo())},reloadAll:function(){let e=[];e.push(this.genMyDSCenterWebapi()),this.isSupportEW()&&e.push(this.genEWWebapi()),0!==e.size&&(this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Entry.Request",method:"request",version:2,params:{mode:"parallel",compound:e},scope:this,callback:function(e,t,i,s){this.appWin.clearStatusBusy(),e?(this.processMyDSCenterWebapiResp(t),this.isSupportEW()&&this.processEWWebapiResp(t)):this.appWin.getMsgBox().alert("",SYNO.API.getErrorString(t))}}))},onActivate:function(){this.module.panel.clearStatusBusy(),this.reloadAll()},onDeactivate:function(){},onLoggedIn:function(e){const t=e.account,i=e.activated;this.displayAccount.setValue(''+Ext.util.Format.htmlEncode(t)+""),this.displayAccount.show(),this.displayLoginOrSignUp.hide(),Ext.getCmp(this.logoutAccountBtnId).show(),i||(this.addUnactivatedTip(this.displayAccount.getEl(),_T("myds","not_activated_desc")),this.appWin.getMsgBox().alert("",_T("myds","not_activated_alert"))),this.appWin.clearStatusBusy()},onLoggedFail:function(e){SYNO.Debug("Login Failed",e),this.appWin.clearStatusBusy()},onLoggedProcessing:function(){this.appWin.setStatusBusy({text:_T("login","waiting")})},showLoginInfo:function(){this.displayAccount.hide(),this.displayLoginOrSignUp.show(),Ext.getCmp(this.logoutAccountBtnId).hide()},onLoginClicked:async function(){this.webLogin||(this.webLogin=await SYNO.SDS.SynologyAccount.WebLogin.create()),this.webLogin.loginUrl&&(this.webLogin.popLoginWeb(),this.webLogin.on("resolve",this.reloadAll.bind(this)),this.webLogin.on("reject",this.onLoggedFail.bind(this)),this.webLogin.on("processing",this.onLoggedProcessing.bind(this)))},showLogoutDialog:function(e){new SYNO.SDS.AdminCenter.SynologyAccount.LogoutDialog({owner:this.appWin,panel:this,reasons:e}).show()},onLogoutAccountClicked:function(){this.doLogout(!1)},doLogout:function(e){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.MyDSCenter.Logout",version:1,method:"pkce_logout",params:{force:!!e},scope:this,callback:async function(e,t,i){this.appWin.clearStatusBusy();var s=[];if(e)this.reloadAll();else if(3014===t.code)try{Ext.each(t.errors.reasons,function(e){var t=Ext.decode(e);s.push(String.format("
  • {0}
  • ",Ext.util.Format.htmlEncode(String.format.apply(window,[SYNO.SDS.Utils.GetFeasibilityCheckMsg(t.task_i18n)].concat(t.args||[])))))}),"soft"===t.errors.check_type?this.showLogoutDialog(s):this.appWin.getMsgBox().alert("",_T("myds","logout_alert")+s.join(""))}catch(e){this.appWin.getMsgBox().alert("",SYNO.API.getErrorString(t))}else this.appWin.getMsgBox().alert("",SYNO.API.getErrorString(t))}})},addUnactivatedTip:function(e,t){var i=document.createElement("a"),s=document.createElement("img"),n="vertical-align: middle; position: relative; margin-left: 6px",o=Ext.getCmp(e.id),a=Ext.id(),r=SYNO.SDS.UIFeatures.test("isRetina")?SYNO.SDS.ThemeProvider.getPath("synoSDSjslib/images/2x/components/icon_error.png"):SYNO.SDS.ThemeProvider.getPath("synoSDSjslib/images/1x/components/icon_error.png");if(s.setAttribute("src",r),s.setAttribute("width","20px"),s.setAttribute("height","20px"),s.setAttribute("draggable","false"),o&&o.defaultTriggerWidth&&(n+=" left:"+o.defaultTriggerWidth+"px;"),s.setAttribute("style",n),s.setAttribute("ext:qtip",t),s.setAttribute("alt",t),s.setAttribute("id",a),i.appendChild(s),o instanceof SYNO.ux.DisplayField)e.appendChild(i);else if(o instanceof SYNO.ux.Button&&Ext.getDom(e).nextSibling){var l=e.dom.getAttribute("style")+" margin-right:0px !important;",d=Ext.getDom(e);d.setAttribute("style",l),i.setAttribute("style","margin-right:6px !important;"),d.parentNode.insertBefore(i,d.nextSibling)}else o instanceof SYNO.ux.TextArea?Ext.getDom(e).parentNode.parentNode.appendChild(i):Ext.getDom(e).parentNode.appendChild(i);return o&&o.el&&o.el.set({"aria-describedby":o.el.dom.getAttribute("aria-describedby")+" "+a}),i},isDirty:function(){return!1},cancelHandler:function(){},genEWWebapi:function(){return{api:"SYNO.Core.EW.Info",method:"get",version:1,params:{use_extended_cache:!1}}},genMyDSCenterWebapi:function(){return{api:"SYNO.Core.MyDSCenter",version:2,method:"query",params:{}}},isSupportEW:function(){const e="chs"===_S("lang")&&"Beijing"===_S("timezone");return"yes"===_D("support_ew_20")&&!e}}),Ext.define("SYNO.SDS.AdminCenter.AppRulePrivileges.PreviewGrid",{extend:"SYNO.ux.GridPanel",pageSize:20,constructor:function(e){this.groupingstore=new Ext.data.GroupingStore({reader:new Ext.data.JsonReader({root:"applications",fields:["name","isInternal"]}),totalProperty:"total",autoDestroy:!0,groupField:"isInternal",groupDir:"DESC"});var t=Ext.apply({header:!1,border:!1,padding:"6px 0px 0px 0px",ds:this.groupingstore,cm:new Ext.grid.ColumnModel([{id:"application",header:_T("user","user_application"),dataIndex:"name",width:200,scope:this},{header:_T("app_privilege","effective_permission"),id:"preview",dataIndex:"preview",align:"left",width:200,renderer:function(e){return"allow"===e?_T("app_privilege","allow_privilege"):"deny"===e?_T("app_privilege","deny_privilege"):"custom"===e?_T("app_privilege","grant_by_ip"):void 0}},{header:"Category",dataIndex:"isInternal",hidden:!0,groupRenderer:function(e,t,i){return i.data.isInternal?_T("service","internal_service"):_T("pkgmgr","title_packages")}}]),autoExpandColumn:"application",enableHdMenu:!1,listeners:{scope:this,activate:function(){this.loadAppRules()}},view:new SYNO.ux.GroupingView({showGroupName:!1,enableGroupingMenu:!1})},e);this.callParent([t])},loadAppRules:function(){this.module.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.AppPriv.App",method:"list",version:2,params:{offset:0,limit:this.pageSize},scope:this,callback:function(e,t){if(!e)return this.module.getMsgBox().alert(this.title,SYNO.API.getErrorString(t)),void this.module.clearStatusBusy();this.store.loadData(t),this.store.sort("name","ASC"),this.module.clearStatusBusy(),this.getSelectionModel().selectFirstRow()}})}}),Ext.define("SYNO.SDS.AdminCenter.AppRulePrivileges.PreviewDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.gridPanel=new SYNO.SDS.AdminCenter.AppRulePrivileges.PreviewGrid({module:this,itemId:"preview",autoScroll:!0,height:370});var t=this,i=[new SYNO.SDS.Share.ACLPrivilege.UserGrpCombo({initComponent:function(){Ext.apply(this,{tpl:'
    {"+this.displayField+"}
    "}),SYNO.SDS.Share.ACLPrivilege.IconCombo.superclass.initComponent.call(this)},fieldLabel:_T("acl_editor","user_or_group"),itemId:"cmb_owner",queryParam:"prefix",width:325,listWidth:325,store:new Ext.data.Store({autoDestroy:!0,proxy:new SYNO.API.Proxy({api:"SYNO.Core.ACL",method:"list_owners",version:1,appWindow:this}),reader:new Ext.data.JsonReader({root:"owners",totalProperty:"total",id:"value"},[{name:"name"},{name:"type"},{name:"value",convert:function(e,t){return t.type+":"+t.name}}]),paramNames:{start:"offset",limit:"limit"},remoteSort:!0,baseParams:{include_everyone:!1,include_owner:!1},pruneModifiedRecords:!0}),listeners:{select:function(){var e=t.form.getComponent("cmb_owner"),i=t.form.getComponent("tcpip_ipaddr");e&&!e.valueNotFound()&&e.getValue()&&""!==e.getValue()?i.enable():i.disable()}}}),{xtype:"syno_textfield",width:325,labelWidth:150,fieldLabel:_T("tcpip","tcpip_ipaddr")+_T("common","optional"),name:"source_ip",itemId:"tcpip_ipaddr",vtype:"fwLooseip",validationEvent:"keyup",disabled:!0,validator:function(e){return!(e&&!Ext.form.VTypes.fwLooseip(e))&&(t.doPreview(t.form.getComponent("cmb_owner")),!0)}},this.gridPanel],s=Ext.apply({width:600,height:500,minWidth:500,minHeight:400,layout:"fit",title:_T("acl_editor","permission_viewer"),items:[this.form=new SYNO.ux.FormPanel({border:!1,labelAlign:"left",padding:"0px",items:i,listeners:{afterlayout:function(){SYNO.ux.AddTip(this.form.findField("source_ip"),_T("app_privilege","tip_privilege_preview"))},single:!0}})],buttons:[{text:_T("common","close"),scope:this,handler:this.close}]},e);this.callParent([s]),this.gridPanel.loadAppRules(),this.mon(this.form.getComponent("cmb_owner"),"valueset",this.doPreview,this)},renderDefaultUser:function(e){var t,i=this.gridPanel.store.getCount(),s=e?"allow":"deny";for(t=0;t=0&&e<=128||_JSLIBSTR("vtype","bad_ipv6prefixLeng"):!!Ext.form.VTypes.netmaskVal.test(e)}}]};return new SYNO.ux.FormPanel(e)},OnSourceRadioClick:function(e,t){if(!e.checked)return!1;switch(e.value){case"single":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable();break;case"subnet":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").enable();break;default:this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable()}},setDefault:function(){this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable()},onApply:function(){if(this.form.isValid()){var e,t=this.form.findField("source").getGroupValue();if("single"==t)e=this.form.findField("source_ip").getValue();else{if("subnet"!=t)return;e=String.format("{0}/{1}",this.form.findField("source_ip").getValue(),this.form.findField("source_subnet_mask").getValue())}this.module.ipList.push(e),this.module.store.loadData(this.module.ipList),this.close()}else this.setStatusError({text:_T("common","forminvalid"),clear:!0})}}),Ext.define("SYNO.SDS.AdminCenter.AppRulePrivileges.RuleList",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.appWin=e.appWin,this.ipList=e.ipList,this.store=new Ext.data.ArrayStore({model:"SYNO.SDS.AdminCenter.AppRulePrivileges.RuleModel",data:this.ipList,expandData:!0,fields:["ip"]}),this.addBtn=new SYNO.ux.Button({itemId:"btn_create",text:_T("autoblock","create_ip_cap"),scope:this,handler:this.launchAddIPDialog}),this.delBtn=new SYNO.ux.Button({itemId:"btn_del",text:_T("common","remove"),scope:this,handler:this.deleteItem,disabled:!0});var t={ds:this.store,loadMask:!0,height:300,enableHdMenu:!1,tbar:{items:[this.addBtn,this.delBtn]}};Ext.apply(t,e),this.callParent([t]),this.mon(this.getSelectionModel(),"selectionchange",this.onSelectionChange,this)},onSelectionChange:function(e){0','
    ','
    ','
    ','
    ',_T("common","no_item"),"
    ","
    ","
    ",""].join("")},ds:this.store,cm:new Ext.grid.ColumnModel({columns:[{id:"name",header:_T("common","name"),dataIndex:"name",width:100,scope:this},this.allowCol,this.denyCol,this.advCol]}),plugins:[this.allowCol,this.denyCol,this.advCol],autoExpandColumn:"name",enableHdMenu:!1,selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),tbar:this.configTopToolbar(e),bbar:new SYNO.ux.PagingToolbar({store:this.store,pageSize:this.pageSize,displayInfo:!0})},e);this.callParent([n]),this.mon(this,"afterrender",this.definePrivGridBehaviors,this),this.mon(this.typeFilter,"filterChanged",this.onTypeFilterChange,this)},definePrivGridBehaviors:function(){this.mon(this,"cellclick",this.onGridCellClick,this),this.mon(this,"headerclick",function(e,t,i){var s=e.getColumnModel(),n=s.getColumnId(t);this.onGridHeaderClick.call(this,s.getColumnById(n))},this)},onTypeFilterChange:function(e){this.store.baseParams.filter_type=e,this.store.load({params:{offset:0}}),this.typeFilter.focus()},restorePermission:function(e,t){var i=e.getChanges();i.hasOwnProperty(t)&&e.set(t,!i[t])},onGridCellClick:function(e,t,i,s){var n=e.getStore().getAt(t),o=e.getColumnModel().getDataIndex(i);(function(e){return"allow"===e||"deny"===e})(o)&&(!0===n.get(o)?function(t,i){"allow"!==t&&(i.set("allow",!1),e.allowCol.checkSelectAll(e.getStore())),"deny"!==t&&(i.set("deny",!1),e.denyCol.checkSelectAll(e.getStore())),"custom"!==t&&i.set("custom",!1)}(o,n):this.restorePermission(n,"custom"))},onGridHeaderClick:function(e){e.box_el&&(e.box_el.hasClass("syno-ux-cb-checked")?("allow"!==e.dataIndex&&(this.allowCol.box_el.removeClass("syno-ux-cb-checked"),this.allowCol.onSelectAll()),"deny"!==e.dataIndex&&(this.denyCol.box_el.removeClass("syno-ux-cb-checked"),this.denyCol.onSelectAll()),this.getStore().each(function(e){e.set("custom",!1)},this)):this.getStore().each(function(e){this.restorePermission(e,"custom")},this))},createStore:function(e){var t,i,s,n=1;return"user"===e.entity_type?(t="SYNO.Core.User",i="users",s="user"):(t="SYNO.Core.Group",i="groups",s="group"),e.module._S("version")>5512&&(t="SYNO.Core.AppPriv",n=2),new SYNO.API.JsonStore({autoDestroy:!0,remoteSort:!0,appWindow:e.owner,api:t,method:"list",version:n,baseParams:{offset:0,limit:this.pageSize,type:this.authType,app_id:e.owner.app_id,filter_type:"all",rule_type:s},listeners:{exception:{scope:this,fn:this.onListUGException},beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:this.onLoad}},root:i,totalProperty:"total",fields:["name","allow","deny","custom"],defaultSortable:!0,scope:this})},onListUGException:function(e,t,i,s,n,o){this.owner.getMsgBox().alert(this.title,SYNO.API.getErrorString(n)),this===this.owner.get("tab").getActiveTab()&&this.appWin.clearStatusBusy()},onBeforeLoad:function(e,t){if(this.isStoreReady=!1,this.isNeedRender=!0,this.isChanged())return this.owner.getMsgBox().confirm(this.title,_T("share","share_save_chg_before_reload"),function(e){if("yes"===e)return this.owner.sendWebAPI({compound:{stopwhenerror:!0,params:this.getWebAPI()},scope:this,callback:function(e,i,s,n){this.owner.clearStatusBusy(),e&&!i.has_fail||this.owner.getMsgBox().alert(this.title,_T("common","error_system")),this.store.commitChanges(),this.store.load(t),this.loadRules()}}),!0;this.store.rejectChanges(),this.store.load(t)},this),!1;this===this.owner.get("tab").getActiveTab()&&this.appWin.setStatusBusy()},onLoad:function(e,t,i){this.isStoreReady=!0,this.clearBusy()},clearBusy:function(){this.isStoreReady&&this.owner.isRuleReady&&this.isNeedRender&&this.renderPrivGrid(),this===this.owner.get("tab").getActiveTab()&&this.appWin.clearStatusBusy()},renderPrivGrid:function(){var e,t,i=this.store.getCount(),s=this.owner.appRules;for(e=0;e",{xtype:"syno_displayfield",value:_T("helptoc","directory_service_domain")+": ",hidden:!0,itemId:"domainListLabel"},{xtype:"syno_combobox",itemId:"domainFilter",valueField:"value",displayField:"domain",store:{xtype:"arraystore",autoDestroy:!0,fields:["domain","value","comment"]},hidden:!0,resizable:!0,mode:"local",triggerAction:"all",editable:!1,value:"",forceSelection:!0,tpl:'
    {domain}
    ',listeners:{beforeselect:{scope:this,fn:this.onDomainFilterSelect}}},this.nameFilter=new SYNO.ux.TextFilter({conStyle:"filter",itemId:"search",queryAction:"list",enumAction:"list",emptyText:_T("user","search_user"),store:this.store,queryParam:"substr",pageSize:this.pageSize}),this.typeFilter=new SYNO.SDS.AdminCenter.AppRulePrivileges.FilterButton({style:"margin-left: 6px",supportIP:e.supportIP,hidden:e.module._S("version")<=5512})]});return this.roleFilter=t.getComponent("roleFilter"),this.domainFilter=t.getComponent("domainFilter"),this.domainListLabel=t.getComponent("domainListLabel"),t},isSupport:function(e){var t,i=this.owner.grant_type;for(t=0;t0&&o.push({api:"SYNO.Core.AppPriv.Rule",version:1,method:"delete",params:{rules:t}}),i.length>0&&o.push({api:"SYNO.Core.AppPriv.Rule",version:1,method:"set",params:{rules:i}}),o}}),Ext.define("SYNO.SDS.AdminCenter.AppRulePrivileges.EditDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.appWin=e.appWin,this.app_id=e.app_id,this.isRuleReady=!1,this.isFirstTime=!0,this.userPanel=new SYNO.SDS.AdminCenter.AppRulePrivileges.PrivGrid({entity_type:"user",module:e.module,owner:this,itemId:"userprivgrid",supportIP:e.supportIP}),this.groupPanel=new SYNO.SDS.AdminCenter.AppRulePrivileges.PrivGrid({entity_type:"group",module:e.module,owner:this,itemId:"groupprivgrid",supportIP:e.supportIP}),this.defaultPanel=new SYNO.SDS.AdminCenter.AppRulePrivileges.DefaultPanel({module:e.module,owner:this,itemId:"defaultpanel"});var t=Ext.apply({width:800,height:470,minWidth:550,minHeight:370,layout:"fit",title:e.appName,closeAction:"onCancel",items:[{xtype:"syno_tabpanel",plain:!0,itemId:"tab",activeTab:0,items:[this.userPanel,this.groupPanel,this.defaultPanel]}],buttons:[{text:_T("common","cancel"),scope:this,handler:this.onCancel},{text:_T("common","save"),scope:this,btnStyle:"blue",handler:this.saveAppRulePriv}]},e);this.callParent([t]),e.supportIP||(this.groupPanel.disable(),this.defaultPanel.disable()),1===this.grant_type.length&&"local"===this.grant_type[0]&&this.defaultPanel.disable(),this.loadRules(),this.userPanel.onActivate(),this.groupPanel.onActivate()},loadRules:function(){this.isRuleReady=!1,this.sendWebAPI({api:"SYNO.Core.AppPriv.Rule",version:1,method:"list",params:{app_id:this.app_id},scope:this,callback:function(e,t,i){if(!e)return this.clearStatusBusy(),void this.getMsgBox().alert(this.title,_T("common","error_system"));this.appRules=t.rules,this.isRuleReady=!0,this.userPanel.clearBusy(),this.groupPanel.clearBusy(),this.isFirstTime&&(this.isFirstTime=!1,this.defaultPanel.initForm(t.rules))}})},isChanged:function(){return this.userPanel.isChanged()||this.groupPanel.isChanged()||this.defaultPanel.isDirty()},onCancel:function(){this.isChanged()?this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),function(e){"leftCustom"===e?this.close():"yes"===e&&this.saveAppRulePriv()},this,{yes:_T("common","save"),cancel:!0,leftCustom:{text:_T("common","dont_save"),extraStyle:"syno-ux-button-dontsave"}}):this.close()},saveAppRulePriv:function(){this.isChanged()?"admin"!==_S("user")?this.groupPanel.isChanged()&&this.groupPanel.hasForbidUsersGroup()?this.getMsgBox().confirm(this.title,_T("app_privilege","warning_forbid_group_users"),function(e){"yes"===e&&this.onSaveAppRulePriv()},this):this.defaultPanel.isDirty()&&this.defaultPanel.hasForbidDefaultDesktop()?this.getMsgBox().confirm(this.title,_T("app_privilege","warning_forbid_default_priv"),function(e){"yes"===e&&this.onSaveAppRulePriv()},this):this.onSaveAppRulePriv():this.onSaveAppRulePriv():this.close()},onSaveAppRulePriv:function(){this.setStatusBusy();var e=[];this.userPanel.isChanged()&&(e=e.concat(this.userPanel.getWebAPI())),this.groupPanel.isChanged()&&(e=e.concat(this.groupPanel.getWebAPI())),this.defaultPanel.isDirty()&&(e=e.concat(this.defaultPanel.getWebAPI())),this.sendWebAPI({compound:{stopwhenerror:!0,params:e},scope:this,callback:this.saveAppRulePrivDone})},saveAppRulePrivDone:function(e,t,i,s){if(this.clearStatusBusy(),e&&!t.has_fail)this.module.loadAppRules(),this.close();else{var n=SYNO.API.Errors.core[t.code]||_T("common","error_system");if(3405===t.code){var o=Ext.id(),a=String.format(n,String.format('',o),"");this.getMsgBox().alert(this.title,a),this.mon(Ext.fly(o),"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.SupportForm.Application")},this)}else this.getMsgBox().alert(this.title,n)}}}),Ext.define("SYNO.SDS.AdminCenter.AppRulePrivileges.AppGrid",{extend:"SYNO.ux.GridPanel",pageSize:20,constructor:function(e){this.actionEdit=new Ext.Action({text:_T("common","alt_edit"),itemId:"edit",scope:this,handler:function(){var e=this.getSelectionModel().getSelected();e&&this.launchEditDialog(e)}});var t=new Ext.Action({text:_T("acl_editor","permission_viewer"),itemId:"preview",scope:this,handler:function(){this.launchPreviewDialog()}}),i=new Ext.Action({text:_T("iscsitrg","iscsitrg_masking_default"),itemId:"default",scope:this,hidden:!0,handler:function(){this.launchEditDefaultDialog()}});this.tbar=new Ext.Toolbar({defaultType:"syno_button",items:[this.actionEdit,t,i]}),this.groupingstore=new Ext.data.GroupingStore({reader:new Ext.data.JsonReader({root:"applications",fields:["name","app_id","grant_type","supportIP","grant_by_default","isInternal"]}),totalProperty:"total",autoDestroy:!0,groupField:"isInternal",groupDir:"DESC"}),this.gridCtxMenu=new SYNO.ux.Menu({items:[{text:_T("common","alt_edit"),scope:this,handler:function(){var e=this.getSelectionModel().getSelected();e&&this.launchEditDialog(e)}}]}),this.addManagedComponent(this.gridCtxMenu);var s=Ext.apply({title:"Privileges",header:!1,border:!1,ds:this.groupingstore,cm:new Ext.grid.ColumnModel([{id:"application",header:_T("user","user_application"),dataIndex:"name",menuDisabled:!0,scope:this},{header:_T("app_privilege","grant_default_privilege"),dataIndex:"grant_by_default",disableSelectAll:!1,align:"center",renderer:function(e){var t=!0===e?"syno-admincenter-media-index-enabled":"";return String.format('
    ',t)}.createDelegate(this)},{header:"Category",dataIndex:"isInternal",hidden:!0,groupRenderer:function(e,t,i){return i.data.isInternal?_T("service","internal_service"):_T("pkgmgr","title_packages")}}]),autoExpandColumn:"application",enableHdMenu:!1,selModel:new Ext.grid.RowSelectionModel({singleSelect:!0}),listeners:{scope:this,activate:function(){this.loadAppRules()},rowdblclick:{scope:this,fn:function(e,t,i){var s=this.store.getAt(t);s&&this.launchEditDialog(s)}},rowcontextmenu:this.onClickContexMenu,containercontextmenu:this.onKeyContexMenu},view:new SYNO.ux.GroupingView({showGroupName:!1,enableGroupingMenu:!1})},e);this.callParent([s])},onKeyContexMenu:function(e,t){this.gridCtxMenu.showAt(t.getXY())},onClickContexMenu:function(e,t,i){var s=e.getSelectionModel();s.isSelected(t)||s.selectRow(t),this.gridCtxMenu.showAt(i.getXY())},loadAppRules:function(){this.module.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.AppPriv.App",method:"list",version:3,params:{offset:0,limit:this.pageSize},scope:this,callback:function(e,t){if(!e)return this.module.appWin.getMsgBox().alert(this.title,SYNO.API.getErrorString(t)),void this.module.appWin.clearStatusBusy();this.store.loadData(t),this.store.sort("name","ASC"),this.module.appWin.clearStatusBusy(),this.getSelectionModel().selectFirstRow()}})},launchEditDialog:function(e){new SYNO.SDS.AdminCenter.AppRulePrivileges.EditDialog({owner:this.module.appWin,module:this,appName:e.get("name"),app_id:e.get("app_id"),grant_type:e.get("grant_type"),supportIP:e.get("supportIP"),enable_domain:this.module.enable_domain,enable_ldap:this.module.enable_ldap,join_domain:this.module.join_domain,join_ldap:this.module.join_ldap,domain_list:this.module.domain_list,manage_mode:this.module.manage_mode}).open()},launchPreviewDialog:function(){new SYNO.SDS.AdminCenter.AppRulePrivileges.PreviewDialog({owner:this.module.appWin,module:this}).open()},launchEditDefaultDialog:function(){new SYNO.SDS.AdminCenter.AppRulePrivileges.DefaultPrivDialog({owner:this.module.appWin,module:this}).open()}}),Ext.define("SYNO.SDS.AdminCenter.AppRulePrivileges.Main",{extend:"SYNO.SDS.AdminCenter.Module",enable_domain:!1,enable_ldap:!1,constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.panel=new SYNO.SDS.AdminCenter.AppRulePrivileges.AppGrid({module:this,title:_T("tree","leaf_appprivilege")})},loadTypeStatus:function(){var e=[];this.panel.getKnownAPI("SYNO.Core.Directory.Domain")&&(e.push({api:"SYNO.Core.Directory.Domain",version:1,method:"get"}),e.push({api:"SYNO.Core.Directory.Domain",version:1,method:"test_dc"}),"yes"===this.appWin._D("supportdomain")&&e.push({api:"SYNO.Core.Directory.Domain",method:"get_domain_list",version:2})),e.push({api:"SYNO.Core.Directory.LDAP",version:1,method:"get"}),this.appWin.sendWebAPI({compound:{stopwhenerror:!0,params:e},scope:this,callback:this.loadTypeStatusHandler})},loadTypeStatusHandler:function(e,t,i,s){this.appWin.isDestroyed||(e&&!t.has_fail?(this.enable_ldap=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.LDAP","get","enable_client"),this.join_ldap=2702===SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.LDAP","get","error"),this.panel.getKnownAPI("SYNO.Core.Directory.Domain")&&(this.enable_domain=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get","enable_domain"),this.join_domain=SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","test_dc","test_join_success"),this.domain_list="yes"===this.appWin._D("supportdomain")&&SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get_domain_list","domain_list"),this.manage_mode="yes"===this.appWin._D("supportdomain")&&SYNO.API.Response.GetValByAPI(t,"SYNO.Core.Directory.Domain","get","manage_mode"))):this.appWin.getMsgBox().alert(this.title,_T("common","error_system")))},getPanel:function(){return this.panel},getHelpParam:function(){return"AdminCenter/application_appprivilege.html"},activate:function(){this.loadTypeStatus()}}),Ext.define("SYNO.SDS.AdminCenter.MediaIndex.IndexFolderEditDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.mode=e.mode,this.store=e.store,this.parent=e.parent,this.panel=this.createPanel(),this.form=this.panel.getForm(),this.defaultLabelWidth=100;var t=Ext.apply({module:e.module,cls:"syno-admincenter-media-index",defaultLabelWidth:this.defaultLabelWidth,title:"add"===this.mode?_T("mediaservice","index_folder_create"):_T("mediaservice","index_folder_edit"),width:640,autoHeight:!0,resizable:!1,padding:0,items:[this.panel],buttons:[{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.close},{xtype:"syno_button",btnStyle:"blue",text:_T("common","alt_apply"),scope:this,disabled:"add"===this.mode,id:this.btnApplyId=Ext.id(),handler:"add"===this.mode?this.createHandler:this.editHandler}]},e);this.callParent([t]),this.btnApply=Ext.getCmp(this.btnApplyId),this.btnEditPath=Ext.getCmp(this.editPathBtnId),this.textFolderPath=Ext.getCmp(this.textFolderPathId),this.textName=Ext.getCmp(this.textNameId),this.checkPhoto=Ext.getCmp(this.checkPhotoId),this.checkMusic=Ext.getCmp(this.checkMusicId),this.checkVideo=Ext.getCmp(this.checkVideoId),"edit"===this.mode&&(this.origPath=this.parent.getSelectionModel().getSelected().get("path")),this.textFolderPath.getEl().on("mouseup",this.editPathBtnHandler,this),this.textFolderPath._window=this},onOpen:function(){if("edit"==this.mode){var e=this.panel.getForm(),t=this.parent.getSelectionModel().getSelected();e.setValues({name:t.get("name"),path:t.get("path"),photo:t.get("photo"),music:t.get("music"),video:t.get("video")}),e.clearInvalid()}this.show()},createPanel:function(){var e={trackResetOnLoad:!0,height:155,border:!1,padding:"16px 20px 0px 20px",items:[{xtype:"syno_fieldset",labelWidth:this.defaultLabelWidth,bwrapCfg:{padding:0},items:[{xtype:"syno_textfield",fieldLabel:_T("common","name"),name:"name",width:260,itemId:"name",id:this.textNameId=Ext.id(),maxlength:255,allowBlank:!1,blankText:_T("mediaservice","error_empty_rule_name")},{xtype:"syno_compositefield",items:[{xtype:"syno_textfield",fieldLabel:_T("common","folder"),width:260,name:"path",id:this.textFolderPathId=Ext.id(),readOnly:!0,allowBlank:!1,validateOnBlur:!1,validationEvent:!1,validator:this.validPath,blankText:_T("mediaservice","error_empty_path")},{xtype:"syno_button",id:this.editPathBtnId=Ext.id(),text:_T("common","choose"),scope:this,handler:this.editPathBtnHandler}]},{xtype:"syno_compositefield",fieldLabel:_T("mediaservice","index_folder_index_type"),width:300,items:[{xtype:"syno_checkbox",boxLabel:_T("mediaservice","class_photos"),width:100,name:"photo",id:this.checkPhotoId=Ext.id(),checked:!0},{xtype:"syno_checkbox",boxLabel:_T("mediaservice","class_music"),width:100,name:"music",id:this.checkMusicId=Ext.id(),checked:!0},{xtype:"syno_checkbox",boxLabel:_T("mediaservice","class_video"),width:100,name:"video",id:this.checkVideoId=Ext.id(),checked:!0}]}]}]};return new SYNO.ux.FormPanel(e)},createHandler:function(){var e=this.panel.getForm().findField("path"),t=this.panel.getForm().findField("name"),i=this.textFolderPath.getValue(),s=this.textName.getValue();if(e.isValid()&&t.isValid()){var n=new this.store.recordType({exist:!0,name:"",path:"",photo:"",music:"",video:"",default:!1});this.store.add(n),n.set("name",s),n.set("path",i),n.set("photo",this.checkPhoto.getValue()),n.set("music",this.checkMusic.getValue()),n.set("video",this.checkVideo.getValue()),this.close()}},editHandler:function(){var e=this.panel.getForm().findField("path"),t=this.panel.getForm().findField("name"),i=this.parent.getSelectionModel().getSelected();e.isValid()&&t.isValid()&&(i.set("name",this.textName.getValue()),i.set("path",this.textFolderPath.getValue()),i.set("photo",this.checkPhoto.getValue()),i.set("music",this.checkMusic.getValue()),i.set("video",this.checkVideo.getValue()),this.close())},editPathBtnHandler:function(){void 0===this.dialog&&(this.dialog=new SYNO.SDS.Utils.FileChooser.Chooser({parent:this,owner:this,closeOwnerWhenNoShare:!0,closeOwnerNumber:2,superuser:!0,needrw:!1,usage:{type:"chooseDir"},title:_T("mediaservice","select_folder"),folderToolbar:!0,treeFilter:function(e,t){return!t||"/home"!==t.spath&&"/homes"!==t.spath&&"remote"!==t.mountType},listeners:{scope:this,choose:function(e,t,i){if(this.textFolderPath.setValue(t.path),""===this.textName.getValue()){var s=t.path.split("/");this.textName.setValue(s[s.length-1])}e.close()},close:function(){delete this.dialog}}})),this.dialog.show()},validPath:function(){var e=this._window;return this.getValue()!==e.origPath&&-1!==e.store.findExact("path",this.getValue())?(e.btnApply.setDisabled(!0),_T("mediaservice","error_duplicate_path")):(e.btnApply.setDisabled(!1),!0)}}),SYNO.SDS.AdminCenter.MediaIndex.MAX_RULE=100,Ext.define("SYNO.SDS.AdminCenter.MediaIndex.DirPanel",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.module=e.module,this.url="",this.store=this.createStore(),this.columnModel=this.createColumnModel(),this.isStoreUpdated=!1;var t=Ext.apply({module:e.module,title:_T("mediaservice","index_folder_title"),store:this.store,enableColumnMove:!1,enableHdMenu:!1,hideMode:"offsets",colModel:this.columnModel,selModel:new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:{fn:this.updateActionGroup,buffer:50,scope:this}}}),tbar:new Ext.Toolbar({defaultType:"syno_button",items:this.getActionGroup().getArray()}),listeners:{rowdblclick:function(){this.openIndexFolderEditDialog("edit")},rowcontextmenu:this.onRowContextMenu,containercontextmenu:this.onContainerContextMenu,scope:this}},e);this.callParent([t]),this.mon(this.store,"onBeforeLoad",this.onBeforeLoad,this)},isDirty:function(){return 0'+a+"
    "}},{id:"photo",header:_T("mediaservice","class_photos"),dataIndex:"photo",renderer:this.indexTypeRenderer},{id:"music",header:_T("mediaservice","class_music"),dataIndex:"music",renderer:this.indexTypeRenderer},{id:"video",header:_T("mediaservice","class_video"),dataIndex:"video",renderer:this.indexTypeRenderer}]})},getColumnById:function(e){return this.getColumnModel().getColumnById(e)},indexTypeRenderer:function(e,t,i,s,n,o){var a,r;return r=this.getColumnById(t.id).header,a=e?"syno-admincenter-media-index-enabled":"",String.format('
    ',a,Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(r+" "+_T("common","enabled"))))},updateActionGroup:function(){var e=this.getActionGroup(),t=this.getStore().getCount(),i=this.getSelectionModel().getCount();e.disableAll(),SYNO.SDS.AdminCenter.MediaIndex.MAX_RULE>t&&e.enable("create"),1===i&&e.enable("edit"),0','
    ',"{[this.getDisplayString(values.value, true)]}","
    ","",{getDisplayString:this.getDisplayString.createDelegate(this)})},getDisplayString:function(e,t){if(e<24)return String.leftPad(String(e),2,"0")+":00";var i=!0===t?String.format(' {0} ',_T("convert_setting","tomorrow")):" "+_T("convert_setting","tomorrow");return String.leftPad(String(e-24),2,"0")+":00"+i}}),Ext.define("SYNO.SDS.AdminCenter.MediaIndex.StartTimeField",{extend:"SYNO.SDS.AdminCenter.MediaIndex.TimeField",constructor:function(e){var t,i=[];for(t=0;t<24;++t)i.push([this.getDisplayString(t),t]);var s=new Ext.data.ArrayStore({fields:["display","value"],data:i});this.addManagedComponent(s);var n={store:s};Ext.apply(n,e),this.callParent([n])}}),Ext.define("SYNO.SDS.AdminCenter.MediaIndex.EndTimeField",{extend:"SYNO.SDS.AdminCenter.MediaIndex.TimeField",constructor:function(e){var t=new Ext.data.ArrayStore({fields:["display","value"]});this.addManagedComponent(t);var i={store:t};Ext.apply(i,e),this.callParent([i])},filterStoreWithStartTime:function(e){var t,i=this.getValue();i&&e>=i&&this.setValue(e+1);var s=[];for(t=e+1;t{0}

    ',e)):"-";var e},updateReIndexingMsg:function(){var e=this.generateReIndexingMsg();this.setReIndexMsg(e)},setReIndexingMsgARIA:function(){this.field_reindex_msg.getEl().setARIA({role:"status",live:"assertive",relevant:"all"}),SYNO.ux.Utils.DescribeGroup(this.field_app_list,this.field_reindex_msg)},getMediaIndexingCfg:function(){return{xtype:"syno_fieldset",stateId:"SYNO.SDS.AdminCenter.MediaIndex.Main::indexing::reindexing",collapsible:!0,title:_T("media_index_service","app_name"),items:[{xtype:"syno_displayfield",htmlEncode:!1,value:_T("media_index_service","description_index_service")},{xtype:"syno_displayfield",id:this.field_app_list=Ext.id(),fieldLabel:_T("media_index_service","application_list")},{xtype:"syno_displayfield",id:this.field_reindex_msg=Ext.id(),htmlEncode:!1,fieldLabel:_T("media_index_service","indexing_status")},{xtype:"syno_compositefield",id:this.compositefie_ld=Ext.id(),hideLabel:!0,items:[{xtype:"syno_button",text:_T("mediaservice","index_folder_title"),itemId:"indexing_folder_btn",name:"indexing_folder_btn",scope:this,handler:this.onClickIndexFolderBtn},{xtype:"syno_button",text:_T("service","service_photo_reindex"),id:this.field_reindex_btn=Ext.id(),name:"reindexing_btn",disabled:!0,scope:this,handler:this.onClickReindexBtn}]},{xtype:"syno_displayfield",htmlEncode:!1,value:this.getNoteMessage(_T("media_index_service","note"))}],listeners:{afterlayout:this.setReIndexingMsgARIA,single:!0,scope:this}}},getConvertSettingsCfg:function(){return{xtype:"syno_fieldset",stateId:"SYNO.SDS.AdminCenter.MediaIndex.Main::convert::video",collapsible:!0,title:_T("convert_setting","title"),items:[{xtype:"syno_displayfield",htmlEncode:!1,value:_T("convert_setting","description")},{xtype:"syno_combobox",name:"thumbnail_quality",id:this.thumbnail_quality_id=Ext.id(),webapi:{api:"SYNO.Core.MediaIndexing.ThumbnailQuality",methods:{get:"get",set:"set"},version:1},width:220,fieldLabel:_T("thumb_conv_options","thumb_quality"),value:"normal",displayField:"display",valueField:"value",store:new Ext.data.ArrayStore({fields:["value","display"],data:[["normal",_T("thumb_conv_options","normal_quality")],["high",_T("thumb_conv_options","high_quality")]]})},{xtype:"syno_checkbox",id:this.scheduler_enabled_id=Ext.id(),webapi:{api:"SYNO.Core.MediaIndexing.Scheduler",methods:{get:"get",set:"set"},version:1},boxLabel:_T("convert_setting","scheduler_enabled"),name:"scheduler_enabled"},{xtype:"syno_schedulefield",id:this.week_name_id=Ext.id(),webapi:{api:"SYNO.Core.MediaIndexing.Scheduler",methods:{get:"get",set:"set"},version:1},indent:1,fieldLabel:_T("convert_setting","frequency"),name:"week",allowBlank:!1,editable:!1,width:220},this.getStartTimeField(),this.getEndTimeField()]}},getStartTimeField:function(){return this.start_time_filed?this.start_time_filed:(this.start_time_filed=new SYNO.SDS.AdminCenter.MediaIndex.StartTimeField({name:"start",fieldLabel:_T("convert_setting","start_time"),indent:1,webapi:{api:"SYNO.Core.MediaIndexing.Scheduler",methods:{get:"get",set:"set"},version:1},listeners:{select:function(e,t,i){this.getEndTimeField().filterStoreWithStartTime(t.get("value"))},scope:this}}),this.start_time_filed)},getEndTimeField:function(){return this.end_time_filed?this.end_time_filed:(this.end_time_filed=new SYNO.SDS.AdminCenter.MediaIndex.EndTimeField({name:"end",fieldLabel:_T("convert_setting","end_time"),indent:1,webapi:{api:"SYNO.Core.MediaIndexing.Scheduler",methods:{get:"get",set:"set"},version:1}}),this.end_time_filed)},getNoteMessage:function(e){return''+_T("common","note")+": "+e},onClickIndexFolderBtn:function(){var e=this;Ext.isDefined(e.indexFolderGrid)||(e.indexFolderGrid=new SYNO.SDS.AdminCenter.MediaIndex.DirPanel({module:e.module,parentTabPanel:e.parentTabPanel}),this.mon(e.indexFolderGrid.getStore(),"load",this.sendIndexFolderWebapi,this)),Ext.isDefined(e.indexFolderDialog)||(e.indexFolderDialog=new SYNO.SDS.ModalWindow({owner:e.module.appWin,layout:"fit",width:680,resizable:!1,title:_T("mediaservice","index_folder_title"),buttons:[{text:_T("common","alt_close"),scope:this,handler:function(){if(this.indexFolderGrid.isDirty()){var e={dontSave:function(){this.indexFolderDialog.hide()},cancel:Ext.emptyFn,save:function(){this.indexFolderGrid.saveHandler(),this.indexFolderDialog.hide()}};this.indexFolderDialog.confirmLostChangePromise(e,this)}else this.indexFolderDialog.hide()}},{text:_T("common","save"),itemId:"save",btnStyle:"blue",scope:e,handler:function(){this.indexFolderGrid.saveHandler(),this.indexFolderDialog.hide()}}],items:[e.indexFolderGrid],listeners:{scope:this,show:function(){this.indexFolderGrid.owner=this.indexFolderDialog,this.indexFolderGrid.getStore().load()},hide:function(){this.indexFolderGrid.clearDirty()}}})),e.indexFolderDialog.mon(e.indexFolderDialog,"close",function(){e.indexFolderDialog=void 0,e.indexFolderGrid=void 0}),e.indexFolderDialog.open()},onClickReindexBtn:function(){this.field_reindex_btn.disable(),this.parentTabPanel.sendWebAPI({params:{},compound:{stopwhenerror:!1,params:[{api:"SYNO.Core.MediaIndexing",method:"reindex",version:1,params:{}}]},scope:this,callback:function(e,t,i){this.parentTabPanel.clearStatusBusy(),e?(this.is_reindexing=!0,this.updateReIndexingMsg()):this.parentTabPanel.onApiFailure("set",t,i)}})},isDirty:function(){return this.thumbnail_quality_field.isDirty()||this.scheduler_enabled_field.isDirty()||this.week_name_field.isDirty()||this.getStartTimeField().isDirty()||this.getEndTimeField().isDirty()},processReturnData:function(e,t,i){"get"===e&&this.processReturnDataGet(t),!1===t.has_fail&&Ext.each(t.result,function(e){if(!0===e.success&&"SYNO.Core.MediaIndexing.Scheduler"===e.api&&"get"===e.method){var t=[];Ext.each(e.data.week,function(e,i){e&&t.push(i)},this);var i=e.data.start.hour;return Ext.apply(e.data,{week:t.join(","),start:i,end:i+e.data.duration,scheduler_enabled:"schedule"===e.data.mode}),this.getEndTimeField().filterStoreWithStartTime(i),!1}},this),this.callParent(arguments)},processParams:function(e,t){return"set"===e?this.processSetParams(e,t):this.callParent(arguments)},processSetParams:function(e,t){const i={api:"SYNO.Core.MediaIndexing.Scheduler",method:"set",version:1};return t.forEach(e=>{SYNO.ux.Utils.checkApiConsistency(i,e)&&(e.params=this.getSchedulerSetParams(e.params))}),t},getSchedulerSetParams:function(e){if(e.scheduler_enabled){for(var t=[],i=0;i<7;i++)t.push(-1!==e.week.indexOf(i.toString()));return{week:t,start:{hour:e.start},duration:e.end-e.start,mode:"schedule"}}return{mode:"always"}},onApiSuccess:function(e,t){"set"===e&&(t.has_fail?this.module.confirmSaveLostReject&&this.module.confirmSaveLostReject():this.module.confirmSaveLostResolve&&this.module.confirmSaveLostResolve()),this.callParent(arguments)},processReturnDataGet:function(e){const t={api:"SYNO.Core.MediaIndexing.ThumbnailQuality",method:"get",version:1};Ext.each(e.result,function(e,i){!0===e.success&&SYNO.ux.Utils.checkApiConsistency(e,t)&&this.processReturnDataThumbnailQuailtyGet(e.data)},this)},processReturnDataThumbnailQuailtyGet:function(e){var t=e.packages;this.mediaIndexingPackages=t,this.updateFieldAppList(t),Promise.all(this.initPromises).then(([e,t])=>{let i=e.folders;this.has_index_folder=Ext.isArray(i)&&i.length>0,this.is_reindexing=t.reindexing}).then(()=>{this.updateReIndexingMsg(),this.field_reindex_btn.setDisabled(!this.hasPackages()||this.is_reindexing)}).catch(e=>{})},updateFieldAppList:function(e){var t="";if(0===e.length)t=_T("mediaservice","no_media_pacakge");else{for(var i=[],s=0;s0)},polling_callback:function(e,t,i,s){this.parentTabPanel.clearStatusBusy(),e?(this.is_reindexing=t.reindexing,this.updateReIndexingMsg(),this.field_reindex_btn.setDisabled(!this.hasPackages()||t.reindexing)):(this.parentTabPanel.setStatusError({text:SYNO.API.getErrorString(t),clear:!1}),this.field_reindex_btn.enable())},prepareInitPromises:function(){let e=this.parentTabPanel.sendWebAPIPromise({api:"SYNO.Core.MediaIndexing.IndexFolder",method:"get",version:1}),t=this.parentTabPanel.sendWebAPIPromise({api:"SYNO.Core.MediaIndexing",method:"status",version:1});this.initPromises=[e,t]},stopPolling:function(){null!==this.polling_id&&(this.pollUnreg(this.polling_id),this.polling_id=null)},startPolling:function(){this.stopPolling(),this.polling_id=this.pollReg({interval:5,immediate:!1,scope:this,webapi:{api:"SYNO.Core.MediaIndexing",method:"status",version:1},status_callback:this.polling_callback})},sendIndexFolderWebapi:function(){this.parentTabPanel.sendWebAPIPromise({api:"SYNO.Core.MediaIndexing.IndexFolder",method:"get",version:"1"}).then(e=>{this.has_index_folder=Ext.isArray(e.folders)&&e.folders.length>0,this.updateReIndexingMsg()}).catch(e=>{})},destroy:function(){this.callParent(arguments),Ext.isDefined(this.indexFolderDialog)&&this.indexFolderDialog.close(),this.stopPolling()}}),Ext.define("SYNO.SDS.AdminCenter.MediaIndex.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.callParent(arguments),this.appWin=e.appWin,this.panel=new SYNO.SDS.AdminCenter.MediaIndex.ServicePanel({module:this,appWin:this.appWin,parentTabPanel:this.appWin})},getPanel:function(){return this.panel},setActivateParams:function(e){},activate:function(e){this.panel.loadForm()},deactivate:function(){return this.panel.stopPolling(),!this.panel.isDirty()},confirmCallback:function(e){"no"===e&&this.panel.startPolling()},getHelpParam:function(){return"AdminCenter/application_mediaindexservice_general.html"},confirmLostChangeSave:function(){return new Promise(function(e,t){this.confirmSaveLostResolve=e,this.confirmSaveLostReject=t,this.panel.applyForm()}.bind(this))},confirmLostChangeCancel:function(){this.panel.startPolling()}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.EventEditDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t=Ext.namespace(e.app_panel);this.blCreate=!e.task_name,this.EditPanelApp=new t({itemId:"appPanel",title:_T("schedule","task_settings"),owner:this,preloadConfig:e.preloadConfig,isCreateMode:this.blCreate}),this.EditPanelBasic=new SYNO.SDS.AdminCenter.TaskScheduler.EventEditPanelBasic({itemId:"basicPanel",owner:this,blCreate:this.blCreate});var i=[this.EditPanelBasic,this.EditPanelApp];this.tabPanel=new SYNO.ux.TabPanel({itemId:"tabPanel",deferredRender:!1,layoutOnTabChange:!0,activeTab:0,plain:!0,height:450,items:i});var s={title:e.task_name?_T("schedule","edit_task"):_T("schedule","create_task"),width:530,height:550,resizable:!1,items:this.tabPanel,buttons:[{xtype:"syno_button",btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.hClickCancel},{xtype:"syno_button",btnStyle:"blue",disabled:_S("demo_mode"),text:_T("common","apply"),scope:this,handler:this.applySetting}],listeners:{change_event:this.hChangeEvent,beforeclose:this.onBeforeClose,scope:this}};return Ext.apply(s,e),s},getInvalidTab:function(){return this.EditPanelBasic.getForm().isValid()?this.EditPanelApp.getForm().isValid()?null:this.EditPanelApp:this.EditPanelBasic},applySetting:function(){var e=this.getInvalidTab(),t=this.getComponent("tabPanel");if(null!==e)return t.setActiveTab(e.itemId),void this.setStatusError({text:_T("common","forminvalid"),clear:!0});var i=this.EditPanelBasic.getData(),s=this.EditPanelApp.getData();Ext.apply(i,s),i.operation_type=this.operation_type,i.operation=i[i.operation_type],delete i[i.operation_type],this.task_name&&this.task_name!=i.task_name&&(i.old_task_name=this.task_name),"0"!==Object.keys(i.owner)[0]?this.sendSaveWebAPI(i):this.getMsgBox().confirmDelete("",_T("schedule","msg_warning_before_save_task"),function(e){"ok"===e&&this.sendSaveWebAPI(i)},this,{ok:{text:Ext.MessageBox.buttonText.ok,btnStyle:"red"},cancel:{text:Ext.MessageBox.buttonText.cancel}})},sendSaveWebAPI(e){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.EventScheduler",method:this.task_name?"set":"create",version:1,params:e,callback:function(e,t,i){this.clearStatusBusy(),e?(this.doClose(),this.owner_grid.loadData()):t.errors&&"DUPLICATE_PRIMARY_KEY"==t.errors?(this.tabPanel.setActiveTab(this.EditPanelBasic),this.EditPanelBasic.getForm().findField("task_name").markInvalid(_T("schedule","msg_duplicate_name")),this.setStatusError({text:_T("common","forminvalid"),clear:!0})):this.getMsgBox().alert(_T("schedule","task_scheduler"),_T("common","commfail"),null,this)},scope:this})},onBeforeClose(){if(this.blCreate||!this.isDirty())return!0;let e={save:()=>{this.applySetting()},cancel:Ext.emptyFn,dontSave:()=>{this.doClose()}};return this.confirmLostChangePromise(e,this),!1},hClickCancel(){this.close()},isDirty:function(){return this.tabPanel.items.getRange().some(e=>Ext.isFunction(e.isDirty)&&e.isDirty())},hChangeEvent:function(){var e=this.EditPanelBasic.getForm().findField("event").getValue();this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.EventScheduler",method:"list",version:1,params:{event:e},callback:function(e,t,i){if(this.clearStatusBusy(),e){t=t||[],this.EditPanelBasic.dependSb.clearValue(),this.EditPanelBasic.dependSb.setDisabled(Ext.isEmpty(t));for(var s=[],n=0;ne.name===t);return i&&Ext.isNumber(i.uid)?i.uid:0},isValid:function(){return this.getForm().isValid()},isDirty:function(){return this.getForm().isDirty()}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.ViewDetail",{extend:"SYNO.SDS.ModalWindow",textValue:"",constructor:function(e){let t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){let t={title:e.fieldLabel,cls:"syno-task-scheduler-status-detail",width:720,height:580,resizable:!1,items:[this.formPanel=new SYNO.ux.FormPanel({height:492,cls:"syno-task-scheduler-status-detail-formpanel",items:[{xtype:"syno_button",text:_T("schedule","copy_all"),scope:this,handler:this.hCopy},{xtype:"syno_textarea",cls:"syno-task-scheduler-status-detail-textarea",ref:"../textArea",hideLabel:!0,emptyText:_T("schedule","msg_no_data"),width:680,height:412,readOnly:!0,value:e.textValue}]})],buttons:[{xtype:"syno_button",btnStyle:"blue",text:_T("common","close"),scope:this,handler:this.hClose}]};return Ext.apply(t,e),t},hClose:function(){this.close()},hCopy:function(){this.textArea.el.dom.select(),document.execCommand("copy"),new SYNO.SDS.ToastBox({text:_T("schedule","copy_to_clipboard"),owner:this,delay:2500}).show()}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.EventViewDialog",{extend:"SYNO.SDS.ModalWindow",DESC_HEIGHT:136,constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){this.result_store=new Ext.data.ArrayStore({fields:["result_id","start_time"],data:[]}),this.selectCb=new SYNO.ux.ComboBox({xtype:"syno_combobox",width:200,editable:!1,mode:"local",triggerAction:"all",fieldLabel:_T("schedule","select_result"),displayField:"start_time",valueField:"result_id",store:this.result_store,listeners:{scope:this,select:this.hSelect}});var t={title:_T("schedule","title_run_result"),width:530,height:622,resizable:!1,items:[this.form=new SYNO.ux.FormPanel({height:472,indent:1,items:[this.selectCb,{xtype:"syno_displayfield",fieldLabel:_T("schedule","exit_status"),name:"exit_code"},{xtype:"syno_displayfield",fieldLabel:_T("schedule","start_time"),name:"start_time"},{xtype:"syno_displayfield",fieldLabel:_T("schedule","stop_time"),name:"stop_time"},{xtype:"syno_displayfield",fieldLabel:_T("schedule","event"),name:"trigger_event"},{xtype:"syno_displayfield",cls:"syno-task-scheduler-status-desc",hidden:!e.enableSaveScriptLog,fieldLabel:_T("schedule","script"),value:_T("schedule","msg_no_data"),name:"script_in",ref:"../script_in",width:290,height:this.DESC_HEIGHT},{xtype:"syno_displayfield",cls:"syno-task-scheduler-status-desc",hidden:!e.enableSaveScriptLog,fieldLabel:_T("schedule","output"),value:_T("schedule","msg_no_data"),name:"script_out",ref:"../script_out",width:290,height:this.DESC_HEIGHT},{xtype:"syno_displayfield",hidden:e.enableSaveScriptLog,hideLabel:!0,htmlEncode:!1,style:{padding:"50px 0 0 0"},value:String.format('{0}{1} {2}',_T("common","note"),_T("common","colon"),_T("schedule","set_script_output_dir"))}]})],buttons:[{xtype:"syno_button",btnStyle:"blue",text:_T("common","ok"),scope:this,handler:this.hClickOK}]};return Ext.apply(t,e),t},hClickOK:function(){this.close()},hSelect:function(e,t,i){this.loadResult(i)},onOpen:function(){this.loadResultList(this.task_name),this.callParent([arguments])},loadResultList:function(e){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.EventScheduler",method:"result_list",version:1,params:{task_name:e},scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),e)if(Ext.isArray(t)){t.reverse();for(var s=[],n=0;nthis.DESC_HEIGHT;)s=s.substr(0,s.length-1),t.innerHTML=s+' ... '+_T("schedule","view_details")+"";let n=e.el.first("a");n&&this.mon(n,"click",function(t){t.preventDefault(),new SYNO.SDS.AdminCenter.TaskScheduler.ViewDetail({owner:this,textValue:i,title:e.fieldLabel}).open()},this)},loadResult:function(e){var t=this.result_list[e];this.form.getForm().setValues(t);var i=_T("schedule",t.exit_info.exit_type),s=t.exit_info.exit_code;Ext.isDefined(t.exit_info.exit_code)?this.form.getForm().findField("exit_code").setValue(i+" ("+s+")"):this.form.getForm().findField("exit_code").setValue(i),this.form.getForm().findField("trigger_event").setValue(_T("schedule",t.trigger_event)||t.trigger_event||"Unknown"),this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.EventScheduler",method:"result_get_file",version:1,params:{task_name:t.task_name,result_id:t.result_id},scope:this,callback:function(e,t,i){this.clearStatusBusy(),e&&Ext.isDefined(t)&&(this.form.getForm().setValues(t),this.trimScript(this.script_in),this.trimScript(this.script_out))}})}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.ViewDialog",{extend:"SYNO.SDS.ModalWindow",DESC_HEIGHT:136,constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){this.resultIndex=0,this.result_store=new Ext.data.ArrayStore({fields:["start_time"],data:[]}),this.selectCb=new SYNO.ux.ComboBox({xtype:"syno_combobox",width:200,editable:!1,mode:"local",triggerAction:"all",fieldLabel:_T("schedule","select_result"),displayField:"start_time",valueField:"start_time",store:this.result_store,listeners:{scope:this,select:this.hSelect}});var t={title:_T("schedule","title_run_result"),width:530,height:622,resizable:!1,items:[this.form=new SYNO.ux.FormPanel({height:472,items:[this.selectCb,{xtype:"syno_displayfield",fieldLabel:_T("schedule","exit_status"),name:"exit_status"},{xtype:"syno_displayfield",fieldLabel:_T("schedule","start_time"),name:"start_time"},{xtype:"syno_displayfield",fieldLabel:_T("schedule","stop_time"),name:"stop_time"},{xtype:"syno_displayfield",cls:"syno-task-scheduler-status-desc",name:"script_in",ref:"../script_in",hidden:!e.enableSaveScriptLog,fieldLabel:_T("schedule","script"),value:_T("schedule","msg_no_data"),width:288,height:this.DESC_HEIGHT},{xtype:"syno_displayfield",cls:"syno-task-scheduler-status-desc",name:"script_out",ref:"../script_out",hidden:!e.enableSaveScriptLog,fieldLabel:_T("schedule","output"),value:_T("schedule","msg_no_data"),width:288,height:this.DESC_HEIGHT},{xtype:"syno_displayfield",hidden:e.enableSaveScriptLog,hideLabel:!0,htmlEncode:!1,style:{padding:"50px 0 0 0"},value:`${_T("common","note")}${_T("common","colon")} ${_T("schedule","set_script_output_dir")}`}]})],buttons:[{xtype:"syno_button",btnStyle:"blue",text:_T("common","ok"),scope:this,handler:this.hClickOK}]};return Ext.apply(t,e),t},hClickOK:function(){this.close()},hSelect:function(e,t,i){this.resultIndex=i,this.refreshFormData()},onOpen:function(){this.loadTask(this.task_id),this.callParent([arguments])},loadTask:function(e){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.TaskScheduler",method:"view",version:1,params:{id:e},scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),e&&Ext.isArray(t)){this.resultData=t;for(var s=[],n=0;nthis.DESC_HEIGHT;)s=s.substr(0,s.length-1),t.innerHTML=s+' ... '+_T("schedule","view_details")+"";let n=e.el.first("a");n&&this.mon(n,"click",function(t){t.preventDefault(),new SYNO.SDS.AdminCenter.TaskScheduler.ViewDetail({owner:this,textValue:i,title:e.fieldLabel}).open()},this)},refreshFormData:function(){var e=this.resultData[this.resultIndex];this.form.getForm().setValues(e),this.trimScript(this.script_in),this.trimScript(this.script_out);var t=this.form.getForm().findField("exit_status");switch(e.exit_type){case"normal":t.setValue(_T("schedule","normal")+" ("+e.exit_code+")");break;case"error":t.setValue(_T("schedule","status_error"));break;case"stop":t.setValue(_T("schedule","status_stop"));break;case"by_signal":t.setValue(_T("schedule","by_signal")+" ("+e.exit_code+")");break;case"running":t.setValue(_T("schedule","status_running"));break;default:t.setValue(_T("schedule","status_unknown"))}}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.SettingDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={title:_T("schedule","setting"),width:561,height:240,resizable:!1,items:[this.form=new SYNO.ux.FormPanel({height:200,padding:"0 0 0 0",items:[{xtype:"syno_checkbox",name:"path_enable",boxLabel:_T("schedule","enable_output_record"),value:!1,listeners:{scope:this,check:this.hCheck}},{xtype:"syno_compositefield",fieldLabel:_T("schedule","output_path"),name:"path_field",hideLabel:!1,indent:1,items:[{xtype:"syno_textfield",name:"path",width:150,readOnly:!0,allowBlank:!1,disabled:!0},this.chooseBtn=new SYNO.ux.Button({text:_T("schedule","select_folder"),handler:this.hChoose,disabled:!0,scope:this})]},{xtype:"syno_displayfield",htmlEncode:!1,value:String.format('{0}: {1}',_T("common","note"),_T("schedule","msg_output_recording"))}]})],buttons:[{xtype:"syno_button",btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.close},{xtype:"syno_button",btnStyle:"blue",text:_T("common","ok"),scope:this,handler:this.hClickOK}]};return Ext.apply(t,e),t},hClickOK:function(){if(this.form.getForm().isValid()){var e=this.form.getForm().findField("path").getValue(),t=this.form.getForm().findField("path_enable").getValue();this.sendWebAPI({api:"SYNO.Core.EventScheduler",method:"config_set",version:1,params:{type:this.type,output_path:e,enable_output:t},scope:this,callback:function(t,i,s){this.clearStatusBusy(),t?Ext.isEmpty(this.output_path)||this.output_path==e?this.close():this.getMsgBox().alert(_T("schedule","task_scheduler"),_T("schedule","msg_output_path_changed"),this.close,this):this.getMsgBox().alert(_T("schedule","task_scheduler"),_T("common","commfail"),null,this)}})}else this.setStatusError({text:_T("common","forminvalid"),clear:!0})},hChoose:function(){new SYNO.SDS.Utils.FileChooser.Chooser({owner:this,usage:{type:"chooseDir"},superuser:!0,treeFilter:function(e,t){return!t||"/home"!==t.spath&&"/surveillance"!==t.spath&&"/homes"!==t.spath},title:_T("schedule","select_folder"),enumColdStorage:!0,folderToolbar:!0,listeners:{scope:this,choose:this.onChooserSelect}}).show()},onChooserSelect:function(e,t){var i=t.path.substr(1);this.form.getForm().findField("path").setValue(i),e.close()},onOpen:function(){this.loadConfig(),this.callParent([arguments])},loadConfig:function(e){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.EventScheduler",method:"config_get",version:1,params:{type:this.type},scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),e){if(t){var s=this.form.getForm();this.output_path=t.output_path,s.findField("path").setValue(t.output_path),s.findField("path_enable").setValue(t.enable_output),t.enable_output&&Ext.isEmpty(t.output_path)&&s.findField("path").markInvalid()}}else this.getMsgBox().alert(_T("schedule","load_task"),_T("schedule","load_task_error"),this.close,this)}})},hCheck:function(e,t){this.form.getForm().findField("path").setDisabled(!t),this.chooseBtn.setDisabled(!t)}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.EnableDialog",{extend:"SYNO.SDS.ModalWindow",openResolve:Ext.emptyFn,constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t,i=[],s=[];for(t=0;te.map(e=>Ext.util.Format.htmlEncode(e)).join(",
    "),o=n(i),a=n(s);var r={title:_T("schedule","title_dialog_save"),closable:!1,width:420,height:200,layout:"fit",cls:"syno-task-scheduler-enabledialog",items:[{xtype:"syno_formpanel",border:!1,items:[{xtype:"syno_displayfield",value:_T("schedule","msg_save_changes")},{xtype:"syno_displayfield",fieldLabel:_T("schedule","enable_tasks"),cls:"ellipsis-content",htmlEncode:!1,hidden:!o,value:o},{xtype:"syno_displayfield",fieldLabel:_T("schedule","disable_tasks"),cls:"ellipsis-content",htmlEncode:!1,hidden:!a,value:a}]}],buttons:[{xtype:"syno_button",btnStyle:"gray",text:_T("common","cancel"),scope:this,handler:function(){this.openResolve("cancel")}},{xtype:"syno_button",btnStyle:"blue",text:_T("common","save"),scope:this,handler:function(){this.openResolve("save")}}]};return Ext.apply(r,e)},openPromise:function(){var e=this;return e.open(),new Promise(function(t){e.openResolve=t}).finally(function(){e.openResolve=Ext.emptyFn,e.close()})}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.CheckDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.disabledDependencies=[],this.callParent([t])},fillConfig:function(e){var t={title:_T("schedule","title_dialog_check"),closable:!1,width:420,height:300,layout:"fit",items:[{xtype:"syno_formpanel",border:!1,items:[this.message=new SYNO.ux.DisplayField({xtype:"syno_displayfield",htmlEncode:!1})]}],buttons:[{xtype:"syno_button",text:_T("common","discard"),scope:this,handler:this.close},{xtype:"syno_button",btnStyle:"blue",text:_T("schedule","enable_all_dependencies"),scope:this,handler:this.enableAllDependencies}]};return Ext.apply(t,e)},startChecking:function(){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.EventScheduler",method:"list",version:1,params:{sort_by:"task_name",sort_direction:"asc"},callback:function(e,t,i){this.clearStatusBusy(),e?t&&this.checkDependency(t):this.owner.getMsgBox().alert(_T("schedule","task_scheduler"),_T("common","commfail"),this.close,this)},scope:this})},enableAllDependencies:function(){var e=[];Ext.each(this.disabledDependencies,function(t){e.push({api:"SYNO.Core.EventScheduler",method:"set_enable",version:1,params:{task_name:t,enable:!0}})}),this.setStatusBusy(),this.sendWebAPI({scope:this,compound:{params:e},callback:function(e,t,i){this.clearStatusBusy(),e&&!t.has_fail?(this.grid.loadData(),this.close()):this.owner.getMsgBox().alert(_T("schedule","task_scheduler"),_T("common","commfail"),this.close,this)}})},checkDependency:function(e){var t,i=[],s={};for(t=0;t",l=!0;for(o=0;o",this.disabledDependencies=this.disabledDependencies.concat(u))}this.disabledDependencies=Ext.unique(this.disabledDependencies),l?Ext.isFunction(this.setGridStatusOK)&&this.setGridStatusOK():(this.message.setValue(r),this.open())}else this.owner.getMsgBox().alert(_T("schedule","task_scheduler"),_T("common","commfail"),this.close,this)}})}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.DeleteDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t,i,s;for(this.task_names=[],this.related_task_names=[],t=0;t{0}',_T("schedule","msg_delete_related_tasks")),hidden:0===this.related_task_names.length,htmlEncode:!1})]}],fbar:["->",{xtype:"syno_button",btnStyle:"gray",text:_T("common","cancel"),scope:this,handler:this.close},{xtype:"syno_button",btnStyle:"red",text:_T("common","delete"),width:120,scope:this,handler:this.onOK}]};return Ext.apply(o,e)},taskListRender:function(e,t){if(!Ext.isArray(e)||!Ext.isArray(t))return"";var i,s="",n="",o="";e.length>5?(n="count",o=e.length):n=1===e.length?"sing":"pl";var a=String.format("confirm_delete_task_{0}",n);return i=String.format(_T("schedule",a),o),(e.length<=5||t.length>0)&&(s=this.joinTasksString(e)),String.format("{0}
    {1}",i,s)},relatedTaskListRender:function(e){return`${_T("schedule","related_tasks")}:
    ${this.joinTasksString(e)}`},joinTasksString:function(e){return e.map(e=>Ext.util.Format.htmlEncode(e)).join(",
    ")},onOK:function(){var e,t=this.confirmCb.getValue(),i=[],s=[],n=[];if(this.tasks.forEach(e=>{e.is_event?n.push(e.task_name):s.push({id:e.id,real_owner:e.real_owner})}),t)for(e=0;e{const t=Ext.isString(e.create_form)&&0!==e.create_form.length,i=SYNO.SDS.Utils.isInVirtualDSM()&&"beep"===e.app_key;return t&&!i}),i=e=>0===e.app_key.indexOf("event",0),s=e=>({text:e.create_btn_text,scope:this,handler:this.hCreate.createDelegate(this,[e])}),n=t.filter(i).map(s);return[t.filter(e=>!i(e)).map(s),n]},createActions:function(){var e=function(e,t,i,s,n){return new Ext.Action(Ext.apply({text:e,itemId:t,scope:s,handler:i,disabled:!0},n))};return this.actions={create:e(_T("common","create"),"create",void 0,this,{id:this.idCreateBtn=Ext.id(),menu:new SYNO.ux.Menu({items:[{text:_T("schedule","title_time_based"),hideOnClick:!1,menu:{xtype:"syno_menu",items:this.create_items}},{text:_T("schedule","title_event_based"),hideOnClick:!1,menu:{xtype:"syno_menu",items:this.create_event_items}}]}),disabled:!1}),edit:e(_T("common","alt_edit"),"edit",this.hEdit,this),remove:e(_T("common","delete"),"delete",this.hDelete,this),run:e(_T("common","run"),"run",this.hRun,this),view:e(_T("schedule","view"),"view",this.hView,this),setting:e(_T("schedule","setting"),"setting",this.hSetting,this,{disabled:!1})},this.actions},getAction:function(e){return e in this.actions?this.actions[e]:void SYNO.Debug("no this action: "+e)},onKeyContextMenu:function(e,t){this.gridCtxMenu.showAt(t.getXY())},onClickContextMenu:function(e,t,i){var s=e.getSelectionModel();s.isSelected(t)||s.selectRow(t),this.gridCtxMenu.showAt(i.getXY())},onRowDbClick:function(){var e=this.getSelectionModel(),t=e.getCount(),i=e.getSelections();1===t&&i[0].data.can_edit&&this.hEdit()},hSelectionChange:function(){var e,t=this.getSelectionModel(),i=t.getCount(),s=t.getSelections();this.btnRun.setDisabled(!(1===i&&s[0].data.can_run));var n=0;for(e=0;e!e.is_event).map(e=>({id:e.id,real_owner:e.real_owner,enable:e.enable})),i=e.filter(e=>e.is_event).map(e=>({api:"SYNO.Core.EventScheduler",method:"set_enable",version:1,params:{task_name:e.task_name,enable:e.enable}}));return this.has_event_tasks=!Ext.isEmpty(i),i.push({api:"SYNO.Core.TaskScheduler",method:"set_enable",version:2,params:{status:t}}),this.sendWebAPIPromise({compound:{params:i}})},getModifiedTasks:function(){return this.getStore().getModifiedRecords().map(function(e){var t=e.data;return{is_event:0===t.type.indexOf("event"),id:t.id,task_name:t.name,real_owner:t.real_owner,enable:t.enable}})},onSaveConfirm:function(e){var t=this;return this.setStatusBusy({text:_T("common","saving")}),t.applyTaskState(e).finally(function(){t.clearStatusBusy()}).catch(function(){throw void t.owner.getMsgBox().alert(_T("schedule","task_scheduler"),_T("common","commfail"),null,t)}).then(t.loadDataPromise.bind(t)).then(function(){t.has_event_tasks?t.hCheck():t.setStatusOK()})},hSave:function(){if(!this.isRecordModified())return this.setStatusError({text:_T("error","nochange_subject"),clear:!0}),Promise.resolve();if(this.taskStore.getModifiedRecords().some(function(e){return""===e.data.owner}))return this.owner.getMsgBox().alert(_T("schedule","task_scheduler"),_T("schedule","msg_empty_owner_for_enable"),this.close,this),Promise.reject();var e=this.getModifiedTasks(),t=new SYNO.SDS.AdminCenter.TaskScheduler.EnableDialog({owner:this.owner,tasks:e}),i=this;return t.openPromise().then(function(t){return"save"===t?i.onSaveConfirm(e):Promise.reject()})},hCheck:function(){new SYNO.SDS.AdminCenter.TaskScheduler.CheckDialog({owner:this.owner,grid:this,setGridStatusOK:this.setStatusOK.bind(this)}).startChecking()},hDelete:function(){var e,t=this.getSelectionModel().getSelections(),i=[];for(e=0;e"+t.join(", ");256{let t=this.store.getRange().find(t=>t.get("id")==e.get("id")&&t.get("real_owner")==e.get("real_owner"));t&&t.set("enable",e.get("enable"))}),this.modifiedRecords=[]},setStatusOK:function(){this.form.setStatusOK(...arguments)},setStatusError:function(){this.form.setStatusError(...arguments)},setStatusBusy:function(){this.form.setStatusBusy(...arguments)},clearStatusBusy:function(){this.form.clearStatusBusy(...arguments)}}),Ext.namespace("SYNO.SDS.AdminCenter.TaskScheduler"),Ext.define("SYNO.SDS.AdminCenter.TaskScheduler.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(){this.callParent()},getHelpParam:function(){return"AdminCenter/system_taskscheduler.html"},getPanel:function(){return this.panel||(this.panel=new SYNO.SDS.AdminCenter.TaskScheduler.TaskForm({owner:this.appWin,module:this})),this.panel},setActivateParams:function(e){if(e&&!0===e.newRecycleBinPolicy){var t=SYNO.SDS.AdminCenter.TaskScheduler.CreateApps(this.appWin),i=SYNO.SDS.AdminCenter.TaskScheduler.getAppInfo("recycle",t),s={};e.share&&(s.share=e.share),this.panel.gridPanel.popEditDialog(-1,i,s)}},activate:function(e){this.setActivateParams(e)},deactivate:function(){return 0===this.panel.gridPanel.taskStore.getModifiedRecords().length},confirmLostChangeSave:function(){return this.getPanel().applyHandlerPromise()}}),Ext.ns("SYNO.SDS.AdminCenter.CMS"),Ext.define("SYNO.SDS.AdminCenter.CMS.Main",{extend:"SYNO.SDS.AdminCenter.Module",constructor:function(e){this.appWin=e.appWin,this.callParent(arguments),this.panel=new SYNO.SDS.AdminCenter.CMS.FormPanel({module:this})},getPanel:function(){return this.panel},activate:function(){this.panel.loadForm(),this.panel.getInfo()}}),Ext.define("SYNO.SDS.AdminCenter.CMS.FormPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){var t,i=[],s=[];this.module=e.module,this.delegateStore=new Ext.data.JsonStore({fields:["userNameCache","is_user","description"],autoLoad:!1}),this.delegateGrid=new SYNO.ux.GridPanel({enableHdMenu:!1,padding:"0px",store:this.delegateStore,columns:[{header:_T("cms","title_delegate_name"),dataIndex:"userNameCache",width:.22,renderer:function(e,t,i){return t.css=i.data.is_user?"acl-combo-item-user acl-icon-combo-icon":"acl-combo-item-group acl-icon-combo-icon",t.style="padding-left: 18px",e}},{header:_T("cms","title_delegate_type"),dataIndex:"is_user",width:.2,renderer:function(e){return e?"User":"Group"}},{header:_T("cms","description"),dataIndex:"description",width:.58,renderer:function(e){return e&&e.length?e:"-"}}]}),i.push({xtype:"syno_displayfield",itemId:"cms_server",fieldLabel:_T("cms","joined")}),s.push({xtype:"syno_displayfield",hideLabel:!0,value:_T("notification","cms_enable_desc")}),s.push({xtype:"syno_checkbox",name:"cms_enable",boxLabel:_T("notification","cms_enable")}),s.push({disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",xtype:"syno_button",text:_T("notification","cms_send_test"),synotype:"indent_no_label",id:this.CMSTestBtnId=Ext.id(),scope:this,handler:this.onClickTestMailBtn}),i.push({xtype:"syno_displayfield",itemId:"cms_desc",value:_T("cms","disjoint_desc")}),i.push({xtype:"syno_button",itemId:"cms_leave_btn",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",text:_T("cms","leave_cms"),handler:function(e,t){this.setStatusBusy({mask:!0}),this.sendWebAPI({api:"SYNO.Core.CMS",version:2,method:"disjoin",params:{from:"SYNO.SDS.AdminCenter.Application"},callback:this.onDeleteServer,button:e,scope:this})},scope:this}),t={padding:"0px",module:e.module,border:!1,frame:!1,autoScroll:!0,header:!1,useDefaultBtn:!0,webapi:{api:"SYNO.Core.Notification.CMS.Conf",methods:{get:"get",set:"set"},version:1},items:[{xtype:"syno_fieldset",title:_T("cms","joined"),collapsible:!1,items:i},{xtype:"syno_fieldset",title:_T("notification","cms_enable"),collapsible:!1,items:s},{xtype:"syno_fieldset",cls:"syno-admincenter-cms-delegatefieldset",title:_T("cms","title_tab_delegate"),collapsible:!1,items:[this.delegateGrid]}]},this.callParent([t])},getInfo:function(){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.CMS.Info",version:1,method:"get",params:{additional:["server","delegate"]},callback:function(e,t){var i,s=null;this.clearStatusBusy(),this.body.unmask(),e?(s=this.getCMSDescComponent(),Ext.isEmpty(s)||Ext.isEmpty(t.additional)||Ext.isEmpty(t.additional.server)?this.body.mask(_T("common","error_system"),"syno-ux-mask-info"):(Ext.isEmpty(t.additional.server.host)?(this.serverHost="",i=_T("cms","disjointed"),this.body.mask(_T("cms","disjointed"),"syno-ux-mask-info")):(this.serverHost=t.additional.server.host||"",i=this.serverHost,i+=" (",Ext.isEmpty(t.additional.server.connect_status)||"fail"!==t.additional.server.connect_status?i+=_T("cms","status_connected"):i+=_T("cms","connect_failed"),i+=")"),s.setValue(i),s.originalValue=i,this.delegateStore.loadData(t.additional.delegate,!1),this.delegateGrid.setHeight(29+29*t.additional.delegate.length+2),this.doLayout())):this.body.mask(_T("common","error_system"),"syno-ux-mask-info")},scope:this})},getCMSDescComponent:function(){return void 0!==this.cmsDescCmp?this.cmsDescCmp:(this.cmsDescCmp=null,this.findBy(function(e){"cms_server"===e.itemId&&(this.cmsDescCmp=e)},this),this.cmsDescCmp)},onDeleteServer:function(e,t,i,s){var n;this.clearStatusBusy(),e?(Ext.isObject(s.button)&&s.button.setDisabled(!0),n=this.getCMSDescComponent(),Ext.isEmpty(n)||(n.setValue(_T("cms","disjointed")),n.originalValue=_T("cms","disjointed"),this.body.mask(_T("cms","disjointed"),"syno-ux-mask-info"))):1010===t.code?this.module.appWin.getMsgBox().alert("",String.format(_T("cms","computing_not_allow_disable"),t.errors.registered_shares)):this.setStatusError()},onClickTestMailBtn:function(){this.module.appWin.delayedMask(.1,100),this.sendWebAPI({api:"SYNO.Core.Notification.CMS",method:"send_test",version:1,scope:this,params:{},callback:function(e,t,i){var s=e?String.format(_T("notification","cms_test_notification_sent"),this.serverHost):_T("common","error_system");this.module.appWin.getMsgBox().alert(_T("notification","cms_send_test"),s),this.module.appWin.unmask()}})}}),Ext.define("SYNO.SDS.AdminCenter.Application",{extend:"SYNO.SDS.AppInstance",appWindowName:"SYNO.SDS.AdminCenter.MainWindow"}),Ext.define("SYNO.SDS.AdminCenter.MainWindow",{extend:"SYNO.SDS.PageListAppWindow",DEFAULT_WIN_SIZE:{width:1150,height:652},constructor:function(e){this.badges={},this.appInstance=e.appInstance,this.categoryVisibleStatus={},this.callParent([this.fillConfig(e)]),this.mon(SYNO.SDS.StatusNotifier,"badgenumget",this.badgeNumGetHandler,this),this.mon(this.getComponent("page_list"),"activate",function(){this.pageList.getAriaEl().focus()},this)},initEvents:function(){this.callParent(arguments);var e=function(){this.sendWebAPI({api:"SYNO.Backup.Config.AutoBackup",method:"backup",params:{instant:!1},version:1})}.bind(this);_S("is_admin")&&(this.mon(this,"close",e),this.mon(this,"close",function(){Ext.EventManager.un(window,"beforeunload",e)}),Ext.EventManager.on(window,"beforeunload",e),this.mon(SYNO.SDS.StatusNotifier,"halt",function(){Ext.EventManager.un(window,"beforeunload",e)})),this.mon(SYNO.SDS.StatusNotifier,"thirdpartychanged",()=>{setTimeout(()=>{SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Finder.Application")?(this.searchField.hide(),this.susSearchField.show()):(this.searchField.show(),this.susSearchField.hide())},1e3)})},onGetPageList:function(e){e.loaded=!0,!0===this.getPageList().getLoader().loaded&&this.callParent(arguments)},fillConfig:function(e){var t=this.DEFAULT_WIN_SIZE,i={cls:"syno-app-admin-center",width:t.width,height:t.height,minWidth:1020,minHeight:440,layout:"card",hideMode:"offsets",activeItem:"home_screen",defaultMaximized:!0,items:[{xtype:"container",itemId:"page_list",layout:"border",hideMode:"offsets",items:[this.getPageList(e),this.getPageCt()]},this.getHomeScreen()],listeners:{beforeshow:{fn:function(){this.isCmsRelay=this.IsAllowRelay()},scope:this,single:!0}}};return Ext.apply(i,e),i},getPageListConfig:function(e){var t=SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Finder.Application");this.susSearchField=new SYNO.SDS.AdminCenter.SUSSearchField({width:164,hidden:!t}),this.searchField=new SYNO.SDS.AdminCenter.SearchField({width:164,hidden:t});var i={id:"syno-app-admin-pagelist-menu",region:"west",xtype:"container",layout:"fit",itemId:"page_list_container",disableCaching:!!Ext.isDefined(SYNO.SDS.JSDebug),badges:{},"aria-label":_T("tree","leaf_control_panel"),dataUrl:String.format("{0}/modules/{1}",this.jsConfig.jsBaseURL,e.moduleFile),loadParam:{v:_S("version")},tbar:{cls:"page-list-tbar",items:[{xtype:"syno_button",tooltip:_T("common","webman_home"),cls:"syno-sds-ac-home",iconCls:"syno-sds-ac-home-icon",width:40,scope:this,handler:this.homeButtonHandler.createDelegate(this)},this.susSearchField,this.searchField]},listeners:{scope:this,single:!0,load:{fn:this.onLoad.createDelegate(this),buffer:50}}};return e.dataUrl?i.dataUrl=e.dataUrl:e.listItems&&(i.listItems=e.listItems),i},getPageList:function(e){if(!this.pageList){var t;t=this.getPageListConfig(Ext.apply({moduleFile:"modules.json"},e)),this.pageList=new SYNO.ux.ModuleList(t)}return this.pageList},getHomeScreen:function(){return this.homeScreen?this.homeScreen:(this.homeScreen=new SYNO.SDS.AdminCenter.HomeScreenPanel({itemId:"home_screen",owner:this}),this.homeScreen)},createPage:function(e){var t,i;return(t=new(Ext.getClassByName(e))({appWin:this,jsConfig:this.jsConfig}))instanceof SYNO.SDS.AdminCenter.Module?(t.appWin=this,i=t.getPanel(),this.wrapModule(i)):i=t,i.itemId=e,i},wrapModule:function(e){e.onPageActivate=e.module.activate.createDelegate(e.module),e.onPageDeactivate=e.module.deactivate.createDelegate(e.module),e.onPageConfirm=e.module.confirmCallback.createDelegate(e.module),e.onPageFocus=e.module.focus.createDelegate(e.module),e.getHelpParam=e.module.getHelpParam.createDelegate(e.module),e.onPageConfirmLostChangeSave=e.module.confirmLostChangeSave.createDelegate(e.module),e.onPageConfirmLostChangeDontSave=e.module.confirmLostChangeDontSave.createDelegate(e.module),e.onPageConfirmLostChangeCancel=e.module.confirmLostChangeCancel.createDelegate(e.module),e.hasLeaveLostChangeDialog=e.module.hasLeaveLostChangeDialog},onLoad:function(e){this.callParent(arguments),this.getHomeScreen().loadModuleData()},getCategoryByClassName:function(e){var t=String.format('div[fn="{0}"]',e),i=this.el.select(t).elements;return 0>=i.length?"":i[0].getAttribute("cate")},setModuleVisible:function(e,t){var i=t;SYNO.SDS.ActionPrivilege&&SYNO.SDS.ActionPrivilege.isUserHasPrivilege(e)||(i=!1),this.getPageList().setModuleVisible(e,i),this.getHomeScreen().setModuleVisible(e,i);var s=this.getCategoryByClassName(e);s&&(void 0===this.categoryVisibleStatus[s]||!this.categoryVisibleStatus[s]&&i)&&(this.categoryVisibleStatus[s]=i,this.getHomeScreen().setCategoryVisible(s,i),this.getPageList().setCategoryVisible(s,i))},isMatchRules:function(e){var t,i,s=this,n=!1;return!!Ext.isArray(e)&&(Ext.each(e,function(e){if(t=e.fn,Ext.isString(t)?(i=this._S(e.key),"greater"===t?n=i>e.value:"less"===t?n=i0&&((o=this.createBadge(s)).setNum(n),a.badges[e]=o))},createBadge:function(e){var t=new SYNO.SDS.Utils.Notify.Badge({renderTo:e,hideNum:!0,badgeClassName:"sds-notify-badge-num"});return this.addManagedComponent(t),t},getBadgeNumByFn:function(e){return SYNO.SDS.PollingTask.BadgeInfo.getInfoOfFn("SYNO.SDS.AdminCenter.Application",e)},getItemElByFn:function(e,t){var i;return!!(i=(t||this.getPageList()).getNodeById(e))&&Ext.get(i.getUI().getEl()).child("div.x-tree-node-leaf")}}),Ext.define("SYNO.SDS.AdminCenter.Network.OobAutoBlock.Window",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){this.denyListTab=new SYNO.SDS.AdminCenter.Network.OOBAutoBlock.RuleList({ruleWin:this,columns:[{header:_T("oob","oob_autoblock_ip"),dataIndex:"ip",width:160,sortable:!1,menuDisabled:!0},{header:_T("oob","oob_autoblock_time"),dataIndex:"record_date",width:200,sortable:!1,menuDisabled:!0}]});var t={ruleWin:this,title:_T("oob","oob_block_list_title"),width:500,height:440,items:this.denyListTab,layout:"fit",buttons:[{btnStyle:"grey",text:_T("common","close"),scope:this,handler:function(){this.close()}}]};return Ext.apply(t,e),t}}),Ext.define("SYNO.SDS.AdminCenter.Network.OOBAutoBlock.RuleList",{extend:"SYNO.ux.GridPanel",constructor:function(e){var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){this.ruleWin=e.ruleWin,this.store=new SYNO.API.JsonStore({api:"SYNO.Core.Hardware.OOBManagement",method:"list_blocked_ipv4",version:1,baseParams:{offset:0,limit:512},root:"ip_info",totalProperty:"total",fields:["ip",{name:"record_date",convert:function(e,t){var i=new Date(1e3*t.record_date);return SYNO.SDS.DateTimeFormatter(i,{type:"datetimesec"})}}],appWindow:e.ruleWin,scope:this,autoLoad:!0,remoteSort:!0,listeners:{load:{scope:this,fn:this.onStoreLoad},exception:{scope:this,fn:this.onStoreException}}}),this.ipFilter=new SYNO.ux.TextFilter({iconStyle:"filter",emptyText:_T("common","filter_label_text"),localFilter:!0,localFilterField:"ip",tabIndex:-1,store:this.store}),this.delBtn=new SYNO.ux.Button({text:_T("oob","oob_autoblock_clear_btn"),scope:this,handler:this.onClickClearBlockIp});var t={ds:this.store,loadMask:!0,height:300,enableHdMenu:!1,tbar:{items:[this.delBtn,"->",this.ipFilter]},bbar:{xtype:"syno_paging",pageSize:512,displayInfo:!0,store:this.store,showRefreshBtn:!0}};return Ext.apply(t,e),t},onStoreLoad:function(){0===this.store.getTotalCount()?this.delBtn.disable():this.delBtn.enable()},onStoreException:function(e,t,i,s,n,o){SYNO.Debug("Store exception: options:",e,t,i,s,n,o),this.ruleWin.clearStatusBusy()},onClickClearBlockIp:function(e,t){this.showMsgBox(_T("oob","oob_block_clear_notice"),_T("oob","oob_confirm_clear_all"),"red",function(e){"yes"===e&&SYNO.SDS.Utils.PasswordConfirmDialog.openDialog(this.ruleWin,this.confirmedClearBlockIpClbk)})},confirmedClearBlockIpClbk:function(){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.Hardware.OOBManagement",method:"exec",version:1,params:{oob_ifname:this.ifname,command:"oob.blocklist.clear"},scope:this,callback:function(e,t,i){this.denyListTab.store.reload(),this.clearStatusBusy()}})},showMsgBox:function(e,t,i,s){this.gMsgBox&&!this.gMsgBox.isDestroyed||(this.gMsgBox=new SYNO.SDS.MessageBoxV5({owner:this.ruleWin,draggable:!1})),this.gMsgBox.confirmDelete(_T("oob","oob_warning_title"),e,s,this,{yes:{text:t,btnStyle:i},no:{text:_T("oob","oob_cancel")}})}}),Ext.define("SYNO.SDS.AdminCenter.Network.TcSrcIpDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.panel=this.createPanel(),this.form=this.panel.getForm();var t={width:680,height:380,title:_T("firewall","firewall_source"),layout:"fit",items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","alt_cancel"),scope:this,handler:this.close},{btnStyle:"blue",text:_T("common","alt_apply"),itemId:"ruleApply",scope:this,handler:this.onApply}]};this.setDefault(),Ext.apply(t,e),this.callParent([t]),this.OnSourceRadioClick(this.form.findField("source"),!0)},createPanel:function(){var e={xtype:"syno_fieldset",title:_T("firewall","firewall_source"),itemId:"firewall_source",items:[{xtype:"syno_displayfield"},{xtype:"syno_compositefield",hideLabel:!0,defaults:{flex:1},items:[{xtype:"syno_radio",name:"source",itemId:"nfs_fieldtitle_host",boxLabel:_T("nfs","nfs_fieldtitle_host"),inputValue:"single",scope:this,checked:!0,handler:this.OnSourceRadioClick},{xtype:"syno_radio",name:"source",itemId:"firewall_source_network",boxLabel:_T("firewall","firewall_source_network"),inputValue:"subnet",scope:this,handler:this.OnSourceRadioClick}]},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("tcpip","tcpip_ipaddr"),name:"source_ip",itemId:"tcpip_ipaddr",vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)&&(this.nextSibling().validate(),!0)}},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("tcpip","tcpip_mask")+"/"+_T("tcpip","ipv6_prefixleng"),name:"source_subnet_mask",itemId:"tcpip_mask",maskRe:/[.0-9]/,invalidText:_JSLIBSTR("vtype","bad_mask"),allowBlank:!1,validator:function(e){var t=this.previousSibling().getValue();return Ext.form.VTypes.fwLoosev6ipVal.test(t)?e>=0&&e<=128||_JSLIBSTR("vtype","bad_ipv6prefixLeng"):!!Ext.form.VTypes.netmaskVal.test(e)}},{xtype:"syno_displayfield"},{xtype:"syno_radio",boxLabel:_T("firewall","firewall_ip_range"),name:"source",width:2*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_LABEL_WIDTH,itemId:"firewall_source_range",inputValue:"range",scope:this,handler:this.OnSourceRadioClick},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("ftp","ftp_port_from"),name:"source_ip_begin",itemId:"tcpip_ipaddr_begin",vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)}},{xtype:"syno_textfield",width:SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,labelWidth:1.7*SYNO.SDS.AdminCenter.Security.Utils.FW_DEFAULT_INPUT_WIDTH,fieldLabel:_T("ftp","ftp_port_to"),name:"source_ip_end",itemId:"tcpip_ipaddr_end",vtype:"fwLooseip",validator:function(e){return!!Ext.form.VTypes.fwLooseip(e)}}]};return new SYNO.ux.FormPanel(e)},onApply:function(){this.validateBlank(this.form)?this.form.isValid()?(this.setSource(this.getSrc()),this.owner.setSrc(this.getSrc()),this.close()):this.setStatusError({text:_T("common","forminvalid"),clear:!0}):"range"===this.form.findField("source").getGroupValue()?this.getMsgBox().alert(_T("tree","leaf_firewall"),_T("firewall","firewall_error_ip_range")):this.getMsgBox().alert(_T("tree","leaf_firewall"),_T("common","forminvalid"))},getSrc:function(){var e,t=this.form.findField("source").getGroupValue();if("single"===t)e=this.form.findField("source_ip").getValue();else if("range"===t){e=this.form.findField("source_ip_begin").getValue()+"-"+this.form.findField("source_ip_end").getValue()}else"subnet"===t&&(e=String.format("{0}/{1}",this.form.findField("source_ip").getValue(),this.form.findField("source_subnet_mask").getValue()));return e},onOpen:function(e){this.setStatusBusy(),e&&""!==e?this.setSource(e):this.form.findField("source").setValue("single"),this.clearStatusBusy(),this.callParent(arguments)},setDefault:function(){this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable()},setSource:function(e){var t="",i="",s="",n="",o="";if(0<=e.indexOf("GEOIP:")||0<=e.indexOf("all"))s="single";else if(00){var a=e.split("/");t=a[0],i=a[1],s="subnet",this.form.findField("source_ip").setValue(t),this.form.findField("source_subnet_mask").setValue(i)}else this.form.findField("source_ip").setValue(e),s="single";this.form.findField("source").setValue(s)},OnSourceRadioClick:function(e,t){if(e.checked)switch(e.value){case"single":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable();break;case"subnet":this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").enable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable();break;case"range":this.form.findField("source_ip").disable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").enable(),this.form.findField("source_ip_end").enable();break;default:this.form.findField("source_ip").enable(),this.form.findField("source_subnet_mask").disable(),this.form.findField("source_ip_begin").disable(),this.form.findField("source_ip_end").disable()}},validateBlank:function(e){var t,i,s,n,o,a=!0,r=0,l=0,d="",c=e.findField("source").getGroupValue();if("single"==c)a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip"]);else if("subnet"==c)(a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip"]))&&(a=SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_subnet_mask"]));else if(SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip_begin"])&&SYNO.SDS.AdminCenter.Utils.Validator.MarkBlankField(e,["source_ip_end"]))if(i=e.findField("source_ip_begin").getValue().toString(),s=e.findField("source_ip_end").getValue().toString(),0parseInt(n[r],10)){a=!0;break}if(parseInt(o[r],10)parseInt(n[r],16)){a=!0;break}if(parseInt(o[r],16)",n=String.format(_T("ovs","ovs_linkaggr_note"),s);return i.push({xtype:"syno_displayfield",value:''+_T("common","note")+_T("common","colon")+" "+n,name:"linkaggr_note",htmlEncode:!1}),SYNO.LayoutConfig.fill(i),i},Ext.define("SYNO.SDS.AdminCenter.Network.SetupOOBAccountDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.passwordChecker=e.passwordChecker,this.panel=this.configForm(e);var t=Ext.apply({width:450,height:300,layout:"fit",border:!1,items:[this.panel],buttons:[{btnStyle:"grey",text:_T("oob","oob_cancel"),scope:this,handler:this.onDiscard},{btnStyle:"blue",text:_T("oob","oob_save"),scope:this,handler:this.onApply}]},e);this.callParent([t]),this.panel.mon(this.panel.getForm().findField("oob_username"),"blur",function(){this.isValid()&&this.clearInvalid()},this.panel.getForm().findField("oob_password")),this.panel.mon(this.panel.getForm().findField("oob_password"),"blur",function(){this.isValid()&&this.clearInvalid()},this.panel.getForm().findField("oob_confirmpassword"))},onApply:function(){var e=this.getFormUsername(),t=this.getFormPassword();!0===this.panel.getForm().isValid()&&(this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.Hardware.OOBManagement",method:"update",version:1,params:{oob_username:e,oob_password:t,oob_ifname:this.hostConfig.oob_ifname},encryption:["oob_password","oob_username","ifname"],scope:this,callback:this.applyDone}))},applyDone:function(e,t,i){var s=this.getFormUsername();!0===e?(this.hostConfig.oob_username=s,this.ownerPanel.getForm().findField("oob_username").setValue(s),Ext.getCmp(this.ownerPanel.btnUsernameEdit).show()):this.ownerPanel.getForm().findField("oob_shell_enable").setValue(!1),this.ownerPanel.doLayout(),this.clearStatusBusy(),this.close()},onDiscard:function(){this.close()},onClose:function(){""===this.hostConfig.oob_username&&this.ownerPanel.getForm().findField("oob_shell_enable").setValue(this.hostConfig.oob_shell_enable),this.ownerPanel.doLayout()},onOpen:function(){!0!==this.hostConfig.oob_shell_enable&&""==this.hostConfig.oob_username||this.panel.getForm().setValues({oob_username:this.hostConfig.oob_username,oob_password:"",oob_confirmpassword:""}),this.panel.getForm().findField("oob_password").startValidate=!0,this.callParent(arguments)},configForm:function(e){var t=new SYNO.ux.FormPanel({items:[{xtype:"syno_displayfield",value:_T("oob","oob_setup_account_desc")},{xtype:"syno_displayfield",name:"description",hidden:!0,value:""},{xtype:"syno_textfield",fieldLabel:_T("oob","oob_setup_username")+' '+_T("common","star")+"","aria-label":_T("oob","oob_setup_username"),name:"oob_username",disabled:!1,allowBlank:!1,blankText:_T("oob","oob_error_noname"),validateOnBlur:!0,validationDelay:250,validationEvent:"keyup",maxLength:30,width:200,labelHtmlEncode:!1,vtype:"username"},{xtype:"syno_compositefield",fieldLabel:_T("oob","oob_setup_password")+' '+_T("common","star")+"",width:500,cls:"password-composite-field",labelHtmlEncode:!1,items:[{xtype:"syno_passwordfield","aria-label":_T("oob","oob_setup_password"),maxLength:64,width:200,name:"oob_password",updateWhenRender:!1,startValidate:!1,validator:this.passwordChecker?this.passwordChecker.isStrongValidator.createDelegate(this.passwordChecker):Ext.emptyFn,listeners:{afterrender:function(){this.hidePasswordStrength()},password_strength_get:function(){this.showPasswordStrength()}}}]},{xtype:"syno_textfield",textType:"password_confirm",fieldLabel:_T("oob","oob_setup_confirmpassword")+' '+_T("common","star")+"","aria-label":_T("oob","oob_setup_confirmpassword"),maxLength:127,name:"oob_confirmpassword",width:200,labelHtmlEncode:!1,confirmFor:"oob_password",validator:function(e){return e===this.ownerCt.getForm().findField(this.confirmFor).getValue()||_T("oob","oob_error_repeat_password")}}]});return this.passwordChecker&&this.passwordChecker.initPasswordChecker({getForm:function(){return t.getForm()},getUserAcc:"oob_username",getUserDesc:"description",getPasswd:"oob_password",getPasswdConfirm:"oob_confirmpassword",getStartValidate:function(){return this.getForm().findField("oob_password").startValidate}}),t},getFormUsername:function(){return this.panel.getForm().findField("oob_username").getValue()},getFormPassword:function(){return this.panel.getForm().findField("oob_password").getValue()}}),Ext.define("SYNO.SDS.AdminCenter.Network.OvsSettingDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){return Ext.apply({title:_T("ovs","ovs_setting"),width:500,height:"yes"===_D("support_oob_ctl")?230:200,layout:"fit",resizable:!1,buttons:[{xtype:"syno_button",text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",text:_T("common","alt_apply"),btnStyle:"blue",scope:this,handler:this.onApply}],items:[this.createOvsSetting()]},e)},createOvsSetting:function(){return{xtype:"syno_formpanel",border:!1,itemId:"ovssetting_form",padding:"0px",items:[{xtype:"syno_checkbox",boxLabel:_T("network","enable_ovs"),name:"enable_ovs"},{xtype:"syno_displayfield",indent:1,value:_T("network","enable_ovs_desc")},{xtype:"syno_displayfield",indent:1,htmlEncode:!1,hidden:"yes"!==_D("support_oob_ctl"),value:''+_T("common","note")+_T("common","colon")+" "+_T("oob","oob_ovs_not_support_note")},{xtype:"syno_displayfield",itemId:"feasibility_field",indent:1,htmlEncode:!1,hidden:!0}]}},onActivate:function(){this.callParent(arguments);var e=[];e.push({api:"SYNO.Core.Network.OVS",method:"get",version:1}),e.push({api:"SYNO.Core.Network.OVS",method:"check",version:1}),this.sendWebAPI({compound:{stopwhenerror:!1,params:e},callback:function(e,t,i,s){Ext.each(t.result,function(e,t,i){if("SYNO.Core.Network.OVS"===e.api&&"get"===e.method){var s=this.getComponent("ovssetting_form").getForm().findField("enable_ovs");s.setValue(e.data.enable_ovs),s.originalValue=e.data.enable_ovs}else if("SYNO.Core.Network.OVS"===e.api&&"check"===e.method&&e.error&&4319===e.error.code&&e.error.errors.hard){var n=this.getComponent("ovssetting_form").getForm(),o="",a=0;for(a=0;a"),o+=SYNO.SDS.Utils.GetFeasibilityCheckMsg(e.error.errors.hard[a]);n.findField("enable_ovs").disable(),SYNO.ux.AddTip(n.findField("enable_ovs"),o),this.doLayout()}},this)},scope:this})},onApply:function(){var e=this.getComponent("ovssetting_form").getForm().findField("enable_ovs");e.isDirty()?this.sendWebAPI({api:"SYNO.Core.Network.Bond",method:"list",version:1,callback:function(t,i){var s=e.getValue();!0!==t||Ext.isEmpty(i)?!0!==_S("ha_handle_set_ovs")?(this.sendWebAPI({api:"SYNO.Core.Network.OVS",method:"set",version:1,params:{enable:!!s},scope:this}),SYNO.SDS.AdminCenter.Network.Utils.Redirect.apply(this,[!1,!1,[""],"","",null,15e3])):SYNO.SDS.HA.SetOVS(this,!0,{enable:!!s}):SYNO.SDS.AdminCenter.Network.OvsSetting.onChangeBondMode.apply(this,[s,i])},scope:this}):this.close()},onCancel:function(){this.close()}}),Ext.ns("SYNO.SDS.AdminCenter.Network.OvsSetting"),SYNO.SDS.AdminCenter.Network.OvsSetting.onChangeBondMode=function(e,t){this.module.stopPolling();var i=new SYNO.SDS.AdminCenter.Network.OvsSetting.BondChangeWizard({owner:this,module:this.module,enable_ovs:e,resp:t});i.addListener("destroy",function(){this.module.startPolling()},this),i.open()},Ext.define("SYNO.SDS.AdminCenter.Network.AuthTab",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.owner=e.owner,this.module=e.module,this.parentPanel=e.parentPanel,this.callParent([this.fillConfig(e)]),this.getCmpsAsMembers(),this.user_cert_update_time="",this.key_update_time="",this.ca_cert_update_time=""},fillConfig:function(e){var t={title:_T("network","auth_8021x"),trackResetOnLoad:!0,xtype:"syno_fieldset",height:450,items:[{xtype:"syno_checkbox",boxLabel:_T("network","auth_enable"),name:"enable",indent:0,disabled:!1,checked:!1},{xtype:"syno_compositefield",name:"eap_composite",indent:1,items:[{xtype:"syno_combobox",fieldLabel:_T("network","auth_eap"),name:"eap",editable:!1,width:150,allowBlank:!1,valueField:"value",displayField:"display",store:new Ext.data.SimpleStore({fields:["value","display"],data:[["auto","Auto"],["peap","PEAP"],["ttls","TTLS"],["tls","TLS"]]}),listeners:{scope:this,disable:this.disableGroup,enable:function(e){this.setGroup(e.value)},select:function(e,t,i){this.setGroup(t.data.value)}}},{xtype:"syno_button",text:_T("routerconf","routerconf_test_conn"),id:this.testConBtnId=Ext.id(),autoWidth:!0,handler:this.testBtn,scope:this}]},{xtype:"syno_combobox",fieldLabel:_T("network","auth_phase2"),name:"phase2",indent:1,editable:!1,hidden:!1,width:150,allowBlank:!1,valueField:"value",displayField:"display",value:"mschapv2",store:new Ext.data.SimpleStore({fields:["value","display"],data:[["mschapv2","MS-CHAP v2"],["gtc","GTC"]]})},{xtype:"syno_textfield",fieldLabel:_T("network","user_account"),name:"identity",indent:1,width:150,allowBlank:!1,hidden:!1},{xtype:"syno_displayfield",fieldLabel:_T("network","auth_user_cert"),name:"user_cert",value:"",id:this.field_user_cert=Ext.id(),indent:1,htmlEncode:!1,width:450},{xtype:"syno_displayfield",fieldLabel:_T("network","auth_private_key"),name:"key",value:"",id:this.field_key=Ext.id(),indent:1,htmlEncode:!1,width:450},{xtype:"syno_textfield",textType:"password",fieldLabel:_T("network","user_pass"),name:"password",indent:1,width:150,allowBlank:!1,hidden:!1},{xtype:"syno_textfield",textType:"password",fieldLabel:_T("network","auth_private_key_passwd"),name:"key_password",indent:1,width:150,allowBlank:!1,hidden:!1},{xtype:"syno_displayfield",fieldLabel:_T("network","auth_ca_cert"),name:"ca_cert",value:"",id:this.field_ca_cert=Ext.id(),htmlEncode:!1,indent:1,width:450},{xtype:"syno_textfield",fieldLabel:_T("network","auth_anonymous"),name:"anonymous_identity",indent:1,width:150,allowBlank:!0,hidden:!1},{xtype:"syno_displayfield",fieldLabel:_T("common","status"),htmlEncode:!1,name:"auth_status",indent:1},{xtype:"syno_displayfield",htmlEncode:!1,value:''+_T("common","note")+_T("common","colon")+" "+_T("network","auth_note")}]};return Ext.apply(t,e),t},getCmpsAsMembers:function(){for(var e=["field_ca_cert","field_user_cert","field_key","testConBtnId"],t=0;t'+_T("mail","mail_authentication_success")+"":"authenticating"==e?_T("network","auth_processing"):"unauthenticated"==e?''+_T("service","service_ddns_status_auth_failed")+"":""===e?_T("common","disabled"):_T("service","service_ddns_error_unknown")},isDirty:function(){return this.getForm().isDirty()},isValid:function(){return this.getForm().isValid()},getWebAPISetData:function(){return{api:"SYNO.Core.Network.Authentication",version:1,method:"set",encryption:["password","key_password"],params:this.prepareWebAPISetData()}},getWebAPIGetData:function(){return{api:"SYNO.Core.Network.Authentication",version:1,method:"get",params:{ifname:this.win.ifname}}},prepareWebAPISetData:function(){var e=this.getForm();return{enable:e.findField("enable").getValue(),ifname:this.win.ifname,identity:e.findField("identity").getValue(),anonymous_identity:e.findField("anonymous_identity").getValue(),password:e.findField("password").getValue(),key_password:e.findField("key_password").getValue(),eap:e.findField("eap").getValue(),phase2:e.findField("phase2").getValue()}},getConfig:function(e){var t=SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix("SYNO.Core.Network.Authentication"),i={};return i.enable=e[t+"enable"],i.identity=e[t+"identity"],i.anonymous_identity=e[t+"anonymous_identity"],i.password=e[t+"password"],i.key_password=e[t+"key_password"],i.eap=e[t+"eap"],i.phase2=e[t+"phase2"],i.auth_status=this.transferStatus(e[t+"status"]),this.updateField(this.field_ca_cert,"ca_cert",e[t+"ca_cert_update_time"]),this.updateField(this.field_user_cert,"user_cert",e[t+"user_cert_update_time"]),this.updateField(this.field_key,"key",e[t+"key_update_time"]),i},disableGroup:function(){for(var e=["phase2","identity","password","user_cert","key","key_password","ca_cert","anonymous_identity"],t=0;t0?(this[s]=i,e.setValue(_T("network","auth_import_notify").replace("{0}",i)+' ('+_T("common","remove")+")")):(this[s]="",e.setValue(''+_T("network","auth_import_file")+"")),Ext.get(n).addListener("click",function(){this.onClickUploadOrDelete(t)},this),Ext.get(n).addKeyListener(Ext.EventObject.ENTER,function(){this.onClickUploadOrDelete(t)},this),e.originalValue=e.getValue()},onClickUploadOrDelete:function(e){var t;("ca_cert"===e?t=this.ca_cert_update_time:"user_cert"===e?t=this.user_cert_update_time:"key"===e&&(t=this.key_update_time),void 0!==t&&t.length>0)?(this.parentPanel.win.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.Network.Authentication.Cert",version:1,method:"delete",params:{ifname:this.win.ifname,upload_type:e},scope:this,callback:function(t,i,s){this.parentPanel.win.clearStatusBusy(),t?"ca_cert"===e?this.updateField(this.field_ca_cert,e):"user_cert"===e?this.updateField(this.field_user_cert,e):"key"===e&&this.updateField(this.field_key,e):this.parentPanel.win.setStatusError({text:SYNO.API.getErrorString(i.code),clear:!0})}})):new SYNO.SDS.AdminCenter.Network.AuthTab.UploadWin({owner:this.findWindow(),ifname:this.win.ifname,parentPanel:this,uploadType:e}).open()}}),Ext.define("SYNO.SDS.AdminCenter.Network.AuthTab.UploadWin",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.ifname=e.ifname,this.parentPanel=e.parentPanel,this.uploadType=e.uploadType,this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.uploadForm=new SYNO.SDS.AdminCenter.Network.AuthTab.UploadForm({owner:this,ifname:this.ifname,uploadType:this.uploadType});var t={title:_T("network","auth_import_file"),resizable:!1,width:550,height:160,buttons:[{xtype:"syno_button",text:_T("common","apply"),btnStyle:"blue",scope:this,handler:this.uploadCert},{xtype:"syno_button",text:_T("common","cancel"),scope:this,handler:this.onCancel}],items:[this.uploadForm]};return Ext.apply(t,e),t},uploadCert:function(){this.uploadForm.uploadCert()},onCancel:function(){this.close()},updateTime:function(){this.sendWebAPI({api:"SYNO.Core.Network.Authentication",version:1,method:"get",params:{ifname:this.ifname},scope:this,callback:function(e,t,i){"ca_cert"===this.uploadType?this.parentPanel.updateField(this.parentPanel.field_ca_cert,this.uploadType,t[this.uploadType+"_update_time"]):"user_cert"===this.uploadType?this.parentPanel.updateField(this.parentPanel.field_user_cert,this.uploadType,t[this.uploadType+"_update_time"]):"key"===this.uploadType&&this.parentPanel.updateField(this.parentPanel.field_key,this.uploadType,t[this.uploadType+"_update_time"])}})}}),Ext.define("SYNO.SDS.AdminCenter.Network.AuthTab.UploadForm",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.owner=e.owner,this.ifname=e.ifname,this.uploadType=e.uploadType,this.callParent([this.fillConfig(e)]),this.setGroup(this.uploadType)},fillConfig:function(e){var t={fileUpload:!0,trackResetOnLoad:!0,frame:!1,border:!1,items:[{xtype:"syno_textfield",hidden:!0,name:"ifname",value:this.ifname},{xtype:"syno_textfield",hidden:!0,name:"upload_type",value:this.uploadType},{xtype:"syno_filebutton",fieldLabel:_T("network","auth_ca_cert"),name:"ca_cert"},{xtype:"syno_filebutton",fieldLabel:_T("network","auth_user_cert"),name:"user_cert"},{xtype:"syno_filebutton",fieldLabel:_T("network","auth_private_key"),name:"key"},{xtype:"syno_filebutton",fieldLabel:_T("network","auth_pac"),name:"pac"}],webapi:{api:"SYNO.Core.Network.Authentication.Cert",method:"upload",version:1}};return Ext.apply(t,e),t},onApiSuccess:function(){this.owner.clearStatusBusy(),this.owner.updateTime(),this.owner.close()},onApiFailure:function(e,t){this.owner.clearStatusBusy();var i=SYNO.API.getErrorString(t.code);this.owner.setStatusError({text:i,clear:!0})},uploadCert:function(){this.getForm().isDirty()?(this.owner.setStatusBusy(),this.upload()):this.owner.setStatusError({text:_T("error","error_nochoosefile"),clear:!0})},setGroup:function(e){var t=this.getForm();this.hideAll(),t.findField(e).show(),t.findField(e).enable()},hideAll:function(){for(var e,t=["ca_cert","user_cert","key","pac"],i=0;i'+_T("common","learn_more")+"",listeners:{afterrender:function(e){this.mon(Ext.get(this.LearnMoreStrId),"click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:"SYNO.SDS.AdminCenter.Application:AdminCenter/connection_network_oob_management.html"},!1)})},scope:this}},{xtype:"syno_checkbox",name:"oob_shell_enable",boxLabel:_T("oob","oob_enable_checkbox_desc"),id:this.oobShellEnableCheckBoxId=Ext.id(),scope:this,handler:this.onShellEnableChangeHandler},{xtype:"syno_compositefield",name:"oob_username_comp",indent:1,items:[{xtype:"syno_displayfield",fieldLabel:_T("oob","oob_account"),name:"oob_username",value:"-"},{xtype:"syno_button",name:"oob_username_edit_button",text:_T("oob","oob_edit"),id:this.btnUsernameEdit=Ext.id(),hidden:!0,scope:this,handler:this.onClickEditHandler}]},{xtype:"syno_displayfield",name:"oob_network_settings_subtitle",indent:1,cls:"syno-oobtab-inline-block-title",hideLabel:!0,value:_T("oob","oob_network_settings_subtitle")},{xtype:"syno_displayfield",name:"oob_network_settings_desc",indent:1,value:_T("oob","oob_network_settings_desc")},{xtype:"syno_displayfield",fieldLabel:_T("tcpip","tcpip_ipaddr"),name:"oob_ipv4",indent:1},{xtype:"syno_numberfield",indent:1,name:"oob_port",vtype:"port",maxlength:5,maxValue:65535,minValue:1,fieldLabel:_T("oob","oob_port")},{xtype:"syno_displayfield",name:"oob_autoblock_subtitle",indent:1,cls:"syno-oobtab-inline-block-title",hideLabel:!0,value:_T("oob","oob_autoblock_subtitle")},{xtype:"syno_displayfield",name:"oob_autoblock_desc",indent:1,value:_T("oob","oob_autoblock_desc")},{xtype:"syno_button",indent:1,text:_T("oob","oob_autoblock_clear_button_label"),id:this.oobAutoblockClearButtonId=Ext.id(),scope:this,handler:this.onClickClearBlockIp},{cls:"syno-oobtab-inline-fieldset",xtype:"syno_fieldset",itemId:"reset_title",title:_T("oob","oob_reset_title"),items:[{xtype:"syno_displayfield",value:_T("oob","oob_reset_desc")},{xtype:"syno_button",text:_T("oob","oob_reset_button_label"),scope:this,handler:this.onClickReset}]}]},e)},fillContent:function(e){var t=this.getConfig(e,SYNO.SDS.AdminCenter.Network.Utils.apiToPrefix(this.getWebAPIName()));this.hostConfig=t,this.getForm().setValues(t),this.setGroup(),this.forceSetDirty=!1},isDirty:function(){return this.getForm().isDirty()||this.forceSetDirty},isValid:function(){return this.getForm().isValid()},getWebAPISetData:function(){var e=this.getPanelConfig(),t=[{api:this.getWebAPIName(),version:1,method:"set",params:Ext.apply({},e)}];return this.forceSetDirty=!1,t},getPanelConfig:function(){var e=this.getForm(),t={};return t.oob_port=e.findField("oob_port").getValue(),t.oob_shell_enable=e.findField("oob_shell_enable").getValue(),t.oob_username=e.findField("oob_username").getValue(),t.oob_ifname=this.win.ifname,t},getWebAPIGetData:function(){return[{api:this.getWebAPIName(),version:1,method:"get",params:{}}]},setGroup:function(){var e=this.getForm();this.oobEnableCheckGroup=new SYNO.ux.Utils.EnableCheckGroup(e,"oob_shell_enable",["oob_username_comp","oob_network_settings_subtitle","oob_network_settings_desc","oob_ipv4","oob_port",this.oobAutoblockClearButtonId,"oob_autoblock_subtitle","oob_autoblock_desc"])},getConfig:function(e,t){var i={},s=this.getDefaultConfig();return i.oob_dhcp=e[t+"oob_dhcp"],i.oob_ifname=e[t+"oob_ifname"],i.oob_ipv4=e[t+"oob_ipv4"],i.oob_port=e[t+"oob_port"],i.oob_shell_enable=e[t+"oob_shell_enable"],i.oob_username=e[t+"oob_username"],i.oob_config_sts="fetched","boolean"==typeof i.oob_dhcp&&"string"==typeof i.oob_ifname&&"string"==typeof i.oob_ipv4&&"number"==typeof i.oob_port&&"boolean"==typeof i.oob_shell_enable&&"string"==typeof i.oob_username&&i.oob_ifname===this.win.ifname?i:s},getDefaultConfig:function(){return{oob_dhcp:!1,oob_ifname:this.win.ifname,oob_ipv4:"",oob_port:0,oob_shell_enable:!1,oob_username:"",oob_config_sts:"default"}},getWebAPIName:function(){return"SYNO.Core.Hardware.OOBManagement"},onClickEditHandler:function(e,t){var i=new SYNO.SDS.Utils.CheckStrongPassword,s=new SYNO.SDS.AdminCenter.Network.SetupOOBAccountDialog({title:e?_T("oob","oob_edit_account_title"):_T("oob","oob_setup_account_title"),owner:this.parentPanel.win,ownerPanel:this,hostConfig:this.hostConfig,passwordChecker:i});this.sendWebAPI({api:"SYNO.Core.User.PasswordPolicy",version:1,method:"get",scope:this,callback:function(e,t,n){e?(this.applyPasswordPolicy(i,t.strong_password),s.open()):SYNO.Debug("failed to get policy")}})},applyPasswordPolicy:function(e,t){Object.keys(t).length>0?(t.strong_password_enable=!0,e.passwordPolicy=Ext.apply({},t)):(t.strong_password_enable=!1,e.passwordPolicy=Ext.apply({},t))},onShellEnableChangeHandler:function(e,t){!0===t?!1===this.hostConfig.oob_shell_enable&&""===this.hostConfig.oob_username?this.onClickEditHandler():(this.getForm().findField("oob_username").enable(),Ext.getCmp(this.btnUsernameEdit).show()):(this.getForm().findField("oob_username").disable(),Ext.getCmp(this.btnUsernameEdit).hide())},showMsgBox:function(e,t,i,s,n){this.gMsgBox&&!this.gMsgBox.isDestroyed||(this.gMsgBox=new SYNO.SDS.MessageBoxV5({owner:this.parentPanel.win,draggable:!1})),this.gMsgBox.confirmDelete(e,t,n,this,{yes:{text:i,btnStyle:s},no:{text:_T("oob","oob_cancel")}},{useMessageTitle:!0})},onClickClearBlockIp:function(e,t){new SYNO.SDS.AdminCenter.Network.OobAutoBlock.Window({owner:this.parentPanel.win,ifname:this.win.ifname}).show()},onClickReset:function(e,t){this.showMsgBox(_T("oob","oob_reset_operation"),_T("oob","oob_reset_operation_desc"),_T("oob","oob_confirm_reset"),"red",function(e){"yes"===e&&SYNO.SDS.Utils.PasswordConfirmDialog.openDialog(this.parentPanel.win,this.confirmedResetClbk)})},confirmedResetClbk:function(){this.setStatusBusy({text:_T("common","applying"),clear:!1}),this.sendWebAPI({api:this.tabpanel.oobPanel.getWebAPIName(),method:"exec",version:1,params:{oob_ifname:this.ifname,command:"oob.reset"},scope:this.tabpanel.oobPanel,callback:function(e,t,i){this.onResetComplete()}})},onResetComplete:function(){this.sendWebAPI({api:this.getWebAPIName(),method:"get",version:1,params:{},scope:this,callback:function(e,t,i){this.hostConfig=this.getConfig(t,""),this.getForm().setValues(this.hostConfig),this.parentPanel.win.clearStatusBusy()}})},updateOobEnable:function(e){!0===e?Ext.getCmp(this.oobShellEnableCheckBoxId).enable():(Ext.getCmp(this.oobShellEnableCheckBoxId).setValue(!1),Ext.getCmp(this.oobShellEnableCheckBoxId).disable(),this.forceSetDirty=!0)}}),Ext.ns("SYNO.SDS.AdminCenter.Share"),Ext.define("SYNO.SDS.AdminCenter.Share.KeyMigrateGrid",{extend:"SYNO.ux.GridPanel",constructor:function(e){var t={module:this,header:!1,border:!1,height:250,padding:0,ds:this.createStore(e),cm:this.createColumnModel(),autoExpandColumn:"share_status"};Ext.apply(t,e),this.callParent([t])},createColumnModel:function(){var e=[{header:_T("share","share"),dataIndex:"share_name",id:"share_name"},{header:_T("common","status"),dataIndex:"share_status",id:"share_status"}];return new Ext.grid.ColumnModel({defaults:{sortable:!1,width:150},columns:e})},createStore:function(e){var t={api:"SYNO.Core.Share.KeyManager.AutoKey",method:"list",version:1,appWindow:e.owner,baseParams:{},listeners:{scope:this,beforeload:function(){this.owner.setStatusBusy({text:_T("common","loading")})},load:function(){this.owner.clearStatusBusy()},exception:function(e,t,i,s,n,o){this.owner.clearStatusBusy(),SYNO.Debug("Store exception: ",e,t,i,s,n,o)}},root:"keys",id:"share_name",fields:["share_name","share_status"],remoteSort:!1,defaultSortable:!0,scope:this};return new SYNO.API.JsonStore(t)}}),Ext.define("SYNO.SDS.AdminCenter.Share.KeyMigrate",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner;var t=this.fillConfig(e);this.callParent([t])},createPanel:function(e){this.gridMigrate=new SYNO.SDS.AdminCenter.Share.KeyMigrateGrid({module:this.module,owner:this,appWin:this});var t={border:!1,frame:!1,autoScroll:!0,header:!1,height:250,trackResetOnLoad:!0,padding:0,items:[{xtype:"syno_checkbox",name:"overwrite",boxLabel:_T("keymanager","ckbox_conflict_policy")},this.gridMigrate]};return Ext.apply(t,e),new SYNO.SDS.Utils.FormPanel(t)},fillConfig:function(e){this.panel=this.createPanel(e);var t={width:600,height:400,minWidth:500,minHeight:200,title:_T("keymanager","title_automount_migration"),layout:"fit",items:[this.panel],buttons:[{itemId:"cancel",text:_T("common","alt_cancel"),scope:this,handler:this.onCancel},{itemId:"apply",text:_T("common","alt_apply"),scope:this,btnStyle:"blue",handler:this.onSubmit}]};return Ext.apply(t,e),t},onSubmit:function(){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.Share.KeyManager.AutoKey",method:"migrate",params:{overwrite:this.panel.getForm().findField("overwrite").getValue()},version:1,scope:this,callback:function(e,t,i){if(this.clearStatusBusy(),!e){var s=SYNO.API.Response.GetFirstError(t),n=SYNO.API.Errors.core[s.code]||_T("common","error_system");return this.getMsgBox().alert("warning_msg",n),!1}this.close()}})},onCancel:function(){this.close()},onActivate:function(){this.callParent(),this.gridMigrate.getStore().load()}}),Ext.namespace("SYNO.SDS.AdminCenter.FileService.AFP"),Ext.define("SYNO.SDS.AdminCenter.FileService.AFP.AdvancedSettingDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.panel=this.configForm();var t=Ext.apply({title:_T("common","adv_setting"),autoDestroy:!0,width:450,height:200,layout:"fit",border:!1,items:[this.panel],buttons:[{btnStyle:"grey",text:_T("common","cancel"),scope:this,handler:this.close},{btnStyle:"blue",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",text:_T("common","save"),scope:this,handler:this.apply}]},e);this.callParent([t]),this.mon(this,"show",this.load,this)},load:function(){this.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({api:"SYNO.Core.FileServ.AFP",method:"get",version:1,scope:this,callback:function(e,t,i){this.clearStatusBusy(),e&&this.panel.getForm().setValues(t)}})},configForm:function(){var e={border:!1,trackResetOnLoad:!0,height:75,width:250,labelWidth:250,items:[{xtype:"syno_checkbox",name:"enable_umask",itemId:"enable_umask",boxLabel:_T("common","apply_default_umask")},{xtype:"syno_checkbox",name:"enable_afp",hidden:!0}]};return this._S("version")>=5545&&e.items.push({xtype:"syno_checkbox",name:"enable_disconnect_quick",itemId:"enable_disconnect_quick",boxLabel:_T("network","apple_quick_disconnect")}),SYNO.LayoutConfig.fill(e),new SYNO.SDS.Utils.FormPanel(e)},apply:function(){var e=this.panel.getForm(),t=e.getValues();return e.isValid()?e.isDirty()?(!0===t.enable_afp?this.confirmSubmit(t):this.submit(t),!0):(this.close(),!1):(this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1)},confirmSubmit:function(e){this.getMsgBox().confirm(_T("tree","leaf_winmacnfs"),_T("network","service_restart_warning")+" "+_T("common","ask_cont"),function(t,i,s){"yes"==t&&this.submit(e)},this)},submit:function(e){this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Core.FileServ.AFP",method:"set",version:1,scope:this,params:e,callback:function(e,t,i){if(this.clearStatusBusy(),e)return this.close(),!0;this.setStatusError()}})}}),Ext.ns("SYNO.SDS.AdminCenter.FileService.Util"),SYNO.SDS.AdminCenter.FileService.Util.getFailRespCompoundParam=function(e,t){if(!1===t.has_fail)return null;if(!(t.result instanceof Array))return null;for(var i=0;it.indexOf(e.name)?e.enabled=!1:e.enabled=!0,i.shares.push(e),i.total+=1)},this),this.panel.store.loadData(i,!1)}}),Ext.namespace("SYNO.SDS.AdminCenter.HardwareControl"),Ext.define("SYNO.SDS.AdminCenter.HardwareControl.LedBrightnessScheduleDialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner;var t={resizable:!1,title:_T("led_brightness","set_schedule"),items:[this.dialogPanel=this.createPanel()],width:680,height:400,buttons:[{text:_T("common","alt_cancel"),scope:this,btnStyle:"gray",handler:this.close},{text:_T("common","alt_apply"),itemId:"apply",scope:this,btnStyle:"blue",handler:this.onApply}]};Ext.apply(t,e),this.callParent([t])},createPanel:function(){return new Ext.form.FormPanel({trackResetOnLoad:!0,border:!1,items:[{xtype:"syno_displayfield",value:_T("led_brightness","schedule_tip_desc")},this.ledSchedule=new SYNO.ux.ScheduleTable({name:"schedule_table",buttons:[{label:_T("led_brightness","schedule_led_default")},{label:_T("led_brightness","schedule_led_adjust")},{label:_T("led_brightness","slider_led_off")}]})]})},onOpen:function(){this.callParent()},onApply:function(){this.isApply=!0,this.close()},getSchedule:function(){return this.ledSchedule.getSchedule()},setSchedule:function(e){this.ledSchedule.setSchedule(e)}}),Ext.define("SYNO.SDS.AdminCenter.HardwareControl.GeneralSettingForm.VideoTranscodingForm",{extend:"SYNO.ux.FieldSet",formType:"video_transcoding",webapi:{api:"SYNO.Core.Hardware.VideoTranscoding",methods:{get:"get",set:"set"},version:1},constructor:function(e){this.enableOnUI=null,this.confirmSetEnable=!1;var t=Ext.apply({labelWidth:250,title:_T("memory_layout","video_transcoding"),items:this.getItemList()},e);SYNO.LayoutConfig.fill(t),this.callParent([t])},getItemList:function(){var e=[];return e.push({xtype:"syno_displayfield",value:_T("memory_layout","desc_for_rtd1296")}),e.push({xtype:"syno_checkbox",name:"enable_video_transcoding",boxLabel:_T("memory_layout","enable_video_transcoding")}),e},onBeforeRequest:function(e){if(this.webapi.methods.set!==e)return!0;var t=this.parent.getForm().findField("enable_video_transcoding");return!(!this.confirmSetEnable&&this.enableOnUI!=t.getValue())||(SYNO.Debug("enable_video_transcoding changed"),this.module.appWin.getMsgBox().confirm(this.title,_T("memory_layout","video_transcoding_confirm"),function(e){"yes"===e?(this.confirmSetEnable=!0,this.module.panel.applyAllForm(),this.confirmSetEnable=!1):t.setValue(this.enableOnUI)},this),!1)},processReturnData:function(e,t,i){for(var s={api:this.webapi.api,method:this.webapi.methods.get,version:this.webapi.version},n=0;n=a.value&&(o=a.value)}e.slider.setValue(n,o,!1),s.fireEvent("drag",s,t,i)},this.ownerCt.addListener("deactivate",this.updateLedBrightness)}},updateTip:function(){this.isSliderDraging||this.isMouseInsideSlider?this.slider.minValue===this.getValue()?(this.ledOffTip.show(),this.ledOnTip.hide()):this.slider.maxValue===this.value?(this.ledOffTip.hide(),this.ledOnTip.show()):(this.ledOffTip.hide(),this.ledOnTip.hide()):(this.ledOffTip.hide(),this.ledOnTip.hide()),this.ledOffTip.isVisible()&&this.ledOffTip.setPosition([this.getPosition()[0]+8-this.ledOffTip.getWidth()/2,this.getPosition()[1]-25]),this.ledOnTip.isVisible()&&this.ledOnTip.setPosition([this.getPosition()[0]+this.getWidth()-7-this.ledOnTip.getWidth()/2,this.getPosition()[1]-25])}},{xtype:"syno_displayfield",hideLabel:!0,width:24,height:24,cls:"led-slider-icon-tail"}]},{xtype:"syno_displayfield",hideLabel:!0,width:400,height:16,id:this.sliderScaleId=Ext.id()},{xtype:"hidden",name:"schedule",id:this.ledScheduleFieldId=Ext.id()},{xtype:"syno_button",text:_T("led_brightness","set_schedule"),listeners:{scope:this,click:this.onLedBrightnessScheduleButtonClick}}]},onLedBrightnessScheduleButtonClick:function(){this.ledBrightnessScheduleDialog=new SYNO.SDS.AdminCenter.HardwareControl.LedBrightnessScheduleDialog({owner:this.module.appWin,module:this}),this.ledBrightnessScheduleDialog.setSchedule(Ext.getCmp(this.ledScheduleFieldId).getValue()),this.ledBrightnessScheduleDialog.on("close",this.onScheduleDialogClose,this),this.ledBrightnessScheduleDialog.open()},onScheduleDialogClose:function(e){!0===e.isApply&&Ext.getCmp(this.ledScheduleFieldId).setValue(e.getSchedule())},onLedSliderValuechange:function(e,t){this.sendWebAPI({api:"SYNO.Core.Hardware.Led.Brightness",method:"set_current_brightness",params:{led_brightness:t},version:1}),e.updateTip()},updateLedBrightness:function(){null!==this.originalBrightness&&this.sendWebAPI({api:"SYNO.Core.Hardware.Led.Brightness",method:"update",version:1})},onSliderStaticDataRecieve:function(e,t,i){if(!1!==e){var s,n;switch(t.max-t.min+1){case 4:s=195,n="led-slider-scale-4";break;case 8:s=295,n="led-slider-scale-8";break;default:return void this.module.appWin.getMsgBox().alert("error","LED brightness scale isn't defined",null,this)}var o=Ext.getCmp(this.sliderFieldId);o.slider.setMinValue(t.min),o.slider.setMaxValue(t.max),o.setWidth(s),o.width=s,o.ownerCt.doLayout(),Ext.getCmp(this.sliderScaleId).getEl().addClass(n),Ext.getCmp(this.compositeFieldId).show()}}}),Ext.namespace("SYNO.SDS.App.SynologyAccountNotify"),SYNO.SDS.App.SynologyAccountNotify.Instance=Ext.extend(SYNO.SDS.AppInstance,{onOpen:function(e){this.sendWebAPI({api:"SYNO.Core.MyDSCenter",version:2,method:"query",params:{},scope:this,callback:function(e,t,i){e&&t.is_logged_in&&!t.activated&&SYNO.SDS.SystemTray.notifyMsg(_T("myds","myds_account"),_T("myds","myds_account"),String.format(_T("myds","not_activated_desc"),'',""),0,!1)}})}}),Ext.namespace("SYNO.SDS.AdminCenter.Notification"),Ext.define("SYNO.SDS.AdminCenter.Notification.VarEditor",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){var t=Ext.apply({dsmStyle:"v5",useStatusBar:!0,title:_T("notification","replacement")+" - "+_T("common","alt_edit"),width:468,height:170,minWidth:468,minHeight:130,layout:"fit",items:[this.getFormConfig()],buttons:[{xtype:"syno_button",text:_T("common","save"),scope:this,handler:this.onClickSave},{xtype:"syno_button",text:_T("common","close"),scope:this,handler:this.onClickClose}]},e);this.callParent([t]),this.formPanel=this.getComponent("VarEditorFormPanel"),this.mon(this,"show",function(){this.setStatusBusy({text:_T("common","loading")}),this.sendWebAPI({api:"SYNO.Core.Notification.Advance.Variables",method:"get",version:1,scope:this,callback:function(e,t,i){this.clearStatusBusy(),e?this.formPanel.getForm().setValues(t):this.getMsgBox().alert(_T("tree","leaf_notification"),String.format(_T("error","error_load_system_settings"),'',""))}})},this,{single:!0})},getFormConfig:function(){return{xtype:"syno_formpanel",itemId:"VarEditorFormPanel",border:!1,trackResetOnLoad:!0,items:[{xtype:"syno_textfield",name:"company_name",fieldLabel:"%COMPANY_NAME%",allowBlank:!1,maxlength:512},{xtype:"syno_textfield",name:"http_url",emptyText:_T("common","default"),fieldLabel:"%HTTP_URL%",allowBlank:!0,maxlength:512}]}},onClickClose:function(){this.formPanel.getForm().isDirty()?this.getMsgBox().confirm(this.title,_T("common","confirm_lostchange"),function(e){"yes"===e&&this.close()},this):this.close()},onClickSave:function(){this.formPanel.form.isValid()&&(this.formPanel.form.isDirty()?(this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({api:"SYNO.Core.Notification.Advance.Variables",method:"set",version:1,params:this.formPanel.form.getValues(),scope:this,callback:function(e,t,i){this.clearStatusBusy(),e?this.close():this.setStatusError({text:String.format(_T("error","error_set_system_settings"),'',""),clear:!0})}})):this.setStatusError({text:_T("error","nochange_subject"),clear:!0}))}}),Ext.namespace("SYNO.SDS.AdminCenter.Notification"),Ext.define("SYNO.SDS.AdminCenter.Notification.FilterButton",{extend:"SYNO.ux.Button",constructor:function(e){var t=Ext.apply({iconCls:"syno-sds-cp-notification-filter-btn"},e);this.callParent([t])},getMenuClass:function(){return""}});