HEX
Server: Apache/2.4.63 (Unix)
System: Linux Synopilou92 4.4.302+ #72806 SMP Mon Jul 21 23:16:00 CST 2025 x86_64
User: pilou92 (1026)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /volume1/@appstore/SynologyDrive/ui/cloudstation.js
/* Copyright (c) 2026 Synology Inc. All rights reserved. */

Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.WelcomeWindow",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.owner=e.owner;var t=this.owner.appInstance.getUserSettings("welcome_window_ds_id"),i=this.owner.appInstance.getUserSettings("welcome_window_index_home_ds_id"),n={illustrationImage:"illustration-img04",title:_STR("migrate_index_home","web_intro_title_admin"),description:_STR("cstn","welcome_desc_index_home"),buttonText:_STR("btn","proceed"),buttonHandler:function(){this.owner.selectPage("SYNO.SDS.CSTN.PanelSharing"),this.owner.appInstance.setUserSettings("welcome_window_ds_id",e.ds_id),this.owner.appInstance.setUserSettings("welcome_window_index_home_ds_id",e.ds_id),this.destroy()}.bind(this)},s=[];t!==e.ds_id?(s.push({illustrationImage:"illustration-img01",title:_STR("cstn","welcome_title_intro"),description:_STR("cstn","welcome_desc_intro")}),!SYNO.SDS.CSTN.HasOffice()&&SYNO.SDS.CSTN.SupportOffice()&&s.push({illustrationImage:"illustration-img02",title:_STR("cstn","welcome_title_office"),description:String.format(_STR("cstn","welcome_desc_office"),'<a id="synopkg-office">'+_STR("cstn","package_center")+"</a>"),description_listeners:{afterrender:function(){Ext.get("synopkg-office").on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.PkgManApp.Instance",{action:"open",packages:["Spreadsheet"]})},this)}}}),e.display_index_home_promotion?s.push(n):s.push({illustrationImage:"illustration-img03",title:_STR("cstn","welcome_title_team_folder"),description:_STR("cstn","welcome_desc_team_folder"),buttonText:_STR("btn","proceed"),buttonHandler:function(){this.owner.selectPage("SYNO.SDS.CSTN.PanelSharing"),this.owner.appInstance.setUserSettings("welcome_window_ds_id",e.ds_id),this.destroy()}.bind(this)})):i!=e.ds_id&&s.push(n);var o={cls:"syno-cstn-welcome",width:680,height:531,header:!1,elements:"body",useStatusBar:!1,resizable:!1,closable:!1,draggable:!1,layout:"fit",items:new SYNO.SDS.CSTN.WelcomeWindowFlow({steps:s})};return Ext.apply(o,e)}}),Ext.ns("SYNO.SDS.CSTN.WelcomeWindow"),Ext.define("SYNO.SDS.CSTN.WelcomeWindowFlow",{extend:"Ext.Container",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){return this.steps=e.steps,this.currentStepIndex=0,this.currentStep=new SYNO.SDS.CSTN.WelcomeWindowStep({owner:this,step:this.steps[this.currentStepIndex],stepIndex:this.currentStepIndex,totalStep:this.steps.length}),{layout:"fit",items:this.currentStep}},gotoStep:function(e){if(!(e>=this.steps.length)){var t=new SYNO.SDS.CSTN.WelcomeWindowStep({owner:this,step:this.steps[e],stepIndex:e,totalStep:this.steps.length});this.remove(this.currentStep),this.add(t),this.currentStep=t,this.currentStepIndex=e,this.doLayout()}},nextStep:function(){this.gotoStep(this.currentStepIndex+1)}}),Ext.define("SYNO.SDS.CSTN.WelcomeWindowStep",{extend:"Ext.Container",constructor:function(e){this.callParent([this.fillConfig(e)])},fillConfig:function(e){this.owner=e.owner;var t=e.step;return{layout:{type:"vbox",align:"center"},items:[{xtype:"container",cls:"illustration-spacer"},{xtype:"container",cls:t.illustrationImage},{xtype:"syno_displayfield",cls:"illustration-title",value:t.title},{xtype:"spacer",height:12},{xtype:"container",cls:"illustration-desc",html:t.description,listeners:t.description_listeners},{xtype:"spacer",height:20},{xtype:"syno_button",cls:"illustration-button",btnStyle:"blue",autoWidth:!1,text:t.buttonText?t.buttonText:_T("common","next"),handler:t.buttonHandler?t.buttonHandler:this.owner.nextStep.bind(this.owner)},this.generateDotIndicators(e.stepIndex,e.totalStep)]}},generateDotIndicators:function(e,t){if(1===t)return{xtype:"container"};for(var i=[],n=0;n<t;++n)0!==n&&i.push({xtype:"container",cls:"dot-indicator-space"}),i.push({xtype:"syno_button",cls:n===e?"dot-indicator-current":"dot-indicator",targetIndex:n,owner:this.owner,handler:function(){this.owner.gotoStep(this.targetIndex)}});return{xtype:"container",layout:"hbox",cls:"dot-indicator-zone",items:i}}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.UDCWindow",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.callParent([this.fillConfig(e)]),this.addManagedComponent(this.vuePanel)},fillConfig:function(e){var t=e.owner.appInstance,i=this,n=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.CSTN.Vue.UDC,mountId:"UDCWindow",layout:"fit",cls:"UDCWindow",owner:this},{propsData:{setDontShowAgain:function(){t.setUserSettings("udc_window_ds_id",e.ds_id)},closeWindow:function(){i.destroy()}}});this.vuePanel=n;var s={cls:"syno-cstn-udc",width:680,height:531,header:!1,elements:"body",useStatusBar:!1,resizable:!1,closable:!1,draggable:!1,layout:"fit",items:this.vuePanel};return Ext.apply(s,e)}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PanelCloudStn",{extend:"SYNO.SDS.Utils.FormPanel",layout:"fit",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin,this.appWin=e.appWin,this.enableStatusPollTask=void 0,this.isStatusNormal=!1,this.getStatus={api:SYNO.SDS.CSTN.WebAPI.api,version:1,method:"get_status",params:{}},this.getConnectionSummary={api:SYNO.SDS.CSTN.WebAPI.Connection.api,version:2,method:"summary",params:{}},this.getConfig={api:SYNO.SDS.CSTN.WebAPI.Config.api,version:1,method:"get",params:{}},this.getUsageTrend={api:SYNO.SDS.CSTN.WebAPI.Statistics.api,version:1,method:"get",params:{after:parseInt(((new Date).getTime()-2592e6)/1e3)}},this.getUDC={api:"SYNO.Core.DataCollect",version:1,method:"get",params:{}},this.statusPanelItem=new SYNO.SDS.CSTN.Overview.Status({owner:this,status_type:"preparing"}),this.clientInfoPanel=new SYNO.SDS.CSTN.Overview.PanelClientInfo({owner:this.owner,module:this.module}),this.lastAuthTimePanel=new SYNO.SDS.CSTN.PanelLastOnline({owner:this.owner,module:this.module}),this.topFilesPanel=new SYNO.SDS.CSTN.GridPanelTopFiles({owner:this.owner,module:this.module}),this.databaseUsagePanel=new SYNO.SDS.CSTN.Overview.PanelDatabaseUsage({owner:this.owner,module:this.module});var t={itemId:"overview",cls:"syno-cstn-overview-content",border:!1,items:[{xtype:"panel",id:this.statusPanelId=Ext.id(),bodyStyle:"padding: 0px;",border:!1,layout:"fit",cls:"syno-cstn-overview-panel",items:this.statusPanelItem},{xtype:"spacer",height:16},{xtype:"panel",bodyStyle:"padding: 0px;",border:!1,height:190,layout:"fit",cls:"syno-cstn-overview-panel",items:this.clientInfoPanel},{xtype:"spacer",height:16},{xtype:"panel",bodyStyle:"padding: 0px;",border:!1,height:267,layout:"fit",cls:"syno-cstn-overview-panel",items:[{xtype:"syno_fieldset",title:_STR("cstn","last_online_time_title"),items:[this.lastAuthTimePanel]}]},{xtype:"spacer",height:16},{xtype:"panel",bodyStyle:"padding: 0px;",border:!1,height:294,layout:"fit",cls:"syno-cstn-overview-panel",items:[{xtype:"syno_fieldset",title:_STR("cstn","top_accessed_files"),items:[this.topFilesPanel]}]},{xtype:"spacer",height:16},{xtype:"panel",bodyStyle:"padding: 0px;",border:!1,height:286,layout:"fit",cls:"syno-cstn-overview-panel syno-cstn-database-panel",items:this.databaseUsagePanel},{xtype:"spacer",height:20}]},i={itemId:"overview-out",bodyStyle:"padding-top: 0px;",layout:{type:"vbox",align:"stretch"},listeners:{scope:this,flexcroll:this.onFleXcroll},items:[t],bubbleEvents:["cstn_config_loaded"]};this.udc_remind_later_clicked=!1,this.callParent([Ext.apply(i,e)])},shouldShowWelcomeWindow:function(e,t){var i=this.owner.appInstance.getUserSettings("welcome_window_ds_id"),n=this.owner.appInstance.getUserSettings("welcome_window_index_home_ds_id");return!!(i!==e||t&&n!==e)},showWelcomeWindow:function(e,t){new SYNO.SDS.CSTN.WelcomeWindow({owner:this.owner,ds_id:e,display_index_home_promotion:t}).open()},shouldShowC2PromotionWindow:function(){return!1},showC2PromotionWindow:function(){this.dialogC2PromotionWindow=this.appWin.openVueWindow(SYNO.SDS.CSTN.Vue.DialogC2Promotion,{synoId:Ext.id(),owner:this.owner,onStartCB:this.owner.reloadC2Transfer.bind(this.owner,"C2Transfer"),redirectC2TransferKB:"https://kb.synology.com/en-us/DSM/help/SynologyDriveClient/synologydriveclient?version=7"}).window},shouldShowUDCWindow:function(){return!0!==this.udc_remind_later_clicked&&(!0!==this.udc_enabled&&this.owner.appInstance.getUserSettings("udc_window_ds_id")!==SYNO.SDS.CSTN.Config.ds_id)},showUDCWindow:function(){this.udc_remind_later_clicked=!0,new SYNO.SDS.CSTN.UDCWindow({owner:this.owner,ds_id:SYNO.SDS.CSTN.Config.ds_id}).open()},shouldVisitAIAssistantPage:function(){return!!SYNO.SDS.CSTN.isAIConsoleEnabled()&&(!(!SYNO.SDS.CSTN.HasOffice()||!SYNO.SDS.Config.FnMap.hasOwnProperty("SYNO.SDS.Office.AdminSetting"))&&!0!==this.owner.appInstance.getUserSettings("ai_assistant_recommend_shown"))},visitAIConsolePage:function(){for(var e="SYNO.SDS.Office.AdminSetting.AiPromotionModule",t=SYNO.SDS.Office.AdminSetting.getItmes(),i=0;i<t.length;i++)t[i].fn===e&&(this.owner.selectPage(e),this.owner.appInstance.setUserSettings("ai_assistant_recommend_shown",!0))},freezeResume:function(){this.resumeService()},ajaxDeleteDatabaseCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.resumeService,failure:SYNO.SDS.CSTN.webapiErrHdl})},onDeleteDatabase:function(){this.owner.getMsgBox().confirm(_STR("app","app_name"),_STR("warning","msg_remove_drive_db"),function(e){"yes"===e&&SYNO.SDS.CSTN.WebAPI.deleteDatabase.call(this.owner,this.ajaxDeleteDatabaseCB,this)},this)},resumeService:function(){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.resumeFreeze.call(this.owner,function(){this.owner.clearStatusBusy(),this.loadForm()},this)},updateStatus:function(e){var t={owner:this};if(Ext.isDefined(e.enable_status)){switch(e.enable_status){case"updating":case"done":t.status_type="preparing",t.status_desc=_STR("warning","msg_upgrading"),this.ctrlEnableStatusPollingTask(!0);break;case"initializing":t.status_type="preparing",t.status_desc=_STR("warning","msg_initializing"),this.ctrlEnableStatusPollingTask(!0);break;case"checking":t.status_type="preparing",t.status_desc=_STR("warning","msg_checking_db"),this.ctrlEnableStatusPollingTask(!0);break;case"enabled":if(e.cstn_freeze){var i=_STR("warning","free_up_volume"),n=[];Ext.each(e.freeze_volume_id,function(e){n.push(_T("volume","volume")+" "+e)},this),t.status_type="error",t.status_text=_STR("warning","err_diskfull"),t.status_desc=String.format(i,n.join(", ")),t.additional_button="resume",this.ctrlEnableStatusPollingTask(!1)}else e.no_folder_available?(t.status_type="no_folder_available",this.isStatusNormal=!0,this.ctrlEnableStatusPollingTask(!0)):(t.status_type="enabled",this.isStatusNormal=!0,this.ctrlEnableStatusPollingTask(!0));break;case"upgradefail":case"dbnewer":case"dbunexist":t.status_type="error","upgradefail"===e.enable_status?(t.status_text=_STR("common","database_upgrade_failed"),t.status_desc=_STR("warning","error_drive_upgradefail")):"dbnewer"===e.enable_status?(t.status_text=_STR("common","database_error"),t.status_desc=_STR("warning","error_upgrade_db_newer_delete")):"dbunexist"===e.enable_status&&(t.status_text=_STR("common","database_error"),t.status_desc=_STR("warning","error_db_unexist_delete")),t.additional_button="db_delete",this.ctrlEnableStatusPollingTask(!1);break;case"homedisabled":t.status_type="error",t.status_text=_STR("common","error"),t.status_desc=_STR("warning","err_enable_homes"),this.ctrlEnableStatusPollingTask(!1);break;case"portconflict":t.status_type="error",t.status_text=_STR("common","port_error"),t.status_desc=String.format(_STR("warning","warn_drive_port_conflict"),"6690"),t.additional_button="resume",this.ctrlEnableStatusPollingTask(!1)}if(!this.statusPanelItem.isEquivalentStatus(t)){var s=Ext.getCmp(this.statusPanelId);s.remove(this.statusPanelItem),this.statusPanelItem=new SYNO.SDS.CSTN.Overview.Status(t),s.add(this.statusPanelItem),this.doLayout(),this.module.enableStatus=e.enable_status}}},ctrlEnableStatusPollingTask:function(e){e?void 0===this.enableStatusPollTask&&(this.enableStatusPollTask=this.addWebAPITask({id:"enable_status_polltask",interval:5e3,autoJsonDecode:!0,api:SYNO.SDS.CSTN.WebAPI.api,version:1,method:"get_status",callback:function(e,t,i){if(t.code)switch(t.code){case SYNO.SDS.CSTN.ErrorCode.NO_SUCH_API:return void this.ctrlEnableStatusPollingTask(!1)}this.loadStatusDone(e,t)},scope:this}),this.enableStatusPollTask.start(!1)):void 0!==this.enableStatusPollTask&&(this.enableStatusPollTask.stop(),this.enableStatusPollTask=void 0)},loadStatusDone:function(e,t){if(this.isStatusNormal=!1,t.code){switch(t.code){case SYNO.SDS.CSTN.ErrorCode.NO_SUCH_API:case SYNO.SDS.CSTN.ErrorCode.REPO_MOVE:case SYNO.SDS.CSTN.ErrorCode.CANNOT_ACCESS:this.ctrlEnableStatusPollingTask(!1)}return SYNO.SDS.CSTN.webapiErrHdl.call(this,t),!1}return this.updateStatus(t),this.module.cstnInfo=t,this.doLayout(),!0},loadConfigDone:function(e,t){if(!e)return this.isStatusNormal&&SYNO.SDS.CSTN.webapiErrHdl.call(this,t),!1;SYNO.SDS.CSTN.Config=t,this.fireEvent("cstn_config_loaded");var i=!t.enable_non_admin_user_sync;return this.clientInfoPanel.changeButtonList(i),this.shouldShowWelcomeWindow(t.ds_id,t.display_index_home_promotion)?this.showWelcomeWindow(t.ds_id,t.display_index_home_promotion):this.shouldShowC2PromotionWindow()?this.showC2PromotionWindow():this.shouldVisitAIAssistantPage()&&this.visitAIConsolePage(),!0},loadUsageTrendDone:function(e,t){var i=["database","repo","office"],n={};i.forEach(function(e){n[e]=[]});var s=1;t.statistics.forEach(function(e){var t=e.labels.type;null!==t&&-1!==i.indexOf(t)&&(n[t].push([1e3*e.timestamp,e.value]),e.value>s&&(s=e.value))});for(var o=0;s>=1024;)o++,s/=1024;return this.databaseUsagePanel.updateData(n,o),!0},loadClientInfoDone:function(e,t){return e?(this.getForm().findField("client_count_total").setValue(t.summary.total),this.getForm().findField("client_count_sharesync").setValue(t.summary.sharesync),this.getForm().findField("client_count_desktop").setValue(t.summary.desktop),this.getForm().findField("client_count_mobile").setValue(t.summary.mobile),this.doLayout(),!0):(this.isStatusNormal&&SYNO.SDS.CSTN.webapiErrHdl.call(this,t),!1)},loadUDCDone:function(e,t){return e?(this.udc_enabled=t.enable,!0):(this.isStatusNormal&&SYNO.SDS.CSTN.webapiErrHdl.call(this,t),!1)},ajaxLoadFormCB:function(e,t,i,n){var s=t.result;this.owner.clearStatusBusy();for(var o=0;o<s.length;++o){var a=null;if(SYNO.ux.Utils.checkApiConsistency(this.getStatus,s[o])?a=this.loadStatusDone:SYNO.ux.Utils.checkApiConsistency(this.getConnectionSummary,s[o])?a=this.loadClientInfoDone:SYNO.ux.Utils.checkApiConsistency(this.getConfig,s[o])?a=this.loadConfigDone:SYNO.ux.Utils.checkApiConsistency(this.getUsageTrend,s[o])?a=this.loadUsageTrendDone:SYNO.ux.Utils.checkApiConsistency(this.getUDC,s[o])&&(a=this.loadUDCDone),a&&!1===a.call(this,s[o].success,s[o].data||s[o].error))break}this.shouldShowUDCWindow()&&this.showUDCWindow()},loadForm:function(){SYNO.SDS.CSTN.DBG("PanelCSTN loadForm"),this.owner.setStatusBusy(),this.lastAuthTimePanel.onPageActivate(),this.topFilesPanel.onPageActivate(),this.sendWebAPI({stop_when_error:!1,compound:{params:[this.getStatus,this.getConfig,this.getUsageTrend,this.getConnectionSummary,this.getUDC]},callback:this.ajaxLoadFormCB,scope:this})},onPageActivate:function(){this.loadForm(),this.ctrlEnableStatusPollingTask(!0),this.ownerCt.addClass("syno-cstn-overview"),this.doLayout()},onPageDeactivate:function(){this.ownerCt.removeClass("syno-cstn-overview")},onActivate:function(){this.onPageActivate()},onDeactivate:function(){this.onPageDeactivate()},onFleXcroll:function(e,t){var i=this.clientInfoPanel.getDownloadButton();i&&i.menu.fireEvent("onScroll",t)}}),Ext.ns("SYNO.SDS.CSTN.Overview"),Ext.define("SYNO.SDS.CSTN.Overview.Status",{extend:"Ext.Container",constructor:function(e){this.owner=e.owner,this.statusConfig=this.applyDefaultConfig(e);var t=(this.statusConfig.additional_button,{xtype:"container",layout:{type:"hbox",align:"stretch"},items:[{xtype:"container",width:91,items:{xtype:"container",cls:"syno-cstn-overview-icon-"+this.statusConfig.status}},{xtype:"container",flex:1,layout:{type:"vbox",pack:"center",align:"stretch"},items:[{xtype:"syno_displayfield",cls:"syno-cstn-overview-icon-text-"+this.statusConfig.status,value:this.statusConfig.status_text},{xtype:"spacer",height:4},this.generateStatusDescription()]}]}),i={itemId:"status",height:106,layout:{type:"hbox",align:"stretch"},items:[Ext.apply(t,{flex:1}),{xtype:"container",style:{padding:"17px 19px 0px 0px"},items:this.generateAdditionalButton()}]};this.callParent([Ext.apply(i)])},applyDefaultConfig:function(e){var t={};switch(e.status_type){case"enabled":t={status:e.status_type,status_text:_STR("common","drive_enable"),status_desc:_STR("cstn","desc_server_enabled")};break;case"preparing":t={status:e.status_type,status_text:_STR("common","preparing_drive"),status_desc:""};break;case"no_folder_available":t={status:"warning",status_text:_STR("common","no_available_folder"),status_desc:{html:String.format(_STR("warning","enable_team_folder"),'<a id="teamfolder-link">'+_STR("category","team_folder")+"</a>"),listeners:{afterrender:function(){Ext.get("teamfolder-link").on("click",function(){this.owner.owner.selectPage("SYNO.SDS.CSTN.PanelSharing")},this)}}}};break;case"error":t={status:e.status_type,status_text:_STR("common","error"),status_desc:""}}return Ext.apply(t,e)},generateAdditionalButton:function(){switch(this.statusConfig.additional_button){case"resume":return this.generateResumeDriveButton();case"db_delete":return this.generateDbRemoveButton();default:return}},generateResumeDriveButton:function(){return{xtype:"syno_button",cls:"syno-cstn-overview-button",btnStyle:"grey",text:_STR("cstn","btn_resume_drive_server"),handler:this.owner.freezeResume,disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this.owner}},generateDbRemoveButton:function(){return{xtype:"syno_button",cls:"syno-cstn-overview-button",btnStyle:"red",text:_STR("cstn","btn_remove_db"),handler:this.owner.onDeleteDatabase,disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this.owner}},generateStatusDescription:function(){var e={xtype:"syno_displayfield",autoHeight:!0,cls:"syno-cstn-overview-icon-desc",owner:this.owner};return Ext.isObject(this.statusConfig.status_desc)?Ext.apply(e,this.statusConfig.status_desc):Ext.apply(e,{value:this.statusConfig.status_desc})},isEquivalentStatus:function(e){var t=this.applyDefaultConfig(e);return Ext.isObject(this.statusConfig.status_desc)?t.status===this.statusConfig.status&&t.status_text===this.statusConfig.status_text&&t.status_desc.html===this.statusConfig.status_desc.html&&t.additional_button===this.statusConfig.additional_button:t.status===this.statusConfig.status&&t.status_text===this.statusConfig.status_text&&t.status_desc===this.statusConfig.status_desc&&t.additional_button===this.statusConfig.additional_button}}),Ext.define("SYNO.SDS.CSTN.Overview.Panel",{extend:"Ext.Container",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin;var t=this.fillConfig(e||{});this.callParent([t])},getTitleConfig:function(){return""},getTitleItems:function(){},getButtonListConfig:function(){return[]},getContentConfig:function(){return{}},fillConfig:function(e){this.buttonList=this.getButtonListConfig();var t=this.generateButtonListWithSeperator(this.buttonList),i={height:190,layout:{type:"vbox",align:"stretch"},items:[{xtype:"container",cls:"syno-cstn-overview-panel-title",layout:{type:"hbox",align:"stretch"},items:[{xtype:"container",cls:"syno-cstn-title-text",flex:1,html:this.getTitleConfig(),items:this.getTitleItems()},{xtype:"container",id:this.buttonListId=Ext.id(),cls:"syno-cstn-button-list",layout:{type:"hbox",pack:"end"},items:t}]},this.getContentConfig()]};return Ext.apply(i,e),i},generateButtonListWithSeperator:function(e){var t=[];return Ext.each(e,function(i,n){i.cls="syno-cstn-title-button "+i.cls,t.push(i),n!==e.length-1&&(t=t.concat([{xtype:"spacer",width:12},{xtype:"container",cls:"syno-cstn-title-seperator"},{xtype:"spacer",width:12}]))}),t},changeButtonList:function(e){var t=!0;if(e.length!==this.buttonList.length?t=!1:Ext.each(e,function(e,i){if(e.itemId!==this.buttonList[i].itemId)return t=!1,!1},this),!t){this.buttonList=e;var i=Ext.getCmp(this.buttonListId);i.removeAll(),i.add(this.generateButtonListWithSeperator(e))}}}),Ext.define("SYNO.SDS.CSTN.Overview.DownloadWindow",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner;var t={xtype:"statusbar",defaultText:"&nbsp;",buttonAlign:"left",items:[{xtype:"syno_button",btnStyle:"grey",text:_T("common","close"),scope:this,handler:this.close}]},i={resizable:!1,width:600,height:420,title:_STR("cstn","download_mobile_client"),cls:"syno-cstn-download-window",fbar:t,layout:{type:"vbox",align:"stretch"},items:[{xtype:"container",layout:{type:"vbox",align:"center"},items:[{xtype:"syno_displayfield",cls:"syno-cstn-desc",value:_STR("common","mobile_desc")}]},{xtype:"container",flex:1,cls:"syno-cstn-qrcode-section",layout:{type:"hbox",pack:"center",align:"middle"},items:[{xtype:"container",items:{xtype:"container",cls:"syno-cstn-qrcode",layout:{type:"vbox",pack:"center",align:"center"},items:[{xtype:"container",cls:"syno-cstn-qrcode-ios"},{xtype:"syno_displayfield",cls:"syno-cstn-qrcode-text",value:_T("common","ios")}]},listeners:{scope:this,afterrender:{single:!0,fn:function(e){this.mon(e.getEl(),"click",function(){window.open("https://itunes.apple.com/us/app/synology-drive/id1267275421?ls=1&mt=8","_blank")},this)}}}},{xtype:"spacer",width:60},{xtype:"container",items:{xtype:"container",cls:"syno-cstn-qrcode",layout:{type:"vbox",pack:"center",align:"center"},items:[{xtype:"container",cls:"syno-cstn-qrcode-android"},{xtype:"syno_displayfield",cls:"syno-cstn-qrcode-text",value:_T("common","android")}]},listeners:{scope:this,afterrender:{single:!0,fn:function(e){this.mon(e.getEl(),"click",function(){window.open("https://play.google.com/store/apps/details?id=com.synology.dsdrive","_blank")},this)}}}}]},{xtype:"spacer",height:23}]};this.callParent([Ext.apply(i,e)])}}),Ext.define("SYNO.SDS.CSTN.Overview.PanelClientInfo",{extend:"SYNO.SDS.CSTN.Overview.Panel",constructor:function(e){this.callParent(arguments),this.lastScrollTop=0},getDownloadButton:function(){return Ext.getCmp(this.downloadButtonId)},getTitleConfig:function(){return _STR("cstn","title_overview_clientinfo")},getButtonListConfig:function(e){var t={xtype:"syno_button",id:this.downloadButtonId=Ext.id(),itemId:"download_button",tooltip:_STR("common","get_desktop_and_mobile_apps"),cls:"syno-cstn-download-icon",menuAlign:"tl-bl?",menu:{xtype:"syno_menu",listeners:{scope:this,onScroll:this.onScroll},items:[{text:_STR("cstn","download_desktop_client"),listeners:{scope:this,click:this.onClickGetDesktopClient}},{text:_STR("cstn","download_mobile_client"),listeners:{scope:this,click:this.onClickGetMobileClient}}]}},i={xtype:"syno_button",itemId:"jumpto_button",tooltip:String.format(_STR("cstn","tooltip_goto_other_tab"),_STR("func","mgr_clientinfo")),cls:"syno-cstn-jumpto-icon",scope:this,handler:this.onJumptoClientList};return e?[i]:[t,i]},onScroll:function(e){this.lastScrollTop!==e.scrollTop&&this.getDownloadButton().menu.hide(),this.lastScrollTop=e.scrollTop},onClickGetDesktopClient:function(){SYNO.SDS.CSTN.WebAPI.getClientLink.call(this,this.getOS(),window.navigator.platform,"drive",function(e,t,i,n){var s=_STR("warning","err_get_download_link_fail");e?SYNO.SDS.Utils.IFrame.request(t.download_link,function(e,t,i,n){"timeout"===e||Ext.isGecko&&!Ext.isObject(n)||this.owner.getMsgBox().alert("",s)},this):this.owner.getMsgBox().alert("",s)},this)},getOS:function(){return Ext.isMac?"Mac":Ext.isWindows?"Windows":Ext.isLinux?"Linux":"default"},onClickGetMobileClient:function(){var e=new SYNO.SDS.CSTN.Overview.DownloadWindow({owner:this.owner});e.doLayout(),e.open()},onJumptoClientList:function(){this.owner.selectPage("SYNO.SDS.CSTN.PanelClient")},getContentConfig:function(){return{xtype:"container",flex:1,cls:"syno-cstn-client-panel",layout:{type:"hbox",align:"stretch"},defaults:{xtype:"container",flex:1,layout:{type:"vbox",pack:"center",align:"center"}},items:[{xtype:"spacer",width:21},{cls:"syno-cstn-client-panel-total",items:[{xtype:"syno_displayfield",cls:"syno-cstn-client-panel-total-value",name:"client_count_total",value:"-"},{xtype:"container",cls:"syno-cstn-client-panel-total-title",html:_STR("clientinfo","total_client")}]},{xtype:"spacer",width:40},{xtype:"container",width:1,cls:"syno-cstn-client-panel-seperator"},{xtype:"spacer",width:40},{cls:"syno-cstn-client-panel-box",items:[{xtype:"container",cls:"syno-cstn-client-icon-sharesync"},{xtype:"container",cls:"syno-cstn-client-panel-title",html:_STR("clientinfo","client_serversync"),listeners:{render:function(e){e.getEl().set({"ext:qtip":_STR("clientinfo","client_serversync")})}}},{xtype:"syno_displayfield",cls:"syno-cstn-client-panel-value",name:"client_count_sharesync",value:"-"}]},{xtype:"spacer",width:40},{cls:"syno-cstn-client-panel-box",items:[{xtype:"container",cls:"syno-cstn-client-icon-desktop"},{xtype:"container",cls:"syno-cstn-client-panel-title",html:_STR("clientinfo","client_drive"),listeners:{render:function(e){e.getEl().set({"ext:qtip":_STR("clientinfo","client_drive")})}}},{xtype:"syno_displayfield",cls:"syno-cstn-client-panel-value",name:"client_count_desktop",value:"-"}]},{xtype:"spacer",width:40},{cls:"syno-cstn-client-panel-box",items:[{xtype:"container",cls:"syno-cstn-client-icon-mobile"},{xtype:"container",cls:"syno-cstn-client-panel-title",html:_STR("clientinfo","client_mobile"),listeners:{render:function(e){e.getEl().set({"ext:qtip":_STR("clientinfo","client_mobile")})}}},{xtype:"syno_displayfield",cls:"syno-cstn-client-panel-value",name:"client_count_mobile",value:"-"}]},{xtype:"spacer",width:21}]}},changeButtonList:function(e){this.callParent([this.getButtonListConfig(e)])}}),Ext.define("SYNO.SDS.CSTN.PanelLastOnline",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t=[{id:"client_type",header:_STR("clientinfo","client_type"),dataIndex:"client_type",align:"left",sortable:!1,flex:1,renderer:function(e){return{drive:_STR("clientinfo","client_drive"),drive_backup:_STR("clientinfo","client_drive"),drive_mobile:_STR("clientinfo","client_drive_mobile"),backup:_STR("clientinfo","client_backup"),ds_cloud:_STR("clientinfo","client_ds_cloud"),cloudstation:_STR("clientinfo","client_cloudstation"),sharesync:_STR("clientinfo","client_sharesync"),serversync:_STR("clientinfo","client_serversync"),unknown:"--"}[e]}},{id:"client_id",header:_STR("cstn","device_name"),dataIndex:"client_id",align:"left",flex:1,sortable:!1},{id:"client_name",header:_STR("common","usrname"),dataIndex:"client_name",align:"left",flex:1,sortable:!1},{id:"last_auth_time",header:_STR("cstn","last_online_time"),dataIndex:"last_auth_time",align:"left",renderer:function(e,t,i){return 0===e?_STR("common","no_data"):"on_line"==i.get("client_status")?_STR("clientinfo","connected"):SYNO.SDS.CSTN.RenderLastDays(e,t)},flex:1,sortable:!1},{id:"client_padding",header:"",dataIndex:"",width:16,fixed:!0,sortable:!1}],i=new Ext.grid.ColumnModel({columns:t}),n=this.createStore();n.on("load",function(e,t,i){0===t.length?this.el.select(".x-grid3-header").addClass("hide-headers"):this.el.select(".x-grid3-header").removeClass("hide-headers")}.bind(this));var s={bodyStyle:"padding-bottom: 3px;",cls:"syno-cstn-last-online-panel",itemId:"client",view:new SYNO.ux.FleXcroll.grid.GridView({emptyText:_STR("empty","sync_client")}),stripeRows:!1,enableColLock:!1,enableHdMenu:!1,disableSelection:!0,enableColumnResize:!1,colModel:i,ds:n,loadMask:!0,height:228};return SYNO.LayoutConfig.fill(s),Ext.apply(s,e),s},createStore:function(){var e=["client_id","client_name","client_status","client_type","last_auth_time"],t=new SYNO.API.Store({pruneModifiedRecords:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Connection.api,version:1,method:"list",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"items",totalProperty:"total",idProperty:"id"},e),paramNames:{start:"offset",limit:"limit",sort:"sort_by",dir:"sort_direction"},baseParams:{offset:0,limit:50,sort_by:"last_auth_time",sort_direction:"ASC",exclude_client_types:["drive_mobile"]},remoteSort:!0});return this.addManagedComponent(t),t},onPageActivate:function(){this.headerBtnWrap&&this.headerBtnWrap.remove(),this.store.load()}}),Ext.define("SYNO.SDS.CSTN.GridPanelTopFiles",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t=[{id:"file_index",dataIndex:"file",align:"left",sortable:!1,width:53,fixed:!0,renderer:function(e,t,i,n){return String.format('<div class="syno-cstn-file-string syno-cstn-file-index">{0}</div><div class="syno-cstn-file-icon" style="background-image:url({1});"></div>',n+1,this.owner.jsConfig.jsBaseURL+SYNO.SDS.CloudStation.getIconPath(e.name,"dir"===e.type))}.bind(this)},{id:"file_name",dataIndex:"file",align:"left",sortable:!1,flex:1,renderer:function(e,t,i,n){return t.attr+=String.format('ext:qtip="{0}"',Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(e.name))),Ext.util.Format.htmlEncode(e.name)}.bind(this)},{id:"file_folder",dataIndex:"file",align:"left",sortable:!1,flex:1,renderer:function(e,t,i,n){var s=e.full_path.substring(0,e.full_path.lastIndexOf("/"));return t.attr+=String.format('ext:qtip="{0}"',Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(s))),Ext.util.Format.htmlEncode(s)}},{id:"count",dataIndex:"count",width:125,align:"left",fixed:!0,sortable:!1,renderer:function(e,t,i,n){var s="",o='<div class="syno-cstn-top-file-tooltip"> <p class="syno-cstn-top-file-tooltip-left">'+_STR("cstn","previews")+_T("common","colon")+'</p> &nbsp; <p class="syno-cstn-top-file-tooltip-right">'+i.data.file.preview_count+"</p> </div>",a='<div class="syno-cstn-top-file-tooltip"> <p class="syno-cstn-top-file-tooltip-left">'+_STR("cstn","downloads")+_T("common","colon")+'</p> &nbsp; <p class="syno-cstn-top-file-tooltip-right">'+i.data.file.download_count+"</p> </div>";switch(this.getType()){case"preview":s+=o;break;case"download":s+=a;break;case"both":s+=o,s+=a}return t.attr+=String.format('ext:qtip="{0}"',Ext.util.Format.htmlEncode(s)),Ext.util.Format.htmlEncode(e)}.bind(this)},{id:"padding",width:0,fixed:!0,sortable:!1}],i=new Ext.grid.ColumnModel({columns:t}),n=this.createStore();this.ds_rank=new Ext.data.JsonStore({fields:["display","value","log_type"],data:[{display:_STR("cstn","previews_and_downloads"),value:"both",log_type:[SYNO.SDS.CSTN.LogType.download_event,SYNO.SDS.CSTN.LogType.preview_event]},{display:_STR("cstn","downloads"),value:"download",log_type:[SYNO.SDS.CSTN.LogType.download_event]},{display:_STR("cstn","previews"),value:"preview",log_type:[SYNO.SDS.CSTN.LogType.preview_event]}]}),this.rank_combo=new SYNO.ux.ComboBox({ctCls:"syno-cstn-grid syno-cstn-grid-combo",name:"combo_share",mode:"local",hideLabel:!1,editable:!1,store:this.ds_rank,displayField:"display",valueField:"value",triggerAction:"all",value:"both",width:340,height:38,hidden:!1,listeners:{scope:this,select:function(e,t,i){this.loadData()}}}),this.ds_time=new Ext.data.JsonStore({fields:["display","value"],data:[{display:String.format(_STR("cstn","last_hours"),"24"),value:1},{display:String.format(_STR("cstn","last_days"),"7"),value:7},{display:String.format(_STR("cstn","last_days"),"30"),value:30}]}),this.time_combo=new SYNO.ux.ComboBox({ctCls:"syno-cstn-grid syno-cstn-grid-combo",name:"combo_share",mode:"local",hideLabel:!1,editable:!1,store:this.ds_time,displayField:"display",valueField:"value",triggerAction:"all",value:1,width:180,height:28,hidden:!1,listeners:{scope:this,select:function(e,t,i){this.loadData()}}});var s=new Ext.Toolbar;s.add({xtype:"syno_displayfield",
value:_STR("cstn","ranking_by")+_T("common","colon")}),s.add(" "),s.add(this.rank_combo),s.add("->"),s.add(this.time_combo);var o={cls:"syno-cstn-top-file-panel",itemId:"client",view:new SYNO.ux.FleXcroll.grid.GridView({emptyText:_STR("common","no_data")}),hideHeaders:!0,tbar:s,stripeRows:!1,enableColLock:!1,enableHdMenu:!1,disableSelection:!0,colModel:i,ds:n,autoExpandColumn:"file_folder",loadMask:!0,sm:new Ext.grid.RowSelectionModel({singleSelect:!0}),listeners:{cellclick:function(e,t,i,n){if(1===i){var s=e.getStore().data.items[t].data,o=this.rank_combo.getStore().find("value",this.rank_combo.getValue());this.owner.setPreConfig("SYNO.SDS.CSTN.PanelLog",{keyword:s.file.name,username:"anonymous",types:this.rank_combo.getStore().getAt(o).data.log_type}),this.owner.selectPage("SYNO.SDS.CSTN.PanelLog")}}}};return SYNO.LayoutConfig.fill(o),Ext.apply(o,e),o},createStore:function(){var e=["count","file"],t=new SYNO.API.Store({pruneModifiedRecords:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Dashboard.api,version:1,method:"top_access_files",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"files",totalProperty:"total",idProperty:"id"},e),paramNames:{start:"offset",limit:"limit"},baseParams:{offset:0,limit:50,ranking_by:"both",period_days:1},remoteSort:!0});return this.addManagedComponent(t),t},onPageActivate:function(){this.headerBtnWrap&&this.headerBtnWrap.remove(),this.loadData()},loadData:function(){this.store.setBaseParam("period_days",this.time_combo.getValue()),this.store.setBaseParam("ranking_by",this.rank_combo.getValue()),this.store.load()},getType:function(){return this.rank_combo.getValue()}}),Ext.define("SYNO.SDS.CSTN.Overview.PanelDatabaseUsage",{extend:"SYNO.SDS.CSTN.Overview.Panel",constructor:function(e){this.callParent(arguments),this.getEchartsPromise()},getEchartsPromise:function(){return this.echartsPromise?this.echartsPromise:this.echartsPromise=new Promise(function(e,t){if("undefined"!=typeof echarts)return void e();var i=document.createElement("script");i.onload=e,i.onerror=t,i.async=!0,i.type="text/javascript",i.src="webman/3rdparty/SynologyDrive/echarts.min.js",document.head.appendChild(i)})},getTitleConfig:function(){},getTitleItems:function(){return[{xtype:"container",html:_STR("cstn","server_usage_trend"),cls:"syno-cstn-database-panel-title",listeners:{afterrender:function(e){var t=_STR("cstn","usage_trend_tooltip");SYNO.ux.AddTip?SYNO.ux.AddTip(this.getEl(),t):SYNO.SDS.Utils.AddTip&&SYNO.SDS.Utils.AddTip(this.getEl(),t)}}}]},getButtonListConfig:function(e){return[{xtype:"syno_button",tooltip:String.format(_STR("cstn","tooltip_goto_other_tab"),_STR("func","database_title")),cls:"syno-cstn-jumpto-icon",scope:this,handler:function(){this.owner.selectPage("SYNO.SDS.CSTN.PanelConfigure")}.bind(this)}]},updateData:function(e,t){e.database.length>0&&(Ext.getCmp(this.usageTitleId).setVisible(!0),Ext.getCmp(this.usageTextId).setValue(String.format(_STR("cstn","usage"),SYNO.SDS.CSTN.GetFileSizeUnits()[t])),this.epsChart.updateData(e,t))},getContentConfig:function(){this.epsChart=new SYNO.SDS.CSTN.EchartsPanel({collapsible:!1,flex:1,height:200,hideMode:"offsets"},this.getEchartsPromise());var e={xtype:"container",cls:"syno-cstn-database-panel-right",flex:5,items:[{xtype:"container",cls:"syno-cstn-database-panel-right-dot",style:"background-color: "+SYNO.SDS.CSTN.EchartsPanel.setting.repo.lightColor},{xtype:"syno_displayfield",html:String.format('<span ext:qtip="{0}">{1}</span>',Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(SYNO.SDS.CSTN.EchartsPanel.setting.repo.tip)),Ext.util.Format.htmlEncode(SYNO.SDS.CSTN.EchartsPanel.setting.repo.name)),cls:"syno-cstn-database-panel-right-item"},{xtype:"container",cls:"syno-cstn-database-panel-right-dot",style:"background-color: "+SYNO.SDS.CSTN.EchartsPanel.setting.database.lightColor},{xtype:"syno_displayfield",html:String.format('<span ext:qtip="{0}">{1}</span>',Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(SYNO.SDS.CSTN.EchartsPanel.setting.database.tip)),Ext.util.Format.htmlEncode(SYNO.SDS.CSTN.EchartsPanel.setting.database.name)),cls:"syno-cstn-database-panel-right-item"}]};return SYNO.SDS.CSTN.HasOffice()&&e.items.push({xtype:"container",cls:"syno-cstn-database-panel-right-dot",style:"background-color: "+SYNO.SDS.CSTN.EchartsPanel.setting.office.lightColor},{xtype:"syno_displayfield",html:String.format('<span ext:qtip="{0}">{1}</span>',Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(SYNO.SDS.CSTN.EchartsPanel.setting.office.tip)),Ext.util.Format.htmlEncode(SYNO.SDS.CSTN.EchartsPanel.setting.office.name)),cls:"syno-cstn-database-panel-right-item"}),config={xtype:"container",cls:"syno-cstn-database-panel-container",flex:1,items:[{xtype:"container",height:22,id:this.usageTitleId=Ext.id(),hidden:!0,layout:{type:"hbox",align:"stretch"},defaults:{flex:1},items:[{xtype:"syno_displayfield",id:this.usageTextId=Ext.id(),value:String.format(_STR("cstn","usage"),SYNO.SDS.CSTN.GetFileSizeUnits()[0]),cls:"syno-cstn-database-panel-left",flex:2},e]},this.epsChart]},config},changeButtonList:function(e){this.callParent([this.getButtonListConfig(e)])}}),Ext.define("SYNO.SDS.CSTN.EchartsPanel",{extend:"Ext.Panel",statics:{setting:{repo:{name:"",tip:"",darkColor:"#FAAF00",lightColor:"#FAAF00"},database:{name:"",tip:"",darkColor:"#00BFBF",lightColor:"#00BFBF"},office:{name:"",tip:"",darkColor:"#3399FF",lightColor:"#3399FF"}},seriesTemplate:{type:"line",showSymbol:!1,itemStyle:{normal:{borderWidth:4}},lineStyle:{normal:{width:2}}},styleGuide:{FONT_FAMILY:SYNO.SDS.CSTN.UIGuidelineStyle.FONT_FAMILY,COLOR_FONT_TIER1:SYNO.SDS.CSTN.UIGuidelineStyle.COLOR_FONT_TIER1,COLOR_FONT_TIER2:SYNO.SDS.CSTN.UIGuidelineStyle.COLOR_FONT_TIER2,COLOR_BORDER_TIER1:SYNO.SDS.CSTN.UIGuidelineStyle.COLOR_BORDER_TIER1,COLOR_BORDER_TIER2:SYNO.SDS.CSTN.UIGuidelineStyle.COLOR_BORDER_TIER2,COLOR_BORDER_TIER3:SYNO.SDS.CSTN.UIGuidelineStyle.COLOR_BORDER_TIER3}},constructor:function(e,t){SYNO.SDS.CSTN.EchartsPanel.setting.repo.name=_STR("cstn","historical_version"),SYNO.SDS.CSTN.EchartsPanel.setting.repo.tip=_STR("cstn","historical_version_desc"),SYNO.SDS.CSTN.EchartsPanel.setting.database.name=_STR("cstn","app_database"),SYNO.SDS.CSTN.EchartsPanel.setting.database.tip=_STR("cstn","app_database_desc"),SYNO.SDS.CSTN.EchartsPanel.setting.office.name=_STR("cstn","synology_office"),SYNO.SDS.CSTN.EchartsPanel.setting.office.tip=_STR("cstn","synology_office_desc"),this.echartsPromise=t;var i={border:!1,cls:"syno-cstn-database-panel-echarts"};this.echartsOption={backgroundColor:"#FFFFFF",tooltip:{axis:"x",backgroundColor:"#FFFFFF",borderColor:SYNO.SDS.CSTN.EchartsPanel.styleGuide.COLOR_BORDER_TIER1,borderRadius:3,borderWidth:1,padding:[6,10],transitionDuration:0,trigger:"axis",confine:!0,axisPointer:{lineStyle:{color:[SYNO.SDS.CSTN.EchartsPanel.styleGuide.COLOR_BORDER_TIER1]}},extraCssText:"box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);",formatter:function(e){var t=e[0].axisValue,i='<div class="syno-cstn-usage-trend-tooltip">';return i+='<div class="syno-cstn-usage-trend-tooltip-title">'+this.convertEpochTime(t)+", "+new Date(t).getUTCFullYear()+"</div>",e.forEach(function(e){var t=e.seriesName,n=e.data[1],s=e.color;i+='<div> <p class="syno-cstn-usage-trend-tooltip-left">'+t+_T("common","colon")+'</p> <p class="syno-cstn-usage-trend-tooltip-right" style="color:'+s+'">'+this.formatSize(n)+"</p> </div> <br>"}.bind(this)),i+="</div>"}.bind(this)},grid:{backgroundColor:"#FAFCFF",borderColor:SYNO.SDS.CSTN.EchartsPanel.styleGuide.COLOR_BORDER_TIER2,top:10,bottom:2,left:18,right:0,containLabel:!0},xAxis:{min:(new Date).getTime()-2592e6,max:(new Date).getTime(),axisLine:{show:!1},axisTick:{show:!1},splitLine:!1,type:"time",boundaryGap:!1,axisLabel:{color:SYNO.SDS.CSTN.EchartsPanel.styleGuide.COLOR_FONT_TIER1,fontSize:12,fontFamily:SYNO.SDS.CSTN.EchartsPanel.styleGuide.FONT_FAMILY,formatter:function(e){return this.convertEpochTime(parseInt(e))}.bind(this),showMaxLabel:!1}},yAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:[SYNO.SDS.CSTN.EchartsPanel.styleGuide.COLOR_BORDER_TIER3]}},axisLabel:{color:SYNO.SDS.CSTN.EchartsPanel.styleGuide.COLOR_FONT_TIER1,fontSize:12,fontFamily:SYNO.SDS.CSTN.EchartsPanel.styleGuide.FONT_FAMILY,formatter:function(e){return(parseInt(e)/this.yDivisor).toFixed(1)}.bind(this)}},series:[]},this.echartsOption.series.push(this.getSeriesConfig("repo")),this.echartsOption.series.push(this.getSeriesConfig("database")),this.hasOffice=SYNO.SDS.CSTN.HasOffice(),this.hasOffice&&this.echartsOption.series.push(this.getSeriesConfig("office")),this.yDivisor=1,this.option={title:{show:!0,textStyle:{color:SYNO.SDS.CSTN.EchartsPanel.styleGuide.COLOR_FONT_TIER2,fontSize:13,fontWeight:"normal",fontFamily:SYNO.SDS.CSTN.EchartsPanel.styleGuide.FONT_FAMILY},text:_STR("common","no_data"),left:"center",top:"center"},xAxis:{show:!1},yAxis:{show:!1},series:[]},Ext.apply(i,e),this.callParent([i])},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){this.collapsed||this.drawChart()},this),this.mon(this,"expand",function(){this.drawChart()},this)},updateData:function(e,t){this.option=this.echartsOption,this.yDivisor=Math.pow(1024,t),1===e.database.length&&this.echartsOption.series.forEach(function(t){1===e.database.length?t.showSymbol=!0:t.showSymbol=!1}),this.echartsOption.series[0].data=e.repo,this.echartsOption.series[1].data=e.database,this.hasOffice&&(this.echartsOption.series[2].data=e.office),this.drawChart()},drawChart:function(){this.echartsPromise.then(this._drawChart.bind(this)).catch()},_drawChart:function(){if(this.collapsed||this.isDestroyed)return!0;this.chartInstance||(this.chartInstance=echarts.init(this.body.dom)),this.chartInstance.resize(),this.chartInstance.setOption(this.option,!0)},convertEpochTime:function(e){var t,i="";return Ext.isNumber(e)?(t=new Date(e),i+=String.format(_STR("date","month_day"),_STR("date","mon_"+(t.getMonth()+1)),t.getDate())):i},formatSize:function(e){for(var t=0;e>=1024;)t++,e/=1024;return e.toFixed(1)+" "+SYNO.SDS.CSTN.GetFileSizeUnits()[t]},getSeriesConfig:function(e){var t=JSON.parse(JSON.stringify(SYNO.SDS.CSTN.EchartsPanel.seriesTemplate));return t.name=SYNO.SDS.CSTN.EchartsPanel.setting[e].name,t.itemStyle.normal.color=SYNO.SDS.CSTN.EchartsPanel.setting[e].lightColor,t.lineStyle.normal.color=SYNO.SDS.CSTN.EchartsPanel.setting[e].darkColor,t}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PanelClient",{extend:"SYNO.ux.GridPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin;var t=this.fillConfig(e);this.callParent([t]);var i=function(e){return e.every(function(e){return"wipe"!==e.data.client_status})},n=function(e){return e.every(function(e){return"wipe"===e.data.client_status})};this.getSelectionModel().on("rowselect",function(e){if(0!==e.getCount()&&!this._S("demo_mode")){var t=i(this.getSelectionModel().getSelections());this.getTopToolbar().getComponent("btnUnlink").setDisabled(!t);var s=n(this.getSelectionModel().getSelections());this.getTopToolbar().getComponent("btnDelete").setVisible(s)}},this),this.getSelectionModel().on("rowdeselect",function(e){if(0===e.getCount())this.getTopToolbar().getComponent("btnUnlink").disable(),this.getTopToolbar().getComponent("btnDelete").setVisible(!1);else{var t=i(this.getSelectionModel().getSelections());this.getTopToolbar().getComponent("btnUnlink").setDisabled(!t);var s=n(this.getSelectionModel().getSelections());this.getTopToolbar().getComponent("btnDelete").setVisible(s)}},this),this.getStore().on("beforeload",function(){this.getTopToolbar().getComponent("btnUnlink").disable(),this.getTopToolbar().getComponent("btnDelete").setVisible(!1)},this)},fillConfig:function(e){var t;this.pageSize=50,t=!this._S("is_admin");var i=[{id:"client_id",header:_STR("clientinfo","title_id"),tooltip:_STR("clientinfo","title_id"),dataIndex:"client_id",align:"left",width:150,sortable:!0},{id:"client_name",header:_STR("common","usrname"),tooltip:_STR("common","usrname"),dataIndex:"client_name",align:"left",hidden:t,width:120,sortable:!0},{id:"client_type",header:_STR("clientinfo","client_type"),tooltip:_STR("clientinfo","client_type"),dataIndex:"client_type",align:"left",sortable:!0,width:130,renderer:function(e){return{drive:_STR("clientinfo","client_drive"),drive_backup:_STR("clientinfo","client_drive"),drive_mobile:_STR("clientinfo","client_drive_mobile"),backup:_STR("clientinfo","client_backup"),ds_cloud:_STR("clientinfo","client_ds_cloud"),cloudstation:_STR("clientinfo","client_cloudstation"),sharesync:_STR("clientinfo","client_sharesync"),serversync:_STR("clientinfo","client_serversync"),unknown:"--"}[e]}},{id:"client_version",header:_STR("clientinfo","client_version"),tooltip:_STR("clientinfo","client_version"),dataIndex:"client_version",align:"left",width:120,sortable:!0},{id:"last_auth_time",header:_STR("clientinfo","title_lastconnectedtime"),tooltip:_STR("clientinfo","title_lastconnectedtime"),dataIndex:"last_auth_time",align:"left",renderer:function(e,t,i){var n=i.get("client_status");return"off_line"===n||"incompatible"===n?0===e?"":SYNO.SDS.CSTN.RenderTime(e,t):_STR("clientinfo","lastconnectedtime_online")},width:130,sortable:!0},{id:"client_status",header:_STR("clientinfo","syncing_status"),tooltip:_STR("clientinfo","syncing_status"),dataIndex:"client_status",align:"left",renderer:function(e){return{off_line:_STR("clientinfo","disconnected"),on_line:'<span class="green-status">'+_STR("clientinfo","connected")+"</span>",syncing:'<span class="blue-status">'+_STR("clientinfo","syncing")+"</span>",wipe:'<span class="red-status">'+_STR("clientinfo","wiped")+"</span>",incompatible:String.format('<span class="red-status" ext:qtip="{0}">{1}</span>',_STR("clientinfo","incompatible_tip"),_STR("clientinfo","incompatible"))}[e]},width:130,sortable:!0},{id:"client_ip",header:_STR("clientinfo","last_ip"),tooltip:_STR("clientinfo","last_ip"),align:"left",dataIndex:"client_ip",width:130,sortable:!0},{id:"client_location",header:_STR("clientinfo","client_location"),tooltip:_STR("clientinfo","client_location"),align:"left",dataIndex:"client_location",width:130,sortable:!0},{id:"client_session_id",dataIndex:"client_session_id",hidden:!0,sortable:!0},{id:"client_is_relay",dataIndex:"client_is_relay",hidden:!0,sortable:!0}],n=new Ext.grid.ColumnModel({columns:i}),s=this.createStore(),o=new Ext.Toolbar,a=new SYNO.ux.TextFilter({itemId:"search",emptyText:_STR("btn","search"),store:s,pageSize:this.pageSize,queryAction:"query"});o.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnUnlink",text:_STR("clientinfo","action_unlink"),handler:this.onUnlinkClient,scope:this}),o.add({xtype:"syno_button",ctCls:"syno-cstn-tab-btn",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnRefres",text:_STR("btn","refresh"),handler:this.onRefresh,scope:this}),o.add({xtype:"syno_button",ctCls:"syno-cstn-tab-btn",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnDelete",text:_STR("action","remove"),handler:this.onDeleteClient,hidden:!0,scope:this}),o.add({xtype:"syno_button",ctCls:"syno-cstn-tab-btn",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnKeyManagement",text:_STR("userkey","userkey_titile"),handler:this.onClickKeyManagement,hidden:!0,scope:this}),o.add("->"),o.add(a);var l=new SYNO.ux.PagingToolbar({cls:"cstn-paging-toolbar",store:s,pageSize:this.pageSize,displayInfo:!0,emptyMsg:"",owner:this}),r={cls:"syno-cstn-panel-padding",itemId:"client",tbar:o,stripeRows:!0,enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,colModel:n,ds:s,view:new SYNO.SDS.CSTN.FleXcroll.GridView({store:s,searchFields:[a]}),sm:new Ext.grid.RowSelectionModel({singleSelect:!1}),autoExpandColumn:"last_auth_time",loadMask:!0,bbar:l};return SYNO.LayoutConfig.fill(r),Ext.apply(r,e),r},createStore:function(){var e=["client_id","client_name","last_auth_time","client_status","client_session_id","client_ip","client_is_relay","client_type","client_version","client_can_wipe","client_location","device_uuid"];return this.store=new SYNO.API.Store({pruneModifiedRecords:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Connection.api,version:1,method:"list",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"items",totalProperty:"total",idProperty:"id"},e),sortInfo:{field:"last_auth_time",direction:"DESC"},paramNames:{start:"offset",limit:"limit",sort:"sort_by",dir:"sort_direction"},baseParams:{offset:0,limit:this.pageSize,sort_by:"last_auth_time",sort_direction:"DESC"},listeners:{scope:this,exception:function(e,t,i,n,s){s&&s.code&&this.owner.getMsgBox().alert(_STR("app","app_name"),SYNO.SDS.CSTN.getErrorString(s))}},remoteSort:!0}),this.addManagedComponent(this.store),this.store},applyDisconnect:function(e){this.owner.setStatusBusy();var t=this.getSelectionModel().getSelections(),i=[];Ext.each(t,function(e){i.push(e.get("client_session_id"))}),SYNO.SDS.CSTN.WebAPI.Connection.delete.call(this.owner,i,e,this.ajaxCheckSrvStatusCB,this)},ajaxCheckSrvStatusCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:SYNO.SDS.CSTN.cbLoad,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},checkSrvStatus:function(){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.checkUser.call(this.owner,this.ajaxCheckSrvStatusCB,this)},onPageActivate:function(){this.checkSrvStatus()},onActivate:function(){this.onPageActivate()},onUnlinkClient:function(){var e=this.getSelectionModel().getSelections().map(function(e){return e.data.client_id?e.data.client_id:e.data.client_ip}),t=this.getSelectionModel().getSelections().filter(function(e){return e.data.client_can_wipe}).map(function(e){return e.data.client_id?e.data.client_id:e.data.client_ip}),i=t.join(_STR("common","comma"));if(SYNO.SDS.CSTN.Config.advanced_feature_activated){var n=new SYNO.SDS.CSTN.ConfirmMessageboxWithCheckbox({module:this,owner:this.owner,custom_title:_STR("warning","msg_confirm_unlink"),custom_message:e.join(_STR("common","comma")),show_checkbox:0!==t.length,checkbox_message:_STR("warning","msg_wipedata"),checkbox_description:String.format(_STR("warning","msg_wipedata_desc"),"<b>"+i+"</b>"),fn:function(e,t){return"yes"!==e||(t?(new SYNO.SDS.MessageBoxV5({owner:n,cls:"syno-cstn-client-panel-double-confirm-dialog",boxMaxWidth:480,listeners:{scope:this,render:function(e){e&&e.msgEl&&e.msgEl.set({"ext:qtip":i})}}}).confirmDelete(_STR("warning","msg_confirm_wipe_title"),_STR("warning","msg_confirm_wipe")+"<br><br>"+i,function(e){"yes"===e&&(this.applyDisconnect(!0),n.close())},this,{yes:{text:_STR("btn","btn_wipe"),btnStyle:"red"},no:{text:_T("common","cancel")}},{useMessageTitle:!0}),!1):(this.applyDisconnect(!1),!0))}.bind(this)});n.open()}else{var s=Ext.util.Format.htmlEncode(e.join(_STR("common","comma"))),o=String.format('<div class="syno-scn-remote-wipe-messagebox-activate-hint"><span class="syno-ux-note">{0}</span> {1}</div>',_STR("common","note")+_STR("common","colon"),String.format(_STR("activate_advance_feature","toast_must_be_activated_before_modifying_option"),"",'<a id="'+(this.gotoActivateId=Ext.id())+'">'+_STR("func","mgr_advance_feature")+"</a>")),a='<div class="syno-cstn-remote-wipe-messagebox-custom-title">'+_STR("warning","msg_confirm_unlink")+"</div>"+s+"<br>"+o,n=this.owner.getMsgBox();n.show({width:420,height:282,title:"",msg:a,buttons:{ok:_T("common","ok"),cancel:_T("common","cancel")},fn:function(e){if("ok"===e)return this.applyDisconnect(!1),!0},scope:this}),Ext.get(this.gotoActivateId).on("click",function(){n.hide(),SYNO.SDS.AppLaunch("SYNO.SDS.CSTN.Instance",{owner:this,fn:"SYNO.SDS.CSTN.PanelAdvancedFeature"})})}},onRefresh:function(){this.checkSrvStatus()},onDeleteClient:function(){var e=this.getSelectionModel().getSelections().map(function(e){return e.data.client_id?e.data.client_id:e.data.client_ip});new SYNO.SDS.CSTN.ConfirmMessageboxWithCheckbox({module:this,owner:this.owner,custom_title:_STR("warning","msg_confirm_delete"),custom_message:e.join(_STR("common","comma")),fn:function(e){return"yes"===e&&this.applyDisconnect(!1),!0}.bind(this)}).open()},onClickKeyManagement:function(){new SYNO.SDS.CSTN.KeyManagement.MainWindow({owner:this.owner}).open()}}),Ext.define("SYNO.SDS.CSTN.ConfirmMessageboxWithCheckbox",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.checked=!1,this.fn=e.fn;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={cls:"syno-cstn-confirm-messagebox-checkbox",xtype:"syno_formpanel",padding:"0px",items:[{xtype:"syno_displayfield",name:"title",value:e.custom_title,itemCls:"custom-title",htmlEncode:!1},{xtype:"syno_displayfield",name:"message",value:e.custom_message,itemCls:"custom-message",htmlEncode:!1,listeners:{render:function(t){t.getEl().set({"ext:qtip":e.custom_message})}}}]};e.show_checkbox&&t.items.push({xtype:"spacer",height:12},{xtype:"syno_checkbox",boxLabel:e.checkbox_message,name:"checkbox",htmlEncode:!1,listeners:{check:{scope:this,fn:this.onCheckboxCheck}}},{xtype:"syno_displayfield",indent:1,name:"message",value:e.checkbox_description,itemCls:"checkbox-message",htmlEncode:!1,listeners:{render:function(t){t.getEl().set({"ext:qtip":e.checkbox_description})}}});var i={cls:"x-window-dlg",layout:"fit",padding:"24px 30px 0",elements:"body",bodyStyle:"max-height: 260px;",width:540,autoScroll:!0,autoHeight:!0,header:!1,closable:!1,resizable:!1,draggable:!1,fbar:["->",{xtype:"syno_button",itemId:"cancel",text:_T("common","cancel"),scope:this,handler:this.onCancel},{xtype:"syno_button",text:e.action_message?e.action_message:_T("common","ok"),itemId:"apply",btnStyle:"blue",scope:this,handler:this.onConfirm}],items:[t]};return Ext.apply(i,e),i},onCheckboxCheck:function(e,t){this.checked=t},onConfirm:function(){this.fn("yes",this.checked)&&this.close()},onCancel:function(){this.fn("no")&&this.close()}}),Ext.define("SYNO.SDS.CSTN.PanelSearch",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.dateType={custom:1,today:2,yesterday:4,lastweek:8,lastmonth:16},this.dataRange=[[this.dateType.custom,_STR("log","date_custom")],[this.dateType.today,_STR("log","date_today")],[this.dateType.yesterday,_STR("log","date_yesterday")],[this.dateType.lastweek,_STR("log","date_lastweek")],[this.dateType.lastmonth,_STR("log","date_lastmonth")]],this.logType=SYNO.SDS.CSTN.LogType,this.logEvent=SYNO.SDS.CSTN.LogEvent,this.logDescEvent=[[this.logEvent.files,_STR("log","log_event_files"),"log_files"],[this.logEvent.sharing,_STR("log","log_event_sharing"),"log_sharing"],[this.logEvent.service,_STR("log","log_event_service"),"log_service"],[this.logEvent.admin_action,_STR("log","log_event_admin_action"),"log_admin_action"]],this.logTypeTree=[{text:_STR("log","log_event_files"),id:"log_event_files",children:[{text:_STR("log","log_type_add_event"),id:"log_type_add_event",logType:this.logType.add_event},{text:_STR("log","log_type_remove_event"),id:"log_type_remove_event",logType:this.logType.remove_event},{text:_STR("log","log_type_modify_event"),id:"log_type_modify_event",logType:this.logType.modify_event},{text:_STR("log","log_type_rename_event"),id:"log_type_rename_event",logType:this.logType.rename_event},{text:_STR("log","log_type_version_rotate"),id:"log_type_version_rotate",logType:this.logType.version_rotate},{text:_STR("log","log_type_copy_event"),id:"log_type_copy_event",logType:this.logType.copy_event},{text:_STR("log","log_type_download_event"),id:"log_type_download_event",logType:this.logType.download_event},{text:_STR("log","log_type_preview_event"),id:"log_type_preview_event",logType:this.logType.preview_event},{text:_STR("log","log_type_restore_node"),id:"log_type_restore_node",logType:this.logType.restore_node},{text:_STR("log","log_type_delfile_forever"),id:"log_type_delfile_forever",logType:this.logType.delfile_forever},{text:_STR("log","log_type_share_save"),id:"log_type_share_save",logType:this.logType.share_save},{text:_STR("log","log_type_restore_a_copy_event"),id:"log_type_restore_a_copy_event",logType:this.logType.restore_a_copy_event},{text:_STR("log","log_type_delete_from_bin_event"),id:"log_type_delete_from_bin_event",logType:this.logType.delete_from_bin_event},{text:_STR("log","log_type_restore_from_bin_event"),id:"log_type_restore_from_bin_event",logType:this.logType.restore_from_bin_event},{text:_STR("log","log_type_manual_file_lock"),id:"log_type_file_lock",logType:this.logType.file_lock},{text:_STR("log","log_type_manual_file_unlock"),id:"log_type_file_unlock",logType:this.logType.file_unlock}]},{text:_STR("log","log_event_sharing"),id:"log_event_sharing",children:[{text:_STR("log","log_type_changed_link_perm"),id:"log_type_changed_link_perm",logType:this.logType.normal_link_permission},{text:_STR("log","log_type_save_adv_link"),id:"log_type_save_adv_link",logType:this.logType.adv_link_create},{text:_STR("log","log_type_allow_download_link"),id:"log_type_allow_download_link",logType:this.logType.normal_link_download},{text:_STR("log","log_type_allow_download_adv_link"),id:"log_type_allow_download_adv_link",logType:this.logType.adv_link_download},{text:_STR("log","log_type_set_pass_adv_link"),id:"log_type_set_pass_adv_link",logType:this.logType.adv_link_password},{text:_STR("log","log_type_set_expiration_adv_link"),id:"log_type_set_expiration_adv_link",logType:this.logType.adv_link_expiration},{text:_STR("log","log_type_set_invitee_link"),id:"log_type_set_invitee_link",logType:this.logType.normal_link_invitee},{text:_STR("log","log_type_save_file_request"),id:"log_type_save_file_request",logType:this.logType.file_request_create},{text:_STR("log","log_type_receive_file_request"),id:"log_type_receive_file_request",logType:this.logType.file_request_receive_file},{text:_STR("log","log_type_set_status_file_request"),id:"log_type_set_status_file_request",logType:this.logType.file_request_status},{text:_STR("log","log_type_enable_disable_file_request"),id:"log_type_enable_disable_file_request",logType:this.logType.file_request_enable_disable},{text:_STR("log","log_type_enable_disable_internal_sharing"),id:"log_type_enable_disable_internal_sharing",logType:this.logType.internal_sharing_enable_disable},{text:_STR("log","log_type_enable_disable_public_sharing"),id:"log_type_enable_disable_public_sharing",logType:this.logType.public_sharing_enable_disable},{text:_STR("log","log_type_grant_file_request_permission"),id:"log_type_grant_file_request_permission",logType:this.logType.grant_file_request_permission},{text:_STR("log","log_type_grant_public_sharing_permission"),id:"log_type_grant_public_sharing_permission",logType:this.logType.grant_public_sharing_permission},{text:_STR("log","log_type_create_delete_shared_label"),id:"log_type_create_delete_shared_label",logType:this.logType.create_delete_shared_label},{text:_STR("log","log_type_enable_disable_shared_label"),id:"log_type_enable_disable_shared_label",logType:this.logType.enable_disable_shared_label},{text:_STR("log","log_type_change_shared_label_setting"),id:"log_type_change_shared_label_setting",logType:this.logType.change_shared_label_setting}]},{text:_STR("log","log_event_service"),id:"log_event_service",children:[{text:_STR("log","log_type_drive_save"),id:"log_type_drive_save",logType:this.logType.cloudstn_save},{text:_STR("log","log_type_client_link"),id:"log_type_client_link",logType:this.logType.client_link},{text:_STR("log","log_type_client_unlink"),id:"log_type_client_unlink",logType:this.logType.client_unlink},{text:_STR("log","log_type_client_wipe_started"),id:"log_type_client_wipe_started",logType:this.logType.client_start_wiping},{text:_STR("log","log_type_client_wipe_aborted"),id:"log_type_client_cancelled",logType:this.logType.client_abort_wiping},{text:_STR("log","log_type_client_wipe_finished"),id:"log_type_client_finished",logType:this.logType.client_finish_wiping}]},{text:_STR("log","log_event_admin_action"),id:"log_event_admin_action",children:[{text:_STR("log","log_type_volume_set"),id:"log_type_volume_set",logType:this.logType.volume_set},{text:_STR("log","log_type_delfile_recyclebin"),id:"log_type_delfile_recyclebin",logType:this.logType.delfile_recyclebin},{text:_STR("log","log_type_transfer_ownership"),id:"log_type_transfer_ownership",logType:this.logType.ownship_transfer},{text:_STR("log","log_type_rotate_policy"),id:"log_type_rotate_policy",logType:this.logType.log_rotate_policy},{text:_STR("log","log_type_log_rotate_cnt_set"),id:"log_type_log_rotate_cnt_set",logType:this.logType.log_rotate_cnt_set},{text:_STR("log","log_type_log_rotate_span_set"),id:"log_type_log_rotate_span_set",logType:this.logType.log_rotate_span_set},{text:_STR("log","log_type_log_export"),id:"log_type_log_export",logType:this.logType.log_export},{text:_STR("log","log_type_log_delete"),id:"log_type_log_delete",logType:this.logType.log_delete},{text:_STR("log","log_type_rotate_policy_set"),id:"log_rotate_policy_set",logType:this.logType.rotate_policy_set},{text:_STR("log","log_type_rotate_days_set"),id:"log_rotate_days_set",logType:this.logType.rotate_days_set},{text:_STR("log","log_type_rotate_set"),id:"log_type_rotate_set",logType:this.logType.rotate_set},{text:_STR("log","log_type_migrate_index_home"),logType:this.logType.migrate_index_home},{text:_STR("log","log_type_disable_download_set"),id:"log_disable_download_set",logType:this.logType.disable_download_set},{text:_STR("log","log_type_enable_watermark_set"),id:"log_type_enable_watermark_set",logType:this.logType.enable_watermark_set},{text:_STR("log","log_type_change_watermark_setting"),id:"log_type_change_watermark_setting",logType:this.logType.change_watermark_setting},{text:_STR("log","log_type_activate_advanced_feature"),id:"log_type_activate_advanced_feature",logType:this.logType.activate_advanced_feature},{text:_STR("log","log_type_sending_link_via_email"),id:"log_type_sending_link_via_email",logType:this.logType.sending_link_via_email},{text:_STR("log","log_type_cleanup_recycle_bins"),id:"log_type_cleanup_recycle_bins",logType:this.logType.cleanup_recycle_bins},{text:_STR("log","log_type_delegate_shared_label"),id:"log_type_delegate_shared_label",logType:this.logType.delegate_shared_label},{text:_STR("log","log_type_transfer_shared_label_ownership"),id:"log_type_transfer_shared_label_ownership",logType:this.logType.transfer_shared_label_ownership},{text:_STR("log","log_type_sending_request_via_email"),id:"log_type_sending_request_via_email",logType:this.logType.sending_request_via_email},{text:_STR("log","log_type_enable_file_locking"),id:"log_type_enable_file_locking",logType:this.logType.enable_file_locking},{text:_STR("log","log_type_disable_file_locking"),id:"log_type_disable_file_locking",logType:this.logType.disable_file_locking},{text:_STR("log","log_type_enable_auto_file_locking"),id:"log_type_enable_auto_file_locking",logType:this.logType.enable_auto_file_locking},{text:_STR("log","log_type_disable_auto_file_locking"),id:"log_type_disable_auto_file_locking",logType:this.logType.disable_auto_file_locking},{text:_STR("log","log_type_force_unlock"),id:"log_type_force_unlock",logType:this.logType.force_unlock},{text:_STR("log","log_type_teamfolder_file_locking"),id:"log_type_teamfolder_file_locking",logType:this.logType.teamfolder_file_locking}]}],this.defaultAnimation=["#000",1,{duration:.35}],Ext.apply(this,e||{});var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(){var e,t,i,n,s=[];e=this.createKeyword(),UserName=this.createUserName(),IpAddress=this.createIpAddress(),t=this.createFriendlyDate(),i=this.createCustDate(),n=this.createType(),s.push(e),s.push(UserName),s.push(IpAddress),s.push(t),s.push(i),s.push(n);var o={xtype:"toolbar",border:!1,itemId:"btns",toolbarCls:"search-panel-fbar-btnPanel",items:[{xtype:"tbfill"}]},a=[{xtype:"syno_button",minWidth:80,text:_T("common","reset"),handler:this.onReset,scope:this},{
xtype:"syno_button",btnStyle:"blue",style:"margin-right: 10px",text:_T("log","search"),itemId:"btn_search",handler:this.onSearch,scope:this}];return o.items.push.apply(o.items,a),s.push(o),{width:368,heigh:480,floating:!0,labelAlign:"left",trackResetOnLoad:!0,waitMsgTarget:!0,border:!0,bodyStyle:"padding: 16px 24px 16px 24px; font-size: 24px;",autoFlexcroll:!1,defaults:{hideLabel:!0,anchor:"100%"},items:s}},createKeyword:function(){return[{xtype:"syno_displayfield",value:_T("log","attr_keyword")+_T("common","colon"),flex:1},{xtype:"syno_textfield",name:"keyword",flex:2,value:""}]},createUserName:function(){return[{xtype:"syno_displayfield",value:_STR("common","user")+_T("common","colon"),flex:1},{xtype:"syno_textfield",name:"username",flex:2,value:""}]},createIpAddress:function(){return[{xtype:"syno_displayfield",value:_STR("clientinfo","last_ip")+_T("common","colon"),flex:1},{xtype:"syno_textfield",name:"ipaddress",flex:2,value:"",vtype:"v4ip"}]},setDate:function(e,t,i){!0===i&&(this.frameAnimation(this.form.findField("searchdatefrom").el,this.defaultAnimation),this.frameAnimation(this.form.findField("searchdateto").el,this.defaultAnimation)),this.form.findField("searchdatefrom").setMaxValue(t),this.form.findField("searchdateto").setMinValue(e),this.form.findField("searchdatefrom").setValue(e),this.form.findField("searchdateto").setValue(t)},getFromToDate:function(e){var t,i,n=new Date;if(e===this.dateType.today)t=n,i=n;else if(e===this.dateType.yesterday)t=n.add(Date.DAY,-1),i=t;else if(e===this.dateType.lastweek){var s=n.getDay();t=n.add(Date.DAY,-7-s),i=t.add(Date.DAY,6)}else e===this.dateType.lastmonth&&(n=n.add(Date.MONTH,-1),t=n.getFirstDateOfMonth(),i=n.getLastDateOfMonth());return{from:t,to:i}},friendlyDateSelect:function(e,t){var i=t.get("id"),n=this.getFromToDate(i);this.setDate(n.from,n.to,!0)},getFriendlyDateStore:function(){var e=this.dataRange;return new Ext.data.ArrayStore({autoDestroy:!0,fields:["id","displayText"],data:e})},createFriendlyDate:function(){return this.FriendlyDate=new SYNO.ux.ComboBox({mode:"local",editable:!1,name:"dateRange",store:this.getFriendlyDateStore(),displayField:"displayText",valueField:"id",triggerAction:"all",value:this.dateType.custom,listeners:{scope:this,beforeselect:this.friendlyDateSelect}}),[{xtype:"syno_displayfield",value:_T("log","date_range")+_T("common","colon"),flex:1},this.FriendlyDate]},createCustDate:function(){return this.DateFrom={xtype:"syno_datetimefield",name:"searchdatefrom",editable:!1,format:SYNO.SDS.CSTN.getDateFormat(),emptyText:_T("log","date_from"),value:"",listeners:{scope:this,select:function(e,t){this.form.findField("searchdateto").setMinValue(t)}}},this.DateTo={xtype:"syno_datetimefield",name:"searchdateto",editable:!1,format:SYNO.SDS.CSTN.getDateFormat(),emptyText:_T("log","date_to"),value:"",listeners:{scope:this,select:function(e,t){this.form.findField("searchdatefrom").setMaxValue(t)}}},[{xtype:"syno_displayfield",value:_T("time","time_date")+_T("common","colon")},{xtype:"syno_compositefield",hideLabel:!0,defaults:{flex:1},defaultMargins:"0 8 0 0",items:[this.DateFrom,this.DateTo]}]},createType:function(){this.logTypeBtn=new SYNO.ux.Button({text:_STR("log","log_title_all"),cls:"syno-cstn-type-btn",menu:this.getTypeMenu(),tooltip:"",listeners:{menushow:this.onClickTypeBtn,menuhide:this.onCloseTypeMenu,scope:this}});var e=[0,1];return this.logTypeBtn.menu.setWidth(320),this.logTypeBtn.menu.defaultOffsets=e,[{xtype:"syno_displayfield",name:"logTypeLabel",value:_STR("log","log_type")+_T("common","colon"),flex:1},this.logTypeBtn]},onClickTypeBtn:function(){this.logTypeBtn.addClass("syno-cstn-type-btn-clicked")},onCloseTypeMenu:function(e,t){var i=this.generateTypeString(this.getLogTypeValue());this.frameAnimation(this.logTypeBtn.getEl(),this.defaultAnimation),this.logTypeBtn.removeClass("syno-cstn-type-btn-clicked"),this.logTypeBtn.setTooltip(i),this.logTypeBtn.setText(this.doTrimString(i))},doTrimString:function(e){var t="",i=document.createElement("canvas"),n=i.getContext("2d");n.font="13px OpenSans";for(var s=20;s<e.length;++s){var o=e.substr(0,s)+"...";if(n.measureText(o).width>230)return t;t=o}return e},onResetType:function(){Ext.each(this.logTypeBtn.menu.items.items,function(e){e.menu&&e.menu.onReset()}),this.logTypeBtn.setText(_STR("log","log_title_all"))},getLogTypeValue:function(){var e=[];return Ext.each(this.logTypeBtn.menu.items.items,function(t){t.menu&&(e=e.concat(t.menu.getLogType()))}),e},getTypeMenu:function(){var e=[{cls:"syno-cstn-type-menu-item",text:_STR("log","log_title_all"),listeners:{click:function(){this.onResetType()},scope:this}},{xtype:"menuseparator"}];return Ext.each(this.logTypeTree,function(t){var i={text:t.text,id:t.id,cls:"syno-cstn-type-menu-item",menu:new SYNO.SDS.CSTN.TriCheckboxMenu({children:t.children}),listeners:{click:function(){return!1},scope:this}};e.push(i)},this),e},frameAnimation:function(e,t){e&&e.isVisible()&&Ext.Element.prototype.frame.apply(e,t)},setKeyWord:function(e){var t=this.form.findField("keyword");t&&Ext.isString(e)&&t.setValue(e),t.focus("",1)},setUsername:function(e){var t=this.form.findField("username");t&&Ext.isString(e)&&t.setValue(e),t.focus("",1)},setTypes:function(e){Ext.each(this.logTypeBtn.menu.items.items,function(t){t.menu&&t.menu.setPreConfigLogType(e)},this);var t=this.generateTypeString(e);this.logTypeBtn.setTooltip(t),this.logTypeBtn.setText(this.doTrimString(t))},generateTypeString:function(e){var t=[];return Ext.each(this.logTypeTree,function(i){Ext.each(i.children,function(i){-1!=e.indexOf(i.logType)&&t.push(i.text)})}),0==t.length?_STR("log","log_title_all"):t.join(", ")},getParams:function(){if(this.getForm().findField("ipaddress").isValid()){var e,t,i,n,s,o,a,l;return e=this.getForm(),t=e.findField("keyword").getValue(),i=e.findField("username").getValue(),n=!!t&&!!_STR("common","system").match(new RegExp(t,"i")),n=n||!!i&&!!_STR("common","system").match(new RegExp(i,"i")),s=e.findField("ipaddress").getValue(),o=e.findField("searchdatefrom"),a=e.findField("searchdateto"),l=this.getLogTypeValue().sort(),{keyword:t,username:i,username_include_system:n,ipaddress:s,datefrom:o.getRawValue()?Date.parseDate(o.getRawValue()+" 00:00:00",o.format+" H:i:s").getTime()/1e3:0,dateto:a.getRawValue()?Date.parseDate(a.getRawValue()+" 23:59:59",a.format+" H:i:s").getTime()/1e3:0,log_type:l}}},onSearch:function(){var e=this.getParams();e&&this.fireEvent("search",this,e)},onReset:function(){this.form.items.each(function(e){e.isDirty()&&this.frameAnimation(e.el,this.defaultAnimation)},this),this.form.reset(),this.onResetType(),this.form.findField("searchdatefrom").setMaxValue(null),this.form.findField("searchdateto").setMinValue(null)},isWithInLogTypeMenu:function(e){if(e.within(this.logTypeBtn.menu.getEl()))return!0;var t=!1;return Ext.each(this.logTypeBtn.menu.items.items,function(i){if(i.menu&&i.menu.isWithIn(e))return t=!0,!1}),t}}),Ext.define("SYNO.SDS.CSTN.TriCheckboxMenu",{extend:"SYNO.ux.Menu",constructor:function(e){this.callParent([this.fillConfig(e.children||{})]),this.children=[];for(var t=2;t<this.items.length;++t)this.children.push(this.get(t));this.preConfigLogTypeArray=[],this.logTypeArray=[],this.initEvent()},fillConfig:function(e){var t=[this.triCheckbox=new SYNO.ux.TriModeCheckbox({boxLabel:_STR("log","log_event_all"),name:"log_event_all",isChild:!1,value:!1,triMode:!0}),{xtype:"menuseparator"}];return e.length&&Ext.each(e,function(e){e.isChild=!0,e.xtype="syno_checkbox",e.boxLabel=e.boxLabel?e.boxLabel:e.text,t.push(e)}),{xtype:"menuitem",cls:"syno-cstn-log-type-submenu",items:t,listeners:{beforeshow:this.onMenuBeforeShow,scope:this}}},initEvent:function(){this.mon(this.triCheckbox,"check",this.onUpdateChecked,this),Ext.each(this.children,function(e){this.mon(e,"check",this.onUpdateChecked,this)},this)},updateParent:function(){if(this.triCheckbox.checkIcon){var e=0,t=[];Ext.each(this.children,function(i){i.getValue()&&(t.push(i.logType),e+=1)}),this.logTypeArray=t,this.triCheckbox.suspendEvents(!1),e===this.children.length?this.triCheckbox.setValue(!0):e>0?this.triCheckbox.setValue(null):this.triCheckbox.setValue(!1),this.triCheckbox.resumeEvents()}},updateChildren:function(e){var t=[];Ext.each(this.children,function(i){e&&t.push(i.logType),i.suspendEvents(!1),i.setValue(e),i.resumeEvents()}),this.logTypeArray=t},onUpdateChecked:function(e,t){e.isChild?this.updateParent():null===t?e.setValue(!1):this.updateChildren(t)},onReset:function(){this.preConfigLogTypeArray=[],this.logTypeArray=[],this.updateChildren(!1),this.updateParent()},onMenuBeforeShow:function(){0!=this.preConfigLogTypeArray.length&&(this.logTypeArray=[],Ext.each(this.children,function(e){var t=-1!=this.preConfigLogTypeArray.indexOf(e.logType);e.suspendEvents(!1),e.setValue(t),e.resumeEvents(),this.logTypeArray.push(e.logType)},this),this.updateParent(),this.preConfigLogTypeArray=[])},setPreConfigLogType:function(e){this.preConfigLogTypeArray=[],Ext.each(this.children,function(t){-1!=e.indexOf(t.logType)&&this.preConfigLogTypeArray.push(t.logType)},this)},getLogType:function(){return 0!=this.preConfigLogTypeArray.length?this.preConfigLogTypeArray:this.logTypeArray},isWithIn:function(e){return e.within(this.getEl())}}),Ext.ns("SYNO.SDS.CSTN"),Ext.ns("SYNO.SDS.CSTN.LOG"),SYNO.SDS.CSTN.LOG.LOG_PAGE_LIMIT=1e3,SYNO.SDS.CSTN.LOG.CLIENT_COL_WIDTH=120,SYNO.SDS.CSTN.LOG.LOG_COL_WIDTH=592,SYNO.SDS.CSTN.LOG.USER_COL_WIDTH=100,SYNO.SDS.CSTN.LOG.TIME_COL_WIDTH=200,SYNO.SDS.CSTN.LOG.EVENT_COL_WIDTH=200,SYNO.SDS.CSTN.LOG.IP_COL_WIDTH=100,Ext.define("SYNO.SDS.CSTN.PanelLog",{extend:"SYNO.ux.EditorGridPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin;var t=this.fillConfig(e);this.callParent([t])},initEvents:function(){this.callParent(),this.mon(this.searchPanel,"search",this.onSearch,this,{buffer:this.searchBuffer}),this.mon(this,"beforedestroy",function(){this.searchPanel.destroy()},this)},fillConfig:function(e){this.pageSize=SYNO.SDS.CSTN.LOG.LOG_PAGE_LIMIT;var t=[{id:"client_type",header:_STR("clientinfo","client_type"),dataIndex:"client_type",align:"left",renderer:function(e,t){return SYNO.SDS.CSTN.RenderClientType(e,t)},width:SYNO.SDS.CSTN.LOG.CLIENT_COL_WIDTH},{id:"log",header:_STR("func","mgr_log"),dataIndex:"log",align:"left",renderer:function(e,t,i,n){return i.ridx=n,SYNO.SDS.CSTN.RenderLog(i)},width:SYNO.SDS.CSTN.LOG.LOG_COL_WIDTH},{id:"user",header:_STR("common","user"),dataIndex:"username",align:"left",hidden:!0,renderer:function(e,t){return SYNO.SDS.CSTN.RenderUserName(e,t)},width:SYNO.SDS.CSTN.LOG.USER_COL_WIDTH},{id:"time",header:_STR("common","time"),dataIndex:"time",align:"left",renderer:function(e,t){return SYNO.SDS.CSTN.RenderTime(e,t)},width:SYNO.SDS.CSTN.LOG.TIME_COL_WIDTH},{id:"event",header:_STR("log","log_event_type"),dataIndex:"type",align:"left",hidden:!0,renderer:function(e,t){return SYNO.SDS.CSTN.RenderEventType(e,t)},width:SYNO.SDS.CSTN.LOG.EVENT_COL_WIDTH},{id:"ip_address",header:_STR("clientinfo","last_ip"),dataIndex:"ip_address",align:"left",hidden:!0,renderer:function(e,t){return SYNO.SDS.CSTN.RenderIPAddress(e,t)},width:SYNO.SDS.CSTN.LOG.IP_COL_WIDTH}],i=new Ext.grid.ColumnModel({columns:t}),n=this.createStore();this.ds_share=new Ext.data.JsonStore({fields:["share_name","share_type"],data:[{share_name:_STR("log","log_title_all"),share_type:"all"}]}),this.searchPanel=new SYNO.SDS.CSTN.PanelSearch({itemId:"search",cls:"syno-cstn-search-panel syno-cstn-search-log-panel",renderTo:Ext.getBody(),shadow:!1,jsConfig:this.owner.jsConfig,hidden:!0,owner:this}),this.findField=new SYNO.SDS.CSTN.AdvancedSearchField({iconStyle:"filter",owner:this}),this.findField.searchPanel=this.searchPanel,this.selected_index=0,this.combo_share=new SYNO.ux.ComboBox({ctCls:"syno-cstn-grid syno-cstn-grid-combo",listClass:"x-layer x-combo-list syno-ux-combobox-list syno-cstn-combobox-list",name:"combo_share",mode:"local",hideLabel:!1,editable:!1,store:this.ds_share,displayField:"share_name",valueField:"share_name",triggerAction:"all",value:"all",hidden:!1,listeners:{scope:this,select:function(e,t,i){this.selected_index=i,this.getStore().load()}}});var s=new Ext.Toolbar({cls:"syno-cstn-log-toolbar"});s.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",text:_STR("btn","btn_export"),handler:this.onExportBtnClicked,scope:this}),s.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",text:_STR("common","setting"),handler:this.onSettingsBtnClicked,scope:this}),s.add("->"),s.add(this.combo_share),s.add(this.findField);var o=new SYNO.ux.PagingToolbar({cls:"cstn-paging-toolbar",store:n,pageSize:this.pageSize,displayInfo:!0,emptyMsg:"",moveLast:function(){this.store.setBaseParam("get_all",!0),this.store.load()},listeners:{change:function(){var e=Math.floor(this.store.totalLength/this.pageSize);this.store.totalLength%this.pageSize!=0&&e++;var t=this.getPageData().pages;!0===this.store.baseParams.get_all&&(this.setFocusPage(e),this.cursor=(e-1)*this.pageSize,this.first.setDisabled(1==e),this.prev.setDisabled(1==e),this.next.setDisabled(e==t),this.last.setDisabled(e==t),this.store.setBaseParam("get_all",!1))}}}),a={cls:"syno-cstn-panel-padding",itemId:"log",tbar:s,view:new SYNO.SDS.CSTN.Flexcroll.BufferView({store:n,searchFields:[this.findField],listeners:{refresh:{scope:this,fn:function(){Ext.select(".syno-cstn-log-filename-exist").on("click",function(e,t){t=Ext.get(t);var i=t.getAttribute("data-open-type"),n=t.getAttribute("data-path"),s=t.getAttribute("data-file-type");if("version"==i){var o=t.getAttribute("data-node-id"),a=t.getAttribute("data-target");"0"===s&&o&&this.showDialogVersion(a,n,o)}else"1"===s?SYNO.SDS.AppLaunch("SYNO.SDS.App.FileStation3.Instance",{opendir:n},!0):SYNO.SDS.AppLaunch("SYNO.SDS.App.FileStation3.Instance",{openfile:n},!0)},this)}}}}),stripeRows:!0,enableColLock:!1,enableHdMenu:!0,enableColumnMove:!1,colModel:i,ds:n,autoExpandColumn:"log",loadMask:!0,bbar:o,sm:new Ext.grid.RowSelectionModel({singleSelect:!1}),listeners:{rowdblclick:{fn:this.rowDoubleClick,scope:this}}};return SYNO.LayoutConfig.fill(a),Ext.apply(a,e),a},canShowVer:function(e){var t=String(e.get("type")),i=SYNO.SDS.CSTN.LogType;return(t==i.restore_node||t==i.add_event||t==i.remove_event||t==i.modify_event||t==i.version_rotate||t==i.rename_event)&&""!==e.get("p1")},rowDoubleClick:function(e,t){var i=this.getStore().getAt(t);this.canShowVer(i)&&this.showDialogVersion(i.get("target"),i.get("s1"),i.get("p1"))},showDialogVersion:function(e,t,i){if(!SYNO.SDS.Drive.Extension.Instance.isOfficeFile(t)){var n=new SYNO.SDS.CSTN.DialogVersion({owner:this.owner}),s={target:e,nodeid:i,filename:t.substring(t.lastIndexOf("/")+1),path:"@"==t.charAt(0)?t.substring(1):t,file_type:0,is_removed:!1};n.winShow(s)}},createStore:function(){var e=["type","username","username_include_system","target","share_name","share_type","time","accessable","filestation_link_prefix","s1","s2","s3","s4","s5","p1","p2","p3","p4","p5","target_share_name","target_share_type","target_accessable","target_link_prefix","client_type","ip_address"],t=new SYNO.API.Store({pruneModifiedRecords:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Log.api,version:1,method:"list",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"items",totalProperty:"total",idProperty:"id"},e),paramNames:{start:"offset",limit:"limit",sort:"sort_by",dir:"sort_direction"},baseParams:{share_type:"all",offset:0,limit:this.pageSize,get_all:!1},listeners:{scope:this,beforeload:function(){var e=this.combo_share.getStore().getAt(this.selected_index);this.getStore().setBaseParam("share_type",e.get("share_type")),"share"==e.get("share_type")?this.getStore().setBaseParam("target","@"+e.get("share_name")):this.getStore().setBaseParam("target","user")}}});return this.addManagedComponent(t),t},getShareCombo:function(){SYNO.SDS.CSTN.WebAPI.Share.listActive.call(this.owner,{exclude_home:!0},function(e,t,i,n){if(e){for(var s=[{share_name:_STR("log","log_title_all"),share_type:"all"}],o=0;o<t.total;o++)s="home"==t.items[o].type?s.concat([{share_name:_STR("category","node"),share_type:t.items[o].type}]):s.concat([{share_name:t.items[o].name,share_type:t.items[o].type}]);this.ds_share.loadData(s)}SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.listActiveCallback,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},this)},listActiveCallback:function(){this.loadPreConfigAndSearch()},clearSearchParam:function(){var e={keyword:"",datefrom:0,dateto:0,log_type:[]};Ext.apply(this.getStore().baseParams,e),this.combo_share.setValue(_STR("log","log_title_all")),this.selected_index=0,this.searchPanel.onReset(),this.findField.setValue("")},onSearch:function(e,t){e.hide(),Ext.apply(this.getStore().baseParams,t),this.getStore().load()},onPageActivate:function(){this.clearSearchParam(),this.owner.setStatusBusy(),this.getShareCombo()},loadPreConfigAndSearch:function(){var e=this.owner.fetchPreConfig();e&&(this.searchPanel.setKeyWord(e.keyword?e.keyword:""),this.searchPanel.setUsername(e.username?e.username:""),this.searchPanel.setTypes(e.types?e.types:[])),this.searchPanel.onSearch()},onDeactivate:function(){},onActivate:function(){this.onPageActivate()},onExportBtnClicked:function(){var e=this.selected_index;e=-1===e?0:e;var t=this.combo_share.store.getAt(e).data,i=this.searchPanel.getParams();if(!i)return void this.owner.getMsgBox().alert(_STR("app","app_name"),_T("common","forminvalid"));Ext.apply(i,{type:"csv",target:"all"===t.share_type?"":t.share_name}),this.owner.downloadWebAPI({webapi:{api:"SYNO.SynologyDrive.Log",version:1,method:"export",params:i},timeout:36e5})},onSettingsBtnClicked:function(){new SYNO.SDS.CSTN.DialogLogSettings({owner:this.owner,logPanel:this}).open()},reloadLogs:function(){this.getStore().reload()}}),Ext.define("SYNO.SDS.CSTN.AdvancedSearchField",{extend:"SYNO.ux.SearchField",initEvents:function(){this.callParent(arguments),this.mon(Ext.getDoc(),"mousedown",this.onMouseDown,this),this.mon(this,"keypress",function(e,t){t.getKey()==Ext.EventObject.ENTER&&(this.searchPanel.setKeyWord(this.getValue()),this.searchPanel.onSearch())},this)},isInnerComponent:function(e,t){var i=!1;return t.items.each(function(t){if(t instanceof Ext.form.ComboBox){if(t.view&&e.within(t.view.getEl()))return i=!0,!1}else if(t instanceof SYNO.ux.DateTimeField){if(t.isWithinEl(e))return i=!0,!1}else if(t instanceof Ext.form.CompositeField&&this.isInnerComponent(e,t))return i=!0,!1},this),i},onMouseDown:function(e){var t=this.searchPanel;!t||!t.isVisible()||t.isDestroyed||t.inEl||e.within(t.getEl())||t.attriWin&&t.attriWin.isVisible()||e.within(this.searchtrigger)||this.isInnerComponent(e,t.getForm())||t.isWithInLogTypeMenu(e)||t.hide()},onSearchTriggerClick:function(){if(this.searchPanel.isVisible())return void this.searchPanel.hide();this.searchPanel.getEl().alignTo(this.wrap,"tr-br?",[0,1]),this.searchPanel.show(),this.getValue()&&this.getValue().length>0&&this.searchPanel.setKeyWord(this.getValue())},onTriggerClick:function(){this.callParent(),this.searchPanel.onReset(),this.searchPanel.onSearch()}}),Ext.define("SYNO.SDS.CSTN.DialogLogSettings",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.win=e.owner,this.logPanel=e.logPanel;var t={xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[{xtype:"syno_button",btnStyle:"grey",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","cancel"),itemId:"cancel",id:this.BtnCancelId=Ext.id(),scope:this,handler:this.onCancel},{xtype:"syno_button",btnStyle:"blue",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","commit"),itemId:"apply",id:this.BtnApplyId=Ext.id(),scope:this,handler:this.onSave}]};this.settingForm=new SYNO.SDS.CSTN.LogSettingsForm({owner:this,module:this.module,logPanel:this.logPanel}),this.callParent([Ext.apply({itemId:"log_setting_editor",title:_STR("log","log_delete_rule_title"),width:600,height:280,resizable:!1,autoScroll:!0,layout:"fit",items:[this.settingForm],fbar:t},e)])},onShow:function(){this.loadForm()},onCancel:function(){this.close()},onSave:function(){this.settingForm.isDirty()?this.settingForm.save(this.onSaveCallback.bind(this)):this.close()},loadForm:function(){this.settingForm.loadForm()},onSaveCallback:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.onSaveSuccess.bind(this),failure:SYNO.SDS.CSTN.webapiHdl})},onSaveSuccess:function(){this.owner.getMsgBox().alert(_STR("app","app_name"),_T("common","setting_applied")),this.close()}}),Ext.define("SYNO.SDS.CSTN.LogSettingsForm",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin,this.logPanel=e.logPanel;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={border:!1,plain:!0,padding:0,itemId:"configure",items:[{xtype:"syno_displayfield",value:_STR("log","log_delete_rule_desc")},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_checkbox",boxLabel:_STR("log","log_delete_by_count"),width:240,name:"use_del_by_cnt"},{xtype:"syno_combobox",name:"del_cnt",width:220,mode:"local",value:1e6,editable:!1,store:this.storeLogDelCntGet(),forceSelection:!0,displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0}]},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_checkbox",boxLabel:_STR("log","log_delete_by_time"),width:240,name:"use_del_by_span"},{xtype:"syno_combobox",name:"del_span",width:220,mode:"local",value:2,editable:!1,store:this.storeLogDelTimeGet(),forceSelection:!0,displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0}]},{xtype:"syno_button",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",text:_STR("log","log_delete_all_logs"),scope:this,handler:this.onDeleteLog}]};return SYNO.LayoutConfig.fill(t),Ext.apply(t,e),t},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){var e=this.getForm();new SYNO.SDS.Utils.EnableCheckGroup(e,"use_del_by_cnt",["del_cnt"]),new SYNO.SDS.Utils.EnableCheckGroup(e,"use_del_by_span",["del_span"])},this,{single:!0})},loadForm:function(){this.owner.setStatusBusy(),this.sendWebAPI({api:SYNO.SDS.CSTN.WebAPI.Config.api,method:"get",version:1,callback:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.fillForm,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},scope:this})},fillForm:function(e){this.getForm().setValues(e)},storeLogDelCntGet:function(){return new Ext.data.SimpleStore({autoDestroy:!0,fields:["value","display"],data:SYNO.SDS.CSTN.getMaxLogCountOptions()})},storeLogDelTimeGet:function(){return new Ext.data.SimpleStore({autoDestroy:!0,fields:["value","display"],data:SYNO.SDS.CSTN.getLogSpanOptions()})},reloadLogPanel:function(){this.logPanel.reloadLogs()},deleteLogCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.reloadLogPanel.bind(this),failure:this.reloadLogPanel.bind(this)})},onDeleteLog:function(){this.owner.getMsgBox().confirm(_STR("app","app_name"),_STR("log","log_delete_all_logs_confirm"),function(e){"yes"===e&&(this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.Log.delete.call(this.owner,this.deleteLogCB,this))},this)},save:function(e){var t=this.getForm().findField("use_del_by_cnt"),i=this.getForm().findField("del_cnt"),n=this.getForm().findField("use_del_by_span"),s=this.getForm().findField("del_span");this.sendWebAPI({api:SYNO.SDS.CSTN.WebAPI.Config.api,method:"set",version:1,params:{use_del_by_cnt:t.getValue(),del_cnt:i.getValue(),use_del_by_span:n.getValue(),del_span:s.getValue()},callback:e,scope:this})},isDirty:function(){return this.getForm().isDirty()}}),Ext.ns("SYNO.SDS.CSTN.SHARING"),SYNO.SDS.CSTN.SHARING.STATUS_COL_WIDTH=150,SYNO.SDS.CSTN.SHARING.ROTATE_COL_WIDTH=150,SYNO.SDS.CSTN.SHARING.SHARENAME_COL_WIDTH=250,SYNO.SDS.CSTN.SHARING.PAGE_ITEM_LIMIT=50,Ext.define("SYNO.SDS.CSTN.PanelSharing",{extend:"SYNO.ux.EditorGridPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin,this.my_ds_center_email="";var t=this.fillConfig(e);this.callParent([t])},getTopToolbar:function(){return this.callParent().getComponent("topToolbar")},fillConfig:function(e){this.pageSize=SYNO.SDS.CSTN.SHARING.PAGE_ITEM_LIMIT;var t=[{id:"share_name",header:_STR("common","shared_folder"),dataIndex:"share_name",sortable:!0,align:"left",width:SYNO.SDS.CSTN.SHARING.SHARENAME_COL_WIDTH,renderer:SYNO.SDS.CSTN.RenderShareName},{id:"share_status",header:_STR("common","status"),dataIndex:"share_status",sortable:!0,align:"left",width:SYNO.SDS.CSTN.SHARING.STATUS_COL_WIDTH,renderer:SYNO.SDS.CSTN.RenderShareStatus},{header:_STR("version","number_of_versions"),dataIndex:"rotate_cnt",sortable:!0,align:"left",width:SYNO.SDS.CSTN.SHARING.ROTATE_COL_WIDTH,renderer:SYNO.SDS.CSTN.RenderShareRotateCount},{header:_STR("cstn","disable_download_title"),dataIndex:"disable_download",sortable:!0,align:"left",width:SYNO.SDS.CSTN.SHARING.ROTATE_COL_WIDTH,renderer:SYNO.SDS.CSTN.RenderShareSecuritySetting},{header:_STR("cstn","watermark_title"),dataIndex:"enable_watermark",sortable:!0,align:"left",width:SYNO.SDS.CSTN.SHARING.ROTATE_COL_WIDTH,renderer:SYNO.SDS.CSTN.RenderShareSecuritySetting},{header:_STR("cstn","file_locking_title"),dataIndex:"enable_node_locking",sortable:!0,align:"left",width:SYNO.SDS.CSTN.SHARING.ROTATE_COL_WIDTH,renderer:SYNO.SDS.CSTN.RenderShareFileLockingStatus}],i=new Ext.grid.RowSelectionModel({singleSelect:!1,listeners:{selectionchange:function(e){var t,i=e.getSelections(),n=!1,s=!1,o=!1,a=!1,l=!1,r=!1,d=this.getTopToolbar().get("btnEnable"),c=this.getTopToolbar().get("btnDisable"),h=this.getTopToolbar().get("btnVersionCnt"),_=this.getTopToolbar().get("btnMigrateIndexHome");this._S("demo_mode")||(Ext.each(i,function(e){return SYNO.SDS.CSTN.ShareNameIsHome(e.get("share_name"))&&(a=!0,t=e.get("share_status")),"c2_share"==e.get("share_type")&&(l=!0),"tiering_share"!=e.get("share_type")&&"cold_tiering_share"!=e.get("share_type")||(r=!0),e.get("share_enable")?(s=!0,o=!0):"not_available"==e.get("share_status")||"not_supported"==e.get("share_status")||"disconnected_cold_tier"==e.get("share_status")||"cold_tiering_share"==e.get("share_type")||SYNO.SDS.CSTN.IsNotAllowedShare(e.get("share_name"))||(n=!0),!0}),(l||r)&&i.length>1&&(n=!1),a&&1===i.length&&0===this.index_home_config?_.setDisabled(!1):_.setDisabled(!0),h.setDisabled(!s),d.setDisabled(!n),c.setDisabled(!o))},scope:this}}),n=new Ext.grid.ColumnModel({columns:t}),s=this.createStore(),o=new SYNO.ux.TextFilter({itemId:"search",emptyText:_STR("btn","search"),store:s,pageSize:this.pageSize,enumAction:"list",queryAction:"list"}),a=new Ext.Toolbar({itemId:"topToolbar"});a.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnEnable",text:_STR("btn","btn_enable"),handler:this.onEnable,scope:this}),a.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnDisable",text:_STR("btn","btn_disable"),handler:this.onDisable,scope:this}),a.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"btnVersionCnt",text:_STR("common","setting"),handler:this.onVersionSet,scope:this}),a.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:!1,itemId:"btnVersionExplorer",text:_STR("func","version_explorer"),handler:function(){SYNO.SDS.AppLaunch("SYNO.SDS.CSTN.Explore.Instance",{})}}),a.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:!0,hidden:!0,itemId:"btnMigrateIndexHome",text:_STR("func","migrate_index_home"),handler:this.onMigrateIndexHome,scope:this}),a.add("->"),a.add(o);var l=new SYNO.ux.PagingToolbar({cls:"cstn-paging-toolbar",store:s,pageSize:this.pageSize,displayInfo:!0,emptyMsg:""}),r={xtype:"syno_displayfield",cls:"syno-cstn-sharing-note-toolbar",html:String.format(_STR("cstn","goto_sharedfolder_setting_desc_upper"),'<a id="cstn-goto-sharedfolder-link" class="link">'+_STR("cstn","shared_folders")+"</a>"),listeners:{scope:this,afterrender:function(){document.getElementById("cstn-goto-sharedfolder-link").addEventListener("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{owner:this,fn:"SYNO.SDS.AdminCenter.Share.Main"})})}}},d={xtype:"container",layout:{type:"vbox",align:"stretch"},items:[r,a]},c={cls:"syno-cstn-panel-padding",itemId:"sharing",tbar:d,view:new SYNO.SDS.CSTN.FleXcroll.GridView({store:s,searchFields:[o],onRowOver:this.onRowOver.bind(this)}),stripeRows:!0,enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,colModel:n,sm:i,ds:s,autoExpandColumn:"share_name",loadMask:!0,bbar:{autoHeight:!0,cls:"syno-cstn-teamfolder-bbar",layout:{type:"vbox",align:"stretch"},items:[l]}};return SYNO.LayoutConfig.fill(c),Ext.apply(c,e),c},onRowOver:function(e,t){this.needShowShareStatusTooltip(t)?t.childNodes[0].setAttribute("ext:qtip",t.innerText.trim()):"function"==typeof t.childNodes[0].removeAttribute&&t.childNodes[0].removeAttribute("ext:qtip")},needShowShareStatusTooltip:function(e){return!(!e||!e.classList.contains("x-grid3-col-share_status"))&&!!this.isEllipsis(e)},isEllipsis:function(e){return!!e&&e.offsetWidth<e.scrollWidth},getC2ShareAccounts:function(){this.sendWebAPI({api:"SYNO.C2FS.Share",method:"list",version:1,scope:this,async:!1,callback:function(e,t){e&&(this.c2_share_accounts=t)}})},getIndexHomeConfig:function(){SYNO.SDS.CSTN.WebAPI.Share.get_migrate_index_home_config.call(this.owner,function(e,t){if(e){var i=t.config;this.index_home_config=t.config,this.to_migrate_count=t.to_migrate_count,this.homes_has_mount_point=t.has_mount_point;var n=this.getTopToolbar().get("btnMigrateIndexHome");0===i&&t.home_service_enabled?n.show():1===i&&t.home_service_enabled?n.show():n.hide()}},this)},onMigrateIndexHome:function(e){if(this.homes_has_mount_point)return void this.owner.getMsgBox().alert(_STR("app","app_name"),_STR("migrate_index_home","home_has_mountpoint"));var t=this,i=function(){SYNO.SDS.CSTN.WebAPI.Share.migrate_index_home.call(t.owner,function(i,n){if(!i)return void t.getStore().load();e.setDisabled(!0),t.index_home_config=1,t.getStore().load()})},n='<span style="font-size:16px;line-height:24px;font-weight:bold;">'+_STR("migrate_index_home","confirm_title")+'</span><div style="height:12px"></div><p style="line-height: 20px;">'+_STR("migrate_index_home","dialog_desc")+'</p><div style="height:12px"></div><p style="line-height: 20px;">'+String.format(_STR("migrate_index_home","confirm_accounts"),this.to_migrate_count)+'</p><div style="height:12px"></div><p style="line-height: 20px;">'+_STR("migrate_index_home","confirm_irreversible")+" "+_STR("migrate_index_home","confirm_proceed")+"</p>";this.owner.getMsgBox().confirm(_STR("app","app_name"),n,function(e){"yes"===e&&i()},window,null,{width:540,hideBrElement:!0})},shareArrC2ShareCount:function(e){var t=0;return Ext.each(e,function(e){"c2_share"===e.share_type&&t++}),t},createStore:function(){var e=["share_name","share_type","share_status","share_enable","rotate_cnt","rotate_policy","rotate_days","disable_download","watermark_font","watermark_font_color","watermark_font_px_size","watermark_opacity_percent","watermark_rotate_degree","watermark_text","enable_watermark","watermark_is_repeat","watermark_density","enable_node_locking"],t=new SYNO.API.Store({pruneModifiedRecords:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Share.api,version:1,method:"list",appWindow:this.owner}),
reader:new Ext.data.JsonReader({root:"items",totalProperty:"total",idProperty:"id"},e),sortInfo:{field:"share_name",direction:"ASC"},paramNames:{start:"offset",limit:"limit",sort:"sort_by",dir:"sort_direction"},baseParams:{offset:0,limit:SYNO.SDS.CSTN.SHARING.PAGE_ITEM_LIMIT,sort_by:"share_name",sort_direction:"ASC"},remoteSort:!0,listeners:{scope:this,beforeload:function(){SYNO.SDS.CSTN.SupportHybridShare()&&this.getC2ShareAccounts(),this.getIndexHomeConfig()},load:function(e,t){e.filterBy(function(e){return"c2_share"===e.get("share_type")&&SYNO.SDS.CSTN.SupportHybridShare()||"c2_share"!==e.get("share_type")}),this.checkShowWatermarkSetting(t)},exception:function(e,t,i,n,s){s&&s.code&&SYNO.SDS.CSTN.webapiErrHdlMain.apply(this,[s])}}});return this.addManagedComponent(t),t},checkShowWatermarkSetting:function(e){var t="yes"===_D("drive_watermark_setting"),i=this.getColumnModel().findColumnIndex("enable_watermark"),n=SYNO.SDS.CSTN.System.minMem,s=e.some(function(e){return e.data.enable_watermark});this.showWatermarkSetting=t||n>=2048||s,this.getColumnModel().setHidden(i,!this.showWatermarkSetting)},showEnableShareRemainder:function(){(function(){var e=_STR("warning","msg_sharing_hint");e+="<br/><br/>"+_STR("warning","warn_mount"),this.owner.getMsgBox().alert(_STR("app","app_name"),e,function(){SYNO.SDS.CSTN.cbLoad.apply(this)},this)}).bind(this)()},showResumeIndexingNotification:function(){var e=Ext.getCmp("syno-drive-indexing-tray-panel");e&&e.timeToResume>0&&window.setTimeout(function(){SYNO.SDS.NotifyMgr.notifyMsg("SYNO.SDS.Drive.Application",_STR("app","pkg_name"),_STR("tray","auto_resume_by_enabling_team_folder"))},5e3)},ajaxCheckSrvStatusCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:SYNO.SDS.CSTN.cbLoad,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},checkSrvStatus:function(){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.checkUser.call(this.owner,this.ajaxCheckSrvStatusCB,this)},onPageActivate:function(){this.checkSrvStatus()},onActivate:function(){this.onPageActivate()},checkDirty:function(){return!1},applyGridDoneFail:function(e){this.getStore().rejectChanges();var t="";switch(e.code){case SYNO.SDS.CSTN.ErrorCode.NO_SUCH_API:case SYNO.SDS.CSTN.ErrorCode.PKG_NOT_ENABLED:case SYNO.SDS.CSTN.ErrorCode.SERVICE_DISABLED:case SYNO.SDS.CSTN.ErrorCode.ADMIN_ONLY:case SYNO.SDS.CSTN.ErrorCode.SYS_DISK_FULL:return void SYNO.SDS.CSTN.webapiErrHdlMain.apply(this,[e]);default:t=SYNO.SDS.CSTN.getErrorString(e)}this.owner.getMsgBox().alert(_STR("app","app_name"),t)},ajaxApplyGridCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:SYNO.SDS.CSTN.cbLoad,failure:this.applyGridDoneFail})},beforeApplyGrid:function(e){var t=this.getAffectedShareInfo(e?"enable":"disable"),i=[],n=!1,s=[],o=[];if(Ext.each(t,function(t){SYNO.SDS.CSTN.ShareNameIsHome(t.share_name)&&(n=!0),"c2_share"==t.share_type&&t.share_enable&&s.push(t),"tiering_share"!=t.share_type||t.share_enable||o.push(t),i.push({share_name:t.share_name,share_enable:e,share_status:t.share_status,share_type:t.share_type,disable_download:t.disable_download,enable_watermark:t.enable_watermark,watermark_font:t.watermark_font,watermark_font_color:t.watermark_font_color,watermark_font_px_size:t.watermark_font_px_size,watermark_text:t.watermark_text,watermark_opacity_percent:t.watermark_opacity_percent,watermark_rotate_degree:t.watermark_rotate_degree,watermark_is_repeat:t.watermark_is_repeat,watermark_density:t.watermark_density})}),!1===e)if(n&&1==t.length)this.owner.getMsgBox().confirm(_STR("app","app_name"),_STR("warning","disable_home_service"),function(e){"yes"===e&&SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{owner:this,fn:"SYNO.SDS.AdminCenter.User.Main",tab:"option_tab"})},this);else if(s.length>0){var a=1==s.length?String.format(_STR("warning","hybrid_share_disable_sync"),s[0].share_name,this.c2_share_accounts[s[0].share_name].synology_account):_STR("warning","hybrid_share_disable_sync_multi");this.owner.getMsgBox().confirm(_STR("app","app_name"),a,function(e){"yes"===e&&this.applyGrid(i,!1)},this)}else this.owner.getMsgBox().confirm(_STR("app","app_name"),_STR("warning","msg_remove_user_share_db"),function(e){"yes"===e&&(n?this.owner.getMsgBox().confirm(_STR("app","app_name"),_STR("warning","disable_home_service_with_team_folder"),function(e){this.applyGrid(i,!1),"yes"===e&&SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{owner:this,fn:"SYNO.SDS.AdminCenter.User.Main",tab:"option_tab"})},this):this.applyGrid(i,!1))},this);else{var l=function(e){e.getEnableShareArr().length>0&&(this.showEnableShareRemainder(),this.showResumeIndexingNotification())};dialog=new SYNO.SDS.CSTN.DialogSetting({sharing_this:this,init_share:!0,owner:this.owner,share_arr:i,c2_share_accounts:this.c2_share_accounts,show_watermark_setting:this.showWatermarkSetting,listeners:{scope:this,close:l}}),dialog.winShow(),n&&dialog.getMsgBox().confirm(_STR("app","app_name"),_STR("warning","enable_home_service"),function(e){"yes"===e?SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.User.Main",tab:"option_tab"}):1==t.length?dialog.close():(dialog.ignoreShare("homes/mydrive"),dialog.ignoreShare("homes/mydrive_home"))},this)}},applyDefaultRotatePolicy:function(e){Ext.each(e,function(e){e.rotate_policy="fifo"})},applyGrid:function(e){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.Share.set.call(this,e,this.ajaxApplyGridCB,this)},getSingleShareInfo:function(e){return{share_name:e.get("share_name"),share_enable:e.get("share_enable"),share_status:e.get("share_status"),share_type:e.get("share_type"),rotate_cnt:e.get("rotate_cnt"),rotate_policy:e.get("rotate_policy"),rotate_days:e.get("rotate_days"),disable_download:e.get("disable_download"),enable_watermark:e.get("enable_watermark"),watermark_font:e.get("watermark_font"),watermark_font_color:e.get("watermark_font_color"),watermark_font_px_size:e.get("watermark_font_px_size"),watermark_text:e.get("watermark_text"),watermark_opacity_percent:e.get("watermark_opacity_percent"),watermark_rotate_degree:e.get("watermark_rotate_degree"),watermark_is_repeat:e.get("watermark_is_repeat"),watermark_density:e.get("watermark_density")}},getAffectedShareInfo:function(e){var t=this.getSelectionModel().getSelections(),i=[];return Ext.each(t,function(t){var n=this.getSingleShareInfo(t);"enable"==e?n.share_enable||SYNO.SDS.CSTN.IsNotAllowedShare(n.share_name)||i.push(n):"disable"==e?n.share_enable&&i.push(n):"version_set"==e?n.share_enable&&i.push(n):i.push(n)},this),i},onEnable:function(){this.beforeApplyGrid(!0)},onDisable:function(){this.beforeApplyGrid(!1)},onVersionSet:function(){var e,t=this.getAffectedShareInfo("version_set"),i=[];Ext.each(t,function(e){i.push({share_name:e.share_name,share_enable:e.share_enable,share_type:e.share_type,rotate_cnt:e.rotate_cnt,rotate_policy:e.rotate_policy,rotate_days:e.rotate_days,disable_download:e.disable_download,enable_watermark:e.enable_watermark,watermark_font:e.watermark_font,watermark_font_color:e.watermark_font_color,watermark_font_px_size:e.watermark_font_px_size,watermark_text:e.watermark_text,watermark_opacity_percent:e.watermark_opacity_percent,watermark_rotate_degree:e.watermark_rotate_degree,watermark_is_repeat:e.watermark_is_repeat,watermark_density:e.watermark_density})}),e=new SYNO.SDS.CSTN.DialogSetting({sharing_this:this,init_share:!1,owner:this.owner,c2_share_accounts:this.c2_share_accounts,share_arr:i,show_watermark_setting:this.showWatermarkSetting,listeners:{close:this.onDialogClose,scope:this}}),e.winShow()},onDialogClose:function(e){}}),Ext.define("SYNO.SDS.CSTN.DialogSetting",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.share_arr=e.share_arr,this.enable_share_arr=[],this.show_watermark_setting=e.show_watermark_setting,this.is_only_homes=1==this.share_arr.length&&SYNO.SDS.CSTN.ShareNameIsHomes(this.share_arr[0].share_name);var t={xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[{xtype:"syno_button",btnStyle:"grey",text:_T("common","cancel"),itemId:"cancel",handler:this.onCancel,scope:this},{xtype:"syno_button",btnStyle:"blue",text:_T("common","apply"),disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"apply",handler:this.onSave,scope:this}]},i=[this.getRotatePanel(e)];this.is_only_homes||i.push(this.getSecurityPanel(e)),this.tabPanel=new SYNO.ux.TabPanel({deferredRender:!1,activeTab:0,items:i}),this.callParent([Ext.apply({cls:"syno-cstn-version-info-dlg",title:_STR("common","setting"),width:700,height:700,resizable:!1,layout:"fit",items:[this.tabPanel],fbar:t},e)]),this.on("afterlayout",this.onAfterLayout,this,{single:!0})},getRotatePanel:function(e){return this.rotatePanel?this.rotatePanel:(this.rotatePanel=new SYNO.SDS.CSTN.RotateSettingPanel({init_share:e.init_share,win:this,owner:e.owner}),this.rotatePanel)},getSecurityPanel:function(e){return this.securityPanel?this.securityPanel:(this.securityPanel=new SYNO.SDS.CSTN.SecurityPanel({init_share:e.init_share,win:this,owner:e.owner,show_watermark_setting:this.show_watermark_setting}),this.securityPanel)},onAfterLayout:function(){this.rotatePanel.init(this.share_arr),this.securityPanel&&this.securityPanel.init(this.share_arr)},mountFieldEvent:function(e,t,i,n){var s=this.findField(e);s.mon(s,t,i,n)},findField:function(e){return SYNO.ux.Utils.findFormField(this.rotatePanel.getForm(),e)},ignoreShare:function(e){this.share_arr=this.share_arr.filter(function(t){return t.share_name!==e},this)},winShow:function(){this.open()},validate:function(){return this.securityPanel?this.securityPanel.validate():Promise.resolve(!0)},onCancel:function(){this.close()},onSave:function(){var e=function(e){if(e){var t,i,n,s,o=[],a=this.rotatePanel.getForm().getValues(),l=this.rotatePanel.oriValues,r=this.securityPanel?this.securityPanel.getValues():{},d=[],c=[];if("true"===a.enable_version){if(!1===this.rotatePanel.isValid())return;if(!a.rotate_policy)return void this.setStatusError({text:_STR("warning","not_choose"),clear:!0});t=parseInt(a.rotate_count,10),i=a.rotate_policy,n="true"===a.enable_rotate_days?parseInt(a.rotate_days,10):0}else t=0,i="fifo",n=0;for(s=0;s<this.share_arr.length;s++){var h=SYNO.SDS.CSTN.ShareNameIsHomes(this.share_arr[s].share_name),_=!SYNO.SDS.CSTN.Config.advanced_feature_activated||0===Object.keys(r).length||h,u=_?{}:{disable_download:r.enableDisableDownload,enable_watermark:r.enableWatermark,watermark_text:r.watermarkContent,watermark_font:r.fontFamily,watermark_font_color:r.fontColor,watermark_font_px_size:r.fontSize,watermark_rotate_degree:r.angle,watermark_opacity_percent:100-r.transparency,watermark_is_repeat:r.watermarkIsRepeat,watermark_density:"0.3"};this.share_arr[s].share_enable&&(o.push(Ext.apply({share_name:this.share_arr[s].share_name,rotate_cnt:t,rotate_policy:i,rotate_days:n,share_type:this.share_arr[s].share_type},u)),"c2_share"===this.share_arr[s].share_type&&d.push(this.share_arr[s]),"tiering_share"===this.share_arr[s].share_type&&c.push(this.share_arr[s]))}if(this.init_share)for(s=0;s<o.length;s++)!1===SYNO.SDS.CSTN.ShareNameIsHome(o[s].share_name)&&(o[s].share_enable=!0),this.enable_share_arr.push(o[s]);var p=function(){this.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.Share.set.call(this.owner,o,this.ajaxApplyGridCB,this)}.bind(this),S=l.enable_version&&"false"===a.enable_version||l.rotate_count>t||!l.enable_rotate_days&&"true"===a.enable_rotate_days||l.enable_rotate_days&&"true"===a.enable_rotate_days&&l.rotate_days>n;if(this.need_show_inc=d.length>0&&(!l.enable_version&&"true"===a.enable_version||l.rotate_count<t||l.enable_rotate_days&&"false"===a.enable_rotate_days||l.enable_rotate_days&&"true"===a.enable_rotate_days&&l.rotate_days<n),this.need_show_tiering_soft_check=c.length>0&&(this.init_share||!l.enable_version)&&"true"===a.enable_version,!this.init_share&&S){var g=d.length>1?_STR("version","hybrid_share_version_start_cleanup_multi"):1===d.length?String.format(_STR("warning","hybrid_share_version_start_cleanup"),this.c2_share_accounts[d[0].share_name].synology_account):_STR("warning","version_start_cleanup");this.owner.getMsgBox().confirm(_STR("app","app_name"),g,function(e){"yes"===e&&p()})}else if(d.length>0&&(this.init_share||this.need_show_inc)){var f='<ol style="list-style:decimal;padding-left:16px;padding-bottom:12px;">'+("true"===a.enable_version?"<li>"+String.format(_STR("version","hybrid_share_localcache_desc")):"")+"<li>"+(d.length>1?_STR("version","hybrid_share_enable_multi"):String.format(_STR("version","hybrid_share_enable"),this.c2_share_accounts[d[0].share_name].synology_account))+"</ol>"+_STR("common","confirm_continue");this.owner.getMsgBox().confirm(_STR("app","app_name"),f,function(e){"yes"===e?p():this.enable_share_arr=[]},this)}else if(this.need_show_tiering_soft_check){var m=_STR("warning","tiering_share_enable_sync")+'</br><span class="sharing-note-tiering">'+_T("common","note")+_T("common","colon")+" </span>"+_STR("warning","tiering_share_enable_sync_note");this.owner.getMsgBox().confirm(_STR("app","app_name"),m,function(e){"yes"===e?p():this.enable_share_arr=[]},this)}else p()}};this.validate().then(e.bind(this))},getEnableShareArr:function(){return this.enable_share_arr},getNeedShowInc:function(){return this.need_show_inc},ajaxApplyGridSuccessCB:function(){this.sharing_this.getStore().load(),this.close()},ajaxApplyGridFailedCB:function(){this.enable_share_arr=[],SYNO.SDS.CSTN.webapiErrHdl.apply(this,arguments)},ajaxApplyGridCB:function(e,t,i,n){this.clearStatusBusy(),SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.ajaxApplyGridSuccessCB,failure:this.ajaxApplyGridFailedCB})}}),Ext.define("SYNO.SDS.CSTN.SecurityPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.init_share=e.init_share,this.show_watermark_setting=e.show_watermark_setting;var t={title:_STR("cstn","security"),labelAlign:"left",border:!1,autoFlexcroll:!0,items:this.getPanelItems()};Ext.apply(t,e),this.callParent([t])},getPanelItems:function(){return[this.getSecurityFieldset()]},getDisableDownloadFieldset:function(){return{cls:"min-fieldset",xtype:"syno_fieldset",title:_STR("cstn","disable_download_title"),collapsible:!1,items:[{xtype:"syno_displayfield",value:_STR("cstn","disable_download_desc")},{xtype:"syno_checkbox",name:"disable_download",itemId:"disable_download",boxLabel:_STR("cstn","disable_download_label")}]}},getSecurityFieldset:function(){return this.securitySetting?this.securitySetting:(this.securitySetting=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.CSTN.Vue.AdminSecuritySetting,mountId:"PanelSharing-AdminSecuritySetting",layout:"fit",cls:"panel-sharing-AdminSecuritySetting",owner:this}),this.securitySetting)},getDefaultValue:function(){return{enableDisableDownload:!1,enableWatermark:!1,watermarkContent:"Confidential",fontFamily:"all-in-one",fontColor:"#C0C0C0",fontSize:72,angle:-45,transparency:50,watermarkIsRepeat:!1}},getMergedValueByDifferent:function(e,t){for(var i="",n=0;n<e.length;n++){if(""!==i&&""!==e[n][t]&&i!==e[n][t])return"";i=e[n][t]||i}return i},getMergedValueByLastElement:function(e,t){return e.reduce(function(e,i){return i.enable_watermark&&void 0!==i[t]?i[t]:e},null)},init:function(e){this.setProps();var t=this.getDefaultValue();if(this.init_share)return void this.setValues(t);if(t.enableDisableDownload=e.some(function(e){return e.disable_download}),t.enableWatermark=e.some(function(e){return e.enable_watermark}),!1===t.enableWatermark)return void this.setValues(t);t.watermarkIsRepeat=e.some(function(e){return e.watermark_is_repeat});var i=this.getMergedValueByLastElement(e,"watermark_opacity_percent"),n=this.getMergedValueByLastElement(e,"watermark_font_px_size");t.transparency=void 0!==i?100-i:t.transparency,t.watermarkContent=this.getMergedValueByDifferent(e,"watermark_text")||t.watermarkContent,t.fontFamily=this.getMergedValueByLastElement(e,"watermark_font")||t.fontFamily,t.fontColor=this.getMergedValueByLastElement(e,"watermark_font_color")||t.fontColor,t.fontSize=void 0!==n?n:t.fontSize,t.angle=this.getMergedValueByLastElement(e,"watermark_rotate_degree")||t.angle,this.setValues(t)},setValues:function(e){this.getSecurityFieldset()._$vueInst.setValues(e)},getValues:function(){return this.getSecurityFieldset()._$vueInst.getValues()},setProps:function(){var e=this.getSecurityFieldset()._$vueInst,t=this.win,i=this.owner;e.setProps({showWatermarkSetting:this.show_watermark_setting,jumpToActivateAdvancedFeaturePage:function(){t.onCancel(),i.selectPage("SYNO.SDS.CSTN.PanelAdvancedFeature")}})},validate:function(){return this.getSecurityFieldset()._$vueInst.validate()}}),Ext.define("SYNO.SDS.CSTN.RotateSettingPanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){var t={cls:"no-scroll",title:_STR("version","version"),labelAlign:"left",border:!1,autoFlexcroll:!1,items:this.getPanelItems()};Ext.apply(t,e),this.callParent([t])},getPanelItems:function(){return[{cls:"min-fieldset",xtype:"syno_fieldset",items:[{xtype:"syno_displayfield",value:_STR("version","version_description")},{xtype:"syno_checkbox",name:"enable_version",boxLabel:_STR("version","enable_versioning")},this.inputField=new SYNO.ux.NumberField({xtype:"syno_numberfield",name:"rotate_count",fieldLabel:_STR("cstn","label_version_limit"),emptyText:_STR("cstn","label_version_limit_placeholder"),indent:1,maxValue:32,minValue:1,maxlength:2,allowBlank:!1,allowNegative:!1,regex:/^\d+$/,width:180}),{cls:"min-fieldset",xtype:"syno_fieldset",items:[{xtype:"syno_displayfield",value:_STR("version","rotate_policy"),indent:1},{xtype:"syno_radio",boxLabel:_STR("version","fifo_rotation"),name:"rotate_policy",inputValue:"fifo",indent:1},{xtype:"syno_radio",boxLabel:_STR("version","smart_rotation"),name:"rotate_policy",inputValue:"smart",indent:1,listeners:{afterrender:function(e){SYNO.SDS.Utils.AddTip(e.el.dom,_STR("version","intelliversion_tooltip"))}}}]},{cls:"min-fieldset",xtype:"syno_fieldset",items:[{xtype:"syno_checkbox",name:"enable_rotate_days",boxLabel:_STR("version","enable_rotate_days_checkbox"),indent:1,listeners:{afterrender:function(e){SYNO.SDS.Utils.AddTip(e.el.dom,_STR("version","rotate_days_tooltip"))}}},{xtype:"syno_displayfield",value:_STR("version","enable_rotate_days_checkbox_desc"),indent:2},{xtype:"syno_combobox",displayField:"display",valueField:"value",hideLabel:!0,indent:2,mode:"local",name:"rotate_days",store:new Ext.data.ArrayStore({autoDestroy:!0,fields:["display","value"],data:[7,30,60,120].map(function(e){return[String.format(_STR("version","days"),e),e]})})}]},{cls:"min-fieldset",xtype:"syno_fieldset",items:[{id:this.summaryBoxId=Ext.id(),xtype:"box",cls:"highlight-box"}]}]}]},init:function(e){new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_version",["rotate_count","rotate_policy","enable_rotate_days"]),new SYNO.ux.Utils.EnableRadioGroup(this.getForm(),"rotate_policy",{fifo:[],smart:[]}),new SYNO.ux.Utils.EnableCheckGroup(this.getForm(),"enable_rotate_days",["rotate_days"]),this.mon(this.getForm().findField("rotate_days"),"enable",this.onRotateDaysEnable,this),this.init_share?this.showDefaultValue(e):this.showMergedValue(e),this.updateSummaryField(),this.mon(this.getForm().findField("enable_version"),"check",this.updateSummaryField,this),this.mon(this.getForm().findField("enable_rotate_days"),"check",this.updateSummaryField,this),this.mon(this.getForm().findField("rotate_count"),"change",this.updateSummaryField,this),this.mon(this.getForm().findField("rotate_days"),"change",this.updateSummaryField,this)},onRotateDaysEnable:function(){!1===this.getForm().findField("enable_version").getValue()&&this.getForm().findField("rotate_days").setDisabled(!0)},getDefaultValue:function(){return{enable_version:!0,rotate_count:8,rotate_policy:"fifo",enable_rotate_days:!0,rotate_days:30}},showDefaultValue:function(e){var t=this.getDefaultValue();"c2_share"==e[0].share_type&&(t.enable_version=!1),this.getForm().setValues(t),this.updateOriginalValues(t)},updateSummaryField:function(){var e=function(e){return"<b>"+e+"</b>"},t=function(){var t;return t=this.getForm().findField("enable_version").getValue()?this.getForm().findField("enable_rotate_days").getValue()?"summary_desc_with_rotate_days":"summary_desc_without_rotate_days":"summary_desc_none",String.format(_STR("version",t),e(this.getForm().findField("rotate_count").getValue()),e(this.getForm().findField("rotate_days").getValue()))}.bind(this),i=Ext.get(this.summaryBoxId),n=String.format("<h2>{0}</h2><p>{1}</p>",_STR("version","summary_title"),t());i.update(n)},showMergedValue:function(e){var t=this.getMergedRotateCount(e),i=this.getMergedRotatePolicy(e),n={};n.enable_version=0!==t,n.rotate_policy=i,n.rotate_days=e.reduce(function(e,t){return 0!=t.rotate_days?t.rotate_days:e},0),n.enable_rotate_days=n.rotate_days>0,n.rotate_days=0===n.rotate_days?120:n.rotate_days,-1!=t&&(n.rotate_count=t),n.enable_version||(n=this.getDefaultValue(),n.enable_version=!1),this.getForm().setValues(n),this.updateOriginalValues(n)},updateOriginalValues:function(e){!1===e.enable_version&&Ext.apply(e,{rotate_count:0,rotate_policy:"fifo",rotate_days:0}),this.oriValues=Ext.apply({},e)},getMergedRotateCount:function(e){for(var t=-1,i=0;i<e.length;i++){if(-1!=t&&t!=e[i].rotate_cnt)return-1;t=e[i].rotate_cnt}return t},getMergedRotatePolicy:function(e){for(var t="",i=0;i<e.length;i++){if(""!==t&&t!==e[i].rotate_policy)return"";t=e[i].rotate_policy}return t},isValid:function(){return this.inputField.validate()}}),Ext.define("SYNO.SDS.CSTN.DialogMigrateIndexHome",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.to_migrate_count=e.to_migrate_count;var t={title:_STR("migrate_index_home","confirm_title"),cls:"syno-cstn-migrate-index-home-dlg",width:600,height:280,resizable:!1,padding:"16px 20px 0px",layout:"fit",items:this.fillItemsConfig(),fbar:this.fillFbConfig()};Ext.apply(t,e),this.callParent([t])},fillItemsConfig:function(){return{xtype:"syno_formpanel",cls:"no-scroll",labelAlign:"left",border:!1,autoFlexcroll:!1,items:[{xtype:"syno_displayfield",html:String.format(_STR("migrate_index_home","confirm_accounts"),this.to_migrate_count)},{xtype:"syno_displayfield",html:String.format('<div class="note">{0}</div><ul><li>{1}<li>{2}</ul>',_STR("migrate_index_home","confirm_note"),_STR("migrate_index_home","confirm_irreversible"),_STR("migrate_index_home","confirm_consume_resource"))},{xtype:"syno_displayfield",value:_STR("migrate_index_home","confirm_proceed")}]}},fillFbConfig:function(){return{xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[{xtype:"syno_button",btnStyle:"grey",text:_T("common","cancel"),itemId:"cancel",handler:this.onCancel,scope:this},{xtype:"syno_button",btnStyle:"blue",text:_T("common","apply"),disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"apply",handler:this.onOk,scope:this}]}},getProceeding:function(){return this.ok},onOk:function(){this.ok=!0,this.close()},onCancel:function(){this.close()}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PanelAdvancedFeature",{extend:"SYNO.ux.FormPanel",layout:"fit",constructor:function(e){var t={items:this.createVuePanel(e)};this.callParent([Ext.apply(t,e)]),this.addManagedComponent(this.vuePanel)},createVuePanel:function(e){return this.vuePanel=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.CSTN.Vue.PanelAdvancedFeatureActivate,mountId:"PanelAdvancedFeature",layout:"fit",cls:"PanelAdvancedFeature",owner:this}),this.vuePanel}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PanelDatabase",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin,this.BtnApplyId=void 0,this.BtnCancelId=void 0,this.BtnDBUsageId=void 0,this.polling_task=void 0,this.clearRecycleMgr=new SYNO.SDS.CSTN.PanelDatabaseUtils.ClearRecycleManager({owner:this,module:this.module,appWin:this.owner,enableScheduleCheckbox:new SYNO.ux.Checkbox({itemId:"enable_recycle_schedule",name:"enable_recycle_schedule_checkbox",boxLabel:_STR("recycle","enable_recyclebin_schedule_checkbox"),id:Ext.id()}),openScheduleDialogButton:new SYNO.ux.Button({name:"recycle_schedule_btn",text:_STR("common","setting"),id:Ext.id(),disabled:!0}),nextScheduleRunTime:new SYNO.ux.DisplayField({itemId:"next_schedule_run_time",value:"",isDirty:function(){return!1}}),stateDisplayField:new SYNO.ux.DisplayField({value:_STR("common","idle"),isDirty:function(){return!1},reset:function(){}}),clearRecycleBinBtn:new SYNO.ux.Button({text:_STR("recycle","clean_all_view_btn")})});var t=this.fillConfig(e);this.callParent([t])},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){var e=this.getForm();new SYNO.SDS.Utils.EnableCheckGroup(e,"enable_vmtouch",["vmtouch_reserve_mem"])},this,{single:!0})},fillConfig:function(e){var t={labelAlign:"left",labelWidth:150,border:!1,itemId:"configure",cls:"syno-cstn-database-panel",id:this.databasePanelId=Ext.id(),trackResetOnLoad:!0,items:this.getItems(),buttons:[{xtype:"syno_button",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","reset"),itemId:"cancel",id:this.BtnCancelId=Ext.id(),scope:this,handler:this.onCancel},{xtype:"syno_button",btnStyle:"blue",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","commit"),itemId:"apply",id:this.BtnApplyId=Ext.id(),scope:this,handler:this.onSave}]};return t=this.addStatusBar(t),SYNO.LayoutConfig.fill(t),Ext.apply(t,e),t},getItems:function(){this.enableDefaultContentIndexing=new SYNO.ux.Checkbox({name:"default_enable_full_content_indexing",boxLabel:_STR("drive","index_enable_team_folder")}),this.launchContentIndexingSettings=new SYNO.ux.Button({name:"launch_sus",text:_STR("drive","detailed_indexing_settings"),handler:function(){SYNO.SDS.AppLaunch("SYNO.Finder.Application",{fn:"preference",data:{tab:"fileindex",data:{tab:SYNO.SDS.Drive.Extension.Instance.isHomeServiceEnabled()?"SYNO.SDS.Drive.Application:drive:displayname":"SYNO.SDS.Drive.Application:drive:displayname_teamfolder"}}})},scope:this}),this.noteHybridShareNotContentIndexing={xtype:"syno_displayfield",htmlEncode:!1,value:String.format('<span class="syno-ux-note">{0}:</span> {1}',_STR("common","note"),_STR("drive","content_indexing_hybrid_share_not_supported"))},this.enableVMTouch=new SYNO.ux.Checkbox({name:"enable_vmtouch",boxLabel:_STR("drive","enable_vmtouch")}),this.vmtouchReserveMem=new SYNO.ux.NumberField({name:"vmtouch_reserve_mem",indent:1,minValue:10,maxValue:90,width:80,fieldLabel:_STR("drive","vmtouch_reserve_mem")}),this.emailDesc=new SYNO.ux.DisplayField({ctCls:"syno-d-setting-email-desc",value:_STR("setting","notification_email_desc")}),this.emailBtn={xtype:"syno_button",text:_STR("setting","notification_email_launch"),handler:function(){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Notification.Main"})},scope:this},this.enableNonAdminUserSync=new SYNO.ux.Checkbox({name:"enable_non_admin_user_sync",boxLabel:_STR("setting","enable_non_admin_syncing_checkbox")}),this.transferHomeMgr=new SYNO.SDS.CSTN.PanelDatabaseUtils.TransferHomeManager({owner:this.owner,fromUserCombo:new SYNO.SDS.CSTN.ComboBox({fieldLabel:"",name:"from_user",cls:"syno-cstn-database-panel-combobox",lazyInit:!1,width:200,emptyText:_STR("cstn","user_a"),listEmptyText:_STR("common","no_data"),editable:!0,hideTrigger:!0,store:this.getDisabledUserStore(),minChars:1,valueField:"name",displayField:"name",queryParam:"query",mode:"remote",enableKeyEvents:!1,invalidText:_STR("cstn","invalid_transfer_from_user"),submitValue:!1,isDirty:function(){return!1},listeners:{scope:this,beforeDropdownExpand:function(){if(this.transferHomeMgr&&this.transferHomeMgr.fromUserCombo){return""!==this.transferHomeMgr.fromUserCombo.getRawValue()}},onProcessValue:function(e){""===e&&this.transferHomeMgr.fromUserCombo.collapse()}}}),toUserCombo:new SYNO.SDS.CSTN.ComboBox({xtype:"syno_combobox",fieldLabel:"",name:"to_user",cls:"syno-cstn-database-panel-combobox",lazyInit:!1,width:200,emptyText:_STR("cstn","user_b"),listEmptyText:_STR("common","no_data"),editable:!0,hideTrigger:!0,store:this.getEnabledUserStore(),minChars:1,valueField:"name",displayField:"name",queryParam:"query",mode:"remote",enableKeyEvents:!1,invalidText:_STR("cstn","invalid_transfer_to_user"),submitValue:!1,isDirty:function(){return!1},listeners:{scope:this,beforeDropdownExpand:function(){if(this.transferHomeMgr&&this.transferHomeMgr.toUserCombo){return""!==this.transferHomeMgr.toUserCombo.getRawValue()}},onProcessValue:function(e){""===e&&this.transferHomeMgr.toUserCombo.collapse()}}}),transferButton:new SYNO.ux.Button({text:_STR("cstn","transfer_files"),scope:this,handler:this.onTransferHome}),transferProgress:new Ext.ProgressBar({width:200,value:.5,style:"padding-left: 20px; padding-top: 5px;"})});var e=[{xtype:"syno_displayfield",value:_STR("drive","content_indexing_desc"),indent:0},this.enableDefaultContentIndexing,{xtype:"syno_displayfield",value:_STR("drive","customize_indexing_detail"),indent:0},this.launchContentIndexingSettings];SYNO.SDS.CSTN.SupportHybridShare()&&e.push(this.noteHybridShareNotContentIndexing);var t=[{xtype:"syno_fieldset",title:_STR("func","database_title"),labelWidth:"220",items:[{xtype:"syno_displayfield",html:_STR("cstn","desc_db_location_setting"),indent:0,isDirty:function(){return!1},reset:function(){}},{xtype:"syno_displayfield",cls:"drive_warning_msg",value:"",indent:1,hidden:!0,name:"warning"},{xtype:"syno_combobox",name:"volume_select",ctCls:"syno-cstn-grid-combo",fieldLabel:_STR("func","db_location"),valueField:"mount_point",displayField:"display",value:1,store:new Ext.data.JsonStore({fields:["mount_point","display"],data:[{mount_point:"/volume1",display:"Volume1"}]}),forceSelection:!0,mode:"local",hideLabel:!1,selectOnFocus:!0,triggerAction:"all",editable:!1,hidden:!1,width:340,listeners:{scope:this,select:function(e,t){if(t.get("mount_point")!=e.originalValue){var i={};i.warning=_STR("warning","warn_move"),this.getForm().findField("warning").setVisible(!0),this.getForm().setValues(i)}else this.getForm().findField("warning").setVisible(!1)}}},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_displayfield",value:_STR("func","usage")+":",width:215},{xtype:"syno_button",text:_STR("btn","db_usage_calculate"),id:this.BtnDBUsageId=Ext.id(),scope:this,handler:this.startCalculateDBUsage},{xtype:"syno_displayfield",name:"usage",value:_STR("func","db_usage_not_calculated"),cls:"syno-cstn-database-panel-usage-text",isDirty:function(){return!1},reset:function(){}}]},{xtype:"syno_compositefield",hideLabel:!0,id:this.summaryBoxParent=Ext.id(),hidden:!0,items:[{xtype:"spacer",width:215},{cls:"min-fieldset",xtype:"syno_fieldset",items:[{id:this.summaryBoxId=Ext.id(),xtype:"box",cls:"highlight-box",html:""}]}]}]},{xtype:"syno_fieldset",title:_STR("recycle","clean_recycle_bin"),labelWidth:"220",items:[{xtype:"syno_displayfield",htmlEncode:!1,html:_STR("recycle","recycle_desc")+' <a id="recyclebin-clean-schedule-filestation" style="cursor: pointer;">'+_STR("recycle","recycle_control_panel")+"</a>",listeners:{scope:this,afterrender:function(){Ext.get("recyclebin-clean-schedule-filestation").on("click",function(){SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.TaskScheduler.Main"})})}},isDirty:function(){return!1},reset:function(){}},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_displayfield",value:_STR("recycle","clean_status")+_STR("common","colon"),width:215},this.clearRecycleMgr.stateDisplayField]},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_displayfield",value:_STR("recycle","cleanup_button_label")+_STR("common","colon"),width:215},this.clearRecycleMgr.clearRecycleBinBtn]},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_displayfield",value:_STR("recycle","schedule_display_field")+_STR("common","colon"),
width:215},this.clearRecycleMgr.enableScheduleCheckbox]},{xtype:"syno_compositefield",hideLabel:!0,indent:1,items:[{xtype:"spacer",width:215},this.clearRecycleMgr.openScheduleDialogButton,{xtype:"spacer",width:25},this.clearRecycleMgr.nextScheduleRunTime]}]},{xtype:"syno_fieldset",title:_STR("drive","content_indexing"),labelWidth:"220",items:e}];if(SYNO.SDS.CSTN.SupportHybridShare()){this.enableC2ShareOffloadCheckboxId=Ext.id(),this.selectC2ShareOffloadButtonId=Ext.id();var i=this;t.push({xtype:"syno_fieldset",title:_STR("drive","c2_offload_title"),labelWidth:"220",items:[{xtype:"syno_displayfield",value:_STR("drive","c2_offload_desc"),indent:0},{xtype:"syno_checkbox",name:"enable_c2share_offload",boxLabel:_STR("drive","c2_offload_option"),id:this.enableC2ShareOffloadCheckboxId,indent:0,checked:!0,onClick:function(e){this.disabled||this.readOnly||(this.setValue(!this.checked),e.browserEvent.isTrusted&&this.checked&&i.openPrivilegedUserSelectionDialog())},handler:function(){Ext.getCmp(i.selectC2ShareOffloadButtonId).setDisabled(!this.checked)}},{xtype:"syno_displayfield",value:_STR("cstn","customize_hybrid_share_plan"),indent:1},{xtype:"syno_button",name:"hybrid_selected_button",text:_STR("common","edit"),style:"margin-right: 32px !important;",indent:1,id:this.selectC2ShareOffloadButtonId,handler:function(){i.openPrivilegedUserSelectionDialog()}}]})}return Array.prototype.push.apply(t,[{xtype:"syno_fieldset",itemId:"performanceSection",title:_STR("drive","performance"),labelWidth:"220",items:[this.enableVMTouch,this.vmtouchReserveMem]},{xtype:"syno_fieldset",title:_STR("setting","notification_email"),items:[this.emailDesc,this.emailBtn]},{xtype:"syno_fieldset",title:_STR("func","displayname"),labelWidth:"220",items:[{xtype:"syno_displayfield",value:_STR("func","displayname_des"),indent:0,isDirty:function(){return!1},reset:function(){}},{xtype:"syno_combobox",name:"displayname_select",ctCls:"syno-cstn-grid-combo",fieldLabel:_STR("func","displayname_default"),valueField:"value",displayField:"display",store:new Ext.data.JsonStore({fields:["value","display"],data:[{value:"username",display:_STR("common","usrname")},{value:"nickname",display:_STR("common","nickname")}]}),forceSelection:!0,mode:"local",hideLabel:!1,selectOnFocus:!0,triggerAction:"all",editable:!1,hidden:!1,width:300}]},{xtype:"syno_fieldset",title:_STR("setting","enable_non_admin_syncing"),labelWidth:"220",items:[{xtype:"syno_displayfield",html:_STR("setting","enable_non_admin_syncing_desc")+' <a id="disable-sync-learn-more" style="cursor: pointer;">'+_STR("share","know_more")+"</a>",indent:0,listeners:{scope:this,afterrender:function(){Ext.get("disable-sync-learn-more").on("click",function(){var e="SYNO.SDS.Drive.Application:drive_admin_console.html",t="disable-sync-learn-more";_S("standalone")?SYNO.SDS.WindowLaunch("SYNO.SDS.HelpBrowser.Application",{topic:e,anchor:t}):SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:e,anchor:t},!1)})}},isDirty:function(){return!1},reset:function(){}},this.enableNonAdminUserSync]},{xtype:"syno_fieldset",title:_STR("cstn","file_owner_transfer"),collapsible:!1,items:[{xtype:"syno_displayfield",value:_STR("cstn","file_owner_transfer_desc"),isDirty:function(){return!1},reset:function(){}},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_displayfield",value:_STR("cstn","transfer_from"),width:215},this.transferHomeMgr.fromUserCombo]},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_displayfield",value:_STR("cstn","transfer_to"),width:215},this.transferHomeMgr.toUserCombo]},{xtype:"syno_compositefield",hideLabel:!0,items:[this.transferHomeMgr.transferButton,this.transferHomeMgr.transferProgress]}]}]),t},openPrivilegedUserSelectionDialog:function(){var e=this;new SYNO.SDS.CSTN.PanelDatabaseUtils.PrivilegedUserSelectionDialog({owner:this.owner,panel:this,share_name:"",listeners:{close:function(){e.owner.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:[{api:"SYNO.SynologyDrive.HybridShare.Privilege",method:"list",version:1}]},callback:function(t,i,n,s){if(e.owner.clearStatusBusy(),t){0===i.result[0].data.enabled_count&&Ext.getCmp(e.enableC2ShareOffloadCheckboxId).setValue(!1)}}})}}}).open()},onTransferHome:function(){var e=!0,t=this.form.findField("from_user"),i=this.form.findField("to_user");return 0!==t.getValue().length&&-1!=this.findIndexUser(this.getDisabledUserStore(),t.getValue())||(t.markInvalid(),e=!1),0!==i.getValue().length&&-1!=this.findIndexUser(this.getEnabledUserStore(),i.getValue())||(i.markInvalid(),e=!1),i.getValue()===t.getValue()&&(i.markInvalid(),t.markInvalid(),e=!1),!0===e&&this.owner.getMsgBox().confirm(_STR("app","app_name"),_STR("cstn","file_owner_transfer_alert"),function(e){"yes"===e&&(this.transferHomeMgr.disableComponents(),this.sendWebAPI({api:SYNO.SDS.CSTN.WebAPI.Migration.UserHome.api,version:1,method:"start",params:{from:t.getValue(),to:i.getValue()},callback:this.transferHomeMgr.transferCB.bind(this.transferHomeMgr)}))},this),e},findIndexUser:function(e,t){var i=e.createFilterFn("name",t,!1,!1,!0);return(e.snapshot||e.data).findIndexBy(i)},getEnabledUserStore:function(){return this.enabledUserStore||(this.enabledUserStore=this.getUserStore(!0))},getDisabledUserStore:function(){return this.disabledUserStore||(this.disabledUserStore=this.getUserStore(!1))},getUserStore:function(e){return new SYNO.API.Store({appWindow:this,autoLoad:!1,autoDestroy:!0,pruneModifiedRecords:!0,baseParams:{query:"",type:e?"enabled":"disabled"},proxy:new SYNO.API.Proxy(Ext.apply({listeners:{scope:this,load:function(){this.query||this.blQueryEmpty||(this.blQueryEmpty=!0)}}},{api:SYNO.SDS.CSTN.WebAPI.Migration.UserHome.api,method:"list",version:1})),reader:new Ext.data.JsonReader({root:"items",idProperty:"",fields:["name"]})})},addStatusBar:function(e){var t={xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[]};return e.buttons&&(t.items=t.items.concat(e.buttons),delete e.buttons),Ext.applyIf(e,{fbar:t}),e},applyFormFail:function(e){var t="";switch(errinfo=SYNO.API.Util.GetFirstError(e),errinfo.code){case SYNO.SDS.CSTN.ErrorCode.NO_SUCH_API:case SYNO.SDS.CSTN.ErrorCode.PKG_NOT_ENABLED:case SYNO.SDS.CSTN.ErrorCode.SERVICE_DISABLED:case SYNO.SDS.CSTN.ErrorCode.ADMIN_ONLY:case SYNO.SDS.CSTN.ErrorCode.SYS_DISK_FULL:case SYNO.SDS.CSTN.ErrorCode.REPO_MOVE:case SYNO.SDS.CSTN.ErrorCode.CANNOT_ACCESS:return this.onCancel(),void SYNO.SDS.CSTN.webapiErrHdlMain.apply(this,[errinfo]);default:t=SYNO.SDS.CSTN.getErrorString(errinfo)}this.owner.getMsgBox().alert(_STR("app","app_name"),t),this.loadForm()},applyFormSuccess:function(){this.owner.setStatusOK(),this.setStatusOK({text:_T("common","setting_applied"),clear:!0}),this.loadForm()},ajaxApplyFormCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.applyFormSuccess,failure:this.applyFormFail})},applySetting:function(){var e=this.getForm(),t=e.findField("volume_select"),i=e.findField("enable_vmtouch"),n=e.findField("vmtouch_reserve_mem"),s=e.findField("default_enable_full_content_indexing"),o=e.findField("displayname_select"),a=e.findField("enable_non_admin_user_sync"),l=e.findField("enable_c2share_offload")||{isDirty:function(){return!1},getValue:function(){return!1}},r=e.findField("enable_recycle_schedule_checkbox"),d=_STR("common","saving"),c=[];this.owner.setStatusBusy({text:d}),(s.isDirty()||o.isDirty()||l.isDirty())&&c.push({api:"SYNO.SynologyDrive.Settings",method:"update",version:2,params:{default_enable_full_content_indexing:s.getValue(),default_displayname:o.getValue(),enable_c2share_offload:l.getValue()}}),(t.isDirty()||i.isDirty()||n.isDirty()||a.isDirty())&&(t.isDirty()&&(d=_STR("warning","error_drive_repomove")),c.push({api:SYNO.SDS.CSTN.WebAPI.Config.api,method:"set",version:1,params:{db_volume:t.getValue(),enable_vmtouch:i.getValue(),vmtouch_reserve_mem:n.getValue(),enable_non_admin_user_sync:a.getValue()}})),r.isDirty()&&c.push({api:SYNO.SDS.CSTN.WebAPI.Node.Delete.api,version:1,method:"set_schedule",params:{enabled:this.clearRecycleMgr.enableScheduleCheckbox.getValue()},callback:this.clearRecycleMgr.getRecycleBinSchedule.bind(this.clearRecycleMgr),scope:this.clearRecycleMgr}),this.sendWebAPI({compound:{stopwhenerror:!1,params:c},callback:this.ajaxApplyFormCB,scope:this})},loadFormDoneSuccess:function(e){if(!this.isDestroyed){var t=SYNO.API.Util.GetValByAPI(e,"SYNO.SynologyDrive.Settings","list"),i=SYNO.API.Util.GetValByAPI(e,SYNO.SDS.CSTN.WebAPI.Config.api,"get"),n=SYNO.API.Util.GetValByAPI(e,SYNO.SDS.CSTN.WebAPI.Node.Delete.api,"get_schedule"),s=Ext.apply(Ext.apply({},i),t);this.getForm().findField("volume_select").getStore().loadData(s.volume_list),this.getForm().findField("warning").setVisible(!1),this.getForm().findField("displayname_select").setValue(s.default_displayname),this.getForm().findField("displayname_select").originalValue=s.default_displayname,this.getForm().setValues(s),s.support_moving_repository||this.getForm().findField("volume_select").setDisabled(!0);var o=this.getComponent("performanceSection");!o||o.hidden||s.display_vmtouch_option||(this.getComponent("performanceSection").hide(),this.doLayout()),this.clearRecycleMgr.parseSchedule.bind(this.clearRecycleMgr)(n,!0)}},ajaxLoadFormCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.loadFormDoneSuccess,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},loadForm:function(){this.owner.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:[{api:"SYNO.SynologyDrive.Settings",method:"list",version:2},{api:SYNO.SDS.CSTN.WebAPI.Config.api,method:"get",version:1},{api:SYNO.SDS.CSTN.WebAPI.Node.Delete.api,method:"get_schedule",version:1}]},callback:this.ajaxLoadFormCB,scope:this})},checkSrvStatusSuccess:function(){this.loadForm()},ajaxCheckSrvStatusCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.checkSrvStatusSuccess,failure:SYNO.SDS.CSTN.webapiErrHdl})},checkSrvStatus:function(){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.checkUser.call(this.owner,this.ajaxCheckSrvStatusCB,this)},setPollingTask:function(e){void 0!==this.polling_task&&(this.polling_task.remove(),this.polling_task=void 0),e&&(this.polling_task=this.addWebAPITask({interval:2e3,api:SYNO.SDS.CSTN.WEBAPI_NAMESPACE+".DBUsage",version:1,method:"status",params:{},callback:this.updateUsage,scope:this}),this.polling_task.start(!0))},startTaskCB:function(e,t,i,n){e||t.code==SYNO.SDS.CSTN.ErrorCode.DBUSAGE_TASK_RUNNING?(this.setPollingTask(!0),Ext.getCmp(this.BtnDBUsageId).setText(_T("common","cancel")),Ext.getCmp(this.BtnDBUsageId).setHandler(this.stopDBCalculateTask,this),this.doLayout()):this._setUsageStatus("failed")},updateUsage:function(e,t,i,n){!e||t.finish?(this.finishPolling(),this.getCachedDBUsage()):this._setUsageStatus("processing")},finishPolling:function(){this.setPollingTask(!1),Ext.getCmp(this.BtnDBUsageId).setText(_STR("btn","db_usage_calculate")),Ext.getCmp(this.BtnDBUsageId).setHandler(this.startCalculateDBUsage,this),this.doLayout()},stopDBCalculateTask:function(){this.sendWebAPI({api:SYNO.SDS.CSTN.WEBAPI_NAMESPACE+".DBUsage",version:1,method:"stop",params:{},scope:this})},startCalculateDBUsage:function(){this.sendWebAPI({api:SYNO.SDS.CSTN.WEBAPI_NAMESPACE+".DBUsage",version:1,method:"start",params:{},callback:this.startTaskCB,scope:this})},getCachedDBUsageCB:function(e,t,i,n){if(e){if(!t.update_time)return void this._setUsageStatus("empty");var s=SYNO.SDS.CSTN.getFormatDateTimeSec(new Date(1e3*t.update_time)),o=SYNO.SDS.CSTN.CalculateSizeUnit(t.repo_size),a=SYNO.SDS.CSTN.CalculateSizeUnit(t.database_size),l=SYNO.SDS.CSTN.CalculateSizeUnit(t.office_size);this._setUsageStatus("done",s,o,a,l)}else this._setUsageStatus("failed")},getCachedDBUsage:function(){this.sendWebAPI({api:SYNO.SDS.CSTN.WEBAPI_NAMESPACE+".DBUsage",version:1,method:"get",params:{},callback:this.getCachedDBUsageCB,scope:this})},onPageActivate:function(){this._S("is_admin")?(this.loadForm(),this.getCachedDBUsage()):this.checkSrvStatus(),this.clearRecycleMgr.fireEvent("activate"),this.transferHomeMgr.fireEvent("activate")},onPageDeactivate:function(){void 0!==this.polling_task&&(this.stopDBCalculateTask(),this.finishPolling()),this.clearRecycleMgr.fireEvent("deactivate"),this.transferHomeMgr.fireEvent("deactivate")},onActivate:function(){this.onPageActivate()},onDeactivate:function(){this.onPageDeactivate()},checkDirty:function(){return this.getForm().isDirty()},onSave:function(){return this.checkDirty()?this.getForm().isValid()?void this.applySetting():void this.setStatusError({text:_T("common","forminvalid"),clear:!0}):void this.setStatusError({text:_T("error","nochange_subject"),clear:!0})},onCancel:function(){this.getForm().findField("warning").setVisible(!1),this.getForm().reset()},_updateSummeryBox:function(e,t,i,n){var s=Ext.getCmp(this.summaryBoxId),o=Ext.getCmp(this.summaryBoxParent);if(!e)return o.setVisible(!1),void this.doLayout();s.update(this._getSummeryBoxContent(t,i,n)),o.setVisible(!0),this.doLayout()},_getSummeryBoxContent:function(e,t,i){var n="",s='<p class="left-text">{0}</p> <p class="right-text">{1}</p>';return n+=String.format(s,Ext.util.Format.htmlEncode(_STR("cstn","usage_historical_version")+_T("common","colon")),Ext.util.Format.htmlEncode(e)),n+="<br>",n+=String.format(s,Ext.util.Format.htmlEncode(_STR("cstn","usage_app_database")+_T("common","colon")),Ext.util.Format.htmlEncode(t)),SYNO.SDS.CSTN.HasOffice()&&(n+="<br>",n+=String.format(s,Ext.util.Format.htmlEncode(_STR("cstn","usage_synology_office")+_T("common","colon")),Ext.util.Format.htmlEncode(i))),n},_setUsageStatus:function(e,t,i,n,s){var o=this.getForm().findField("usage");o.removeClass("gray-text"),o.removeClass("blue-text"),o.removeClass("red-text"),"done"===e?(o.setValue(t+" ("+_STR("cstn","label_overview_db_last_caculated")+")"),this._updateSummeryBox(!0,i,n,s)):"processing"===e?(o.addClass("blue-text"),o.setValue(_STR("func","db_usage_calculating")),this._updateSummeryBox(!1)):"failed"===e?(o.addClass("red-text"),o.setValue(_STR("func","db_usage_last_calculation_failed")),this._updateSummeryBox(!1)):(o.addClass("gray-text"),o.setValue(_STR("func","db_usage_not_calculated")),this._updateSummeryBox(!1))}}),Ext.define("SYNO.SDS.CSTN.PanelDatabaseUtils.TransferHomeManager",{extend:"Ext.util.Observable",constructor:function(e){Ext.apply(this,e),this.callParent(),this.addEvents(["activate","deactivate"]),this.on("activate",this.onActivate,this),this.on("deactivate",this.onDeactivate,this)},onActivate:function(){this.disableComponents(),this.updateState()},onDeactivate:function(){this.stopPolling()},updateState:function(){this.owner.sendWebAPI({api:SYNO.SDS.CSTN.WebAPI.Migration.UserHome.api,version:1,method:"status",params:{},callback:this.statusCB,scope:this})},statusCB:function(e,t,i,n){e&&("none"===t.status?(this.enabledComponents(),this.stopPolling()):"in_progress"===t.status?(this.onProgress(t.progress,t.from_user,t.to_user),this.startPolling()):"finished"===t.status?(this.owner.getMsgBox().alert(this.owner.title,String.format(_STR("cstn","finished_transfer_msg"),t.from_user,t.to_user)),this.stopPolling(),this.clearComponents()):"failed"===t.status&&(this.owner.getMsgBox().alert(this.owner.title,_STR("cstn","failed_transfer_msg")),this.stopPolling(),this.clearComponents()))},disableComponents:function(){this.fromUserCombo.setDisabled(!0),this.toUserCombo.setDisabled(!0),this.transferButton.setDisabled(!0),this.transferProgress.setVisible(!1)},enabledComponents:function(){this.fromUserCombo.setDisabled(!1),this.toUserCombo.setDisabled(!1),this.transferButton.setDisabled(!1),this.transferProgress.setVisible(!1)},clearComponents:function(){this.fromUserCombo.setDisabled(!1),this.fromUserCombo.setValue(""),this.fromUserCombo.clearInvalid(),this.toUserCombo.setDisabled(!1),this.toUserCombo.setValue(""),this.toUserCombo.clearInvalid(),this.transferButton.setDisabled(!1),this.transferProgress.reset(),this.transferProgress.setVisible(!1)},onProgress:function(e,t,i){this.fromUserCombo.setDisabled(!0),this.fromUserCombo.setValue(t),this.fromUserCombo.clearInvalid(),this.toUserCombo.setDisabled(!0),this.toUserCombo.setValue(i),this.toUserCombo.clearInvalid(),this.transferButton.setDisabled(!0),this.transferProgress.updateProgress(e/100,e+" %"),this.transferProgress.setVisible(!0)},transferCB:function(e,t,i,n){if(!e){var s=SYNO.SDS.CSTN.getErrorString(t);return this.owner.getMsgBox().alert(_STR("app","app_name"),s),void(SYNO.SDS.CSTN.ErrorCode.TRANSFER_RUNNING===t.code?this.startPolling():(this.stopPolling(),this.enabledComponents()))}return this.statusCB(e,t,i,n)},startPolling:function(){this.stopPolling(),this.polling_task=setTimeout(this.updateState.bind(this),2e3)},stopPolling:function(){this.polling_task&&(clearTimeout(this.polling_task),this.polling_task=null)}}),Ext.define("SYNO.SDS.CSTN.PanelDatabaseUtils.ClearRecycleManager",{extend:"Ext.util.Observable",constructor:function(e){SYNO.Assert(e.stateDisplayField,"need stateDisplayField"),SYNO.Assert(e.clearRecycleBinBtn,"need clearRecycleBinBtn"),this.owner=e.owner,this.module=e.module,this.appWin=e.appWin,this.ready=!1,this.setting=!1,SYNO.Assert(e.enableScheduleCheckbox,"need enableScheduleCheckbox"),SYNO.Assert(e.openScheduleDialogButton,"need openScheduleDialogButton"),SYNO.Assert(e.nextScheduleRunTime,"need nextScheduleRunTime"),e.openScheduleDialogButton.setDisabled(!0),Ext.apply(this,e),this.callParent(),this.scheduleData=void 0,this.addEvents(["activate","deactivate"]),this.on("activate",this.onActivate,this),this.on("deactivate",this.onDeactivate,this),this.clearRecycleBinBtn.on("click",this.onBtnClick,this),this.openScheduleDialogButton.on("click",this.openScheduleDialog,this),this.enableScheduleCheckbox.onClick=this.onEnableScheduleCheckboxClick.bind(this),this.enableScheduleCheckbox.handler=this.onEnableScheduleCheckboxCheck.bind(this)},onActivate:function(){this.updateState()},onDeactivate:function(){this.stopPolling()},onBtnClick:function(){this.owner.sendWebAPI({api:SYNO.SDS.CSTN.WEBAPI_NAMESPACE+".Node.Delete",version:1,method:"start",params:{},callback:this.startCB,scope:this})},startCB:function(e,t,i,n){if(e)this.setState("running"),this.startPolling();else{var s=SYNO.SDS.CSTN.getErrorString(t);this.owner.owner.getMsgBox().alert(_STR("app","app_name"),s)}},updateState:function(){this.owner.sendWebAPI({api:SYNO.SDS.CSTN.WEBAPI_NAMESPACE+".Node.Delete",version:1,method:"status",params:{},callback:this.statusCB,scope:this})},statusCB:function(e,t,i,n){if(!e)return void this.setState("error");t.total!==t.current?(this.setState("running"),this.startPolling()):this.setState("idle")},setState:function(e){var t="",i=!1,n=this.enableScheduleCheckbox.getValue();switch(e){case"error":t=_STR("common","error");break;case"running":t=_STR("common","running"),i=!0,buttonDisable=!0,checkboxDisable=!0;break;case"idle":t=_STR("common","idle")}this.clearRecycleBinBtn.setDisabled(i),this.stateDisplayField.setValue(t),this.enableScheduleCheckbox.setDisabled(i),this.openScheduleDialogButton.setDisabled(i||!n)},startPolling:function(){this.stopPolling(),this.polling_task=setTimeout(this.updateState.bind(this),2e3)},stopPolling:function(){this.polling_task&&(clearTimeout(this.polling_task),this.polling_task=null)},findAppWindow:function(){return this.appWin},openScheduleDialog:function(){this.dialogRecycleScheduleWindow=this.appWin.openVueWindow(SYNO.SDS.CSTN.Vue.DialogRecycleSchedule,{findAppWindow:this.findAppWindow.bind(this),scheduleData:this.scheduleData,closeDialog:this.closeDialog.bind(this),synoId:Ext.id()}).window},onEnableScheduleCheckboxCheck:function(){if(this.enableScheduleCheckbox.getValue()){if(this.scheduleData.found&&this.scheduleData.enabled){var e=SYNO.SDS.CSTN.getFormatDateTime(new Date(1e3*this.scheduleData.next_time));this.nextScheduleRunTime.setValue(e+" ("+_STR("schedule","next_trigger_time")+")")}this.openScheduleDialogButton.setDisabled(!1)}else this.nextScheduleRunTime.setValue(""),this.openScheduleDialogButton.setDisabled(!0)},onEnableScheduleCheckboxClick:function(e){if(this.ready)return this.disabled||this.readOnly||this.enableScheduleCheckbox.setValue(!this.enableScheduleCheckbox.getValue()),this.scheduleData.enabled=this.enableScheduleCheckbox.getValue(),this.enableScheduleCheckbox.getValue()?void this.openScheduleDialog():void 0},parseSchedule:function(e,t){if(this.scheduleData=e,this.nextScheduleRunTime.setValue(""),this.scheduleData.found){if(this.setting=!0,t&&(this.enableScheduleCheckbox.value=e.enabled,this.enableScheduleCheckbox.originalValue=e.enabled,this.enableScheduleCheckbox.setValue(e.enabled)),this.enableScheduleCheckbox.getValue()&&this.scheduleData.enabled){var i=SYNO.SDS.CSTN.getFormatDateTime(new Date(1e3*this.scheduleData.next_time));this.nextScheduleRunTime.originalValue=i+" ("+_STR("schedule","next_trigger_time")+")",this.nextScheduleRunTime.setValue(i+" ("+_STR("schedule","next_trigger_time")+")")}if(this.scheduleData.enabled){var n=new Date(1e3*this.scheduleData.next_time)-new Date;this.startGetRecycleBinSchedulePolling(Math.max(n,1e3))}1===this.scheduleData.status?this.setState("running"):this.setState("idle")}else this.enableScheduleCheckbox.setValue(!1);this.ready=!0},getRecycleBinScheduleCB:function(e,t,i,n){if(!e||t.has_fail)return void this.owner.clearStatusBusy();this.parseSchedule(t,!1),this.owner.clearStatusBusy()},closeDialog:function(){this.dialogRecycleScheduleWindow&&(this.getRecycleBinSchedule(),this.dialogRecycleScheduleWindow.close())},startGetRecycleBinSchedulePolling:function(e){this.stopGetRecycleBinSchedulePolling(),this.recycle_bin_polling_task=setTimeout(this.getRecycleBinSchedule.bind(this),e)},stopGetRecycleBinSchedulePolling:function(){this.recycle_bin_polling_task&&(clearTimeout(this.recycle_bin_polling_task),this.recycle_bin_polling_task=null)},getRecycleBinSchedule:function(){this.owner.sendWebAPI({api:SYNO.SDS.CSTN.WebAPI.Node.Delete.api,version:1,method:"get_schedule",params:{},callback:this.getRecycleBinScheduleCB,scope:this})}}),Ext.define("SYNO.SDS.CSTN.PanelDatabaseUtils.EnableColumn",{extend:"SYNO.ux.EnableColumn",constructor:function(e){this.box_id=Ext.id(),this.orgHeader=e.header,e.disableSelectAll||(e.header=String.format("{1}",this.box_id,e.header||"")),SYNO.ux.EnableColumn.superclass.constructor.call(this,e)},renderer:function(e,t,i){return this.checkDisabled(i)?this.disableRenderer(e,t,i):SYNO.ux.EnableColumn.prototype.renderer.call(this,e,t,i)},onChange:function(e){},toggleRec:function(e){var t=SYNO.ux.EnableColumn.prototype.toggleRec.call(this,e);return this.onChange(e),t},isIgnore:function(e,t){return this.checkDisabled(t)},checkDisabled:function(e){return!1}}),Ext.define("SYNO.SDS.CSTN.PanelDatabaseUtils.PrivilegedUserSelectionDialog",{extend:"SYNO.SDS.ModalWindow",pageSize:20,constructor:function(e){this.module=e.module,this.owner=e.owner,this.appWin=e.appWin,this.share_name=e.share_name,this.bannerField=new SYNO.ux.DisplayField({htmlEncode:!1}),this.grid=this.createPanel();var t={width:540,height:560,resizable:!1,cls:"syno-cstn-hybrid-share-user-window",padding:"8px 20px 0px",closeAction:"onCancel",layout:{type:"vbox"},title:_STR("cstn","select_user"),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.bannerField,{xtype:"spacer",height:6},this.grid,{xtype:"spacer",height:12}]};Ext.apply(t,e),this.callParent([t])},createPanel:function(){this.store=this.createStore();var e=this;this.enableColumn=new SYNO.SDS.CSTN.PanelDatabaseUtils.EnableColumn({header:_STR("cstn","header_enable"),tooltip:_STR("cstn","header_enable"),dataIndex:"enabled",width:40,align:"center",checkDisabled:function(t){return!t.data.enabled&&!(e.selectedCount<e.quotaCount)},onChange:function(t){var i=t.data.enabled,n=e.selectedCount+(i?1:-1);e.updateSelectionStatus(n,e.quotaCount),e.grid.view.refresh()}});var t=function(e,t){var i=Ext.util.Format.htmlEncode(e);return t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(i)+'"',i},i=new Ext.grid.ColumnModel([this.enableColumn,{id:"name",header:_T("user","user_account"),dataIndex:"name",renderer:t,width:80}]);this.paging_bar=new SYNO.ux.PagingToolbar({store:this.store,pageSize:this.pageSize,displayInfo:!0,emptyMsg:""}),this.selectionFootBar=new SYNO.ux.DisplayField({htmlEncode:!1}),this.updateSelectionStatus(0,0);var n={cm:i,ds:this.store,flex:1,bwrapCfg:{style:"padding-bottom: 0px;"},plugins:[this.enableColumn],autoExpandColumn:"name",enableColLock:!1,enableHdMenu:!1,cls:"without-dirty-red-grid syno-cstn-user-selection-panel",tbar:this.createTopToolbar(),view:new SYNO.SDS.CSTN.FleXcroll.GridView({store:this.store,searchFields:[this.nameFilter]}),bbar:{style:"padding: 0px;",autoHeight:!0,cls:"bbar",layout:{type:"vbox",align:"stretch"},items:[this.paging_bar,{xtype:"spacer",height:6},this.selectionFootBar]},listeners:{scope:this,afterrender:{fn:this.onAfterRender}}};return new SYNO.ux.GridPanel(n)},createStore:function(){var e=this;return new SYNO.API.JsonStore({appWindow:this,autoDestroy:!0,proxy:new SYNO.API.Proxy({api:"SYNO.SynologyDrive.HybridShare.Privilege",method:"list",version:1,onRequestAPI:function(t,i){return e.updateSelectionStatus(i.enabled_count,i.quota),SYNO.API.Proxy.prototype.onRequestAPI.apply(this,arguments)}}),baseParams:{offset:0,limit:this.pageSize,share_name:this.share_name},fields:[{name:"id"},{name:"name"},{name:"enabled",type:"boolean"}],root:"list",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(){SYNO.SDS.CSTN.WebAPI.getDirSrvStatus.call(this.owner,function(e,t){if(e){var i=[{display:_STR("cstn","local_user"),type:"local",value:"",index:0,content_type:"user"}],n=1;Ext.each(t.domain_names,function(e){var t="-";"ldap"===e.type?t=_STR("cstn","ldap_user"):"domain"===e.type&&(t=_STR("cstn","domain_user")+" ("+e.value+")"),i.push({display:t,type:e.type,value:e.value,index:n++,content_type:"user"})}),this.roleFilter.getStore().loadData(i,!1),this.store.baseParams.type=i[0].type,this.store.load()}else this.win.getMsgBox().alert(_STR("app","app_name"),_T("common","error_system"))},this)},onStoreException:function(e,t,i,n,s){this.clearStatusBusy(),this.getMsgBox().alert(this.title,SYNO.API.Erros.core[s.code]||_T("common","commfail"))},onBeforeLoad:function(e,t){if(this.setStatusBusy({text:_T("common","loading")}),this.isDirty())return this.clearStatusBusy(),this.getMsgBox().confirm(this.title,_T("share","share_save_chg_before_reload"),function(e){"yes"===e?this.confirmSave(t):(this.store.rejectChanges(),this.store.load(t))},this),!1},onLoad:function(){this.clearStatusBusy()},isDirty:function(){return 0<this.store.getModifiedRecords().length},createTopToolbar:function(){return this.roleFilter=new SYNO.ux.ComboBox({itemId:"roleFilter",valueField:"index",displayField:"display",mode:"local",value:0,forceSelection:!0,store:new Ext.data.JsonStore({fields:["display","type","value","content_type","index"],data:[{display:_STR("cstn","local_user"),type:"local",value:"",index:0,content_type:"user"}]}),listeners:{scope:this,beforeselect:{fn:this.onRoleSelect}}}),this.nameFilter=new SYNO.ux.SearchField({iconStyle:"search",itemId:"search",emptyText:_T("share","share_filter_text"),width:180,store:this.store,pageSize:this.pageSize,queryParam:"search",menu:new SYNO.ux.Menu({cls:"syno-ux-check-menu",items:[{checked:!0,value:"all",text:_STR("cstn","show_all")},{value:"enabled",text:_STR("cstn","selected_users")}],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.nameFilter]})},onRoleSelect:function(e,t){this.store.baseParams.type=t.data.type,this.store.baseParams.domain_name=t.data.value,this.store.load()},onTypeFilterSelect:function(e){this.store.baseParams.enabled_only="enabled"===e.value,this.store.load()},updateSelectionStatus:function(e,t){this.selectedCount=e,this.quotaCount=t;var i=_STR("cstn","info_selected_users"),n=String.format(i,e,t,"footbar-selection-field");this.selectionFootBar.setValue(n),i=_STR("cstn","info_hybrid_share_storage_plan"),n=String.format(i,t,"https://c2.synology.com/pricing/storage"),this.bannerField.setValue(n)},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,enabled:t.data.enabled})}),{api:"SYNO.SynologyDrive.HybridShare.Privilege",method:"update",version:1,params:{settings:e,share_name:this.share_name}}},confirmSave:function(e){this.setStatusBusy(),this.sendWebAPI(Ext.apply(this.getWebAPIParams(),{callback:function(t,i){if(this.clearStatusBusy(),!t)return void this.getMsgBox().alert(this.title,SYNO.API.Erros.core[i.code]||_T("common","commfail"));this.store.commitChanges(),this.store.load(e)},scope:this}))},onApply:function(){if(!this.isDirty())return void this.close();this.setStatusBusy(),this.sendWebAPI(Ext.apply(this.getWebAPIParams(),{callback:function(e,t){if(this.clearStatusBusy(),!e)return void this.getMsgBox().alert(this.title,SYNO.API.Erros.core[t.code]||_T("common","commfail"));this.close()},scope:this}))}}),Ext.ns("SYNO.SDS.CSTN.SharingReport"),Ext.define("SYNO.SDS.CSTN.SharingReport.Dialog",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.callParent([this.fillConfig(e)]),this.reportFormat="html",this.reportSavePath.getEl().on("mouseup",this.selectPathHandler,this)},fillConfig:function(e){this.treePanel=new SYNO.SDS.CSTN.SharingReport.TreePanel(e);var t={title:_STR("cstn","sharing_report_dialog_title"),cls:"syno-cstn-sharing-report-dialog",items:[{xtype:"syno_displayfield",value:_STR("cstn","sharing_report_dialog_desc"),cls:"dialog-title"},{layout:"border",border:!1,cls:"dialog-panel",flex:1,items:[this.treePanel]}],layout:{type:"vbox",align:"stretch",pack:"start"},height:560,width:600,resizable:!1};return t=Ext.apply(t,this.initFbar()),t.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({cls:"save-path-selector",fieldLabel:_T("common","folder"),readOnly:!0,allowBlank:!1,validateOnBlur:!1,validationEvent:!1,flex:1,blankText:_T("mediaservice","error_empty_path"),emptyText:_STR("cstn","sharing_report_dialog_path_placeholder")}),{xtype:"syno_toolbar",border:!1,style:{padding:"0 20px"},layout:{type:"vbox",align:"stretch",pack:"start"},items:[{xtype:"syno_panel",hideLabel:!0,layout:"hbox",style:{padding:"0 0 6px 0"},items:[{xtype:"syno_displayfield",value:_STR("cstn","sharing_report_dialog_format")+_T("common","colon"),width:188},{xtype:"syno_radio",boxLabel:"HTML",name:"sharing-report-format",inputValue:"html",checked:!0,width:158,listeners:{scope:this,check:function(e,t){t&&(this.reportFormat="html")}}},{xtype:"syno_radio",boxLabel:"CSV",name:"sharing-report-format",width:150,listeners:{scope:this,check:function(e,t){t&&(this.reportFormat="csv")}}}]},{xtype:"syno_panel",hideLabel:!0,layout:"hbox",items:[{xtype:"syno_displayfield",value:_T("perm_report","save_to")+_T("common","colon"),width:188},{xtype:"syno_panel",layout:"hbox",items:[this.reportSavePath],flex:1}]}]}},selectPathHandler:function(){this.pathSelector||(this.pathSelector=new SYNO.SDS.Utils.FileChooser.Chooser({parent:this,owner:this,resizable:!1,closeOwnerWhenNoShare:!0,closeOwnerNumber:2,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:_STR("btn","btn_export"),minWidth:80,autoHeight:!0,scope:this,handler:this.applyHandler}]}},applyHandler:function(){return this.reportSavePath.isValid()?this.createReport()?void 0:void this.setStatusError({text:_T("mediaservice","select_one"),clear:!0}):void this.setStatusError({text:_T("error","error_bad_field"),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.SynologyDrive.Sharing.Report",version:1,method:"start",params:{files:e,save_path:t,format:this.reportFormat},scope:this,callback:function(e,t){if(!t.task_id||!e)return void this.showMsgBox(_T("error","error_error_system"));this.startExport()}}),!0)},stopPermissionReportPolling:function(){this.sharingReportPollId&&(this.pollUnreg(this.sharingReportPollId),this.sharingReportPollId=void 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.finishExport():this.stopExport()}.createDelegate(this),msg:_STR("cstn","sharing_report_dialog_exporting_desc"),scope:this}),this.sharingReportPollId=this.pollReg({webapi:{api:"SYNO.SynologyDrive.Sharing.Report",method:"status",version:1},interval:2,immediate:!1,scope:this,status_callback:function(e,t){if(!e)return this.finishExport(),void this.getMsgBox().alert("","Failed to get status");"in_progress"!==t.status&&this.finishExport()}})},finishExport:function(){this.stopPermissionReportPolling(),this.closeMsgBox(),this.close()},stopExport:function(){this.stopPermissionReportPolling(),this.stopExportPermissionReport(),this.closeMsgBox(),this.close()},stopExportPermissionReport:function(){this.sendWebAPI({api:"SYNO.SynologyDrive.Sharing.Report",version:1,method:"stop"})},closeMsgBox:function(){this.getMsgBox().getDialog().doClose()},showMsgBox:function(e){this.getMsgBox().alert("",e,function(){this.closeMsgBox(),this.close()}.createDelegate(this))}}),Ext.define("SYNO.SDS.CSTN.SharingReport.TreePanel",{extend:"SYNO.ux.TreePanel",constructor:function(e){this.uiProvider=SYNO.SDS.CSTN.SharingReport.TreeNodeUI,this.callParent([this.fillConfig(e)]),this.mon(this,"checkchange",this.onCheckChange,this)},fillConfig:function(e){var t=new SYNO.SDS.CSTN.SharingReport.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.SynologyDrive.Sharing.Report",method:"list_target",version:1,params:{path:"/"},callback:function(e,t,i){if(!e)return void this.getMsgBox().alert("",SYNO.API.getErrorString(t.code));var n=[];Ext.each(t.items,function(e){Ext.isDefined(e.id)&&n.push(e)},this),this.createShareNode(n)},scope:this})},createShareNode:function(e){var t=this.createTreeLoader(e);this.shareNode="/",this.root.appendChild({id:"/",expanded:!0,leaf:!1,text:this._S("hostname"),loader:t,checked:!1},this)},createTreeLoader:function(e){return new SYNO.SDS.CSTN.SharingReport.TreeLoader({owner:this,nodeData:e,nodeUI:this.uiProvider,sendWebAPI:this.sendWebAPI.createDelegate(this)})},onCheckChange:function(e){var t=e.getUI(),i=function(e){var t=0,i=0;return check_count=0,e.eachChild(function(e){var n=e.getUI()||{};n.checkbox&&Ext.isFunction(n.getCheckValue)&&(!1===n.getCheckValue()?i+=1:!0===n.getCheckValue()&&check_count++,t+=1)}),0===t?e.getUI().getCheckValue():t!==i&&(t===check_count||"gray")},n=function(e,t){e.eachChild(function(e){e.getUI().setCheckValue(t),n(e,t)})};if(original_value=t.getCheckValue(),!1===original_value)t.setCheckValue(!0),n(e,!0);else{if(!0!==original_value&&"gray"!==original_value)return;t.setCheckValue(!1),n(e,!1)}!function(e){for(var t,n,s,o,a=e.parentNode,l=!0;a&&(t=a.getUI())&&a.attributes&&a.attributes.hasOwnProperty("checked")&&(o=t.getCheckValue(),n=o,s=i(a),n===s?l=!1:(t.setCheckValue(s),a=a.parentNode),l););}(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){if(Ext.isDefined(e)&&Ext.isDefined(e.id)){var i=e.id;!0===e.attributes.checked&&(i=i.concat("/*"),t.push(i)),"gray"===e.attributes.checked&&(i=i.concat("/"),t.push(i),Ext.each(e.childNodes,function(e){this.setFolderList(e,t)},this))}}}),Ext.define("SYNO.SDS.CSTN.SharingReport.TreeLoader",{extend:"Ext.tree.TreeLoader",constructor:function(e){this.dataUrl="dummy",this.callParent([e])},requestData:function(e,t,i){if(this.nodeData&&-1!==this.owner.shareNode.indexOf(e.id))this.loadShareNode(e,this.nodeData,t,i);else if(this.sendWebAPI){var n={api:"SYNO.SynologyDrive.Sharing.Report",method:"list_target",version:1,params:{path:e.id},argument:{callback:t,node:e,scope:i},callback:this.handleWebAPIResponse,scope:this};this.sendWebAPI(n)}},loadShareNode:function(e,t,i,n){e.beginUpdate();for(var s=0,o=t.length;s<o;s++){var a=this.createNode(t[s]);a&&e.appendChild(a)}e.endUpdate(),this.runCallback(i,n||e,[e]),this.fireEvent("load",this,e,t)},handleWebAPIResponse:function(e,t,i,n){var s=n.argument,o=s.node,a=o.attributes.checked,l={};if(this.transId=!1,Ext.isDefined(t.items)&&(l=t.items),e){o.beginUpdate();for(var r=0,d=l.length;r<d;r++){l[r].checked=!0===a;var c=this.createNode(l[r]);c&&o.appendChild(c)}o.endUpdate(),this.runCallback(s.callback,s.scope||o,[o]),this.fireEvent("load",this,o,t)}else this.fireEvent("loadexception",this,o,t),this.runCallback(s.callback,s.scope||o,[o])},createNode:function(e){if(e.uiProvider||(e.uiProvider=this.nodeUI?this.nodeUI:"SYNO.SDS.CSTN.SharingReport.TreeNodeUI"),e.draggable=!1,e.leaf=!1,Ext.isDefined(e.id)){if(Ext.isDefined(e.text)&&e.text||(e.text=e.name),Ext.isDefined(e.checked)||(e.checked=!1),Ext.isFunction(this.createNodeFn)){if(!1===this.createNodeFn.call(this.createNodeScope||this,e))return}return this.callParent(arguments)}},onBeforeLoad:function(e,t,i){if(!0===t.disabled)return!1}}),Ext.define("SYNO.SDS.CSTN.SharingReport.TreeNodeUI",{extend:"Ext.tree.TreeNodeUI",renderElements:function(e,t,i,n){this.indentMarkup=e.parentNode?e.parentNode.ui.getChildIndent():"";var s,o=Ext.util.Format.htmlEncode,a=t.input,l=this.getHref(t.href),r=['<li class="x-tree-node syno-extended-tree-node"><div ext:tree-node-id="',o(e.id),'" class="x-tree-node-el x-tree-node-leaf x-unselectable ',t.cls,'" unselectable="on">','<span class="x-tree-node-indent">',this.indentMarkup,"</span>",'<img alt="" src="',this.emptyIcon,'" class="x-tree-ec-icon x-tree-elbow" />','<img alt="" src="',this.emptyIcon,'"  class="syno-tree-node-cb syno-perm-report-tree-node-cb  syno-ux-checkbox-icon" />','<img alt="" src="',t.icon||this.emptyIcon,'" class="x-tree-node-icon',t.icon?" x-tree-node-inline-icon":"",t.iconCls?" "+t.iconCls:"",'" unselectable="on" ',(t.icon||t.iconCls?"":'style="display: none;"')+"/>",'<a hidefocus="on" class="x-tree-node-anchor" href="',l,'" tabIndex="1" ',t.hrefTarget?' target="'+t.hrefTarget+'"':"",'><span unselectable="on">',o(e.text),"</span></a>","</div>",'<ul class="x-tree-node-ct" style="display:none;"></ul>',"</li>"].join("");!0!==n&&e.nextSibling&&(s=e.nextSibling.ui.getEl())?this.wrap=Ext.DomHelper.insertHtml("beforeBegin",s,r):this.wrap=Ext.DomHelper.insertHtml("beforeEnd",i,r),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){this.rendered&&this.elNode.setAttribute("ext:tree-node-id",Ext.util.Format.htmlEncode(e))},createInputField:function(e,t,i){var n=e;switch(Ext.isObject(e)?(this.inputConfig=Ext.apply({},e),n=e.xtype||"textfield",delete e.xtype):this.inputConfig={},Ext.isDefined(t.value)&&(this.inputConfig.value=t.value),this.inputConfig.renderTo=i,n){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.CSTN"),Ext.define("SYNO.SDS.CSTN.PanelSharingLink",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin,this.BtnApplyId=void 0,this.BtnCancelId=void 0,this.sharing_link_options=null,this.sharingReportPollId=void 0;var t=this.fillConfig(e);this.callParent([t])},initEvents:function(){this.callParent(arguments),this.mon(this,"afterlayout",function(){var e=this.getForm();new SYNO.SDS.Utils.EnableCheckGroup(e,"enable_sharing_link_customization",["sharing_link_customization","customized_sharing_link_preview"]),new SYNO.SDS.Utils.EnableCheckGroup(e,"sharing_force_expiration_checkbox",["sharing_force_expiration_title","sharing_force_expiration_text"]),new SYNO.SDS.Utils.EnableCheckGroup(e,"sharing_enabled",["sharing_public_enabled","sharing_internal_level"]),new SYNO.SDS.Utils.EnableCheckGroup(e,"sharing_public_enabled",["sharing_force_selected","sharing_force_password","sharing_force_expiration_checkbox"]),new SYNO.SDS.Utils.EnableCheckGroup(e,"file_request_force_expiration_checkbox",["file_request_force_expiration_title","file_request_force_expiration_text"]),new SYNO.SDS.Utils.EnableCheckGroup(e,"file_request_enabled",["file_request_force_selected","file_request_force_password","file_request_force_expiration_checkbox","file_request_link_by_email"])},this,{single:!0}),this.mon(this,"beforeshow",function(){this.getComponent("file_request_settings").getComponent("prompt").setVisible(!SYNO.SDS.CSTN.Config.advanced_feature_activated)},this),this.mon(this,"show",function(){var e=Ext.get("jump-to-activate");e&&e.on("click",function(e){e.preventDefault(),this.owner.selectPage("SYNO.SDS.CSTN.PanelAdvancedFeature")}.bind(this))},this)},fillConfig:function(e){this.forceHTTPSSharingLink=new SYNO.ux.Checkbox({name:"force_https_sharing_link",boxLabel:_STR("setting","force_https_sharing_link")}),this.enableCustomizedSharingLink=new SYNO.ux.Checkbox({name:"enable_sharing_link_customization",boxLabel:_STR("setting","enable_sharing_link_customization")}),this.customizedSharingLinkOptions=new SYNO.ux.ComboBox({name:"sharing_link_customization",fieldLabel:_STR("setting","sharing_link_domain"),indent:1,ctCls:"syno-cstn-grid-combo",valueField:"option_id",displayField:"display",store:new Ext.data.JsonStore({fields:["option_id","display"],data:[]}),forceSelection:!0,mode:"local",hideLabel:!1,selectOnFocus:!0,triggerAction:"all",editable:!1,hidden:!1,width:300,validator:function(e){if(null===this.sharing_link_options)return!0;for(var t=0;t<this.sharing_link_options.length;t++)if(this.sharing_link_options[t].display===e)return this.sharing_link_options[t].valid;return!1}.createDelegate(this),listeners:{scope:this,afterrender:function(e){SYNO.SDS.Utils.AddTip(e.el.dom,_STR("setting","customized_sharing_link_options_tooltip"))},select:function(e,t){this.rearrangeSharingLinkComponent(t.data.option_id)},enable:function(){this.rearrangeSharingLinkComponent()},disable:function(){this.getForm().findField("sharing_link_fully_custom_url").setDisabled(!0)}}}),this.customizedSharingLinkPreview=new SYNO.ux.DisplayField({name:"customized_sharing_link_preview",value:"dummy",fieldLabel:_STR("setting","customized_sharing_link_preview"),hidden:!0,indent:1}),this.customizedSharingLinkInputField=new SYNO.ux.TextField({name:"sharing_link_fully_custom_url",fieldLabel:_STR("setting","sharing_link_last_fully_custom_url"),emptyText:"https://example.com",validator:function(e){return url_regex_str=["^(","(?:(?:http|https):\\/\\/)?","(?:((?!\\/)\\S)+(?::((?!\\/)\\S)*)?@)?","(?:","(?:","\\[(?:","([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|","([0-9a-fA-F]{1,4}:){1,7}:|","([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|","([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|","([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|","([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|","([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|","[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|",":((:[0-9a-fA-F]{1,4}){1,7}|:)|","fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|","::(ffff(:0{1,4}){0,1}:){0,1}","((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|","([0-9a-fA-F]{1,4}:){1,4}:","((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])",")\\]|","((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])",")|","(?:","(?:[a-zA-Z0-9][a-zA-Z0-9_-]*)","(?:","(?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)*","(?:\\.[a-zA-Z]{2,})",")?",")",")","(?::\\d{2,5})?","(?:\\/[^\\s]*)?",")$"].join(""),new RegExp(url_regex_str).test(e)},hidden:!0,indent:1}),this.customizedSharingLinkInputField.setWidth(300),this.selectedButtonId=Ext.id(),this.selectedTextId=Ext.id(),this.selectedCheckboxId=Ext.id(),this.selectedUids=[],this.selectedGids=[],this.sharingReportFieldId=Ext.id(),this.sharingReportExportButtonId=Ext.id(),this.sharingReportCancelButtonId=Ext.id(),this.fileRequestSelectedUids=[],this.fileRequestSelectedGids=[];var t=this;this.sharingLinkSettings=[{xtype:"syno_checkbox",boxLabel:_STR("cstn","enable_file_sharing"),name:"sharing_enabled",handler:function(e,i){t.enableSharingSelected(i)}},{xtype:"syno_displayfield",name:"sharing_interal_selected_text",value:_STR("cstn","enable_file_sharing_desc"),indent:1},{xtype:"syno_radio",boxLabel:_STR("cstn","sharing_internal_level_link"),name:"sharing_internal_level",inputValue:"link",indent:2},{xtype:"syno_radio",boxLabel:_STR("cstn","sharing_internal_level_invite"),name:"sharing_internal_level",inputValue:"invite",indent:2},{xtype:"syno_radio",boxLabel:_STR("cstn","sharing_internal_level_both"),name:"sharing_internal_level",inputValue:"both",indent:2},{xtype:"syno_checkbox",boxLabel:_STR("cstn","enable_file_public_sharing"),name:"sharing_public_enabled",indent:1,handler:function(e,i){t.enableSharingSelected(i)}},{xtype:"syno_checkbox",boxLabel:_STR("cstn","public_sharing_allow_selected"),name:"sharing_force_selected",indent:2,id:this.selectedCheckboxId,onClick:function(e){this.disabled||this.readOnly||(this.setValue(!this.checked),t.enableSharingSelected(this.checked),this.checked?e.browserEvent.isTrusted&&Ext.getCmp(t.selectedButtonId).el.dom.click():(t.updateSelectedUid([]),t.updateSelectedGid([]))),t.updateSelectedText()}},{xtype:"syno_panel",layout:"table",bodyStyle:"padding: 2px 0px 2px 84px;",items:[{xtype:"syno_button",name:"sharing_force_selected_button",inputValue:"fifo",text:_STR("common","edit"),style:"margin-right: 32px !important;",id:this.selectedButtonId,disabled:!0,handler:function(){new SYNO.SDS.CSTN.Sharing.DialogSelectionEdit({owner:this.owner,panel:this}).open()}.bind(this)},{xtype:"syno_displayfield",name:"sharing_force_selected_text",value:_STR("cstn","no_selection"),style:"padding-top: 0px;",id:this.selectedTextId,disabled:!0}]},{xtype:"syno_checkbox",boxLabel:_STR("cstn","public_sharing_force_password"),name:"sharing_force_password",indent:2},{xtype:"syno_checkbox",boxLabel:_STR("cstn","public_sharing_with_expiration"),name:"sharing_force_expiration_checkbox",indent:2,handler:function(e,t){var i=this.getForm().findField("sharing_force_expiration_text");t?i.setValue("30"):i.setValue("")}.bind(this)},{xtype:"syno_panel",bodyStyle:"padding: 2px 0px 2px 84px;",layout:{type:"table"},items:[{xtype:"syno_displayfield",value:_STR("cstn","max_force_expired_days"),style:"margin-right: 32px;",name:"sharing_force_expiration_title"},{xtype:"syno_textfield",value:"30",width:100,style:"margin-right: 8px;",name:"sharing_force_expiration_text",invalidText:String.format(_STR("cstn","max_force_expired_days_invaild_text"),1,999),validator:function(e){if(!this.getForm().findField("sharing_force_expiration_checkbox").checked)return!0;var t=parseInt(e,10);return t>0&&t<=999}.bind(this)}]}],this.activate_advanced_feature_prompt={xtype:"container",cls:"advanced-feature-activation-prompt",itemId:"prompt",layout:{type:"hbox"},items:[{xtype:"container",cls:"icon"},{xtype:"spacer",width:6},{xtype:"syno_displayfield",itemId:"link",htmlEncode:!1,cls:"text",value:String.format(_STR("activate_advance_feature","toast_must_be_activated_before_modifying_option_plural"),"",'<a id="jump-to-activate" class="link">'+_STR("func","mgr_advance_feature")+"</a>","")}]},this.fileRequestLinkSettings=[{xtype:"syno_checkbox",boxLabel:_STR("cstn","enable_file_request"),name:"file_request_enabled",scope:this,handler:function(e,i){t.enableFileRequestSelected(i)}},{xtype:"syno_checkbox",boxLabel:_STR("cstn","file_request_allow_selected"),name:"file_request_force_selected",indent:1,scope:this,onClick:function(e){this.disabled||this.readOnly||(this.setValue(!this.checked),t.enableFileRequestSelected(this.checked),this.checked?e.browserEvent.isTrusted&&t.getComponent("file_request_settings").getComponent("settings").getComponent("file_request_force_selected_panel").getComponent("file_request_force_selected_button").el.dom.click():(t.updateFileRequestSelectedUid([]),t.updateFileRequestSelectedGid([])))},handler:function(e,i){t.getComponent("file_request_settings").getComponent("settings").getComponent("file_request_force_selected_panel").getComponent("file_request_force_selected_button").setDisabled(!i),t.updateFileRequestSelectedText()}},{xtype:"syno_panel",layout:"table",bodyStyle:"padding: 2px 0px 2px 57px;",itemId:"file_request_force_selected_panel",items:[{xtype:"syno_button",name:"file_request_force_selected_button",inputValue:"fifo",text:_STR("common","edit"),style:"margin-right: 32px !important;",itemId:"file_request_force_selected_button",disabled:!0,scope:this,handler:function(){new SYNO.SDS.CSTN.FileRequest.DialogSelectionEdit({owner:this.owner,panel:this}).open()}},{xtype:"syno_displayfield",name:"file_request_force_selected_text",value:_STR("cstn","no_selection"),style:"padding-top: 0px;",itemId:"file_request_force_selected_text",disabled:!0}]},{xtype:"syno_checkbox",boxLabel:_STR("cstn","public_sharing_force_password"),name:"file_request_force_password",itemId:"file_request_force_password",indent:1},{xtype:"syno_checkbox",boxLabel:_STR("cstn","public_sharing_with_expiration"),name:"file_request_force_expiration_checkbox",itemId:"file_request_force_expiration_checkbox",indent:1,scope:this,handler:function(e,t){var i=this.getForm().findField("file_request_force_expiration_text");t?i.setValue("7"):i.setValue(""),this.getComponent("file_request_settings").getComponent("settings").getComponent("file_request_force_expiration_panel").setDisabled(!t)}},{xtype:"syno_panel",bodyStyle:"padding: 2px 0px 2px 56px;",itemId:"file_request_force_expiration_panel",layout:{type:"table"},items:[{xtype:"syno_displayfield",value:_STR("cstn","max_force_expired_days"),style:"margin-right: 32px;",name:"file_request_force_expiration_title"},{xtype:"syno_textfield",value:"7",width:100,style:"margin-right: 8px;",name:"file_request_force_expiration_text",invalidText:String.format(_STR("cstn","max_force_expired_days_invaild_text"),1,999),validator:function(e){if(!this.getForm().findField("file_request_force_expiration_checkbox").checked)return!0;var t=parseInt(e,10);return t>0&&t<=999}.bind(this)}]},{xtype:"syno_checkbox",boxLabel:_STR("cstn","enable_show_mail_link"),name:"file_request_link_by_email",indent:1,itemId:"file_request_link_by_email"}];var t=this,i={labelAlign:"left",labelWidth:150,border:!1,itemId:"configure-sharing-link",trackResetOnLoad:!0,items:[{xtype:"syno_fieldset",title:_STR("cstn","sharing_setting_for_non_admin"),items:[this.sharingLinkSettings,{xtype:"syno_checkbox",boxLabel:_STR("cstn","enable_show_mail_link"),name:"sharing_link_by_email"}]},{xtype:"syno_fieldset",title:_STR("cstn","sharing_report_title"),id:this.sharingReportFieldId,cls:"syno-cstn-sharing-report-field",items:[{xtype:"syno_displayfield",value:_STR("cstn","sharing_report_desc")},{xtype:"syno_compositefield",hideLabel:!0,items:[{xtype:"syno_button",hidden:!1,text:_STR("btn","btn_export"),id:this.sharingReportExportButtonId,handler:function(){new SYNO.SDS.CSTN.SharingReport.Dialog({owner:t.findWindow(),listeners:{close:function(){t.startPollingSharingReportStatus(!0)}}}).open()}},{xtype:"syno_button",hidden:!0,text:_T("common","cancel"),id:this.sharingReportCancelButtonId,handler:function(){this.sendWebAPI({api:"SYNO.SynologyDrive.Sharing.Report",version:1,method:"stop"})}},{xtype:"syno_displayfield",cls:"syno-cstn-sharing-report-status-text",value:_STR("cstn","sharing_report_exporting")}]}]},{xtype:"syno_fieldset",cls:"syno-cstn-sharing-link-field",title:_STR("drive","custom_sharing_link_url"),labelWidth:"220",items:[this.forceHTTPSSharingLink,this.enableCustomizedSharingLink,{xtype:"syno_displayfield",htmlEncode:!1,value:_STR("drive","customized_sharing_link_desc"),indent:1},this.customizedSharingLinkOptions,this.customizedSharingLinkPreview,this.customizedSharingLinkInputField,{xtype:"syno_displayfield",name:"sharing_link_note",htmlEncode:!1,value:'<span class="syno-ux-note">'+_STR("common","note")+_STR("common","colon")+" </span>"+_STR("drive","customized_sharing_link_note"),indent:1}]},{xtype:"syno_fieldset",title:_STR("cstn","file_request_setting"),labelWidth:"220",itemId:"file_request_settings",items:[this.activate_advanced_feature_prompt,{xtype:"container",itemId:"settings",items:[this.fileRequestLinkSettings],listeners:{afterlayout:function(e){SYNO.SDS.CSTN.Config.advanced_feature_activated?e.el.unmask():e.el.mask()}.bind(this)}}]}],buttons:[{xtype:"syno_button",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","reset"),itemId:"cancel",id:this.BtnCancelId=Ext.id(),scope:this,handler:this.onCancel},{xtype:"syno_button",btnStyle:"blue",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","commit"),itemId:"apply",id:this.BtnApplyId=Ext.id(),scope:this,handler:this.onSave}]};return i=this.addStatusBar(i),SYNO.LayoutConfig.fill(i),Ext.apply(i,e),i},getSelectedUid:function(){return this.selectedUids},getSelectedGid:function(){return this.selectedGids},updateSelectedUid:function(e){this.selectedUids=e,this.updateSelectedText()},updateSelectedGid:function(e){this.selectedGids=e,this.updateSelectedText()},updateSelectedText:function(){var e=Ext.getCmp(this.selectedTextId);if(!0!==Ext.getCmp(this.selectedCheckboxId).getValue())return void e.setVisible(!1);var t=this.selectedUids.length+this.selectedGids.length;1==t?e.setValue(_STR("cstn","member_selected_single")):t>1?e.setValue(String.format(_STR("cstn","member_selected_multiple"),t)):e.setValue(_STR("cstn","no_selection")),e.originalValue=e.getValue(),e.setVisible(!0)},getFileRequestSelectedUids:function(){return this.fileRequestSelectedUids},getFileRequestSelectedGids:function(){return this.fileRequestSelectedGids},updateFileRequestSelectedUid:function(e){this.fileRequestSelectedUids=e,this.updateFileRequestSelectedText()},updateFileRequestSelectedGid:function(e){this.fileRequestSelectedGids=e,this.updateFileRequestSelectedText()},updateFileRequestSelectedText:function(){var e=this.getForm(),t=e.findField("file_request_force_selected_text");if(!0!==e.findField("file_request_force_selected").getValue())return void t.setVisible(!1);var i=this.fileRequestSelectedUids.length+this.fileRequestSelectedGids.length;1==i?t.setValue(_STR("cstn","member_selected_single")):i>1?t.setValue(String.format(_STR("cstn","member_selected_multiple"),i)):t.setValue(_STR("cstn","no_selection")),t.originalValue=t.getValue(),t.setVisible(!0)},enableFormItem:function(e,t){for(var i=0;i<this.getForm().items.items.length;i++)this.getForm().items.items[i].name===e&&this.getForm().items.items[i].setDisabled(!t)},enableSharingInternalLevel:function(e){this.enableFormItem("sharing_internal_level",e)},enableSharingSelected:function(e){var t=!0;!1!==e&&!1!==Ext.getCmp(this.selectedCheckboxId).getValue()||(t=!1),Ext.getCmp(this.selectedButtonId).setDisabled(!t)},enableFileRequestSelected:function(e){var t=this.getComponent("file_request_settings").getComponent("settings"),i=t.getComponent("file_request_force_selected_panel"),n=this.getForm(),s=n.findField("file_request_force_selected").getValue(),o=n.findField("file_request_force_expiration_checkbox").getValue();i.getComponent("file_request_force_selected_button").setDisabled(!e||!s),n.findField("file_request_force_password").setDisabled(!e),n.findField("file_request_force_expiration_checkbox").setDisabled(!e),t.getComponent("file_request_force_expiration_panel").setDisabled(!e||!o),n.findField("file_request_link_by_email").setDisabled(!e)},addStatusBar:function(e){var t={xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[]};return e.buttons&&(t.items=t.items.concat(e.buttons),delete e.buttons),Ext.applyIf(e,{fbar:t}),e},applyFormFail:function(e){var t="";switch(errinfo=SYNO.API.Util.GetFirstError(e),errinfo.code){case SYNO.SDS.CSTN.ErrorCode.NO_SUCH_API:case SYNO.SDS.CSTN.ErrorCode.PKG_NOT_ENABLED:case SYNO.SDS.CSTN.ErrorCode.SERVICE_DISABLED:case SYNO.SDS.CSTN.ErrorCode.ADMIN_ONLY:case SYNO.SDS.CSTN.ErrorCode.SYS_DISK_FULL:case SYNO.SDS.CSTN.ErrorCode.REPO_MOVE:case SYNO.SDS.CSTN.ErrorCode.CANNOT_ACCESS:return this.onCancel(),void SYNO.SDS.CSTN.webapiErrHdlMain.apply(this,[errinfo]);default:t=SYNO.SDS.CSTN.getErrorString(errinfo)}this.owner.getMsgBox().alert(_STR("app","app_name"),t),this.loadForm()},applyFormSuccess:function(){SYNO.SDS.CSTN.showToastMsg(this.owner,_T("common","setting_applied")),this.loadForm()},ajaxApplyFormCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.applyFormSuccess,failure:this.applyFormFail})},getRadioResult:function(e){for(var t=0;t<this.getForm().items.items.length;t++){var i=this.getForm().items.items[t];if(i.name===e&&i.checked)return i.inputValue}},getRadioIsDirty:function(e){for(var t=0;t<this.getForm().items.items.length;t++){var i=this.getForm().items.items[t];if(i.name===e&&i.isDirty())return!0}return!1},setSelectedFieldDirty:function(){this.selectSelectedFieldDirty=!0},isSelectedFieldDirty:function(){return!0===this.selectSelectedFieldDirty},resetSelectedField:function(){this.selectSelectedFieldDirty=void 0,this.selectedUids=this.oldSelectedUid,this.selectedGids=this.oldSelectedGid,this.updateSelectedText()},setFileRequestSelectedFieldDirty:function(){this.fileRequestSelectedFieldDirty=!0},isFileRequestSelectedFieldDirty:function(){return!0===this.fileRequestSelectedFieldDirty},resetFileRequestSelectedField:function(){this.fileRequestSelectedFieldDirty=void 0,this.fileRequestSelectedUids=this.oldFileRequestSelectedUids,this.fileRequestSelectedGids=this.oldFileRequestSelectedGids,this.updateFileRequestSelectedText()},applySetting:function(){var e=this.getForm(),t=e.findField("sharing_enabled"),i=e.findField("sharing_public_enabled"),n=e.findField("sharing_force_selected"),s=e.findField("sharing_force_password"),o=e.findField("sharing_force_expiration_checkbox"),a=e.findField("sharing_force_expiration_text"),l=e.findField("force_https_sharing_link"),r=e.findField("enable_sharing_link_customization"),d=e.findField("sharing_link_customization"),c=e.findField("sharing_link_fully_custom_url"),h=e.findField("sharing_link_by_email"),_=e.findField("file_request_enabled"),u=e.findField("file_request_force_selected"),p=e.findField("file_request_force_password"),S=e.findField("file_request_force_expiration_checkbox"),g=e.findField("file_request_force_expiration_text"),f=e.findField("file_request_link_by_email"),m=_STR("common","saving"),y=[];if(this.owner.setStatusBusy({text:m}),t.isDirty()||i.isDirty()||this.getRadioIsDirty("sharing_internal_level")||n.isDirty()||this.isSelectedFieldDirty()||s.isDirty()||o.isDirty()||o.checked&&a.isDirty()||l.isDirty()||r.isDirty()||d.isDirty()||c.isDirty()||h.isDirty()||_.isDirty()||u.isDirty()||p.isDirty()||S.isDirty()||S.checked&&g.isDirty()||f.isDirty()||this.isFileRequestSelectedFieldDirty()){var b="disallow";t.checked&&i.checked?b="public":t.checked&&(b="internal"),y.push({api:"SYNO.SynologyDrive.Settings",method:"update",version:2,params:{sharing_level:b,sharing_internal_level:this.getRadioResult("sharing_internal_level"),sharing_force_selected:n.getValue(),sharing_force_password:s.getValue(),sharing_force_expiration:o.checked&&parseInt(a.getValue(),10)>=0?parseInt(a.getValue(),10):0,force_https_sharing_link:l.getValue(),enable_sharing_link_customization:r.getValue(),sharing_link_customization:d.getValue(),sharing_link_fully_custom_url:c.getValue(),sharing_force_selected_users:this.getSelectedUid(),sharing_force_selected_groups:this.getSelectedGid(),sharing_link_by_email:h.getValue(),file_request_enabled:_.getValue(),file_request_force_selected:u.getValue(),file_request_force_password:p.getValue(),file_request_force_expiration:S.checked&&parseInt(g.getValue(),10)>=0?parseInt(g.getValue(),10):0,file_request_link_by_email:f.getValue(),file_request_force_selected_users:this.getFileRequestSelectedUids(),file_request_force_selected_groups:this.getFileRequestSelectedGids()}})}this.sendWebAPI({compound:{stopwhenerror:!1,params:y},callback:this.ajaxApplyFormCB,scope:this})},loadFormDoneSuccess:function(e){if(!this.isDestroyed){var t=SYNO.API.Util.GetValByAPI(e,"SYNO.SynologyDrive.Settings","list");this.sharing_link_options=t.sharing_link_options;for(var i=[],n=0;n<this.sharing_link_options.length;n++)this.sharing_link_options[n].display=_STR("setting","sharing_url_type_"+this.sharing_link_options[n].option_id),this.sharing_link_options[n].valid?i.push(this.sharing_link_options[n]):t.sharing_link_customization===this.sharing_link_options[n].option_id&&(t.sharing_link_customization=this.sharing_link_options[n].display);this.getForm().findField("sharing_link_customization").getStore().loadData(i);var s=t.sharing_force_expiration;switch(s>0?(this.getForm().setValues({sharing_force_expiration_checkbox:!0}),this.getForm().setValues({sharing_force_expiration_text:s})):(this.getForm().setValues({sharing_force_expiration_checkbox:!1}),
this.getForm().setValues({sharing_force_expiration_text:""})),s=t.file_request_force_expiration,s>0?(this.getForm().setValues({file_request_force_expiration_checkbox:!0}),this.getForm().setValues({file_request_force_expiration_text:s})):(this.getForm().setValues({file_request_force_expiration_checkbox:!1}),this.getForm().setValues({file_request_force_expiration_text:""})),this.getForm().setValues(t),t.sharing_level){case"public":this.getForm().setValues({sharing_enabled:!0,sharing_public_enabled:!0});break;case"internal":this.getForm().setValues({sharing_enabled:!0,sharing_public_enabled:!1});break;default:this.getForm().setValues({sharing_enabled:!1,sharing_public_enabled:!1})}""===t.sharing_link_customization&&i.length>0?(this.getForm().setValues({sharing_link_customization:i[0].option_id}),this.rearrangeSharingLinkComponent(i[0].option_id)):this.rearrangeSharingLinkComponent(t.sharing_link_customization),this.oldSelectedUid=t.sharing_force_selected_users,this.oldSelectedGid=t.sharing_force_selected_groups,this.resetSelectedField(),this.oldFileRequestSelectedUids=t.file_request_force_selected_users,this.oldFileRequestSelectedGids=t.file_request_force_selected_groups,this.resetFileRequestSelectedField()}},ajaxLoadFormCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.loadFormDoneSuccess,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},loadForm:function(){this.owner.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!1,params:[{api:"SYNO.SynologyDrive.Settings",method:"list",version:2}]},callback:this.ajaxLoadFormCB,scope:this})},checkSrvStatusSuccess:function(){this.loadForm()},ajaxCheckSrvStatusCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.checkSrvStatusSuccess,failure:SYNO.SDS.CSTN.webapiErrHdl})},checkSrvStatus:function(){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.checkUser.call(this.owner,this.ajaxCheckSrvStatusCB,this)},startPollingSharingReportStatus:function(e){this.sharingReportPollId&&e&&this.stopPollingSharingReportStatus(),this.sharingReportPollId||(this.sharingReportPollId=this.pollReg({webapi:{api:"SYNO.SynologyDrive.Sharing.Report",method:"status",version:1},interval:5,immediate:!0,scope:this,status_callback:function(e,t){e&&("in_progress"!==t.status?this.updateSharingReportStatus(!1):this.updateSharingReportStatus(!0))}}))},stopPollingSharingReportStatus:function(){this.sharingReportPollId&&(this.pollUnreg(this.sharingReportPollId),this.sharingReportPollId=void 0)},updateSharingReportStatus:function(e){e?(Ext.getCmp(this.sharingReportFieldId).addClass("syno-cstn-sharing-report-progress"),Ext.getCmp(this.sharingReportExportButtonId).hide(),Ext.getCmp(this.sharingReportCancelButtonId).show()):(Ext.getCmp(this.sharingReportFieldId).removeClass("syno-cstn-sharing-report-progress"),Ext.getCmp(this.sharingReportExportButtonId).show(),Ext.getCmp(this.sharingReportCancelButtonId).hide())},onPageActivate:function(){this._S("is_admin")?this.loadForm():this.checkSrvStatus(),this.startPollingSharingReportStatus()},onActivate:function(){this.onPageActivate()},onPageDeactivate:function(){this.stopPollingSharingReportStatus()},onDeactivate:function(){this.onPageDeactivate()},checkDirty:function(){return this.getForm().isDirty()||this.isSelectedFieldDirty()||this.isFileRequestSelectedFieldDirty()},onSave:function(){return this.checkDirty()?this.getForm().isValid()?void this.applySetting():void SYNO.SDS.CSTN.showToastMsg(this.owner,_T("common","forminvalid")):void SYNO.SDS.CSTN.showToastMsg(this.owner,_T("error","nochange_subject"))},onCancel:function(){this.getForm().reset(),this.resetSelectedField(),this.resetFileRequestSelectedField(),this.rearrangeSharingLinkComponent()},rearrangeSharingLinkComponent:function(e){var t=this.getForm().findField("sharing_link_customization");e=e||t.getValue();var i=this.getForm().findField("customized_sharing_link_preview"),n=this.getForm().findField("sharing_link_note"),s=this.getForm().findField("sharing_link_fully_custom_url");if("fully_customized"!=e){for(var o=0;o<this.sharing_link_options.length;o++)this.sharing_link_options[o].option_id===e&&this.getForm().setValues({customized_sharing_link_preview:this.sharing_link_options[o].preview});i.setVisible(!0),n.setVisible(!0),s.setVisible(!1),s.setDisabled(!0)}else i.setVisible(!1),n.setVisible(!1),s.setVisible(!0),t.disabled||s.setDisabled(!1);this.doLayout()}}),Ext.define("SYNO.SDS.CSTN.Sharing.DialogSelectionEdit",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.win=e.owner,this.panel=e.panel;var t={xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[{xtype:"syno_button",btnStyle:"grey",hidden:!1,text:_T("common","cancel"),itemId:"cancel",id:this.BtnCancelId=Ext.id(),scope:this,handler:this.onCancel},{xtype:"syno_button",btnStyle:"blue",hidden:!1,text:_T("common","commit"),itemId:"apply",id:this.BtnApplyId=Ext.id(),scope:this,handler:this.onSave}]};this.callParent([Ext.apply({title:_STR("cstn","select_user_group"),width:500,height:506,padding:"16px 20px 12px 20px",resizable:!1,autoScroll:!0,cls:"syno-cstn-sharing-link-user-window",layout:"fit",bodyStyle:"padding: 5px 5px 0px 5px;",items:[{xtype:"cstn_sharing_selection",itemId:"selection_apply",panel:e.panel,owner:e.owner,win:this}],fbar:t},e)])},winShow:function(){this.open()},onCancel:function(){this.close()},onSave:function(){this.get("selection_apply").saveModification();var e=this.get("selection_apply").cachedSelectedUids,t=this.get("selection_apply").cachedSelectedGids;this.panel.updateSelectedUid(e),this.panel.updateSelectedGid(t),this.get("selection_apply").isDirty()&&this.panel.setSelectedFieldDirty(),this.close()}}),Ext.define("SYNO.SDS.CSTN.Sharing.PanelSelection",{extend:"SYNO.ux.EditorGridPanel",xtype:"cstn_sharing_selection",constructor:function(e){this.owner=e.owner,this.win=e.win,this.panel=e.panel,this.callParent([this.fillConfig(e)]),this.cachedSelectedUids=this.panel.getSelectedUid().slice(),this.cachedSelectedGids=this.panel.getSelectedGid().slice(),this.type_combo=this.getTopToolbar().getComponent("typeCombo"),this.fillTypeCombo(),this.mon(this.type_combo,"select",this.onUserTypeSelect,this)},fillConfig:function(e){var t=new SYNO.ux.EnableColumn({header:_STR("common","enable"),dataIndex:"enable",defaultValue:!1,align:"center",width:110}),i=[t,{header:_STR("showdel","attr_name"),dataIndex:"name",align:"left",width:250,sortable:!0}],n=new Ext.grid.ColumnModel({columns:i}),s=this.createTargetStore();this.paging_bar=new SYNO.ux.PagingToolbar({cls:"cstn-paging-toolbar syno-cstn-sharinglink-toolbar",store:s,pageSize:100,style:"",displayInfo:!0,emptyMsg:""}),this.findField=new SYNO.ux.TextFilter({itemId:"search",emptyText:_STR("btn","search"),listeners:{keyup:{scope:this,fn:function(e){this.saveModification(),this.getStore().baseParams.substr=e.getValue(),this.getStore().load()},buffer:300},afterrender:{scope:this,single:!0,fn:function(e){e.mon(e.trigger,"click",function(){this.saveModification(),this.getStore().baseParams.substr=e.getValue(),this.getStore().load()},this)}}}}),this.noteBar={xtype:"syno_displayfield",cls:"syno-cstn-sharing-setting-toolbar",html:'<span class="sharing-note">'+_T("common","note")+_T("common","colon")+" </span>"+_STR("cstn","select_public_sharing_desc")};var o={layout:"fit",border:"false",cm:n,sm:new Ext.grid.RowSelectionModel({singleSelect:!1}),enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,loadMask:!0,plugins:[t],store:s,view:new SYNO.SDS.CSTN.GridView({store:s,searchFields:[this.findField]}),bbar:{autoHeight:!0,cls:"syno-cstn-sharing-setting-bbar",layout:{type:"vbox",align:"stretch"},items:[this.paging_bar,this.noteBar]},listeners:{scope:this,afterrender:function(){this.getStore().load()}},tbar:new Ext.Toolbar({items:[{xtype:"syno_combobox",itemId:"typeCombo",displayField:"display",valueField:"index",value:0,labelStyle:"margin-left: 0 !important",width:220,store:new Ext.data.JsonStore({fields:["display","type","value","content_type","index"],data:[{display:_STR("cstn","local_user"),type:"local",value:"",index:0,content_type:"user"}]})},"->",this.findField]})};return Ext.apply(o,e)},createTargetStore:function(){var e=["name","id","type","enable"],t=new SYNO.API.Store({autoLoad:!1,proxy:new SYNO.API.Proxy({api:"SYNO.SynologyDrive.Settings",version:2,method:"list_targets",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"list",totalProperty:"total"},e),paramNames:{start:"offset",limit:"limit"},baseParams:{offset:0,limit:100,type:"local",domain_name:"",content_type:"user",substr:""},remoteSort:!1,listeners:{scope:this,beforeload:this.onPageChange,load:function(){var e=this.type_combo.getStore(),i=e.find(this.type_combo.valueField,this.type_combo.getValue());if(-1!=i){content_type=e.getAt(i).get("content_type");var n=[];"user"===content_type?n=this.cachedSelectedUids:"group"===content_type&&(n=this.cachedSelectedGids),n.length&&t.each(function(e){var t=e.get("id");-1!==n.indexOf(t)&&e.set("enable",!0)}.bind(this)),t.commitChanges()}},exception:function(e,t,i,n,s){s&&s.code&&this.win.getMsgBox().alert(_STR("app","app_name"),SYNO.SDS.CSTN.getErrorString(s))}}});return t},saveModification:function(){var e=this.getStore().getModifiedRecords();return e.length>0&&(this.dirty=!0,Ext.each(e,function(e){var t=e.get("type"),i=e.get("id");if(i<=0||!t)return!0;var n=[];if("user"===t?n=this.cachedSelectedUids:"group"===t&&(n=this.cachedSelectedGids),!0===e.get("enable"))n.push(i);else for(var s=n.length-1;s>=0;s--)if(n[s]===i)return n.splice(s,1),!0}.bind(this)),this.getStore().commitChanges()),e&&e.length>0},isDirty:function(){var e=this.getStore().getModifiedRecords();return this.dirty||e>0},onUserTypeSelect:function(e,t){this.saveModification();var i=this.getStore();Ext.apply(i.baseParams,{domain_name:t.get("value"),type:t.get("type"),content_type:t.get("content_type")}),i.load()},fillTypeCombo:function(){SYNO.SDS.CSTN.WebAPI.getDirSrvStatus.call(this.win,function(e,t){if(e){var i=[{display:_STR("cstn","local_user"),type:"local",value:"",index:0,content_type:"user"},{display:_STR("cstn","local_group"),type:"local",value:"",index:1,content_type:"group"}],n=2;Ext.each(t.domain_names,function(e){var t="-",s="-";"ldap"===e.type?(t=_STR("cstn","ldap_user"),s=_STR("cstn","ldap_group")):"domain"===e.type&&(t=_STR("cstn","domain_user")+" ("+e.value+")",s=_STR("cstn","domain_group")+" ("+e.value+")"),i.push({display:t,type:e.type,value:e.value,index:n++,content_type:"user"}),i.push({display:s,type:e.type,value:e.value,index:n++,content_type:"group"})}),this.type_combo.getStore().loadData(i,!1)}else this.win.getMsgBox().alert(_STR("app","app_name"),_T("common","error_system"))},this)},onPageChange:function(e,t){this.saveModification()&&this.getStore().load(t)}}),Ext.define("SYNO.SDS.CSTN.FileRequest.DialogSelectionEdit",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.win=e.owner,this.panel=e.panel;var t={xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[{xtype:"syno_button",btnStyle:"grey",hidden:!1,text:_T("common","cancel"),itemId:"cancel",id:this.BtnCancelId=Ext.id(),scope:this,handler:this.onCancel},{xtype:"syno_button",btnStyle:"blue",hidden:!1,text:_T("common","commit"),itemId:"apply",id:this.BtnApplyId=Ext.id(),scope:this,handler:this.onSave}]};this.callParent([Ext.apply({title:_STR("cstn","select_user_group"),width:500,height:506,padding:"16px 20px 12px 20px",resizable:!1,autoScroll:!0,cls:"syno-cstn-sharing-link-user-window",layout:"fit",bodyStyle:"padding: 5px 5px 0px 5px;",items:[{xtype:"cstn_file_request_selection",itemId:"request_selection_apply",panel:e.panel,owner:e.owner,win:this}],fbar:t},e)])},winShow:function(){this.open()},onCancel:function(){this.close()},onSave:function(){this.get("request_selection_apply").saveModification();var e=this.get("request_selection_apply").cachedFileRequestSelectedUids,t=this.get("request_selection_apply").cachedFileRequestSelectedGids;this.panel.updateFileRequestSelectedUid(e),this.panel.updateFileRequestSelectedGid(t),this.get("request_selection_apply").isDirty()&&this.panel.setFileRequestSelectedFieldDirty(),this.close()}}),Ext.define("SYNO.SDS.CSTN.FileRequest.PanelSelection",{extend:"SYNO.ux.EditorGridPanel",xtype:"cstn_file_request_selection",constructor:function(e){this.owner=e.owner,this.win=e.win,this.panel=e.panel,this.callParent([this.fillConfig(e)]),this.cachedFileRequestSelectedUids=this.panel.getFileRequestSelectedUids().slice(),this.cachedFileRequestSelectedGids=this.panel.getFileRequestSelectedGids().slice(),this.type_combo=this.getTopToolbar().getComponent("typeCombo"),this.fillTypeCombo(),this.mon(this.type_combo,"select",this.onUserTypeSelect,this)},fillConfig:function(e){var t=new SYNO.ux.EnableColumn({header:_STR("common","enable"),dataIndex:"enable",defaultValue:!1,align:"center",width:110}),i=[t,{header:_STR("showdel","attr_name"),dataIndex:"name",align:"left",width:250,sortable:!0}],n=new Ext.grid.ColumnModel({columns:i}),s=this.createTargetStore();this.paging_bar=new SYNO.ux.PagingToolbar({cls:"cstn-paging-toolbar syno-cstn-sharinglink-toolbar",store:s,pageSize:100,style:"",displayInfo:!0,emptyMsg:""}),this.findField=new SYNO.ux.TextFilter({itemId:"search",emptyText:_STR("btn","search"),listeners:{keyup:{scope:this,fn:function(e){this.saveModification(),this.getStore().baseParams.substr=e.getValue(),this.getStore().load()},buffer:300},afterrender:{scope:this,single:!0,fn:function(e){e.mon(e.trigger,"click",function(){this.saveModification(),this.getStore().baseParams.substr=e.getValue(),this.getStore().load()},this)}}}}),this.noteBar={xtype:"syno_displayfield",cls:"syno-cstn-sharing-setting-toolbar",html:'<span class="sharing-note">'+_T("common","note")+_T("common","colon")+" </span>"+_STR("cstn","select_file_request_desc")};var o={layout:"fit",border:"false",cm:n,sm:new Ext.grid.RowSelectionModel({singleSelect:!1}),enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,loadMask:!0,plugins:[t],store:s,view:new SYNO.SDS.CSTN.GridView({store:s,searchFields:[this.findField]}),bbar:{autoHeight:!0,cls:"syno-cstn-sharing-setting-bbar",layout:{type:"vbox",align:"stretch"},items:[this.paging_bar,this.noteBar]},listeners:{scope:this,afterrender:function(){this.getStore().load()}},tbar:new Ext.Toolbar({items:[{xtype:"syno_combobox",itemId:"typeCombo",displayField:"display",valueField:"index",value:0,labelStyle:"margin-left: 0 !important",width:220,store:new Ext.data.JsonStore({fields:["display","type","value","content_type","index"],data:[{display:_STR("cstn","local_user"),type:"local",value:"",index:0,content_type:"user"}]})},"->",this.findField]})};return Ext.apply(o,e)},createTargetStore:function(){var e=["name","id","type","enable"],t=new SYNO.API.Store({autoLoad:!1,proxy:new SYNO.API.Proxy({api:"SYNO.SynologyDrive.Settings",version:2,method:"list_targets",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"list",totalProperty:"total"},e),paramNames:{start:"offset",limit:"limit"},baseParams:{offset:0,limit:100,type:"local",domain_name:"",content_type:"user",substr:""},remoteSort:!1,listeners:{scope:this,beforeload:this.onPageChange,load:function(){var e=this.type_combo.getStore(),i=e.find(this.type_combo.valueField,this.type_combo.getValue());if(-1!=i){content_type=e.getAt(i).get("content_type");var n=[];"user"===content_type?n=this.cachedFileRequestSelectedUids:"group"===content_type&&(n=this.cachedFileRequestSelectedGids),n.length&&t.each(function(e){var t=e.get("id");-1!==n.indexOf(t)&&e.set("enable",!0)}.bind(this)),t.commitChanges()}},exception:function(e,t,i,n,s){s&&s.code&&this.win.getMsgBox().alert(_STR("app","app_name"),SYNO.SDS.CSTN.getErrorString(s))}}});return t},saveModification:function(){var e=this.getStore().getModifiedRecords();return e.length>0&&(this.dirty=!0,Ext.each(e,function(e){var t=e.get("type"),i=e.get("id");if(i<=0||!t)return!0;var n=[];if("user"===t?n=this.cachedFileRequestSelectedUids:"group"===t&&(n=this.cachedFileRequestSelectedGids),!0===e.get("enable"))n.push(i);else for(var s=n.length-1;s>=0;s--)if(n[s]===i)return n.splice(s,1),!0}.bind(this)),this.getStore().commitChanges()),e&&e.length>0},isDirty:function(){var e=this.getStore().getModifiedRecords();return this.dirty||e>0},onUserTypeSelect:function(e,t){this.saveModification();var i=this.getStore();Ext.apply(i.baseParams,{domain_name:t.get("value"),type:t.get("type"),content_type:t.get("content_type")}),i.load()},fillTypeCombo:function(){SYNO.SDS.CSTN.WebAPI.getDirSrvStatus.call(this.win,function(e,t){if(e){var i=[{display:_STR("cstn","local_user"),type:"local",value:"",index:0,content_type:"user"},{display:_STR("cstn","local_group"),type:"local",value:"",index:1,content_type:"group"}],n=2;Ext.each(t.domain_names,function(e){var t="-",s="-";"ldap"===e.type?(t=_STR("cstn","ldap_user"),s=_STR("cstn","ldap_group")):"domain"===e.type&&(t=_STR("cstn","domain_user")+" ("+e.value+")",s=_STR("cstn","domain_group")+" ("+e.value+")"),i.push({display:t,type:e.type,value:e.value,index:n++,content_type:"user"}),i.push({display:s,type:e.type,value:e.value,index:n++,content_type:"group"})}),this.type_combo.getStore().loadData(i,!1)}else this.win.getMsgBox().alert(_STR("app","app_name"),_T("common","error_system"))},this)},onPageChange:function(e,t){this.saveModification()&&this.getStore().load(t)}}),Ext.define("SYNO.SDS.CSTN.PanelLabel",{extend:"Ext.Container",hasRestore:!1,constructor:function(e){this.owner=e.owner,this.win=e.win;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={height:"auto",layout:"fit",items:[this.getLabelPanel()]};return Ext.apply(t,e),t},getLabelPanel:function(){return this.labelPanel?this.labelPanel:this.labelPanel=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.CSTN.Vue.AdminLabelPanel,mountId:"PanelLabel-AdminLabelPanel",layout:"fit",cls:"panel-label-AdminLabelPanel",owner:this,listeners:{afterlayout:function(){this._$vueInst.setActivationStatus(SYNO.SDS.CSTN.Config.advanced_feature_activated)}}},{propsData:{getParentWindow:function(){return this.win}.bind(this),jumpToActivateAdvancedFeaturePage:function(){this.owner.selectPage("SYNO.SDS.CSTN.PanelAdvancedFeature")}.bind(this)}})},getVueInstance:function(){return this.vueInst?this.vueInst:(this.vueInst=this.getLabelPanel()._$vueInst,this.vueInst)},onPageActivate:function(){this.onReset()},onPageDeactivate:function(){},checkDirty:function(){var e=this.getVueInstance();if(e)return e.isDirty()},onReset:function(){var e=this.getVueInstance();e&&e.onReset()},onSave:function(){var e=this.getVueInstance();e&&e.onApply()},onCancel:function(){this.onReset()},onActivate:function(){},onDeactivate:function(){}}),Ext.define("SYNO.SDS.CSTN.PanelFileLocking",{extend:"Ext.Container",hasRestore:!1,constructor:function(e){this.owner=e.owner,this.win=e.win;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t={height:"auto",layout:"fit",items:[this.getFileLockingPanel()]};return Ext.apply(t,e),t},getFileLockingPanel:function(){return this.FileLockingPanel?this.FileLockingPanel:this.FileLockingPanel=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.CSTN.Vue.FileLockingPanel,mountId:"PanelFileLocking-FileLockingPanel",layout:"fit",cls:"panel-file-locking-FileLockingPanel",owner:this,listeners:{afterlayout:function(){this._$vueInst.setActivationStatus(SYNO.SDS.CSTN.Config.advanced_feature_activated)}}},{propsData:{getParentWindow:function(){return this.win}.bind(this),getAppInstance:function(){return this.owner.appInstance}.bind(this),jumpToActivateAdvancedFeaturePage:function(){this.owner.selectPage("SYNO.SDS.CSTN.PanelAdvancedFeature")}.bind(this)}})},getVueInstance:function(){return this.vueInst?this.vueInst:(this.vueInst=this.getFileLockingPanel()._$vueInst,this.vueInst)},onPageActivate:function(){this.onReset()},onPageDeactivate:function(){},checkDirty:function(){var e=this.getVueInstance();if(e)return e.isDirty()},onReset:function(){var e=this.getVueInstance();e&&e.onReset()},onSave:function(){var e=this.getVueInstance();e&&e.onApply()},onCancel:function(){this.onReset()},onActivate:function(){},onDeactivate:function(){}}),Ext.ns("SYNO.SDS.CSTN"),Ext.ns("SYNO.SDS.CSTN.PROFILE"),SYNO.SDS.CSTN.PROFILE.STATUS_COL_WIDTH=150,SYNO.SDS.CSTN.PROFILE.CHECKBOX_COL_WIDTH=110,SYNO.SDS.CSTN.PROFILE.USERNAME_COL_WIDTH=250,SYNO.SDS.CSTN.RenderUserType=function(e){return"local"===e?_T("share","share_local_user"):"ldap"===e?_T("share","ldap_user"):"domain"===e?_T("app_privilege","domain_user"):"invalid_user_type"},Ext.define("SYNO.SDS.CSTN.PROFILE.PanelProfileApply",{extend:"SYNO.ux.EditorGridPanel",xtype:"cstn_profile_apply",constructor:function(e){this.owner=e.owner,this.win=e.win,this.callParent([this.fillConfig(e)]),this.profile_info||(this.profile_info={},this.profile_info.profile_applied=[]),this.type_combo=this.getTopToolbar().getComponent("userTypeCombo"),this.mon(this.type_combo,"select",this.onUserTypeSelect,this),this.mon(this,"activate",this.fillUserTypeCombo,this)},fillConfig:function(e){var t=new SYNO.ux.EnableColumn({header:_STR("common","enable"),dataIndex:"user_enable",align:"center",width:SYNO.SDS.CSTN.PROFILE.CHECKBOX_COL_WIDTH}),i=[t,{id:"user_name",header:_STR("common","usrname"),dataIndex:"name",align:"left",width:SYNO.SDS.CSTN.PROFILE.USERNAME_COL_WIDTH,sortable:!0},{id:"user_type",header:_STR("common","user_type"),dataIndex:"user_type",align:"left",width:SYNO.SDS.CSTN.PROFILE.STATUS_COL_WIDTH,renderer:SYNO.SDS.CSTN.RenderUserType,sortable:!0}],n=new Ext.grid.ColumnModel({columns:i}),s=this.createUserStore();this.paging_bar=new SYNO.ux.PagingToolbar({cls:"cstn-paging-toolbar",store:s,pageSize:100,displayInfo:!1});var o={itemId:"cstn_profile_apply_tab",title:_STR("profile","profile_applied"),layout:"fit",border:"false",cm:n,sm:new Ext.grid.RowSelectionModel({singleSelect:!1}),enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,loadMask:!0,plugins:[t],store:s,bbar:this.paging_bar,listeners:{scope:this,afterrender:function(){this.getStore().load()}},tbar:new Ext.Toolbar({items:[{xtype:"syno_combobox",itemId:"userTypeCombo",displayField:"display",valueField:"value",value:"",labelStyle:"margin-left: 0 !important",width:220,store:new Ext.data.JsonStore({fields:["display","type","value"],data:[{display:_T("share","share_local_user"),type:"local",value:""}]})}]})};return Ext.apply(o,e)},createUserStore:function(){var e=["name"],t=new SYNO.API.Store({pruneModifiedRecords:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WEBAPI_NAMESPACE+".Privilege",version:1,method:"list",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"users",totalProperty:"total",id:"id"},e),paramNames:{start:"offset",limit:"limit"},baseParams:{offset:0,limit:100,type:"local",domain_name:""},remoteSort:!1,listeners:{scope:this,beforeload:this.onPageChange,load:function(){var e=this.type_combo.getStore(),i=e.find(this.type_combo.valueField,this.type_combo.getValue()),n="local";if(-1!=i&&(n=e.getAt(i).get("type")),t.each(function(e){e.set("user_type",n),e.set("user_enable",!1)}),this.profile_info.profile_applied.length){var s=[];Ext.each(this.profile_info.profile_applied,function(e){s.push(e.user_name)}),t.each(function(e){var t=e.get("name");-1!==s.indexOf(t,0)&&e.set("user_enable",!0)})}t.commitChanges()},exception:function(e,t,i,n,s){s&&s.code&&this.win.getMsgBox().alert(_STR("app","app_name"),SYNO.SDS.CSTN.getErrorString(s))}}});return t},getSetting:function(){var e=this.profile_info.profile_applied.slice(),t=this.getStore().getModifiedRecords();return t.length>0&&(this.dirty=!0,Ext.each(t,function(t){var i=t.get("name");if(!0===t.get("user_enable"))e.splice(-1,0,{user_name:t.get("name")});else for(var n=e.length-1;n>=0;n--)e[n].user_name===i&&e.splice(n,1)})),e=e.sort(function(e,t){return e.user_name.toLowerCase()>t.user_name.toLowerCase()})},isDirty:function(){var e=this.getStore().getModifiedRecords();return this.dirty||e>0},onUserTypeSelect:function(e,t){var i=this.getStore();Ext.apply(i.baseParams,{domain_name:t.get("value"),type:t.get("type")}),i.load()},fillUserTypeCombo:function(){SYNO.SDS.CSTN.WebAPI.getDirSrvStatus.call(this.win,function(e,t){e?this.type_combo.getStore().loadData([{display:_T("share","share_local_user"),type:"local",value:""}].concat(t.domain_names),!1):this.win.getMsgBox().alert(_STR("app","app_name"),_T("common","error_system"))},this)},onPageChange:function(e,t){if(this.getStore().getModifiedRecords().length)return this.win.getMsgBox().confirm(_STR("app","app_name"),_T("share","share_save_chg_before_reload"),function(e){return"yes"==e&&(this.profile_info.profile_applied=this.getSetting()),this.getStore().rejectChanges(),this.getStore().load(t),!0},this),!1}}),Ext.define("SYNO.SDS.CloudStation.Component.ExtendedTreePanel.BaseTree",{extend:"SYNO.ux.TreePanel",constructor:function(e){var t=Ext.apply({useArrows:!0,autoScroll:!0,containerScroll:!0,bodyStyle:"overflow-x: hidden;overflow-y:auto; padding-right: 12px;",enableDD:!1},e);return this.callParent([t])}}),Ext.define("SYNO.SDS.CloudStation.Component.ExtendedTreePanel.SelectiveFile",{extend:"SYNO.SDS.CloudStation.Component.ExtendedTreePanel.BaseTree",constructor:function(e){var t=Ext.apply({useArrows:!0,autoScroll:!0,containerScroll:!0,bodyStyle:"overflow-x: hidden; overflow-y: auto; padding-top: 0px; padding-right: 2px; padding-left: 0px",enableDD:!1,root:new Ext.tree.TreeNode},e);return this.callParent([t])},initEvents:function(){var e=this.callParent(arguments);return this.mon(this,"checkchange",this.onCheckChange,this),e},get_state_by_children:function(e){var t=0,i=0,n=0;return e.eachChild(function(e){var s=e.getUI()||{};!s.checkbox||!Ext.isFunction(s.getCheckValue)||Ext.isFunction(s.isDisabled)&&s.isDisabled()||(!0===s.getCheckValue()?i+=1:!1===s.getCheckValue()&&(n+=1),t+=1)}),"other"==e.attributes.node_type?t==i||"gray":0===t?e.getUI().getCheckValue():i===t||n!==t&&"gray"},propagate_down:function(e,t){!0===t?e.eachChild(function(e){var t=e.getUI();!t||!Ext.isFunction(t.setCheckValue)||Ext.isFunction(t.isDisabled)&&t.isDisabled()||t.setCheckValue(!0)},this):!1===t&&e.eachChild(function(e){var t=e.getUI();t&&Ext.isFunction(t.setCheckValue)&&t.setCheckValue(!1)},this)},set_pnode_checked:function(e){var t=e.getUI();t&&Ext.isFunction(t.getCheckValue)&&(e.attributes.checked=this.get_state_by_children(e),t.syncCheckCssClass())},propagate_up:function(e,t){for(;e;)this.set_pnode_checked(e),e=e.parentNode},onCheckChange:function(e,t){this.propagate_down(e,t),this.propagate_up(e.parentNode)}}),Ext.define("SYNO.SDS.CloudStation.Component.ExtendedTreePanelUI",{extend:"Ext.tree.TreeNodeUI",renderElements:function(e,t,i,n){this.indentMarkup=e.parentNode?e.parentNode.ui.getChildIndent():"";var s,o=Ext.isBoolean(t.checked)||"gray"===t.checked,a=Ext.isBoolean(t.hide_checkbox)&&!0===t.hide_checkbox,l=Ext.isString(t.rimgCls),r=Ext.util.Format.htmlEncode,d=t.input,c=this.getHref(t.href),h=['<li class="x-tree-node syno-extended-tree-node"><div ext:tree-node-id="',r(e.id),'" class="x-tree-node-el x-tree-node-leaf x-unselectable ',t.cls,'" unselectable="on">',l?'<img alt="" src="'+this.emptyIcon+'" class= "'+t.rimgCls+'" style="float: right" />':"",'<span class="x-tree-node-indent">',this.indentMarkup,"</span>",'<img alt="" src="',this.emptyIcon,'" class="x-tree-ec-icon x-tree-elbow" />',o?'<img alt="" src="'+this.emptyIcon+'"'+(a?' style="display: none;"':"")+' class="syno-tree-node-cb syno-ux-checkbox-icon" />':"",'<img alt="" src="',t.icon||this.emptyIcon,'" class="x-tree-node-icon',t.icon?" x-tree-node-inline-icon":"",t.iconCls?" "+t.iconCls:"",'" unselectable="on" ',(t.icon||t.iconCls?"":'style="display: none;"')+"/>",t.icon||t.iconCls?"<span>&nbsp</span>":"",'<a hidefocus="on" class="x-tree-node-anchor" href="',c,'" tabIndex="1" ',t.hrefTarget?' target="'+t.hrefTarget+'"':"",'><span unselectable="on">',Ext.util.Format.htmlEncode(e.text),"</span></a>","</div>",'<ul class="x-tree-node-ct" style="display:none;"></ul>',"</li>"].join("");!0!==n&&e.nextSibling&&(s=e.nextSibling.ui.getEl())?this.wrap=Ext.DomHelper.insertHtml("beforeBegin",s,h):this.wrap=Ext.DomHelper.insertHtml("beforeEnd",i,h),this.elNode=this.wrap.childNodes[0],this.ctNode=this.wrap.childNodes[1];var _=this.elNode.childNodes,u=0;l&&(this.rimgNode=_[u++]),this.indentNode=_[u++],this.ecNode=_[u++],o&&(this.checkbox=_[u++],this.syncCheckCssClass()),this.iconNode=_[u++],this.anchor=_[u++],this.textNode=this.anchor.firstChild,d&&(this.createInputField(d,t,this.elNode),u++),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 n=e;switch(Ext.isObject(e)?(this.inputConfig=Ext.apply({},e),n=e.xtype||"textfield",delete e.xtype):this.inputConfig={},Ext.isDefined(t.value)&&(this.inputConfig.value=t.value),this.inputConfig.renderTo=i,n){case"textfield":this.input=new SYNO.ux.TextField(this.inputConfig);break;case"numberfield":this.input=new SYNO.ux.NumberField(this.inputConfig)}},initEvents:function(){var e=this.callParent(arguments);return this.rimgNode&&Ext.EventManager.on(this.rimgNode,"click",this.onRImgClick,this),e},onRImgClick:function(){this.node.fireEvent("rimgclick")},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.preventDefault(),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.addClassName("syno-ux-cb-disabled"):this.checkbox.removeClassName("syno-ux-cb-disabled"))},onCheckChange:function(){this.syncCheckCssClass(),this.fireEvent("checkchange",this.node,this.getCheckValue())},isValid:function(){return!!this.node.disabled||!(this.input&&!this.input.isValid())},getInputValue:function(){if(this.input&&!this.disabled)return this.input.getValue()},setInputValue:function(e){this.input&&this.input.setValue(e)},isChecked:function(){return this.getCheckValue()},getCheckValue:function(){return this.node.attributes.checked},toggleCheck:function(){var e=this.checkbox;!0!==this.node.disabled&&e&&this.setCheckValue(!this.getCheckValue())},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.onCheckChange())},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.define("SYNO.SDS.CloudStation.Component.ExtendedTreePanel.FolderLoader.Base",{extend:"Ext.tree.TreeLoader",createNode:function(e){if(e.uiProvider="SYNO.SDS.CloudStation.Component.ExtendedTreePanelUI",e.iconCls="x-tree-node-icon",e.draggable=!1,!Ext.isFunction(this.createNodeFn)||!1!==this.createNodeFn.call(this.createNodeScope||this,e))return this.callParent(arguments)}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PROFILE.PanelSeletiveFile",{extend:"SYNO.ux.FormPanel",xtype:"cstn_selective_file",constructor:function(e){this.remove_id_list=[],e.profile_info=Ext.apply({profile_name:"",profile_desc:{filtered_extensions:[],user_defined_extensions:[],user_defined_names:[],filtered_names:[],filtered_max_upload_size:0}},e.profile_info),this.callParent([this.fillConfig(e)])},fillConfig:function(e){var t={itemId:"cstn_selective_file_tab",title:_STR("profile","file_selective"),layout:"border",border:!1,cls:"syno-cstn-profile-edit",autoFlexcroll:!1,items:[{region:"north",border:!1,xtype:"syno_fieldset",
labelWidth:200,itemId:"top_part",items:[{fieldLabel:_STR("profile","profile_name"),xtype:"syno_textfield",itemId:"input_profile_name",allowBlank:!1,stripCharsRe:/(^\s+|\s+$)/g,validator:function(e){var t=this.profile_grid.getStore(),i=this.profile_grid.getSelectionModel().getSelected();return!(!i||e!==i.get("profile_name"))||(-1===t.findExact("profile_name",e)||_STR("common","name_used"))}.createDelegate(this)},{border:!1,fieldLabel:_STR("profile","max_size_label"),xtype:"syno_numberfield",itemId:"input_max_size",regex:/^\d+$/,maxlength:8,listeners:{render:function(e){e.getEl().set({"ext:qtip":_STR("profile","size_tool_tip")})}}},{xtype:"syno_displayfield",style:"",value:_STR("profile","seletive_file")}]},{region:"center",layout:"fit",border:!0,itemId:"center_part",items:[this.getSelectiveFilePanel(e)]},{region:"south",border:!1,layout:"border",height:34,itemId:"south_part",style:"padding: 6px 0 0",items:[{region:"center",layout:"border",border:!1,itemId:"custom_file_row",items:[{region:"center",xtype:"syno_textfield",itemId:"custom_file",validator:this.isValidRule.createDelegate(this),emptyText:_STR("profile","name_tool_tip"),enableKeyEvents:!0,listeners:{render:function(e){e.getEl().set({"ext:qtip":e.emptyText})},keyup:function(e){""!==e.getValue()?e.getEl().set({"ext:qtip":Ext.util.Format.htmlEncode(e.getValue())}):e.getEl().set({"ext:qtip":e.emptyText})}},allowBlank:!0},{region:"east",border:!1,width:6}]},{region:"east",itemId:"add_custom_file_rule",xtype:"syno_button",btnStyle:"gray",text:_T("common","add"),listeners:{click:this.addCustomFileRule,scope:this}}]}]};return Ext.apply(t,e)},getSelectiveFilePanel:function(e){return void 0===this.selectiveFilePanel&&(this.selectiveFilePanel=new SYNO.SDS.CloudStation.Component.ExtendedTreePanel.SelectiveFile({owner:e.owner,itemId:"selective_file_treepanel",ctCls:"syno-cstn-profile-edit-treepanel",border:!1,rootVisible:!1,listeners:{afterrender:function(){this.reloadPanel()},scope:this}})),this.selectiveFilePanel},isValidRule:function(e){return!(""!==e&&!this.isExtRule(e)&&!this.isNameRule(e))},getBuiltinExtensions:function(){return SYNO.SDS.CloudStation.SelectiveSync.getBuiltInExtensions()},reloadPanel:function(){var e=this.selectiveFilePanel.getRootNode();e.removeAll(),this.get("south_part").get("custom_file_row").get("custom_file").setValue("");var t=this.getBuiltinExtensions();Ext.each(t,function(t){var i=this.createBuiltInCategory(t,this.profile_info.profile_desc.filtered_extensions);e.appendChild(i)},this),e.appendChild(this.createUserDefinedCategory()),e.expand(),function(){for(var t=0;t<e.childNodes.length;t++)e.childNodes[t].expand(void 0,!1),!1===e.childNodes[t].attributes.is_customize_session&&e.childNodes[t].collapse(void 0,!1),e.childNodes[t].ui.syncCheckCssClass()}(),e.childNodes[0].ensureVisible(),function(){var e=this.get("top_part").get("input_max_size"),t=Math.round(this.profile_info.profile_desc.filtered_max_upload_size/1024/1024);e.setMinValue(0),e.setMaxValue(1024e4),e.setValue(t)}.createDelegate(this)(),this.get("top_part").get("input_profile_name").setValue(this.profile_info.profile_name)},createBuiltInCategory:function(e,t){var i=!0,n=!0,s={text:e.display_name,uiProvider:SYNO.SDS.CloudStation.Component.ExtendedTreePanelUI,iconCls:e.icon_cls,children:[],is_customize_session:!1,node_type:e.node_type};return Ext.each(e.extensions,function(e){e=e.toLowerCase();var o=!(t.indexOf(e)>=0);s.children.push(this.createExtensionNode(e,o,!0)),i=i&&o,n=n&&!o},this),s.checked=!0===i||!0!==n&&"gray",s},node_remove_clicked:function(){var e=this.parentNode,t=!0,i=!1;this.parentNode.removeChild(this,!0),Ext.each(e.childNodes,function(e){var n=e.attributes.checked;t=t&&n,i=i&&!n},this),e.attributes.checked=!0!==i&&(!0===t||"gray"),e.ui.onCheckChange()},createExtensionNode:function(e,t,i){var n=this.createBaseNode(t);return n.node_type="ext",n.extension_name=e,n.text=e,n.qtip=Ext.util.Format.htmlEncode(n.text),i||(n.text="*."+e,n.rimgCls="syno-tree-node-remove",n.listeners={rimgclick:this.node_remove_clicked}),n},createNameNode:function(e,t){var i=this.createBaseNode(t);return i.node_type="name",i.file_name=e,i.text=e,i.qtip=Ext.util.Format.htmlEncode(i.text),i.rimgCls="syno-tree-node-remove",i.listeners={rimgclick:this.node_remove_clicked},i},createBaseNode:function(e){return{uiProvider:SYNO.SDS.CloudStation.Component.ExtendedTreePanelUI,text:void 0,checked:e,leaf:!0,extension_name:void 0,file_name:void 0,node_type:void 0}},createUserDefinedCategory:function(){var e=!0,t=this.profile_info.profile_desc,i={text:_STR("profile","customize"),uiProvider:SYNO.SDS.CloudStation.Component.ExtendedTreePanelUI,iconCls:"syno-tree-node-customized",children:[],is_customize_session:!0,node_type:"other"};return Ext.each(t.user_defined_extensions,function(n){n=n.toLowerCase();var s=!(t.filtered_extensions.indexOf(n)>=0);i.children.push(this.createExtensionNode(n,s,!1)),e=e&&s},this),Ext.each(t.user_defined_names,function(n){var s=!(t.filtered_names.indexOf(n)>=0);i.children.push(this.createNameNode(n,s)),e=e&&s},this),i.checked=!0===e||"gray",i},isExtensionNode:function(e){return"ext"===e.node_type},isNameNode:function(e){return"name"===e.node_type},getSettings:function(){var e=this.get("top_part").get("input_max_size"),t=this.get("center_part").get("selective_file_treepanel").getRootNode(),i=[],n=[],s=[],o=[],a=0<e.getValue()?1024*e.getValue()*1024:0,l=function(e){this.isExtensionNode(e.attributes)?s.indexOf(e.attributes.extension_name)<0&&s.push(e.attributes.extension_name):this.isNameNode(e.attributes)&&o.indexOf(e.attributes.file_name)<0&&o.push(e.attributes.file_name)}.createDelegate(this),r=function(e){this.isExtensionNode(e.attributes)?i.indexOf(e.attributes.extension_name)<0&&i.push(e.attributes.extension_name):this.isNameNode(e.attributes)&&n.indexOf(e.attributes.file_name)<0&&n.push(e.attributes.file_name)}.createDelegate(this);return Ext.each(t.childNodes,function(e){Ext.each(e.childNodes,function(t){!1===t.attributes.checked&&r(t),!0===e.attributes.is_customize_session&&l(t)},this)},this),{filtered_max_upload_size:a,filtered_extensions:i,filtered_names:n,user_defined_extensions:s,user_defined_names:o}},isDirty:function(){var e=this.get("top_part").get("input_profile_name"),t=this.get("top_part").get("input_max_size");if(e.getValue()!==this.profile_info.profile_name)return!0;if(1048576*t.getValue()!==this.profile_info.profile_desc.filtered_max_upload_size)return!0;var i=this.getSettings();if(this.profile_info.profile_desc.filtered_extensions.length!==i.filtered_extensions.length)return!0;if(this.profile_info.profile_desc.filtered_names.length!==i.filtered_names.length)return!0;if(this.profile_info.profile_desc.user_defined_extensions.length!==i.user_defined_extensions.length)return!0;if(this.profile_info.profile_desc.user_defined_names.length!==i.user_defined_names.length)return!0;var n=0;for(this.profile_info.profile_desc.filtered_extensions.sort(),i.filtered_extensions.sort(),n=0;n<i.filtered_extensions.length;n++)if(i.filtered_extensions[n]!=this.profile_info.profile_desc.filtered_extensions[n])return!0;for(this.profile_info.profile_desc.filtered_names.sort(),i.filtered_names.sort(),n=0;n<i.filtered_names.length;n++)if(i.filtered_names[n]!=this.profile_info.profile_desc.filtered_names[n])return!0;for(this.profile_info.profile_desc.user_defined_extensions.sort(),i.filtered_extensions.sort(),n=0;n<i.user_defined_extensions.length;n++)if(i.user_defined_extensions[n]!=this.profile_info.profile_desc.user_defined_extensions[n])return!0;for(this.profile_info.profile_desc.user_defined_names.sort(),i.filtered_extensions.sort(),n=0;n<i.user_defined_names.length;n++)if(i.user_defined_names[n]!=this.profile_info.profile_desc.user_defined_names[n])return!0;return!1},getInfo:function(){var e=this.get("top_part").get("input_profile_name"),t=this.get("top_part").get("input_max_size");return!(!e.isValid()||!t.isValid())&&(this.profile_info.profile_desc=this.getSettings(),this.profile_info.profile_name=e.getValue(),this.profile_info)},addCustomizeNode:function(e){for(var t=this.get("center_part").get("selective_file_treepanel"),i=t.getRootNode(),n=null,s=i.childNodes.length-1;s>=0;s--)if(!0===i.childNodes[s].attributes.is_customize_session){n=i.childNodes[s];break}null!==n&&(n.appendChild(e),n.collapse(void 0,!1),n.expand(void 0,!1))},addCustomFileRule:function(){var e=this.get("south_part").get("custom_file_row").get("custom_file"),t=e.getValue();t=t.toLowerCase(),this.isExtRule(t)?(this.addExtRule(t.substring(2,t.length)),e.reset()):this.isNameRule(t)&&(this.addNameRule(t),e.reset())},isExtRule:function(e){var t=/^\*\.[^\*\:\?\"<\>\|\\\/]*$/;return""!==e&&t.test(e)},isNameRule:function(e){var t=/[\*\:\?\"<\>\|\\\/]+/;return""!==e&&!t.test(e)},addExtRule:function(e){var t=function(t){return t.attributes.extension_name===e},i=this.selectNode(t);if(null!==i)return i.attributes.checked=!1,void i.ui.onCheckChange();var n=this.createExtensionNode(e,!1,!1);this.addCustomizeNode(n),i=this.selectNode(t),i.ui.onCheckChange()},addNameRule:function(e){var t=function(t){return t.attributes.file_name===e},i=this.selectNode(t);if(null!==i)return i.attributes.checked=!1,void i.ui.onCheckChange();var n=this.createNameNode(e,!1);this.addCustomizeNode(n),i=this.selectNode(t),i.ui.onCheckChange()},selectNode:function(e){var t=this.get("center_part").get("selective_file_treepanel").getRootNode(),i=null,n=function(){t.childNodes[s].childNodes[o].select(),t.childNodes[s].childNodes[o].ensureVisible()};t.expand();for(var s=0;s<t.childNodes.length;s++){for(var o=0;o<t.childNodes[s].childNodes.length;o++)if(e(t.childNodes[s].childNodes[o])){t.childNodes[s].expand(void 0,void 0,n),i=t.childNodes[s].childNodes[o];break}if(null!==i)break}return i}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.DialogProfileEdit",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.owner=e.owner,this.win=e.owner;var t={xtype:"statusbar",hideMode:"visibility",defaultText:"&nbsp;",statusAlign:"left",buttonAlign:"left",items:[{xtype:"syno_button",btnStyle:"grey",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","cancel"),itemId:"cancel",id:this.BtnCancelId=Ext.id(),scope:this,handler:this.onCancel},{xtype:"syno_button",btnStyle:"blue",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",hidden:!1,text:_T("common","commit"),itemId:"apply",id:this.BtnApplyId=Ext.id(),scope:this,handler:this.onSave}]};this.callParent([Ext.apply({itemId:"profile_editor",title:_STR("profile","profile_editor"),width:500,height:500,resizable:!1,autoScroll:!0,layout:"fit",items:[{xtype:"syno_tabpanel",itemId:"profile_tab_panel",deferredRender:!1,layoutOnTabChange:!0,border:!1,plain:!0,activeTab:0,items:[{xtype:"cstn_selective_file",itemId:"selective_file",profile_info:e.profile_info,profile_grid:e.profile_grid,owner:e.owner,win:this},{xtype:"cstn_profile_apply",itemId:"profile_apply",profile_info:e.profile_info,profile_grid:e.profile_grid,owner:e.owner,win:this}]}],listeners:{beforeclose:this.onCancel,scope:this},fbar:t},e)])},winShow:function(){this.open()},onCancel:function(){return this.get("profile_tab_panel").get("selective_file").isDirty()||this.get("profile_tab_panel").get("profile_apply").isDirty()?this.owner.confirmLostChangePromise({save:function(){this.onSave()}.bind(this),cancel:Ext.emptyFn,dontSave:function(){this.doClose()}.bind(this)},this):this.doClose(),!1},onSave:function(){var e=this.get("profile_tab_panel").get("selective_file").getInfo(),t=this.get("profile_tab_panel").get("profile_apply").getSetting();if(!1===e)return this.get("profile_tab_panel").setActiveTab("selective_file"),this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1;"create"===this.open_mode?function(){var i=this.profile_grid.getStore(),n=new i.recordType({profile_applied:t,profile_desc:e.profile_desc,profile_name:e.profile_name,profile_id:-1});this.profile_grid.getStore().add(n),n.markDirty(),this.profile_grid.onSave()}.createDelegate(this)():"edit"===this.open_mode&&function(){var i=this.profile_grid.getSelectionModel().getSelected();i.set("profile_applied",t),i.set("profile_desc",e.profile_desc),i.set("profile_name",e.profile_name),i.set("profile_id",this.profile_info.profile_id),i.markDirty(),this.profile_grid.onSave()}.createDelegate(this)(),this.doClose()}}),Ext.ns("SYNO.SDS.CSTN"),SYNO.SDS.CSTN.RenderProfile=function(e,t){var i="",n=!1;return e.filtered_max_upload_size&&e.filtered_max_upload_size>0&&(i+=String.format(_STR("profile","profile_max_size"),e.filtered_max_upload_size/1024/1024),n=!0),e.filtered_extensions&&e.filtered_extensions.length>0&&(n&&(i+="; "),i+=String.format(_STR("profile","profile_filtered_ext"),e.filtered_extensions.join(", ")),n=!0),e.filtered_names&&e.filtered_names.length>0&&(n&&(i+="; "),i+=String.format(_STR("profile","profile_filtered_names"),e.filtered_names.join(", ")),n=!0),t&&(t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(i))+'"'),Ext.util.Format.htmlEncode(i)},SYNO.SDS.CSTN.RenderAppliedUser=function(e,t){var i="",n=[];return Ext.each(e,function(e){n.push(e.user_name)},this),e.length>0&&(i+=n.join(", ")),t&&(t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(Ext.util.Format.htmlEncode(i))+'"'),i},Ext.define("SYNO.SDS.CSTN.PanelProfile",{extend:"SYNO.ux.GridPanel",hasRestore:!1,constructor:function(e){this.owner=e.owner,this.win=e.win;var t=this.fillConfig(e);this.deleted_profile_ids=[],this.callParent([t])},fillConfig:function(e){var t=new Ext.Toolbar;t.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:this._S("demo_mode"),tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"profile_create",text:_STR("common","create"),handler:this.onCreate,scope:this}),t.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"profile_edit",text:_STR("common","edit"),handler:this.onEdit,scope:this}),t.add({xtype:"syno_button",cls:"syno-cstn-tab-btn-main-el",ctCls:"syno-cstn-tab-btn",disabled:!0,tooltip:this._S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",itemId:"profile_delete",text:_STR("common","remove"),handler:this.onDelete,scope:this});var i=[{id:"profile_id",header:"profile_id",dataIndex:"profile_id",hidden:!0},{id:"profile_name",width:40,header:_STR("profile","profile_name"),dataIndex:"profile_name",align:"left",sortable:!0},{id:"profile_desc",header:_STR("profile","profile_desc"),dataIndex:"profile_desc",align:"left",renderer:SYNO.SDS.CSTN.RenderProfile},{id:"profile_applied",header:_STR("profile","profile_applied"),dataIndex:"profile_applied",align:"left",width:150,renderer:SYNO.SDS.CSTN.RenderAppliedUser}],n=new Ext.grid.ColumnModel({columns:i}),s=this.CreateProfileStore(),o={tbar:t,view:new SYNO.SDS.CSTN.FleXcroll.GridView({store:s,searchFields:[]}),stripeRows:!0,enableColLock:!1,enableHdMenu:!1,enableColumnMove:!1,colModel:n,ds:s,sm:new Ext.grid.RowSelectionModel({singleSelect:!0,listeners:{rowselect:function(){this.win._S("demo_mode")||(this.getTopToolbar().get("profile_edit").enable(),this.getTopToolbar().get("profile_delete").enable())},rowdeselect:this.disableEditAndDeleteButton,scope:this}}),loadMask:!0,owner:e.owner};return Ext.apply(o,e),o},CreateProfileStore:function(){var e=["profile_id","profile_name","profile_desc","profile_applied"];return new SYNO.API.Store({pruneModifiedRecords:!0,autoLoad:!1,proxy:new SYNO.API.Proxy({api:SYNO.SDS.CSTN.WebAPI.Profiles.api,version:1,method:"list",appWindow:this.owner}),reader:new Ext.data.JsonReader({root:"profile_list",totalProperty:"total",id:"id"},e),baseParams:{start:0,limit:this.pageSize,user:this.win._S("user")},listeners:{scope:this,exception:function(e,t,i,n,s){s&&s.code&&this.owner.getMsgBox().alert(_STR("app","app_name"),SYNO.SDS.CSTN.getErrorString(s))},load:this.disableEditAndDeleteButton},remoteSort:!1})},doRefresh:function(e,t){this.getStore().removeAll(),this.getStore().load({callback:e,scope:t}),this.deleted_profile_ids=[]},disableEditAndDeleteButton:function(){this.getTopToolbar().get("profile_edit").disable(),this.getTopToolbar().get("profile_delete").disable()},onCreate:function(){this.getSelectionModel().clearSelections(),new SYNO.SDS.CSTN.DialogProfileEdit({owner:this.owner,profile_grid:this,open_mode:"create"}).open()},onEdit:function(){var e=this.getSelectionModel().getSelected();new SYNO.SDS.CSTN.DialogProfileEdit({owner:this.owner,profile_info:e.data,profile_grid:this,open_mode:"edit"}).open()},onDelete:function(){this.owner.getMsgBox().confirm(_STR("app","app_name"),_STR("common","confirm_remove"),function(e){if("yes"==e){var t=this.getSelectionModel().getSelected(),i=t.get("profile_id");-1!=i&&this.deleted_profile_ids.push(i),this.getStore().remove(t),this.getTopToolbar().get("profile_edit").disable(),this.getTopToolbar().get("profile_delete").disable(),this.onSave()}},this)},ajaxCheckSrvStatusCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:SYNO.SDS.CSTN.cbLoad,failure:SYNO.SDS.CSTN.webapiErrHdlMain})},checkSrvStatus:function(){this.owner.setStatusBusy(),SYNO.SDS.CSTN.WebAPI.checkUser.call(this.owner,this.ajaxCheckSrvStatusCB,this)},onPageActivate:function(){this.checkSrvStatus()},onPageDeactivate:function(){},checkDirty:function(){return this.getStore().getModifiedRecords().length>0||this.deleted_profile_ids.length>0},onReset:function(){this.doRefresh()},onSave:function(){var e=this.getStore(),t=[],i=this.deleted_profile_ids,n=e.getModifiedRecords(),s=[];if(!this.checkDirty())return void this.owner.getMsgBox().alert(_STR("app","app_name"),_T("error","nochange_subject"));Ext.each(n,function(e){t.push({profile_name:e.get("profile_name"),profile_desc:e.get("profile_desc"),profile_applied:e.get("profile_applied"),profile_id:e.get("profile_id")})}),t.length>0&&s.push({api:SYNO.SDS.CSTN.WebAPI.Profiles.api,version:1,method:"set",params:{profiles:t}}),i.length>0&&s.push({api:SYNO.SDS.CSTN.WebAPI.Profiles.api,version:1,method:"delete",params:{id:i}}),this.owner.setStatusBusy(),this.sendWebAPI({compound:{params:s},callback:this.ajaxApplyGridCB,scope:this})},ajaxApplyGridSuccessCB:function(){this.doRefresh(function(){this.owner.getMsgBox().alert(_STR("app","app_name"),_T("common","setting_applied"))},this)},ajaxApplyGridCB:function(e,t,i,n){SYNO.SDS.CSTN.webapiHdl.call(this,e,t,i,n,{success:this.ajaxApplyGridSuccessCB,failure:SYNO.SDS.CSTN.webapiErrHdl})}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PanelConfigure",{extend:"SYNO.ux.TabPanel",constructor:function(e){this.owner=e.owner||e.appWin,this.module=e.module||e.appWin;var t=this.fillConfig(e);this.callParent([t])},fillConfig:function(e){var t=new SYNO.SDS.CSTN.PanelDatabase({owner:this.owner,win:this.owner,module:this.module,title:_STR("setting","general"),itemId:"GeneralTab"}),i=new SYNO.SDS.CSTN.PanelProfile({owner:this.owner,win:this.owner,module:this.module,title:_STR("profile","profile_manager"),itemId:"ProfileTab"}),n=new SYNO.SDS.CSTN.PanelSharingLink({owner:this.owner,win:this.owner,module:this.module,title:_STR("setting","share"),itemId:"SharingTab"}),s=new SYNO.SDS.CSTN.PanelLabel({owner:this.owner,win:this.owner,module:this.module,title:_STR("common","shared_labels"),itemId:"SharedLabelTab"}),o=new SYNO.SDS.CSTN.PanelFileLocking({owner:this.owner,win:this.owner,module:this.module,title:_STR("common","file_locking"),itemId:"FileLockingTab"}),a={cls:"syno-cstn-panel-padding",itemId:"tabPanel",deferredRender:!1,layoutOnTabChange:!0,border:!1,plain:!0,region:"center",items:[],listeners:{beforetabchange:{fn:this.onTabChange},activate:{fn:function(){this.needCheck=!1}}}};return a.items.push(t),a.items.push(i),a.items.push(n),a.items.push(s),a.items.push(o),a.itemTpl=this.getTabItemTpl(),a.getTemplateArgs=function(e){var t=SYNO.ux.TabPanel.prototype.getTemplateArgs.call(this,e),i=SYNO.SDS.CSTN.Config["display_4.0_new_feature_hint"],n=["SharingTab","SharedLabelTab","FileLockingTab"].includes(e.itemId),s=this.findAppWindow().appInstance.getUserSettings("hide_admin_console_new_feature_icon_"+e.itemId);return Ext.apply(t,{show_new_feature_icon:i&&n&&s!==SYNO.SDS.CSTN.Config.ds_id})}.bind(this),Ext.apply(a,e),a},onTabChange:function(e,t,i){if(["SharingTab","SharedLabelTab","FileLockingTab"].includes(t.itemId)){this.findAppWindow().appInstance.setUserSettings("hide_admin_console_new_feature_icon_"+t.itemId,SYNO.SDS.CSTN.Config.ds_id);var n=t.tabEl.querySelector(".syno-d-admin-console-new-feature-tab-icon");n&&(n.style.display="none")}return this.needCheck&&this.checkDirty()?(this.owner.confirmLostChangePromise({save:function(){this.needCheck=!1,this.onSave(),i&&i.onPageDeactivate(),e.setActiveTab(t),t.onPageActivate()}.bind(this),cancel:Ext.emptyFn,dontSave:function(){this.needCheck=!1,this.onCancel(),i&&i.onPageDeactivate(),e.setActiveTab(t),t.onPageActivate()}.bind(this)},this),!1):(i&&i.onPageDeactivate(),t.onPageActivate(),this.needCheck=!0,!0)},checkDirty:function(){var e=this.getActiveTab();return!!e&&e.checkDirty()},onSave:function(){this.getActiveTab().onSave()},onCancel:function(){this.getActiveTab().onCancel()},onPageActivate:function(){},onPageDeactivate:function(){this.getActiveTab().onPageDeactivate()},onActivate:function(){this.onPageActivate()},onDeactivate:function(){this.onPageDeactivate()},getTabItemTpl:function(){return new Ext.XTemplate('<li class="syno-d-admin-console-tab {cls}" id="{id}" unselectable="on" tabIndex="0" role="tab" aria-selected="false">','<a class="x-tab-right" href="#">','<span class="syno-d-admin-console-tab-text x-tab-strip-inner">','<span class="x-tab-strip-text">{text}</span>',"</span>",'<tpl if="show_new_feature_icon">','<span class="syno-d-admin-console-new-feature-tab-icon"></span>',"</tpl>","</a>","</li>")}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PanelRedirect",{extend:"SYNO.ux.FormPanel",layout:"fit",constructor:function(e){var t={items:this.createVuePanel(e)};this.callParent([Ext.apply(t,e)]),this.addManagedComponent(this.vuePanel)},createVuePanel:function(e){return this.vuePanel=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.CSTN.Vue.PanelRedirect,mountId:"PanelRedirect",layout:"fit",cls:"PanelRedirect",owner:this}),this.vuePanel}}),Ext.ns("SYNO.SDS.CSTN"),SYNO.SDS.CSTN.Instance=Ext.extend(SYNO.SDS.AppInstance,{appWindowName:"SYNO.SDS.CSTN.MainAppWindow",constructor:function(){void 0===SYNO.SDS.Strings["SYNO.SDS.CSTN.MainAppWindow"]&&(SYNO.SDS.Strings["SYNO.SDS.CSTN.MainAppWindow"]=SYNO.SDS.Strings["SYNO.SDS.CSTN.Instance"]),void 0===SYNO.SDS.Strings["SYNO.SDS.CSTN.MainWindow"]&&(SYNO.SDS.Strings["SYNO.SDS.CSTN.MainWindow"]=SYNO.SDS.Strings["SYNO.SDS.CSTN.Instance"]),SYNO.SDS.CSTN.Instance.superclass.constructor.apply(this,arguments)},loadRequiredJSFiles:function(){return SYNO.SDS.Config.FnMap.hasOwnProperty("SYNO.SDS.Office.AdminSetting")&&SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.SDS.Office.AppInstance")?new Promise(function(e,t){SYNO.SDS.JSLoad("SYNO.SDS.Office.AdminSetting",e,this,t)}):Promise.resolve()},loadRequiredC2JSFiles:function(){return SYNO.SDS.Config.FnMap.hasOwnProperty("SYNO.SDS.C2Transfer.AdminSetting")&&SYNO.SDS.CSTN.HasC2Transfer()?new Promise(function(e,t){SYNO.SDS.JSLoad("SYNO.SDS.C2Transfer.AdminSetting",e,this,t)}):Promise.resolve()},open:function(e){var t=SYNO.SDS.CSTN.Instance.superclass.open.bind(this,e);this.loadRequiredC2JSFiles(),this.loadRequiredJSFiles().then(t).catch(t)}}),Ext.define("SYNO.SDS.CSTN.MainAppTreeNodeUI",{extend:"SYNO.ux.ModuleList.TreeNodeUI",renderElements:function(e,t,i,n){this.callParent(arguments);Ext.DomHelper.append(this.elNode,'<span class="syno-cstn-new-feature-hint"></span>')}}),Ext.define("SYNO.SDS.CSTN.MainAppTreeLoader",{extend:"SYNO.ux.ModuleList.Loader",constructor:function(e){this.callParent(arguments)},createNode:function(e){return e.uiProvider=SYNO.SDS.CSTN.MainAppTreeNodeUI,e.appWin=this.appWin,this.callParent(arguments)}}),Ext.define("SYNO.SDS.CSTN.MainAppModuleList",{extend:"SYNO.ux.ModuleList",constructor:function(){this.callParent(arguments)},createLoader:function(e){return new SYNO.SDS.CSTN.MainAppTreeLoader({baseAttrs:e.baseAttrs,moduleList:this,disableCaching:!!e.disableCaching,listItems:e.listItems?e.listItems:null,loadParam:e.loadParam,appWin:e.appWin})}}),Ext.define("SYNO.SDS.CSTN.MainAppWindow",{extend:"SYNO.SDS.PageListAppWindow",constructor:function(e){this.enableStatus=void 0,this.cstnInfo={},this.forceChangePage=!1,this.preConfigMap={},this.modelName=_D("upnpmodelname");var t=this.fillConfig(e);this.callParent([t]),this.setWidth(SYNO.SDS.CSTN.WIN_WIDTH),this.getPageList().findNext=!1,this.mon(SYNO.SDS.StatusNotifier,"thirdpartychanged",this.reloadC2Transfer,this),this.initEnv()},initEnv:function(){if(SYNO.SDS.CSTN.System={minMem:0},"VirtualDSM"!==this.modelName)return void(SYNO.SDS.CSTN.System.minMem=parseInt(_D("mem_min_mb"),10));this.sendWebAPI({api:"SYNO.Core.System",method:"info",version:1,scope:this,callback:function(e,t){if(this.clearWholeWindowBusy(),!e||t.error)return void SYNO.Debug.error("Failed to fetch system info");SYNO.SDS.CSTN.System.minMem=t.ram_size}})},ajaxLoadFormCB:function(e,t,i,n){var s=t.result;this.clearWholeWindowBusy();for(var o=0;o<s.length;++o){var a=null;SYNO.ux.Utils.checkApiConsistency(this.getSystemInfo,s[o])&&(a=this.loadSystemInfoDone),a&&a.call(this,s[o].success,s[o].data||s[o].error)}},loadSystemInfoDone:function(e,t){if(!e||t.error)return void SYNO.Debug.error("Failed to fetch system info");SYNO.SDS.CSTN.System.minMem=t.ram_size},setWholeWindowBusy:function(){this.setStatusBusy(),this.getPageList().disable()},clearWholeWindowBusy:function(){this.clearStatusBusy(),this.getPageList().enable()},onOpen:function(){SYNO.SDS.CSTN.MainAppWindow.superclass.onOpen.apply(this,arguments),this.forceShowWatermarkSetting||"VirtualDSM"===this.modelName&&this.setWholeWindowBusy()},checkShowWatermarkSetting:function(e){return e>=2048},fillConfig:function(e){var t=[{text:_STR("func","mgr_overview"),iconCls:"syno-cstn-list-cloudstn",fn:"SYNO.SDS.CSTN.PanelCloudStn"}];t.push({text:_STR("func","mgr_clientinfo"),iconCls:"syno-cstn-list-client",fn:"SYNO.SDS.CSTN.PanelClient"}),t.push({text:_STR("func","mgr_log"),iconCls:"syno-cstn-list-log",fn:"SYNO.SDS.CSTN.PanelLog"}),this._S("is_admin")&&(t.push({text:_STR("func","mgr_sharing"),iconCls:"syno-cstn-list-teamfolder",fn:"SYNO.SDS.CSTN.PanelSharing"}),t.push({text:_STR("func","mgr_advance_feature"),iconCls:"syno-cstn-list-advance-feature",fn:"SYNO.SDS.CSTN.PanelAdvancedFeature"}),t.push({text:_STR("func","settings"),iconCls:"syno-cstn-list-configure",fn:"SYNO.SDS.CSTN.PanelConfigure"}));var i=[{text:_STR("drive","displayname"),items:t}];return SYNO.SDS.CSTN.HasOffice()&&SYNO.SDS.Config.FnMap.hasOwnProperty("SYNO.SDS.Office.AdminSetting")&&i.push({text:_TT("SYNO.SDS.Office.AdminSetting","app","displayname"),items:SYNO.SDS.Office.AdminSetting.getItmes.call(this)}),Ext.apply({useGradient:!1,cls:"syno-cstn",activePage:"SYNO.SDS.CSTN.PanelCloudStn",autoScroll:!1,minWidth:SYNO.SDS.CSTN.WIN_MINWIDTH,minHeight:SYNO.SDS.CSTN.WIN_MINHEIGHT,width:SYNO.SDS.CSTN.WIN_WIDTH,height:SYNO.SDS.CSTN.DEFAULT_HEIGHT,listItems:i.length>1?i:t},e)},getPageCt:function(){return this.pageCt||(this.pageCt=new Ext.Panel({layout:"card",cls:"syno-cstn-admin-console-panel",padding:"0px 0px 0px 0px",border:!1,frame:!1,hideMode:"offsets",region:"center",listeners:{cstn_config_loaded:{fn:this.onCstnConfigLoaded},scope:this}})),this.pageCt},pageList:null,getPageList:function(e){var t;return this.pageList||(t={region:"west",width:240,padding:"12px 12px 0 12px",appWin:this},e.dataUrl?t.dataUrl=e.dataUrl:e.listItems&&(t.listItems=e.listItems),this.pageList=new SYNO.SDS.CSTN.MainAppModuleList(t)),this.pageList},onCstnConfigLoaded:function(){var e=SYNO.SDS.CSTN.Config["display_4.0_new_feature_hint"],t=this.appInstance.getUserSettings("hide_admin_console_new_feature_module_setting_hint");if(!0===e&&t!==SYNO.SDS.CSTN.Config.ds_id){var i=this.getPageList().getNodeById("SYNO.SDS.CSTN.PanelConfigure");i&&i.ui.elNode.querySelector(".syno-cstn-new-feature-hint").classList.add("show-hint")}},onSelectionChange:function(e,t){if(t&&t.attributes&&"SYNO.SDS.CSTN.PanelConfigure"===t.attributes.id){this.appInstance.setUserSettings("hide_admin_console_new_feature_module_setting_hint",SYNO.SDS.CSTN.Config.ds_id);var i=this.getPageList().getNodeById("SYNO.SDS.CSTN.PanelConfigure");i&&i.ui.elNode.querySelector(".syno-cstn-new-feature-hint").classList.remove("show-hint")}this.callParent(arguments)},getC2TransferItems:function(){return this.c2transferFn="SYNO.SDS.CSTN.PanelRedirect",SYNO.SDS.Config.FnMap.hasOwnProperty("SYNO.SDS.C2Transfer.AdminSetting")&&SYNO.SDS.CSTN.HasC2Transfer()&&(this.c2transferFn="SYNO.SDS.C2Transfer.AdminSetting"),[{text:_STR("func","mgr_c2transfer_sendcopy"),iconCls:"syno-cstn-list-sendcopy",fn:this.c2transferFn}]},reloadC2Transfer:function(e,t){if("C2Transfer"===e)if("install"===t){var i=this.afterReload.bind(this,"SYNO.SDS.C2Transfer.AdminSetting");const n=function(e){this.appInstance.loadRequiredC2JSFiles().then(i).catch(i),e.disconnect()};this.notifyWhenC2TransferLoaded(n.bind(this))}else if("uninstall"===t)this.afterReload("SYNO.SDS.CSTN.PanelRedirect");else{var s="SYNO.SDS.CSTN.PanelRedirect";if(SYNO.SDS.CSTN.HasC2Transfer()&&(s="SYNO.SDS.C2Transfer.AdminSetting",!SYNO.SDS.C2Transfer)){var i=this.afterReload.bind(this,s);return void this.appInstance.loadRequiredC2JSFiles().then(i).catch(i)}this.afterReload(s)}},afterReload:function(e){const t=this.getPageList().getNodeById(this.c2transferFn);if(t){t.attributes.fn;if(t.attributes.fn=e,this.launchPage(t.attributes.fn),SYNO.Debug("select mudule: "+this.c2transferFn),this.getPageList().selectModule(this.c2transferFn),"SYNO.SDS.C2Transfer.AdminSetting"===t.attributes.fn){this.mask(1,null,null,!1);const i=function(e){this.unmask(!1),e.disconnect()};this.notifyWhenC2TransferLoaded(i.bind(this))}}},notifyWhenC2TransferLoaded:function(e){const t=function(t,i){document.querySelector("link[href*=C2Transfer]")&&e(i)};new MutationObserver(t).observe(document.body,{childList:!0,subtree:!0})},setPreConfig:function(e,t){this.preConfigMap[e]=t},fetchPreConfig:function(e){var t=e||this.activePage.itemId,i=this.preConfigMap[t];return this.preConfigMap[t]=void 0,i},onBeforeSelect:function(e,t,i){if(!this.forceChangePage&&!this.canChangePage(e,t,i))return!1;if(i&&i.leaf){var n=this.pageCt.getComponent(i.attributes.fn);n&&Ext.isFunction(n.onPageDeactivate)&&n.onPageDeactivate()}return this.forceChangePage=!1,!0},onClickHelp:function(){var e="SYNO.SDS.Drive.Application:drive_admin_console.html";_S("standalone")?SYNO.SDS.WindowLaunch("SYNO.SDS.HelpBrowser.Application",{topic:e}):SYNO.SDS.AppLaunch("SYNO.SDS.HelpBrowser.Application",{topic:e},!1)},canChangePage:function(e,t,i){var n=t.attributes.fn,s=i?i.attributes.fn:null,o=this.getActivePage();if(n!=s&&"SYNO.SDS.CSTN.PanelCloudStn"!==n){var a,l=!1;switch(this.enableStatus){case"enabled":this.cstnInfo&&!0===this.cstnInfo.cstn_freeze&&"SYNO.SDS.CSTN.PanelConfigure"!==n?a=_STR("cstn","drive_diskfull_desc"):l=!0;break;case"done":case"updating":case"initializing":a=_STR("warning","msg_upgrading");break;case"checking":a=_STR("warning","msg_checking_db");break;case"upgradefail":a=_STR("warning","error_drive_upgradefail");break;case"dbnewer":a=_STR("warning","error_upgrade_drive_db_newer");break;case"dbunexist":a=_STR("warning","error_drive_db_unexist");break;case"homedisabled":a=_STR("warning","err_enable_homes");break;case"portconflict":a=String.format(_STR("warning","warn_drive_port_conflict"),"6690");break;default:l=!0}if(!1===l)return this.getMsgBox().alert(_STR("app","app_name"),a),l}return!(o&&Ext.isFunction(o.checkDirty)&&o.checkDirty())||(this.confirmLostChangePromise({save:function(){o.onSave(),this.forceChangePage=!0,this.selectPage(n)}.bind(this),cancel:Ext.emptyFn,dontSave:function(){o.onCancel(),this.forceChangePage=!0,this.selectPage(n)}.bind(this)},this),!1)}
}),SYNO.SDS.CSTN.MainWindow=Ext.extend(SYNO.SDS.AppWindow,{appInstance:null,mainPanel:null,constructor:function(e){this.appInstance=e.appInstance,this.mainPanel=new SYNO.SDS.CSTN.MainPanel({owner:this}),SYNO.SDS.CSTN.MainWindow.superclass.constructor.call(this,Ext.apply({resizable:!0,maximizable:!1,minimizable:!0,minWidth:SYNO.SDS.CSTN.WIN_WIDTH,minHeight:SYNO.SDS.CSTN.DEFAULT_HEIGHT,width:SYNO.SDS.CSTN.WIN_WIDTH,height:SYNO.SDS.CSTN.DEFAULT_HEIGHT,layout:"fit",cls:"syno-cstn",items:[this.mainPanel]},e))},onOpen:function(e){SYNO.SDS.CSTN.MainWindow.superclass.onOpen.call(this,e),this.mainPanel.onActivate(),e.sel_func&&this.mainPanel.onActivate(e.sel_func)},onRequest:function(e){SYNO.SDS.CSTN.MainWindow.superclass.onRequest.call(this,e)},onClose:function(){if(!1===SYNO.SDS.CSTN.MainWindow.superclass.onClose.apply(this,arguments))return!1;var e=this.mainPanel,t=e.formPanel.getLayout().activeItem.itemId;return!e.isPanelDirty(t)||(this.getMsgBox().confirm(_STR("app","app_name"),_T("common","confirm_lostchange"),function(e){"yes"===e&&this.doClose()},this),!1)},setStatus:function(e){e=e||{};var t=this.mainPanel.formPanel.getLayout().activeItem.getFooterToolbar();t&&Ext.isFunction(t.setStatus)?t.setStatus(e):this.getMsgBox().alert("alert from MainWindow.js",e.text)}}),Ext.ns("SYNO.SDS.CSTN"),Ext.define("SYNO.SDS.CSTN.PathBar",{extend:"Ext.util.Observable",constructor:function(e){this.init(e.rb),this.callParent(arguments),this.addEvents("updatepath")},init:function(e){return this.rb=e,this.tbPanel=new SYNO.SDS.CSTN.PathButtonsPanel({cls:"syno-cstn-pathtoolbar",rb:this.rb}),this},addPathButton:function(e,t,i,n,s,o,a){return this.tbPanel.addButton(e,t,i,n,s,o,a,this.rb)},updatePathButton:function(e,t,i,n,s,o){return this.tbPanel.updateButton(e,t,i,n,s,o)},addPathButtons:function(e){for(var t=this.tbPanel.items.length<e.length?e.length:this.tbPanel.items.length,i=e.length-1,n=0;n<t;n++)if(n<this.tbPanel.items.length&&n<e.length)this.updatePathButton(n,e[n].text,e[n].tooltip,e[n].path,e[n].node_id,n===i);else{if(!(n<e.length)){this.removePathButtons(n,t);break}this.addPathButton(this.tbPanel.items.length,e[n].text,e[n].tooltip,e[n].path,e[n].node_id,0===n,n===i)}this.tbPanel.setActiveButton(this.tbPanel.items[this.tbPanel.items.length-1]),this.fireEvent("updatepath",this)},removePathButtons:function(e,t){this.tbPanel.removeButtons(e,t)},removeAllButtons:function(){this.tbPanel.removeAllButtons()},setWidth:function(e){this.tbPanel.setWidth(e)}}),Ext.define("SYNO.SDS.CSTN.PathButtonsPanel",{extend:"Ext.BoxComponent",onRender:function(){this.activeButton=null,this.enableScroll=!0,this.scrollIncrement=0,this.scrollRepeatInterval=400,this.scrollDuration=.35,this.animScroll=!0,this.buttonWidthSet=!1,this.allowDomMove=!1,this.callParent(arguments),this.mon(this,"resize",this.delegateUpdates),this.items=[],this.selMenu=new SYNO.ux.Menu({items:[],listeners:{click:{fn:function(e,t){if(t.obj.getPath()){var i=t.obj.getPath(),n=t.obj.getNodeId();if(n){var s={};s.name=i,s.node_id=n,t.obj.rb.onChangeDir("normal",s)}}},scope:this}}}),this.stripWrap=Ext.get(this.el).createChild({cls:"cs-pathbuttons-strip-wrap",cn:{tag:"ul",cls:"cs-pathbuttons-strip"}}),this.stripSpacer=Ext.get(this.el).createChild({cls:"cs-pathbuttons-strip-spacer"}),this.strip=new Ext.Element(this.stripWrap.dom.firstChild),this.edge=this.strip.createChild({tag:"li",cls:"cs-pathbuttons-edge"}),this.strip.createChild({cls:"x-clear"})},addButton:function(e,t,i,n,s,o,a,l){var r=this.strip.createChild({tag:"li"},this.edge),d=new SYNO.SDS.CSTN.PathBar.PathButton(r,e,t,i,n,s,o,a,l);return this.items.push(d),this.buttonWidthSet||(this.lastButtonWidth=d.container.getWidth()),this.addManagedComponent(d),d},updateButton:function(e,t,i,n,s,o){this.items[e].updateButton(t,i,n,s,o)},removeButtons:function(e,t){for(var i,n,s=e;s<t;s++)n=this.items[s],i=document.getElementById(n.container.id),this.removeManagedComponent(n),n.destroy(),i.parentNode.removeChild(i);var o=[];for(s=0;s<e;s++)o.push(this.items[s]);this.items=o,this.delegateUpdates()},removeAllButtons:function(){for(var e,t,i=this.items.length,n=0;n<i;n++)t=this.items[n],e=document.getElementById(t.container.id),this.removeManagedComponent(t),t.destroy(),e.parentNode.removeChild(e);this.items=[],this.delegateUpdates()},setActiveButton:function(e){this.activeButton=e,this.delegateUpdates()},delegateUpdates:function(){this.enableScroll&&this.rendered&&this.autoScroll()},autoScroll:function(){var e=this.items.length,t=this.el.dom.clientWidth,i=this.stripWrap,n=i.dom.offsetWidth,s=this.getScrollPos(),o=this.edge.getOffsetsTo(this.stripWrap)[0]+s;!this.enableScroll||e<1||n<20||(i.setWidth(t),o<=t?(i.dom.scrollLeft=0,this.showSelBtn&&(this.showSelBtn=!1,this.el.removeClass("x-pathbuttons-selection-btn-displayed"),this.menuBtn.hide())):(this.showSelBtn||this.el.addClass("x-pathbuttons-selection-btn-displayed"),t-=i.getMargins("lr"),i.setWidth(t>20?t:20),this.showSelBtn||(this.menuBtn?(this.showSelBtn=!0,this.menuBtn.show()):this.createMenuBtn()),this.updateScrollandSelMenu()))},createMenuBtn:function(){var e=this.el.dom.offsetHeight,t=this.el.insertFirst({cls:"cs-pathbuttons-selection-btn"});t.setHeight(e),t.addClassOnOver("cs-pathbuttons-selection-btn-over"),t.addClassOnClick("cs-pathbuttons-selection-btn-click"),this.leftRepeater=new Ext.util.ClickRepeater(t,{interval:this.scrollRepeatInterval,handler:this.onShowMenu,scope:this}),this.menuBtn=t},onShowMenu:function(){var e=this.menuBtn.getXY();this.selMenu.isVisible()?this.selMenu.hide():this.selMenu.showAt([e[0]+-5,e[1]+28])},updateScrollandSelMenu:function(){for(var e,t=this.items.length,i=t-1,n=0,s=this.stripWrap.getWidth(),o=i;o>=0&&(e=this.items[o].el.child(".cs-pathbutton-center"),!((n+=e.getWidth()+14)>s));o--);o==i&&(o-=1),this.selMenu.removeAll();for(var a=0;a<=o;a++)this.selMenu.addItem({obj:this.items[a],text:this.items[a].text});var l=this.items[o+1],r=this.stripWrap.dom.scrollLeft,d=l.el.getOffsetsTo(this.stripWrap)[0]+r;this.stripWrap.scrollTo("left",d-14)},getScrollWidth:function(){return this.edge.getOffsetsTo(this.stripWrap)[0]+this.getScrollPos()},getScrollPos:function(){return parseInt(this.stripWrap.dom.scrollLeft,10)||0},getScrollAnim:function(){return{duration:this.scrollDuration,scope:this}}}),SYNO.SDS.CSTN.PathBar.PathButton=function(e,t,i,n,s,o,a,l,r){this.rb=r,this.setPath(s),this.setNodeId(o);var d=a?this.firstBtnCls:"",c=l?this.lastBtnCls:"";SYNO.SDS.CSTN.PathBar.PathButton.superclass.constructor.call(this,{text:i,itemId:t,renderTo:e,tooltip:n,clickEvent:"mousedown",listeners:{click:{fn:function(){var e=this.getPath(),t=this.getNodeId();if(t){var i={};i.name=e,i.node_id=t,this.rb.onChangeDir("normal",i)}},scope:this}},template:new Ext.Template('<table cellspacing="0" class="x-btn '+d+" "+c+' {3}"><tbody><tr>','<td class="cs-pathbutton-left"></td>','<td class="cs-pathbutton-center"><em class="{5} unselectable="on">','<button class="x-btn-text {2}" type="{1}" style="height:18px;">{0}</button>',"</em></td>",'<td class="cs-pathbutton-right"></td>',"</tr></tbody></table>")}),this.setPath(s)},Ext.extend(SYNO.SDS.CSTN.PathBar.PathButton,Ext.Button,{firstBtnCls:"x-first-btn",lastBtnCls:"x-last-btn",setPath:function(e){this.path=e},getPath:function(){return this.path},setNodeId:function(e){this.node_id=e},getNodeId:function(){return this.node_id},updateButton:function(e,t,i,n,s){this.setPath(i),this.setText(e),this.setTooltip(t),this.setNodeId(n),s?this.addClass(this.lastBtnCls):this.removeClass(this.lastBtnCls)}}),Ext.define("SYNO.SDS.CloudStation.Component.ExtendedTreePanel.SelectiveFolder",{extend:"SYNO.SDS.CloudStation.Component.ExtendedTreePanel.BaseTree",constructor:function(e){var t=Ext.apply({},e);return this.callParent([t])},initEvents:function(){var e=this.callParent(arguments);return this.mon(this,"checkchange",this.onCheckChange,this),this.mon(this,"beforeexpandnode",this.beforeExpandNode,this),this.mon(this,"beforeappend",this.beforeAppend,this),e},get_state_by_children:function(e){var t=0,i=0,n=0;return e.eachChild(function(e){var s=e.getUI()||{};!s.checkbox||!Ext.isFunction(s.getCheckValue)||Ext.isFunction(s.isDisabled)&&s.isDisabled()||(!0===s.getCheckValue()?i+=1:!1===s.getCheckValue()&&(n+=1),t+=1)}),0===t?e.getUI().getCheckValue():i===t||"gray"},propagate_down:function(e,t){var i=function(e,t){e.eachChild(function(e){i(e,t)});var n=e.getUI();n&&Ext.isFunction(n.setCheckValue)&&n.setCheckValue(t)};i(e,t)},set_pnode_checked:function(e,t){var i=e.getUI();i&&Ext.isFunction(i.getCheckValue)&&(e.attributes.checked=this.get_state_by_children(e),i.syncCheckCssClass())},propagate_up:function(e,t){for(;e;)this.set_pnode_checked(e,t),e=e.parentNode},onCheckChange:function(e,t){this.propagate_down(e,t),this.propagate_up(e.parentNode,t)},beforeExpandNode:function(e,t,i){e.eachChild(function(t){!0===t.attributes.checked_TBD&&(t.attributes.checked=!1!==e.attributes.checked,t.attributes.checked_TBD=!1,t.getUI().syncCheckCssClass())},this),e.sort(function(e,t){var i=e.attributes.text,n=t.attributes.text;return i<n?-1:i>n})},beforeAppend:function(e,t,i){var n,s=i.attributes.path;return Ext.each(t.childNodes,function(e){e.attributes.path==s&&(n=e)}),!n||(n.attributes.filtered=n.attributes.filtered||i.attributes.filtered,n.attributes.map_entries.push.apply(n.attributes.map_entries,i.attributes.map_entries),!1)}}),Ext.define("SYNO.SDS.CloudStation.Component.ExtendedTreePanel.FolderLoader.Regular",{extend:"SYNO.SDS.CloudStation.Component.ExtendedTreePanel.FolderLoader.Base",clearOnLoad:!1,paramsAsHash:!0,constructor:function(){var e=this.callParent(arguments),t=this.baseParams;return this.baseParams={url:this.url,params:t},this.on("beforeload",function(e,t){this.removeNotFilteredChildren(t),this.baseParams.params.map_entries=t.attributes.map_entries,this.baseParams.params.path=t.attributes.path},this),e},createNode:function(e){return e.checked=!0,e.checked_TBD=!0,this.callParent(arguments)},removeNotFilteredChildren:function(e){for(var t=e.childNodes.length-1;t>=0;t--)!1===e.childNodes[t].attributes.filtered&&e.removeChild(e.childNodes[t],!0)},directFn:function(e,t){Ext.Ajax.request({method:"POST",url:e.url,params:Ext.encode(e.params),callback:function(e,i,n){var s=Ext.decode(n.responseText),o={};s.success?o.status=!0:o.status=!1,t(s.children,o)},scope:this})}});