HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: /volume1/@appstore/HyperBackup/ui/backup.js
/* Copyright (c) 2026 Synology Inc. All rights reserved. */

Ext.define("SYNO.SDS.Backup.Task.BlueActionButton",{extend:"SYNO.ux.Button",btnStyle:"blue",enable:function(){var e=this.el.dom.classList;return e.remove("syno-ux-button-default"),e.remove("syno-ux-button-blue"),e.add("syno-ux-button-blue"),this.callParent(arguments)},disable:function(){var e=this.el.dom.classList;return e.remove("syno-ux-button-default"),e.remove("syno-ux-button-blue"),e.add("syno-ux-button-default"),this.callParent(arguments)}}),Ext.define("SYNO.SDS.Backup.Task.SubPanel",{extend:"Ext.Panel",constructor:function(e){e=this.fillConfig(e),this.callParent(arguments)},fillConfig:function(e){return Ext.apply({cls:"syno-backup-task-subpanel",buttonAlign:"left"},e)},setHeaderStatus:function(e,t,s){var i=this.header,a=i.child("span.dest-status-text");if(a)Ext.fly(a).setStyle("color",t),Ext.fly(a).update(e),Ext.isEmpty(s)?a.dom.removeAttribute("ext:qtip"):a.dom.setAttribute("ext:qtip",s);else{var n=i.child("span."+this.headerTextCls);if(n){var r=Ext.DomHelper.insertAfter(n.dom,{tag:"span",cls:"dest-status-text",style:"color:"+t,html:e});Ext.isEmpty(s)||r.setAttribute("ext:qtip",s)}}},setHeaderLock:function(e){var t=this.header,s="data-enc-lock";t.child("span."+s)||(Ext.DomHelper.append(t.dom,{tag:"span",cls:s,"ext:qtip":e?SYNO.SDS.Backup.String("app","enc_lock_close"):SYNO.SDS.Backup.String("app","enc_lock_open")}),e&&t.child("span."+s).addClass("has-data-enc"))}}),Ext.define("SYNO.SDS.Backup.Task.MainPage",{extend:"SYNO.ux.Panel",border:!1,constructor:function(e){this.isOnline=void 0,this.taskState=e.taskState,this.taskStatus=e.taskStatus,this.taskLastResult=e.taskLastResult,this.statusPanel=null,this.cancelBtn=null,this.backupBtn=null,this.browseBtn=null,this.actionBtn=null,this.suspendedMenu=null,this.backingupMenu=null,this.statisticBtn=null,this.endofserviceBtn=null,this.deleteBtn=null,this.isSupportStatistics=!0,this.suspendedMenuBtn=null,this.backingupMenuBtn=null,this.canCancel=!0,this.destPanel=null,this.settingPanel=null,this.displayStatus=this.checkDisplayStatus(),this.isDemoMode=_S("demo_mode"),this.taskIcon=e.taskIcon,e=this.fillConfig(e),this.callParent(arguments)},getStatusPanel:function(){if(this.statusPanel)return this.statusPanel;var e="suspended"===this.displayStatus?"suspended":"idle";return this.statusPanel=new Ext.Panel({cls:"syno-backup-task-status-panel",buttonAlign:"left",height:208,bwrapStyle:"height: 178px",items:[{itemId:"statusText",data:{status:this.taskIcon,extraCss:"",text:_T("common","loading")},tpl:'<div class="task-status-text task-status-text-{status} {extraCss}">{text}</div>'},{xtype:"container",itemId:"statusCard",layout:"card",activeItem:e,items:[{itemId:"idle",cls:"syno-backup-task-status-idle-panel",xtype:"container",items:[{itemId:"errorText",data:{errorText:_T("common","loading"),isShowError:!1},tpl:'<div class="tip-text {cls}" <tpl if="!isShowError">style="display:none"</tpl> >{errorText}</div>'},{itemId:"timeText",data:{lastBkpTime:_T("common","loading"),nextBkpTime:_T("common","loading")},tpl:'<div class="bkp-time-text">'+_T("usbbackup","usbbkp_lasttime")+': {lastBkpTime}</div><div class="bkp-time-text">'+_T("backup","next_bkp_time")+": {nextBkpTime}</div>"}]},{itemId:"active",cls:"syno-backup-task-status-active-panel",xtype:"container",items:[{itemId:"progress",data:{isShowPercentage:!1,hidePercentageNumber:!1,description:"",speed:"",percentage:0,bottom_description:"",scan_file:""},tpl:new Ext.XTemplate('<div class="progress-upper-row">{[this.upperText(values.description)]}<span class="syno-backup-progress-percentage-text" <tpl if="this.shouldUseNoPercentageStyle(values)">style="visibility:hidden"</tpl>>{percentage}%</span></div><div class="syno-backup-percentage-bar-bg" <tpl if="!isShowPercentage">style="visibility:hidden"</tpl>><div class="syno-backup-percentage-bar" style="width:{percentage}%;<tpl if="this.shouldUseNoPercentageStyle(values)">animation: widthPercentageBarAnimation 3s linear;</tpl>"></div></div><div class="progress-bottom-row" <tpl if="!isShowPercentage || !this.isShowProgressBottomText(values)">style="visibility:hidden"</tpl>><span class="syno-backup-overflow-ellipsis" ext:qtip="{[this.bottomText(values.bottom_description, values.scan_file, values.speed)]}">{[this.bottomText(values.bottom_description, values.scan_file, values.speed)]}</span><div class="syno-ux-whitetip-icon" style="margin:0;width:20px;height:20px;min-width:20px;min-height:20px;background-position:-1px -1px;"  ext:wtip="{[this.tooltip()]}"></div></div>',{tooltip:function(){return SYNO.SDS.Backup.String("app","transfer_speed_tips")},upperText:function(e){return String.format('<span class="upper-row-desc-text">{0}</span>',e)},bottomText:function(e,t,s){return[t,e=e+" "+String.format("({0}{1}{2})",SYNO.SDS.Backup.String("app","speed"),_T("common","colon"),Ext.isString(s)&&""!==s?s:"--")].filter((function(e){return!0!==Ext.isEmpty(e)}),this).join(",&nbsp")},shouldUseNoPercentageStyle:function(e){return!e.isShowPercentage||e.hidePercentageNumber},isShowProgressBottomText:function(e){return[e.bottom_description,e.scan_file,e.speed].some((function(e){return!Ext.isEmpty(e)}))}})}]},{itemId:"suspended",cls:"syno-backup-task-status-suspend-panel",xtype:"container",items:[{itemId:"errorText",data:{errorText:_T("common","loading"),isShowError:!1},tpl:'<div class="tip-text task-status-text-failed" <tpl if="!isShowError">style="display:none"</tpl> >{errorText}</div>'},{itemId:"progress",data:{isShowPercentage:!0,percentage:0},tpl:'<div class="progress-upper-row"><span class="syno-backup-progress-percentage-text" <tpl if="!isShowPercentage">style="visibility:hidden"</tpl>>{percentage}%</span></div><div class="syno-backup-percentage-bar-bg" <tpl if="!isShowPercentage">style="visibility:hidden"</tpl>><div class="syno-backup-percentage-bar" style="width:{percentage* 4.2}px"></div></div>'},{itemId:"timeText",data:{nextBkpTime:_T("common","loading")},tpl:"<div>"+_T("backup","next_bkp_time")+": {nextBkpTime}</div>"}]}]}],buttons:[this.suspendedMenuBtn=new Ext.Container({hidden:"suspended"!==e||"backupable"!==this.taskState,cls:"syno-backup-container-menu",items:[this.suspendedMenu=new SYNO.ux.Button({text:SYNO.SDS.Backup.String("app","backingup_action_menu"),disabled:!0,cls:"syno-backup-button-menu",menu:{xtype:"syno_menu",items:[{itemId:"btn_resume",text:SYNO.SDS.Backup.String("app","resume_button_title"),scope:this,disabled:!0,handler:this.onResumeNow},{itemId:"btn_discard",text:SYNO.SDS.Backup.String("app","discard_button_title"),scope:this,disabled:!0,handler:this.onDiscard}]}}),{xtype:"box",height:28,width:1,cls:"syno-backup-box"}]}),this.backingupMenuBtn=new Ext.Container({hidden:!0,cls:"syno-backup-container-menu",items:[this.backingupMenu=new SYNO.ux.Button({text:SYNO.SDS.Backup.String("app","backingup_action_menu"),disabled:!0,cls:"syno-backup-button-menu",menu:{xtype:"syno_menu",items:[{itemId:"btn_suspend",text:SYNO.SDS.Backup.String("app","suspend_button_title"),scope:this,disabled:!0,handler:this.onSuspendBackup},{itemId:"btn_cancel",text:_T("common","cancel"),scope:this,disabled:!0,handler:this.onCancelBackup},{itemId:"btn_cancel_discard",text:SYNO.SDS.Backup.String("app","discard_button_title"),scope:this,disabled:!1,handler:this.onCancelAndDiscard}]}}),{xtype:"box",height:28,width:1,cls:"syno-backup-box"}]}),this.backupBtn=new SYNO.SDS.Backup.Task.BlueActionButton({text:SYNO.SDS.Backup.String("app","backup_button_title"),hidden:"idle"!==e||"backupable"!==this.taskState,scope:this,handler:this.onBackupNow}),this.cancelBtn=new SYNO.ux.Button({text:_T("common","cancel"),hidden:!0,scope:this,handler:this.onCancelBackup}),this.importBtn=new SYNO.ux.Button({btnStyle:"blue",text:SYNO.SDS.Backup.String("app","relink_button_title"),scope:this,hidden:"importable"!==this.taskStatus,handler:this.onImportNow}),this.relinkBtn=new SYNO.ux.Button({btnStyle:"blue",text:SYNO.SDS.Backup.String("app","relink_button_title"),scope:this,hidden:"relinkable"!==this.taskStatus,handler:this.onRelinkNow}),this.exportBtn=new SYNO.ux.Button({btnStyle:"blue",text:SYNO.SDS.Backup.String("app","export_button_title"),scope:this,handler:this.onBackupNow,hidden:"exportable"!==this.taskStatus}),this.reauthBtn=new SYNO.ux.Button({btnStyle:"blue",text:SYNO.SDS.Backup.String("app","reauth_button_title"),scope:this,handler:this.onReauthNow,hidden:"unauth"!==this.taskStatus}),this.rebootNowBtn=new SYNO.ux.Button({btnStyle:"blue",text:SYNO.SDS.Backup.String("app","restart_now"),scope:this,handler:function(){SYNO.SDS.System.Reboot()},hidden:!0}),this.endofserviceBtn=new SYNO.ux.Button({btnStyle:"blue",text:SYNO.SDS.Backup.String("app","endofservice_button_title"),scope:this,disabled:!0,hidden:!0}),this.browseBtn=new SYNO.ux.Button({iconCls:"syno-backup-button-icon syno-backup-browse-icon",tooltip:SYNO.SDS.Backup.String("app","backup_explorer"),hidden:!this.isImage||"multi_ver_lun"===this.dataType,width:30,scope:this,handler:this.onVersionBrowse}),this.statisticBtn=new SYNO.ux.Button({iconCls:"syno-backup-button-icon syno-backup-statistics-icon",tooltip:SYNO.SDS.Backup.String("statistics","storage_statistics_title"),hidden:!this.isImage,width:30,scope:this,handler:this.onStatisticBrowse}),this.deleteBtn=new SYNO.ux.Button({text:_T("common","delete"),hidden:!0,scope:this,handler:this.onDeleteBackupTask}),this.actionBtn=new SYNO.ux.SplitButton({iconCls:"syno-backup-button-icon syno-backup-action-icon",handler:function(){this.showMenu()},menu:{xtype:"syno_menu",items:[{itemId:"btn_edit",text:_T("common","alt_edit"),disabled:!0,scope:this,handler:this.onEditBackupTask},{itemId:"btn_delete",tooltip:this.isDemoMode?_JSLIBSTR("uicommon","error_demo"):"",text:_T("common","delete"),scope:this,handler:this.onDeleteBackupTask},{itemId:"btn_check",text:SYNO.SDS.Backup.String("app","detect_button"),disabled:!0,scope:this,handler:this.onDetectTarget}]}})]}),this.statusPanel},getDestPanel:function(){return this.destPanel||(this.destPanel=new SYNO.SDS.Backup.Task.SubPanel({flex:296,margins:"0 17 4 0",title:_T("netbackup","netbkp_target"),items:this.destView=new Ext.DataView({store:this.destStore=new Ext.data.JsonStore({autoDestroy:!0,fields:["key","text","tip"],data:this.getDestData(),listeners:{load:this.destEllipsisSetOnLoad,scope:this}}),itemSelector:"table",tpl:new Ext.XTemplate('<tpl for=".">','<table style="width:100%;border-spacing: 0px;table-layout:fixed;">','<tr class="detail-row">','<td style="width:46%" valign="top"><div class="detail-key" ext:qtip="{key:htmlEncode}">{key}:</div></td>','<td style="width:8%"></td>','<td style="width:46%" valign="top"><div class="detail-value" ext:qtip="{tip:htmlEncode}">{text}</div></td>',"</tr>","</table>","</tpl>")}),listeners:{resize:this.destEllipsisSetOnResize,scope:this},buttons:[{xtype:"syno_button",text:SYNO.SDS.Backup.String("app","version_list"),hidden:!this.isImage,scope:this,handler:this.onVersionList}]})),this.destPanel},getSettingPanel:function(){return this.settingPanel||(this.settingPanel=new SYNO.SDS.Backup.Task.SubPanel({flex:330,margins:"0 0 4 0",title:_T("schedule","task_settings"),items:this.settingView=new Ext.DataView({store:this.settingStore=new Ext.data.JsonStore({autoDestroy:!0,fields:["key","text","link_text","handle_fn"],data:this.getSettingData(),listeners:{load:this.settingEllipsisSetOnLoad,scope:this}}),itemSelector:"table",tpl:new Ext.XTemplate('<tpl for=".">','<table style="width:100%;border-spacing: 0px;table-layout:fixed;">','<tr class="detail-row">','<td style="width:42%" valign="top"><div class="detail-key" ext:qtip="{key:htmlEncode}">{key}:</div></td>','<td style="width:7%"></td>','<td style="width:51%" valign="top"><div class="detail-value" ext:qtip="{text:htmlEncode}">{text}&nbsp;<span class="detail-value-link {handle_fn}">{link_text}</span></div></td>',"</tr>","</table>","</tpl>")}),listeners:{resize:this.settingEllipsisSetOnResize,scope:this},buttons:[{xtype:"syno_button",text:_T("schedule","task_settings"),disabled:!0,scope:this,handler:this.onEditBackupTask}]})),this.settingPanel},settingEllipsisSetOnResize:function(){this.viewComponentEllipsisSet(this.settingView,3,!1)},settingEllipsisSetOnLoad:function(){this.settingClickHandler(this.settingView),this.viewComponentEllipsisSet(this.settingView,3,!0)},destEllipsisSetOnResize:function(){this.viewComponentEllipsisSet(this.destView,2,!1)},destEllipsisSetOnLoad:function(){this.viewComponentEllipsisSet(this.destView,2,!0)},viewComponentEllipsisSet:function(e,t,s){if(e){var i=e.getTemplateTarget(),a=i.parent("div");t+=Math.floor((a.getHeight()-207)/18),Ext.each(Ext.query("div.detail-key",i.dom),(function(e){s&&(e.originInnerHTML=e.innerHTML),this.textEllipseSet(e,18,t)}),this)}},textEllipseSet:function(e,t,s){if(Ext.isDefined(e.originInnerHTML)&&(e.innerHTML=e.originInnerHTML),!(e.offsetHeight<=t*s)){var i=0,a="",n="",r=[],o=[],c=e.innerHTML.match(/(^<[^>]*>)([^<]*)(<\/[^>]*>$)/);null!==c?(o.push(c[1]),r=c[2].split(" "),o.push(c[3])):r=e.innerHTML.split(" "),e.innerHTML="",Ext.each(r,(function(a,n){if(i=n,e.innerHTML+=a+" ",e.offsetHeight>t*(s-1))return!1}));for(var l=0;l<i;l++)a+=r[l]+" ";for(var u=i;u<r.length;u++)n+=r[u]+" ";e.innerHTML=a+'<div style="white-space: nowrap; text-overflow: ellipsis; overflow:hidden;"ext:qtip="'+n.trim().replace(":","")+'">'+n+"</div>",2===o.length&&(e.innerHTML=o[0]+e.innerHTML+o[1])}},fillConfig:function(e){return Ext.apply({cls:"syno-backup-task-main-page",layout:"border",border:!1,items:[{region:"north",height:208,xtype:"container",cls:"syno-backup-task-status-wrapper",layout:"hbox",items:[{xtype:"container",width:92,items:[this.statusIcon=new Ext.Component({data:{status:this.taskIcon},tpl:'<div class= "task-status-icon task-status-icon-{status}"/>'})]},{border:!1,xtype:"container",layout:"fit",flex:1,items:[this.getStatusPanel()]}]},{region:"center",xtype:"container",margins:"16 0 13 0",layout:{type:"hbox",align:"stretch"},items:[this.getDestPanel(),this.getSettingPanel()]}]},e)},setTaskStatus:function(e,t,s,i,a,n,r,o){this.taskStatus=t,this.taskState=e,this.taskLastResult=i,this.displayStatus=this.checkDisplayStatus(),this.setDetailLinkVisibility(),this.setBtnStatus();var c=SYNO.SDS.Backup.getStatusIcon(e,t,i,r,o),l=SYNO.SDS.Backup.getStatusText(e,t,i,r,o),u=l[0],p=l[1],d=SYNO.SDS.Backup.getStatusSubText(e,t,i,a,n,r),h=!1;if(this.statusIcon.update({status:c}),this.owner.setTaskStatusIcon(c),this.lastIcon===c&&this.lastText===u&&this.lastHasEllipsis===p||(this.lastIcon=c,this.lastText=u,this.lastHasEllipsis=p,this.getStatusPanel().getComponent("statusText").update({status:c,extraCss:p?"syno-backup-animated-ellipsis":"",text:u})),"suspended"===this.displayStatus)this.getStatusPanel().getComponent("statusCard").layout.setActiveItem("suspended"),(h="none"!==d)&&(d+=' <a class="syno-backup-log-detail-link">('+SYNO.SDS.Backup.String("app","status_detailed_log")+")</a>",this.setErrDetailedLogLink("suspended")),this.getStatusPanel().getComponent("statusCard").getComponent("suspended").getComponent("errorText").update({errorText:d,isShowError:h});else if("idle"===this.displayStatus){if(this.getStatusPanel().getComponent("statusCard").layout.setActiveItem("idle"),"partial"===i&&this.isImage&&!0!==r&&(d="none"===d?SYNO.SDS.Backup.String("app","partial_success"):d,d+=" <a class='syno-backup-version-detail-link'>("+SYNO.SDS.Backup.String("app","version_detail")+")</a>"),this.getStatusPanel().getComponent("statusCard").getComponent("idle").getComponent("errorText").body){var S="task-status-text-failed";if("restore_only"===this.taskState?(S="task-status-text-restoreonly",d="none"===d?SYNO.SDS.Backup.String("error","status_target_broken"):d,4535!==a&&(d+=" <a class='syno-backup-version-detail-link'>("+SYNO.SDS.Backup.String("app","download_damage_report")+")</a>")):"partial"===i&&(S="task-status-text-partial"),h="none"!==d,"backupable"!==this.taskState&&"exportable"!==this.taskState||"suspend"!==this.taskLastResult&&"failed"!==this.taskLastResult&&"tierfs_busy"!==this.taskLastResult||!h||(d+=' <a class="syno-backup-log-detail-link">('+SYNO.SDS.Backup.String("app","status_detailed_log")+")</a>",this.setErrDetailedLogLink("idle")),this.getStatusPanel().getComponent("statusCard").getComponent("idle").getComponent("errorText").update({errorText:d,isShowError:h,cls:S}),this.isImage){var _=this.getStatusPanel().getComponent("statusCard").getComponent("idle").getComponent("errorText").getEl();"restore_only"===this.taskState?this.registerErrorText(_,"download_report"):"partial"===i&&this.registerErrorText(_,"partial_detail")}}}else"active"===this.displayStatus?this.getStatusPanel().getComponent("statusCard").layout.setActiveItem("active"):"rbd_service_requires_reboot"===this.displayStatus?(this.getStatusPanel().getComponent("statusCard").layout.setActiveItem("idle"),this.getStatusPanel().getComponent("statusCard").getComponent("idle").getComponent("errorText").update({errorText:SYNO.SDS.Backup.String("app","explain_why_system_restart_is_required"),isShowError:!0})):"does_not_support_entire_dsm_backup"===this.displayStatus&&(this.getStatusPanel().getComponent("statusCard").layout.setActiveItem("idle"),this.getStatusPanel().getComponent("statusCard").getComponent("idle").getComponent("errorText").update({errorText:SYNO.SDS.Backup.String("app","explain_why_not_support_backing_up_entire_system"),isShowError:!0}))},registerErrorText:function(e,t){if(e){var s={download_report:this.downloadDamageReport,partial_detail:this.checkDetailLink,error_log:this.openErrFilteredLogWindow};Ext.iterate(s,(function(s,i){e.un("click",i,this),s===t&&e.on("click",i,this)}),this)}},setProgress:function(e){this.getStatusPanel().getComponent("statusCard").getComponent("active").getComponent("progress").update(e)},setSuspendedProgress:function(e){this.getStatusPanel().getComponent("statusCard").getComponent("suspended").getComponent("progress").update(e)},setIsOnline:function(e,t){this.isOnline=e,e?this.getDestPanel().setHeaderStatus(" - "+_T("usbbackup","usbbkp_online"),"#1CA600",t):this.getDestPanel().setHeaderStatus(" - "+_T("usbbackup","usbbkp_offline"),"#D94141",t)},setErrDetailedLogLink:function(e){var t=this.getStatusPanel().getComponent("statusCard").getComponent(e).getComponent("errorText").getEl();this.registerErrorText(t,"error_log")},getIsOnline:function(){return this.isOnline},setIsSupportStatistics:function(e){this.isSupportStatistics=e,e?this.statisticBtn.setTooltip(SYNO.SDS.Backup.String("statistics","storage_statistics_title")):this.statisticBtn.setTooltip(SYNO.SDS.Backup.String("error","status_server_version_old"))},isTaskNotRunning:function(){return!(!this.taskStatus||!this.taskState)&&("none"===this.taskStatus||"discard_failed"===this.taskStatus||"wait_discard"===this.taskStatus)},inVersionDeleteSession:function(){return"preparing_version_delete"===this.taskStatus||"version_deleting"===this.taskStatus},isEnableBrowse:function(){return(this.isTaskNotRunning()||"error_detect"===this.taskState||this.inVersionDeleteSession())&&!this.owner.isRestore()&&!1!==this.getIsOnline()&&("backupable"===this.taskState||"restore_only"===this.taskState||"error_detect"===this.taskState||"rbd_service_requires_reboot"===this.taskState)},isEnableEdit:function(){return!(!this.taskStatus||!this.taskState)&&("backupable"===this.taskState||"restore_only"===this.taskState||"unauth"===this.taskState||"error_detect"==this.taskState||"rbd_service_requires_reboot"==this.taskState)},getIsSupportStatistics:function(){return this.isSupportStatistics},loadDestData:function(e){this.destStore.loadData(this.getDestData(e))},loadSettingData:function(e){this.settingStore.loadData(this.getSettingData(e)),this.isImage&&this.getSettingPanel().setHeaderLock(e.data_enc)},getScheduleStr:function(e){return SYNO.SDS.Backup.Client.Common.Utils.getScheduleStr(e)},getLastBkpTextCls:function(e){return""},getDisplayTimeText:function(e){var t=SYNO.SDS.Backup.Client.Common.Utils.getDSMStyleDateTimeString(e);return t||e},setBkpTime:function(e,t,s){var i=this.getStatusPanel().getComponent("statusCard").layout.activeItem.itemId;"idle"===i?this.getStatusPanel().getComponent("statusCard").getComponent("idle").getComponent("timeText").update({lastBkpTime:e?'<span class="'+this.getLastBkpTextCls(s)+'">'+this.getDisplayTimeText(e)+"</span>":SYNO.SDS.Backup.String("app","localbkp_not_bkp"),nextBkpTime:t?this.getDisplayTimeText(t):_T("common","none")}):"suspended"===i&&this.getStatusPanel().getComponent("statusCard").getComponent("suspended").getComponent("timeText").update({nextBkpTime:t?this.getDisplayTimeText(t):_T("common","none")})},setBtnStatus:function(){if(this.taskStatus&&this.taskState){var e=this.owner.isRestore(),t=this.owner.isSnapShotRestore();this.enableBackup("backupable"===this.taskState&&"none"===this.taskStatus&&!e&&!1!==this.getIsOnline()&&"backingup"!==this.taskLastResult&&"resuming"!==this.taskLastResult,t),this.enableRelink("relinkable"===this.taskState&&"none"===this.taskStatus&&!e),this.enableImport("importable"===this.taskState&&"none"===this.taskStatus&&!e),this.enableExport("exportable"===this.taskState&&"none"===this.taskStatus&&!e&&!1!==this.getIsOnline()),this.enableReauth("none"===this.taskStatus&&!e),this.enableCancel(("waiting"===this.taskStatus||"relink_waiting"===this.taskStatus||"syncing"===this.taskStatus||"backup"===this.taskStatus&&"backupable"===this.taskState&&(!this.isImage||this.canCancel)||"relink"===this.taskStatus&&"relinkable"===this.taskState||"backup"===this.taskStatus&&"exportable"===this.taskState||"detect"===this.taskStatus&&"error_detect"===this.taskState)&&"resuming"!==this.taskLastResult);var s=this.isTaskNotRunning(),i=this.isEnableEdit();this.enableEdit(i);var a=(s||"error_detect"===this.taskState)&&!e&&!this.isDemoMode;this.enableDelete(a);var n="none"===this.taskStatus&&"backupable"===this.taskState&&this.isImage&&!1!==this.getIsOnline();this.enableCheck(n),this.actionBtn.setDisabled(!i&&!a&&!n);var r="discard"===this.taskLastResult||"discard_failed"===this.taskStatus;"importable"===this.taskState?(this.displayRunningOrIdle(this.importBtn),this.suspendedMenuBtn.hide(),this.backupBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide()):"relinkable"===this.taskState?(this.displayRunningOrIdle(this.relinkBtn),this.suspendedMenuBtn.hide(),this.backupBtn.hide(),this.importBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide()):"exportable"===this.taskState?(this.backupBtn.hide(),this.importBtn.hide(),this.relinkBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide(),"suspend"===this.taskLastResult?(this.exportBtn.hide(),this.displayRunningOrIdle(this.suspendedMenuBtn)):r?(this.exportBtn.hide(),this.suspendedMenuBtn.show(),this.backingupMenuBtn.hide(),this.cancelBtn.hide()):(this.suspendedMenuBtn.hide(),this.displayRunningOrIdle(this.exportBtn))):"broken"===this.taskState?(this.displayRunningOrIdle(null),this.suspendedMenuBtn.hide(),this.backupBtn.hide(),this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide()):"unauth"===this.taskState?(this.displayRunningOrIdle(this.reauthBtn),this.suspendedMenuBtn.hide(),this.backupBtn.hide(),this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide()):"backupable"===this.taskState?(this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide(),"suspend"===this.taskLastResult?(this.backupBtn.hide(),this.displayRunningOrIdle(this.suspendedMenuBtn)):r?(this.backupBtn.hide(),this.suspendedMenuBtn.show(),this.backingupMenuBtn.hide(),this.cancelBtn.hide()):(this.suspendedMenuBtn.hide(),this.displayRunningOrIdle(this.backupBtn))):"error_detect"===this.taskState?(this.suspendedMenuBtn.hide(),this.backingupMenuBtn.hide(),this.backupBtn.hide(),this.cancelBtn.show(),this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide()):"restore_only"===this.taskState?(this.suspendedMenuBtn.hide(),this.backingupMenuBtn.hide(),this.backupBtn.hide(),this.cancelBtn.hide(),this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide()):"endofservice"===this.taskState?(this.suspendedMenuBtn.hide(),this.backingupMenuBtn.hide(),this.backupBtn.hide(),this.cancelBtn.hide(),this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.actionBtn.hide(),this.endofserviceBtn.show(),this.deleteBtn.show(),this.rebootNowBtn.hide()):"rbd_service_requires_reboot"===this.taskState?(this.suspendedMenuBtn.hide(),this.backingupMenuBtn.hide(),this.backupBtn.hide(),this.cancelBtn.hide(),this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.show()):(this.taskState,this.suspendedMenuBtn.hide(),this.backingupMenuBtn.hide(),this.backupBtn.show(),this.cancelBtn.hide(),this.importBtn.hide(),this.relinkBtn.hide(),this.exportBtn.hide(),this.reauthBtn.hide(),this.endofserviceBtn.hide(),this.deleteBtn.hide(),this.rebootNowBtn.hide())}},checkDetailLink:function(e,t,s){Ext.fly(e.target).hasClass("syno-backup-version-detail-link")&&this.launchDetailWindow()},downloadDamageReport:function(e,t,s){if(!Ext.fly(e.target).hasClass("syno-backup-version-detail-link"))return!1;var i={support_utf8_name:Ext.isChrome||Ext.isGecko||Ext.isSafari,task_id:this.taskId};this.findAppWindow().downloadWebAPI({filename:"error_report.txt",webapi:{api:"SYNO.Backup.Target",version:1,method:"damage_report_download",params:i},scope:this,callback:function(e,t,s,i){s||!i||this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(i.code),(function(){}),this)}})},checkDisplayStatus:function(){return"backupable"===this.taskState&&"none"===this.taskStatus&&"suspend"===this.taskLastResult?"suspended":"rbd_service_requires_reboot"===this.taskState?"rbd_service_requires_reboot":"does_not_support_entire_dsm_backup"===this.taskState?"does_not_support_entire_dsm_backup":"rbd_service_is_disabled"===this.taskState?"active":"none"===this.taskStatus&&"error_detect"!==this.taskState||"restore"===this.taskStatus||"discard_failed"===this.taskStatus||"wait_discard"===this.taskStatus||"version_delete_fail"===this.taskStatus||"wait_version_delete"===this.taskStatus?"idle":"active"},launchDetailWindow:function(){new SYNO.SDS.Backup.Client.Common.ErrorReportWindow({task_id:this.taskId,owner:this.owner}).open()},enableEdit:function(e){this.getSettingPanel().buttons[0].setDisabled(!e),this.actionBtn.menu.getComponent("btn_edit").setDisabled(!e)},enableDelete:function(e){this.actionBtn.menu.getComponent("btn_delete").setDisabled(!e)},enableCheck:function(e){this.actionBtn.menu.getComponent("btn_check").setDisabled(!e)},enableBackup:function(e,t){this.backupBtn.setDisabled(!e),t?this.backupBtn.setTooltip(SYNO.SDS.Backup.String("app","bkp_disabled_by_restore_snapshot")):this.backupBtn.setTooltip("")},enableRelink:function(e){this.relinkBtn.setDisabled(!e)},enableImport:function(e){this.importBtn.setDisabled(!e)},enableExport:function(e){this.exportBtn.setDisabled(!e)},enableReauth:function(e){this.reauthBtn.setDisabled(!e)},enableCancel:function(e){this.cancelBtn.setDisabled(!e),this.backingupMenu.menu.getComponent("btn_cancel").setDisabled(!e)},openWindow:function(e){this.appWin.openWindow(e)},openErrFilteredLogWindow:function(e,t,s){if(Ext.fly(e.target).hasClass("syno-backup-log-detail-link")){var i=this.owner.getCurrentTask(),a=new SYNO.SDS.Backup.Client.Common.Log.LogsWindow({appWin:this.owner,jsConfig:this.owner.jsConfig,owner:this.owner,filterParams:{filter_keyword:i.name,filter_level:"3"}});this.openWindow(a)}},onPageActivate:function(){this.setBtnStatus(),this.updatePageData()},onPageDeactivate:function(){this.stopUpdatePageData()},updatePageData:function(){this.loadStaticData(),this.onStartPolling()},stopUpdatePageData:function(){this.onStopPolling()},onCancelBackup:function(){this.appWin.getMsgBox().confirm(_T("tree","leaf_backup"),SYNO.SDS.Backup.String("app","backup_confirm_cancel_task"),(function(e){"yes"===e&&"none"!==this.taskStatus&&("error_detect"===this.taskState?this.doCancelErrorDetect():this.doCancelBackup())}),this)},onSuspendBackup:function(){this.appWin.getMsgBox().confirm(_T("tree","leaf_backup"),SYNO.SDS.Backup.String("app","backup_confirm_suspend_task"),(function(e){"yes"===e&&"none"!==this.taskStatus&&this.doSuspendBackup()}),this)},onCancelAndDiscard:function(){this.appWin.getMsgBox().confirm(_T("tree","leaf_backup"),SYNO.SDS.Backup.String("app","backup_confirm_discard"),(function(e){"yes"===e&&"backingup"!==this.taskStatus&&this.doCancelAndDiscard()}),this)},onDiscard:function(){this.appWin.getMsgBox().confirm(_T("tree","leaf_backup"),SYNO.SDS.Backup.String("app","backup_confirm_discard"),(function(e){"yes"===e&&("none"!==this.taskStatus&&"discard_failed"!==this.taskStatus||this.doDiscard())}),this)},displayRunningOrIdle:function(e){"idle"===this.displayStatus||"suspended"===this.displayStatus?(e&&e.show(),this.cancelBtn.hide(),this.backingupMenuBtn.hide()):(e&&e.hide(),!this.isImage||"backupable"!==this.taskState&&"exportable"!==this.taskState?(this.cancelBtn.show(),this.backingupMenuBtn.hide()):(this.cancelBtn.hide(),this.backingupMenuBtn.show()))},getDestData:function(){return[]},getSettingData:function(){return[]},setDetailLinkVisibility:function(){},settingClickHandler:function(e){},loadStaticData:function(){},onStartPolling:function(){},onStopPolling:function(){},onEditBackupTask:function(){},onDeleteBackupTask:function(){},onDetectTarget:function(){},doCancelBackup:function(){},doCancelAndDiscard:function(){},doCancelErrorDetect:function(){},doBackupSuspend:function(){},doDiscard:function(){},onBackupNow:function(){},onResumeNow:function(){},onImportNow:function(){},onRelinkNow:function(){},onReauthNow:function(){},onStatisticBrowse:function(){},onVersionBrowse:function(){},onVersionList:function(){}}),Ext.define("SYNO.SDS.Backup.EditSchedulePanel",{extend:"SYNO.SDS.TaskScheduler2.EditSchedulePanel",constructor:function(e){this.blSupportErrorDetect=!0;var t=Ext.apply({labelWidth:250},e);t.isImage||(t.cls="syno-backup-edit-schedule-panel-single",t.bwrapStyle="padding: 0px 8px"),this.callParent([t])},initComponent:function(){this.items[0].title="",this.items[1].title="",this.items[0].items.unshift({xtype:"syno_radio",id:this.disable_id=Ext.id(),boxLabel:_T("backup","schedule_disabled"),name:"date",inputValue:-1}),this.isImage&&(this.items[0].title=SYNO.SDS.Backup.String("app","backup_schedule_title"),this.items.push({xtype:"syno_fieldset",title:SYNO.SDS.Backup.String("app","detect_schedule_title"),cls:"syno-backup-edit-field-set",collapsible:!1,itemId:"incheck-panel",items:[this.incheckSchedule=new SYNO.SDS.Backup.IntegrityCheckSchedulePanel({owner:this,targetType:this.targetType,containerLabelWidth:this.labelWidth})]})),this.callParent(arguments)},initEvents:function(){this.callParent(arguments),this.mon(Ext.getCmp(this.disable_id),"check",this.onDisableChecked,this),delete Ext.getCmp(this.per_week_id).handler,this.mon(Ext.getCmp(this.per_week_id),"check",this.onWeekChecked,this),this.mon(Ext.getCmp(this.by_date_id),"check",this.onDateChecked,this),this.mon(this,"activate",this.addTips,this,{single:!0})},addTips:function(){var e=this.getForm().findField("incheck_schedule_enable");e&&e.getEl()&&SYNO.SDS.Utils.AddTip(e.getEl(),SYNO.SDS.Backup.String("app","incheck_schedule_tip"))},setData:function(e){this.callParent([e.backup]),e.backup.schedule_enable?Ext.getCmp(this.disable_id).setValue(!1):(Ext.getCmp(this.disable_id).setValue(!0),Ext.getCmp(this.by_date_id).setValue(!1),Ext.getCmp(this.per_week_id).setValue(!1),Ext.getCmp(this.week_name_id).setDisabled(!0),Ext.getCmp(this.date_id).setDisabled(!0),Ext.getCmp(this.repeat_id).setDisabled(!0),Ext.getCmp(this.hour_id).setDisabled(!0),Ext.getCmp(this.min_id).setDisabled(!0),Ext.getCmp(this.repeat_hour_id).setDisabled(!0),Ext.getCmp(this.last_work_hour_id).setDisabled(!0)),this.isImage&&this.blSupportErrorDetect&&this.incheckSchedule.setData(e.incheck,e.support_detect_time_limit)},getData:function(){var e={backup:this.callParent()};return this.isImage&&this.blSupportErrorDetect&&(e.incheck=this.incheckSchedule.getData()),e.backup.schedule_enable=!1===Ext.getCmp(this.disable_id).getValue(),e},onDisableChecked:function(e,t){t&&(Ext.getCmp(this.week_name_id).setDisabled(!0),Ext.getCmp(this.date_id).setDisabled(!0),Ext.getCmp(this.repeat_id).setDisabled(!0),Ext.getCmp(this.hour_id).setDisabled(!0),Ext.getCmp(this.min_id).setDisabled(!0),Ext.getCmp(this.repeat_hour_id).setDisabled(!0),Ext.getCmp(this.last_work_hour_id).setDisabled(!0))},onWeekChecked:function(e,t){t&&(Ext.getCmp(this.week_name_id).setDisabled(!1),Ext.getCmp(this.date_id).setDisabled(!0),Ext.getCmp(this.repeat_id).setDisabled(!0),Ext.getCmp(this.hour_id).setDisabled(!1),Ext.getCmp(this.min_id).setDisabled(!1),Ext.getCmp(this.repeat_hour_id).setDisabled(!1),Ext.getCmp(this.last_work_hour_id).setDisabled(!1))},onDateChecked:function(e,t){t&&(Ext.getCmp(this.week_name_id).setDisabled(!0),Ext.getCmp(this.date_id).setDisabled(!1),Ext.getCmp(this.repeat_id).setDisabled(!1),Ext.getCmp(this.hour_id).setDisabled(!1),Ext.getCmp(this.min_id).setDisabled(!1),Ext.getCmp(this.repeat_hour_id).setDisabled(!1),Ext.getCmp(this.last_work_hour_id).setDisabled(!1))},setSupportErrorDetect:function(e){this.blSupportErrorDetect=e,e?this.items.get(2).show():(this.items.get(2).hide(),this.remove("incheck-panel"))}}),Ext.define("SYNO.SDS.Backup.C2CloudEditSchedulePanel",{extend:"SYNO.ux.FormPanel",constructor:function(e){this.blSupportErrorDetect=!0,this.simpleSchedule=new SYNO.SDS.Backup.SimpleScheduleComponent({canUnckeckSchedule:!0,owner:this});var t=[];t.push({xtype:"syno_fieldset",title:SYNO.SDS.Backup.String("app","backup_schedule_title"),collapsible:!1,cls:"syno-backup-edit-field-set",items:[this.simpleSchedule]}),t.push({xtype:"syno_fieldset",title:SYNO.SDS.Backup.String("app","detect_schedule_title"),cls:"syno-backup-edit-field-set",collapsible:!1,itemId:"incheck-panel",items:[this.incheckSchedule=new SYNO.SDS.Backup.IntegrityCheckSchedulePanel({owner:this,targetType:e.targetType})]});var s=Ext.apply({bwrapStyle:"padding: 8px 8px 0 8px;",labelWidth:250,items:t},e);this.callParent([s])},setData:function(e){this.bkpSchedule=Ext.apply({},e.backup),this.simpleSchedule.setData(this.bkpSchedule),this.blSupportErrorDetect&&this.incheckSchedule.setData(e.incheck,e.support_detect_time_limit)},getData:function(){var e=this.simpleSchedule.getData(),t={schedule_enable:e.schedule_enable,hour:e.hour,minute:e.min,last_work_hour:e.last_work_hour,week_day:e.week_name},s={backup:t=Ext.apply(this.bkpSchedule,t)};return this.blSupportErrorDetect&&(s.incheck=this.incheckSchedule.getData()),s},setSupportErrorDetect:function(e){this.blSupportErrorDetect=e,e?this.getComponent("incheck-panel").show():this.remove("incheck-panel")}}),Ext.define("SYNO.SDS.Backup.BackupTypePanel",{extend:"SYNO.SDS.Backup.FormPanel",constructor:function(e){var t=!SYNO.Backup.FeatureSupport.Utils.SupportEntireDSMBackup();const s=!SYNO.Backup.FeatureSupport.Utils.SupportLegacyLunBackup(),i=!SYNO.Backup.FeatureSupport.Utils.SupportMultiVerLunBackup();var a=Ext.apply({height:410,items:[{xtype:"syno_radio",name:"backup_type",itemId:"backup_type_data",inputValue:"backup_type_data",checked:!0,boxLabel:SYNO.SDS.Backup.String("app","backup_type_data")},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","backup_type_data_desc"),indent:1,cls:"syno-backup-type-option-margin"},{xtype:"syno_radio",name:"backup_type",itemId:"backup_type_dsm",hidden:t,inputValue:"backup_type_dsm",boxLabel:SYNO.SDS.Backup.String("app","backup_type_entire_dsm")},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","backup_type_entire_dsm_desc"),hidden:t,indent:1},{xtype:"syno_radio",name:"backup_type",itemId:"backup_type_multi_ver_lun",inputValue:"backup_type_multi_ver_lun",boxLabel:SYNO.SDS.Backup.String("app","backup_type_multiver_lun"),hidden:i,disabled:!_S("is_admin"),listeners:{afterrender:function(e){_S("is_admin")||SYNO.ux.AddTip(e.getEl(),SYNO.SDS.Backup.String("app","only_admin_able_lun"))},scope:this}},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","backup_type_multiver_lun_desc"),hidden:i,indent:1},{xtype:"syno_radio",name:"backup_type",itemId:"backup_type_lun",inputValue:"backup_type_lun",boxLabel:SYNO.SDS.Backup.String("app","backup_type_lun"),hidden:s,disabled:!_S("is_admin"),listeners:{afterrender:function(e){_S("is_admin")||SYNO.ux.AddTip(e.getEl(),SYNO.SDS.Backup.String("app","only_admin_able_lun"))},scope:this}},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","backup_type_lun_desc"),hidden:s,indent:1,cls:"syno-backup-type-option-margin"}]},e);return this.activated=!1,this.callParent([a])},getNext:function(){if(!this.getForm().isValid())return!1;switch(this.getForm().getValues().backup_type){case"backup_type_data":return this.owner.backupType="data","repo_type";case"backup_type_lun":return this.owner.backupType="lun","desttype";case"backup_type_dsm":return this.owner.backupType="entire_dsm","dsm_repo_type";case"backup_type_multi_ver_lun":return this.owner.backupType="multi_ver_lun","multi_ver_lun_repo_type"}return!1},summary:function(e){switch(this.getForm().getValues().backup_type){case"backup_type_data":e.append(SYNO.SDS.Backup.String("app","backup_type"),SYNO.SDS.Backup.String("app","backup_type_data"));break;case"backup_type_lun":e.append(SYNO.SDS.Backup.String("app","backup_type"),SYNO.SDS.Backup.String("app","backup_type_lun"));break;case"backup_type_dsm":e.append(SYNO.SDS.Backup.String("app","backup_type"),SYNO.SDS.Backup.String("app","backup_type_entire_dsm"))}}}),Ext.define("SYNO.SDS.Backup.RepoTypePanel",{extend:"SYNO.SDS.Backup.FormPanel",cls:"syno-backup-repo-type-panel",constructor:function(e){this.addonInfo=null,this.callParent([e])},isRepoDisplay:function(e){return!e.hidden},getFieldHeightStyle:function(e){return"height:"+41*Math.ceil(e/2)+"px;"},selectDest:function(e,t){var s=Ext.getCmp(t.id),i=null;if(!s&&t&&(s=Ext.getCmp(t.parentNode.id)),Ext.each(this.getComponent("repo_button_ct").items.items,(function(e,t){e.get(0)&&Ext.each(e.get(0).items.items,(function(e){e.removeClass("selected")}),this)}),this),t.classList.contains("syno-backup-destination-button"))i=s;else{if(!s||!s.ownerCt)return;i=s.ownerCt}i.addClass("selected"),this.addonInfo=i.addonInfo},unSelectAll:function(){this.addonInfo=null},launchOAuthWindow:function(e){var t=SYNO.Backup.Addon.Util.getOathWindowParams(e);return!!Ext.isObject(t)&&(this.winAuth||(Ext.isIE||Ext.isIE11||Ext.isIE10?window.cbDSCS=this.authCB.createDelegate(this):(this.cbDSCS=this.receiveMessage.createDelegate(this),window.addEventListener("message",this.cbDSCS))),this.winAuth=window.open(encodeURI(t.url),"",t.specs),!0)},authCB:function(e){if(this.winAuth=null,Ext.isEmpty(e.error)){var t=this.getRepoType();this.owner.getStep(this.nextId[t.id]).setOauthResponse(e),"entire_dsm"!==this.owner.backupType||"synocloud"!==t.id||SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.ROTATION_CUSTOM===this.owner.accountMeta.versionRotation?this.owner.goNext(this.nextId[t.id]):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.String("app","entire_dsm_need_plan_two_desc"))}},receiveMessage:function(e){"hyperbackup_oauth"===e.data.source&&(window.removeEventListener("message",this.cbDSCS),this.authCB(e.data))},getRepoType:function(){return this.addonInfo},getNext:function(){var e=this.getRepoType();return!!Ext.isObject(e)&&(!this.launchOAuthWindow(e)&&this.nextId[e.id])},getParams:function(){var e={},t=this.getRepoType();return Ext.isObject(t)&&(e.target_type=t.target_type),e},isValid:function(){return null!==this.getRepoType()}}),Ext.define("SYNO.SDS.Backup.SelectSingleOrMultiple",{extend:"Ext.Container",constructor:function(e){this.vuePanel=new SYNO.SDS.VuePanel({vueClass:Vue.component("SYNO.SDS.Backup.Vue.SelectSingleOrMultiple",SYNO.SDS.Backup.Vue.SelectSingleOrMultiple),layout:"fit"},{propsData:e.propsData||{}});var t={items:[this.vuePanel]};this.callParent([Ext.apply(t,e)]),this.addManagedComponent(this.vuePanel)}}),Ext.define("SYNO.SDS.Backup.SelectSingleOrMultiplePanel",{extend:"SYNO.SDS.Backup.FormPanel",selected:null,constructor:function(e){var t=this,s=Ext.apply({items:[new SYNO.SDS.Backup.SelectSingleOrMultiple({propsData:{onSelect:function(e){t.selected=e}}})]},e);this.callParent([s])},getNext:function(){return null!==this.selected&&this.nextIdFn(this.selected)}}),Ext.define("SYNO.SDS.Backup.SelectBackupDestination",{extend:"Ext.Container",constructor:function(e){this.vuePanel=new SYNO.SDS.VuePanel({vueClass:Vue.component("SYNO.SDS.Backup.Vue.SelectBackupDestination",SYNO.SDS.Backup.Vue.SelectBackupDestination),layout:"fit"},{propsData:e.propsData||{}});var t={items:[this.vuePanel]};this.callParent([Ext.apply(t,e)]),this.addManagedComponent(this.vuePanel)}}),Ext.define("SYNO.SDS.Backup.DataRepoTypePanel",{extend:"SYNO.SDS.Backup.RepoTypePanel",constructor:function(e){var t=this,s=Ext.apply({items:[new SYNO.SDS.Backup.SelectBackupDestination({propsData:{destinations:["c2","remote","local"],showOtherDestinations:!0,showBetaForC2:!1,onSelect:function(e){t.addonInfo=t.mapToOriginFormat(e)}}})]},e);this.callParent([s])},mapToOriginFormat:function(e){const t=function(){switch(e){case"c2":return"synocloud";case"remote":return"remote";case"local":return"local";case"dropbox":return"dropbox";case"google_drive":return"google_drive";case"hidrive":return"hidrive";case"jd_cloud":return"jdcloud_s3";case"azure":return"azure_blob";case"rackspace":return"rackspace";case"s3_storage":return"aws_s3";case"hicloud_s3":return"hicloud_s3";case"rsync":return"rsync";case"webdav":return"webdav";case"openstack_swift":return"openstack";default:return SYNO.Debug("Unmapped selected type: "+e),e}}();return"rsync"===t||"local"===t?{id:t}:(s=t,SYNO.Backup.Addon.Config.addon_list.find((function(e){return e.id===s})));var s}}),Ext.define("SYNO.SDS.Backup.EntireDSMRepoTypePanel",{extend:"SYNO.SDS.Backup.RepoTypePanel",constructor:function(e){var t=this,s=Ext.apply({items:[new SYNO.SDS.Backup.SelectBackupDestination({propsData:{destinations:["c2","remote"],showOtherDestinations:!1,showBetaForC2:!0,onSelect:function(e){t.addonInfo=t.mapToOriginFormat(e)}}})]},e);this.callParent([s])},mapToOriginFormat:function(e){const t=function(){switch(e){case"c2":return"synocloud";case"remote":return"remote";default:return SYNO.Debug("Unmapped selected type: "+e),e}}();return s=t,SYNO.Backup.Addon.Config.addon_list.find((function(e){return e.id===s}));var s}}),Ext.define("SYNO.SDS.Backup.LUNMultiVerRepoTypePanel",{extend:"SYNO.SDS.Backup.EntireDSMRepoTypePanel"}),Ext.define("SYNO.SDS.Backup.BaseTaskSourceSelector",{extend:"SYNO.SDS.Backup.BasicTreePanel",preloaded:!1,preload_blocked:!1,dest:void 0,folderLoadCount:0,_mysql_pwd:void 0,pre_load_folder_done:!1,folderDisplayLimit:1e4,apiFolder:null,constructor:function(e){this.fm_root_nodes=[],this._folder_list=[],this._volList=[],this._excludeFolderList=[],this.pre_load_folder_done=e.pre_load_folder_done;var t=Ext.apply({bwrapStyle:"padding-top: 0px",bodyStyle:"padding: 8px 8px 0px 8px",rootVisible:!1,loader:new SYNO.SDS.Backup.TreeLoader,root:new Ext.tree.AsyncTreeNode({draggable:!1,id:"root",title:_T("backup","select_share_app_title")}),listeners:{beforedestroy:function(){this.apiFolder&&(Ext.Ajax.abort(this.apiFolder),this.apiFolder=null)},scope:this}},e);return this.callParent([t])},activate:function(){this.preloaded||(this.owner.setStatusBusy(),this.preload_blocked=!0)},initEvents:function(){var e=this.callParent(arguments);return this.owner instanceof SYNO.SDS.Backup.TaskEditDialog&&this.owner.onSourceFolderLoad(),this.apiFolder=this.sendWebAPI({api:"SYNO.Backup.Source.Folder",version:1,method:"list",params:{node:"fm_root"},callback:function(e,t,s){this.owner instanceof SYNO.SDS.Backup.TaskEditDialog?this.owner.onClearStatusBusy("folder"):this.preload_blocked&&this.owner.clearStatusBusy(),e?(this.allFolders=t.folder,this.allVolumes=t.volume,this.pre_load_folder_done?this.createVolumeNodes():this.pre_load_folder_done=!0,this.preloaded=!0,Ext.isEmpty(this.allFolders)&&new Ext.LoadMask(this.pageContainer.getEl(),{msgCls:"syno-ux-mask-info syno-backup-task-create-empty-style",msg:SYNO.SDS.Backup.String("app","no_shared_folder_available")}).show()):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code),(function(){4531===t.code&&this.owner.close()}),this)},scope:this}),this.mon(this,"beforeexpandnode",this.onBeforeExpandNode),e},onBeforeExpandNode:function(e){if(e.attributes.exceedLimit)return this.owner.getMsgBox().alert(_T("tree","leaf_backup"),String.format(SYNO.SDS.Backup.String("app","node_exceed_display_limit"),e.text,this.folderDisplayLimit)),!1},getUiProvider:function(){},getInitialVolumeCheckStatus:function(){},setNodeCheckAttr:function(){},getPathProcessParams:function(){},disableNode:function(e){},enableNode:function(e,t){},dealEmptyVolumeNode:function(e){},createVolumeNodes:function(){var e={};this.fm_root_map={},this.petaVolId="",Ext.each(this.allFolders,(function(t){var s="";s=t.isClusterShare?"petaspace":t.volume,e[s]||(e[s]=[]),e[s].push(t)}),this),this.dealEmptyVolumeNode(e);var t,s=function(e,t,s){-1!==this.fm_root_nodes.indexOf(t.id)&&(this.folderLoadCount++,this.folderLoadCount===this.volumeCount&&this.owner.doIfAppShareReady("folder_loaded"))};t=this._folder_list?this._folder_list.slice(0):[];var i=Object.keys(e);i.sort(),this.volumeCount=i.length,0>=this.volumeCount&&(this.owner.doIfAppShareReady("folder_loaded"),this.owner.doIfAppShareReady("folder_initialed"),new Ext.LoadMask(this.pageContainer.getEl(),{msgCls:"syno-ux-mask-info syno-backup-task-create-empty-style",msg:SYNO.SDS.Backup.String("app","no_shared_folder_available")}).show()),Ext.each(i,(function(t){if(e.hasOwnProperty(t)){var i=this.createTreeLoader("SYNO.Backup.Source.Folder",this.onCreateFolderNode,e[t]);i.on("load",s,this);var a="fm_root"+this.fm_root_nodes.length;"petaspace"===t&&(this.petaVolId=a),this.fm_root_nodes.push(a),this.fm_root_map[a]=t,this.root&&this.root.appendChild({id:a,expanded:!0,leaf:!1,text:this.getVolName(t,e),loader:i,uiProvider:this.getUiProvider(),checked:this.getInitialVolumeCheckStatus(t),volume:t,encryptedVolume:this.getVolAttr(t,"encryptedVolume"),lockedVolume:this.getVolAttr(t,"lockedVolume")})}}),this),this.checkMissingVolume(i,this._volList),this.setVolumeCheckState(t,this._volList,this._excludeFolderList),this.setConflictVolume()},checkMissingVolume:function(e,t){},setVolumeCheckState:function(e,t,s){},setConflictVolume:function(){var e=null;Ext.isFunction(this.owner.getLocalRepoVolume)&&(e=this.owner.getLocalRepoVolume()),Ext.each(this.fm_root_nodes,(function(t){var s=this.getNodeById(t);return!s||("petaspace"===s.attributes.volume||void(e&&s.attributes.volume===e?s.getUI().getEl().classList.add("syno-backup-tri-conflict-volume"):s.getUI().getEl().classList.remove("syno-backup-tri-conflict-volume")))}),this)},getVolName:function(e,t){if(-1!==e.indexOf("usb"))return t[e][0].display_vol_name;var s=this.getVolDesc(e,this.allVolumes);return SYNO.Backup.Util.parseVolName(e,s)},getVolDesc:function(e,t){var s="";return"petaspace"===e||Ext.each(t,(function(t){if(e===t.volume)return s=t.description,!1})),s},getVolAttr:function(e,t){var s;return!!(s=this.allVolumes.find((function(t){return t.volume===e})))&&s[t]},createTreeLoader:function(e,t,s,i,a,n,r){return new SYNO.SDS.Backup.TreeLoader({sendWebAPI:this.sendWebAPI.createDelegate(this),webapi:{api:e,method:n||"list",version:r||1},createNodeFn:t,createNodeScope:this,owner:this,nodeData:s,baseParams:{folder_limit:this.folderDisplayLimit+1},nodeUI:this.getUiProvider().displayName,parseWebApiResponse:function(e,t){return Ext.isArray(t)?t:this.folderDisplayLimit>=t.folder.length?t.folder:(e.attributes.expandable=!0,e.attributes.exceedLimit=!0,[])}.createDelegate(this)})},convertLanguage:function(e,t){var s=SYNO.SDS.Backup.converLanString(e[t]);s&&(t+"_param"in e&&(s=String.format(s,e[t+"_param"])),e[t]=s)},onCreateFolderNode:function(e){e.uiProvider=this.getUiProvider().displayName,this.convertLanguage(e,"text"),this.convertLanguage(e,"qtip"),"remote"==e.fileSystemType?(e.disabled=!0,e.qtip=_T("backup","source_not_remote_folder"),e.disable_reason=_T("backup","source_not_remote_folder")):"image"==e.fileSystemType&&(e.disabled=!0,e.qtip=_T("backup","source_not_virtual_drive"),e.disable_reason=_T("backup","source_not_virtual_drive")),!0===e.encryptedShare?!0===e.dataEncrypted&&(e.leaf=!0):!0===e.isC2Share?this.isImage||(e.disabled=!0,e.qtip=SYNO.SDS.Backup.String("app","source_not_c2share"),e.disable_reason=SYNO.SDS.Backup.String("app","source_not_c2share")):1==e.isTieringShare&&(this.isImage||(e.disabled=!0,e.qtip=SYNO.SDS.Backup.String("app","source_not_tiering_share"),e.disable_reason=SYNO.SDS.Backup.String("app","source_not_tiering_share"))),!0===e.disabled&&(e.leaf=!0),SYNO.SDS.Backup.Client.Common.Utils.isABBDataFolder(e.folderPath)?e.leaf=!0:e.disabled&&SYNO.SDS.Backup.Client.Common.Utils.isABBFuseFolder(e.folderPath)&&(e.qtip=SYNO.SDS.Backup.String("app_backup","ABB_no_backup_fuse"),e.disable_reason=SYNO.SDS.Backup.String("app_backup","ABB_no_backup_fuse")),this.setNodeCheckAttr(e),!1===e.checked&&!0===e.recycle&&(e.hidden=!0,e.disabled=!0)},setVolumeList:function(e){this._volList=e},setExcludeFolderList:function(e){this._excludeFolderList=e},setFolderList:function(e){this._folder_list=[];var t=[],s=[],i=[],a=[],n=[],r=!1,o="";Ext.each(e,(function(e){if(e.isValidSource)this._folder_list.push(e.folderPath);else{var r=SYNO.SDS.Backup.Util.lengthEllipsis(e.folderPath.substring(1),20);"remote"===e.fileSystemType?t.push(r):"image"===e.fileSystemType?s.push(r):e.missing?n.push(r):SYNO.SDS.Backup.Client.Common.Utils.isABBFuseFolder(e.folderPath)?a.push(r):i.push(r)}}),this),0<t.length&&(o+=_T("backup","remote_folder")+": "+t.join(", ")+"<br/>",r=!0),0<s.length&&(o+=_T("backup","virtual_drive")+": "+s.join(", ")+"<br/>",r=!0),0<n.length&&(o+=_T("backup","missing_folder")+": "+n.join(", ")+"<br/>",r=!0),0<a.length&&(o+=SYNO.SDS.Backup.String("app_backup","ABB_no_backup_fuse")+": "+a.join(", ")+"<br/>",r=!0),0<i.length&&(o+=_T("backup","not_support_filesystem")+": "+i.join(", ")+"<br/>",r=!0),r&&(this.owner.invalidList+=o),this.pre_load_folder_done?(this.createVolumeNodes(),this.checkAllAzureDotEnd(this.owner.transferType)):this.pre_load_folder_done=!0},getSelectedEncVolumeList:function(e){var t=[];return Ext.each(this.fm_root_nodes,(function(s){var i=this.getNodeById(s);!0!==i.attributes.encryptedVolume||void 0!==e&&e!==i.attributes.lockedVolume||!1===i.getUI().getCheckValue()||t.push(i.text)}),this),t},listSelectedShares:function(){var e=[];return Ext.each(this.fm_root_nodes,(function(t){var s,i=this.getNodeById(t),a=i.childNodes.length;for(s=0;s<a;s++){var n=i.childNodes[s];!1!==n.getUI().getCheckValue()&&e.push(n.attributes)}}),this),e},getSelectedC2Shares:function(){return this.listSelectedShares().reduce((function(e,t){return t.isC2Share&&e.push(t.text),e}),[])},getTieringShareList:function(){return this.listSelectedShares().reduce((function(e,t){return t.isTieringShare&&e.push(t.text),e}),[])},getTieringVaultList:function(){return this.listSelectedShares().reduce((function(e,t){return t.isTieringVault&&e.push(t.text),e}),[])},getSelectedEncList:function(e){return this.listSelectedShares().reduce((function(t,s){return!0!==s.encryptedShare||void 0!==e&&e!==s.dataEncrypted||t.push(s.text),t}),[])},updateAllEncShare:function(e,t){var s=!1;return Ext.each(this.fm_root_nodes,(function(i){this.getNodeById(i).eachChild((function(i){this.updateEncShare(e,t,i)&&(s=!0)}),this)}),this),s},updateEncShare:function(e,t,s){var i=!1;return!0===s.attributes.encryptedShare&&("cloud"===e&&"hicloud_s3"===t?(!1!==s.getUI().getCheckValue()&&(i=!0),this.disableNode(s),s.setTooltip(_T("backup","multi_version_not_support_encrypted_share"))):(this.enableNode(s,!s.attributes.dataEncrypted),s.setTooltip(s.text)),i)},checkAllAzureDotEnd:function(e){var t=[];Ext.each(this.fm_root_nodes,(function(s){this.getNodeById(s).eachChild((function(s){this.checkAzureDotEnd(e,s)&&t.push(s.text)}),this)}),this),0<t.length&&(this.owner.invalidList+=SYNO.SDS.Backup.String("app","azure_share_end_with_dot_msg")+": "+t.join(", ")+"<br/>")},checkAzureDotEnd:function(e,t){return!!t.text.endsWith(".")&&("azure_blob"===e||"azure_cn_blob"===e?(this.disableNode(t),t.setTooltip(SYNO.SDS.Backup.String("error","azure_share_end_with_dot")),!0):(this.enableNode(t,!0),t.setTooltip(t.text),!1))},hasCheckedNode:function(e){if(e.getUI().isChecked())return!0;var t,s=e.childNodes.length;for(t=0;t<s;t++)if(!0===this.hasCheckedNode(e.childNodes[t]))return!0;return!1},setExpandable:function(e,t){e.collapse(!1,!1),e.leaf=!t,e.getUI().updateExpandIcon()},setDestination:function(e){var t=this.getNodeById(e);if(void 0!==this.dest&&this.clearDestination(),void 0!==t){if(this.disableNode(t),t.attributes.disabled=!0,t.attributes.disable_reason=_T("backup","source_share_conflict_destination"),t.setTooltip(_T("backup","source_share_conflict_destination")),t.getUI().getEl())t.getUI().getEl().classList.add("syno-backup-show-disable-folder"),t.getUI().getEl().getElementsByClassName("syno-backup-tree-node-disable-folder")[0].setAttribute("ext:qtip",_T("backup","source_share_conflict_destination"));this.dest=e}},getDestination:function(){return this.dest},clearDestination:function(){var e=this.getNodeById(this.dest);e&&(this.enableNode(e,!0),e.setTooltip(e.text),e.attributes.disabled=!1,e.attributes.disable_reason="",e.getUI().getEl()&&e.getUI().getEl().classList.remove("syno-backup-show-disable-folder"),this.dest=void 0)},onBeforeLoad:function(e,t,s){if(!0===t.disabled)return!1},getNext:function(){this.callParent(arguments)}}),Ext.define("SYNO.SDS.Backup.TaskSourceTriSelector",{extend:"SYNO.SDS.Backup.BaseTaskSourceSelector",constructor:function(e){this.callParent([e])},getUiProvider:function(){return SYNO.SDS.Backup.TriTreeNodeUI},getInitialVolumeCheckStatus:function(){return"none"},setVolumeCheckState:function(e){Ext.each(this.fm_root_nodes,(function(t){var s=this.getNodeById(t);s&&(s.attributes.checked=this.getCheckState(t,e),s.getUI().syncCheckCssClass())}),this)},setNodeCheckAttr:function(e){(Ext.isBoolean(e.checked)||"gray"===e.checked)&&(e.checked=this.getCheckState(e.id,this._folder_list))},getPathProcessParams:function(){var e=[];return Ext.each(this.fm_root_nodes,(function(t){Ext.each(this.getCheckedSubTreeRoot(this.getNodeById(t)),(function(t){e.push(t.id)}))}),this),Ext.each(this._folder_list,(function(t){e.push(t)})),{folder_list:e}},disableNode:function(e){e.getUI().setCheckValue(!1),this.setExpandable(e,!1),e.disable()},enableNode:function(e,t){e.enable(),this.setExpandable(e,t)},onCheckChange:function(e,t){var s,i,a=this.callParent(arguments),n=e.attributes.id;if(!n)return a;if(this._folder_list)for(s=[],Ext.each(this._folder_list,(function(e,t){if(e===n)return s.push(t),!1;0===e.indexOf(n+"/")&&s.push(t)}),this),i=s.length-1;i>=0;i--)this._folder_list.splice(s[i],1);return e.bubble((function(e){if(0===e.id.indexOf("fm_root"))return this.updateVolumeConflictTip(e),!1}),this),a},updateVolumeConflictTip:function(e){e.getUI().getEl().classList.remove("syno-volume-show-conflict"),e.eachChild((function(t){return!0===t.disabled||!1===t.attributes.checked||(e.getUI().getEl().classList.add("syno-volume-show-conflict"),!1)}))},getCheckState:function(e,t){var s=!1;return!!t&&(-1!==this.fm_root_nodes.indexOf(e)?(Ext.each(t,(function(t){var i=t.indexOf("/",1);-1!==i&&(t=t.substring(0,i));var a=this.getNodeById(t);if(null!==a&&a.parentNode.id===e)return s="gray",!1}),this),this.getNodeById(e).eachChild((function(t){Ext.each(this._folder_list,(function(s){if(t.id===s||0===s.indexOf(t.id+"/"))return this.getNodeById(e).getUI().getEl().classList.add("syno-volume-show-conflict"),!1}),this)}),this),s):(Ext.each(t,(function(i,a){return e===i?(t.splice(a,1),s=!0,!1):0===i.indexOf(e+"/")?(s="gray",!1):void 0})),s))}}),Ext.define("SYNO.SDS.Backup.TaskSourceQuadSelector",{extend:"SYNO.SDS.Backup.BaseTaskSourceSelector",constructor:function(e){this.callParent([e])},getUiProvider:function(){return SYNO.SDS.Backup.QuadTreeNodeUI},getInitialVolumeCheckStatus:function(e){return-1!==this._volList.indexOf(e)||"gray"},checkMissingVolume:function(e,t){var s=[];Ext.each(t,(function(t){-1===e.indexOf(t)&&s.push(SYNO.Backup.Util.parseVolName(t,""))})),0<s.length&&(this.owner.invalidList+=SYNO.SDS.Backup.String("app","missing_volume")+": "+s.join(", ")+"<br/>")},setVolumeCheckState:function(e,t,s){Ext.each(this.fm_root_nodes,(function(i){var a=this.getNodeById(i);a&&(a.attributes.checked=this.getCheckState(a.attributes,e,t,s),!0===a.attributes.checked?a.state=new SYNO.SDS.Backup.QuadTreeNodeFullState({node:a}):"gray"===a.attributes.checked?a.state=new SYNO.SDS.Backup.QuadTreeNodePartialState({node:a}):!1===a.attributes.checked&&(a.state=new SYNO.SDS.Backup.QuadTreeNodeEmptyState({node:a})),a.getUI().syncCheckCssClass())}),this)},setNodeCheckAttr:function(e){(Ext.isBoolean(e.checked)||"gray"===e.checked)&&(e.checked=this.getCheckState(e,this._folder_list,this._volList,this._excludeFolderList),!0===e.checked?e.state="SYNO.SDS.Backup.QuadTreeNodeFullState":"gray"===e.checked?e.state="SYNO.SDS.Backup.QuadTreeNodePartialState":!1===e.checked&&(e.state="SYNO.SDS.Backup.QuadTreeNodeEmptyState"))},dealEmptyVolumeNode:function(e){Ext.each(this.allVolumes,(function(t){e.hasOwnProperty(t.volume)||(e[t.volume]=[])}),this)},onExpandNode:function(e){},getPathProcessParams:function(){var e=this.root,t=[],s=[],i=[];return e.cascade((function(e){if("root"!==e.id){var a=e.getUI();if(Ext.isFunction(a.getCheckValue))if(0===e.id.indexOf("fm_root"))!0===a.getCheckValue()&&t.push(e.attributes.volume);else if(!0===a.getCheckValue()){if(!0===e.parentNode.getUI().getCheckValue())return;s.push(e.id)}else!0===e.parentNode.getUI().getCheckValue()&&i.push(e.id+"/")}}),this),{backup_volumes:t,folder_list:SYNO.ux.Utils.uniqueApiArray(s.concat(this._folder_list)),folder_exclude_list:SYNO.ux.Utils.uniqueApiArray(i.concat(this._excludeFolderList))}},checkFolderUnderVolume:function(e,t){var s="/"+t.split("/")[1],i=!1;return Ext.each(e.childNodes,(function(e){if(e.id===s)return i=!0,!1})),i},disableNode:function(e){e.state||this.preInitNodeStateFromAttr(e),e.state.setDisable(),this.setExpandable(e,!1)},enableNode:function(e,t){e.state||this.preInitNodeStateFromAttr(e),e.state.setEnable(),this.setExpandable(e,t)},preInitNodeStateFromAttr:function(e){if(e.attributes&&e.attributes.state){var t=Ext.getClassByName(e.attributes.state);e.state=new t({node:e})}},getParentNodeFromId:function(e){if(!0===e.isClusterShare)return this.getNodeById(this.petaVolId);var t;if(-1===e.id.indexOf("/",1))return Ext.each(this.fm_root_nodes,(function(s){if(this.fm_root_map[s]===e.volume)return t=this.getNodeById(s),!1}),this),t;var s=e.id.lastIndexOf("/");return this.getNodeById(e.id.substring(0,s))},getCheckState:function(e,t,s,i){var a=!1,n=!1;if("remote"==e.fileSystemType||"image"==e.fileSystemType)a=!1;else if(e.disabled&&SYNO.SDS.Backup.Client.Common.Utils.isABBFuseFolder(e.folderPath))a=!1;else if(-1!==this.fm_root_nodes.indexOf(e.id)){var r=this.getNodeById(e.id);-1!==s.indexOf(r.attributes.volume)?a=!0:Ext.each(t,(function(e){if(this.checkFolderUnderVolume(r,e))return a="gray",!1}),this)}else!0===this.getParentNodeFromId(e).dirty?a=this.getParentNodeFromId(e).getUI().getCheckValue():-1!==i.indexOf(String(e.id+"/"))?(Ext.each(t,(function(t){if(0===t.indexOf(e.id+"/"))return a="gray",n=!0,!1})),n||(a=!1)):!0===this.getParentNodeFromId(e).getUI().getCheckValue()?a=!0:!1===this.getParentNodeFromId(e).getUI().getCheckValue()?a=!1:(Ext.each(t,(function(t){if(e.id===t)return a=!0,n=!0,!1})),n||Ext.each(t,(function(t){if(0===t.indexOf(e.id+"/"))return a="gray",n=!0,!1})));return a}}),Ext.define("SYNO.SDS.Backup.TaskSourceContainerWrapper",{extend:"SYNO.ux.Panel",constructor:function(e){var t={layout:"fit",height:425,items:[new SYNO.SDS.Backup.TaskSourceContainer({owner:e.owner,appWin:e.appWin,itemId:"source_container_wrapper",isImage:e.isImage,pre_load_folder_done:e.pre_load_folder_done,bodyStyle:"padding-right: 0px;"})]};Ext.apply(t,e),this.callParent([t])},initComponent:function(){this.callParent(arguments);var e=this.appWin.appInstance.getUserSettings("show_parent_file_only_tip");this.isImage&&(void 0===e||e)&&this.add(new SYNO.SDS.Backup.NewFeaturePanel({appInstance:this.appWin.appInstance,subTopic:"data_backup_source.html"}))},getParams:function(){return this.getComponent("source_container_wrapper").getParams()},getNext:function(){return this.owner.setStatusBusy(),this.getComponent("source_container_wrapper").checkApply().then(function(){this.goToNextStep()}.bind(this)).catch(function(e){e&&SYNO.Debug(e),this.owner.clearStatusBusy()}.bind(this)),!1},goToNextStep:function(){this.owner.getStep("app").isLoaded()?(this.owner.clearStatusBusy(),this.owner.getStep("app").needHide()?this.owner.goNext(this.owner.getStep("app").getNext()):this.owner.goNext(this.nextId)):setTimeout(function(){this.goToNextStep()}.createDelegate(this),100)},saveFilterParams:function(e){this.getComponent("source_container_wrapper").saveFilterParams(e)},getSourceSelector:function(){return this.getComponent("source_container_wrapper").getSourceSelector()},activate:function(){this.getComponent("source_container_wrapper").activate()},getWarnEncList:function(){return this.getComponent("source_container_wrapper").getWarnEncList()},getWarnEncVolumeList:function(){return this.getComponent("source_container_wrapper").getWarnEncVolumeList()},summary:function(e){var t=this.getParams(),s=[];(s=t.isImage?(s=s.concat(t.backup_volumes)).concat(t.file_list):s.concat(t.file_list)).length?e.append(SYNO.SDS.Backup.String("app","source_share_wizard_title"),s.join(", ")):e.append(SYNO.SDS.Backup.String("app","source_share_wizard_title"),"-")}}),Ext.define("SYNO.SDS.Backup.TaskSourceContainer",{extend:"SYNO.SDS.Backup.FormPanel",constructor:function(e){var t=Ext.apply({cls:"syno-backup-source-container syno-backup-source-wrapper",autoFlexcroll:!1,items:[this.createSourceSelector(e.owner,e.pre_load_folder_done,e.isImage)],bbar:e.isImage?this.createBbar():void 0},e);return this.callParent([t])},createSourceSelector:function(e,t,s){var i={itemId:"source",owner:e,pageContainer:this,isImage:s,firstLevelExpanded:!0,pre_load_folder_done:t};return s?(i.height=367,new SYNO.SDS.Backup.TaskSourceQuadSelector(i)):(i.height=396,new SYNO.SDS.Backup.TaskSourceTriSelector(i))},createBbar:function(){var e=new SYNO.ux.Toolbar;return e.add(new Ext.ux.StatusBar({html:'<span class="syno-backup-open-filter-text">'+SYNO.SDS.Backup.String("app","create_file_filter")+"</span>",hideBorders:!0,listeners:{scope:this,afterrender:function(e){e.getEl().on("click",(function(){var e=new SYNO.SDS.Backup.Client.Common.FilterSettingWindow({owner:this.owner,backupFilter:this.backupFilter});e.on("savefilterparams",this.saveFilterParams,this),e.open()}),this)}}})),e},saveFilterParams:function(e){var t={};Ext.copyTo(t,e,"whitelist"),t.exclude_list=SYNO.Backup.Util.ExtractPattern(e.exclude_list,"file"),this.backupFilter=t},activate:function(){var e,t,s,i=this.owner.getParams(),a=this.getSourceSelector();a.updateAllEncShare(i.target_type,i.transfer_type)&&this.owner.getMsgBox().alert(_T("tree","leaf_backup"),String.format(_T("backup","multi_version_not_support_encrypted_share")+"&nbsp;"+_T("backup","deselect_all_encrypted_share"))),a.checkAllAzureDotEnd(i.transfer_type),a.clearDestination(),("share"===i.target_type&&"local"===i.transfer_type||"image"===i.target_type&&"image_local"===i.transfer_type||"export"===i.action)&&(e=i.share,(t=a.getNodeById("/"+e))&&(s=a.hasCheckedNode(t),a.setDestination("/"+e),!0===s&&this.owner.getMsgBox().alert(_T("tree","leaf_backup"),String.format(_T("localbkp","localbkp_dest_conflict_bkpshare")+"&nbsp;"+_T("localbkp","deselect_conflict_source_share")+"&nbsp;["+e+"]")))),a.setConflictVolume(),this.owner.doIfAppShareReady("folder_initialed"),this.getSourceSelector().activate()},getSourceSelector:function(){return this.getComponent("source")},getSourceSelectorName:function(){return this.getSourceSelector().self.displayName},getWarnEncList:function(){var e=this.owner.getParams();return"image"===e.target_type||"cloud_image"===e.target_type?this.getSourceSelector().getSelectedEncList():[]},getWarnEncVolumeList:function(){var e=this.owner.getParams();return"image"===e.target_type||"cloud_image"===e.target_type?this.getSourceSelector().getSelectedEncVolumeList():[]},getTieringShareList:function(){var e=this.owner.getParams();return"image"===e.target_type||"cloud_image"===e.target_type?this.getSourceSelector().getTieringShareList():[]},getTieringVaultList:function(){var e=this.owner.getParams();return"image"===e.target_type||"cloud_image"===e.target_type?this.getSourceSelector().getTieringVaultList():[]},getParams:function(){var e,t={};return e=this.getSourceSelector().getPathProcessParams(),t.isImage=this.isImage,t.file_list=e.folder_list,!0===this.isImage&&(t.backup_volumes=e.backup_volumes,t.backup_filter=SYNO.Backup.Util.deepCopyObject(this.backupFilter)||{whitelist:[],exclude_list:[]},t.backup_filter.exclude_list=t.backup_filter.exclude_list.concat(e.folder_exclude_list)),t},checkApply:function(){return this.checkC2Shares().then(this.checkEncryptedShares.bind(this)).then(this.checkTieringSharesAndVaults.bind(this))},checkC2Shares:function(){var e=this.getSourceSelector().getSelectedC2Shares();return e.length?this.isImage?new Promise(function(t,s){this.owner.getMsgBox().confirm(_T("leaf","backup"),String.format(SYNO.SDS.Backup.String("error","backup_source_c2_share"),"<b>"+e.join(", ")+"</b>"),(function(e){"yes"===e?t():s()}))}.bind(this)):Promise.reject("Not support c2 share in single version."):Promise.resolve()},checkEncryptedShares:function(){var e=this.getWarnEncList(),t=this.getWarnEncVolumeList();if(0<e.length||0<t.length){var s,i="";return 0<e.length&&0<t.length?(i=String.format("keep_enc_mounted_{0}volume_{1}share_when_backup",1<t.length?"plural_":"",1<e.length?"plural_":""),s=SYNO.SDS.Backup.String("error",i),s=String.format(s,"<b>"+t.join(", ")+"</b>","<b>"+e.join(", ")+"</b>")):0<e.length?(i=String.format("keep_enc_mounted_{0}share_when_backup",1<e.length?"plural_":""),s=String.format(SYNO.SDS.Backup.String("error",i),"<b>"+e.join(", ")+"</b>")):(i=String.format("keep_enc_mounted_{0}volume_when_backup",1<t.length?"plural_":""),s=String.format(SYNO.SDS.Backup.String("error",i),"<b>"+t.join(", ")+"</b>")),new Promise(function(e){this.owner.getMsgBox().alert(_T("leaf","backup"),s,e)}.bind(this))}return Promise.resolve()},checkTieringSharesAndVaults:function(){return new Promise(((e,t)=>{const s=this.getTieringShareList(),i=this.getTieringVaultList(),a=SYNO.SDS.Backup.String("error","backup_tiering_share_bucket_warning");if(Ext.isEmpty(s)&&!Ext.isEmpty(i))this.owner.getMsgBox().alert(_T("leaf","backup"),a,e);else if(Ext.isEmpty(s))e();else{new SYNO.SDS.Backup.HotTiering.ConfirmDialog({owner:this.owner,resolveFn:Ext.createDelegate(e,this),rejectFn:Ext.createDelegate(t,this)}).show()}}))}}),Ext.define("SYNO.SDS.Backup.AppGridPanel",{extend:"SYNO.ux.GridPanel",isAddAppDepTip:{},createColumnSelect:function(){return this.enableColumn=new SYNO.SDS.Backup.EnableColumn({sortable:!1,resizable:!1,dataIndex:"checked",width:40,align:"center",afterCheck:{handler:function(e){this.clickAppNode(e)},scope:this}}),this.enableColumn},createColumnAppInfo:function(){return new Ext.grid.Column({header:_T("backup","application"),width:200,dataIndex:"name",scope:this,renderer:function(e,t,s,i,a,n){var r=new Ext.XTemplate('<table><tbody><tr><td class="syno-backup-cell-app-td"><div class="syno-backup-cell-app-icon" ext:qtip="{app_err_msg}"> <img class="syno-backup-cell-app-icon-img" url="{[this.getIconUrl(values.id, values.version)]}" src="{[this.getIconUrl(values.id, values.version)]}" ext:qtip="{app_err_msg}"><tpl if="app_err_msg.length &gt; 0"><div class="syno-backup-cell-app-warning"ext:qtip="{app_err_msg}"></div></tpl></div><tpl if="is_beta"><div class="syno-backup-cell-app-beta-label" ext:qtip="{app_err_msg}"></div></tpl></td><td class="syno-backup-cell-app-title"><span class="syno-backup-cell-app-name" ext:qtip="{app_err_msg}">{name:htmlEncode}</span><tpl if="online_backup == false"><span class="syno-backup-cell-app_disable"ext:qtip="{disable_tip:htmlEncode}"></span></tpl><div class="normal-font" ext:qtip="{app_err_msg}">{version:htmlEncode}</div></div></tr></tbody></table>');return r.getIconUrl=SYNO.SDS.Backup.getAppIconPath,r.compile(),r.apply({name:s.get("name"),id:s.get("id"),version:s.get("version"),is_beta:s.get("is_beta"),online_backup:s.get("online_backup"),disable_tip:_T("backup","disable_in_backup_qtip"),app_err_msg:this.getErrorMsg(s)})}})},createColumnAppDependency:function(){return new Ext.grid.Column({header:'<span class="app-share-depend-header">'+_T("backup","share_depend")+'</span><div class="app-share-depend-header-tip" ext:wtip="'+this.getAppDepShareTipFormat()+'"></div>',headerHtmlEncode:!1,dataIndex:"depend",width:130,renderer:function(e,t,s,i,a,n){var r=[];if(!0===s.get("disabled")){if(!e)return"--";Ext.isDefined(e.invalid_shares)&&0!==e.invalid_shares.length&&r.push('<span class="red-status">'+e.invalid_shares.join(", ")+"</span>");var o=e.folder_list.map((function(e){return SYNO.SDS.Backup.getShareName(e.folder)}));return o=SYNO.ux.Utils.uniqueApiArray(o),Ext.each(o,(function(t){if(Ext.isDefined(e.invalid_shares)&&0<=e.invalid_shares.indexOf(t))return!0;r.push(t)})),r.join(", ")}if(0===e.folder_list.length)return"--";var c=SYNO.SDS.Backup.parseAppDependFolderInfo(e),l=[];Ext.each(c.detail,(function(e){if(-1!==e.whitelist.indexOf("*"))return l.push(e.path),!0;l.push(e.path+"("+e.whitelist.join(", ")+")")}));var u=new Ext.XTemplate('<div class="syno-backup-cell-folder-detail"><span ext:qtip="{folder_detail:htmlEncode}">{folder_outline:htmlEncode}</span></div>');return u.compile(),u.apply({folder_outline:c.outline.sort().join(", "),folder_detail:l.sort().join("<br>")})}})},createColumnAppSummary:function(){var e=this;return new Ext.grid.Column({header:SYNO.SDS.Backup.String("app","summary"),headerHtmlEncode:!1,dataIndex:"summary",width:220,renderer:function(t,s,i,a,n,r){var o=e.getAppInfoTip(r,i),c=i.get("summary_disp_tip");Ext.isEmpty(o)||(c=o+"<br>"+c),Ext.isEmpty(c)&&(c="--");var l=new Ext.XTemplate('<span class="syno-backup-cell-app-summary"ext:qtip="{finalDisp}">{finalDisp}</span>');return l.compile(),l.apply({finalDisp:c})}})},syncSourceTip:function(e){},syncCheckedStatus:function(){this.enableColumn.checkSelectAll(this.getStore())},clickAppNode:function(e){var t=e.get("id"),s=[];if(e.get("checked"))s=SYNO.SDS.Backup.getDepentApps(this.getStore(),t),Ext.each(s,(function(e){this.getStore().getById(e).set("checked",!0),this.syncSourceTip(this.getStore().getById(e))}),this);else{s=SYNO.SDS.Backup.getAppsDependOnThis(this.getStore(),t);var i,a=[],n=[];if(Ext.each(s,(function(e){var t=this.getStore().getById(e);t.get("checked")&&(a.push(t),n.push(t.get("name")))}),this),0<a.length&&0<n.length)i=!0===this.isBackup?SYNO.SDS.Backup.String("app","unselect_app_alert_bkp"):SYNO.SDS.Backup.String("app","unselect_app_alert_restore"),i=String.format(i,e.get("name"),n.join(", ")),this.owner.getMsgBox().confirm("",i,(function(t){"yes"===t?Ext.each(a,(function(e){e.set("checked",!1),this.syncSourceTip(e)}),this):e.set("checked",!0),this.syncCheckedStatus()}),this)}this.syncSourceTip(e)},getAppList:function(){var e=[];return Ext.each(this.getStore().data.items,(function(t){!0===t.get("checked")&&e.push(t.get("id"))})),e},getAppFolder:function(e){return this.getStore().getById(e).get("depend").folder_list},getAppWhitelist:function(e){return this.getStore().getById(e).get("depend").whitelist},normalizeFolder:function(e,t){if(e.length<t.length)return!1;var s=e.toLowerCase(),i=t.toLowerCase();return s===i?t:i===s.substring(0,t.length)&&"/"===s.charAt(t.length)&&t+e.substring(t.length)},getDealedAppWhitelist:function(e,t){var s=[];return Ext.each(t,(function(t){s.push(e+"/"+t),s.push(e+"/**/"+t)})),s},getSelectedAppFolderWhitelist:function(){var e=this.owner.getStep("share").getFolderList(!0),t=[],s=[];return this.getStore().each((function(i){if(!0!==i.get("checked"))return!0;var a=i.get("depend").folder_list;if(!a||0===a.length)return!0;(function(i){Ext.each(i,(function(i){var a=!1,n="/"+i.folder;Ext.each(e,(function(e){var t=this.normalizeFolder(n,e.path);if(t)return n=t,a=e.is_enc,!1}),this);var r={path:n,is_enc:a};t.push(r),s=s.concat(this.getDealedAppWhitelist(n,i.whitelist))}),this)}).call(this,a,!1)}),this),{app_folder:t,app_whitelist:s}},getSelectedAppShare:function(){var e=[];return this.getStore().each((function(t){if(!0!==t.get("checked"))return!0;var s=t.get("depend").folder_list;if(!s||0===s.length)return!0;e=e.concat(s.map((function(e){return e.folder})))})),SYNO.ux.Utils.uniqueApiArray(e)},getAppDepTip:function(e,t,s){var i="",a=SYNO.SDS.Backup.getDepentApps(e,t);if(0<a.length){var n=SYNO.SDS.Backup.getAppDisplayName(e,a);i=String.format(this.getAppDepTipFormat(),s,n.join(", "))}return i},getSource:function(){}}),Ext.define("SYNO.SDS.Backup.Restore.AppStep",{extend:"SYNO.SDS.Backup.AppGridPanel",AppSummary:{},constructor:function(e){Ext.copyTo(this,e,"owner");var t=this.createColumnSelect(),s=this.createColumnAppInfo(),i=this.createColumnAppDependency(),a=this.createColumnAppSummary(),n=Ext.apply({cls:"syno-backup-app-grid-panel",store:this.createStore(),enableHdMenu:!1,bbar:[new Ext.ux.StatusBar({id:"selectStatus",cls:"normal-font"})],colModel:new Ext.grid.ColumnModel({columns:[t,s,i,a]}),viewConfig:{getRowClass:function(e,t,s,i){if(e.get("disabled"))return"syno-backup-app-grid-disabled-row"}},listeners:{rowmousedown:function(e,t,s){if(e.getStore().getAt(t).get("disabled"))return!1}},plugins:[t]},e);this.callParent([n])},createStore:function(){return new Ext.data.JsonStore({proxy:new SYNO.API.Proxy({api:"SYNO.Backup.App2.Restore",method:"list",timeout:3e5,version:2,listeners:{load:{scope:this,fn:this.onProxyLoad}}}),listeners:{exception:{scope:this,fn:this.onStoreException},beforeload:{scope:this,fn:this.onBeforeLoad},load:{scope:this,fn:this.onLoad}},root:"app_list",idProperty:"id",sortInfo:{field:"name",direction:"ASC"},fields:["id","name","version","depend","disabled","behavior","error_code","is_beta","summary_disp","summary_disp_tip"]})},onProxyLoad:function(e,t){Ext.isEmpty(t.version_id)||Ext.isEmpty(t.dss_id)||(this.owner.dssCache[t.version_id]=t.dss_id)},isMaskError:function(e){return SYNO.SDS.Backup.ERR_APP_VOLUME===e||SYNO.SDS.Backup.ERR_APP_NO_SPACE===e},onStoreException:function(e,t,s,i,a,n){this.owner.clearStatusBusy(),this.isMaskError(a.code)?this.loadErrorCode=a.code:this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),SYNO.SDS.Backup.GetErrorString(a.code),(function(e){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===a.code&&this.owner.clearSession(),this.owner.close()}),this)},onBeforeLoad:function(e,t){delete this.loadErrorCode,this.owner.setStatusBusy()},onLoad:function(e,t,s){SYNO.SDS.Backup.setAppGridDependency(this,this.getFileTree(),!1,!1),this.owner.clearStatusBusy()},getFileTree:function(){return this.owner.getStep("share").getFileSourcePanel()},getVersionAppParams:function(){var e=this.owner.getBaseParams("share");return Ext.apply(e,this.owner.getEncParams()),e.dss_id=this.owner.dssCache[e.version_id],e},isReloadNeeded:function(){var e=this.getVersionAppParams();delete e.dss_id;var t=Ext.encode(e);return this.lastQuery!==t&&(this.lastQuery=t,!0)},activate:function(){this.isMaskError(this.loadErrorCode)?this.body.mask(SYNO.SDS.Backup.GetErrorString(this.loadErrorCode),"syno-ux-mask-info"):this.body.unmask(),this.isReloadNeeded()&&this.getStore().load({params:this.getVersionAppParams()})},summary:function(e){var t=[],s={install:{title:_T("backup","app_install_list"),list:[]},reinstall:{title:_T("backup","app_reinstall_list"),list:[]},upgrade:{title:_T("backup","app_upgrade_list"),list:[]},replace:{title:SYNO.SDS.Backup.String("app","app_replace_list"),list:[]},to_break:{title:SYNO.SDS.Backup.String("app","app_break_list"),list:[]}};for(var i in Ext.iterate(this.AppSummary,(function(e,i){i.isDepended||t.push(i.name),"install"===i.behavior||"upgrade"===i.behavior?s[i.behavior].list.push(i.name+" ("+i.version+")"):"reinstall"===i.behavior||"replace"===i.behavior?s[i.behavior].list.push(i.name):"break"===i.behavior&&s.to_break.list.push(i.name)})),0===t.length?e.append(SYNO.SDS.Backup.String("app","app_restore_list"),_T("system","none_opt")):e.append(SYNO.SDS.Backup.String("app","app_restore_list"),t.join(", ")),s)0<s[i].list.length&&e.append(s[i].title,s[i].list.join(", "))},updateAppSummaryAndGoNext:function(){if(this.AppSummary={},0<this.getAppList().length)return this.owner.getMsgBox().confirm("",_T("backup","restore_stop_app_alert"),(function(e){if("yes"===e){this.owner.setStatusBusy();var t=this.owner.getBaseParams();Ext.apply(t,this.owner.getEncParams()),t.dss_id=this.owner.dssCache[t.version_id],t.app_list=this.getAppList(),this.sendWebAPI({api:"SYNO.Backup.App2.Restore",version:1,method:"list_install",timeout:3e5,params:t,encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],t),scope:this,callback:function(e,s,i){this.owner.clearStatusBusy(),e?(Ext.each(s.app_list,(function(e,s,i){var a=-1===t.app_list.indexOf(e.id);if(a&&"skip"===e.behavior)return!0;this.AppSummary[e.id]=[],this.AppSummary[e.id].name=e.name,this.AppSummary[e.id].behavior=e.behavior,this.AppSummary[e.id].version=e.version,this.AppSummary[e.id].isDepended=a}),this),this.owner.goNext(this.nextId)):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(s.code),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===s.code&&(this.owner.clearSession(),this.owner.close())}),this)}})}}),this),!1;this.owner.goNext(this.nextId)},getNext:function(){var e=this.owner.getStep("share");if(0===e.getFolderList().length&&0===this.getAppList().length&&!this.owner.getStep("config").isRestoreConfig())return this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("backup","backup_data_empty")),!1;var t=e.getFileSourcePanel().getWarning(this.getSelectedAppShare());return t?this.owner.getMsgBox().confirm(_T("netbackup","netbkp_recovery"),t,(function(e){"yes"===e&&this.updateAppSummaryAndGoNext()}),this):this.updateAppSummaryAndGoNext(),!1},getParams:function(){var e=this.getAppList(),t={app_list:e=e.map((function(e){var t=this.AppSummary[e];return{id:e,version:t?t.version:this.getStore().getById(e).get("version"),display_name:this.getStore().getById(e).get("name")}}),this)};return Ext.apply(t,this.getSelectedAppFolderWhitelist()),t},getAppDepTipFormat:function(){return SYNO.SDS.Backup.String("app","app_depend_app_restore_qtip")},getAppDepShareTipFormat:function(){return SYNO.SDS.Backup.String("app","restore_share_depend_qtip")},getErrorMsg:function(e){var t="";return e.get("error_code")&&(t=SYNO.SDS.Backup.convertAppError(e.get("error_code"))),t},getAppInfoTip:function(e,t){var s=[],i=this.getAppDepTip(e,t.get("id"),t.get("name"));Ext.isEmpty(i)||s.push(i);var a=function(e,t){return String.format(SYNO.SDS.Backup.String("app","app_restore_action_also_"+e),t)};"skip"!==t.get("behavior")&&s.push(a(t.get("behavior"),t.get("name")));var n=t.get("depend");return n&&Ext.each(n.app_install_list,(function(e){var t=a(e.behavior,e.name);"skip"!==e.behavior&&0>s.indexOf(t)&&s.push(t)})),s.join("<br/>")},getSource:function(){return this.owner.getStep("share").getFileSourcePanel()},syncSourceTip:function(e){var t=this.getSource();SYNO.Backup.Util.updateAppShareTip(t,e,SYNO.SDS.Backup.String("app","tip_share_restore_by_app"))}}),Ext.define("SYNO.SDS.Backup.AppParamsPanel",{extend:"SYNO.SDS.Backup.AppGridPanel",isStoreLoaded:!1,checkedList:[],configList:[],AppAvailableTipId:void 0,AppEditId:"",AppEditColumnIdx:4,constructor:function(e){Ext.copyTo(this,e,"owner");var t=this.createColumnSelect(),s=this.createColumnAppInfo(),i=this.createColumnAppDependency(),a=this.createColumnAppSummary(),n=this.createColumnAppEdit();this.isReadOnly=e.isReadOnly;e.owner.configWizard;var r=Ext.apply({layout:"fit",cls:"syno-backup-app-grid-panel",store:this.createStore(),enableHdMenu:!1,bwrapStyle:{paddingTop:"0px",paddingBottom:"0px"},bbar:[new SYNO.ux.DisplayField({html:'<span class="syno-ux-note">'+_T("common","note")+_T("common","colon")+"&nbsp</span><span>"+SYNO.SDS.Backup.String("app","source_pkg_wizard_title_tip")+"</span>"})],colModel:new Ext.grid.ColumnModel({columns:[t,s,i,a,n]}),viewConfig:{getRowClass:function(e,t,s,i){if(e.get("disabled"))return"syno-backup-app-grid-disabled-row"}},listeners:{rowmousedown:function(e,t,s){if(e.getStore().getAt(t).get("disabled"))return!1}},plugins:[t]},e);this.callParent([r])},initEvents:function(){this.callParent(arguments),this.mon(this,"rowclick",this.onRowClick,this),this.mon(this,"afterlayout",(function(){this.isReadOnly&&(this.view.scroller.mask(),this.view.mainHd.mask())}),this)},createColumnAppEdit:function(){return new Ext.grid.Column({header:_T("common","alt_edit"),width:60,resizable:!1,dataIndex:"edit",menuDisabled:!0,renderer:function(e,t,s,i,a,n){if(this.isEnableAppEdit(s)){var r="app-summary-button-hidden";(s.get("checked")||!0===s.get("disabled"))&&(r="app-summary-button-visible");var o=new Ext.XTemplate('<div class="x-btn syno-ux-button syno-ux-button-default x-btn-icon syno-backup-cell-app-edit-button app-summary-button-tag {visibility_value}"><div class="syno-backup-cell-app-edit-button-icon app-summary-button-tag {visibility_value}"></div></div>');return o.compile(),o.apply({visibility_value:r})}}.createDelegate(this)})},isEnableAppEdit:function(e){var t=e.get("summary_edit_window");if(Ext.isEmpty(t)||!Ext.isString(t)||!e.get("is_running"))return!1;var s=Ext.isDefined(e.get("depend").invalid_shares)&&0<e.get("depend").invalid_shares.length;return!(!0===e.get("disabled")&&!s)},createStore:function(){return new Ext.data.JsonStore({id:"id",fields:["id","name","version","checked","depend","online_backup","is_beta","disabled","app_custom_err_msg","error_session","error_key","summary_disp","summary_disp_tip","summary_edit_window","config","is_running"],listeners:{scope:this,load:function(e,t){var s=!0;Ext.each(t,(function(e){if(this.isEnableAppEdit(e))return s=!1,!1}),this),s?this.getColumnModel().setHidden(this.AppEditColumnIdx,!0):this.getColumnModel().setHidden(this.AppEditColumnIdx,!1),this.doLayout()}}})},getFileTree:function(){return this.owner.getSourceSelector()},syncSourceTip:function(e){var t=this.getSource();SYNO.Backup.Util.updateAppShareTip(t,e,SYNO.SDS.Backup.String("app","tip_share_backup_by_app"))},loadStore:function(e,t){this.isStoreLoaded=!1,this.sendWebAPI({api:"SYNO.Backup.App2.Backup",method:"list",version:2,params:{app_config:this.configList,support_app_share:e,detailed_app_info:!0},scope:this,callback:function(e,s,i){e||(SYNO.SDS.Backup.ERR_APP_VOLUME===s.code?this.loadErrorCode=s.code:this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(s.code),(function(e){this.owner.close()}),this)),Ext.each(s,(function(e){-1<this.checkedList.indexOf(e.id)?e.checked=!0:e.checked=!1,Ext.each(this.configList,(function(t){e.id===t.app&&(e.config=t.config)}),this)}),this),this.getStore()&&(this.getStore().loadData(s),this.owner.doIfAppShareReady("app_loaded"),this.isStoreLoaded=!0,this.getStore().each((function(e){this.syncSourceTip(e)}),this),this.getStore().sort([{field:"disabled",direction:"ASC"},{field:"name",direction:"ASC"}])),Ext.isFunction(t)&&t()}})},isLoaded:function(){return this.isStoreLoaded},needHide:function(){return!this.loadErrorCode&&0===this.getStore().data.items.length},activate:function(){this.loadErrorCode&&this.bwrap.mask(SYNO.SDS.Backup.GetErrorString(this.loadErrorCode),"syno-ux-mask-info")},onRowClick:function(e,t,s){var i=Ext.fly(s.target);if(i){var a=this.store.getAt(t);i.hasClass("app-summary-button-tag")&&this.onAppSummaryEdit(a)}},onAppSummaryEdit:function(e){var t=e.get("summary_edit_window");if(!Ext.isEmpty(t)&&Ext.isString(t)&&e.get("is_running")){SYNO.SDS.JSLoad(t,(function(){var s=Ext.getClassByName(t);if(s.prototype instanceof SYNO.SDS.ModalWindow){var i=new s({owner:this.owner,config:e.get("config"),submitFn:Ext.createDelegate(this.onAppSummaryEditDone,this)});this.AppEditId=e.get("id"),this.mon(i,"close",(function(){this.AppEditId=""})),i.open()}else SYNO.Debug.error(t+" is not extends from SYNO.SDS.ModalWindow.")}),this)}},onAppSummaryEditDone:function(e){var t=this.getStore().getById(this.AppEditId);t&&(t.set("config",e),this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.App2.Backup",method:"get",version:1,params:{app_name:this.AppEditId,app_config:e,support_app_share:this.owner.support_app_share},scope:this,callback:function(e,t,s){this.owner.clearStatusBusy(),e||this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code),(function(e){this.owner.close()}),this);var i=this.getStore().getById(s.app_name);i.set("summary_disp",t.summary_disp),i.set("summary_disp_tip",t.summary_disp_tip),i.set("depend",t.depend),i.set("online_backup",t.online_backup),SYNO.SDS.Backup.setAppGridDependency(this,this.getFileTree(),!0,!1)}}))},afterRender:function(){this.callParent(arguments),this.getView().refresh(),this.owner.app_loaded&&(this.loadErrorCode?this.bwrap.mask(SYNO.SDS.Backup.GetErrorString(this.loadErrorCode),"syno-ux-mask-info"):Ext.isEmpty(this.getStore().data.items)&&this.bwrap.mask(_T("backup","no_application"),"syno-ux-mask-info"))},setAppCheckList:function(e){this.checkedList=e},setAppNameList:function(e){this.nameList=e},setAppLastConfig:function(e){this.configList=e},getAppConfig:function(){var e=[];return Ext.each(this.getStore().data.items,(function(t){t.get("checked")&&!Ext.isEmpty(t.get("config"))&&e.push({app:t.get("id"),config:t.get("config")})})),e},getParams:function(){return{app_list:this.getAppList(),app_config:this.getAppConfig()}},getNext:function(){var e,t,s=this.owner.getParams(),i=this.owner.getSourceSelector(),a=s.target_type+":"+s.transfer_type;if("share"===s.target_type&&"local"===s.transfer_type&&(e=s.share,(t=i.getNodeById("/"+e))&&!1!==t.getUI().getCheckValue()))return this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("localbkp","localbkp_dest_conflict_bkpshare")),!1;var n=this.owner.getStep(this.nextId[a]).getForm();n&&n.findField("dest_auto_unmount")&&(n.findField("dest_auto_unmount").hide(),n.findField("dest_auto_unmount").disable(),!_D("usbstation")&&this.owner.is_usb_share&&("local"!==s.transfer_type&&"image_local"!==s.transfer_type&&"export"!==s.action||(n.findField("dest_auto_unmount").show(),n.findField("dest_auto_unmount").enable())));var r=s.target_type;return"share"===r||"cloud"===r?(this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Target",method:"get_candidate_dir",params:s,version:1,encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],s),timeout:24e4,scope:this,callback:function(e,t,i){this.owner.clearStatusBusy();var n;e?(n=t.candidate_dir,this.owner.goNext(this.nextId[a]),n&&this.owner.setDestFolderName(n,s.target_type,s.transfer_type)):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code))}}),!1):this.nextId[a]},getAppDepTipFormat:function(){return SYNO.SDS.Backup.String("app","app_depend_app_backup")},getAppDepShareTipFormat:function(){return _T("backup","share_depend_qtip")},getErrorMsg:function(e){var t="";if(!(e.get("app_custom_err_msg")||e.get("depend").invalid_shares||e.get("error_session")&&e.get("error_key")))return"";t=SYNO.SDS.Backup.Util.htmlEncodeTip(SYNO.SDS.Backup.String("app","cannot_backup_reason_prefix")),t+="<br/>";var s=e.get("depend").invalid_shares;if(Ext.isDefined(s)&&0!==s.length){t+="<br/>",t+=SYNO.SDS.Backup.Util.htmlEncodeTip(SYNO.SDS.Backup.String("app","err_mapped_shared_folder_restore"));var i=this.getSource().getDestination();!Ext.isEmpty(i)&&-1<s.indexOf(i.substr(1))&&(t+="<br/>",t+=String.format(SYNO.SDS.Backup.String("error","localbkp_dest_conflict_bkpshare"),i.substr(1)))}return e.get("error_session")&&e.get("error_key")&&(t+="<br/>","not_support_new_framework"===e.get("error_key")?"share"===this.owner.getParams().target_type||"cloud"===this.owner.getParams().target_type?t+=SYNO.SDS.Backup.String("error","not_support_new_framework_legacy_task"):"image_remote"===this.owner.getParams().transfer_type&&!1===this.owner.isOnline?t+=t=SYNO.SDS.Backup.String("error","general_backup_destination_disconnect"):"image_remote"===this.owner.getParams().transfer_type?t+=SYNO.SDS.Backup.String("error","not_support_new_framework_vault"):t+=SYNO.SDS.Backup.String("app","restore_version_old"):t+=SYNO.SDS.Backup.Util.htmlEncodeTip(SYNO.SDS.Backup.String(e.get("error_session"),e.get("error_key")))),e.get("app_custom_err_msg")&&(t+="<br/>",t+=SYNO.SDS.Backup.Util.htmlEncodeTip(e.get("app_custom_err_msg"))),t},getAppInfoTip:function(e,t){return this.getAppDepTip(e,t.get("id"),t.get("name"))},getSource:function(){return this.owner.getSourceSelector()},summary:function(e){var t=this.getParams();t.app_list&&(t.app_list.length?e.append(SYNO.SDS.Backup.String("app","source_pkg_wizard_title"),t.app_list.join(", ")):e.append(SYNO.SDS.Backup.String("app","source_pkg_wizard_title"),"-"))}}),Ext.define("SYNO.SDS.Backup.RotationParamsPanel",{extend:"SYNO.SDS.Backup.FormPanel",rotate_customize_retention:[],rotation_action:[],smart_rotation_setting:[[86400,3600,1],[2419200,86400,1],[0,604800,1]],constructor:function(e){var t=[{xtype:"syno_fieldset",itemId:"rotation_fieldset",cls:"syno-sds-backup-rotationParam-fieldset",labelWidth:300,collapsible:!1,items:this.configRotationFields(e)}];this.isReadOnly=e.isReadOnly,Ext.isIE8||(this.previewer=new SYNO.SDS.Backup.Rotation.Previewer({cls:"syno-sds-backup-rotationPreviewer"}),t.push(this.previewer));var s=Ext.apply({height:410,cls:"syno-sds-backup-rotationParamPanel",items:[t]},e);return this.rotate_customize_retention=this.rotate_customize_retention.concat(this.smart_rotation_setting),this.activated=!1,this.lastTypeValue=!1,this.callParent([s])},initEvents:function(){this.callParent(arguments),this.mon(this,"activate",this.activate,this),this.mon(this,"afterlayout",(function(){this.isReadOnly&&this.body.mask()}),this)},activate:function(){if(!this.activated){var e=this.getForm().findField("backup_rotation"),t=this.getForm().items.filter("name","backup_rotation_action").get(1),s=this.getForm().findField("backup_rotation_condition_max_version");if(e&&e.getEl()&&SYNO.ux.AddTip(e.getEl(),_T("backup","rotate_enable_hint")),t&&t.getEl()){var i=_T("backup","rotate_action_smart_recycle_description")+"<br/><br/><b>"+_T("backup","rotate_action_smart_recycle_hourly")+"</b><br/>"+_T("backup","rotate_action_smart_recycle_hourly_hint")+"<br/><br/><b>"+_T("backup","rotate_action_smart_recycle_daily")+"</b><br/>"+_T("backup","rotate_action_smart_recycle_daily_hint")+"<br/><br/><b>"+_T("backup","rotate_action_smart_recycle_weekly")+"</b><br/>"+_T("backup","rotate_action_smart_recycle_weekly_hint")+"<br/>";SYNO.ux.AddTip(t,i)}if(s&&s.getEl()){var a=SYNO.SDS.Backup.String("app","rotate_condition_desc");SYNO.ux.AddTip(s,a)}this.activated=!0}this.doLayout(),this.previewer&&this.updatePreviewer(),this.changeSynoCloudRotateView()},isSynoCloudType:function(){return SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.ROTATION_BASIC===this.owner.accountMeta.versionRotation},changeSynoCloudRotateView:function(){var e=function(e){return this.getComponent("rotation_fieldset").getComponent(e)}.createDelegate(this),t=function(e){return this.getForm().findField(e)}.createDelegate(this),s=this.isSynoCloudType();this.lastTypeValue!==s&&(this.lastTypeValue=s,this.rotate_customize_retention=s?[[2419200,604800,1],[604800,86400,1]]:[[86400,3600,1],[2419200,86400,1],[0,604800,1]],t("backup_rotation").setValue(s),t("backup_rotation").setDisabled(s),t("rotate_condition_desc").setVisible(!s),t("rotate_action_desc").setVisible(!s),t("backup_rotation_condition_max_version").setValue(s?10:256),t("backup_rotation_condition_max_version").setVisible(!s),t("synocloud_rotation_desc").setVisible(s),e("rotate_earliest").setValue(!s),e("rotate_earliest").setVisible(!s),e("rotate_smart_recycle").setVisible(!s),e("rotate_customize_retention").setValue(s),e("rotate_customize_retention").setVisible(!s),e("rotate_customize_retention_setting").setVisible(!s),this.updatePreviewer())},configRotationFields:function(e){return this.customize_button_id=Ext.id(),[{xtype:"syno_checkbox",name:"backup_rotation",checked:!0,groupFields:{enable:["backup_rotation_action","backup_rotation_condition_max_version"]},boxLabel:_T("backup","enable_backup_rotation"),listeners:{check:function(){this.updatePreviewer()},scope:this}},{xtype:"syno_displayfield",name:"rotate_action_desc",indent:1,value:SYNO.SDS.Backup.String("app","rotate_action_description")},{xtype:"syno_radio",indent:1,name:"backup_rotation_action",itemId:"rotate_earliest",inputValue:"rotate_earliest",checked:!0,boxLabel:_T("backup","rotate_action_earliest"),listeners:{check:function(e,t){t&&this.updatePreviewer("rotate_earliest")},scope:this}},{xtype:"syno_radio",indent:1,name:"backup_rotation_action",itemId:"rotate_smart_recycle",inputValue:"rotate_smart_recycle",boxLabel:_T("backup","rotate_action_smart_recycle"),listeners:{check:function(e,t){t&&this.updatePreviewer("rotate_smart_recycle")},scope:this}},{xtype:"syno_radio",indent:1,name:"backup_rotation_action",itemId:"rotate_customize_retention",inputValue:"rotate_customize_retention",groupFields:[this.customize_button_id],boxLabel:SYNO.SDS.Backup.String("app","customized_retention"),listeners:{check:function(e,t){t&&this.updatePreviewer("rotate_customize_retention")},scope:this}},{xtype:"syno_button",id:this.customize_button_id,indent:2,itemId:"rotate_customize_retention_setting",text:_T("common","common_settings"),handler:this.openCustomizedRetentionWindow,scope:this},{xtype:"syno_displayfield",name:"synocloud_rotation_desc",cls:"syno-sds-backup-synocloud-rotation-desc",indent:1,value:SYNO.SDS.Backup.String("synocloud","rotation_description"),hidden:!0,htmlEncode:!1},{xtype:"container",layout:{type:"hbox"},items:[{xtype:"syno_displayfield",cls:"syno-sds-backup-rotation-maximumVer-text",name:"backup_rotation_condition_max_label",value:SYNO.SDS.Backup.String("app","rotate_maximum_versions")+":"},{xtype:"syno_numberfield",cls:"syno-sds-backup-rotation-maximumVer-num-field",allowBlank:!1,name:"backup_rotation_condition_max_version",width:60,value:256,minValue:1,maxValue:65535,enableKeyEvents:!0,listeners:{keyup:function(){this.updatePreviewer()},scope:this}}]},{xtype:"syno_displayfield",cls:"syno-sds-backup-rotationPreviewer-title",value:SYNO.SDS.Backup.String("app","rotate_retention_description")}]},loadData:function(e){var t=this.getForm().findField("backup_rotation");Ext.isBoolean(e.enable_rotate)&&t.setValue(e.enable_rotate),Ext.isEmpty(e.rotate_option)?Ext.isArray(e.rotate_action)&&(0<e.rotate_action.length?this.setRotationOptionValue("rotate_smart_recycle"):this.setRotationOptionValue("rotate_earliest")):this.setRotationOptionValue(e.rotate_option),Ext.isArray(e.rotate_action)&&(this.rotation_action=e.rotate_action),Ext.isArray(e.rotate_customized_rules)&&(this.rotate_customize_retention=e.rotate_customized_rules);var s=this.getForm().findField("backup_rotation_condition_max_version");s&&(Ext.isArray(e.rotate_condition)?s.setValue(e.rotate_condition[1]):s.setValue(256))},getRotationParams:function(e){var t=this.getForm().findField("backup_rotation"),s=this.getForm().findField("backup_rotation_condition_max_version"),i={rotate_params:{}};return i.rotate_params.enable_rotate=t.getValue(),"rotate_earliest"===(e=Ext.isDefined(e)?e:this.getRotationOptionValue())?(i.rotate_params.rotate_option="rotate_earliest",i.rotate_params.rotate_action=[]):"rotate_smart_recycle"===e?(i.rotate_params.rotate_option="rotate_smart_recycle",i.rotate_params.rotate_action=this.smart_rotation_setting):"rotate_customize_retention"===e&&(i.rotate_params.rotate_option="rotate_customize_retention",i.rotate_params.rotate_action=this.rotate_customize_retention),i.rotate_params.rotate_condition=[1,s.getValue()],i.rotate_params.rotate_customized_rules=this.rotate_customize_retention,i},getParams:function(e){var t=this.getRotationParams();return t.rotate_params.enable_rotate||(delete t.rotate_params.rotate_action,delete t.rotate_params.rotate_condition),t},updatePreviewer:function(e){if(this.activated&&this.previewer){var t=this.owner.getParams().schedule,s=this.getRotationParams(e).rotate_params;s.isSynoCloudType=this.isSynoCloudType(),this.previewer.updatePreviewer(t,s)}},getNext:function(){return!!this.getForm().isValid()&&this.nextId},openCustomizedRetentionWindow:function(){var e=[];e=e.concat(this.rotate_customize_retention);var t=new SYNO.SDS.Backup.Client.Common.RetentionSetting.CustomizedWindow({title:SYNO.SDS.Backup.String("app","customized_retention_title"),owner:this.owner,appWin:this.appWin,retention_rules:e});this.mon(t,"setCustomizedRetention",this.onSetCustomizedRetention,this),t.open()},onSetCustomizedRetention:function(e){this.rotate_customize_retention=e.rotate_customize_retention,this.updatePreviewer()},getRotationOptionList:function(){return this.getForm().items.items.filter((function(e){if("backup_rotation_action"===e.name)return!0}))},setRotationOptionValue:function(e){var t=this.getRotationOptionList();Ext.each(t,(function(t){e===t.itemId?t.setValue(!0):t.setValue(!1)}))},getRotationOptionValue:function(){var e=this.getRotationOptionList(),t="";return Ext.each(e,(function(e){if(e.getValue())return t=e.itemId,!1})),t},summary:function(e){var t=this.getParams();if(t.rotate_params.enable_rotate)switch(t.rotate_params.rotate_option){case"rotate_earliest":e.append(SYNO.SDS.Backup.String("app","backup_rotation"),_T("backup","rotate_action_earliest"));break;case"rotate_smart_recycle":e.append(SYNO.SDS.Backup.String("app","backup_rotation"),_T("backup","rotate_action_smart_recycle"));break;case"rotate_customize_retention":e.append(SYNO.SDS.Backup.String("app","backup_rotation"),SYNO.SDS.Backup.String("app","customized_retention"))}else e.append(SYNO.SDS.Backup.String("app","backup_rotation"),"-")}}),Ext.namespace("SYNO.SDS.LunBackup"),SYNO.SDS.LunBackup.LUNBKP_SYNO_SERVER="lunbkp_synology",SYNO.SDS.LunBackup.BKPSET_MAX_LEN=32,SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH=250,SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH=230,SYNO.SDS.LunBackup.BKP_DEST_TYPE_LOCLUN="locallun",SYNO.SDS.LunBackup.BKP_DEST_TYPE_NETLUN="netlun",SYNO.SDS.LunBackup.BKPTASK_LOCLUN="loclunbkp",SYNO.SDS.LunBackup.BKPTASK_NETLUN="netlunbkp",SYNO.SDS.LunBackup.getFakePass=function(){var e,t="";for(e=0;e<8;e++)t+=String.fromCharCode(65283);return t},SYNO.SDS.LunBackup.GetServerName=function(e){var t=e,s=e.indexOf("(");return s>0&&(t=e.substring(0,s)),Ext.form.VTypes.netbiosName(t)||Ext.form.VTypes.hostname(t)&&!Ext.form.VTypes.looseip(t)?t:""},SYNO.SDS.LunBackup.GetServerIP=function(e){var t=e,s=e.indexOf("("),i=e.indexOf(")");return s>0&&s<i&&i===e.length-1&&(t=e.substring(s+1,i)),Ext.form.VTypes.looseip(t)?t:""},SYNO.SDS.LunBackup.onLoadSynologyServer=function(e,t,s){s.setStatusBusy({text:_T("netbackup","netbkp_wait_server")}),s.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"net_bkp_host",scope:this,callback:function(i,a){if(s.clearStatusBusy(),i){for(var n=0;n<a.total;n++)t.push([a.items[n].ip,a.items[n].host]);e.isExpanded()||e.el.focus(),e.getStore().loadData(t,!1)}}})},SYNO.SDS.LunBackup.onTestSvrConnection=function(e,t,s,i){s.owner.setStatusBusy({text:_T("netbackup","netbkp_connection_testing")}),s.owner.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:e,params:t,scope:s,callback:function(e,a){var n=t.title?t.title:_T("tree","leaf_backup");i?i.call(s,e,a):(s.owner.clearStatusBusy(),e?s.owner.getMsgBox().alert(n,_T("netbackup","netbkp_connection_testing_success")):a&&a.errors&&a.errors.sec&&a.errors.key&&""!==a.errors.sec&&""!==a.errors.key?s.owner.getMsgBox().alert(n,_T(a.errors.sec,a.errors.key)):s.owner.getMsgBox().alert(n,_T("netbackup","netbkp_connection_testing_fail")))}})},SYNO.SDS.LunBackup.getLocalIPs=function(e,t){e.sendWebAPI({api:"SYNO.Backup.Lunbackup",method:"get_self_host",version:1,scope:e,callback:function(s,i){t&&t.call(e,s,i)}})},SYNO.SDS.LunBackup.netbkpValidator=function(e,t,s){var i=t.split(","),a=new RegExp(s,"gi");if(e===t||"127.0.0.1"===e||e.match(a)&&e.length===s.length)return SYNO.SDS.Backup.String("app","connect_self_ip");for(var n=0;n<i.length;n++)if(e===i[n])return SYNO.SDS.Backup.String("app","connect_self_ip");return!0},Ext.define("SYNO.SDS.Backup.TaskNamePanel",{extend:"SYNO.ux.FormPanel",oriTaskName:"",constructor:function(e){for(var t={title:_T("localbkp","localbkp_dest"),padding:"24px 0 0 0",items:[{xtype:"syno_textfield",fieldLabel:_T("localbkp","localbkp_bkpset_name"),name:"bkpset",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,maxlength:SYNO.SDS.LunBackup.BKPSET_MAX_LEN,vtype:"taskname",width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,allowBlank:!1}]},s=0;s<e.items.length;s++)t.items.push(e.items[s]);Ext.applyIf(t,e),this.callParent([t])},getDefaultName:function(){for(var e="My LUN Backup Set",t=1;-1!==this.owner.owner.getTaskNameList().indexOf(e+" "+t);)t++;return e+" "+t},setDefaultName:function(){var e=this.getForm().findField("bkpset");""===e.getValue()&&e.setValue(this.getDefaultName()),this.getForm().findField("bkpset").focus(!0)},bkpsetConflict:function(e,t){var s=e.getForm().findField("bkpset"),i=Ext.util.Format.trim(s.getValue());if(s.setValue(i),e.oriTaskName!==i){e.owner.setStatusBusy({text:_T("common","loading")});var a={};a.bkpset=i,e.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"is_bkp_set_conflict",params:a,scope:e,callback:function(s,i){if(e.owner.clearStatusBusy(),s)if(i.conflict)e.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("localbkp","localbkp_bkpset_exist"),(function(){e.getForm().findField("bkpset").focus(!0)}),e);else{var a=e.getForm().findField("bkpset").getValue();e.oriTaskName=a,e.LUNBackupParam.taskName=a,t&&t.call(e)}}})}else t&&t.call(e)},summary:function(e){var t=e.reader.readRecords({data:[{key:_T("localbkp","localbkp_bkpset_name"),value:this.getForm().findField("bkpset").getValue()}]});e.insert(0,t.records)}}),Ext.define("SYNO.SDS.Backup.LUNSourcePanel",{extend:"SYNO.ux.FormPanel",isActivatedBefore:!1,constructor:function(e){var t=new Ext.data.SimpleStore({id:"value",sortInfo:{field:"display",direction:"ASC"},fields:["value",{name:"display",sortType:"asNaturalUCString"}],data:e.LUNBackupParam.lunSourceList});e.LUNBackupParam.lunSourceStore=t;var s={title:Ext.util.Format.ellipsis(_T("lunbkp","lun_source"),15),padding:"24px 0 0 0",items:[{tpl:'<tpl for="."><div ext:qtip="{display}" class="x-combo-list-item">{display}</div></tpl>',xtype:"syno_combobox",fieldLabel:_T("lunbkp","lun_source"),hiddenName:"lunsource",name:"lunsource",forceSelection:!0,allowBlank:!1,editable:!1,store:t,displayField:"display",valueField:"value",triggerAction:"all",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,mode:"local",scope:this}]};Ext.apply(s,e),this.callParent([s]),this.registerEvent()},registerEvent:function(){this.getForm().findField("lunsource").on("select",(function(e,t,s){this.getForm().findField("lunsource").el.dom.qtip=this.LUNBackupParam.lunSourceList[s][1]}),this)},activate:function(){this.isActivatedBefore||(this.isActivatedBefore=!0,this.lunSourceRequest())},saveSettings:function(){this.LUNBackupParam.lunSource=this.getForm().findField("lunsource").getValue().name,this.LUNBackupParam.lunSourceSize=this.getForm().findField("lunsource").getValue().size,this.LUNBackupParam.lunSourceType=this.getForm().findField("lunsource").getValue().type},checkLUNDone:function(e,t){this.owner.clearStatusBusy(),e?"passed"===t.name_check&&"passed"===t.space_check&&this.owner.goNext(this.nextId):(null!==t?"failed"===t.errors.name_check?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("smsnotify","provider_name_repetition")):"failed"===t.errors.space_check?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("share","share_space_not_enough")):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system")):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system")),this.owner.getButton("next").disable())},checkLUN:function(){var e={};e.tasktype=this.LUNBackupParam.taskType,e.lunname=this.LUNBackupParam.lunSource,e.lunsize=this.LUNBackupParam.lunSourceSize,SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.LUNBackupParam.taskType?e.share=this.owner.LUNPanelDestLocal.getForm().findField("localDest").getValue():SYNO.SDS.LunBackup.BKPTASK_NETLUN===this.LUNBackupParam.taskType&&(e.servertype="synology",e.share=this.owner.LUNPanelDestShare.getForm().findField("remoteShare").getValue(),e=this.owner.LUNPanelDestNet.getParamsVal(e)),this.owner.setStatusBusy({text:_T("bkpwizard","msg_waiting")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"check_lun",params:e,scope:this,callback:this.checkLUNDone})},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),"block"!==this.LUNBackupParam.lunSourceType?this.checkLUN():this.owner.getMsgBox().confirm(_T("tree","leaf_backup"),_T("lunbkp","lun_is_vaai_or_block"),(function(e){"yes"===e&&this.checkLUN()}),this),!1)},summary:function(e){e.append(_T("lunbkp","lun_source"),this.LUNBackupParam.lunSource)},lunSourceDone:function(e,t){var s=0;if(this.owner.clearStatusBusy(),e){if(this.LUNBackupParam.lunSourceList=this.generateLunSourceList(t),this.LUNBackupParam.lunSourceStore.loadData(this.LUNBackupParam.lunSourceList,!1),"edit"!==this.mode)if(0<this.LUNBackupParam.lunSourceList.length){var i=this.LUNBackupParam.lunSourceStore.getAt(0);this.getForm().findField("lunsource").setValue(i.get("value")),this.getForm().findField("lunsource").el.dom.qtip=i.get("display"),this.owner.getButton("next").enable()}else this.owner.getButton("next").disable(),this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("lunbkp","err_no_available_lun"));else if(0<this.LUNBackupParam.lunSourceList.length)for(s=0;s<this.LUNBackupParam.lunSourceList.length;s++)this.LUNBackupParam.lunSource===this.LUNBackupParam.lunSourceList[s][0].name&&(this.getForm().findField("lunsource").setValue(this.LUNBackupParam.lunSourceList[s][0]),this.LUNBackupParam.lunSourceSize=this.LUNBackupParam.lunSourceList[s][0].size)}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system")),this.owner.getButton("next").disable()},lunSourceRequest:function(){var e={};this.LUNBackupParam.lunSourceList.length=0,e.mode=this.mode,"edit"===this.mode?e.lunname=this.LUNBackupParam.lunSource:e.lunname="",this.owner.setStatusBusy({text:_T("lunbkp","search_lun_source")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_lun",params:e,scope:this,callback:this.lunSourceDone})},generateLunSourceList:function(e){const t=[];for(let s=0;s<e.total;s++)t.push([{name:e.items[s].name,size:e.items[s].size},e.items[s].name]);return t}}),Ext.define("SYNO.SDS.Backup.LUNMultiVerSourcePanel",{extend:"SYNO.SDS.Backup.LUNSourcePanel",checkLUN:function(){let e=this.owner.getParams();this.owner.goNext(this.nextId[`${e.target_type}:${e.transfer_type}`])},lunSourceRequest:function(){this.LUNBackupParam.lunSourceList.length=0,this.owner.setStatusBusy({text:_T("lunbkp","search_lun_source")}),this.sendWebAPI({api:"SYNO.Backup.MultiVerLun",version:1,method:"enum_lun",scope:this,callback:this.lunSourceDone})},generateLunSourceList:function(e){const t=[];for(let s=0;s<e.total;s++)t.push([{name:e.items[s].name,size:e.items[s].size,type:e.items[s].type,type_str:e.items[s].type_str,uuid:e.items[s].uuid},e.items[s].display_name]);return t},saveSettings:function(){this.callParent(),this.LUNBackupParam.lunSourceUuid=this.getForm().findField("lunsource").getValue().uuid,this.LUNBackupParam.lunSourceName=this.getForm().findField("lunsource").getValue().name,this.LUNBackupParam.lunSourceType=this.getForm().findField("lunsource").getValue().type_str},summary:function(e){const t=SYNO.Backup.Util.GetMultiVerLunDisplayName(this.LUNBackupParam.lunSourceName,this.LUNBackupParam.lunSourceType);e.append(_T("lunbkp","lun_source"),t)}}),Ext.define("SYNO.SDS.Backup.LUNDestTypePanel",{extend:"SYNO.ux.FormPanel",selected:null,constructor:function(e){var t=this,s=Ext.apply({items:[new SYNO.SDS.Backup.SelectBackupDestination({propsData:{destinations:["remote","local"],showOtherDestinations:!1,onSelect:function(e){t.selected=e}}})]},e);this.callParent([s])},getNext:function(){return null!==this.selected&&this.nextIdFn(this.selected)}}),Ext.define("SYNO.SDS.Backup.LUNDestLocalPanel",{extend:"SYNO.ux.FormPanel",blLoaded:!1,userInputDirectoryFlag:!1,destStore:null,destList:[],constructor:function(e){var t=new Ext.data.ArrayStore({id:"value",fields:["value","display"],data:this.destList});this.destStore=t;var s={padding:"24px 0 0 0",items:[{xtype:"syno_combobox",fieldLabel:_T("localbkp","localbkp_dest"),name:"localDest",store:t,allowBlank:!1,displayField:"display",valueField:"value",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,listeners:{scope:this,select:this.defaultDirectoryUpdate}},{xtype:"syno_textfield",fieldLabel:_T("backup","backup_dest_directory"),itemId:"destDirectory",allowBlank:!1,labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,vtype:"sharename",maxlength:32,listeners:{scope:this,change:this.userInputDirectory}}]};Ext.apply(s,e),this.callParent([s])},localbkpDestDone:function(e,t){if(this.owner.clearStatusBusy(),e){this.allDest=t.items,this.destList=[];for(var s=0;s<t.total;s++)this.destList.push([this.allDest[s].destValue,this.allDest[s].dest]);var i=this.getForm().findField("localDest");i.store.loadData(this.destList,!1),0<this.destList.length?(i.setValue(this.destList[0][0]),this.defaultDirectoryUpdate(),this.owner.getButton("next").enable()):(this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("share","error_noneshare")),this.owner.getButton("next").disable())}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system")),this.owner.getButton("next").disable()},load:function(){this.destList.length=0,this.owner.setStatusBusy({text:_T("localbkp","localbkp_wait_dest")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_local_bkp_dest",scope:this,callback:this.localbkpDestDone})},activate:function(){this.blLoaded||(this.load(),this.blLoaded=!0)},checkDirDone:function(e,t){this.owner.clearStatusBusy(),e?this.owner.goNext(this.nextId):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))},checkDir:function(){var e={};e.bkptype=SYNO.SDS.LunBackup.BKPTASK_LOCLUN,e.bkpset=this.LUNBackupParam.taskName,e.share=this.getBkpDest(),e.directory=this.getBkpDir(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"check_dir",params:e,scope:this,callback:this.checkDirDone})},getNext:function(){return!!this.getForm().isValid()&&(this.LUNBackupParam.taskDest=this.getBkpDest()+"/"+this.getBkpDir(),this.checkDir(),!1)},summary:function(e){var t=[String.format("{0}",_T("lunbkp","local_lunbkp")),String.format("{0} : {1}",_T("localbkp","localbkp_dest"),this.getBkpDest()),String.format("{0} : {1}",_T("backup","backup_dest_directory"),this.getBkpDir())];e.append(_T("localbkp","localbkp_dest"),t)},userInputDirectory:function(){this.userInputDirectoryFlag=!0},defaultDirectoryUpdate:function(){if(!this.userInputDirectoryFlag){var e=this.getForm().findField("destDirectory"),t=this.owner,s={};s.bkpShare=this.getBkpDest(),this.owner.setStatusBusy({text:_T("localbkp","localbkp_wait_dest")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"get_local_dest_dir",params:s,scope:this,callback:function(s,i){t.clearStatusBusy(),s?e.setValue(i.defaultDirectory):t.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))}})}},getBkpDest:function(){return this.getForm().findField("localDest").getValue()},getBkpDir:function(){return this.getForm().findField("destDirectory").getValue()}}),Ext.define("SYNO.SDS.Backup.LUNDestNetPanel",{extend:"SYNO.ux.FormPanel",blSynoServerLoad:!1,ServerStore:null,constructor:function(e){this.ServerList=[],this.ServerStore=new Ext.data.SimpleStore({fields:["value","display"],data:this.ServerList,sortInfo:{field:"display",direction:"ASC"}});var t={padding:"24px 0 0 0",items:[{xtype:"syno_combobox",fieldLabel:_T("netbackup","netbkp_set_ip"),name:"server",allowBlank:!1,emptyText:_T("netbackup","netbkp_input_addr"),editable:!0,store:this.ServerStore,displayField:"display",valueField:"value",triggerAction:"all",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,mode:"local",validator:function(t){return SYNO.SDS.LunBackup.netbkpValidator(t,e.LUNBackupParam.selfIPs,e.LUNBackupParam.selfHostName)},onTriggerClick:function(){0!==this.getStore().getCount()?this.isExpanded()?(this.collapse(),this.el.focus()):(this.onFocus({}),this.expand(),this.el.focus()):(this.owner.serverListLoaded=!0,this.el.focus(),SYNO.SDS.LunBackup.onLoadSynologyServer(this,this.owner.ServerList,this.owner.owner))},owner:this},{xtype:"syno_textfield",fieldLabel:_T("netbackup","netbkp_account"),name:"account",allowBlank:!1,labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,vtype:"username_ext"},{xtype:"syno_textfield",fieldLabel:_T("common","password"),name:"password",inputType:"password",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH}]};Ext.apply(t,e),this.callParent([t])},activate:function(){this.serverListLoaded=!1},getNext:function(){return!!this.getForm().isValid()&&(this.onTestConnectionButton(),!1)},summary:function(e){},TestServerVersionDone:function(e,t){this.owner.clearStatusBusy(),e?this.owner.goNext(this.nextId):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),SYNO.SDS.Backup.String(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_fail"))},TestConnectionWhenGoNext:function(e,t){if(e){var s={servertype:"synology",share:"share"};s=this.getParamsVal(s),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"remote_version_check",params:s,scope:this,callback:this.TestServerVersionDone})}else this.owner.clearStatusBusy(),t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_fail"))},onTestConnectionButton:function(e){var t={};t.servertype=SYNO.SDS.LunBackup.LUNBKP_SYNO_SERVER,(t=this.getParamsVal(t))&&SYNO.SDS.LunBackup.onTestSvrConnection("test_connections",t,this,this.TestConnectionWhenGoNext)},getParamsVal:function(e){var t=this.getForm(),s=SYNO.SDS.LunBackup.GetServerName(t.findField("server").getRawValue()),i=SYNO.SDS.LunBackup.GetServerIP(t.findField("server").getRawValue()),a=t.findField("account").getValue(),n=t.findField("password").getValue();return""===s&&""===i?(this.owner.getMsgBox().alert(_T("tree","node_backup"),_T("netbackup","netbkp_err_host_str")),!1):(e.server=s,e.ip=i,e.account=a,e.password=n,e.user=a,e)}}),Ext.define("SYNO.SDS.Backup.LUNDestSharePanel",{extend:"SYNO.ux.FormPanel",owner:null,userInputDirectoryFlag:!1,remoteHost:"",constructor:function(e){var t,s;s=_T("lunbkp","dest_shared_folder"),e.LUNBackupParam.remoteShareStore=new Ext.data.ArrayStore({id:"dsRemoteShare",fields:["value"],data:[]}),t={padding:"24px 0 0 0",items:[{xtype:"syno_displayfield",itemId:"serverInfo",fieldLabel:_T("netbackup","netbkp_server"),labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:300},{xtype:"syno_combobox",fieldLabel:s,name:"remoteShare",store:e.LUNBackupParam.remoteShareStore,allowBlank:!1,displayField:"value",valueField:"value",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,listeners:{scope:this,select:this.defaultDirectoryUpdate}},{xtype:"syno_textfield",fieldLabel:_T("backup","backup_dest_directory"),itemId:"destDirectory",allowBlank:!1,labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,vtype:"sharename",maxlength:32,listeners:{scope:this,change:this.userInputDirectory}}]},Ext.apply(t,e),this.callParent([t])},activate:function(){this.remoteShareEnum(),this.serverNameSet()},checkDirDone:function(e,t){this.owner.clearStatusBusy(),e?this.owner.goNext(this.nextId):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))},checkDir:function(){var e={};e.bkptype=SYNO.SDS.LunBackup.BKPTASK_NETLUN,e.bkpset=this.LUNBackupParam.taskName,e.share=this.getBkpDest(),e.directory=this.getBkpDir(),e=this.owner.LUNPanelDestNet.getParamsVal(e),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"check_dir",params:e,scope:this,callback:this.checkDirDone})},saveSetting:function(){this.LUNBackupParam.directory=this.getBkpDir()},getNext:function(){return!!this.getForm().isValid()&&(this.checkDir(),this.saveSetting(),!1)},summary:function(e){var t={};t=this.owner.LUNPanelDestNet.getParamsVal(t);var s=[String.format("{0}",_T("lunbkp","net_lunbkp")),String.format("{0} : {1}",_T("netbackup","netbkp_slct_server"),String.format(_T("netbackup","synology_server"),_D("company_title"))),String.format("{0} : {1}",_T("netbackup","netbkp_server"),0!==t.server.length?t.server:t.ip),String.format("{0} : {1}",_T("netbackup","netbkp_auth_user"),t.account),String.format("{0} : {1}",_T("lunbkp","dest_shared_folder"),this.getBkpDest()),String.format("{0} : {1}",_T("backup","backup_dest_directory"),this.getBkpDir())];e.append(_T("localbkp","localbkp_dest"),s)},remoteShareEnumDone:function(e,t){this.owner.clearStatusBusy(),e?(this.LUNBackupParam.remoteShareStore.loadData(t.shares,!1),0<this.LUNBackupParam.remoteShareStore.getCount()?(this.getForm().findField("remoteShare").setValue(t.shares[0][0]),this.defaultDirectoryUpdate()):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("ftp","ftp_no_share"))):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))},remoteShareEnum:function(){var e;(e={}).type="lunbkp";var t=0!==(e=this.owner.LUNPanelDestNet.getParamsVal(e)).server.length?e.server:e.ip;0!==t.length&&t!==this.remoteHost&&(this.remoteHost=t,this.owner.setStatusBusy({text:_T("netbackup","netbkp_search_folder")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_remote_share",params:e,scope:this,callback:this.remoteShareEnumDone}))},serverNameSet:function(){var e={};(e=this.owner.LUNPanelDestNet.getParamsVal(e)).server.length?this.getForm().findField("serverInfo").setValue(e.server):e.ip.length&&this.getForm().findField("serverInfo").setValue(e.ip)},userInputDirectory:function(){this.userInputDirectoryFlag=!0},defaultDirectoryUpdate:function(){var e,t;if(!this.userInputDirectoryFlag){e={},(e=this.owner.LUNPanelDestNet.getParamsVal(e)).ssh_enable="0",e.servertype="synology",e.share=this.getBkpDest(),t=this.getForm().findField("destDirectory");var s=this.owner;s.setStatusBusy({text:_T("netbackup","netbkp_wait_server")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"get_remote_dest_dir",params:e,scope:this,callback:function(e,i){s.clearStatusBusy(),e?t.setValue(i.defaultDirectory):s.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))}})}},getBkpDest:function(){return this.getForm().findField("remoteShare").getValue()},getBkpDir:function(){return this.getForm().findField("destDirectory").getValue()}}),Ext.define("SYNO.SDS.Backup.SchedulePanel",{extend:"SYNO.SDS.Backup.TaskNamePanel",isLoaded:!1,advanceScheduleDialog:null,weekArray:null,constructor:function(e){this.weekArray=SYNO.SDS.Backup.Client.Common.Utils.WeekArray;var t=new Ext.data.SimpleStore({fields:["value","display"],data:this.weekArray}),s={title:Ext.util.Format.ellipsis(_T("common","schedule"),15),tabTip:_T("common","schedule"),padding:e.padding,items:[{xtype:"syno_checkbox",boxLabel:_T("netbackup","netbkp_set_schedule"),name:"schedule_enable"},{xtype:"syno_radio",name:"schedule_type",inputValue:"basic",boxLabel:_T("schedule","schedule_basic"),checked:!0,indent:1},{xtype:"syno_compositefield",hideLabel:!0,fieldLabel:"composite field",name:"basic_time",indent:2,items:[{xtype:"syno_displayfield",name:"text_week",value:_T("time","time_day")},{xtype:"syno_combobox",name:"basic_weekday",store:t,displayField:"display",valueField:"value",width:90},{border:!1,width:50},{xtype:"syno_displayfield",name:"text_hour",value:_T("time","time_hour")},{xtype:"syno_combobox",name:"hour",displayField:"display",valueField:"value",store:SYNO.SDS.Backup.createTimeItemStore("hour"),width:70},{border:!1,width:10},{xtype:"syno_displayfield",name:"text_min",value:_T("time","time_minute")},{xtype:"syno_combobox",name:"minute",displayField:"display",valueField:"value",store:SYNO.SDS.Backup.createTimeItemStore("min"),width:70}]},{xtype:"syno_radio",name:"schedule_type",inputValue:"advance",boxLabel:_T("schedule","schedule_advance"),checked:!1,indent:1},{xtype:"syno_button",id:"btn_schedule",name:"btn_schedule",text:_T("schedule","schedule_title"),handler:this.launchScheduleDialog,scope:this,indent:2},{xtype:"syno_displayfield",name:"txtadvscheduletime",labelSeparator:"",value:"",height:"12px",style:"margin-left: 80px"},{xtype:"syno_displayfield",name:"txtadvscheduleday",labelSeparator:"",value:"",height:"12px",style:"margin-left: 80px"}]};Ext.apply(s,e),this.callParent([s]),this.mon(this,"afterlayout",(function(e,t){new SYNO.ux.Utils.EnableCheckGroup(e.getForm(),"schedule_enable",["schedule_type","text_week","basic_weekday","text_hour","hour","text_min","minute","btn_schedule"]),new SYNO.ux.Utils.EnableRadioGroup(e.getForm(),"schedule_type",{basic:["text_week","basic_weekday","text_hour","hour","text_min","minute"],advance:["btn_schedule"]});for(var s=SYNO.ux.Utils.getRadioGroup(e.getForm(),"schedule_type"),i=0;i<s.length;i++){var a=s[i];a.mon(a,"check",this.onScheduleTypeChecked,this)}}),this,{single:!0})},onScheduleTypeChecked:function(e,t){t&&("basic"===e.getInputValue()?(this.getForm().findField("txtadvscheduletime").setValue(""),this.getForm().findField("txtadvscheduleday").setValue("")):this.LUNBackupParam.schedule&&this.advSchedulePrint(this.LUNBackupParam.schedule))},advSchedulePrint:function(e){if(e){var t=this.getForm().findField("txtadvscheduletime"),s=this.getForm().findField("txtadvscheduleday");t.setValue(this.timeScheduleToString(e)),s.setValue(this.dateScheduleToString(e))}},afterScheduleDialog:function(){this.owner.schedule&&(this.LUNBackupParam.schedule=this.deConstructJson(this.owner.schedule),this.advSchedulePrint(this.LUNBackupParam.schedule))},launchScheduleDialogDone:function(e,t){this.advanceScheduleDialog=new SYNO.SDS.TaskScheduler2.ScheduleDialog({title:_T("schedule","schedule_advance"),height:472,owner:this.owner}),this.advanceScheduleDialog.mon(this.advanceScheduleDialog,"hide",this.afterScheduleDialog,this),this.owner.clearStatusBusy(),e?this.advanceScheduleDialog.onOpen(this.reConstructJson(t.task.schedule)):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))},launchScheduleDialog:function(){var e;this.LUNBackupParam.schedule?(this.owner.schedule=this.LUNBackupParam.schedule,(e=new SYNO.SDS.TaskScheduler2.ScheduleDialog({title:_T("schedule","schedule_advance"),height:472,owner:this.owner})).mon(e,"hide",this.afterScheduleDialog,this),e.open(this.reConstructJson(this.LUNBackupParam.schedule))):(this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"load_default_adv_schedule",scope:this,callback:this.launchScheduleDialogDone}))},loadForm:function(e){e&&(this.getForm().loadRecord(e),!1===e.data.schedule_enable?(Ext.getCmp("btn_schedule").disable(),this.getForm().findField("basic_weekday").disable(),this.getForm().findField("hour").disable(),this.getForm().findField("minute").disable(),this.getForm().findField("text_week").disable(),this.getForm().findField("text_hour").disable(),this.getForm().findField("text_min").disable()):"advance"===e.data.schedule_type&&this.LUNBackupParam.schedule&&this.advSchedulePrint(this.LUNBackupParam.schedule))},activate:function(){if(!1===this.isLoaded){this.setDefaultName();var e={},t={};e.schedule_enable=!1,e.schedule_type="basic",e.basic_weekday="1",e.hour=0,e.minute=0,t.data=e,this.loadForm(t),this.isLoaded=!0}},getNext:function(){var e;if(!this.getForm().isValid())return this.owner.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1;if((e=this.getScheduleData()).basic)this.LUNBackupParam.schedule=e.schedule,this.LUNBackupParam.enableschedule=e.enableschedule;else if(this.LUNBackupParam.enableschedule=e.enableschedule,this.LUNBackupParam.enableschedule&&!this.LUNBackupParam.schedule)return this.owner.getMsgBox().alert(_T("netbackup","netbkp_no_schedule"),_T("netbackup","netbkp_no_schedule")),!1;return this.bkpsetConflict(this,(function(){this.owner.goNext(this.nextId)})),!1},summary:function(e){var t,s=this.LUNBackupParam.schedule;this.callParent([e]),this.getForm().findField("schedule_enable").getValue()?(t=this.timeScheduleToString(s)+" "+this.dateScheduleToString(s),e.append(_T("netbackup","netbkp_schedule"),t)):e.append(_T("netbackup","netbkp_schedule"),_T("netbackup","netbkp_no_schedule"))},getScheduleData:function(){var e,t=[],s=this.getForm();if(t.enableschedule=s.findField("schedule_enable").getValue(),t.basic="basic"===s.findField("schedule_type").getGroupValue(),t.basic){var i=s.findField("basic_weekday").getValue(),a=s.findField("hour").getValue(),n=s.findField("minute").getValue();(e={}).date_type=0,e.repeat=0,e.hour=a,e.min=n,e.repeat_hour=0,e.last_work_hour=a,e.week_name=String(i)}else this.LUNBackupParam.schedule?e=this.deConstructJson(this.LUNBackupParam.schedule):((e={}).date_type=0,e.repeat=0,e.hour=0,e.min=0,e.repeat_hour=0,e.last_work_hour=0,e.week_name="0,1,2,3,4,5,6");return t.schedule=e,t},reConstructJson:function(e){var t=e;return void 0===t.minute&&(t.minute=t.min),void 0===t.week_day&&(t.week_day=t.week_name),void 0===t.repeat_date&&(t.repeat_date=t.repeat),t},deConstructJson:function(e){var t=e;return void 0===t.min&&(t.min=t.minute),void 0===t.week_name&&(t.week_name=t.week_day),void 0===t.repeat&&(t.repeat=t.repeat_date),t},dateScheduleToString:function(e){return SYNO.SDS.Backup.Client.Common.Utils.DateScheduleToString(e)},timeScheduleToString:function(e){return SYNO.SDS.Backup.Client.Common.Utils.TimeScheduleToString(e)}}),Ext.define("SYNO.SDS.Backup.SummaryPanel",{extend:"SYNO.SDS.Wizard.SummaryStep",constructor:function(e){return this.callParent([e])},activate:function(){var e=this.owner.stepStack,t=null,s=0;for(this.getStore().removeAll(!0),s=0;s<e.length;s++)t=this.owner.getStep(e[s]),Ext.isFunction(t.summaryFirst)&&t.summaryFirst(this.getStore());for(s=0;s<e.length;s++)t=this.owner.getStep(e[s]),Ext.isFunction(t.summary)&&t.summary(this.getStore());this.getView().refresh()},descRenderer:function(e,t){var s=e;return("string"==typeof s||s instanceof String)&&(s=[s]),s=s.map((function(e){return Ext.util.Format.htmlEncode(e)})).join("<br>"),t.attr='ext:qtip="'+Ext.util.Format.htmlEncode(s)+'"','<span class="wizard-summary-desc">'+s+"</span>"},AppendBackupTypeToSummary:function(e){const t=SYNO.SDS.Backup.String("app","backup_type");if(SYNO.Backup.FeatureSupport.Utils.SupportDataBackupOnly())this.getStore().append(t,SYNO.SDS.Backup.String("app","backup_type_data"));else{var s;switch(e){case"lun":s=SYNO.SDS.Backup.String("app","backup_type_lun");break;case"multi_ver_lun":s=SYNO.SDS.Backup.String("app","backup_type_multiver_lun");break;case"entire_dsm":s=SYNO.SDS.Backup.String("app","backup_type_entire_dsm");break;default:s=SYNO.SDS.Backup.String("app","backup_type_data")}this.getStore().append(t,s)}}}),Ext.define("SYNO.SDS.Backup.TaskCreateWizard",{extend:"SYNO.SDS.Backup.Wizard",wizardAnchor:"",support_app_share:!1,support_detect_time_limit:!1,accountMeta:SYNO.SDS.Backup.Client.Common.Utils.createAccountMeta(),backupType:"data",constructor:function(e){var t=SYNO.Backup.Addon.Config.addon_list;this.LUNBackupData={selfIPs:null,selfHostName:null,taskName:null,taskType:null,taskDest:null,schedule:null,remoteShareStore:null,remoteShare:null,lunSourceList:[],lunSourceStore:null,lunSource:null,lunSourceSize:null,lunSourceType:null,enableschedule:null,bkpDir:null,directory:null},this.LUNMultiVerBackupData={...JSON.parse(JSON.stringify(this.LUNBackupData)),lunSourceUuid:null,lunSourceName:"",lunSourceType:""};var s,i=this;this.BackupTypeSelection=new SYNO.SDS.Backup.BackupTypePanel({owner:this,itemId:"backup_type",headline:SYNO.SDS.Backup.String("app","select_data_type_title")}),this.DataBackupRepoType=new SYNO.SDS.Backup.DataRepoTypePanel({owner:this,itemId:"repo_type",nextId:(s={},Ext.each(t,(function(e,t,i){s[e.id]=e.id+"::data_dest_setting"})),s.rsync="rsync::select_single_or_multiple",s.local="local::select_single_or_multiple",s),headline:SYNO.SDS.Backup.String("app","select_backup_dest")}),this.SelectRsyncType=new SYNO.SDS.Backup.SelectSingleOrMultiplePanel({owner:this,itemId:"rsync::select_single_or_multiple",nextIdFn:function(e){switch(this.select=e,e){case"single":return"legacy_rsync::data_dest_setting";case"multiple":return"rsync::data_dest_setting";default:return e}},getParams:function(){function e(e){return SYNO.Backup.Addon.Config.addon_list.find((function(t){return t.id===e}))}switch(this.select){case"single":return e("legacy_rsync");case"multiple":return e("rsync");default:return SYNO.Debug("unknown selection: "+this.select),{}}},headline:SYNO.SDS.Backup.String("app","select_rsync_single_or_multi")}),this.SelectLocalType=new SYNO.SDS.Backup.SelectSingleOrMultiplePanel({owner:this,itemId:"local::select_single_or_multiple",nextIdFn:function(e){switch(this.select=e,e){case"single":return"legacy_local::data_dest_setting";case"multiple":return"local::data_dest_setting";default:return e}},getParams:function(){function e(e){return SYNO.Backup.Addon.Config.addon_list.find((function(t){return t.id===e}))}switch(this.select){case"single":return e("legacy_local");case"multiple":return e("local");default:return SYNO.Debug("unknown selection: "+this.select),{}}},headline:SYNO.SDS.Backup.String("app","select_local_single_or_multi")}),this.DataBackupNetworkCreate=new SYNO.SDS.Backup.Repository.NetworkCreateStep({owner:this,itemId:"legacy_rsync::dest_folder_setting",nextId:"source_repo_legacy",headline:SYNO.SDS.Backup.String("app","repo_info_wizard_title")}),this.DataBackupSourceRepoLegacy=new SYNO.SDS.Backup.TaskSourceContainerWrapper({owner:this,appWin:e.appWin,itemId:"source_repo_legacy",isImage:!1,pre_load_folder_done:!0,nextId:"app",headline:SYNO.SDS.Backup.String("app","source_share_wizard_title")}),this.DataBackupSourceRepoImage=new SYNO.SDS.Backup.TaskSourceContainerWrapper({owner:this,appWin:e.appWin,itemId:"source_repo_image",isImage:!0,pre_load_folder_done:!0,nextId:"app",headline:SYNO.SDS.Backup.String("app","source_share_wizard_title")}),this.DataBackupApp=new SYNO.SDS.Backup.AppParamsPanel({owner:this,appWin:e.appWin,itemId:"app",headline:SYNO.SDS.Backup.String("app","source_pkg_wizard_title"),bodyStyle:"max-height: 373px; min-height: 373px",nextId:function(){var e={};return Ext.each(t,(function(t,s,i){var a=t.target_type+":"+t.transfer_type;e[a]=t.id+":"+t.target_type+":data_task_setting"})),e}()}),this.DataBackupRotation=new SYNO.SDS.Backup.RotationParamsPanel({owner:this,appWin:e.appWin,itemId:"data_rotate",headline:_T("backup","backup_rotation_settings"),nextId:"data_summary"}),this.DataBackupSummary=new SYNO.SDS.Backup.SummaryPanel({owner:this,autoScroll:!0,headline:SYNO.SDS.Backup.String("app","summary"),itemId:"data_summary",nextId:null,getNext:function(){return this.owner.initializeTask(),!1}}),this.LUNPanelDestType=new SYNO.SDS.Backup.LUNDestTypePanel({owner:this,headline:SYNO.SDS.Backup.String("app","select_backup_dest"),itemId:"desttype",nextIdFn:function(e){switch(e){case"remote":return i.LUNBackupData.taskType=SYNO.SDS.LunBackup.BKPTASK_NETLUN,"destnet";case"local":return i.LUNBackupData.taskType=SYNO.SDS.LunBackup.BKPTASK_LOCLUN,"destlocal";default:return e}}}),this.LUNPanelDestLocal=new SYNO.SDS.Backup.LUNDestLocalPanel({owner:this,itemId:"destlocal",nextId:"lunsource",headline:_T("localbkpwizard","select_dest_title"),LUNBackupParam:this.LUNBackupData}),this.LUNPanelDestNet=new SYNO.SDS.Backup.LUNDestNetPanel({owner:this,itemId:"destnet",nextId:"destshare",headline:_T("netbackup","netbkp_serverset_title"),LUNBackupParam:this.LUNBackupData}),this.LUNPanelDestShare=new SYNO.SDS.Backup.LUNDestSharePanel({owner:this,headline:_T("netbackup","dest_share_title"),itemId:"destshare",nextId:"lunsource",LUNBackupParam:this.LUNBackupData}),this.LUNPanelLUNSource=new SYNO.SDS.Backup.LUNSourcePanel({owner:this,headline:_T("lunbkp","select_lun_title"),itemId:"lunsource",nextId:"schedule",LUNBackupParam:this.LUNBackupData}),this.LUNPanelSchedule=new SYNO.SDS.Backup.SchedulePanel({owner:this,headline:_T("usbbackup","usbbkp_schedule_desc1"),itemId:"schedule",nextId:"lun_summary",padding:"24px 0 0 0",LUNBackupParam:this.LUNBackupData}),this.LUNPanelSummary=new SYNO.SDS.Backup.SummaryPanel({owner:this,autoScroll:!0,headline:_T("localbkpwizard","summary_title"),itemId:"lun_summary",nextId:null,getNext:function(){return this.owner.sendLUNRequest(),!1}}),this.DSMBackupRepoType=new SYNO.SDS.Backup.EntireDSMRepoTypePanel({owner:this,itemId:"dsm_repo_type",nextId:function(){var e={};return Ext.each(t,(function(t){e[t.id]=t.id+"::entire_dsm_dest_setting"})),e}(),headline:SYNO.SDS.Backup.String("app","select_backup_dest")}),this.DSMBackupRotation=new SYNO.SDS.Backup.RotationParamsPanel({owner:this,appWin:e.appWin,itemId:"dsm_rotate",headline:_T("backup","backup_rotation_settings"),nextId:"dsm_summary"}),this.DSMBackupSummary=new SYNO.SDS.Backup.SummaryPanel({owner:this,autoScroll:!0,headline:SYNO.SDS.Backup.String("app","summary"),itemId:"dsm_summary",nextId:null,getNext:function(){return this.owner.sendEntireDSMRequest(),!1}}),this.LUNMultiVerBackupRepoType=new SYNO.SDS.Backup.LUNMultiVerRepoTypePanel({owner:this,itemId:"multi_ver_lun_repo_type",nextId:function(){var e={};return Ext.each(t,(function(t){e[t.id]=t.id+"::multi_ver_lun_dest_setting"})),e}(),headline:SYNO.SDS.Backup.String("app","select_backup_dest")}),this.LUNMultiVerBackupSource=new SYNO.SDS.Backup.LUNMultiVerSourcePanel({owner:this,headline:_T("lunbkp","select_lun_title"),itemId:"multi_ver_lun_source",nextId:SYNO.SDS.Backup.Util.getDataTaskSettingOptionsForLunMultiVerBackup(),LUNBackupParam:this.LUNMultiVerBackupData}),this.LUNMultiVerBackupRotation=new SYNO.SDS.Backup.RotationParamsPanel({owner:this,appWin:e.appWin,itemId:"multi_ver_lun_rotate",headline:_T("backup","backup_rotation_settings"),nextId:"multi_ver_lun_summary"}),this.LUNMultiVerBackupSummary=new SYNO.SDS.Backup.SummaryPanel({owner:this,autoScroll:!0,headline:SYNO.SDS.Backup.String("app","summary"),itemId:"multi_ver_lun_summary",nextId:null,getNext:function(){return this.owner.sendLunMultiVerBackupRequest(),!1}});var a=[this.BackupTypeSelection,this.DataBackupRepoType,this.SelectRsyncType,this.SelectLocalType,this.DataBackupNetworkCreate,this.DataBackupSourceRepoLegacy,this.DataBackupSourceRepoImage,this.DataBackupApp,this.DataBackupRotation,this.DataBackupSummary,this.LUNPanelDestType,this.LUNPanelDestLocal,this.LUNPanelDestNet,this.LUNPanelDestShare,this.LUNPanelLUNSource,this.LUNPanelSchedule,this.LUNPanelSummary,this.DSMBackupRepoType,this.DSMBackupRotation,this.DSMBackupSummary,this.LUNMultiVerBackupRepoType,this.LUNMultiVerBackupSource,this.LUNMultiVerBackupRotation,this.LUNMultiVerBackupSummary],n=Ext.apply({title:_T("bkpwizard","wizard_title"),cls:"syno-backup-create-wizard",banner:!0,width:700,height:580,steps:a},e);this.callParent([n]),_S("is_admin")&&SYNO.SDS.LunBackup.getLocalIPs(this,(function(e,t){e&&(this.LUNBackupData.selfIPs=t.selfIPs,this.LUNBackupData.selfHostName=t.selfHostName)}))},createStep:function(e){var t=e.split(":")[0],s=e.split(":")[2],i=null,a=SYNO.Backup.Addon.Util.getInfo(t);if(["data_dest_setting","entire_dsm_dest_setting","multi_ver_lun_dest_setting"].includes(s)){var n=SYNO.Backup.Addon.Util.getClass(t,"Destination.SettingPanel");if(n){var r=SYNO.Backup.Util.IsImage(a.target_type)?"source_repo_image":"source_repo_legacy",o={appWin:this.appWin,owner:this,cls:"syno-backup-base-destination-setting",itemId:e,target_type:a.target_type,transfer_type:a.transfer_type,nextId:a.options.dest_setting_nextId?a.options.dest_setting_nextId:r,headline:SYNO.SDS.Backup.String("app","repo_info_wizard_title"),description:SYNO.SDS.Backup.String("app","repo_info_wizard_desc")};"entire_dsm_dest_setting"===s&&(o.nextId=a.id+":"+a.target_type+":entire_dsm_task_setting",o.supportExport=!1),"multi_ver_lun_dest_setting"===s&&(o.nextId="multi_ver_lun_source",o.supportExport=!1),i=new n(o)}}else if(["data_task_setting","entire_dsm_task_setting","multi_ver_lun_task_setting"].includes(s)){const n=e=>{switch(e){case"entire_dsm_task_setting":return"dsm_rotate";case"multi_ver_lun_task_setting":return"multi_ver_lun_rotate";default:return"data_rotate"}};var c=SYNO.Backup.Addon.Util.getClass(t,"Task.SettingPanel");let r={appWin:this.appWin,owner:this,isEntireDSMOrLUNMultiVerTask:["entire_dsm_task_setting","multi_ver_lun_task_setting"].includes(s),itemId:e,target_type:a.target_type,transfer_type:a.transfer_type,nextId:n(s),headline:_T("backup","backup_settings")};"entire_dsm_task_setting"!==s||"remote"!==a.id&&"synocloud"!==a.id||(r.disableAutoUnmount=!0,r.hideAutoUnmount=!0),c&&(i=new c(r))}return i},initializeTask:function(){var e=this.getActiveStep();if(!e||Ext.isFunction(e.isValid)&&!e.isValid())return!1;var t=this.getParams();this.setStatusBusy(),t.repo_id?this.createTask(t):("image_remote"===t.transfer_type&&delete t.enc_port,"export"===t.action&&("image_remote"===t.transfer_type?t.transfer_type="image_local":t.transfer_type="local",t.account=_S("user")),t.name=t.repo_name,delete t.backup_params.encrypt_password,delete t.backup_params.encrypt_password_confirm,delete t.clientEncrypt,this.sendWebAPI({api:"SYNO.Backup.Repository",version:1,method:"create",encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret"],t),params:t,callback:this.onCreateRepoDone,scope:this}))},onCreateRepoDone:function(e,t,s){if(!e||t.has_fail)return this.reportError(t),void this.clearStatusBusy();var i=this.getParams();Ext.apply(i,{repo_id:t.repo_id}),"export"===i.action&&(i.transfer_type="local"),this.createTask(i,i.action)},getRepoInfo:function(){return this.getParams()},getSourceSelector:function(){var e=SYNO.Backup.Util.IsImage(this.getParams().target_type)?"source_repo_image":"source_repo_legacy";return this.getStep(e).getSourceSelector()},getAppPanel:function(){return this.getStep("app")},loadAppParams:function(){this.getAppPanel().setAppCheckList(this.getAppPanel().getAppList()),this.getAppPanel().setAppLastConfig(this.getAppPanel().getAppConfig()),this.getAppPanel().loadStore(this.support_app_share)},doIfAppShareReady:function(e){this[e]=!0,this.app_loaded&&this.folder_loaded&&this.folder_initialed&&SYNO.SDS.Backup.setAppGridDependency(this.getAppPanel(),this.getSourceSelector(),!0,!1)},createTask:function(e){var t={app_list:Ext.isEmpty(e.app_list)?[]:e.app_list,file_list:Ext.isEmpty(e.file_list)?[]:e.file_list,app_config:Ext.isEmpty(e.app_config)?[]:e.app_config};SYNO.Backup.Util.IsImage(e.target_type)&&(t.backup_filter=e.backup_filter,t.backup_volumes=Ext.isEmpty(e.backup_volumes)?[]:e.backup_volumes);var s=Ext.apply({name:e.name,source:t},e);delete s.app_list,delete s.file_list,delete s.app_config,delete s.backup_filter,delete s.backup_volumes,delete s.clientEncrypt,this.data_enc&&(s.backup_params.enable_data_encrypt=!0),this.data_comp&&(s.backup_params.enable_data_compress=!0),"relink"!==s.action||Ext.isEmpty(this.sess_id)||Ext.apply(s,{sess_id:this.sess_id}),Ext.isEmpty(s.backup_params.encrypt_password)||(s.encrypt_password=s.backup_params.encrypt_password),delete s.backup_params.encrypt_password,delete s.backup_params.encrypt_password_confirm,this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"create",encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","encrypt_password"],s),params:s,timeout:6e5,callback:this.onCreateTaskDone,scope:this})},downloadPrivateKey:function(e,t,s){this.findAppWindow().downloadWebAPI({webapi:{api:"SYNO.Backup.Target",version:1,method:"private_key_download_by_password",params:{task_id:e,password:t,file_name:s,support_utf8_name:Ext.isChrome||Ext.isGecko||Ext.isSafari},encryption:["password"]}})},onCreateTaskDone:function(e,t,s){if(!e)return this.clearStatusBusy(),void this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===t.code&&this.close()}),this);var i=this.getParams();this.callbacks&&this.callbacks.apply&&this.callbacks.apply.call(this.callbacks.scope||window,t,s),Ext.isEmpty(i.backup_params.encrypt_password)||this.downloadPrivateKey(t.task_id,i.backup_params.encrypt_password,s.name),this.owner.onTaskCreated(t.task_id,(function(){if("create"===i.action||"export"===i.action){var e="";"create"===i.action?e=SYNO.SDS.Backup.String("app","backup_now_confirm"):"export"===i.action&&(e=SYNO.SDS.Backup.String("app","export_now_confirm_dont_change_target_name")),this.getMsgBox().confirm(_T("tree","leaf_backup"),e,(function(e){"yes"===e&&this.appWin.getActivePage().onBackupNow(),this.clearStatusBusy(),this.close()}),this)}else this.clearStatusBusy(),this.close()}),this)},createTaskDefaultName:function(e){for(var t=1;!this.isTaskNameValid(e+" "+t);)t++;return e+" "+t},isTaskNameValid:function(e){return-1===this.owner.getTaskNameList().indexOf(e)},setDestFolderName:function(e,t,s){var i;if("local"===s)i=this.getStep("legacy_local:share:data_task_setting").getForm();else if("rsync"===s)i=this.getStep("legacy_rsync:share:data_task_setting").getForm();else if("rsync_ds"===s)i=this.getStep("legacy_rsync_ds:share:data_task_setting").getForm();else if("aws_s3"===s)i=this.getStep("legacy_aws_s3:cloud:data_task_setting").getForm();else if("azure_blob"===s)i=this.getStep("legacy_azure_blob:cloud:data_task_setting").getForm();else if("sfr_s3"===s)i=this.getStep("legacy_sfr_s3:cloud:data_task_setting").getForm();else{if("hicloud_s3"!==s)return;i=this.getStep("legacy_hicloud_s3:cloud:data_task_setting").getForm()}var a=t+":"+s;i.findField("task_dir").getValue()&&this.choosedType===a||(this.choosedType=a,i.findField("task_dir").setValue(e))},getLocalRepoVolume:function(){var e;e=this.lastStepId?this.stepStack.concat([this.lastStepId]):this.stepStack;var t=null;return Ext.each(e,(function(e){var s=this.getStep(e);if(Ext.isFunction(s.getLocalRepoVolume)&&(t=this.getStep(e).getLocalRepoVolume()))return!1}),this),t},reportError:function(e,t){t=t||{},this.reporter||(this.reporter=new SYNO.SDS.Backup.ApiHelper({owner:this})),this.reporter.alert(e,t.callback,t.scope)},genLUNRequestParams:function(){var e={mode:"create",oldbkpset:""};return e.newbkpset=this.LUNBackupData.taskName,e.bkptype=this.LUNBackupData.taskType,e.lunsource=this.LUNBackupData.lunSource,e.lunsize=this.LUNBackupData.lunSourceSize,e.scheduleEnable=this.LUNBackupData.enableschedule,e.schedule=this.LUNBackupData.schedule,SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.LUNBackupData.taskType?(e.dest=this.LUNBackupData.taskDest,e.desttype=SYNO.SDS.LunBackup.BKP_DEST_TYPE_LOCLUN):(e.servertype=SYNO.SDS.Backup.BKP_DEST_TYPE_SYNO,(e=this.LUNPanelDestNet.getParamsVal(e,"create")).dest=this.LUNPanelDestShare.getBkpDest()+"/"+this.LUNBackupData.directory,this.LUNPanelDestNet.getParamsVal(e)),e},sendLUNRequest:function(){var e=this.genLUNRequestParams();this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",method:"apply_lun",version:1,params:e,scope:this,callback:function(e,t){e?this.owner.onLunTaskCreated(this.LUNBackupData.taskName,(function(){var e=SYNO.SDS.Backup.String("app","backup_now_confirm");this.getMsgBox().confirm(_T("tree","leaf_backup"),e,(function(e){"yes"===e&&this.appWin.getActivePage().onBackupNow(),this.clearStatusBusy(),this.close()}),this)}),this):(this.clearStatusBusy(),null!==t&&null!==t.err_type&&"dir_in_used"===t.err_type?this.getMsgBox().alert(_T("tree","leaf_backup"),_T("backup","backup_dest_directory_not_available")):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","commfail")))}})},sendEntireDSMRequest:function(){var e=this.getParams();return this.setStatusBusy(),delete e.backup_params.encrypt_password,delete e.backup_params.encrypt_password_confirm,delete e.clientEncrypt,this.sendWebAPI({api:"SYNO.Backup.Repository",version:1,method:"create",encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret"],e),params:e,callback:this.onCreateEntireDSMRepoDone,scope:this}),!1},onCreateEntireDSMRepoDone:function(e,t){if(!e||t.has_fail)return this.reportError(t),void this.clearStatusBusy();var s=this.getParams();Ext.apply(s,{repo_id:t.repo_id}),this.createEntireDSMTask(s)},createEntireDSMTask:function(e){var t={app_list:[],file_list:[],app_config:[]};SYNO.Backup.Util.IsImage(e.target_type)&&(t.backup_filter={whitelist:[],exclude_list:[]},t.backup_volumes=[]);var s=Ext.apply({name:e.name,source:t},e);delete s.app_list,delete s.file_list,delete s.app_config,delete s.backup_filter,delete s.backup_volumes,delete s.clientEncrypt,this.data_enc&&(s.backup_params.enable_data_encrypt=!0),this.data_comp&&(s.backup_params.enable_data_compress=!0),"relink"!==s.action||Ext.isEmpty(this.sess_id)||Ext.apply(s,{sess_id:this.sess_id}),Ext.isEmpty(s.backup_params.encrypt_password)||(s.encrypt_password=s.backup_params.encrypt_password),delete s.backup_params.encrypt_password,delete s.backup_params.encrypt_password_confirm,s.is_full_dsm_backup=!0,this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"create",encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","encrypt_password"],s),params:s,timeout:6e5,callback:this.onCreateEntireDSMTaskDone,scope:this})},onCreateEntireDSMTaskDone:function(e,t,s){if(!e)return this.clearStatusBusy(),void this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===t.code&&this.close()}),this);var i=this.getParams();this.callbacks&&this.callbacks.apply&&this.callbacks.apply.call(this.callbacks.scope||window,t,s),Ext.isEmpty(i.backup_params.encrypt_password)||this.downloadPrivateKey(t.task_id,i.backup_params.encrypt_password,s.name);var a=t.reboot_is_needed_before_backup;this.owner.onTaskCreated(t.task_id,(function(){if("create"!==i.action)return this.clearStatusBusy(),void this.close();if(a){var e=SYNO.SDS.Backup.String("app","desc_confirm_reboot_for_backup");this.getMsgBox().confirm("",e,(function(e){"yes"===e&&SYNO.SDS.System.Reboot(),this.clearStatusBusy(),this.close()}),this)}else this.getMsgBox().confirm(_T("tree","leaf_backup"),SYNO.SDS.Backup.String("app","backup_now_confirm"),(function(e){"yes"===e&&this.appWin.getActivePage().onBackupNow(),this.clearStatusBusy(),this.close()}),this)}),this)},sendLunMultiVerBackupRequest:function(){var e=this.getParams();return this.setStatusBusy(),delete e.backup_params.encrypt_password,delete e.backup_params.encrypt_password_confirm,delete e.clientEncrypt,this.sendWebAPI({api:"SYNO.Backup.Repository",version:1,method:"create",encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret"],e),params:e,callback:this.onCreateLunMultiVerBackupRepoDone,scope:this}),!1},onCreateLunMultiVerBackupRepoDone:function(e,t){if(!e||t.has_fail)return this.reportError(t),void this.clearStatusBusy();var s=this.getParams();Ext.apply(s,{repo_id:t.repo_id}),this.createLunMultiVerBackupTask(s)},createLunMultiVerBackupTask:function(e){var t={app_list:[],file_list:[],app_config:[]};SYNO.Backup.Util.IsImage(e.target_type)&&(t.backup_filter={whitelist:[],exclude_list:[]},t.backup_volumes=[]);var s=Ext.apply({name:e.name,source:t},e);delete s.app_list,delete s.file_list,delete s.app_config,delete s.backup_filter,delete s.backup_volumes,delete s.clientEncrypt,this.data_enc&&(s.backup_params.enable_data_encrypt=!0),this.data_comp&&(s.backup_params.enable_data_compress=!0),"relink"!==s.action||Ext.isEmpty(this.sess_id)||Ext.apply(s,{sess_id:this.sess_id}),Ext.isEmpty(s.backup_params.encrypt_password)||(s.encrypt_password=s.backup_params.encrypt_password),delete s.backup_params.encrypt_password,delete s.backup_params.encrypt_password_confirm,s.is_multi_ver_lun=!0,"relink"===s.action||(s.source.lun_uuid=this.LUNMultiVerBackupData.lunSourceUuid,s.source.lun_name=this.LUNMultiVerBackupData.lunSourceName,s.source.lun_type=this.LUNMultiVerBackupData.lunSourceType),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"create",encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","encrypt_password"],s),params:s,timeout:6e5,callback:this.onLunMultiVerBackupTaskDone,scope:this})},onLunMultiVerBackupTaskDone:function(e,t,s){if(!e)return this.clearStatusBusy(),void this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===t.code&&this.close()}),this);var i=this.getParams();this.callbacks&&this.callbacks.apply&&this.callbacks.apply.call(this.callbacks.scope||window,t,s),Ext.isEmpty(i.backup_params.encrypt_password)||this.downloadPrivateKey(t.task_id,i.backup_params.encrypt_password,s.name),this.owner.onTaskCreated(t.task_id,(function(){if("create"!==i.action)return this.clearStatusBusy(),void this.close();this.getMsgBox().confirm(_T("tree","leaf_backup"),SYNO.SDS.Backup.String("app","backup_now_confirm"),(function(e){"yes"===e&&this.appWin.getActivePage().onBackupNow(),this.clearStatusBusy(),this.close()}),this)}),this)}}),SYNO.SDS.Backup.Util.getDataTaskSettingOptionsForLunMultiVerBackup=(()=>{let e;return()=>(e||(e={},Ext.each(SYNO.Backup.Addon.Config.addon_list,(function(t,s,i){var a=t.target_type+":"+t.transfer_type;e[a]=t.id+":"+t.target_type+":multi_ver_lun_task_setting"}))),e)})(),Ext.define("SYNO.SDS.Backup.Restore.RestoreListView",{extend:"SYNO.ux.ExpandableListView",constructor:function(e){this.callParent(arguments),this.addClass("syno-backup-restore-progress-listview")},createTpl:function(){return new Ext.XTemplate('<tpl for="."><div class="item-wrap"><div class="item-summary"><div class="item-icon {icon_cls} icon-task" style="{style}"></div><div><span class="item-title">{display_name:htmlEncode}</span><tpl if="version != null && version != \'\'"><span class="version-text"> ({version:htmlEncode}) </span></tpl><div class="status-wrapper '+this.getStatusStyle()+'">{status_str}</div></div></div></div></tpl><div class="x-clear"></div>')},checkShowFn:function(e){return 0<this.getStore().getCount()},mapDisplayName:function(e){var t={system_config:_T("confbackup","config"),shared_folder:_T("backup","data"),app:SYNO.SDS.Backup.String("app","application_install_update")};"app"===e.stage&&"app_install_update"!==e.id?e.display_name=e.display_name:e.stage in t?e.display_name=t[e.stage]:e.display_name=e.stage},mapStatusStr:function(e){"done"===e.status?(e.status_str=_T("backup","restore_success"),e.status_class="green-status"):"waiting"===e.status?(e.status_str=_T("netbackup","netbkp_wait_sync"),e.status_class="disable-font"):"failed"===e.status?(e.status_str=_T("backup","restore_fail"),e.status_class="red-status"):"cancel"===e.status?(e.status_str=_T("usbbackup","usbbkp_cancel"),e.status_class="red-status"):"partial"===e.status?(e.status_str=_T("backup","status_partial"),e.status_class="orange-status"):"canceling"===e.status&&(e.status_str=_T("backup","restore_do_cancel"),e.status_class="red-status")},getStatusStyle:function(){},prepareData:function(e,t,s){}}),Ext.define("SYNO.SDS.Backup.Restore.ProgressView",{extend:"SYNO.SDS.Backup.Restore.RestoreListView",WINDOW_SIZE:5,constructor:function(e){this.transSizeBuf=[],this.callParent(arguments)},createTpl:function(){return new Ext.XTemplate('<tpl for=".">','<div class="item-wrap">','<div class="item-summary">','<div class="item-icon {icon_cls} icon-task" style="{style}"></div>','<div class="item-wrapper">','<span class="item-title">{display_name:htmlEncode}</span><tpl if="version != null && version != \'\'"><span class="version-text"> ({version:htmlEncode}) </span></tpl>','<div class="status-wrapper {status_class}">{status_str}</div>',"</div>",'<tpl if="has_progress">','<div class="syno-backup-usage" ext:qtip="{tran_speed}"><div class="syno-backup-percentage-bar-bg"><div class="syno-backup-percentage-bar" style="width:{percentage * 1.87}px"></div></div><span class="blue-status percentage-text" ext:qtip="{tran_speed}">{progress_left}</span><span class="percentage-text percentage-denominator">{progress_right}</span></div>',"</tpl>","</div>","</div>","</tpl>",'<div class="x-clear"></div>')},calTranSpeed:function(e){var t=this.transSizeBuf,s=parseInt(e.get("processed_size"),10);if(t.length>0&&t[0].tran_size>s&&(t.length=0),t.unshift({tran_size:s,tran_time:(new Date).getTime()}),t.length>this.WINDOW_SIZE&&t.pop(),t.length>1){var i=1e3*(t[0].tran_size-t[t.length-1].tran_size);if(i>=0){var a=i/(t[0].tran_time-t[t.length-1].tran_time);e.data.tran_speed=SYNO.SDS.Backup.ConverSize(a,2)+"/s"}else e.data.tran_speed=""}else e.data.tran_speed=""},appStatusStringGet:function(e,t){var s;return s="install"===t?"installing_something":"reinstall"===t?"reinstalling_something":"upgrade"===t?"upgrading_something":"restoring_something",String.format(_T("backup",s),e)},prepareData:function(e,t,s){if(e.icon_cls="",e.style="",e.status_str="",this.mapStatusStr(e),""===e.status_str&&("app"===e.stage?"app_install_update"===e.id?e.status_str=this.appStatusStringGet(e.current_object_name,e.current_object_status):e.hasOwnProperty("percentage")?(e.app_stage=e.app_stage?e.app_stage:"",e.progress_left=SYNO.SDS.Backup.ConverSize(e.processed_size,2),0<e.percentage?e.progress_right="&nbsp;("+e.percentage+"%)":e.progress_right="",Ext.isEmpty(e.app_stage)?e.status_str=_T("backup","restoring"):e.status_str=String.format(SYNO.SDS.Backup.String("app","restoring_app_something"),e.app_stage)):e.status_str=_T("backup","restoring"):"shared_folder"===e.stage?"0"!==e.total_size?(this.calTranSpeed(s),e.progress_left=SYNO.SDS.Backup.ConverSize(e.processed_size,2),e.progress_right="&nbsp;/&nbsp;"+SYNO.SDS.Backup.ConverSize(e.total_size,2),e.current_object_name?e.status_str=String.format(_T("backup","restoring_something"),e.current_object_name):e.status_str=_T("backup","restoring")):e.status_str=_T("backup","restoring"):"system_config"===e.stage&&(e.progress_left=e.percentage+"%","initializing"===e.current_object_id?e.status_str=_T("confbackup","confbkp_st_init"):"stopping_system_service"===e.current_object_id?e.status_str=_T("confbackup","confbkp_st_service_stop"):"starting_system_service"===e.current_object_id?e.status_str=_T("confbackup","confbkp_st_service_start"):e.current_object_name?e.status_str=String.format(_T("backup","restoring_something"),SYNO.SDS.Backup.converLanString(e.current_object_name)):e.status_str=_T("backup","restoring")),e.status_class="blue-status"),e.has_progress=!!e.progress_left,this.mapDisplayName(e),"app"!==e.stage||"app_install_update"===e.id)e.icon_cls="syno-backup-restore-progress-"+e.stage;else{var i=SYNO.SDS.Backup.getAppIconPath(e.id,e.version);e.style="background-size: cover; background-image:url("+i+")"}return e}}),Ext.define("SYNO.SDS.Backup.Restore.SuccessStageView",{extend:"SYNO.SDS.Backup.Restore.RestoreListView",getStatusStyle:function(){return"green-status"},prepareData:function(e,t,s){if(e.icon_cls="",e.style="",e.version||(e.version=null),e.status_str=_T("backup","restore_success"),this.mapDisplayName(e),"app"!==e.stage||"app_install_update"===e.id)e.icon_cls="syno-backup-restore-progress-"+e.stage;else{var i=SYNO.SDS.Backup.getAppIconPath(e.id,e.version);e.style="background-size: cover; background-image:url("+i+")"}return e}}),Ext.define("SYNO.SDS.Backup.Restore.IssueStageView",{extend:"SYNO.SDS.Backup.Restore.RestoreListView",getStatusStyle:function(){return"red-status"},prepareData:function(e,t,s){if(e.icon_cls="",e.style="",e.version||(e.version=null),e.error_code||e.error_string?e.status_str=SYNO.SDS.Backup.convertAppError(e.error_code,e.error_string):this.mapStatusStr(e),this.mapDisplayName(e),"app"!==e.stage||"app_install_update"===e.id)e.icon_cls="syno-backup-restore-progress-"+e.stage;else{var i=SYNO.SDS.Backup.getAppIconPath(e.id,e.version);e.style="background-size: cover; background-image:url("+i+")"}return e}}),Ext.define("SYNO.SDS.Backup.Restore.ProgressPanel",{extend:"SYNO.ux.Panel",constructor:function(e){e=this.fillConfig(e),this.callParent([e])},initEvents:function(){this.on("afterrender",this.startPolling,this),this.on("beforeclose",this.stopPolling,this)},fillConfig:function(e){return Ext.apply({items:[this.processingFieldSet=new SYNO.ux.FieldSet({title:_T("backup","restore_progress"),items:[this.getProcessingView()]}),this.issueFieldSet=new SYNO.ux.FieldSet({title:SYNO.SDS.Backup.String("app","restoration_issue_title"),items:[this.getIssueView()],hidden:!0}),this.successFieldSet=new SYNO.ux.FieldSet({title:SYNO.SDS.Backup.String("app","success_restoration"),items:[this.getSuccessView()],hidden:!0})]},e)},startPolling:function(){this.pollingID=this.pollReg({webapi:{api:"SYNO.Backup.Restore",version:1,method:"status",params:{restore_id:this.owner.restore_id}},interval:2,immediate:!0,scope:this,status_callback:this.onPollingDone})},stopPolling:function(){this.pollUnreg(this.pollingID)},setCancelStatus:function(e){this.isCanceling=!0;var t=[];Ext.each(this.getProcessingStore().data.items,(function(s){var i={};i.stage=s.data.stage,i.stage!==e||s.data.status&&"waiting"!==s.data.status&&"restoring"!==s.data.status||(i.status="canceling"),Ext.applyIf(i,s.data),t.push(i)})),this.loadDataAndDecideShow(this.processingFieldSet,t)},onPollingDone:function(e,t,s,i){if(e)if(-1===this.owner.restore_id&&(this.owner.restore_id=t.restore_id,this.stopPolling(),this.startPolling()),"init"===t.current_stage||"system_config"===t.current_stage||"none"===t.current_stage||this.isCanceling?this.owner.getButton("cancel").disable():!0===_S("is_admin")&&this.owner.getButton("cancel").enable(),t.processing_stage){if(t.finish){this.owner.getButton("ok").enable(),this.owner.getButton("cancel").disable(),this.loadDataAndDecideShow(this.issueFieldSet,t.issue_stage);t.success_stage&&t.success_stage.some((function(e){return"app"===e.stage}))&&SYNO.SDS.StatusNotifier.fireEvent("thirdpartychanged"),this.stopPolling(),Ext.isDefined(t.init_error_code)&&this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.init_error_code),(function(){this.owner.close()}),this)}else if(this.isCanceling)return;t.finish||"success"!==t.current_stage?this.owner.clearStatusBusy():0===this.owner.maskCnt&&this.owner.setStatusBusy(),this.view.setHeight(10+50*t.processing_stage.length),this.processingFieldSet.setVisible(!0),this.loadDataAndDecideShow(this.processingFieldSet,t.processing_stage),this.loadDataAndDecideShow(this.issueFieldSet,t.issue_stage),this.loadDataAndDecideShow(this.successFieldSet,t.success_stage)}else 0===this.owner.maskCnt&&this.owner.setStatusBusy()},loadDataAndDecideShow:function(e,t){if(e&&t){var s=e.getComponent("viewWrapper");s.getStore()&&(s.getStore().loadData(t),s.checkShowFn()?(e.show(),e.setHeight(36+59*t.length)):e.hide(),this.owner.doLayout())}},getProcessingStore:function(){return this.store||(this.store=new Ext.data.JsonStore({id:"id",fields:["id","stage","status","percentage","total_size","processed_size","current_object_id","current_object_name","current_object_status","version","display_name","app_stage"]})),this.store},getSuccessStore:function(){return this.successStore||(this.successStore=new Ext.data.JsonStore({id:"id",fields:["id","status","display_name","version","stage"]})),this.successStore},getIssueStore:function(){return this.issueStore||(this.issueStore=new Ext.data.JsonStore({id:"id",fields:["id","version","err","display_name","error_code","error_string","stage","status"]})),this.issueStore},getProcessingView:function(e){if(!this.view){var t={itemId:"viewWrapper",store:this.getProcessingStore(),owner:this,autoFlexcroll:!1,appRestoreList:e};this.view=new SYNO.SDS.Backup.Restore.ProgressView(t)}return this.view},getSuccessView:function(){if(!this.successView){var e={itemId:"viewWrapper",store:this.getSuccessStore(),owner:this,autoFlexcroll:!1};this.successView=new SYNO.SDS.Backup.Restore.SuccessStageView(e)}return this.successView},getIssueView:function(){if(!this.issueView){var e={itemId:"viewWrapper",store:this.getIssueStore(),owner:this,autoFlexcroll:!1};this.issueView=new SYNO.SDS.Backup.Restore.IssueStageView(e)}return this.issueView}}),Ext.define("SYNO.SDS.Backup.Restore.ProgressWindow",{extend:"SYNO.SDS.ModalWindow",dsmStyle:"v5",constructor:function(e){Ext.copyTo(this,e,"owner");var t=Ext.apply({resizable:!1,banner:!1,layout:"fit",width:680,height:580,cls:"syno-backup-restore-progress-window",title:SYNO.SDS.Backup.String("app","restore"),items:[this.wrapPanel=new SYNO.ux.Panel({autoFlexcroll:!0,items:[this.progressPanel=new SYNO.SDS.Backup.Restore.ProgressPanel({owner:this})]})],buttons:[{xtype:"syno_button",itemId:"cancel",disabled:!0,text:_T("common","cancel"),scope:this,handler:function(){this.getMsgBox().confirm(_T("tree","leaf_backup"),_T("backup","restore_cancel_confirm"),(function(e){"yes"===e&&this.onRestoreCancel()}),this)}},{xtype:"syno_button",itemId:"ok",btnStyle:"blue",disabled:!0,text:_T("common","ok"),btnStle:"blue",scope:this,handler:this.close}]},e);this.callParent([t])},getButton:function(e){return this.getFooterToolbar().getComponent(e)},onRestoreCancel:function(){this.getButton("cancel").disable(),this.setStatusBusy(),this.progressPanel.stopPolling(),this.sendWebAPI({api:"SYNO.Backup.Restore",version:1,method:"cancel",scope:this,callback:function(e,t,s){this.clearStatusBusy(),e?(this.progressPanel.setCancelStatus(t.current_stage),this.progressPanel.startPolling()):this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code))}})}}),Ext.define("SYNO.SDS.Backup.Restore.MultiVerLunProgressView",{extend:"SYNO.ux.ExpandableListView",constructor:function(e){this.callParent(arguments),this.addClass("syno-backup-restore-progress-listview")},createTpl:function(){return new Ext.XTemplate('<tpl for=".">','<div class="item-wrap" style="margin-top:16px; margin-left:20px; margin-right:20px">','<div class="item-summary">','<div class="item-icon {icon_cls} icon-task"></div>',"<div>",'<span class="item-title" style="padding-top: 8px">{name:htmlEncode}</span>','<div class="item-status" style="margin-top: 2px; color: unset; padding-bottom:8px"><div class="{status_class}">{status_str}</div></div>',"</div>",'<tpl if="has_progress">','<div class="syno-restore-usage-lun"><div class="item-title syno-backup-percentage-bar-bg"><div class="syno-backup-percentage-bar" style="height: inherit; width:{progress * 2}px"></div></div><div class="item-status" style="color: unset; padding-bottom:8px; padding-top:3px"><span class="blue-status">{processed_size}</span>&nbsp;/&nbsp;{total_size}</div></div>',"</tpl>","</div>","</div>","</tpl>",'<div class="x-clear"></div>')},mapStatusStr:function(e){"restoring"===e.status?(e.status_str=_T("backup","restore_lun_executing"),e.status_class="blue-status"):"finished"===e.status?(e.status_str=_T("backup","restore_success"),e.status_class="green-status"):"none"===e.status||"reset"===e.status?(e.status_str=_T("netbackup","netbkp_wait_sync"),e.status_class="disable-font"):"error"===e.status?(e.status_str=_T("backup","restore_fail"),e.status_class="red-status"):"canceled"===e.status?(e.status_str=_T("usbbackup","usbbkp_cancel"),e.status_class="red-status"):"canceling"===e.status&&(e.status_str=_T("backup","restore_do_cancel"),e.status_class="red-status")},prepareData:function(e,t,s){return e.name=_T("lunbkp","lun_restore"),this.mapStatusStr(e),e.has_progress="restoring"===e.status,e.processed_size=SYNO.SDS.Backup.ConverSize(e.restored_bytes,2),e.total_size=SYNO.SDS.Backup.ConverSize(e.total_bytes,2),e.icon_cls="syno-backup-restore-progress-lun",e.progress=e.restored_bytes/e.total_bytes*100,e}}),Ext.define("SYNO.SDS.Backup.Restore.MultiVerLunProgressPanel",{extend:"SYNO.ux.Panel",constructor:function(e){e=this.fillConfig(e),this.callParent([e])},initEvents:function(){this.on("afterrender",this.startPolling,this),this.on("beforeclose",this.stopPolling,this)},fillConfig:function(e){return Ext.apply({items:[this.getView()]},e)},startPolling:function(){this.pollingID=this.pollReg({webapi:{api:"SYNO.Backup.MultiVerLun",version:1,method:"restore_status"},interval:2,immediate:!0,scope:this,status_callback:this.onPollingDone})},stopPolling:function(){this.pollUnreg(this.pollingID)},setCancelStatus:function(){this.isCanceling=!0,this.getView().getStore().loadData([{last_update_time:0,restored_bytes:0,total_bytes:0,used_bytes:0,status:"canceled"}]),this.owner.getButton("ok").enable()},onPollingDone:function(e,t,s,i){e&&(-1!==this.owner.restore_id&&t.restore_id===this.owner.restore_id?("restoring"!==t.status||this.isCanceling?this.owner.getButton("cancel").disable():!0===_S("is_admin")&&this.owner.getButton("cancel").enable(),"finished"!==t.status&&"error"!==t.status&&"canceled"!==t.status||(this.owner.getButton("ok").enable(),this.owner.getButton("cancel").disable(),this.stopPolling()),t.payload?this.getView().getStore().loadData([{last_update_time:t.last_update_time,restored_bytes:t.payload.restored_bytes,total_bytes:t.payload.total_bytes,used_bytes:t.payload.used_bytes,status:t.status}]):this.getView().getStore().loadData([{last_update_time:t.last_update_time,restored_bytes:0,total_bytes:0,used_bytes:0,status:t.status}])):this.getView().getStore().loadData([{last_update_time:t.last_update_time,restored_bytes:0,total_bytes:0,used_bytes:0,status:"none"}]))},getStore:function(){return this.store||(this.store=new Ext.data.JsonStore({id:"id",fields:["last_update_time","restored_bytes","total_bytes","used_bytes","status"]})),this.store},getView:function(){return this.view||(this.view=new SYNO.SDS.Backup.Restore.MultiVerLunProgressView({store:this.getStore(),owner:this,height:60,autoFlexcroll:!1})),this.view}}),Ext.define("SYNO.SDS.Backup.Restore.MultiVerLunProgressWindow",{extend:"SYNO.SDS.ModalWindow",dsmStyle:"v5",constructor:function(e){Ext.copyTo(this,e,"owner");var t=Ext.apply({resizable:!1,banner:!1,layout:"fit",width:680,height:580,cls:"syno-backup-restore-progress-window",title:SYNO.SDS.Backup.String("app","restore"),items:[this.wrapPanel=new SYNO.ux.Panel({autoFlexcroll:!0,items:[this.progressPanel=new SYNO.SDS.Backup.Restore.MultiVerLunProgressPanel({owner:this})]})],buttons:[{xtype:"syno_button",itemId:"cancel",disabled:!0,text:_T("common","cancel"),scope:this,handler:function(){this.getMsgBox().confirm(_T("tree","leaf_backup"),_T("backup","restore_cancel_confirm"),(function(e){"yes"===e&&this.onRestoreCancel()}),this)}},{xtype:"syno_button",itemId:"ok",btnStyle:"blue",disabled:!0,text:_T("common","ok"),btnStle:"blue",scope:this,handler:this.close}]},e);this.callParent([t])},getButton:function(e){return this.getFooterToolbar().getComponent(e)},onRestoreCancel:function(){this.getButton("cancel").disable(),this.setStatusBusy(),this.progressPanel.stopPolling(),this.sendWebAPI({api:"SYNO.Backup.MultiVerLun",version:1,method:"restore_cancel",scope:this,callback:function(e,t,s){if(this.clearStatusBusy(),!e)return this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code)),this.getButton("cancel").enable(),void this.progressPanel.startPolling();this.progressPanel.setCancelStatus()}})}}),Ext.define("SYNO.SDS.Backup.Restore.BasicRestoreWizard",{extend:"SYNO.SDS.Backup.Wizard",deepApply:function(e,t){for(var s in t)"object"==typeof t[s]&&t[s].constructor===Object&&"object"==typeof e[s]&&e[s].constructor===Object&&e[s]?Ext.apply(e[s],t[s]):e[s]=t[s]},getParams:function(){var e={task_id:this.taskId};return Ext.each(this.stepStack,(function(t){var s=this.getStep(t);Ext.isFunction(s.getParams)&&this.deepApply(e,s.getParams())}),this),0>this.taskId&&!Ext.isEmpty(this.cache_sess_id)&&Ext.apply(e,{cache_sess_id:this.cache_sess_id}),e},getBaseParams:function(e){var t={task_id:this.taskId},s=this.stepStack.slice(0);return e&&-1===s.indexOf(e)&&s.push(e),Ext.each(s,(function(e){var s=this.getStep(e);Ext.isFunction(s.getBaseParams)?this.deepApply(t,s.getBaseParams()):Ext.isFunction(s.getParams)&&this.deepApply(t,s.getParams())}),this),0>this.taskId&&!Ext.isEmpty(this.cache_sess_id)&&Ext.apply(t,{cache_sess_id:this.cache_sess_id}),t},getEncParams:function(){return this.data_enc?{data_enc:this.data_enc,sess_id:this.sess_id,sess_key:this.sess_key,uni_key:this.uni_key}:{data_enc:!1}},onRestore:function(){var e=this.getParams();Ext.apply(e,this.getEncParams()),this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Restore",method:"restore",version:2,params:e,encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],e),scope:this,callback:function(e,t,s){if(this.clearStatusBusy(),e){this.appWin.isRestoreWinShow=!0;var i=new SYNO.SDS.Backup.Restore.ProgressWindow({restore_id:t.restore_id,owner:this.owner});i.on("close",(function(){this.appWin.isRestoreWinShow=!1}),this),this.close(),i.open()}else this.getMsgBox().alert(_T("netbackup","netbkp_recovery"),SYNO.SDS.Backup.GetErrorStringEx(t),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED!==t.code&&SYNO.SDS.Backup.ERR_DATA_SESSION_EXPIRED!==t.code||(this.clearSession(),this.close())}),this)}})},onRestoreMultiVerLun:async function(){this.setStatusBusy();const e=this.getParams();Ext.apply(e,this.getEncParams());let t=null;try{await synowebapi.promises.request({api:"SYNO.Backup.MultiVerLun",version:1,method:"download_layout",params:e}),t=await synowebapi.promises.request({api:"SYNO.Backup.MultiVerLun",version:1,method:"create_restore_task",params:e});let i={...e,multi_ver_lun_restore_uuid:t.restore_uuid,multi_ver_lun_restore_file_path:t.restore_file_path};const a=await synowebapi.promises.request({api:"SYNO.Backup.Restore",method:"restore",version:2,params:i,encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],e)});this.clearStatusBusy(),this.appWin.isRestoreWinShow=!0;var s=new SYNO.SDS.Backup.Restore.MultiVerLunProgressWindow({restore_id:a.restore_id,owner:this.owner});return s.on("close",(function(){this.appWin.isRestoreWinShow=!1}),this),this.close(),void s.open()}catch(e){if(this.clearStatusBusy(),this.getMsgBox().alert(_T("netbackup","netbkp_recovery"),SYNO.SDS.Backup.GetErrorStringEx(e),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED!==e.code&&SYNO.SDS.Backup.ERR_DATA_SESSION_EXPIRED!==e.code||(this.clearSession(),this.close())}),this),null!==t)try{await synowebapi.promises.request({api:"SYNO.Backup.MultiVerLun",version:1,method:"delete_restore_task",params:{restore_uuid:t.restore_uuid,is_finished:!1}})}catch(e){SYNO.Debug(`Failed to delete restore task for multi-ver lun [${e.code}]`)}return void SYNO.Debug(`Failed to restore for multi-ver lun [${e.code}]`)}},clearSession:function(){if(delete this.sess_id,delete this.sess_key,this.taskId&&0<this.taskId){var e=this.owner.getTaskById(this.taskId);delete e.sess_id,delete e.sess_key}}}),Ext.define("SYNO.SDS.Backup.RestoreTypePanel",{extend:"SYNO.SDS.Backup.FormPanel",constructor:function(e){var t=!SYNO.Backup.FeatureSupport.Utils.SupportEntireDSMBackup();const s=!SYNO.Backup.FeatureSupport.Utils.SupportLegacyLunBackup(),i=!SYNO.Backup.FeatureSupport.Utils.SupportMultiVerLunBackup();var a=function(e){return{afterrender:function(t){t.disabled&&SYNO.ux.AddTip(t.getEl(),e)}.bind(this)}},n=Ext.apply({height:410,items:[{xtype:"syno_radio",name:"restore_type",itemId:"restore_type_data",inputValue:"restore_type_data",checked:!0,boxLabel:SYNO.SDS.Backup.String("app","backup_type_data")},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","restore_type_data_desc"),indent:1,cls:"syno-backup-type-option-margin"},_S("ha_running")?{xtype:"syno_radio",name:"restore_type",itemId:"restore_type_dsm",inputValue:"restore_type_dsm",boxLabel:SYNO.SDS.Backup.String("app","backup_type_entire_dsm"),hidden:t,disabled:!0,listeners:a(_TT("SYNO.SDS.HA.Instance","ui","ha_not_support_setting"))}:{xtype:"syno_radio",name:"restore_type",itemId:"restore_type_dsm",hidden:t,inputValue:"restore_type_dsm",boxLabel:SYNO.SDS.Backup.String("app","backup_type_entire_dsm")},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","restore_type_entire_dsm_desc"),disabled:_S("ha_running"),hidden:t,indent:1},{xtype:"syno_radio",name:"restore_type",itemId:"restore_type_multi_ver_lun",inputValue:"restore_type_multi_ver_lun",boxLabel:SYNO.SDS.Backup.String("app","backup_type_multiver_lun"),hidden:i,disabled:!_S("is_admin"),listeners:a(SYNO.SDS.Backup.String("app","only_admin_able_lun"))},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","restore_type_multiver_lun_desc"),hidden:i,indent:1,cls:"syno-backup-type-option-margin"},{xtype:"syno_radio",name:"restore_type",itemId:"restore_type_lun",inputValue:"restore_type_lun",boxLabel:SYNO.SDS.Backup.String("app","backup_type_lun"),hidden:s,disabled:!_S("is_admin"),listeners:a(SYNO.SDS.Backup.String("app","only_admin_able_lun"))},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","restore_type_lun_desc"),hidden:s,indent:1,cls:"syno-backup-type-option-margin"}]},e);return this.activated=!1,this.callParent([n])},summary:function(e){switch(this.getForm().getValues().restore_type){case"restore_type_data":e.append(SYNO.SDS.Backup.String("app","backup_type"),SYNO.SDS.Backup.String("app","backup_type_data"));break;case"restore_type_lun":e.append(SYNO.SDS.Backup.String("app","backup_type"),SYNO.SDS.Backup.String("app","backup_type_lun"));break;case"restore_type_multi_ver_lun":e.append(SYNO.SDS.Backup.String("app","backup_type"),SYNO.SDS.Backup.String("app","backup_type_multiver_lun"));break;case"restore_type_dsm":e.append(SYNO.SDS.Backup.String("app","backup_type"),SYNO.SDS.Backup.String("app","backup_type_entire_dsm"))}}}),Ext.define("SYNO.SDS.Backup.Restore.MainBranch",{extend:"SYNO.ux.Panel",constructor:function(e){Ext.copyTo(this,e,"owner");var t=Ext.apply({autoFlexcroll:!1,cls:"syno-backup-task-grid",bodyStyle:"padding-top: 0px",items:this.configFields(),bbar:[{xtype:"component",cls:"syno-backup-restore-from-other-link-wrapper",autoEl:{html:'<a class="link-font syno-backup-restore-from-other-link">'+_TT("SYNO.SDS.Backup.Application","app","restore_from_link")+"</a>"},listeners:{scope:this,render:function(e){e.getEl().on("click",(function(){this.owner.taskId=-1,this.owner.goNext(this.nextId.restore_from_other)}),this)}}}]},e);return this.callParent([t])},activate:function(){var e=this.getGridStore(),t=this.taskList;if(Ext.isArray(t)&&0<t.length){e.loadData(t);var s=this.getComponent("task_list"),i=this.owner.appWin.getCurrentTask(),a=s.getSelectionModel();if(Ext.isEmpty(i)||Ext.isEmpty(i.id))return;var n=e.indexOfId(i.id);0<=n?a.selectRow(n):0<e.getCount()&&a.selectFirstRow()}else this.getComponent("task_list").bwrap.mask(SYNO.SDS.Backup.String("error","no_available_restore_task"),"syno-ux-mask-info")},configFields:function(){return[{xtype:"syno_gridpanel",itemId:"task_list",height:367,autoFlexcroll:!0,layout:"fit",viewConfig:{hideSortIcons:!0},bodyStyle:"padding: 0px",bwrapStyle:"padding: 0px",store:this.getGridStore(),colModel:this.getColumnModel()}]},getGridStore:function(){return this.gridStore||(this.gridStore=new Ext.data.JsonStore({fields:[{name:"data_type",mapping:"data_type"},{name:"last_bkp_end_time",mapping:"last_bkp_end_time"},{name:"last_bkp_result",mapping:"last_bkp_result"},{name:"last_bkp_time",mapping:"last_bkp_time"},{name:"name",mapping:"name"},{name:"repo_id",mapping:"repo_id"},{name:"status",mapping:"status"},{name:"target_id",mapping:"target_id"},{name:"target_type",mapping:"target_type"},{name:"task_id",mapping:"task_id"},{name:"transfer_type",mapping:"transfer_type"},{name:"type",mapping:"type"}]})),this.gridStore},getColumnModel:function(){return new Ext.grid.ColumnModel([{header:_TT("SYNO.SDS.Backup.Application","app","restore_column_task_name"),dataIndex:"name"},{header:_TT("SYNO.SDS.Backup.Application","app","last_backup_time"),dataIndex:"last_bkp_time",renderer:function(e,t,s,i,a,n){return SYNO.SDS.Backup.Client.Common.Utils.getDSMStyleDateTimeString(e)}}])},getNext:function(){var e=this.getComponent("task_list").getSelectionModel();if(!e||!e.hasSelection())return!1;var t=e.getSelected().data;this.owner.taskRecord=t,this.owner.targetType=t.target_type,this.owner.transferType=t.transfer_type,this.owner.repoId=t.repo_id,this.owner.targetId=t.target_id,this.owner.taskId=t.task_id,this.owner.blChangeRcvrSrc=!0,this.owner.setSingle("share"===this.owner.targetType||"cloud"===this.owner.targetType);var s=this.owner.owner.getTaskById(this.owner.taskId);return this.owner.data_enc=s.data_enc,this.owner.sess_id=null,this.owner.sess_key=null,this.isTaskVerified(s)?(this.owner.sess_id=s.sess_id,this.owner.sess_key=s.sess_key,this.owner.goNext(this.nextId.restore_from_task)):this.launchPasswordWindow(s,(function(){this.owner.goNext(this.nextId.restore_from_task)})),!1},isTaskVerified:function(e){return!e.data_enc||!Ext.isEmpty(e.sess_id)},launchPasswordWindow:function(e,t){var s={task_id:e.task_id,repo_id:e.repo_id,target_id:e.target_id};new SYNO.SDS.Backup.Client.Common.Password.Window({owner:this.owner,verify_params:s,setter:Ext.createDelegate(this.setSession,this),callback:Ext.createDelegate(t,this)}).open()},setSession:function(e){var t=this.owner.owner.getTaskById(this.owner.taskId);t.sess_id=e.sess_id,t.sess_key=e.sess_key,this.owner.sess_id=e.sess_id,this.owner.sess_key=e.sess_key}}),Ext.define("SYNO.SDS.Backup.Restore.RepoTypePanel",{extend:"SYNO.SDS.Backup.DataRepoTypePanel",constructor:function(e){Ext.copyTo(this,e,"owner"),this.callParent([e])},isRepoDisplay:function(e){return!1!==e.options.supportRestore&&!e.hidden},loadLocalDestData:function(){this.owner.setStatusBusy({text:_T("backup","search_restore_folder")}),this.owner.api.send([{api:"SYNO.Backup.Repository",method:"find",params:{connect_list:[{target_type:"share",transfer_type:"local"}]},version:1}],(function(e,t,s){var i=this.nextId[this.getRepoType().id],a=this.owner.getStep(i);this.owner.clearStatusBusy(),e?a.loadData(t)?(this.owner.goNext(i),this.loaded=!0):this.owner.api.alert(_T("backup","restore_no_dest"),(function(){this.getComponent(0).getComponent("local").disable(),this.getForm().setValues({bkptype:"synology"})}),this):this.owner.api.alert(t)}),this)},getNext:function(){var e=this.getRepoType();return!!Ext.isObject(e)&&("local"!==e.id||this.loaded?!this.launchOAuthWindow(e)&&this.nextId[e.id]:(this.loadLocalDestData(),!1))},getParams:function(){var e=this.getRepoType();return Ext.isObject(e)?{bkptype:e.target_type}:{}}}),Ext.define("SYNO.SDS.Backup.Restore.LUNMultiVerRepoTypePanel",{extend:"SYNO.SDS.Backup.LUNMultiVerRepoTypePanel"}),Ext.define("SYNO.SDS.Backup.Restore.ConfigStep",{extend:"SYNO.SDS.Backup.FormPanel",constructor:function(e){Ext.copyTo(this,e,"owner"),this.configTreeHeight=299,this.singleConfigTreeHeight=265,this.configTree=new SYNO.SDS.ConfigBackup.Restore.ConfigTreePanel({height:this.singleConfigTreeHeight,loader:new SYNO.SDS.Backup.TreeLoader,disabled:!0,rootVisible:!0,autoWidth:!0,style:"padding-left: 30px"});var t=new Ext.tree.AsyncTreeNode({expanded:!1,id:"config_root",allowDrop:!1,leaf:!1,checked:!1,loader:this.createTreeLoader(),uiProvider:SYNO.SDS.ConfigBackup.TriTreeNodeUI});this.configTree.setRootNode(t);var s={items:new SYNO.ux.FieldSet({cls:"syno-backup-syscfg-field",items:[{xtype:"syno_radio",boxLabel:_T("backup","restore_config_no"),name:"config_selected",itemId:"config_selected_no",groupFields:[],inputValue:"no",indent:0,hideLabel:!0,scope:this,checked:!0},{xtype:"syno_radio",boxLabel:_T("backup","restore_config_yes")+":",name:"config_selected",itemId:"config_selected_yes",groupFields:["version_selector"],inputValue:"yes",indent:0,hideLabel:!0,scope:this,listeners:{scope:this,check:this.onConfigYesChecked},checked:!1},{width:240,xtype:"syno_combobox",hideLabel:!0,itemId:"version_selector",name:"version_selector",forceSelection:!0,allowBlank:!1,autoSelect:!0,displayField:"text",valueField:"version_id",indent:1,store:new Ext.data.SimpleStore({id:"version_id",fields:["version_id","text"]}),listeners:{scope:this,select:function(e,t,s){this.reloadTree(t.get("version_id"))}}},{xtype:"syno_checkbox",indent:1,boxLabel:_T("confbackup","bkp_overwrite"),disabled:!0,hiddenName:"overwrite",name:"overwrite"},this.configTree]}),cls:"syno-backup-config-step-panel"};Ext.apply(s,e),this.callParent([s])},onConfigYesChecked:function(e,t){t&&!this.isConfigInvalid||!t&&this.newestDssId?this.owner.getButton("next").enable():this.owner.getButton("next").disable(),this.isConfigInvalid||(this.configTree.setDisabled(!t),this.configTree.getRootNode().getUI().setCheckValue(t),this.getForm().findField("overwrite").setValue(t),this.getForm().findField("overwrite").setDisabled(!t))},setConfigInvalid:function(e,t){this.isConfigInvalid=e,e||!this.getForm().findField("config_selected_no").getValue()?(e?this.configTree.getEl().mask(t):this.configTree.getEl().unmask(),this.configTree.getRootNode().getUI().setCheckValue(!e),this.getForm().findField("overwrite").setDisabled(e),this.getForm().findField("overwrite").setValue(!e),this.owner.getButton("next").setDisabled(e)):this.owner.getButton("next").setDisabled(e)},createTreeLoader:function(){var e=new SYNO.SDS.Backup.TreeLoader({sendWebAPI:this.configTree.sendWebAPI.createDelegate(this.configTree),webapi:{api:"SYNO.Backup.Target.Config",method:"list",version:1,encryption:["pwd","secret"],timeout:36e4},baseParams:{is_show_shared_folder:!1},parseWebApiResponse:this.parseWebApiResponse.createDelegate(this),createNodeFn:function(e){this.configTree.createConfigNodeFn(e),this.owner.isSingle||delete e.checked},createNodeScope:this});return e.on("beforeload",(function(e,t,s){var i;this.owner.el.isMasked()||this.owner.setStatusBusy(),this.owner.getButton("next").disable(),(i=this.getLoadVersionListParams()).version_id=this.configTree.version_id,this.owner.data_enc&&(i.sess_id=this.owner.sess_id,i.sess_key=this.owner.sess_key,i.data_enc=this.owner.data_enc,i.uni_key=this.owner.uni_key),i.dss_id=this.owner.dssCache[i.version_id],i.is_show_shared_folder=!1,e.baseParams=i}),this),e.on("loadexception",(function(e,t,s){var i=SYNO.SDS.Backup.GetErrorString(s);s.code==SYNO.SDS.ConfigBackup.ERR_CONFIG_VERSION_WRONG||s.code==SYNO.SDS.ConfigBackup.ERR_CONFIG_VERSION_OTHER_OS||s.code==SYNO.SDS.ConfigBackup.ERR_CONFIG_VERSION_FUTURE?this.setConfigInvalid(!0,i):(this.setConfigInvalid(!0),this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),i,(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===s.code&&this.owner.clearSession(),this.owner.close()}),this)),this.owner.clearStatusBusy()}),this),e.on("load",(function(e,t,s){this.setConfigInvalid(!1),this.owner.clearStatusBusy(),this.owner.skipConfBackup&&this.owner.goNext(this.nextId)}),this),e},parseWebApiResponse:function(e,t){return this.newestDssId||(this.newestDssId=t.dss_id),this.owner.dssCache[this.configTree.version_id]=t.dss_id,this.configTree.dss_id=t.dss_id,t.config_info_list},getLoadVersionListParams:function(){return Ext.apply({offset:0,limit:-1},this.owner.getBaseParams())},checkState:function(){SYNO.SDS.Wizard.Step.prototype.checkState.apply(this,arguments),this.isConfigInvalid&&this.owner.getButton("next").disable()},activate:function(){var e=this.owner.getBaseParams();"sfr_s3"!==this.owner.transferType?0<e.task_id||"cloud_image"!==e.target_type?this.loadVersion():this.lastQueryCloudCache!==Ext.encode(e)&&(this.owner.setStatusBusy({text:_T("backup","search_restore_config")}),this.sendWebAPI({api:"SYNO.Backup.Target",version:1,method:"create_cache",params:e,encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],e),scope:this,callback:function(e,t,s){if(!e)return this.owner.clearStatusBusy(),void this.reportFatalError(SYNO.SDS.Backup.GetErrorString(t.code));this.owner.cache_sess_id=t.cache_sess_id,this.lastQueryCloudCache=Ext.encode(this.owner.getBaseParams()),this.loadVersion()}})):this.reportFatalError(SYNO.SDS.Backup.String("error","cloud_not_support_sfr"))},loadVersion:function(){var e,t,s,i=this.getLoadVersionListParams();if(this.lastQueryVersionList!==Ext.encode(i)){if(this.owner.dssCache={},this.newestDssId="",this.getForm().findField("config_selected_no").setValue(!0),(t=this.getForm().findField("version_selector")).getStore().loadData([],!1),t.clearValue(),e=this.configTree.getRootNode(),this.owner.el.isMasked()||this.owner.setStatusBusy({text:_T("backup","search_restore_config")}),this.owner.isSingle)s=_T("confbackup","confbkp_all"),e.setText(s),e.setTooltip(s),this.getForm().findField("overwrite").setVisible(!0),this.configTree.setHeight(this.singleConfigTreeHeight);else{s=_T("confbackup","confbkp_all")+' <element class="red-status">('+_T("confbackup","bkp_overwrite")+")</element>";var a=_T("confbackup","confbkp_all")+" ("+_T("confbackup","bkp_overwrite")+")";e.setText(s),e.setTooltip(a),this.getForm().findField("overwrite").setVisible(!1),this.configTree.setHeight(this.configTreeHeight)}i.sort_direction="desc",i.filter_name="success",this.sendWebAPI({api:"SYNO.Backup.Version",version:2,method:"list",params:i,encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],i),scope:this,callback:this.loadVersionDone,timeout:24e4})}},loadVersionDone:function(e,t,s){if(!e)return this.owner.clearStatusBusy(),void this.reportFatalError(SYNO.SDS.Backup.GetErrorString(t.code));var i=this.getForm().findField("version_selector"),a=[];if(!t||!t.version_info_list||0===t.version_info_list.length)return this.setConfigInvalid(!0),this.owner.clearStatusBusy(),void(this.owner.isSingle?this.reportFatalError(_T("confbackup","confbkp_file_not_found")):this.reportFatalError(SYNO.SDS.Backup.String("error","no_available_restore_version")));Ext.each(t.version_info_list,(function(e){var t;0===e.timestamp?a.push([e.version_id,_T("confbackup","confbkp_old_config_format")]):(t=new Date(1e3*e.timestamp),a.push([e.version_id,SYNO.SDS.Backup.Client.Common.Utils.DateTimeFormatter(t,{type:"datetimesec"})]))}),this),this.newestVersionId=a[0][0],i.getStore().loadData(a,!1),i.setValue(a[0][0]),i.setRawValue(a[0][1]),this.lastQueryVersionList=Ext.encode(this.getLoadVersionListParams()),this.reloadTree(a[0][0])},reportFatalError:function(e){this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),e||SYNO.SDS.Backup.String("error","app_network_disconnected"),(function(e){this.owner.close()}),this)},getNext:function(){var e=this.nextId,t=this.isOverwrite();return this.isRestoreConfig()?(this.configTree.checkUGConflict(t,(function(){this.goNext(e)}),this.owner),!1):e},summary:function(e){var t;this.isRestoreConfig()?(e.append(SYNO.SDS.Backup.String("app","select_version"),this.getForm().findField("version_selector").getRawValue()),t=_T("common","yes")+", ",t+=_T("netbackup","netbkp_restore_enhance")):t=_T("common","no"),e.append(SYNO.SDS.Backup.String("app","bkp_import"),t)},reloadTree:function(e){var t;this.configTree.dss_id="",this.configTree.version_id=e,(t=this.configTree.getRootNode()).reload(),t.expand()},getVersionId:function(){return this.isRestoreConfig()?this.getForm().findField("version_selector").getValue():this.owner.isSingle?this.newestVersionId:-1},isOverwrite:function(){return this.owner.isSingle?this.getForm().findField("overwrite").getValue():this.configTree.isRestoreConfig()},isRestoreConfig:function(){return this.getForm().findField("config_selected_yes").getValue()&&this.configTree.isRestoreConfig()},getBaseParams:function(){var e=this.getVersionId();return-1===e?{}:{dss_id:this.owner.dssCache[e],version_id:e}},getParams:function(){var e=this.getBaseParams();return this.isRestoreConfig()?Ext.apply(e,{config_list:this.configTree.getRestoreServiceList(),option:{overwrite:this.isOverwrite()}}):e}}),Ext.define("SYNO.SDS.Backup.VersionFileTree",{extend:"SYNO.SDS.Backup.BasicTreePanel",shareWarnStatus:{},folderDisplayLimit:1e4,constructor:function(e){this.dss_id=null,Ext.copyTo(this,e,"owner");var t=Ext.apply({border:!1,loader:this.createTreeLoader(),root:this.createTreeRoot(),bodyStyle:"padding: 0px"},e);return this.callParent([t])},initEvents:function(){this.callParent(arguments),this.mon(this,"beforeexpandnode",this.onBeforeExpandNode)},createTreeRoot:function(){return new Ext.tree.AsyncTreeNode({draggable:!1,expanded:!1,id:"fm_root",allowDrop:!1,text:_T("tree","leaf_sharefolder"),checked:!1,uiProvider:SYNO.SDS.Backup.TriTreeNodeUI})},createTreeLoader:function(){return new SYNO.SDS.Backup.TreeLoader({sendWebAPI:this.sendWebAPI.createDelegate(this),scope:this,webapi:{},baseParams:{offset:0,limit:-1},listeners:{beforeload:this.onBeforeLoad,load:this.onLoad,loadexception:this.onLoadException,scope:this},createNodeFn:this.createNodeFn,createNodeScope:this,parseWebApiResponse:this.parseWebApiResponse.createDelegate(this)})},onBeforeLoad:function(e,t,s){e.baseParams={offset:0,limit:-1},this.owner.setStatusBusy();var i=this.getBaseParams();Ext.apply(i,this.owner.getEncParams()),"fm_root"===t.id?(e.webapi.api="SYNO.Backup.Share.Restore",e.webapi.method="list",e.webapi.version=1,e.webapi.encryption=["pwd","secret"]):(i.path=SYNO.SDS.Backup.ConvertUniqueIdToConflictId(t.id),e.webapi.api="SYNO.Backup.Version",e.webapi.method="list_folder",e.webapi.version=1,e.webapi.encryption=["pwd","secret"],e.baseParams.limit=this.folderDisplayLimit,e.baseParams.type="dir"),Ext.apply(e.baseParams,i)},onLoad:function(e,t,s){var i=0;"fm_root"===t.id&&(t.eachChild((function(e){e.disabled||i++})),0===t.childNodes.length?(t.disable(),t.appendChild(new Ext.tree.AsyncTreeNode({checked:!1,leaf:!0,uiProvider:SYNO.SDS.Backup.TriTreeNodeUI,text:'<element class="red-status">'+_T("download","download_task_dest_not_exist")+"</element>",disabled:!0}))):0===i?t.disable():t.enable()),this.owner.clearStatusBusy()},onLoadException:function(e,t,s){this.owner.clearStatusBusy(),this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),SYNO.SDS.Backup.GetErrorString(s.code),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===s.code&&this.owner.clearSession(),this.owner.close()}),this)},onBeforeExpandNode:function(e){if(e.attributes.exceedLimit)return this.owner.getMsgBox().alert(_T("netbackup",'"netbkp_recovery"'),String.format(SYNO.SDS.Backup.String("app","node_exceed_display_limit"),e.text,this.folderDisplayLimit)),!1},createNodeFn:function(e){e.uiProvider="SYNO.SDS.Backup.TriTreeNodeUI",e.checked=!1,e.text=e.qtip=e.name,e.htmlEncode=!1,e.is_user_modify=!1,e.is_restore=!0,e.file_path?e.id=e.file_path:(e.id="/"+e.text,e.is_bad?(e.disabled=!0,e.disable_reason=SYNO.SDS.Backup.String("app","broken_share")):e.conflict&&(e.is_valid?e.shareConflict=e.conflict:(e.disabled=!0,"err_target_share_cannot_be_worm"===e.conflict?e.disable_reason=SYNO.SDS.Backup.String("app","err_target_share_cannot_be_worm"):(e.disable_reason=SYNO.SDS.ConfigBackup.getShareErrorString(e.conflict,e.name),"err_share_not_writable"===e.conflict&&void 0!==e.read_only_owner&&(e.disable_reason+=" ",e.disable_reason+=String.format(SYNO.SDS.Backup.String("app","share_used_by_running_application"),SYNO.SDS.Backup.getReadOnlyOwnerString(e.read_only_owner))))),delete e.conflict)),e.is_enc&&(e.id=SYNO.SDS.Backup.ConvertConflictIdToUniqueId(e.id)),delete e.name,e.leaf=SYNO.SDS.Backup.Client.Common.Utils.isABBDataFolder(e.file_path)||!this.isShareExpandable||e.disabled},parseWebApiResponse:function(e,t){var s=[];return"fm_root"===e.id?(void 0!==t.dss_id&&(this.owner.dssCache[e.getLoader().baseParams.version_id]=t.dss_id),this.dss_id=t.dss_id,t.share_info_list):this.folderDisplayLimit<t.total?(e.attributes.expandable=!0,e.attributes.exceedLimit=!0,s):(Ext.each(t.file_list,(function(t){!1!==t.is_dir&&(t.is_enc=e.attributes.is_enc,t.warning=e.attributes.warning,s.push(t))})),s)},getVersionPanel:function(){return this.versionPanel},checkShare:function(){var e="";if(this.isSingle){this.owner.setStatusBusy();var t=!1,s=!1,i=this.getFolderList(),a={};Ext.each(i,(function(e){var i=e.path,n=e.is_enc;if(i=(i=i.substr(1)).toLowerCase(),a[i])return"enc_share"===a[i]===n?t=!0:s=!0,!1;a[i]=n?"enc_share":"share"})),this.owner.clearStatusBusy(),t?e=_T("netbackup","netbkp_restore_conflict_share"):s&&(e=_T("backup","restore_the_same_share_err"))}return e},getWarning:function(e){var t=[];e&&Ext.isArray(e)?t=this.getRootNode().childNodes.filter((function(t){return e.some((function(e){return!this.shareWarnStatus[e]&&e===SYNO.SDS.Backup.ConvertUniqueIdToConflictId(t.id).substr(1)}),this)}),this):(this.shareWarnStatus={},t=this.getCheckedSubTreeRoot(this.getRootNode()));var s={};return Ext.each(t,(function(t){if(Ext.isEmpty(t.attributes.warning))return!0;var i=SYNO.SDS.Backup.ConvertUniqueIdToConflictId(t.id).split("/")[1];e||(this.shareWarnStatus[i]=!0),Ext.each(t.attributes.warning.split(","),(function(e){void 0===s[e]&&(s[e]=[]),-1===s[e].indexOf(i)&&s[e].push(i)}))}),this),SYNO.SDS.ConfigBackup.getShareWarningString(s)},getFolderList:function(e){var t=[],s=[];return e?this.getRootNode().eachChild((function(e){s.push(e)})):s=this.getCheckedSubTreeRoot(this.getRootNode()),Ext.each(s,(function(e){var s=e.id,i=e.attributes.is_enc;i&&(s=SYNO.SDS.Backup.ConvertUniqueIdToConflictId(s)),t.push({path:s,is_enc:i})})),t},getTieringShare:function(){let e=[],t=this.getCheckedSubTreeRoot(this.getRootNode());return Ext.each(t,(function(t){let s=t.id,i=t.attributes.is_enc,a=t.attributes.is_tiering_share,n=t.attributes.shareConflict;i&&(s=SYNO.SDS.Backup.ConvertUniqueIdToConflictId(s)),a&&e.push({name:s.substring(1),conflict:n})})),e}}),Ext.define("SYNO.SDS.Backup.VersionSelector",{extend:"SYNO.SDS.Backup.FormPanel",constructor:function(e){Ext.copyTo(this,e,"owner");var t=Ext.apply({style:"border-top: 1px solid #D7E1EB; padding: 12px 20px 0px 20px;",items:[{labelWidth:260,width:240,fieldLabel:_T("backup","select_version"),xtype:"syno_combobox",itemId:"version_selector",name:"version_selector",forceSelection:!0,allowBlank:!1,autoSelect:!0,displayField:"name",valueField:"version_id",store:this.createStore(e),listeners:{scope:this,select:function(e,t,s){this.getVersionPanel().reloadTree(t.get("version_id"))}}}]},e);return this.callParent([t])},createStore:function(e){return new SYNO.API.Store({api:"SYNO.Backup.Version",version:2,method:"list",baseParams:Ext.apply({},this.params),encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],this.params),appWindow:this.owner.findAppWindow(),reader:new Ext.data.JsonReader({idProperty:"version_id",root:"version_info_list",totalProperty:"total",fields:[{name:"version_id",mapping:"version_id"},{name:"name",mapping:"name"},{name:"modify",mapping:"modify"},{name:"status",mapping:"status"},{name:"timestamp",mapping:"timestamp"}]})})},getVersionId:function(){return this.getComponent("version_selector").getValue()},getVersionDate:function(){var e=this.getVersionId();return this.getComponent("version_selector").getStore().getById(e).get("name")},getVersionPanel:function(){return this.versionPanel}}),Ext.define("SYNO.SDS.Backup.Restore.ShareStep",{extend:"SYNO.ux.Panel",loaded:!1,version_selector:Ext.isIE6||Ext.isIE7?"combobox":"timeline",constructor:function(e){Ext.copyTo(this,e,"owner,repoId,targetId,taskId"),this.timelineHeight=112,this.wizardStepHeight=425,this.versionFileTreeHeight=this.wizardStepHeight-this.timelineHeight-6-24,this.versionFileTree=new SYNO.SDS.Backup.VersionFileTree({itemId:"version_file_tree",owner:this.owner,versionPanel:this,getBaseParams:function(){var e=this.owner.getBaseParams();return this.getVersionSelectPanel()&&this.getVersionSelectPanel().isVisible()&&(e.version_id=this.getVersionSelectPanel().getVersionId(),e.dss_id=this.owner.dssCache[e.version_id]),e}.createDelegate(this),height:this.versionFileTreeHeight,bwrapStyle:"padding-top: 0px",bodyStyle:"padding: 8px 8px 0px 8px"});var t=Ext.apply({itemId:"version_panel",layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},items:[new SYNO.ux.FieldSet({itemId:"tree_field",layout:"fit",cls:"syno-backup-sharestep-treefield",items:[this.versionFileTree]}),{xtype:"spacer",flex:1}]},e);return this.callParent([t])},getFileSourcePanel:function(){return this.versionFileTree},getVersionSelectPanel:function(){return this.versionSelector},showVersionSelector:function(e){this.versionSelector?this.versionSelector.setVisible(e):e&&("timeline"===this.version_selector?this.versionSelector=new SYNO.SDS.Backup.Client.Explore.TimeLine({loadAfterRender:!0,cls:"syno-backup-client-explore",owner:this.owner,getBaseParams:this.getLoadVersionListParams.createDelegate(this),height:this.timelineHeight,apiClass:"SYNO.Backup.Version",methodVersionMap:{list:2,summary:1},listeners:{select:this.reloadTree,scope:this}}):this.versionSelector=new SYNO.SDS.Backup.VersionSelector({owner:this.owner,height:60,versionPanel:this}),this.add(this.versionSelector)),e&&"timeline"===this.version_selector?this.owner.getFooterToolbar().getEl().addClass("syno-backup-timeline-fbar"):this.owner.getFooterToolbar().getEl().removeClass("syno-backup-timeline-fbar")},isReloadNeeded:function(){var e=this.getLoadVersionListParams();return e=Ext.encode(e),this.lastQuery!==e&&(this.lastQuery=e,!0)},isShareExpandable:function(){if(this.owner.isSingle)return!1;var e=this.owner.getBaseParams();return-1!==e.task_id||"cloud_image"!==e.target_type},activate:function(){this.owner.isSingle!==this.getFileSourcePanel().isSingle&&(this.getFileSourcePanel().isSingle=this.owner.isSingle,this.getFileSourcePanel().loader=this.getFileSourcePanel().createTreeLoader()),this.getFileSourcePanel().isShareExpandable=this.isShareExpandable(),-1!==this.owner.getStep("config").getVersionId()?(this.showVersionSelector(!1),this.isReloadNeeded()&&this.reloadTree(),this.getComponent("tree_field").setHeight(this.wizardStepHeight-24),this.doLayout()):(this.showVersionSelector(!0),this.isReloadNeeded()&&this.reloadVersionList(),this.getComponent("tree_field").setHeight(this.versionFileTreeHeight),this.setHeight(this.wizardStepHeight),this.doLayout())},launchTieringPlan:function(e){SYNO.SDS.AppLaunch("SYNO.SDS.TierFS.Application",{share:e})},feasibilityCheck:async function(e){try{this.owner.setStatusBusy();const t=await this.sendWebAPIPromise({api:"SYNO.Backup.TieringShare.Feasibility",version:1,method:"check",params:{action:"restore",share_list:e},scope:this});if(!Ext.isArray(t.share_list))return!1;if(!Ext.isEmpty(t.share_list)){const e=this.generateBusyStatusMessage(t.share_list),s=t.share_list[0];return this.owner.getMsgBox().alert(SYNO.SDS.Backup.String("app","unable_to_restore"),e),Ext.defer((function(){const e=Ext.get("tiering-plan-link");e&&e.on("click",(function(){this.launchTieringPlan(s)}),this)}),100,this),!1}}catch(e){return this.owner.getMsgBox().alert("",SYNO.SDS.Backup.GetErrorString(e.code)),SYNO.Debug(e),!1}finally{this.owner.clearStatusBusy()}return!0},generateBusyStatusMessage:function(e){const t=`<b><a href="#" id="tiering-plan-link">${SYNO.SDS.Backup.String("app","synology_tiering")}</a></b>`,s=`<ul class="syno-backup-restore-tiering-share-share-step-msgBox-ul">${e.map((e=>`<li>${e}</li>`)).join("")}</ul>`;return`${String.format(SYNO.SDS.Backup.String("app","tiering_share_is_busy_before_restore"),t)}${s}`},showWarningForRestoreTieringShare:async function(e){const t=SYNO.SDS.Backup.String("app","restore_tiering_share_warning");return new Promise(((e,s)=>{this.owner.getMsgBox().alert("",t,e)}))},CheckTieringShare:async function(){const e=this.getFileSourcePanel().getTieringShare().filter((e=>"overwrite"===e.conflict)).map((e=>e.name));let t=[];try{this.owner.setStatusBusy();const s=await this.sendWebAPIPromise({api:"SYNO.Backup.TieringShare",version:1,method:"get",scope:this});e.forEach((e=>{var i;null!=s&&null!==(i=s.share_list)&&void 0!==i&&i.includes(e)&&t.push(e)}))}catch(e){return this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(e.code)),SYNO.Debug(e),!1}finally{this.owner.clearStatusBusy()}return!!Ext.isEmpty(t)||!!await this.feasibilityCheck(t)&&(await this.showWarningForRestoreTieringShare(),!0)},getNext:function(){var e=this.getFileSourcePanel().checkShare();if(""!==e)return this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),e),!1;var t=this.getFileSourcePanel().getWarning();return""!==t?this.owner.getMsgBox().confirm(_T("netbackup","netbkp_recovery"),t,(function(e){"yes"===e&&this.loadNextStep()}),this):this.loadNextStep(),!1},loadNextStep:async function(){if(!await this.CheckTieringShare())return!1;if(this.owner.getFooterToolbar().getEl().removeClass("syno-backup-timeline-fbar"),this.owner.getStep("app").isReloadNeeded()){this.isAppSkip=!1,this.owner.setStatusBusy();var e=this.owner.getStep("app").getStore(),t=this.owner.getStep("app").getVersionAppParams();e.proxy.encryption=SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],t),this.owner.getStep("app").getStore().load({params:t,scope:this,callback:function(e,t,s){this.owner.clearStatusBusy(),s&&0===e.length?(this.isAppSkip=!0,this.owner.goNext(this.owner.getStep("app").getNext())):this.owner.goNext(this.nextId)}})}else this.isAppSkip?this.owner.goNext(this.owner.getStep("app").getNext()):this.owner.goNext(this.nextId);return!1},getBack:function(){this.owner.getFooterToolbar().getEl().removeClass("syno-backup-timeline-fbar")},summary:function(e){var t=[],s=[],i=[],a=[];Ext.each(this.getFileSourcePanel().getFolderList(),(function(e){t.push({path:e.path.substring(1),whitelist:["*"]})})),s=s.concat(t),this.owner.getStep("app").getStore().each((function(e){if(!0!==e.get("checked"))return!0;var t=SYNO.SDS.Backup.parseAppDependFolderInfo(e.get("depend"));i=i.concat(t.detail)})),Ext.each(i,(function(e){-1!==e.whitelist.indexOf("*")&&s.push(e)})),s.sort((function(e,t){return e.path<t.path?-1:e.path===t.path?0:1}));var n=0;s=s.filter((function(e,t,s){return 0===t||e.path!==s[n].path&&(0!==e.path.indexOf(s[n].path+"/")&&(n=t,!0))})),a=SYNO.Backup.Util.deepCopyObject(s);var r=function(e){Ext.each(e,(function(e){s.some((function(t){return e.path===t.path||0===e.path.indexOf(t.path+"/")}))||a.push(e)}))};r(t),r(i),a=a.map((function(e){return-1!==e.whitelist.indexOf("*")?e.path:e.path+"("+e.whitelist.join(", ")+")"})),this.getVersionSelectPanel()&&this.getVersionSelectPanel().isVisible()&&e.append(SYNO.SDS.Backup.String("app","select_version"),SYNO.SDS.Backup.Client.Common.Utils.getDSMStyleDateTimeString(this.getVersionSelectPanel().getVersionDate(),{type:"datetimesec"})),0===a.length?e.append(SYNO.SDS.Backup.String("app","restore_share"),_T("system","none_opt")):e.append(SYNO.SDS.Backup.String("app","restore_share"),a.sort().join(", "))},getLoadVersionListParams:function(){return Ext.apply({offset:0,limit:-1},this.owner.getBaseParams())},reloadVersionList:function(){if("combobox"===this.version_selector){var e=this.getLoadVersionListParams();this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Version",version:2,method:"list",encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],e),params:e,scope:this,callback:function(e,t,s){if(this.owner.clearStatusBusy(),e){var i=this.getVersionSelectPanel(),a=[];Ext.each(t.version_info_list,(function(e,t,s){"success"!==e.status&&"partial"!==e.status||a.push(e)}),this),0!==a.length?((i=i.getComponent("version_selector")).getStore().loadData({version_info_list:a}),i.setValue(a[0].version_id),i.setRawValue(a[0].name),this.lastQueryVersionList&&this.getFileSourcePanel().getRootNode().reload(),this.getFileSourcePanel().getRootNode().expand()):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),SYNO.SDS.Backup.String("error","no_available_restore_version"),(function(){this.owner.close()}),this)}else this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),SYNO.SDS.Backup.GetErrorString(t.code),(function(){this.owner.close()}),this)}})}else"timeline"===this.version_selector&&(this.remove(this.versionSelector),this.versionSelector=null,this.showVersionSelector(!0),this.doLayout())},reloadTree:function(){this.getFileSourcePanel().getRootNode().removeAll(),this.getFileSourcePanel().getRootNode().getUI().setCheckValue(!1),this.getFileSourcePanel().getRootNode().reload()},getFolderList:function(e){return this.getFileSourcePanel().getFolderList(e)},getBaseParams:function(){var e={};return this.getVersionSelectPanel()&&this.getVersionSelectPanel().isVisible()&&(e.version_id=this.getVersionSelectPanel().getVersionId()),e},getParams:function(){var e=this.getBaseParams();return null!==this.getFileSourcePanel().dss_id&&(e.dss_id=this.getFileSourcePanel().dss_id),Ext.apply(e,{share_list:this.getFolderList(),option:{conflict:"overwrite"}})}}),Ext.define("SYNO.SDS.Backup.Restore.LunProgressView",{extend:"SYNO.ux.ExpandableListView",constructor:function(e){this.callParent(arguments),this.addClass("syno-backup-restore-progress-listview")},createTpl:function(){return new Ext.XTemplate('<tpl for=".">','<div class="item-wrap" style="margin-top:16px; margin-left:20px; margin-right:20px">','<div class="item-summary">','<div class="item-icon {icon_cls} icon-task"></div>',"<div>",'<span class="item-title" style="padding-top: 8px">{name:htmlEncode}</span>','<div class="item-status" style="margin-top: 2px; color: unset; padding-bottom:8px"><div class="{status_class}">{status_str}</div></div>',"</div>",'<tpl if="has_progress">','<div class="syno-restore-usage-lun"><div class="item-title syno-backup-percentage-bar-bg"><div class="syno-backup-percentage-bar" style="height: inherit; width:{progress * 2}px"></div></div><div class="item-status" style="color: unset; padding-bottom:8px; padding-top:3px"><span class="blue-status">{processed_size}</span>&nbsp;/&nbsp;{total_size}</div></div>',"</tpl>","</div>","</div>","</tpl>",'<div class="x-clear"></div>')},prepareData:function(e,t,s){return e.name=_T("lunbkp","lun_restore"),e.status_str=_T("backup","restore_lun_executing"),e.status_class="blue-status",e.has_progress=""!==e.total_size,e.processed_size=SYNO.SDS.Backup.ConverSize(e.processed_size,2),e.total_size=SYNO.SDS.Backup.ConverSize(e.total_size,2),e.icon_cls="syno-backup-restore-progress-lun",e}}),Ext.define("SYNO.SDS.Backup.Restore.LunProgressPanel",{extend:"SYNO.ux.Panel",constructor:function(e){e=this.fillConfig(e),this.callParent([e])},initEvents:function(){this.on("afterrender",this.startPolling,this),this.on("beforeclose",this.stopPolling,this)},fillConfig:function(e){return Ext.apply({items:[this.getView()]},e)},startPolling:function(){this.pollingTask?this.pollingTask.restart():this.pollingTask=this.addWebAPITask({api:"SYNO.Backup.Lunbackup",version:1,method:"load_restore_progress",interval:2e3,scope:this,callback:this.onPollingDone}).start(!0)},stopPolling:function(){this.pollingTask&&this.pollingTask.stop()},onPollingDone:function(e,t){if(e){if(t.finish)return this.stopPolling(),void this.owner.close();t.progress.id="lun",t.progress.progress>=0&&this.owner.getButton("cancel").enable(),this.getStore().loadData([t.progress])}},getStore:function(){return this.store||(this.store=new Ext.data.JsonStore({fields:["progress","processed_size","total_size"]})),this.store},getView:function(){if(!this.view){var e={store:this.getStore(),owner:this,height:60,autoFlexcroll:!1};this.view=new SYNO.SDS.Backup.Restore.LunProgressView(e)}return this.view}}),Ext.define("SYNO.SDS.Backup.Restore.LunProgressWindow",{extend:"SYNO.SDS.ModalWindow",dsmStyle:"v5",constructor:function(e){Ext.copyTo(this,e,"owner");var t=Ext.apply({resizable:!1,banner:!1,layout:"fit",width:580,height:250,bodyCssClass:"sds-wizard-step",title:_T("backup","restore_progress"),items:[this.wrapPanel=new SYNO.ux.Panel({autoFlexcroll:!0,bwrapCfg:{cls:"x-panel-bwrap sds-wizard-step-bwrap"},items:[this.progressPanel=new SYNO.SDS.Backup.Restore.LunProgressPanel({owner:this})]})],buttons:[{xtype:"syno_button",itemId:"cancel",disabled:!0,text:_T("common","cancel"),scope:this,handler:function(){this.getMsgBox().confirm(_T("tree","leaf_backup"),_T("backup","restore_cancel_confirm"),(function(e){"yes"===e&&this.onRestoreCancel()}),this)}}]},e);this.callParent([t])},getButton:function(e){return this.getFooterToolbar().getComponent(e)},onRestoreCancel:function(){this.getButton("cancel").disable(),this.setStatusBusy(),this.progressPanel.stopPolling(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"restore_cancel",scope:this,callback:function(e,t){this.clearStatusBusy(),e||(t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))),this.close()}})}}),Ext.define("SYNO.SDS.Backup.LUNResTypePanel",{extend:"SYNO.ux.FormPanel",isActivatedBefore:!1,taskStore:null,constructor:function(e){this.bkptaskList=[];var t=new Ext.data.Store({reader:new Ext.data.JsonReader({idProperty:"name",root:"lun_task_list",totalProperty:"total",fields:[{name:"name",mapping:"name"},{name:"type",mapping:"type"},{name:"bkp_dest_type",mapping:"bkp_dest_type"},{name:"status",mapping:"last_bkp_result"}]})});t.loadData({lun_task_list:e.taskList});var s,i=!0;for(s=0;s<t.getCount();s++){var a=t.getAt(s);"success"!==a.data.status||SYNO.SDS.LunBackup.BKPTASK_LOCLUN!==a.data.type&&SYNO.SDS.LunBackup.BKPTASK_NETLUN!==a.data.type||(this.bkptaskList.push([a.data.name,a.data.type,a.data.bkp_dest_type]),i=!1)}this.taskStore=new Ext.data.SimpleStore({id:"bkptaskstore",fields:["bkpset","bkptype","bkp_dest_type"],data:this.bkptaskList}),this.taskStore.loadData(this.bkptaskList,!1);var n={items:[{xtype:"syno_displayfield",value:_T("backup","restore_current_task")},{xtype:"syno_radio",boxLabel:_T("backup","select_task"),name:"bkptype",inputValue:SYNO.SDS.Backup.BKPTASK_EXISTED,checked:!0,disabled:i,indent:1},{xtype:"syno_combobox",name:"select_current_task",hiddenName:"select_current_task",width:200,listWidth:200,store:this.taskStore,valueField:"bkpset",displayField:"bkpset",editable:!1,forceSelection:!0,triggerAction:"all",selectOnFocus:!0,scope:this,indent:2,hideLabel:!0},{xtype:"syno_displayfield",value:String.format(_T("backup","restore_new_task"),_D("company_title"))},{xtype:"syno_radio",boxLabel:_T("lunbkp","local_lun_restore"),name:"bkptype",inputValue:SYNO.SDS.LunBackup.BKPTASK_LOCLUN,checked:!!i,indent:1},{xtype:"syno_displayfield",value:_T("lunbkp","local_lun_restore_desc"),indent:2},{xtype:"syno_radio",boxLabel:_T("lunbkp","network_lun_restore")+" ("+String.format(_T("netbackup","synology_server"),_D("company_title"))+")",name:"bkptype",inputValue:SYNO.SDS.LunBackup.BKPTASK_NETLUN,indent:1},{xtype:"syno_displayfield",value:String.format(_T("lunbkp","network_lun_restore_desc"),_D("company_title")),indent:2}]};Ext.apply(n,e),this.callParent([n])},registerEvent:function(){0<this.bkptaskList.length?this.getForm().findField("select_current_task").setValue(this.bkptaskList[0][0]):this.getForm().findField("select_current_task").setDisabled(!0)},activate:function(){this.isActivatedBefore||(this.isActivatedBefore=!0,this.registerEvent())},saveSettings:function(){var e,t=this.getForm(),s=t.findField("select_current_task").getValue(),i=t.findField("bkptype").getGroupValue();if(this.wizardStore.taskname=s,this.wizardStore.bkptype=i,this.wizardStore.desttype=i,SYNO.SDS.Backup.BKPTASK_EXISTED===this.wizardStore.bkptype){this.wizardStore.blExistedTask=!0;var a=t.findField("select_current_task").getValue();for(e=0;e<this.taskStore.getCount();e++)if(a===this.taskStore.getAt(e).data.bkpset){this.wizardStore.bkptype=this.taskStore.getAt(e).data.bkptype,this.wizardStore.desttype=this.taskStore.getAt(e).data.bkp_dest_type;break}}else this.wizardStore.blExistedTask=!1},getNext:function(){return this.saveSettings(),this.wizardStore.blExistedTask?this.nextId[0]:SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.wizardStore.bkptype?this.nextId[2]:SYNO.SDS.LunBackup.BKPTASK_NETLUN===this.wizardStore.bkptype&&this.nextId[3]},summary:function(e){}}),Ext.define("SYNO.SDS.Backup.LUNResSynoSerPanel",{extend:"SYNO.ux.FormPanel",isActivatedBefore:!1,ServerStore:null,constructor:function(e){this.ServerList=[],this.ServerStore=new Ext.data.SimpleStore({fields:["value","display"],data:this.ServerList,sortInfo:{field:"display",direction:"ASC"}});var t={items:[{xtype:"syno_combobox",fieldLabel:_T("netbackup","netbkp_set_ip"),hiddenName:"server",name:"server",forceSelection:!1,allowBlank:!1,emptyText:_T("netbackup","netbkp_input_addr"),editable:!0,store:this.ServerStore,displayField:"display",valueField:"value",triggerAction:"all",lazyRender:!0,queryDelay:18e5,width:200,validateOnBlur:!0,validationEvent:"blur",validator:function(t){return SYNO.SDS.LunBackup.netbkpValidator(t,e.wizardStore.selfIPs,e.wizardStore.selfHostName)},onTriggerClick:function(){0!==this.getStore().getCount()?this.isExpanded()?(this.collapse(),this.el.focus()):(this.onFocus({}),this.expand(),this.el.focus()):(this.scope.serverListLoaded=!0,this.el.focus(),SYNO.SDS.LunBackup.onLoadSynologyServer(this,this.scope.ServerList,this.scope.owner))},scope:this},{xtype:"syno_textfield",fieldLabel:_T("netbackup","netbkp_account"),hiddenName:"account",name:"account",allowBlank:!1,width:200,vtype:"username_ext"},{xtype:"syno_textfield",fieldLabel:_T("common","password"),name:"password",inputType:"password",width:200},{xtype:"syno_button",id:this.btnTestId=Ext.id(),labelSeparator:"",name:"testconbtn",hiddenName:"testconbtn",text:_T("netbackup","netbkp_test_connection"),handler:this.onTestConnectionButton,scope:this}]};Ext.apply(t,e),this.callParent([t])},activate:function(){},saveSettings:function(){var e=this.getForm().findField("server").getRawValue();this.wizardStore.netRcvrParams={account:this.getForm().findField("account").getValue(),password:this.getForm().findField("password").getValue(),server:SYNO.SDS.LunBackup.GetServerName(e),ip:SYNO.SDS.LunBackup.GetServerIP(e)}},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),this.onTestConnectionButton("next"),!1)},summary:function(e){},TestServerVersionDone:function(e,t){this.owner.clearStatusBusy(),e?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","netbkp_connection_testing_success")):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),SYNO.SDS.Backup.String(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","netbkp_connection_testing_fail"))},TestConnectionDone:function(e,t){if(e){var s={servertype:"synology",share:"share"};(s=this.getParamsVal(s)).ip=t.ip,this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"remote_version_check",params:s,scope:this,callback:this.TestServerVersionDone})}else this.owner.clearStatusBusy(),t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","netbkp_connection_testing_fail"))},TestServerVersionWhenGoNext:function(e,t){this.owner.clearStatusBusy(),e?this.owner.goNext(this.nextId):t&&t.errors&&t.errors.key?"netbkp_e_unknown"!==t.errors.key?this.owner.goNext(this.nextId):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("lunbkp","server_version_error")):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","netbkp_connection_testing_fail"))},TestConnectionWhenGoNext:function(e,t){if(e){var s={servertype:"synology",share:"share"};(s=this.getParamsVal(s)).ip=t.ip,this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"remote_version_check",params:s,scope:this,callback:this.TestServerVersionWhenGoNext})}else this.owner.clearStatusBusy(),t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","netbkp_connection_testing_fail"))},onTestConnectionButton:function(e){var t={};if(t.servertype=SYNO.SDS.LunBackup.LUNBKP_SYNO_SERVER,t=this.getParamsVal(t)){var s="next"===e?this.TestConnectionWhenGoNext:this.TestConnectionDone;SYNO.SDS.LunBackup.onTestSvrConnection("test_connections",t,this,s)}else this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","netbkp_err_host_str"))},getParamsVal:function(e){var t=this.getForm(),s=t.findField("server").getRawValue(),i=SYNO.SDS.LunBackup.GetServerName(s),a=SYNO.SDS.LunBackup.GetServerIP(s);return""===i&&""===a?(this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","netbkp_err_host_str")),!1):(e.server=i,e.ip=a,e.account=t.findField("account").getValue(),e.password=t.findField("password").getValue(),e.module="",e.incrbkp_enable=!1,e.ssh_enable=!1,e.compression_enable=!1,e.blockbkp_enable=!1,e)}}),Ext.define("SYNO.SDS.Backup.LUNResNetShare",{extend:"SYNO.ux.FormPanel",initialized:!1,RemoteStore:null,constructor:function(e){this.RemoteStore=new Ext.data.SimpleStore({id:"dsRemoteShare",fields:["value"],data:[]});var t={items:[{xtype:"syno_combobox",fieldLabel:_T("netbackup","restore_share_folder"),name:"remoteShare",store:this.RemoteStore,allowBlank:!1,displayField:"value",valueField:"value",width:250}]};Ext.apply(t,e),this.callParent([t])},activate:function(){this.initialized||this.remoteShareEnum()},saveSettings:function(){this.wizardStore.netRcvrParams.module=this.getForm().findField("remoteShare").getValue()},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),this.nextId)},summary:function(e){},remoteShareEnumDone:function(e,t){this.owner.clearStatusBusy(),e?(this.RemoteStore.loadData(t.shares,!1),0<this.RemoteStore.getTotalCount()?(this.getForm().findField("remoteShare").setValue(t.shares[0][0]),this.wizardStore.netRcvrParams.ip=t.server_ip,this.owner.getButton("next").enable()):(this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("ftp","ftp_no_share")),this.owner.getButton("next").disable())):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):(this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system")),this.owner.getButton("next").disable())},remoteShareEnum:function(){var e={user:this.wizardStore.netRcvrParams.account,password:this.wizardStore.netRcvrParams.password,server:this.wizardStore.netRcvrParams.server,ip:this.wizardStore.netRcvrParams.ip,type:"lunrtor"};this.owner.setStatusBusy({text:_T("netbackup","netbkp_search_folder")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_remote_share",params:e,scope:this,callback:this.remoteShareEnumDone})}}),Ext.define("SYNO.SDS.Backup.LUNResLocSrc",{extend:"SYNO.ux.FormPanel",isActivatedBefore:!1,constructor:function(e){var t=new Ext.data.SimpleStore({id:"value",fields:["value","display"],data:e.wizardStore.localRcvrSrcList});e.wizardStore.localRcvrSrcStore=t;var s={items:[new SYNO.ux.ComboBox({fieldLabel:_T("backup","local_restore_rcvr_folder"),hiddenName:"localrcvrsrc",name:"localrcvrsrc",forceSelection:!0,editable:!1,store:e.wizardStore.localRcvrSrcStore,displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0,width:200,value:"",mode:"local"})]};Ext.apply(s,e),this.callParent([s])},activate:function(){this.isActivatedBefore||(this.isActivatedBefore=!0,this.localRcvrSrcRequest())},saveSettings:function(){this.wizardStore.localRcvrSrc=this.getForm().findField("localrcvrsrc").getValue()},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),this.nextId)},summary:function(e){},localRcvrSrcDone:function(e,t){if(this.owner.clearStatusBusy(),e){for(var s=0;s<t.total;s++)this.wizardStore.localRcvrSrcList.push([t.items[s],t.items[s]]);this.wizardStore.localRcvrSrcStore.loadData(this.wizardStore.localRcvrSrcList,!1),0<this.wizardStore.localRcvrSrcList.length?(this.getForm().findField("localrcvrsrc").setValue(this.wizardStore.localRcvrSrcList[0][0]),this.owner.getButton("next").enable()):this.owner.getButton("next").disable()}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):(this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system")),this.owner.getButton("next").disable())},localRcvrSrcRequest:function(){this.wizardStore.localRcvrSrcList.length=0,this.owner.setStatusBusy({text:_T("backup","search_restore_folder")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_local_share",scope:this,callback:this.localRcvrSrcDone})}}),Ext.define("SYNO.SDS.Backup.ResLocSrcCID",{extend:"SYNO.ux.FormPanel",isActivatedBefore:!1,constructor:function(e){var t=new Ext.data.SimpleStore({id:"value",fields:["value","display"],data:e.wizardStore.localSrcCIDList});e.wizardStore.localSrcCIDStore=t;var s=new SYNO.ux.ComboBox({fieldLabel:_T("backup","backup_dest_directory"),hiddenName:"localsrccid",name:"localsrccid",forceSelection:!0,editable:!1,store:e.wizardStore.localSrcCIDStore,displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0,width:200,value:"",mode:"local"}),i={items:[s]};Ext.apply(i,e),this.callParent([i]),s.on("select",(function(){this.wizardStore.blChangeRcvrSrc=!0}),this)},activate:function(){this.localSrcCIDRequest()},saveSettings:function(){this.wizardStore.localSrcCID=this.getForm().findField("localsrccid").getValue()},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),this.nextId)},summary:function(e){},localSrcCIDDone:function(e,t){if(this.owner.clearStatusBusy(),e){for(var s=0;s<t.total;s++)this.wizardStore.localSrcCIDList.push([t.items[s],t.items[s]]);this.wizardStore.localSrcCIDStore.loadData(this.wizardStore.localSrcCIDList,!1),0<this.wizardStore.localSrcCIDList.length?(this.getForm().findField("localsrccid").setValue(this.wizardStore.localSrcCIDList[0][0]),this.owner.getButton("next").enable()):(this.getForm().findField("localsrccid").setValue(""),this.owner.getButton("next").disable())}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):(this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system")),this.owner.getButton("next").disable())},localSrcCIDRequest:function(){var e={};this.wizardStore.localSrcCIDList.length=0,e.share=this.wizardStore.localRcvrSrc,this.owner.setStatusBusy({text:_T("lunbkp","search_client_folder")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_local_lun_dir",params:e,scope:this,callback:this.localSrcCIDDone})}}),Ext.define("SYNO.SDS.Backup.ResDestVol",{extend:"SYNO.ux.FormPanel",isActivatedBefore:!1,lunName:null,constructor:function(e){var t=new Ext.data.SimpleStore({id:"value",fields:["value","display"],data:e.wizardStore.destVolumeList});e.wizardStore.destVolumeStore=t;var s=new SYNO.ux.ComboBox({fieldLabel:_T("localbkp","localbkp_dest"),hiddenName:"destvolume",name:"destvolume",forceSelection:!0,editable:!1,store:e.wizardStore.destVolumeStore,tpl:'<tpl for="."><div ext:qtip="{display}" class="x-combo-list-item">{display}</div></tpl>',displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0,width:200,value:"",mode:"local"}),i={items:[s]};Ext.apply(i,e),SYNO.SDS.Backup.ResDestVol.superclass.constructor.call(this,i),s.on("select",(function(e,t,s){this.getForm().findField("destvolume").el.dom.qtip=this.wizardStore.destVolumeList[s][1]}),this)},activate:function(){this.isActivatedBefore||(this.isActivatedBefore=!0,this.destVolumeRequest()),this.wizardStore.blExistedTask?this.loadLUNBkpConf(this.wizardStore.taskname):SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.wizardStore.bkptype?this.enumLocLUNName():SYNO.SDS.LunBackup.BKPTASK_NETLUN===this.wizardStore.bkptype&&this.enumNetLUNName()},saveSettings:function(){this.wizardStore.destVolume=this.getForm().findField("destvolume").getValue()},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),this.nextId)},enumLocLUNNameDone:function(e,t){this.owner.clearStatusBusy(),e?(this.wizardStore.lunName=t.items[0].lunname_org,this.wizardStore.lunSize=t.items[0].lunsize,this.wizardStore.renamedLun=t.items[0].lunname_new,this.wizardStore.blocksize=t.items[0].blocksize,this.wizardStore.lun_type=t.items[0].lun_type,this.wizardStore.dev_attribs=t.items[0].dev_attribs,this.wizardStore.directIOPattern=t.items[0].directIOPattern,this.wizardStore.advLun=t.items[0].advLun):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system"))},enumLocLUNName:function(){var e={};e.share=this.wizardStore.localRcvrSrc,e.dir=this.wizardStore.localSrcCID,this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_local_restore_lun_name",params:e,scope:this,callback:this.enumLocLUNNameDone})},enumNetLUNNameDone:function(e,t){this.owner.clearStatusBusy(),e?(this.wizardStore.lunName=t.items[0].lunname_org,this.wizardStore.renamedLun=t.items[0].lunname_new,this.wizardStore.lunSize=t.items[0].lunsize,this.wizardStore.blocksize=t.items[0].blocksize,this.wizardStore.lun_type=t.items[0].lun_type,this.wizardStore.dev_attribs=t.items[0].dev_attribs,this.wizardStore.directIOPattern=t.items[0].directIOPattern,this.wizardStore.advLun=t.items[0].advLun):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system"))},enumNetLUNName:function(){var e={share:this.wizardStore.netRcvrParams.module,dir:this.wizardStore.netSrcCID,account:this.wizardStore.netRcvrParams.account,password:this.wizardStore.netRcvrParams.password,server:this.wizardStore.netRcvrParams.server,ip:this.wizardStore.netRcvrParams.ip};this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_net_restore_lun_name",params:e,scope:this,callback:this.enumNetLUNNameDone})},loadLUNBkpConfDone:function(e,t){this.owner.clearStatusBusy(),e?(this.wizardStore.serverIP=t.items[0].ip,this.wizardStore.account=t.items[0].user,this.wizardStore.sourcePath=t.items[0].dest,this.wizardStore.lunName=t.items[0].lunname_org,this.wizardStore.renamedLun=t.items[0].lunname_new,this.wizardStore.blocksize=t.items[0].blocksize,this.wizardStore.lun_type=t.items[0].lun_type):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system"))},loadLUNBkpConf:function(e){var t={};t.taskname=e,this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"load_lun_bkp_conf",params:t,scope:this,callback:this.loadLUNBkpConfDone})},summary:function(e){if(this.wizardStore.blExistedTask)SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.wizardStore.bkptype?e.append(_T("backup","restore_type"),_T("lunbkp","local_lun_restore")):(e.append(_T("backup","restore_type"),_T("lunbkp","network_lun_restore")),e.append(_T("netbackup","netbkp_slct_server"),String.format(_T("netbackup","synology_server"),_D("company_title"))),e.append(_T("netbackup","restore_server"),this.wizardStore.serverIP),e.append(_T("netbackup","netbkp_auth_user"),this.wizardStore.account)),e.append(_T("netbackup","netbkp_restore_folder"),this.wizardStore.sourcePath);else if(SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.wizardStore.bkptype)e.append(_T("backup","restore_type"),_T("lunbkp","local_lun_restore")),e.append(_T("netbackup","netbkp_restore_folder"),this.wizardStore.localRcvrSrc+"/"+this.wizardStore.localSrcCID+"/");else{e.append(_T("backup","restore_type"),_T("lunbkp","network_lun_restore")),e.append(_T("netbackup","netbkp_slct_server"),String.format(_T("netbackup","synology_server"),_D("company_title")));var t=this.wizardStore.netRcvrParams.server.length>0?this.wizardStore.netRcvrParams.server:this.wizardStore.netRcvrParams.ip;e.append(_T("netbackup","restore_server"),t),e.append(_T("netbackup","netbkp_auth_user"),this.wizardStore.netRcvrParams.account),e.append(_T("netbackup","netbkp_restore_folder"),this.wizardStore.netRcvrParams.module+"/"+this.wizardStore.netSrcCID+"/")}this.wizardStore.dest=this.wizardStore.destVolume+"/"+this.wizardStore.renamedLun,e.append(_T("lunbkp","restore_lun"),this.wizardStore.lunName),e.append(_T("lunbkp","name_after_restored"),this.wizardStore.dest)},destVolumeDone:function(e,t){if(this.owner.clearStatusBusy(),e){this.wizardStore.blChangeRcvrSrc=!0;for(var s=0;s<t.volume_list.length;s++)this.wizardStore.destVolumeList.push([t.volume_list[s].mount_point.substring(1,t.volume_list[s].mount_point.length),t.volume_list[s].display]);this.wizardStore.destVolumeStore.loadData(this.wizardStore.destVolumeList,!1),0<this.wizardStore.destVolumeList.length?(this.getForm().findField("destvolume").setValue(this.wizardStore.destVolumeList[0][0]),this.getForm().findField("destvolume").el.dom.qtip=this.wizardStore.destVolumeList[0][1],this.owner.getButton("next").enable()):this.owner.getButton("next").disable()}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):(this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system")),this.owner.getButton("next").disable())},destVolumeRequest:function(){this.wizardStore.destVolumeList.length=0,this.owner.setStatusBusy({text:_T("lunbkp","search_dest_volume")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_volume",scope:this,callback:this.destVolumeDone})}}),Ext.define("SYNO.SDS.Backup.MultiVerLunResDestVol",{extend:"SYNO.ux.FormPanel",isActivatedBefore:!1,destVolume:null,destVolumeList:[],destVolumeStore:null,constructor:function(e){this.destVolumeStore=new Ext.data.SimpleStore({id:"value",fields:["value","display"]});var t=new SYNO.ux.ComboBox({fieldLabel:_T("localbkp","localbkp_dest"),hiddenName:"destvolume",name:"destvolume",forceSelection:!0,editable:!1,store:this.destVolumeStore,tpl:'<tpl for="."><div ext:qtip="{display}" class="x-combo-list-item">{display}</div></tpl>',displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0,width:200,value:"",mode:"local"}),s={items:[t]};Ext.apply(s,e),SYNO.SDS.Backup.MultiVerLunResDestVol.superclass.constructor.call(this,s),t.on("select",(function(e,t,s){this.getForm().findField("destvolume").el.dom.qtip=this.destVolumeList[s][1]}),this)},activate:function(){this.isActivatedBefore||(this.isActivatedBefore=!0,this.destVolumeRequest())},saveSettings:function(){this.destVolume=this.getForm().findField("destvolume").getValue(),this.displayDestVolume=this.getForm().findField("destvolume").getRawValue()},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),this.nextId)},summary:function(e){e.append(_T("localbkp","localbkp_dest"),`${this.displayDestVolume}`)},destVolumeDone:function(e,t){if(this.owner.clearStatusBusy(),e){for(var s=0;s<t.volume_list.length;s++)this.destVolumeList.push([t.volume_list[s].mount_point.substring(1,t.volume_list[s].mount_point.length),t.volume_list[s].display]);this.destVolumeStore.loadData(this.destVolumeList,!1),0<this.destVolumeList.length?(this.getForm().findField("destvolume").setValue(this.destVolumeList[0][0]),this.getForm().findField("destvolume").el.dom.qtip=this.destVolumeList[0][1],this.owner.getButton("next").enable()):this.owner.getButton("next").disable()}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):(this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system")),this.owner.getButton("next").disable())},destVolumeRequest:function(){this.destVolumeList=[],this.owner.setStatusBusy({text:_T("lunbkp","search_dest_volume")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_volume",scope:this,callback:this.destVolumeDone})},getParams:function(){return{location:`/${this.destVolume}`}}}),Ext.define("SYNO.SDS.Backup.ResNetSrcCID",{extend:"SYNO.ux.FormPanel",loadFinished:!1,enableNext:!1,isActivatedBefore:!1,taskPolling:null,constructor:function(e){var t=new Ext.data.SimpleStore({id:"value",fields:["value","display"],data:e.wizardStore.netSrcCIDList});e.wizardStore.netSrcCIDStore=t;var s=new SYNO.ux.ComboBox({fieldLabel:_T("backup","backup_dest_directory"),hiddenName:"netSrcCID",name:"netSrcCID",forceSelection:!0,editable:!1,store:e.wizardStore.netSrcCIDStore,displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0,width:200,value:"",mode:"local"}),i={items:[s]};Ext.apply(i,e),s.on("select",(function(){this.wizardStore.blChangeRcvrSrc=!0}),this),this.callParent([i])},load:function(){this.wizardStore.netSrcCIDList.length=0,this.netSrcCIDRequest()},activate:function(){this.enableNext=!1,this.loadFinished=!1,this.wizardStore.netSrcCIDStore.loadData([],!1),this.getForm().findField("netSrcCID").clearValue(),this.isActivatedBefore||this.load()},checkState:function(){SYNO.SDS.Wizard.Step.prototype.checkState.apply(this,arguments),this.loadFinished&&this.enableNext?this.owner.getButton("next").enable():this.owner.getButton("next").disable()},saveSettings:function(){this.wizardStore.netSrcCID=this.getForm().findField("netSrcCID").getValue()},getNext:function(){return!!this.getForm().isValid()&&(this.saveSettings(),this.nextId)},summary:function(e){},netSrcCIDDone:function(e,t){if(this.owner.clearStatusBusy(),e){this.enableNext=!0,this.loadFinished=!0,this.checkState();for(var s=0;s<t.total;s++)this.wizardStore.netSrcCIDList.push([t.items[s],t.items[s]]);null!==this.wizardStore.netSrcCIDStore&&this.wizardStore.netSrcCIDStore.loadData(this.wizardStore.netSrcCIDList,!1),t.params&&(this.wizardStore.netRcvrParams=t.params),0<this.wizardStore.netSrcCIDList.length?(this.getForm().findField("netSrcCID").setValue(this.wizardStore.netSrcCIDList[0][0]),this.owner.getButton("next").enable()):(this.getForm().findField("netSrcCID").setValue(""),this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("netbackup","bkp_host_no_dir")),this.owner.getButton("next").disable())}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","error_system"))},netSrcCIDRequest:function(){var e={servertype:"synology"};e.share=this.wizardStore.netRcvrParams.module,this.GetParams(e),this.SearchRequest(e,_T("backup","search_restore_folder"),this.netSrcCIDDone)},GetParams:function(e){e.account=this.wizardStore.netRcvrParams.account,e.ip=this.wizardStore.netRcvrParams.ip,e.server=this.wizardStore.netRcvrParams.server,e.module=this.wizardStore.netRcvrParams.module,e.password=this.wizardStore.netRcvrParams.password},SearchRequest:function(e,t,s){this.owner.setStatusBusy(_T("lunbkp","search_directory")),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_net_lun_dir",params:e,scope:this,callback:s})}}),Ext.define("SYNO.SDS.Backup.Restore.SelectMultiVerLunStep",{extend:"Ext.Container",constructor(e){this.vuePanel=new SYNO.SDS.VuePanel({height:413,vueClass:Vue.component("SYNO.SDS.Backup.Vue.SelectMutliVerLunVersion",SYNO.SDS.Backup.Vue.SelectMutliVerLunVersion),owner:this});const t={style:{padding:"12px 0 0 0"},items:[this.vuePanel]};this.callParent([Ext.apply(t,e)])},getVueComponent(){return this.vuePanel.components[0]},loadVersion(){const e=this.owner.taskId;this.getVueComponent().onActivate({task_id:e})},activate(){var e=this.owner.getBaseParams();"sfr_s3"!==this.owner.transferType?0<e.task_id||"cloud_image"!==e.target_type?this.loadVersion():this.lastQueryCloudCache!==Ext.encode(e)&&(this.owner.setStatusBusy({text:_T("backup","search_restore_config")}),this.sendWebAPI({api:"SYNO.Backup.Target",version:1,method:"create_cache",params:e,encryption:SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],e),scope:this,callback:function(e,t,s){if(!e)return this.owner.clearStatusBusy(),void this.owner.reportFatalError(SYNO.SDS.Backup.GetErrorString(t.code));this.owner.cache_sess_id=t.cache_sess_id,this.lastQueryCloudCache=Ext.encode(this.owner.getBaseParams()),this.loadVersion()}})):this.owner.reportFatalError(SYNO.SDS.Backup.String("error","cloud_not_support_sfr"))},getNext(){return!!this.getVueComponent().enterNextPre()&&this.nextId},getParams(){return this.getVueComponent().getParams()},summary(e){const t=this.getVueComponent().getSummary();for(const s of t)e.append(s[0],s[1])}}),Ext.define("SYNO.SDS.Backup.Restore.RestoreWizard",{extend:"SYNO.SDS.Backup.Restore.BasicRestoreWizard",constructor:function(e){this.dssCache={},Ext.copyTo(this,e,"owner"),e.skipConfBackup="yes"===_D("support_hyper_converged"),this.api=new SYNO.SDS.Backup.ApiHelper({owner:this}),this.taskId=-1;var t=SYNO.Backup.Addon.Config.addon_list;this.restoreLUNStore={blExistedTask:!1,blChangeRcvrSrc:!0,selectedShareCount:0,localRcvrSrcList:[],localSrcCIDList:[],netSrcShareList:[],netSrcCIDList:[],destVolumeList:[],shareList:[],netRcvrParams:{}};var s,i=[new SYNO.SDS.Backup.RestoreTypePanel({owner:this,headline:SYNO.SDS.Backup.String("app","select_data_type_title_restore"),itemId:"restore_type",getNext:function(){if(!this.getForm().isValid())return!1;switch(this.getForm().getValues().restore_type){case"restore_type_data":return"main_branch";case"restore_type_lun":return this.owner.restoreLUNGetLocalIPs(),"type";case"restore_type_dsm":return this.owner.restoreDSMConfirmLaunchingControlPanel(),!1;case"restore_type_multi_ver_lun":return"multi_ver_lun_main_branch"}return!1}}),new SYNO.SDS.Backup.Restore.MainBranch({owner:this,headline:SYNO.SDS.Backup.String("app","task_restore_wizard_title"),bodyStyle:"max-height: 367px; min-height: 367px",itemId:"main_branch",nextId:{restore_from_task:"config",restore_from_other:"dest_type"},taskList:this.getDataTaskList()}),new SYNO.SDS.Backup.Restore.RepoTypePanel({owner:this,headline:SYNO.SDS.Backup.String("app","repo_type_restore_wizard_title"),itemId:"dest_type",nextId:(s={},Ext.each(t,(function(e,t,i){s[e.id]=e.id+"::restore_setting"})),s)}),new SYNO.SDS.Backup.Restore.ConfigStep({headline:SYNO.SDS.Backup.String("app","source_config_restore_wizard_title"),itemId:"config",nextId:"share",owner:this}),new SYNO.SDS.Backup.Restore.ShareStep({headline:SYNO.SDS.Backup.String("app","source_share_restore_wizard_title"),itemId:"share",nextId:"app",owner:this}),new SYNO.SDS.Backup.Restore.AppStep({headline:SYNO.SDS.Backup.String("app","source_pkg_restore_wizard_title"),itemId:"app",nextId:"data_summary",bodyStyle:"max-height: 380px; min-height: 380px",owner:this}),new SYNO.SDS.Backup.SummaryStep({headline:SYNO.SDS.Backup.String("app","restore_summary"),itemId:"data_summary",nextId:null,getNext:function(){return this.owner.onRestore(),!1},owner:this,columns:[{width:200,header:_T("status","header_item"),dataIndex:"key",renderer:this.fieldRenderer},{id:"value",autoExpand:!0,header:_T("status","header_value"),dataIndex:"value",renderer:this.descRenderer,scope:this}]}),new SYNO.SDS.Backup.LUNResTypePanel({headline:_T("backup","restore_wizard_desttype_title"),description:_T("backup","reswizard_type_title"),itemId:"type",nextId:["dest-volume","net-srccid","loc-src","syno-server"],taskList:this.getLUNTaskList(),wizardStore:this.restoreLUNStore,owner:this}),new SYNO.SDS.Backup.LUNResSynoSerPanel({headline:_T("netbackup","recover_serverset_title"),description:_T("netbackup","netbkp_serverset3_desc"),itemId:"syno-server",nextId:"net-share",wizardStore:this.restoreLUNStore,owner:this}),new SYNO.SDS.Backup.LUNResNetShare({headline:_T("lunbkp","source_folder_title"),description:_T("lunbkp","source_folder_desc"),itemId:"net-share",nextId:"net-srccid",wizardStore:this.restoreLUNStore,owner:this}),new SYNO.SDS.Backup.LUNResLocSrc({headline:_T("lunbkp","source_folder_title"),description:_T("lunbkp","source_folder_desc"),itemId:"loc-src",nextId:"loc-srccid",wizardStore:this.restoreLUNStore,owner:this}),new SYNO.SDS.Backup.ResLocSrcCID({headline:_T("lunbkp","directory_title"),description:_T("lunbkp","directory_desc"),itemId:"loc-srccid",nextId:"dest-volume",wizardStore:this.restoreLUNStore,owner:this}),new SYNO.SDS.Backup.ResDestVol({headline:_T("lunbkp","dest_vol_select"),description:_T("lunbkp","dest_vol_select_desc"),itemId:"dest-volume",nextId:"lun_summary",wizardStore:this.restoreLUNStore,owner:this}),new SYNO.SDS.Backup.ResNetSrcCID({headline:_T("lunbkp","directory_title"),description:_T("lunbkp","directory_desc"),itemId:"net-srccid",nextId:"dest-volume",wizardStore:this.restoreLUNStore,owner:this}),new SYNO.SDS.Wizard.SummaryStep({headline:_T("localbkpwizard","summary_title"),description:_T("wizcommon","summary_descr"),itemId:"lun_summary",nextId:null,getNext:function(){return this.owner.restoreLUN(),!1},owner:this}),new SYNO.SDS.Backup.Restore.MainBranch({owner:this,headline:SYNO.SDS.Backup.String("app","task_restore_wizard_title"),bodyStyle:"max-height: 367px; min-height: 367px",itemId:"multi_ver_lun_main_branch",nextId:{restore_from_task:"multi_ver_lun_dest_volume",restore_from_other:"multi_ver_lun_dest_type"},taskList:this.getMultiVerLUNTaskList()}),new SYNO.SDS.Backup.Restore.LUNMultiVerRepoTypePanel({owner:this,headline:SYNO.SDS.Backup.String("app","repo_type_restore_wizard_title"),itemId:"multi_ver_lun_dest_type",nextId:function(){var e={};return Ext.each(t,(function(t,s,i){e[t.id]=t.id+"::multi_ver_lun_restore_setting"})),e}()}),new SYNO.SDS.Backup.MultiVerLunResDestVol({headline:_T("lunbkp","dest_vol_select"),description:_T("lunbkp","dest_vol_select_desc"),itemId:"multi_ver_lun_dest_volume",nextId:"multi_ver_lun_select_version",owner:this}),new SYNO.SDS.Backup.Restore.SelectMultiVerLunStep({headline:SYNO.SDS.Backup.String("restore_ed","select_version_title"),description:SYNO.SDS.Backup.String("restore_ed","select_version_desc"),itemId:"multi_ver_lun_select_version",nextId:"multi_ver_lun_data_summary",owner:this}),new SYNO.SDS.Backup.SummaryStep({headline:SYNO.SDS.Backup.String("app","restore_summary"),itemId:"multi_ver_lun_data_summary",nextId:null,getNext:function(){return this.owner.onRestoreMultiVerLun(),!1},owner:this,columns:[{width:200,header:_T("status","header_item"),dataIndex:"key",renderer:this.fieldRenderer},{id:"value",autoExpand:!0,header:_T("status","header_value"),dataIndex:"value",renderer:this.descRenderer,scope:this}]})];this.callParent([Ext.apply({title:SYNO.SDS.Backup.String("app","main_branch_restore_wizard_title"),cls:"syno-backup-restore-wizard",width:700,height:580,banner:!0,steps:i},e)])},setSingle:function(e){this.isSingle=e},targetGetErrorHandle:function(e){SYNO.SDS.Backup.ERR_TARGET_BROKEN===e.code?this.getMsgBox().alert(_T("tree","leaf_backup"),SYNO.SDS.Backup.String("error","target_not_support")):SYNO.SDS.Backup.ERR_SERVER_NOT_DOWNLOADABLE===e.code?this.getMsgBox().alert(_T("tree","leaf_backup"),SYNO.SDS.Backup.GetErrorStringArg(e.code,e.errors.error_msg)):this.api.alert(e)},createStep:function(e){var t=e.split(":")[0],s=e.split(":")[2],i=null,a=SYNO.Backup.Addon.Util.getInfo(t);if("restore_setting"===s){let s=SYNO.Backup.Addon.Util.getClass(t,"Restore.DestStep");s&&(i=new s({owner:this,itemId:e,backup_data_type:"data",target_type:a.target_type,transfer_type:a.transfer_type,nextId:"config",headline:SYNO.SDS.Backup.String("app","dest_info_restore_wizard_title"),description:SYNO.SDS.Backup.String("app","dest_info_restore_wizard_desc")}))}if("multi_ver_lun_restore_setting"===s){let s=SYNO.Backup.Addon.Util.getClass(t,"Restore.DestStep");s&&(i=new s({owner:this,itemId:e,backup_data_type:"multi_ver_lun",target_type:a.target_type,transfer_type:a.transfer_type,nextId:"multi_ver_lun_dest_volume",headline:SYNO.SDS.Backup.String("app","dest_info_restore_wizard_title"),description:SYNO.SDS.Backup.String("app","dest_info_restore_wizard_desc")}))}return i},getDestType:function(){return this.getStep("dest_type").getOption()},reportError:function(e,t){t=t||{},this.reporter||(this.reporter=new SYNO.SDS.Backup.ApiHelper({owner:this})),this.reporter.alert(e,t.callback,t.scope)},restoreLUNParams:function(){var e={},t=this.restoreLUNStore,s=t.bkptype;return e.rcvrtype=s,t.blExistedTask?(e.bytask=!0,e.taskname=t.taskname,e.destvolume=t.destVolume,e.lunname=t.lunName,e.advLun=t.advLun):SYNO.SDS.LunBackup.BKPTASK_LOCLUN===s?(e.dest=t.destVolume,e.share=t.localRcvrSrc,e.dir=t.localSrcCID,e.lunname=t.lunName,e.lunsize=t.lunSize,e.advLun=t.advLun,e.blocksize=t.blocksize,e.dev_attribs=t.dev_attribs,e.directIOPattern=t.directIOPattern,e.lun_type=t.lun_type):(e.dest=t.destVolume,e.share=t.netRcvrParams.module,e.dir=t.netSrcCID,e.lunname=t.lunName,e.lunsize=t.lunSize,e.advLun=t.advLun,e.blocksize=t.blocksize,e.account=t.netRcvrParams.account,e.ip=t.netRcvrParams.ip,e.server=t.netRcvrParams.server,e.password=t.netRcvrParams.password,e.dev_attribs=t.dev_attribs,e.directIOPattern=t.directIOPattern,e.lun_type=t.lun_type),e},restoreLUNDone:function(e,t){if(this.clearStatusBusy(),e){this.appWin.isRestoreWinShow=!0;var s=new SYNO.SDS.Backup.Restore.LunProgressWindow({owner:this.owner});s.on("close",(function(){this.appWin.isRestoreWinShow=!1}),this),this.close(),s.open()}else t&&t.errors&&""!==t.errors.sec&&""!==t.errors.key?this.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T(t.errors.sec,t.errors.key)):this.getMsgBox().alert(_T("netbackup","netbkp_recovery"),_T("common","commfail"))},restoreLUN:function(){this.setStatusBusy({text:_T("common","saving")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"restore_lun",params:this.restoreLUNParams(),scope:this,callback:this.restoreLUNDone})},getDataTaskList:function(){return this.owner.getTaskList().filter((function(e){return"data"===e.data_type}))},getMultiVerLUNTaskList:function(){return this.owner.getTaskList().filter((function(e){return"multi_ver_lun"===e.data_type}))},getLUNTaskList:function(){return this.owner.getTaskList().filter((function(e){return"lun"===e.data_type}))},restoreLUNGetLocalIPs:function(){SYNO.SDS.LunBackup.getLocalIPs(this,(function(e,t){e&&(this.restoreLUNStore.selfIPs=t.selfIPs,this.restoreLUNStore.selfHostName=t.selfHostName)}))},restoreDSMConfirmLaunchingControlPanel:function(){this.getMsgBox().confirm("",SYNO.SDS.Backup.String("app","restore_ed_at_control_panel_desc"),(function(e){"yes"===e&&(SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",{fn:"SYNO.SDS.AdminCenter.Update_Reset.Main",tab:"SystemRecoveryTab",open_recovery_dialog:!0}),this.close())}),this,{yes:{text:SYNO.SDS.Backup.String("app","restore_ed_at_control_panel_btn")},no:{text:_T("common","cancel")}})}}),Ext.define("SYNO.SDS.Backup.LUNDestEditPanel",{extend:"SYNO.ux.FormPanel",destStore:null,selfIPs:null,selfHostName:null,btnTestId:null,ServerStore:null,RemoteStore:null,RsyncModuleStore:null,RegionStore:null,BucketStore:null,BucketKeyed:!1,constructor:function(e){this.ServerList=[],this.destList=[],this.RegionList=[],this.BucketList=[],SYNO.SDS.LunBackup.getLocalIPs(this,(function(e,t){e&&(this.selfIPs=t.selfIPs,this.selfHostName=t.selfHostName)}));var t=this.initLayout(e);Ext.apply(t,e),this.callParent([t])},initLayout:function(e){var t;return SYNO.SDS.LunBackup.BKPTASK_LOCLUN===e.type?t=this.initDestLocal():SYNO.SDS.LunBackup.BKPTASK_NETLUN===e.type?t=this.initDestNet(e):SYNO.Debug("Invalid type"),t},onLoadLocalDest:function(){this.destList.length=0,this.owner.setStatusBusy({text:_T("localbkp","localbkp_wait_dest")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_local_bkp_dest",scope:this,callback:function(e,t){if(this.owner.clearStatusBusy(),e){for(var s=0;s<t.total;s++)this.destList.push([t.items[s].destValue,t.items[s].dest]);this.destStore.loadData(this.destList,!1)}}})},TestServerVersionDone:function(e,t){this.owner.clearStatusBusy(),e?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_success")):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),SYNO.SDS.Backup.String(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_fail"))},TestServerVersion:function(e,t){if(e){var s={servertype:"synology",share:"share",mode:"edit"};if(!(s=this.getTestconParams(s,!0)))return void this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_err_host_str"));s.ip=t.ip,this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"remote_version_check",params:s,scope:this,callback:this.TestServerVersionDone})}else this.owner.clearStatusBusy(),t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_fail"))},onTestConnectionButton:function(){var e={};(e=this.getTestconParams(e,!0))?SYNO.SDS.LunBackup.onTestSvrConnection("test_connections",e,this,this.TestServerVersion):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_err_host_str"))},getTestconParams:function(e,t){var s,i=this.getForm();if(i.findField("comboServer").isValid()&&((s=i.findField("comboServer")).getRawValue(),e.account=i.findField("textAccount").getValue(),e.module=t?i.findField("remoteShare").getValue():"",e.servertype=SYNO.SDS.LunBackup.LUNBKP_SYNO_SERVER,e.server=SYNO.SDS.LunBackup.GetServerName(s.getRawValue()),e.ip=SYNO.SDS.LunBackup.GetServerIP(s.getRawValue()),""!==e.server||""!==e.ip))return e.password=i.findField("password").getValue(),e.ssh_enable=!1,e.bkpset=this.owner.taskNameOrig,e},remoteShareEnumDone:function(e,t){this.owner.clearStatusBusy(),e?(this.RemoteStore.loadData(t.shares,!1),0<this.RemoteStore.getCount()?""===this.getForm().findField("remoteShare").getValue()&&this.getForm().findField("remoteShare").setValue(t.shares[0][0]):this.owner.getMsgBox().alert(_T("share","share_remote_volume"),_T("common","error_system"))):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("share","share_remote_volume"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("share","share_remote_volume"),_T("common","error_system"))},remoteShareEnum:function(e){this.owner.setStatusBusy({text:_T("netbackup","netbkp_search_folder")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"enum_remote_share",params:e,scope:this,callback:this.remoteShareEnumDone})},initDestLocal:function(){var e;return e=new Ext.data.ArrayStore({id:"value",fields:["value","display"],data:this.destList}),this.destStore=e,{title:Ext.util.Format.ellipsis(_T("localbkp","localbkp_detail_info"),15),tabTip:_T("localbkp","localbkp_detail_info"),items:[{xtype:"syno_textfield",fieldLabel:_T("localbkp","localbkp_bkpset_name"),name:"bkpset",maxlength:SYNO.SDS.LunBackup.BKPSET_MAX_LEN,vtype:"taskname",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,allowBlank:!1},{xtype:"syno_displayfield",hideLabel:!1,fieldLabel:_T("backup","backup_type"),hiddenName:"bkptype_localbkp",name:"bkptype_localbkp",value:_T("lunbkp","local_lunbkp"),labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH},{xtype:"syno_displayfield",hideLabel:!1,fieldLabel:_T("backup","backup_restore_source"),name:"lunSource",value:"",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH},{xtype:"syno_combobox",fieldLabel:_T("localbkp","localbkp_dest"),hiddenName:"localDest",name:"localDest",editable:!1,store:e,forceSelection:!0,allowBlank:!1,displayField:"display",valueField:"value",typeAhead:!0,triggerAction:"all",lazyRender:!0,labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH},{xtype:"syno_textfield",fieldLabel:_T("backup","backup_dest_directory"),name:"destDirectory",maxlength:32,allowBlank:!1,labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,vtype:"sharename"}]}},initDestNet:function(e){return this.ServerStore=new Ext.data.SimpleStore({fields:["value","display"],data:this.ServerList,sortInfo:{field:"display",direction:"ASC"}}),this.RemoteStore=new Ext.data.SimpleStore({id:"dsRemoteShare",fields:["value"],data:[]}),this.RsyncModuleStore=new Ext.data.SimpleStore({fields:["module"],data:[]}),{title:Ext.util.Format.ellipsis(_T("localbkp","localbkp_detail_info"),15),tabTip:_T("localbkp","localbkp_detail_info"),items:[{xtype:"syno_textfield",fieldLabel:_T("localbkp","localbkp_bkpset_name"),name:"bkpset",maxlength:SYNO.SDS.LunBackup.BKPSET_MAX_LEN,vtype:"taskname",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,allowBlank:!1},{xtype:"syno_displayfield",hideLabel:!1,fieldLabel:_T("backup","backup_type"),hiddenName:"bkptype_localbkp",name:"bkptype_localbkp",value:_T("lunbkp","net_lunbkp"),labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH},{xtype:"syno_combobox",fieldLabel:_T("netbackup","netbkp_set_ip"),hiddenName:"comboServer",name:"comboServer",forceSelection:!1,allowBlank:!1,emptyText:_T("netbackup","netbkp_input_addr"),editable:!0,store:this.ServerStore,displayField:"display",valueField:"value",triggerAction:"all",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,validateOnBlur:!0,validationEvent:"blur",mode:"local",validator:function(e){return SYNO.SDS.LunBackup.netbkpValidator(e,this.ownerCt.selfIPs,this.ownerCt.selfHostName)},onTriggerClick:function(){0!==this.getStore().getCount()?this.isExpanded()?(this.collapse(),this.el.focus()):(this.onFocus({}),this.expand(),this.el.focus()):(this.scope.serverListLoaded=!0,this.el.focus(),SYNO.SDS.LunBackup.onLoadSynologyServer(this,this.scope.ServerList,this.scope.owner))},listeners:{change:function(){this.scope.getForm().findField("remoteShare").setValue("")}},scope:this},{xtype:"syno_textfield",fieldLabel:_T("netbackup","netbkp_account"),name:"textAccount",emptyText:_T("netbackup","netbkp_input"),labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,validateOnBlur:!0,validationEvent:"blur",allowBlank:!1,vtype:"username_ext",scope:this,listeners:{change:function(){this.scope.owner.blUserChanged=!0}}},{xtype:"syno_textfield",fieldLabel:_T("common","password"),name:"password",inputType:"password",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,scope:this,listeners:{change:function(){this.scope.owner.blUserChanged=!0}}},{xtype:"syno_displayfield",hideLabel:!1,fieldLabel:_T("backup","backup_restore_source"),name:"lunSource",value:"",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH},{xtype:"syno_combobox",fieldLabel:_T("netbackup","dest_share_folder"),name:"remoteShare",store:this.RemoteStore,allowBlank:!1,displayField:"value",valueField:"value",labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,triggerAction:"all",onTriggerClick:function(){var e={};(e=this.scope.getTestconParams(e,!1))?SYNO.SDS.LunBackup.onTestSvrConnection("test_connections",e,this.scope,(function(e,t){if(this.owner.clearStatusBusy(),e){var s={},i=this.getForm().findField("comboServer").getValue();s.task=this.owner.taskNameOrig,s.user=this.getForm().findField("textAccount").getValue(),s.password=this.getForm().findField("password").getValue(),s.server=SYNO.SDS.LunBackup.GetServerName(i),s.ip=SYNO.SDS.LunBackup.GetServerIP(i),s.type="lunbkp";var a=this.getForm().findField("remoteShare");a.isExpanded()?(a.collapse(),a.el.focus()):(a.onFocus({}),a.expand(),a.el.focus()),this.remoteShareEnum(s)}else t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_fail"))})):this.scope.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_err_host_str"))},scope:this},{xtype:"syno_textfield",fieldLabel:_T("backup","backup_dest_directory"),itemId:"destDirectory",maxlength:32,allowBlank:!1,labelWidth:SYNO.SDS.LunBackup.BKP_DEST_LABEL_WIDTH,width:SYNO.SDS.LunBackup.BKP_DEST_CONTD_WIDTH,vtype:"sharename"},{xtype:"syno_button",id:this.btnTestId=Ext.id(),labelSeparator:"",name:"testconbtn",hiddenName:"testconbtn",text:_T("netbackup","netbkp_test_connection"),handler:this.onTestConnectionButton,scope:this}]}},switchNetLayout:function(e){var t=this.getForm();SYNO.SDS.Utils.DisplayField(t,"comboServer",!0),SYNO.SDS.Utils.DisplayField(t,"remoteShare",!0)}}),Ext.define("SYNO.SDS.Backup.ScheduleEditPanel",{extend:"SYNO.ux.FormPanel",isLoaded:!1,advanceScheduleDialog:null,weekArray:null,constructor:function(e){this.weekArray=SYNO.SDS.Backup.Client.Common.Utils.WeekArray;var t=new Ext.data.SimpleStore({fields:["value","display"],data:this.weekArray}),s={title:Ext.util.Format.ellipsis(_T("common","schedule"),15),tabTip:_T("common","schedule"),padding:e.padding,items:[{xtype:"syno_checkbox",boxLabel:_T("netbackup","netbkp_set_schedule"),name:"schedule_enable"},{xtype:"syno_radio",name:"schedule_type",inputValue:"basic",boxLabel:_T("schedule","schedule_basic"),checked:!0,indent:1},{xtype:"syno_compositefield",hideLabel:!0,fieldLabel:"composite field",name:"basic_time",indent:2,items:[{xtype:"syno_displayfield",name:"text_week",value:_T("time","time_day")},{xtype:"syno_combobox",name:"basic_weekday",store:t,displayField:"display",valueField:"value",width:90},{border:!1,width:50},{xtype:"syno_displayfield",name:"text_hour",value:_T("time","time_hour")},{xtype:"syno_combobox",name:"hour",displayField:"display",valueField:"value",store:SYNO.SDS.Backup.createTimeItemStore("hour"),width:70},{border:!1,width:10},{xtype:"syno_displayfield",name:"text_min",value:_T("time","time_minute")},{xtype:"syno_combobox",name:"minute",displayField:"display",valueField:"value",store:SYNO.SDS.Backup.createTimeItemStore("min"),width:70}]},{xtype:"syno_radio",name:"schedule_type",inputValue:"advance",boxLabel:_T("schedule","schedule_advance"),checked:!1,indent:1},{xtype:"syno_button",id:"btn_schedule",name:"btn_schedule",text:_T("schedule","schedule_title"),handler:this.launchScheduleDialog,scope:this,indent:2},{xtype:"syno_displayfield",name:"txtadvscheduletime",labelSeparator:"",value:"",height:"12px",style:"margin-left: 80px"},{xtype:"syno_displayfield",name:"txtadvscheduleday",labelSeparator:"",value:"",height:"12px",style:"margin-left: 80px"}]};Ext.apply(s,e),this.callParent([s]),this.mon(this,"afterlayout",(function(e,t){new SYNO.ux.Utils.EnableCheckGroup(e.getForm(),"schedule_enable",["schedule_type","text_week","basic_weekday","text_hour","hour","text_min","minute","btn_schedule"]),new SYNO.ux.Utils.EnableRadioGroup(e.getForm(),"schedule_type",{basic:["text_week","basic_weekday","text_hour","hour","text_min","minute"],advance:["btn_schedule"]});for(var s=SYNO.ux.Utils.getRadioGroup(e.getForm(),"schedule_type"),i=0;i<s.length;i++){var a=s[i];a.mon(a,"check",this.onScheduleTypeChecked,this)}}),this,{single:!0})},onScheduleTypeChecked:function(e,t){t&&("basic"===e.getInputValue()?(this.getForm().findField("txtadvscheduletime").setValue(""),this.getForm().findField("txtadvscheduleday").setValue("")):this.LUNBackupParam.schedule&&this.advSchedulePrint(this.LUNBackupParam.schedule))},advSchedulePrint:function(e){if(e){var t=this.getForm().findField("txtadvscheduletime"),s=this.getForm().findField("txtadvscheduleday");t.setValue(this.timeScheduleToString(e)),s.setValue(this.dateScheduleToString(e))}},afterScheduleDialog:function(){this.owner.schedule&&(this.LUNBackupParam.schedule=this.deConstructJson(this.owner.schedule),this.advSchedulePrint(this.LUNBackupParam.schedule))},launchScheduleDialogDone:function(e,t){this.advanceScheduleDialog=new SYNO.SDS.TaskScheduler2.ScheduleDialog({title:_T("schedule","schedule_advance"),height:472,owner:this.owner}),this.advanceScheduleDialog.mon(this.advanceScheduleDialog,"hide",this.afterScheduleDialog,this),this.owner.clearStatusBusy(),e?this.advanceScheduleDialog.onOpen(this.reConstructJson(t.task.schedule)):t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))},launchScheduleDialog:function(){var e;this.LUNBackupParam.schedule?(this.owner.schedule=this.LUNBackupParam.schedule,(e=new SYNO.SDS.TaskScheduler2.ScheduleDialog({title:_T("schedule","schedule_advance"),height:472,owner:this.owner})).mon(e,"hide",this.afterScheduleDialog,this),e.open(this.reConstructJson(this.LUNBackupParam.schedule))):(this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"load_default_adv_schedule",scope:this,callback:this.launchScheduleDialogDone}))},loadForm:function(e){e&&(this.getForm().loadRecord(e),!1===e.data.schedule_enable?(Ext.getCmp("btn_schedule").disable(),this.getForm().findField("basic_weekday").disable(),this.getForm().findField("hour").disable(),this.getForm().findField("minute").disable(),this.getForm().findField("text_week").disable(),this.getForm().findField("text_hour").disable(),this.getForm().findField("text_min").disable()):"advance"===e.data.schedule_type&&this.LUNBackupParam.schedule&&this.advSchedulePrint(this.LUNBackupParam.schedule))},activate:function(){if(!1===this.isLoaded){var e={},t={};e.schedule_enable=!1,e.schedule_type="basic",e.basic_weekday="1",e.hour=0,e.minute=0,t.data=e,this.loadForm(t),this.isLoaded=!0}},getScheduleData:function(){var e,t=[],s=this.getForm();if(t.enableschedule=s.findField("schedule_enable").getValue(),t.basic="basic"===s.findField("schedule_type").getGroupValue(),t.basic){var i=s.findField("basic_weekday").getValue(),a=s.findField("hour").getValue(),n=s.findField("minute").getValue();(e={}).date_type=0,e.repeat=0,e.hour=a,e.min=n,e.repeat_hour=0,e.last_work_hour=a,e.week_name=String(i)}else this.LUNBackupParam.schedule?e=this.deConstructJson(this.LUNBackupParam.schedule):((e={}).date_type=0,e.repeat=0,e.hour=0,e.min=0,e.repeat_hour=0,e.last_work_hour=0,e.week_name="0,1,2,3,4,5,6");return t.schedule=e,t},reConstructJson:function(e){var t=e;return void 0===t.minute&&(t.minute=t.min),void 0===t.week_day&&(t.week_day=t.week_name),void 0===t.repeat_date&&(t.repeat_date=t.repeat),t},deConstructJson:function(e){var t=e;return void 0===t.min&&(t.min=t.minute),void 0===t.week_name&&(t.week_name=t.week_day),void 0===t.repeat&&(t.repeat=t.repeat_date),t},dateScheduleToString:function(e){return SYNO.SDS.Backup.Client.Common.Utils.DateScheduleToString(e)},timeScheduleToString:function(e){return SYNO.SDS.Backup.Client.Common.Utils.TimeScheduleToString(e)}}),Ext.define("SYNO.SDS.Backup.LUNEditDialog",{extend:"SYNO.SDS.ModalWindow",serverOrg:null,IPOrg:null,taskDestOrg:null,destDirectoryOrg:null,taskName:null,taskType:null,taskDest:null,destDirectory:null,lunSource:null,uuid:null,blScheduleLoad:!1,oldSchedule:null,oldScheduleType:null,oldScheduleEnable:null,constructor:function(e){var t=SYNO.SDS.Backup;this.isReadOnly=e.isReadOnly,this.shareList=[],this.LUNBackupData={blSrcChanged:!1,blDestChanged:!1,blUserChanged:!1,taskNameOrig:null,schedule:null,enableschedule:null},this.PanelDest=new t.LUNDestEditPanel({owner:this,mode:"edit",type:e.type,LUNBackupParam:this.LUNBackupData}),this.PanelSchedule=new t.ScheduleEditPanel({owner:this,padding:"8px 8px 0 8px",mode:"edit",LUNBackupParam:this.LUNBackupData});var s=new SYNO.ux.TabPanel({activeTab:0,plain:!0,itemId:"tabpanel",items:[this.PanelDest,this.PanelSchedule]});let i=[];this.isReadOnly?i.push({text:_T("common","apply"),btnStyle:"blue",itemId:"apply",handler:this.onCancel,scope:this}):i.push({text:_T("common","cancel"),itemId:"cancel",handler:this.onCancel,scope:this},{text:_T("common","apply"),btnStyle:"blue",itemId:"apply",handler:this.onOk,scope:this});var a={width:600,height:480,minWidth:300,minHeight:250,layout:"fit",closable:!0,items:[s],buttons:i};Ext.apply(a,e),this.callParent([a]),this.PanelSchedule.on("activate",(function(){this.activateSchedulePanel()}),this)},initEvents:function(){this.callParent(arguments),this.isReadOnly&&this.mon(this.getComponent("tabpanel"),"afterlayout",(function(){this.body&&this.body.mask()}),this.getComponent("tabpanel"))},activateSchedulePanel:function(){var e={},t={};this.blScheduleLoad=!0,"basic"===this.oldScheduleType?(e.basic_weekday=this.oldSchedule.week_name,e.hour=this.oldSchedule.hour,e.minute=this.oldSchedule.min):"advance"===this.oldScheduleType?(this.LUNBackupData.schedule=this.oldSchedule,e.basic_weekday="1",e.hour=0,e.minute=0):(e.basic_weekday="1",e.hour=0,e.minute=0),e.schedule_enable=this.oldScheduleEnable,e.schedule_type=this.oldScheduleType,t.data=e,this.PanelSchedule.loadForm(t)},initDestPanel:function(){if(SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.taskType){var e=this.PanelDest.getForm();this.taskDestOrg=this.taskDest,this.destDirectoryOrg=this.destDirectory;var t;t={bkpset:this.taskName,localDest:this.taskDest,destDirectory:this.destDirectory,lunSource:this.lunSource},e.setValues(t),this.taskDestOrg=this.taskDest,this.destDirectoryOrg=this.destDirectory,this.PanelDest.onLoadLocalDest()}else{if(SYNO.SDS.LunBackup.BKPTASK_NETLUN!==this.type)return!1;this.PanelDest.switchNetLayout(this.type);var s={};s.taskname=this.taskName,this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"load_lun_bkp_conf",params:s,scope:this,callback:function(e,t){if(this.clearStatusBusy(),e){this.selfIPs=t.selfIPs,this.selfHostName=t.selfHostName;var s,i;i=t.items[0].dest.split("/"),s={bkpset:this.taskName,comboServer:t.items[0].ip,textAccount:t.items[0].user,remoteShare:i[0],password:SYNO.SDS.LunBackup.getFakePass(),destDirectory:i[1],lunSource:this.lunSource},this.PanelDest.getForm().setValues(s),this.serverOrg=SYNO.SDS.LunBackup.GetServerName(t.items[0].ip),this.IPOrg=SYNO.SDS.LunBackup.GetServerIP(t.items[0].ip),this.taskDestOrg=i[0],this.destDirectoryOrg=i[1]}}})}this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"load_schedule",params:{bkpset:this.taskName,bkptype:this.taskType},scope:this,callback:function(e,t){if(this.clearStatusBusy(),e){if(this.oldScheduleEnable=t.schedule_enable,this.oldScheduleType=t.schedule_type,"basic"!==t.schedule_type&&"advance"!==t.schedule_type)return;this.oldSchedule=t.task.schedule,1===this.oldSchedule.date_type&&(this.oldSchedule.date=this.oldSchedule.date)}else this.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))}})},load:function(e){this.taskNameOrig=e.name,this.taskName=e.name,this.taskType=e.type,this.lunSource=e.bkpdata,this.uuid=e.uuid,SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.taskType&&(this.taskDest=e.dest,this.destDirectory=e.destDirectory),this.setTitle(this.taskName),this.initDestPanel()},RequestDone:function(e,t){this.clearStatusBusy(),e?t&&t.newbkpset!==t.oldbkpset?this.owner.onLunTaskRenamed(t.newbkpset,(function(){this.close()}),this):this.close():t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","commfail"))},SendRequest:function(e,t){this.setStatusBusy(_T("common","saving")),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:e,params:t,scope:this,callback:this.RequestDone})},CheckSetting:function(){var e=this.PanelDest.getForm(),t=this.PanelSchedule.getForm();if(e.isValid()){if(t.findField("schedule_enable").getValue()){if("basic"===t.findField("schedule_type").getGroupValue()&&(""===t.findField("basic_weekday").getValue()||""===t.findField("hour").getValue()||""===t.findField("minute").getValue()))return this.getMsgBox().alert(_T("tree","leaf_backup"),_T("schedule","schedule_warn_nodaysel")),!1;if("advance"===t.findField("schedule_type").getGroupValue()&&!this.LUNBackupData.schedule)return this.getMsgBox().alert(_T("netbackup","netbkp_no_schedule"),_T("netbackup","netbkp_no_schedule")),!1}this.LUNBackupData.blDestChanged?SYNO.SDS.LunBackup.BKPTASK_LOCLUN==this.taskType?this.checkDirLocal():this.checkDirNet():this.ApplySetting()}},CheckChanges:function(){var e=this.PanelDest.getForm();if(SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.taskType)this.taskDest=e.findField("localDest").getValue(),this.destDirectory=e.findField("destDirectory").getValue(),this.taskDest!==this.taskDestOrg||this.destDirectory!==this.destDirectoryOrg?this.LUNBackupData.blDestChanged=!0:this.LUNBackupData.blDestChanged=!1;else{this.taskDest=e.findField("remoteShare").getValue(),this.destDirectory=e.findField("destDirectory").getValue();var t=e.findField("comboServer"),s=SYNO.SDS.LunBackup.GetServerName(t.getRawValue()),i=SYNO.SDS.LunBackup.GetServerIP(t.getRawValue());this.taskDest!==this.taskDestOrg||this.destDirectory!==this.destDirectoryOrg||i!==this.IPOrg&&""===this.serverOrg||s!==this.serverOrg&&""!==this.serverOrg?this.LUNBackupData.blDestChanged=!0:this.LUNBackupData.blDestChanged=!1}},ApplySetting:function(){var e={mode:"edit"};if(e.oldbkpset=this.taskNameOrig,e.newbkpset=this.PanelDest.getForm().findField("bkpset").getValue(),e.srcchanged=this.LUNBackupData.blSrcChanged,e.destchanged=this.LUNBackupData.blDestChanged,e.bkptype=this.taskType,e.lunsource=this.lunSource,this.blScheduleLoad){var t=this.PanelSchedule.getScheduleData();e.scheduleEnable=t.enableschedule,t.enableschedule?t.basic?e.schedule=t.schedule:e.schedule=this.LUNBackupData.schedule:e.schedule=this.oldSchedule}else e.schedule=this.oldSchedule,e.scheduleEnable=this.oldScheduleEnable;var s=this.PanelDest.getForm();if(SYNO.SDS.LunBackup.BKPTASK_LOCLUN===this.taskType){var i=s.findField("localDest").getValue();e.dest=i+"/"+s.findField("destDirectory").getValue()}else{var a;e.servertype=this.taskType,e.dest=s.findField("remoteShare").getValue()+"/"+s.findField("destDirectory").getValue()+"/",a=s.findField("comboServer"),e.server=SYNO.SDS.LunBackup.GetServerName(a.getRawValue()),e.ip=SYNO.SDS.LunBackup.GetServerIP(a.getRawValue()),e.account=s.findField("textAccount").getValue(),e.password=s.findField("password").getValue(),e.module=s.findField("remoteShare").getValue()}this.SendRequest("apply_lun",e)},TestServerVersionDone:function(e,t){this.owner.clearStatusBusy(),e?this.owner.CheckSetting():t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),SYNO.SDS.Backup.String(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_fail"))},onTestConnectionDone:function(e,t){if(e){var s={servertype:"synology",share:"share",mode:"edit"};s=this.owner.PanelDest.getTestconParams(s,!1),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"remote_version_check",params:s,scope:this,callback:this.owner.TestServerVersionDone})}else this.owner.clearStatusBusy(),t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_connection_testing_fail"))},onTestConnection:function(){var e={};(e=this.PanelDest.getTestconParams(e,!1))?SYNO.SDS.LunBackup.onTestSvrConnection("test_connections",e,this.PanelDest,this.onTestConnectionDone):this.scope.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("netbackup","netbkp_err_host_str"))},checkDirDone:function(e,t){this.clearStatusBusy(),e?this.ApplySetting():t&&t.errors&&t.errors.sec&&t.errors.key&&""!==t.errors.sec&&""!==t.errors.key?this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T(t.errors.sec,t.errors.key)):this.owner.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system"))},checkDirNet:function(){var e=this.PanelDest.getForm(),t=e.findField("comboServer").getRawValue();this.setStatusBusy({text:_T("netbackup","netbkp_wait_server")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"check_dir",params:{bkptype:SYNO.SDS.LunBackup.BKPTASK_NETLUN,bkpset:this.taskName,share:this.taskDest,directory:this.destDirectory,user:e.findField("textAccount").getValue(),password:e.findField("password").getValue(),server:SYNO.SDS.LunBackup.GetServerName(t),ip:SYNO.SDS.LunBackup.GetServerIP(t),uuid:this.uuid,lunname:this.lunSource},scope:this,callback:this.checkDirDone})},checkDirLocal:function(){this.setStatusBusy({text:_T("localbkp","localbkp_wait_dest")}),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"check_dir",params:{bkptype:SYNO.SDS.LunBackup.BKPTASK_LOCLUN,bkpset:this.taskName,share:this.taskDest,directory:this.destDirectory,uuid:this.uuid,lunname:this.lunSource},scope:this,callback:this.checkDirDone})},onOk:function(){this.CheckChanges(),""!==this.taskDest&&""!==this.destDirectory&&(SYNO.SDS.LunBackup.BKPTASK_NETLUN!==this.taskType||!0!==this.LUNBackupData.blDestChanged&&!0!==this.LUNBackupData.blSrcChanged&&!0!==this.LUNBackupData.blUserChanged?this.CheckSetting():this.onTestConnection())},onCancel:function(){this.close()}}),Ext.define("SYNO.SDS.Backup.Task.LunMainPage",{extend:"SYNO.SDS.Backup.Task.MainPage",constructor:function(e){this.taskData={},this.pollingTask=null,this.pollingDest=null,this.taskType=e.taskType,this.taskLoaded=!1,this.callParent(arguments)},onStartPolling:function(){this.pollingTask?this.pollingTask.restart():this.pollingTask=this.addWebAPITask({api:"SYNO.Backup.Lunbackup",version:1,method:"load_task",params:{taskName:this.taskName},interval:3e3,scope:this,callback:this.loadTask}).start(!0),this.pollingDest?this.pollingDest.restart(!0):this.pollingDest=this.addWebAPITask({api:"SYNO.Backup.Lunbackup",version:1,method:"load_dest_status",params:{taskName:this.taskName},interval:3e4,scope:this,callback:this.loadDest}).start(!0)},onStopPolling:function(){this.pollingTask&&this.pollingTask.stop(),this.pollingDest&&this.pollingDest.stop()},setBtnStatus:function(){if(this.callParent(arguments),this.taskStatus&&this.taskState){var e=this.owner.isRestore(),t="backupable"===this.taskState&&this.taskLoaded;this.enableEdit(t);var s="none"===this.taskStatus&&!e&&!this.isDemoMode&&"backupable"===this.taskState;this.enableDelete(s);var i="none"===this.taskStatus&&!e&&!this.isDemoMode&&"backupable"===this.taskState&&"success"===this.taskLastResult&&this.enable_check;this.enableCheck(i),this.actionBtn.setDisabled(!t&&!s&&!i),_S("systemdr_running")&&this.enableBackup(!1)}},setTaskDetailStatus:function(e){this.enable_check=e.enable_check,"cksum_failed"===e.last_bkp_result?this.setTaskStatus(e.state?e.state:"backupable",e.status,e.last_bkp_time,e.last_bkp_result,0,"SYNO.SDS.Backup.Application:error:desc_target_cksum_error"):this.setTaskStatus(e.state?e.state:"backupable",e.status,e.last_bkp_time,e.last_bkp_result),"waiting"===e.status?this.setProgress({isShowPercentage:!1,description:"",scan_file:"",bottom_description:""}):"backup"===e.status?"syncing"===e.progress.step?this.setProgress({isShowPercentage:!0,description:_T("backup","transmitted_size"),scan_file:"",bottom_description:"",speed:"",percentage:e.progress?e.progress.progress:0}):"prebackup"===e.progress.step&&this.setProgress({isShowPercentage:!1,description:_T("usbbackup","usbbkp_init"),scan_file:"",bottom_description:""}):"docksum"==e.status&&this.setProgress({isShowPercentage:!0,description:SYNO.SDS.Backup.String("app","detect_data_progress"),bottom_description:"",scan_file:"",speed:"",percentage:e.progress?e.progress.progress:0})},loadTask:function(e,t){this.isDestroyed||e&&(this.taskLoaded=!0,this.taskData.name=t.taskName,this.taskData.type=t.type,this.taskData.bkpdata=t.bkpdata,this.taskData.dest=t.dest_share,this.taskData.destDirectory=t.dest_dir,this.taskData.uuid=t.uuid,this.setTaskDetailStatus(t),this.setBkpTime(t.last_bkp_time,t.next_bkp_time),this.loadDestData(t),this.loadSettingData({bkpdata:t.bkpdata,schedule:this.getScheduleStr(t.schedule)}))},getDestData:function(e){var t=[];return SYNO.SDS.LunBackup.BKPTASK_NETLUN===this.taskType&&(t=[{key:_T("common","ip_addr"),text:e?Ext.util.Format.htmlEncode(e.ip):_T("common","loading"),tip:e?Ext.util.Format.htmlEncode(e.ip):_T("common","loading")},{key:_T("netbackup","netbkp_account"),text:e?Ext.util.Format.htmlEncode(e.user):_T("common","loading"),tip:e?Ext.util.Format.htmlEncode(e.user):_T("common","loading")}]),t.concat([{key:_T("tree","leaf_sharefolder"),text:e?Ext.util.Format.htmlEncode(e.dest_share):_T("common","loading"),tip:e?Ext.util.Format.htmlEncode(e.dest_share):_T("common","loading")},{key:_T("backup","backup_dest_directory"),text:e?Ext.util.Format.htmlEncode(e.dest_dir):_T("common","loading"),tip:e?Ext.util.Format.htmlEncode(e.dest_dir):_T("common","loading")},{key:SYNO.SDS.Backup.String("app","last_detect_time"),text:e?Ext.util.Format.htmlEncode(e.last_chk_time):_T("common","loading"),tip:e?Ext.util.Format.htmlEncode(e.last_chk_time):_T("common","loading")}])},getSettingData:function(e){return[{key:SYNO.SDS.Backup.String("app","backup_type"),text:e?SYNO.SDS.Backup.String("app","backup_type_lun"):_T("common","loading")},{key:_T("lunbkp","lun_source"),text:e?Ext.util.Format.htmlEncode(e.bkpdata):_T("common","loading")},{key:_T("common","schedule"),text:e?Ext.util.Format.htmlEncode(e.schedule):_T("common","loading")}]},loadDest:function(e,t){if(!this.isDestroyed&&e){var s=t.deststatus,i="connected"===s||"int_ok"===s||"normal"===s,a="";t.sec&&t.key&&(a=_T(t.sec,t.key)),this.setIsOnline(i,a),this.pollingDest&&(this.pollingDest.interval=i?3e4:12e4)}},editDialogIsReadOnly:function(){return"none"!==this.taskStatus&&"backupable"===this.taskState&&this.taskLoaded},onEditBackupTask:async function(){var e=new SYNO.SDS.Backup.LUNEditDialog({owner:this.appWin,type:this.taskData.type,isReadOnly:this.editDialogIsReadOnly()});this.mon(e,"close",this.loadStaticData,this),e.load({name:this.taskData.name,type:this.taskData.type,bkpdata:this.taskData.bkpdata,dest:this.taskData.dest,destDirectory:this.taskData.destDirectory,uuid:this.taskData.uuid}),this.editDialogIsReadOnly()&&await SYNO.SDS.Backup.Util.asyncAlert(e.owner.getMsgBox(),_T("leaf","backup"),SYNO.SDS.Backup.String("app","task_busy_read_only")),this.openWindow(e)},onDeleteBackupTask:function(){this.appWin.getMsgBox().confirmDelete(_T("tree","leaf_backup"),_T("backup","backup_confirm_delete_task"),(function(e){"yes"===e&&this.doDeleteBackupTask()}),this)},onDetectTarget:function(){this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:"do_cksum",params:{taskName:this.taskName},scope:this,callback:function(e,t,s){this.owner.clearStatusBusy(),e?this.setTaskDetailStatus({state:"error_detect",status:"waiting"}):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code))}})},doDeleteBackupTask:function(){this.sendWebAPIRequest("delete",{before:function(){this.onStopPolling()},success:function(){this.appWin.deleteCurrentTask()},fail:function(){this.onStartPolling()}})},doCancelBackup:function(){this.sendWebAPIRequest("cancel",{before:function(){this.onStopPolling()},success:function(){this.onStartPolling()},fail:function(){this.onStartPolling()}})},onBackupNow:function(){this.sendWebAPIRequest("bkpnow",{before:function(){this.onStopPolling()},success:function(){this.setTaskDetailStatus({status:"waiting"}),this.onStartPolling()},fail:function(){this.onStartPolling()}})},sendWebAPIRequest:function(e,t){this.appWin.setStatusBusy(),t.before&&t.before.call(this);var s,i,a,n,r,o=(s=this.taskData,i=[],a=[],n=[],r=[],SYNO.SDS.LunBackup.BKPTASK_LOCLUN===s.type?(i.push(s.name),a.push(s.bkpdata)):SYNO.SDS.LunBackup.BKPTASK_NETLUN===s.type&&(n.push(s.name),r.push(s.bkpdata)),{action:e,locluntasks:i.join(","),loclunnames:a.join(","),netluntasks:n.join(","),netlunnames:r.join(",")});this.sendWebAPI({api:"SYNO.Backup.Lunbackup",version:1,method:e,params:o,scope:this,callback:function(e,s){e?(t.success&&t.success.call(this),this.appWin.clearStatusBusy()):(t.fail&&t.fail.call(this),this.appWin.clearStatusBusy(),s&&s.errors&&s.errors.sec&&s.errors.key&&""!==s.errors.sec&&""!==s.errors.key?this.appWin.getMsgBox().alert(_T("tree","leaf_backup"),_T(s.errors.sec,s.errors.key)):this.appWin.getMsgBox().alert(_T("tree","leaf_backup"),_T("common","error_system")))}})}}),Ext.define("SYNO.SDS.Backup.EditSourcePanelWrapper",{extend:"SYNO.ux.Panel",constructor:function(e){var t={layout:"fit",items:[new SYNO.SDS.Backup.EditSourcePanel({itemId:"source_selector_panel",owner:e.owner,isImage:e.isImage,height:e.height,disable_modified_source:e.disable_modified_source})]};Ext.apply(t,e),this.callParent([t])},initComponent:function(){this.callParent(arguments);var e=this.appInstance.getUserSettings("show_parent_file_only_tip");this.isImage&&(void 0===e||e)&&this.add(new SYNO.SDS.Backup.NewFeaturePanel({appInstance:this.appInstance,subTopic:"data_backup_source.html"}))}}),Ext.define("SYNO.SDS.Backup.EditSourcePanel",{extend:"SYNO.ux.Panel",constructor:function(e){var t={bbar:e.isImage?this.createBbar():void 0,cls:"syno-backup-source-wrapper",height:e.height,layout:"fit",items:[this.createSourceSelector(e.owner,e.disable_modified_source,e.isImage)]};t=Ext.apply(e,t),this.callParent([t])},createSourceSelector:function(e,t,s){var i={itemId:"source_selector",owner:e,pageContainer:this,isImage:s,pre_load_folder_done:!1,disabled:t};return s?new SYNO.SDS.Backup.TaskSourceQuadSelector(i):new SYNO.SDS.Backup.TaskSourceTriSelector(i)},openFilterSettingWindow:function(){var e=new SYNO.SDS.Backup.Client.Common.FilterSettingWindow({owner:this.owner,backupFilter:this.backupFilter,disable_modified_source:this.disable_modified_source});e.on("savefilterparams",this.saveFilterParams,this),e.open()},createBbar:function(){var e=new SYNO.ux.Toolbar;return e.add(new Ext.ux.StatusBar({html:'<span class="syno-backup-open-filter-text">'+SYNO.SDS.Backup.String("app","create_file_filter")+"</span>",hideBorders:!0,listeners:{scope:this,afterrender:function(e){e.getEl().on("click",(function(){this.openFilterSettingWindow()}),this)}}})),e},getSource:function(){return this.getComponent("source_selector")},saveFilterParams:function(e){var t={};Ext.copyTo(t,e,"whitelist"),t.exclude_list=SYNO.Backup.Util.ExtractPattern(e.exclude_list,"file"),this.backupFilter=t},getParams:function(){return this.backupFilter||{}},checkApply:function(){return this.checkC2Shares().then(this.checkTieringSharesAndVaults.bind(this))},checkC2Shares:function(){var e=this.getSource().getSelectedC2Shares();return e.length?this.isImage?new Promise(function(t,s){this.owner.getMsgBox().confirm(_T("leaf","backup"),String.format(SYNO.SDS.Backup.String("error","backup_source_c2_share"),"<b>"+e.join(", ")+"</b>"),(function(e){"yes"===e?t():s()}))}.bind(this)):Promise.reject("Not support c2 share in single version."):Promise.resolve()},checkTieringSharesAndVaults:function(){return new Promise(((e,t)=>{const s=this.getSource().getTieringShareList(),i=this.getSource().getTieringVaultList(),a=SYNO.SDS.Backup.String("error","backup_tiering_share_bucket_warning");if(Ext.isEmpty(s)&&!Ext.isEmpty(i))this.owner.getMsgBox().alert(_T("leaf","backup"),a,e);else if(Ext.isEmpty(s))e();else{new SYNO.SDS.Backup.HotTiering.ConfirmDialog({owner:this.owner,resolveFn:Ext.createDelegate(e,this),rejectFn:Ext.createDelegate(t,this)}).show()}}))}}),Ext.define("SYNO.SDS.Backup.TaskEditDialog",{extend:"SYNO.SDS.ModalWindow",dsmStyle:"v5",invalidList:"",support_app_share:!1,pageLoadDoneMap:null,constructor:function(e){this.repoEdit=!1,this.invalidAlerted=!1,this.expandedRoot=0,this.isImage=SYNO.Backup.Util.IsImage(e.targetType),this.accountMeta=e.accountMeta,this.isEntireDSMOrLUNMultiVerTask="entire_dsm"===e.dataType||"multi_ver_lun"===e.dataType;var t=this.isImage,s=580,i=!0===e.isOnline&&!0===e.isSuspended||"restore_only"===e.taskState;this.initActiveTab=i||this.isEntireDSMOrLUNMultiVerTask?"task_setting_panel":"source_selector_panel_wrapper",this.isReadOnly=e.isReadOnly,this.disable_rotate=SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.ROTATION_CUSTOM!==e.accountMeta.versionRotation||!0===e.isDiscard||"error_detect"===e.taskState,this.pageLoadDoneMap={task:!1},"source_selector_panel_wrapper"!==this.initActiveTab||this.isEntireDSMOrLUNMultiVerTask||(this.pageLoadDoneMap.folder=!1),this.isEntireDSMOrLUNMultiVerTask||(this.pageLoadDoneMap.app=!1);var a=[];this.isEntireDSMOrLUNMultiVerTask||(a.push(new SYNO.SDS.Backup.EditSourcePanelWrapper({title:_T("backup","folder_title"),itemId:"source_selector_panel_wrapper",cls:"syno-backup-edit-source-panel",owner:this,isImage:this.isImage,height:437,disable_modified_source:i||e.isReadOnly,appInstance:e.appInstance})),a.push(new SYNO.SDS.Backup.AppParamsPanel({title:_T("backup","application"),itemId:"app_panel",isReadOnly:i||e.isReadOnly,height:437,owner:this}))),a.push(this.createParamsPanelByType(e.transferType,e.targetType,{title:_T("common","common_settings"),itemId:"task_setting_panel",owner:this,isEntireDSMOrLUNMultiVerTask:this.isEntireDSMOrLUNMultiVerTask,height:437,accountMeta:e.accountMeta,isSuspended:e.isSuspended})),SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.SCHEDULE_UNLIMITED===e.accountMeta.scheduleRule?a.push(new SYNO.SDS.Backup.EditSchedulePanel({title:_T("common","schedule"),itemId:"sched_panel",owner:this,isImage:e.isImage,height:437,targetType:e.targetType})):SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.SCHEDULE_ONCE_A_DAY===e.accountMeta.scheduleRule&&a.push(new SYNO.SDS.Backup.C2CloudEditSchedulePanel({title:_T("common","schedule"),itemId:"sched_panel",owner:this,height:437,targetType:e.targetType})),t&&a.push(new SYNO.SDS.Backup.RotationParamsPanel({title:SYNO.SDS.Backup.String("app","rotation"),tabTip:SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.ROTATION_BASIC===e.accountMeta.versionRotation?SYNO.SDS.Backup.String("error","plan_not_support"):null,itemId:"rotate_panel",isReadOnly:i||this.disable_rotate||this.isReadOnly,owner:this,appWin:e.appWin,height:450}));var n=SYNO.Backup.Addon.Util.getID(e.targetType,e.transferType),r=SYNO.Backup.Addon.Util.getClass(n,"Destination.EditPanel");Ext.isFunction(r)&&a.push(new r({title:_T("netbackup","netbkp_target"),itemId:"repo_panel",taskId:e.taskId,repoId:e.repoId,targetType:e.targetType,transferType:e.transferType,owner:this}));let o=[];this.isReadOnly?o.push({text:_T("common","apply"),btnStyle:"blue",scope:this,handler:this.close}):o.push({text:_T("common","cancel"),scope:this,handler:this.close},{text:_T("common","apply"),btnStyle:"blue",scope:this,handler:this.onApplyClick});var c=Ext.apply({width:680,height:s,resizable:!1,cls:"syno-backup-edit-window",title:_T("schedule","task_settings"),items:[{xtype:"syno_tabpanel",itemId:"edit_tab_panel",activeTab:this.initActiveTab,items:a}],buttons:o},e);this.callParent([c])},initEvents:function(){if(this.callParent(arguments),!this.isEntireDSMOrLUNMultiVerTask){var e=this.getSourceSelector();this.mon(e,"beforeexpandnode",this.onExpandFmRoot,this)}this.isReadOnly&&(this.setMaskAfterLayout(this.getTaskSettingPanel()),this.setMaskAfterLayout(this.getSchedPanel()),this.setMaskAfterLayout(this.getRepoPanel()))},setMaskAfterLayout:function(e){e&&this.mon(e,"afterlayout",(function(){this.body&&this.body.mask()}),e)},createParamsPanelByType:function(e,t,s){var i=s;i.target_type=t,i.transfer_type=e,i.enableRotate=SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.ROTATION_CUSTOM===s.accountMeta.versionRotation&&("image"===t||"cloud_image"===t),i.hideDataEnc=!0,this.isEntireDSMOrLUNMultiVerTask&&(i.disableAutoUnmount=!0,i.hideAutoUnmount=!0),i.disableDataComp=!0,i.hideDataComp=!1,i.bwrapStyle="padding: 0px 8px";var a=SYNO.Backup.Addon.Util.getID(t,e),n=SYNO.Backup.Addon.Util.getClass(a,"Task.SettingPanel");return Ext.isFunction(n)?new n(i):null},disableNode:function(e){e.getUI().setCheckValue(!1),e.leaf=!0,e.expandable=!1,e.disable()},disableEncShare:function(e){e.eachChild((function(e){if(e.attributes.encryptedShare)if(this.isImage&&!this.support_enc_share){e.disable();var t="offline"===this.destStatus?SYNO.SDS.Backup.String("app","offline_disable_enc_share"):_T("backup","multi_version_not_support_encrypted_share");e.setTooltip(t)}else this.getSourceSelector().updateEncShare(this.targetType,this.transferType,e)}),this)},destShareCheck:function(e){this.destShare&&this.getSourceSelector().setDestination("/"+this.destShare)},onExpandFmRoot:function(e){return-1!==this.getSourceSelector().fm_root_nodes.indexOf(e.id)&&(this.disableEncShare(e),this.destShareCheck(e),this.expandedRoot+=1,this.getSourceSelector().volumeCount===this.expandedRoot&&this.doIfAppShareReady("folder_initialed")),!0},doIfAppShareReady:function(e){if(this[e]=!0,this.app_loaded&&this.folder_loaded&&this.folder_initialed){var t="image_remote"===this.transferType&&!this.isOnline;SYNO.SDS.Backup.setAppGridDependency(this.getAppPanel(),this.getSourceSelector(),!0,t),this.alertInvalidList()}},onOpen:function(){this.setStatusBusy();var e=["is_usb_share","local_volume","support_ssl","support_rotate","support_enc_share","support_compression","support_app_share","support_error_detect","support_detect_time_limit","support_version_file_log","skip_repo_status","is_share_enc"],t=["backup_params","rotate_params","schedule","incheck_schedule","backup_volumes","backup_filter"];return this.disable_rotate||t.push("version_count"),this.sendWebAPI({compound:{stopwhenerror:!1,mode:"parallel",params:[{api:"SYNO.Backup.Task",version:1,method:"get",scope:this,params:{task_id:this.taskId,additional:t,account_meta:this.accountMeta}},{api:"SYNO.Backup.Repository",version:1,method:"get",params:{task_id:this.taskId,additional:e}}]},timeout:18e4,scope:this,callback:this.onOpenDone}),this.callParent(arguments)},onOpenDone:function(e,t,s){if(this.onClearStatusBusy("task"),e)if(t.result[1].success){var i=t.result[1].data;if(this.repoVolume=i.local_volume,"image_remote"===i.transfer_type&&t.result[0].success&&Ext.isDefined(t.result[0].data.backup_params.trans_encrypt)){var a=Ext.apply({sslcheck:t.result[0].data.backup_params.trans_encrypt},i);this.loadRepoParams(a)}else this.loadRepoParams(i);if(t.result[0].success){var n=t.result[0].data;if("local"!==i.transfer_type&&"image_local"!==i.transfer_type||(this.destShare=i.share),this.support_ssl=i.support_ssl,this.support_rotate=i.support_rotate,this.support_enc_share=i.support_enc_share,this.support_data_comp=i.support_compression,this.support_app_share=i.support_app_share,this.support_error_detect=i.support_error_detect,this.support_detect_time_limit=i.support_detect_time_limit,this.support_version_file_log=i.support_version_file_log,this.destStatus=i.deststatus,this.destEnc=i.is_share_enc,this.version_count=n.version_count,this.isEntireDSMOrLUNMultiVerTask||this.loadBackupSource(n,i),this.loadTaskSettingParams(n,i),this.loadScheduleParams(n),void 0!==this.getRotationPanel()&&(this.support_rotate?this.loadRotationParams(n):(this.getRotationPanel().setDisabled(!0),"offline"===i.deststatus&&this.getRotationPanel().tabEl.setAttribute("ext:qtip",SYNO.SDS.Backup.String("app","offline_disable_rotation")))),!this.isEntireDSMOrLUNMultiVerTask){var r=function(){this.onClearStatusBusy("app"),this.isSuspended&&(!0===this.isOnline?this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.String("app","suspend_modified_warning")):this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.String("app","offline_modified_warning"))),!0===this.openFilterPage&&this.getSourceSelectorPanel().openFilterSettingWindow()}.createDelegate(this);this.loadAppParams(n,r)}}else{var o=this.getComponent("edit_tab_panel");this.getRepoPanel()?(o.setActiveTab("repo_panel"),o.items.get(0).setDisabled(!0),o.items.get(1).setDisabled(!0),o.items.get(2).setDisabled(!0),o.items.get(3).setDisabled(!0),void 0!==this.getRotationPanel()&&this.getRotationPanel().setDisabled(!0),this.repoEdit=!0):this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.result[0].error.code),(function(){this.close()}),this)}}else this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.result[1].error.code),(function(){this.close()}),this);else this.getMsgBox().alert(_T("leaf","backup"),_T("error","error_error_system"),(function(){this.close()}),this)},onClearStatusBusy:function(e){this.pageLoadDoneMap[e]=!0,Object.values(this.pageLoadDoneMap).every((function(e){return!0===e}))&&this.clearStatusBusy()},onSourceFolderLoad:function(){"source_selector_panel_wrapper"!==this.initActiveTab&&this.setStatusBusy()},alertInvalidList:function(){this.invalidAlerted=!0;var e=this.getAppPanel().getAppList().slice(0),t=this.getAppPanel().checkedList.slice(0),s=this.getAppPanel().nameList.slice(0),i=[];Ext.each(t,(function(t,a){0>e.indexOf(t)&&i.push(s[a])}));var a="",n="";if("image"===this.targetType||"cloud_image"===this.targetType){var r=this.getSourceSelector().getSelectedEncList(!0),o=this.getSourceSelector().getSelectedEncVolumeList(!0);0<r.length&&(n=String.format("mount_enc_{0}share_before_backup",1<r.length?"plural_":""),a+=SYNO.SDS.Backup.String("error",n)+":<br/>"+r.join(", ")+"<br/>"),0<o.length&&(n=String.format("mount_enc_{0}volume_before_backup",1<o.length?"plural_":""),a+=SYNO.SDS.Backup.String("error",n)+":<br/>"+o.join(", ")+"<br/>")}var c="";0<this.invalidList.length&&(c+=this.invalidList),0<i.length&&(c+=_T("backup","application")+": "+i.join(", ")),0<c.length&&(c=_T("backup","unselect_invalid_source")+"<br/>"+c),0<(a+=c).length&&(a='<div style="width:420px; max-height:460px; overflow:auto;">'+a+"</div>",this.getMsgBox().alert(_T("leaf","backup"),a,this.clearStatusBusy,this))},getLocalRepoVolume:function(){return this.repoVolume},loadAppParams:function(e,t){this.getAppPanel().setAppCheckList(e.source.app_list),this.getAppPanel().setAppNameList(e.source.app_name_list),this.getAppPanel().setAppLastConfig(e.source.app_config),this.getAppPanel().loadStore(this.support_app_share,t)},loadBackupSource:function(e,t){var s=this.getSourceSelector();e&&e.source&&(this.isImage&&(s.setVolumeList(e.source.backup_volumes),s.setExcludeFolderList(SYNO.Backup.Util.ExtractPattern(e.source.backup_filter.exclude_list,"dir")),this.getSourceSelectorPanel().saveFilterParams(e.source.backup_filter||{})),s.setFolderList(e.source.file_list))},loadBackupVolumeAndExcludeFolder:function(e){if(this.isImage&&e){var t=this.getSourceSelector();e.backup_volumes&&t.setVolumeList(e.backup_volumes),e.backup_filter&&t.setExcludeFolderList(SYNO.Backup.Util.ExtractPattern(e.backup_filter.exclude_list,"dir"))}},loadScheduleParams:function(e){var t={week_name:"1",hour:0,min:0,date:(new Date).format("Y/m/d"),date_type:0,repeat:0,repeat_hour:0,last_work_hour:0,schedule_enable:!1};e.schedule&&((t=e.schedule.schedule).schedule_enable=e.schedule.schedule_enable),t.repeat_date=t.repeat,t.minute=t.min,t.week_day=t.week_name,delete t.repeat,delete t.min,delete t.week_name,this.isImage&&!this.support_error_detect&&this.getSchedPanel().setSupportErrorDetect(!1),this.getSchedPanel().setData({backup:t,incheck:e.incheck_schedule,support_detect_time_limit:this.support_detect_time_limit})},loadFilterParams:function(e){this.getSourceSelectorPanel().saveFilterParams(e.backup_filter||{})},loadTaskSettingParams:function(e,t){if("synocloud_swift"===t.transfer_type&&e.backup_params.bw_limit&&e.backup_params.bw_limit>0&&(e.backup_params.bw_limit=e.backup_params.bw_limit/1024,e.backup_params.bw_limit_unit="KB",e.backup_params.bw_limit>=1024&&0==e.backup_params.bw_limit%1024&&(e.backup_params.bw_limit=e.backup_params.bw_limit/1024,e.backup_params.bw_limit_unit="MB"),this.getTaskSettingPanel().getForm().findField("bw_limit_unit").setValue(e.backup_params.bw_limit_unit)),this.getTaskSettingPanel().getForm().setValues(Ext.apply({task_name:e.name,task_dir:e.target_id,incrbkp_enable:!e.backup_params.delete_on_target,bandwidthcheck:e.backup_params.bw_limit&&e.backup_params.bw_limit>0},e.backup_params)),this.orgName=e.name,"cloud_image"!==t.target_type||"rsync"!==t.transfer_type&&"rsync_ds"!==t.transfer_type&&"hidrive"!==t.transfer_type||(Ext.isDefined(e.backup_params.trans_compress)?(this.getTaskSettingPanel().getForm().findField("trans_compress").setVisible(!0),this.getTaskSettingPanel().getForm().findField("trans_compress").setDisabled(!1)):(this.getTaskSettingPanel().getForm().findField("trans_compress").setVisible(!1),this.getTaskSettingPanel().getForm().findField("trans_compress").setDisabled(!0))),"cloud_image"===t.target_type&&"aws_s3"===t.transfer_type&&(Ext.isDefined(e.backup_params.storage_class)?(this.getTaskSettingPanel().getFieldset().getComponent("storage_class").setValue(e.backup_params.storage_class),this.getTaskSettingPanel().getFieldset().getComponent("storage_class").transToText()):this.getTaskSettingPanel().getFieldset().getComponent("storage_class").setVisibleAndEnable(!1)),this.getTaskSettingPanel().getForm().findField("dest_auto_unmount")&&(this.getTaskSettingPanel().getForm().findField("dest_auto_unmount").hide(),this.getTaskSettingPanel().getForm().findField("dest_auto_unmount").disable(),!_D("usbstation")&&t.is_usb_share&&("local"!==t.transfer_type&&"image_local"!==t.transfer_type||(this.getTaskSettingPanel().getForm().findField("dest_auto_unmount").show(),this.getTaskSettingPanel().getForm().findField("dest_auto_unmount").enable()))),!this.support_data_comp){var s=this.getTaskSettingPanel().getForm().findField("enable_data_compress");Ext.isEmpty(s)||(s.hide(),s.disable())}var i=this.getTaskSettingPanel().getForm().findField("enable_version_file_log");Ext.isEmpty(i)||(this.isSuspended?i.disable():this.support_version_file_log||(i.setValue(!1),i.disable()))},loadRotationParams:function(e){this.getRotationPanel().loadData(e.rotate_params)},loadRepoParams:function(e){if(this.getRepoPanel()){var t={};t.accountMeta=this.accountMeta,this.getRepoPanel().loadData(e,t)}},getSourceSelectorPanel:function(){return this.getComponent("edit_tab_panel").getComponent("source_selector_panel_wrapper").getComponent("source_selector_panel")},getSourceSelector:function(){return this.getSourceSelectorPanel().getSource()},getAppPanel:function(){return this.getComponent("edit_tab_panel").getComponent("app_panel")},getTaskSettingPanel:function(){return this.getComponent("edit_tab_panel").getComponent("task_setting_panel")},getSchedPanel:function(){return this.getComponent("edit_tab_panel").getComponent("sched_panel")},getRotationPanel:function(){return this.getComponent("edit_tab_panel").getComponent("rotate_panel")},getRepoPanel:function(){return this.getComponent("edit_tab_panel").getComponent("repo_panel")},onApplyClick:function(){this.repoEdit?this.onRepoEditApply():this.onFullEditApply()},onFullEditApply:function(){return this.getTaskSettingPanel().getForm().isValid()?this.getRepoPanel()&&!this.getRepoPanel().getForm().isValid()?(this.getComponent("edit_tab_panel").setActiveTab("repo_panel"),this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1):this.getSchedPanel().getForm().isValid()?void 0!==this.getRotationPanel()&&this.support_rotate&&(e=this.getRotationPanel().getForm(),t=e.findField("backup_rotation"),s=e.findField("backup_rotation_action"),i=e.findField("backup_rotation_condition_max_version"),!e.isValid())?(this.getComponent("edit_tab_panel").setActiveTab("rotate_panel"),this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1):void new Promise(function(e,a){var n;t&&t.getValue()&&(t&&t.isDirty()||s&&s.isDirty()||i&&i.isDirty())?i&&this.version_count&&i.getValue()+1<this.version_count?(this.getComponent("edit_tab_panel").setActiveTab("rotate_panel"),n=String.format(SYNO.SDS.Backup.String("app","rotate_delete_hint"),this.version_count,i.getValue())+"<br/><br/>"+SYNO.SDS.Backup.String("app","rotate_delete_note"),n+="<br/><br/>"+SYNO.SDS.Backup.String("app","rotate_delete_confirm"),this.getMsgBox().confirmDelete("",n,(function(t){"yes"===t?e():a()}),this,{yes:{text:_T("backup","rotate"),btnStyle:"red"},no:{text:Ext.MessageBox.buttonText.no}})):(this.getComponent("edit_tab_panel").setActiveTab("rotate_panel"),n=String.format(SYNO.SDS.Backup.String("app","rotate_delete_hint_under"),this.version_count,i.getValue()),n+="<br/><br/>"+SYNO.SDS.Backup.String("app","rotate_delete_confirm"),this.getMsgBox().confirm("",n,(function(t){"yes"===t?e():a()}),this)):e()}.bind(this)).then(function(){if(!this.isEntireDSMOrLUNMultiVerTask)return this.getSourceSelectorPanel().checkApply()}.bind(this)).then(function(){if(!this.isEntireDSMOrLUNMultiVerTask)return this.checkEncShare()}.bind(this)).then(function(){return this.checkNeedVerify()}.bind(this)).then(function(e){this.applyEdit(e)}.bind(this)).catch(function(e){e&&SYNO.Debug(e)}.bind(this)):(this.getComponent("edit_tab_panel").setActiveTab("sched_panel"),this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1):(this.getComponent("edit_tab_panel").setActiveTab("task_setting_panel"),this.setStatusError({text:_T("common","forminvalid"),clear:!0}),!1);var e,t,s,i},checkEncShare:function(){if("image"===this.targetType||"cloud_image"===this.targetType){var e=this.getSourceSelector().getSelectedEncList(),t=this.getSourceSelector().getSelectedEncVolumeList();if(0<e.length||0<t.length){var s=this.getTaskSettingPanel().getForm().findField("enable_data_encrypt");if(!1===this.destEnc&&s&&!1===s.getValue()){var i;this.getComponent("edit_tab_panel").setActiveTab("source_selector");var a="";return 0<e.length&&0<t.length?(a=String.format("backup_enc_{0}volume_{1}share_to_not_enc_dest",1<t.length?"plural_":"",1<e.length?"plural_":""),i=SYNO.SDS.Backup.String("error",a),i=String.format(i,"<b>"+t.join(", ")+"</b>","<b>"+e.join(", ")+"</b>")):0<e.length?(a=String.format("backup_enc_{0}share_to_not_enc_dest",1<e.length?"plural_":""),i=String.format(SYNO.SDS.Backup.String("error",a),"<b>"+e.join(", ")+"</b>")):(a=String.format("backup_enc_{0}volume_to_not_enc_dest",1<t.length?"plural_":""),i=String.format(SYNO.SDS.Backup.String("error",a),"<b>"+t.join(", ")+"</b>")),new Promise(function(e,t){this.getMsgBox().confirm(_T("leaf","backup"),i,(function(s){"yes"===s?e():t()}),this)}.bind(this))}}}return Promise.resolve()},checkNeedVerify:function(){var e,t,s,i,a=this.owner.getCurrentTask();if(a.data_enc&&(void 0!==this.getRotationPanel()&&this.support_rotate&&(t=(e=this.getRotationPanel().getForm()).findField("backup_rotation"),s=e.findField("backup_rotation_action"),i=e.findField("backup_rotation_condition_max_version")),t&&t.getValue()&&(t&&t.isDirty()||s&&s.isDirty()||i&&i.isDirty())))return Ext.isEmpty(a.sess_id)?new Promise(function(e){this.launchPasswordWindow((function(){e(!0)}),SYNO.SDS.Backup.String("app","edit_version_rotate_verify"))}.bind(this)):Promise.resolve(!0);return Promise.resolve(!1)},launchPasswordWindow:function(e,t){var s=this.owner.getCurrentTask(),i={task_id:s.task_id,repo_id:s.repo_id,target_id:s.target_id};new SYNO.SDS.Backup.Client.Common.Password.Window({owner:this.owner,verify_params:i,verify_hint:t,setter:Ext.createDelegate(this.owner.setCurTaskSession,this.owner),callback:Ext.createDelegate(e,this)}).open()},onRepoEditApply:function(){if(this.getRepoPanel()&&this.getRepoPanel().getForm().isDirty())return this.setStatusBusy(),this.sendWebAPI(Ext.apply(this.getRepoPanel().getApplyApi(),{scope:this,callback:function(e,t,s){if(!e)return this.clearStatusBusy(),void this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code));this.clearStatusBusy(),this.close()}})),!1;this.close()},applyEdit:function(e){var t=[],s={},i=this.getParams();if(this.getRepoPanel()){var a=this.getRepoPanel().getForm().findField("sslcheck");a&&(a.getValue()?i.backup_params.trans_encrypt=!0:i.backup_params.trans_encrypt=!1)}if(!this.isNameValid(i.name))return this.getComponent("edit_tab_panel").setActiveTab("task_setting_panel"),this.getMsgBox().alert(_T("tree","leaf_backup"),_T("localbkp","localbkp_bkpset_exist")),!1;e&&Ext.apply(i,{need_sess:!0,sess_id:this.owner.getCurrentTask().sess_id}),s.api="SYNO.Backup.Task",s.version=1,s.method="set",s.params=i,t.push(s);var n=[];if(this.getRepoPanel()&&this.getRepoPanel().getForm().isDirty()){var r=this.getRepoPanel().getApplyApi();r&&(n=SYNO.SDS.Backup.Util.getEncryption(["pwd","secret","remote_refresh_token","remote_access_token"],r.params),t.unshift(r))}return this.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!0,params:t},encryption:n,scope:this,callback:function(e,t,s){var a=!0;if(!e)return this.clearStatusBusy(),void this.owner.getMsgBox().alert(_T("leaf","backup"),_T("error","error_error_system"));Ext.each(t.result,(function(e){var t;if(!e.success)return this.clearStatusBusy(),a=!1,SYNO.SDS.Backup.ERR_OFFLINE===e.error.code&&Ext.isDefined(e.error.errors)&&Ext.isDefined(e.error.errors.errorlist)?(t="<li>"+_T("backup","network_backup")+"<BR>"+SYNO.SDS.Backup.GetErrorString(e.error.errors.errorlist.rsync)+"</li>",t+="<li>"+_T("backup","encrypt_backup")+"<BR>"+SYNO.SDS.Backup.GetErrorString(e.error.errors.errorlist.ssh)+"</li>",this.getMsgBox().alert(_T("leaf","backup"),t)):SYNO.SDS.Backup.ERR_SESSION_EXPIRED===e.error.code?(this.owner.clearCurTaskSession(),this.launchPasswordWindow((function(){this.applyEdit(!0)}),SYNO.SDS.Backup.String("app","edit_version_rotate_verify"))):e.error.errors&&e.error.errors.verify_req_host&&e.error.errors.verify_cert_hosts?this.owner.getMsgBox().alert(_T("leaf","backup"),String.format(SYNO.SDS.Backup.GetErrorString(e.error.code),e.error.errors.verify_req_host,e.error.errors.verify_cert_hosts)):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(e.error.code)),!1}),this),a&&(t.result[0].data.is_upload_success&&this.triggerVersionRotation(i),this.getTaskSettingPanel().getForm().findField("task_name").isDirty()?this.owner.onDataTaskRenamed(this.taskId,(function(){this.clearStatusBusy(),this.close()}),this):(this.clearStatusBusy(),this.close()))}}),!1},triggerVersionRotation:function(e){if(void 0!==this.getRotationPanel()&&this.support_rotate){var t=this.getRotationPanel().getForm(),s=t.findField("backup_rotation"),i=t.findField("backup_rotation_action"),a=t.findField("backup_rotation_condition_max_version");s&&s.getValue()&&(s&&s.isDirty()||i&&i.isDirty()||a&&a.isDirty())&&this.sendWebAPI({api:"SYNO.Backup.Version",version:1,method:"rotate",params:e,callback:function(e,t,s){var i;e||(SYNO.SDS.Backup.ERR_OFFLINE===t.code&&Ext.isDefined(t.errors)&&Ext.isDefined(t.errors.errorlist)?(i="<li>"+_T("backup","network_backup")+"<BR>"+SYNO.SDS.Backup.GetErrorString(t.errors.errorlist.rsync)+"</li>",i+="<li>"+_T("backup","encrypt_backup")+"<BR>"+SYNO.SDS.Backup.GetErrorString(t.errors.errorlist.ssh)+"</li>",this.getMsgBox().alert(_T("leaf","backup"),i)):SYNO.SDS.Backup.ERR_SESSION_EXPIRED===t.code?(this.owner.clearCurTaskSession(),this.launchPasswordWindow((function(){this.applyEdit(!0)}),SYNO.SDS.Backup.String("app","edit_version_rotate_verify"))):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code)))},scope:this})}},isNameValid:function(e){return this.orgName===e||-1===this.owner.getTaskNameList().indexOf(e)},getParams:function(){var e=this.getParamsSchedule(),t={task_id:this.taskId,repo_id:this.repoId,source:this.getParamsSource(),schedule:e.backup,target_type:this.targetType,transfer_type:this.transferType,incheck_schedule:e.incheck};return Ext.apply(t,this.getTaskSettingPanel().getParams()),void 0!==this.getRotationPanel()&&this.support_rotate&&Ext.apply(t,this.getRotationPanel().getParams()),t},getParamsSource:function(){if(this.isEntireDSMOrLUNMultiVerTask)return{file_list:[],app_list:[],app_config:[],backup_volumes:[],backup_filter:{whitelist:[],exclude_list:[]}};var e=this.getSourceSelector().getPathProcessParams(),t={file_list:e.folder_list,app_list:this.getAppPanel().getAppList(),app_config:this.getAppPanel().getAppConfig()};return this.isImage&&(t.backup_volumes=e.backup_volumes,t.backup_filter=SYNO.Backup.Util.deepCopyObject(this.getSourceSelectorPanel().getParams()),t.backup_filter.exclude_list=t.backup_filter.exclude_list.concat(e.folder_exclude_list)),t},getParamsSchedule:function(){var e={};return Ext.apply(e,this.getSchedPanel().getData()),e.backup.repeat=e.backup.repeat_date,e.backup.min=e.backup.minute,e.backup.week_name=e.backup.week_day,delete e.backup.repeat_date,delete e.backup.minute,delete e.backup.week_day,e}}),Ext.define("SYNO.SDS.Backup.TaskImportWizard",{extend:"SYNO.SDS.Backup.Wizard",wizardAnchor:"",support_app_share:!1,support_detect_time_limit:!1,accountMeta:SYNO.SDS.Backup.Client.Common.Utils.createAccountMeta(),backupType:"data",constructor:function(e){this.lastStepId=null;var t=SYNO.Backup.Addon.Config.addon_list,s=SYNO.Backup.Addon.Util.getID(e.targetType,e.transferType),i={};Ext.each(t,(function(t){i[e.targetType+":"+t.transfer_type]="params"}));var a=SYNO.Backup.Addon.Util.getClass(s,"Destination.SettingPanel"),n=SYNO.Backup.Addon.Util.getClass(s,"Task.SettingPanel");this.source_selector_id=SYNO.Backup.Util.IsImage(e.targetType)?"source_repo_image":"source_repo_legacy";var r=[new a({owner:this,appWin:e.appWin,itemId:"auth_repo",target_type:e.targetType,transfer_type:e.transferType,action:"import",supportCreate:!1,supportExport:!1,headline:SYNO.SDS.Backup.String("app","repo_info_wizard_title"),nextId:this.source_selector_id}),new SYNO.SDS.Backup.TaskSourceContainerWrapper({owner:this,appWin:e.appWin,itemId:this.source_selector_id,isImage:SYNO.Backup.Util.IsImage(e.targetType),pre_load_folder_done:!1,headline:SYNO.SDS.Backup.String("app","source_share_wizard_title"),nextId:"app"}),new SYNO.SDS.Backup.AppParamsPanel({owner:this,appWin:e.appWin,itemId:"app",headline:SYNO.SDS.Backup.String("app","source_pkg_wizard_title"),bodyStyle:"max-height: 373px; min-height: 373px",nextId:i}),new n({owner:this,appWin:e.appWin,itemId:"params",target_type:e.targetType,transfer_type:e.transferType,action:"import",headline:_T("backup","backup_settings"),nextId:"data_rotate"}),new SYNO.SDS.Backup.RotationParamsPanel({owner:this,appWin:e.appWin,itemId:"data_rotate",headline:_T("backup","backup_rotation_settings"),nextId:null,getNext:function(){return this.owner.initializeTask(),!1}})],o=Ext.apply({title:SYNO.SDS.Backup.String("app","wizard_relink"),cls:"syno-backup-import-wizard",banner:!0,width:680,height:580,steps:r},e);this.callParent([o])},onOpen:function(){var e=this.getAuthPanel();return Ext.isFunction(e.setOauthResponse)&&e.setOauthResponse(this.auth_response),this.getDefaultParams(),this.callParent(arguments)},getDefaultParams:function(){this.setStatusBusy(),this.sendWebAPI({compound:{stopwhenerror:!0,params:[{api:"SYNO.Backup.Task",version:1,method:"get",scope:this,params:{task_id:this.taskId,additional:["backup_params","rotate_params","schedule","backup_filter","backup_volumes"]}},{api:"SYNO.Backup.Repository",version:1,method:"get",params:{repo_id:this.repoId,additional:["support_auto_unmount","local_volume","support_ssl","support_rotate","support_app_share","support_detect_time_limit","support_version_file_log"]}}]},scope:this,callback:this.getDefaultParamsDone})},getDefaultParamsDone:function(e,t,s){if(this.clearStatusBusy(),e)if(t.result[0].success)if(t.result[1].success){var i=t.result[0].data,a=t.result[1].data;this.taskName=i.name,this.repoName=a.name,this.loadRepoAuth(a,i),this.loadBackupSource(i),this.loadBackupParams(i),this.setAppCheckList(i),this.setAppLastConfig(i)}else this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.result[1].error.code),(function(){this.close()}),this);else this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.result[0].error.code),(function(){this.close()}),this);else this.getMsgBox().alert(_T("leaf","backup"),_T("error","error_error_system"),(function(){this.close()}),this)},loadRepoAuth:function(e,t){this.getAuthPanel().getForm().setValues({name:e.name}),SYNO.Backup.Util.HBKDisplayComboboxLoadData(this.getAuthPanel().relink_target_id,[t.target_id])},loadBackupSource:function(e){var t=this.getSourceSelector();e&&e.source&&(SYNO.Backup.Util.IsImage(this.targetType)&&(t.setVolumeList(e.source.backup_volumes),t.setExcludeFolderList(SYNO.Backup.Util.ExtractPattern(e.source.backup_filter.exclude_list,"dir")),this.getSourceSelectorPanel().saveFilterParams(e.source.backup_filter||{})),t.setFolderList(e.source.file_list))},setAppCheckList:function(e){this.getAppPanel().setAppCheckList(e.source.app_list)},setAppLastConfig:function(e){this.getAppPanel().setAppLastConfig(e.source.app_config)},loadAppParams:function(){this.getAppPanel().isLoaded()&&this.getAppPanel().setAppCheckList(this.getAppPanel().getAppList()),this.getAppPanel().loadStore(this.support_app_share)},loadBackupParams:function(e){this.getParamsPanel().getForm().setValues(Ext.apply({task_name:e.name},e.backup_params))},loadFilterParams:function(e){this.getSourceSelectorPanel().saveFilterParams(e.backup_filter||{})},loadBackupVolumeAndExcludeFolder:function(e){if(!this.isImage&&e){var t=this.getSourceSelector();e.backup_volumes&&t.setVolumeList(e.backup_volumes),e.backup_filter&&t.setExcludeFolderList(SYNO.Backup.Util.ExtractPattern(e.backup_filter.exclude_list,"dir"))}},initializeTask:function(){this.setStatusBusy();var e=this.getSourceSelector().getPathProcessParams(),t={file_list:e.folder_list,app_list:this.getAppPanel().getAppList(),app_config:this.getAppPanel().getAppConfig()};SYNO.Backup.Util.IsImage(this.targetType)&&(t.backup_volumes=e.backup_volumes,t.backup_filter=SYNO.Backup.Util.deepCopyObject(this.getParams().backup_filter));var s=Ext.apply(this.getParams(),{task_id:this.taskId,sess_id:this.sess_id,source:t});delete s.backup_filter,delete s.backup_volumes,this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"import",params:s,callback:this.onRelinkTaskDone,scope:this})},onRelinkTaskDone:function(e,t,s){if(!e)return this.clearStatusBusy(),void this.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===t.code&&this.close()}),this);this.getParamsPanel().getForm().findField("task_name").isDirty()?this.owner.onDataTaskRenamed(this.taskId,(function(){this.clearStatusBusy(),this.close()}),this):(this.clearStatusBusy(),this.close()),this.fireEvent("wizardResult",!0)},getParams:function(){var e=this.callParent();return this.taskId&&(e.ori_task_id=this.taskId),e},createTaskDefaultName:function(e){return this.taskName},getSourceSelectorPanel:function(){return this.getStep(this.source_selector_id)},getSourceSelector:function(){return this.getSourceSelectorPanel().getSourceSelector()},getAppPanel:function(){return this.getStep("app")},getParamsPanel:function(){return this.getStep("params")},getAuthPanel:function(){return this.getStep("auth_repo")},doIfAppShareReady:function(e){this[e]=!0,this.app_loaded&&this.folder_loaded&&this.folder_initialed&&SYNO.SDS.Backup.setAppGridDependency(this.getAppPanel(),this.getSourceSelector(),!0,!1)},isTaskNameValid:function(e){return this.taskName===e||-1===this.owner.getTaskNameList().indexOf(e)},getRepoInfo:function(){return this.getParams()},reportError:function(e,t){t=t||{},this.reporter||(this.reporter=new SYNO.SDS.Backup.ApiHelper({owner:this})),this.reporter.alert(e,t.callback,t.scope)}}),Ext.define("SYNO.SDS.Backup.Task.DataMainPage",{extend:"SYNO.SDS.Backup.Task.MainPage",WINDOW_SIZE:5,constructor:function(e){this.pollingTaskID=null,this.pollingTargetID={},this.transSizeBuf=[],this.isCalculatingSpace=!1,this.destStatusLoaded=!1,this.skipNextWebAPI=!1,this.skipCheckLastResult=!1,this.canResume=!1,this.canDiscard=!1,this.canSuspend=!1,this.isImage="image"===e.targetType||"cloud_image"===e.targetType,this.isCloudImage="cloud_image"===e.targetType,this.targetType=e.targetType,this.transferType=e.transferType;var t=SYNO.Backup.Addon.Util.getID(this.targetType,this.transferType);this.addonInfo=SYNO.Backup.Addon.Util.getInfo(t),this.isReAuth=!1,this.maxVersionSourceSize=0,this.usedSize=0,this.usedSizeCache=0,this.transSize=0,this.repo={},this.reconnectTimes=0,this.dataType=e.dataType,this.callParent(arguments);var s='<div class="bkp-time-text">'+SYNO.SDS.Backup.String("app","last_bkp_success_time")+': {lastBkpTime}</div><div class="bkp-time-text">'+_T("backup","next_bkp_time")+": {nextBkpTime}</div>";"sfr_s3"===this.transferType&&(s='<div class="bkp-time-text">'+SYNO.SDS.Backup.String("app","status_cloud_not_support_sfr")+"</div>"),this.getStatusPanel().getComponent("statusCard").getComponent("idle").getComponent("timeText").tpl=s},initEvents:function(){this.callParent(arguments),this.mon(this,"activate",(function(){this.getDestPanel().setHeaderStatus(SYNO.SDS.Backup.String("app","status_connecting"),"#0086E5")}),this,{single:!0})},loadStaticData:function(){var e=this.appWin.getTaskById(this.taskId);e.accountMeta||(e.accountMeta=SYNO.SDS.Backup.Client.Common.Utils.createAccountMeta(),"synocloud_swift"===this.transferType&&e.accountMeta.setSynoCloudDefault()),"synocloud_swift"===this.transferType?this.sendWebAPI({compound:{mode:"parallel",stopwhenerror:!1,params:[{api:"SYNO.Backup.Task",version:1,method:"get",params:{task_id:this.taskId,additional:["repository","schedule"]}},{api:"SYNO.Backup.Target",version:1,method:"get",params:{task_id:this.taskId,additional:["account_meta"]}}]},callback:this.loadTaskStaticWithAccountMeta,scope:this}):this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"get",params:{task_id:this.taskId,additional:["repository","schedule"]},callback:this.loadTaskStatic,scope:this})},onStartPolling:function(){var e;this.pollingTaskID||(e=this.isImage?["last_bkp_time","next_bkp_time","last_bkp_result","is_modified","last_bkp_progress","last_bkp_success_version"]:["last_bkp_time","next_bkp_time","last_bkp_result","is_modified"],this.pollingTaskID=this.pollReg({webapi:{api:"SYNO.Backup.Task",version:1,method:"status",params:{task_id:this.taskId,blOnline:!0===this.getIsOnline(),additional:e}},interval:3,immediate:!0,scope:this,status_callback:this.loadTaskDynamic}));this.refreshTargetPolling()},refreshTaskInfo:function(){var e;this.appWin.setStatusBusy(),e=this.isImage?["last_bkp_time","next_bkp_time","last_bkp_result","is_modified","last_bkp_progress"]:["last_bkp_time","next_bkp_time","last_bkp_result","is_modified"],this.sendWebAPI({compound:{mode:"parallel",stopwhenerror:!1,params:[{api:"SYNO.Backup.Task",version:1,method:"status",params:{task_id:this.taskId,blOnline:!0===this.getIsOnline(),additional:e}},{api:"SYNO.Backup.Task",version:1,method:"get",params:{task_id:this.taskId,additional:["repository","schedule"]}}]},callback:this.loadTask,scope:this})},loadTask:function(e,t){e?(this.loadTaskDynamic(t.result[0].success,t.result[0].data),this.loadTaskStatic(t.result[1].success,t.result[1].data)):this.appWin.clearStatusBusy()},refreshTargetPolling:function(){if("broken"===this.taskState&&!1===this.getIsOnline()||"unauth"===this.taskState&&!1===this.getIsOnline())this.stopTargetPolling();else{var e={};!1===this.getIsOnline()?e={additional:["is_online"],interval:120}:"canceling"!==this.taskStatus&&"relink"!==this.taskStatus&&"delete"!==this.taskStatus&&"broken"!==this.taskState&&this.isImage?"backup"===this.taskStatus||"importable"===this.taskState?e={additional:["is_online","used_size"],interval:30}:"relinkable"===this.taskState?e={additional:["is_online","used_size","check_auth"],interval:30}:this.isCalculatingSpace?e={additional:["is_online","used_size","check_auth"],interval:3}:"suspend"===this.taskLastResult||"discard_failed"===this.taskStatus?e={additional:["is_online","used_size","check_task_key","check_auth","suspend_runtime_button"],interval:30}:(e={additional:["is_online","used_size","check_task_key","check_auth","account_meta"],interval:30},this.destStatusLoaded&&e.additional.push("update_account_meta")):e={additional:["is_online"],interval:30},this.spaceUndetermined()&&e.additional.remove("used_size");var t=JSON.stringify(e);if(Ext.isEmpty(this.pollingTargetID[t])){for(var s in this.pollingTargetID)this.pollingTargetID.hasOwnProperty(s)&&s!==t&&this.stopTargetPollingID(s);this.pollingTargetID[t]=this.pollReg({webapi:{api:"SYNO.Backup.Target",version:1,method:"get",params:{task_id:this.taskId,additional:e.additional}},interval:e.interval,immediate:!0,scope:this,status_callback:this.loadTarget})}}},settingClickHandler:function(e){if(e){var t=e.getTemplateTarget();Ext.each(Ext.query("div.detail-value .detail-value-link",t.dom),(function(e){var t=Ext.fly(e),s=e.className.split(" ");Ext.each(s,(function(e){if("open_filter"===e)return t.on("click",(function(){this.openEditWindow({openFilterPage:!0})}),this),!1}),this)}),this)}},editDialogIsReadOnly:function(){return"backupable"===this.taskState&&!1===this.isTaskNotRunning()&&!1===this.inVersionDeleteSession()},openEditWindow:async function(e){var t=this.appWin.getTaskById(this.taskId),s={targetType:this.targetType,transferType:this.transferType,dataType:t.data_type,isImage:this.isImage,isSuspended:"suspend"===this.taskLastResult,isDiscard:"discard"===this.taskLastResult,isOnline:this.getIsOnline(),isReadOnly:this.editDialogIsReadOnly(),taskState:this.taskState,owner:this.appWin,appWin:this.appWin,taskId:this.taskId,repoId:this.repoId,accountMeta:t.accountMeta,appInstance:this.findAppWindow().appInstance};Ext.apply(s,e);var i=new SYNO.SDS.Backup.TaskEditDialog(s);return this.mon(i,"close",this.loadStaticData,this),this.editDialogIsReadOnly()&&await SYNO.SDS.Backup.Util.asyncAlert(i.owner.getMsgBox(),_T("leaf","backup"),SYNO.SDS.Backup.String("app","task_busy_read_only")),this.openWindow(i),i},stopTargetPollingID:function(e){Ext.isEmpty(this.pollingTargetID[e])||(this.pollUnreg(this.pollingTargetID[e]),delete this.pollingTargetID[e])},stopTargetPolling:function(){for(var e in this.pollingTargetID)this.pollingTargetID.hasOwnProperty(e)&&this.stopTargetPollingID(e)},onStopPolling:function(){this.pollingTaskID&&(this.pollUnreg(this.pollingTaskID),this.pollingTaskID=null),this.stopTargetPolling()},loadTaskStatic:function(e,t,s){if(!this.isDestroyed)if(e){var i=t.target_id;".hbk"===t.target_id.slice(-4,t.target_id.length)&&(i=i.slice(0,i.lastIndexOf(".hbk"))),this.loadDestData({repository:t.repository,targetId:i}),this.repo=t.repository;var a={};Ext.each(t.source.folder_list,(function(e,t,s){var i,n=0,r=e.folderPath.split("/");!this.isImage&&e.dataEncrypted&&2<r.length?(i=r[1],n=1):i=SYNO.Backup.Util.getSharePath(e.folderPath),i in a?a[i]+=n:a[i]=n}),this);var n=[];Ext.iterate(a,(function(e,t){t>0?n.push(e+"/"+t+" "+_T("backup","folders")):n.push(e.substr(1))}),this),n.sort();var r={folder:0!==n.length?n.join(", "):_T("common","none"),app:0!==t.source.app_name_list.length?t.source.app_name_list.join(", "):_T("common","none"),schedule:this.getScheduleStr(t.schedule),data_type:t.data_type,data_enc:t.data_enc};if(SYNO.Backup.Util.IsImage(t.target_type)){var o=[],c=[];o=o.concat(t.source.backup_filter.whitelist),c=c.concat(SYNO.Backup.Util.ExtractPattern(t.source.backup_filter.exclude_list,"file"));var l="";if(0<t.source.backup_volumes.length){var u=[];Ext.each(t.source.backup_volumes,(function(e){u.push(SYNO.Backup.Util.parseVolName(e))})),l=u.join(", ")}else l=_T("common","none");Ext.apply(r,{volume:l,filter:0<o.length||0<c.length?SYNO.SDS.Backup.String("app","on"):SYNO.SDS.Backup.String("app","off"),filterLinkText:0<o.length||0<c.length?SYNO.SDS.Backup.String("app","version_detail"):"",filterHandleFn:"open_filter"})}"multi_ver_lun"===t.data_type&&(r.lun_name=t.source.lun_name,r.lun_type=t.source.lun_type),this.loadSettingData(r),this.appWin.clearStatusBusy()}else this.appWin.clearStatusBusy()},loadTaskStaticWithAccountMeta:function(e,t){e?(this.loadTaskStatic(t.result[0].success,t.result[0].data),t.result[1].success&&!Ext.isEmpty(t.result[1].data.account_meta)&&this.appWin.getTaskById(this.taskId).accountMeta.setData(t.result[1].data.account_meta)):this.appWin.clearStatusBusy()},lastResultHasVersion:function(e){return void 0!==e&&0<Number(e)},getLastBkpTextCls:function(e){return this.isEnableBrowse()&&this.lastResultHasVersion(e)?"last-bkp-version-link":""},setBkpTime:function(e,t,s){this.callParent(arguments);var i=this.getStatusPanel().getComponent("statusCard").getComponent("idle");if(i&&i.isVisible()){var a;try{a=i.getComponent("timeText").getEl().select("."+this.getLastBkpTextCls(s))}catch(e){return}a&&a.on("click",(function(){this.isTaskVerified(this.appWin.getTaskById(this.taskId))?this.launchVersionList(s):this.launchPasswordWindow((function(){this.launchVersionList(s)}))}),this)}},getDestData:function(e){var t=[],s=SYNO.Backup.Addon.Util.getFunc(this.addonInfo.id,"Destination.getInfo");return Ext.isDefined(e)||(e={repository:{},targetId:void 0}),e.isImage=this.isImage,e.taskState=this.taskState,e.stringSection=this.addonInfo.stringSection,e.regionWebLink=this.addonInfo.options.regionWebLink,e.popupIcon=this.addonInfo.options.popupIcon,e.targetType=this.targetType,e.transferType=this.transferType,Ext.isEmpty(this.destStore)||(Ext.isEmpty(this.destStore.getById("space"))||(e.spaceUsage=this.destStore.getById("space").get("text")),Ext.isEmpty(this.destStore.getById("last_detect_time"))||(e.lastDetectTime=this.destStore.getById("last_detect_time").get("text")),Ext.isEmpty(this.destStore.getById("owner_name"))||(e.ownerName=this.destStore.getById("owner_name").get("text"))),Ext.isFunction(s)&&(t=s(e)),Ext.each(t,(function(t){if(t.text=Ext.util.Format.htmlEncode(t.text),t.tip=t.text,Ext.isDefined(t.regionWebLink)){var s="",i="";s=Ext.isDefined(e.repository.region)?String.format(t.regionWebLink,e.repository.region):t.regionWebLink,e.popupIcon&&(i='<span class="popup-icon"></span>'),t.text=String.format('<b><a href="{0}" target="_blank">{1} {2}</a></b>',s,t.text,i)}})),t},getSettingData:function(e){var t,s={key:SYNO.SDS.Backup.String("app","backup_type"),text:e?(t=e.data_type,"data"==t?SYNO.SDS.Backup.String("app","backup_type_data"):"entire_dsm"==t?SYNO.SDS.Backup.String("app","backup_type_entire_dsm"):"multi_ver_lun"==t?SYNO.SDS.Backup.String("app","backup_type_multiver_lun"):""):_T("common","loading")},i={key:_T("tree","leaf_sharefolder"),text:e?Ext.util.Format.htmlEncode(e.folder):_T("common","loading")},a={key:_T("lunbkp","lun_source"),text:function(e){return e?SYNO.Backup.Util.GetMultiVerLunDisplayName(e.lun_name,e.lun_type):""}(e)||_T("common","loading")},n={key:_TT("SYNO.SDS.Backup.Application","app","application"),text:e?Ext.util.Format.htmlEncode(e.app):_T("common","loading")},r={key:SYNO.SDS.Backup.String("app","file_filter_title"),text:e?Ext.util.Format.htmlEncode(e.filter):_T("common","loading"),link_text:e?e.filterLinkText:"",handle_fn:e?e.filterHandleFn:""},o={key:SYNO.SDS.Backup.String("app","backup_schedule_title"),text:e?Ext.util.Format.htmlEncode(e.schedule):_T("common","loading")};if(!e)return[s,o];switch(e.data_type){case"data":return[].concat([s,i,n],this.isImage?[r]:[],[o]);case"multi_ver_lun":return[s,a,o];case"entire_dsm":return[s,o];default:return SYNO.Debug.error("Unknown data type: "+e.data_type),[]}},getScanFileCountStr:function(e){return e>0?SYNO.SDS.Backup.String("app","scan_file_count")+e:""},getTransFileSizeStr:function(e){return String.format(SYNO.SDS.Backup.String("app","processed_changed_data"),SYNO.SDS.Backup.ConverSize(e,2))},getProgressData:function(e,t,s,i,a){return{isShowPercentage:!0,hidePercentageNumber:!a,description:e,speed:function(e,t,s){var i=parseInt(s,10);if(e.length>0&&e[0].tran_size>i&&(e.length=0),e.unshift({tran_size:i,tran_time:(new Date).getTime()}),e.length>t&&e.pop(),e.length>1){var a=1e3*(e[0].tran_size-e[e.length-1].tran_size);if(a>0){var n=a/(e[0].tran_time-e[e.length-1].tran_time);return SYNO.SDS.Backup.ConverSize(n,2)+"/s"}return""}return""}(this.transSizeBuf,this.WINDOW_SIZE,s),percentage:t,bottom_description:this.getTransFileSizeStr(s),scan_file:this.getScanFileCountStr(i)}},setDetailLinkVisibility:function(){if(this.settingView){var e=this.isEnableEdit(),t=this.settingView.getTemplateTarget();!0===e?t.removeClass("hidelink"):!1===e&&t.addClass("hidelink")}},setBtnStatus:function(){if(this.callParent(arguments),this.taskStatus&&this.taskState&&this.isImage){var e=this.isEnableBrowse();this.browseBtn.disable().setDisabled(!e);var t=e;this.getDestPanel().buttons[0].setDisabled(!t);var s=e&&this.getIsSupportStatistics();this.statisticBtn.disable().setDisabled(!s);var i=!("backup"!==this.taskStatus&&"waiting"!==this.taskStatus||"backupable"!==this.taskState&&"exportable"!==this.taskState);this.backingupMenu.setDisabled(!i),this.backingupMenu.menu.getComponent("btn_suspend").setDisabled(!(i&&this.canSuspend));var a=("backupable"===this.taskState||"exportable"===this.taskState)&&"resuming"===this.taskLastResult;a?(this.backingupMenu.menu.getComponent("btn_cancel").hide(),this.backingupMenu.menu.getComponent("btn_cancel_discard").show(),this.backingupMenu.menu.getComponent("btn_cancel_discard").setDisabled(!(i&&this.canCancel))):(this.backingupMenu.menu.getComponent("btn_cancel").show(),this.backingupMenu.menu.getComponent("btn_cancel_discard").hide(),this.backingupMenu.menu.getComponent("btn_cancel_discard").setDisabled(!0));var n=("backupable"===this.taskState||"exportable"===this.taskState)&&("none"===this.taskStatus&&"suspend"===this.taskLastResult||"discard_failed"===this.taskStatus),r="discard_failed"===this.taskStatus;this.suspendedMenu.setDisabled(!n),this.suspendedMenu.menu.getComponent("btn_resume").setDisabled(!(!0===this.getIsOnline()&&n&&this.canResume&&!r)),this.suspendedMenu.menu.getComponent("btn_discard").setDisabled(!(!0===this.getIsOnline()&&n&&this.canDiscard))}},getBackupStepStr:function(e,t,s,i){switch(e){case"data_backup":return _T("netbackup","netbkp_backuping");case"prebackup":return _T("usbbackup","usbbkp_init");case"backup_prepare":return SYNO.SDS.Backup.String("app","backup_preparing");case"config_backup":return _T("backup","bkpstatus_sys");case"app_backup":return Ext.isEmpty(s)?_T("backup","bkpstatus_app"):t+s;case"total_size_count":return _T("localbkp","localbkp_check_dest_size")+" ("+String.format(SYNO.SDS.Backup.String("app","check_file_count"),i.counted_file_count)+")";case"backup_complete":return SYNO.SDS.Backup.String("app","backup_completing");case"postbackup":return _T("backup","backup_finishing");case"canceling":return _T("backup","backup_do_cancel");case"rebuild_client_cache":case"rebuild_tag":return SYNO.SDS.Backup.String("app","resume_preparing");case"upload_queue":return _T("common","none");case"wait_server":return SYNO.SDS.Backup.String("app","backup_wait_process");case"entire_dsm_backup":return SYNO.SDS.Backup.String("app","entire_system_data");case"device_busy":return SYNO.SDS.Backup.String("app","device_busy")}return _T("common","none")},getRelinkStepStr:function(e){switch(e){case"prerelink":return _T("usbbackup","usbbkp_init");case"total_size_count":return _T("localbkp","localbkp_check_dest_size");case"download":return _T("dashboard_version","downloading");case"rebuild_index":return _T("backup","transmitted_size");case"postrelink":return _T("backup","backup_finishing");case"canceling":return _T("backup","backup_do_cancel")}return _T("common","none")},getAppStageStr:function(e){return Ext.isEmpty(e)?"":String.format(SYNO.SDS.Backup.String("app","backing_up_app_something"),e)},spaceUndetermined:function(){return"backupable"===this.taskState&&"backup"===this.taskStatus&&"backup_prepare"===this.backup_step||"backupable"===this.taskState&&"suspending"===this.taskStatus},setTaskDetailStatus:function(e){var t=null!==this.taskStatus&&this.taskStatus!==e.status,s=this.taskLastResult!==e.last_bkp_result&&"suspend"===e.last_bkp_result;if(t||s){var i=[];i=!t&&s||"discard_failed"===e.status?["is_online","suspend_runtime_button"]:"none"===e.status&&"suspend"===e.last_bkp_result?["is_online","check_task_key","check_auth","suspend_runtime_button"]:["is_online","check_task_key","check_auth"],this.sendWebAPI({api:"SYNO.Backup.Target",version:1,method:"get",params:{task_id:this.taskId,additional:i},scope:this,callback:this.loadTarget})}t&&"discarding"===this.taskStatus&&(this.usedSize=-1,this.usedSizeCache=-1,this.updateSpace(this.maxVersionSourceSize,this.usedSize,this.usedSizeCache));var a,n=Ext.isEmpty(e.progress)?"":e.progress.title_type;if(this.canSuspend=!Ext.isEmpty(e.progress)&&!0===e.progress.can_suspend,this.isImage&&(this.canCancel=!Ext.isEmpty(e.progress)&&!0===e.progress.can_cancel),this.setTaskStatus(e.state,e.status,e.last_bkp_time,e.last_bkp_result,e.last_bkp_error_code,e.last_bkp_error,e.is_modified,n),this.transSize=0,"canceling"===e.status||"waiting"===e.status||"preparing_version_delete"===e.status||"relink_waiting"===e.status||"deleting"===e.status||"suspending"===e.status)this.setProgress({isShowPercentage:!1,hidePercentageNumber:!0,description:"",bottom_description:"",scan_file:""});else if("backup"===e.status){if(this.prevProgressPercentage=this.prevProgressPercentage||0,t&&(this.prevProgressPercentage=0),e.progress){const t=e.progress.progress_type;if("entire_dsm"===t||"multi_ver_lun"===t){e.progress.percentage<this.prevProgressPercentage&&SYNO.Debug("suspicious progress from webapi, previous is "+this.prevProgressPercentage+"% but latest is "+e.progress.percentage+"%"),this.prevProgressPercentage=Math.max(this.prevProgressPercentage,e.progress.percentage);const s="entire_dsm"===t?SYNO.SDS.Backup.String("app","entire_system_data"):SYNO.SDS.Backup.String("app","multi_ver_lun_data");return void this.setProgress(this.getProgressData(s,Math.round(this.prevProgressPercentage),e.progress.transmitted_bytes,0,!0))}}this.backup_step=e.progress?e.progress.step:"none";var r=e.progress?e.progress.current_app:"",o=e.progress?e.progress.current_app_stage:"",c=e.progress?e.progress.app_list:[],l="("+((e.progress?e.progress.app_done_list:[]).length+1).toString()+"/"+(c.length+1).toString()+"): ",u=this.getBackupStepStr(this.backup_step,l,r,e.progress),p=e.progress?e.progress.progress:0,d=e.progress?e.progress.current_app_percent:0,h=e.progress?e.progress.scan_file_count:0,S=e.progress?e.progress.transmitted_size:0,_=!e.progress||e.progress.show_progress;if("data_backup"===this.backup_step||"upload_queue"===this.backup_step){var g=l+SYNO.SDS.Backup.String("app","shared_folder_data");this.setProgress(this.getProgressData(g,p,S,h,_)),this.transSize=S/1024,0<this.usedSize&&this.updateSpace(this.maxVersionSourceSize,this.usedSize+this.transSize,this.usedSizeCache)}else"app_backup"==this.backup_step?this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,description:u,scan_file:"",bottom_description:this.getAppStageStr(o),percentage:d}):"backup_prepare"===this.backup_step?this.setProgress({isShowPercentage:!1,hidePercentageNumber:!0,description:u,bottom_description:"",scan_file:""}):"postbackup"===this.backup_step?this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,description:u,speed:"",percentage:p,bottom_description:this.getTransFileSizeStr(S),scan_file:this.getScanFileCountStr(h)}):this.setProgress({isShowPercentage:!1,hidePercentageNumber:!0,description:u,bottom_description:"",scan_file:""})}else if("relink"===e.status){var k=e.progress?e.progress.step:"none",m=this.getRelinkStepStr(k);"download"===k||"rebuild_index"===k?this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,description:m,speed:"",percentage:e.progress?e.progress.progress:0,bottom_description:"",scan_file:""}):this.setProgress({isShowPercentage:!1,hidePercentageNumber:!0,description:m,bottom_description:"",scan_file:""})}else if("detect"===e.status){var f=e.progress?e.progress.stage:"none";"detect_index"===f?this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,description:SYNO.SDS.Backup.String("app","detect_index_progress"),percentage:e.progress?e.progress.progress:0,bottom_description:"",scan_file:""}):"detect_data"===f?this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,description:SYNO.SDS.Backup.String("app","detect_data_progress"),percentage:e.progress?e.progress.progress:0,bottom_description:"",scan_file:""}):"detect_cloud_data"===f?this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,description:SYNO.SDS.Backup.String("app","detect_cloud_progress"),percentage:e.progress?e.progress.progress:0,bottom_description:"",scan_file:""}):"collect_error_index"===f?this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,description:SYNO.SDS.Backup.String("app","collect_error_index"),percentage:e.progress?e.progress.progress:0,bottom_description:"",scan_file:""}):this.setProgress({isShowPercentage:!1,hidePercentageNumber:!0,description:SYNO.SDS.Backup.String("app","backup_preparing"),bottom_description:"",scan_file:""})}else if("detect_waiting"===e.status)this.setProgress({isShowPercentage:!1,hidePercentageNumber:!0,description:SYNO.SDS.Backup.String("app","task_status_check"),bottom_description:"",scan_file:""});else if("discarding"===e.status)this.setProgress({isShowPercentage:!0,hidePercentageNumber:!1,speed:"",percentage:e.progress?e.progress.progress:0,description:"",bottom_description:"",scan_file:""});else if("backupable"===e.state&&"version_deleting"===e.status){this.setProgress({isShowPercentage:!!e.progress,hidePercentageNumber:!e.progress,speed:"",percentage:e.progress?e.progress.progress:0,description:(a=e.progress,a?"unlink_version"===a.stage?String.format(SYNO.SDS.Backup.String("app","deleting_version_desc"),SYNO.SDS.Backup.Client.Common.Utils.getDSMStyleDateTimeString(1e3*a.version_create_time,{type:"datetimesec"})):"compact"===a.stage?SYNO.SDS.Backup.String("app","deleting_version_compact"):void 0:""),bottom_description:"",scan_file:""})}else"backupable"===e.state&&"none"===e.status&&"suspend"===e.last_bkp_result&&this.setSuspendedProgress({isShowPercentage:!!e.last_bkp_progress,hidePercentageNumber:!e.last_bkp_progress,percentage:e.last_bkp_progress?e.last_bkp_progress:0,bottom_description:"",scan_file:""});this.spaceUndetermined()&&(this.usedSize=-1,this.usedSizeCache=-1,this.updateSpace(this.maxVersionSourceSize,this.usedSize,this.usedSizeCache)),!0!==this.getIsOnline()||!0!==this.isImage||!1!==this.skipCheckLastResult||"backupable"!==e.state||"none"!==e.status||"failed_checking"!==e.last_bkp_result&&"backingup"!==e.last_bkp_result&&"resuming"!==e.last_bkp_result||this.updateLastResult()},loadTaskDynamic:function(e,t,s){this.isDestroyed||("sfr_s3"===this.transferType&&(t.state="endofservice"),this.skipNextWebAPI?this.skipNextWebAPI=!1:e?(this.setTaskDetailStatus(t),this.setBkpTime(t.last_bkp_success_time,t.next_bkp_time,t.last_bkp_success_version),this.refreshTargetPolling()):SYNO.SDS.Backup.ERR_INTERNAL_ERROR===t.code&&t.errors&&"task_not_exist"===t.errors.description&&this.appWin.deleteCurrentTask())},loadDestStatus:function(e,t,s){var i,a;e?i=t.is_online:(i=!!t.errors&&t.errors.is_online,(a=4442!==t.code||"rsync_ds"!==this.transferType&&"rsync"!==this.transferType?4442===t.code&&"image_remote"===this.transferType?SYNO.SDS.Backup.String("error","remote_service_disable"):SYNO.SDS.Backup.GetErrorStringEx(t):SYNO.SDS.Backup.String("error","rsync_service_disable"))===_T("error","error_error_system")&&(a=SYNO.SDS.Backup.String("error","general_backup_destination_disconnect"))),!1===(i=!!i)&&"exportable"===this.taskState&&"synocloud_swift"===this.transferType&&!Ext.isEmpty(this.repo)&&"/mnt/synology_cloud_export_share"===this.repo.share&&1>this.reconnectTimes&&(this.reconnectTimes++,this.remountFireball()),this.setIsOnline(i,a),this.destStatusLoaded||(this.destStatusLoaded=!0)},loadTarget:function(e,t,s,i){if(!this.isDestroyed){if(e||"broken"!==this.taskState||this.stopTargetPolling(),Ext.isEmpty(t.can_resume)||(this.canResume=t.can_resume),Ext.isEmpty(t.can_discard)||(this.canDiscard=t.can_discard),this.isCalculatingSpace=!1,this.loadDestStatus(e,t,s),this.setBtnStatus(),Ext.isObject(t.capability)&&this.setIsSupportStatistics(t.capability.support_statistics),!Ext.isEmpty(t.account_meta))this.appWin.getTaskById(this.taskId).accountMeta.setData(t.account_meta);0<=s.additional.indexOf("used_size")&&(this.maxVersionSourceSize=t.max_version_source_size||t.source_size,this.usedSize=t.used_size,this.usedSizeCache=t.used_size_cache,this.updateSpace(this.maxVersionSourceSize,this.usedSize+this.transSize,t.used_size_cache));var a=this.destStore.getById("owner_name");a&&(Ext.isEmpty(t.owner_name)?a.set("text",SYNO.SDS.Backup.String("app","not_available")):a.set("text",t.owner_name));var n=this.destStore.getById("last_detect_time");n&&("error_detect"===this.taskState?(n.set("text",SYNO.SDS.Backup.String("app","detect_result_doing")),n.set("tip",SYNO.SDS.Backup.String("app","detect_result_doing"))):Ext.isEmpty(t.last_detect_time)?(n.set("text",SYNO.SDS.Backup.String("app","detect_result_none")),n.set("tip",SYNO.SDS.Backup.String("app","detect_result_none"))):(n.set("text",SYNO.SDS.Backup.Client.Common.Utils.getDSMStyleDateTimeString(t.last_detect_time)),n.set("tip",SYNO.SDS.Backup.Client.Common.Utils.getDSMStyleDateTimeString(t.last_detect_time)))),this.refreshTargetPolling()}},updateSpace:function(e,t,s){var i=this.destStore.getById("space");if(i){var a="";if(this.isCloudImage){var n=this.appWin.getTaskById(this.taskId),r=t;SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.SPACE_SOURCE===n.accountMeta.spaceUsage&&Ext.isDefined(e)&&(r=e),i.set("text",this.getSpaceStr(this.getIsOnline(),r)),i.set("tip",this.getCloudSpaceTip(this.getIsOnline(),r,s))}else a=this.getSpaceStr(this.getIsOnline(),t),i.set("text",a),i.set("tip",a)}},getSpaceStr:function(e,t){var s="";return e?void 0===t?s=_T("error","error_error"):-1===t?(this.isCalculatingSpace=!0,s=_T("backup","calculating")):s=SYNO.SDS.Backup.ConverSize(1024*t,2):s=SYNO.SDS.Backup.String("app","not_available"),s},getCloudSpaceTip:function(e,t,s){if(e){var i=_T("backup","bkp_storage")+": "+this.getSpaceStr(e,t),a=SYNO.SDS.Backup.String("app","index_size")+": "+this.getSpaceStr(e,s);return String.format("{0}<br/>{1}",i,a)}return SYNO.SDS.Backup.String("app","not_available")},onDetectTarget:function(){this.isTaskVerified(this.appWin.getTaskById(this.taskId))?this.prepareDetectTarget():this.launchPasswordWindow(this.prepareDetectTarget)},prepareDetectTarget:function(){this.owner.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Target",version:1,method:"status",params:{task_id:this.taskId,required_idx_major:0,required_idx_minor:3,required_idx_sub_minor:3,additional:["version_cmp"]},scope:this,callback:function(e,t,s){this.owner.clearStatusBusy(),e?this.alertDetectTarget(t.status,!1):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code))}})},alertDetectTarget:function(e,t){var s=new SYNO.SDS.Backup.AlertWindow({appWin:this.appWin,owner:this.appWin,yesBtnText:_T("common","ok"),noBtnText:_T("common","cancel"),width:486,height:1!==e&&6!==e||t?335:285,title:SYNO.SDS.Backup.String("app","detect_title"),formItems:[{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","detect_after_import"),hidden:!t},{xtype:"syno_displayfield",value:"1. "+SYNO.SDS.Backup.String("error","target_busy_protect_rollback"),hidden:1===e||6===e||t},{xtype:"syno_displayfield",value:(1===e||6===e?"":"2. ")+SYNO.SDS.Backup.String("app",this.isCloudImage?"incheck_cloud_desc":"incheck_desc"),hidden:t},{xtype:"syno_checkbox",name:"detect_data",checked:t||this.isCloudImage,disabled:t,hidden:this.isCloudImage,boxLabel:SYNO.SDS.Backup.String("app","detect_data")},{xtype:"syno_displayfield",value:SYNO.SDS.Backup.String("app","detect_data_warning")}],callback:Ext.createDelegate((function(e,t){if("yes"===e){var s=this.appWin.getTaskById(this.taskId);this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Target",version:1,method:"error_detect",params:{task_id:this.taskId,detect_data:"true"===t.detect_data,sessId:s.sess_id,sessKey:s.sess_key},scope:this,callback:function(e,t,s){e?this.setTaskDetailStatus({state:"error_detect",status:"detect"}):this.owner.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code),(function(){SYNO.SDS.Backup.ERR_SESSION_EXPIRED===t.code&&this.owner.clearCurTaskSession()}),this),this.appWin.clearStatusBusy()}}),this.skipNextWebAPI=!0}}),this)});this.openWindow(s)},onEditBackupTask:async function(e){var t=await this.openEditWindow();Ext.isString(e)&&t.getComponent("edit_tab_panel").setActiveTab(e)},onDeleteBackupTask:function(){var e=this.taskId;this.findAppWindow().getMsgBox().confirmDelete("",_T("backup","backup_confirm_delete_task"),(function(t){"yes"===t&&(this.findAppWindow().setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"delete",params:{task_id_list:[e],is_remove_data:!1},callback:function(e,t,s){this.findAppWindow().clearStatusBusy(),e?this.setTaskDetailStatus({state:"broken",status:"deleting"}):this.findAppWindow().getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code))},scope:this}))}),this)},launchPasswordWindow:function(e){var t=this.appWin.getTaskById(this.taskId),s={task_id:t.task_id,repo_id:t.repo_id,target_id:t.target_id},i=new SYNO.SDS.Backup.Client.Common.Password.Window({owner:this.appWin,verify_params:s,setter:Ext.createDelegate(this.appWin.setCurTaskSession,this.appWin),callback:Ext.createDelegate(e,this,[])});this.openWindow(i)},doCancelBackup:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"cancel",params:{task_id:this.taskId,task_state:this.taskState},scope:this,callback:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code));this.setTaskDetailStatus({state:this.taskState,status:"canceling"}),this.appWin.clearStatusBusy()}})},doCancelAndDiscard:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"cancel_and_discard",params:{task_id:this.taskId},scope:this,callback:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code));this.setTaskDetailStatus({state:this.taskState,status:"canceling"}),this.appWin.clearStatusBusy()}})},doCancelErrorDetect:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Target",version:1,method:"error_detect_cancel",params:{task_id:this.taskId},scope:this,callback:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code));this.setTaskDetailStatus({state:this.taskState,status:"canceling"}),this.appWin.clearStatusBusy()}})},doSuspendBackup:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"suspend",params:{task_id:this.taskId,task_state:this.taskState},scope:this,callback:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code));this.setTaskDetailStatus({state:this.taskState,status:"suspending"}),this.appWin.clearStatusBusy()}})},doDiscard:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"discard",params:{task_id:this.taskId},scope:this,callback:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorStringEx(t));this.setTaskDetailStatus({state:this.taskState,status:"discarding",progress:{progress:0}}),this.appWin.clearStatusBusy()}})},onBackupNow:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"backup",params:{task_id:this.taskId},scope:this,callback:this.onBackupDone})},onImportNow:function(){this.isReAuth=!1,this.addonInfo&&Ext.isObject(this.addonInfo.oauth)?this.launchOAuthWindow(this.addonInfo):this.launchImportWizard()},onRelinkNow:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"relink",timeout:36e5,params:{task_id:this.taskId},scope:this,callback:this.onRelinkDone})},onReauthNow:function(){this.isReAuth=!0,this.addonInfo&&Ext.isObject(this.addonInfo.oauth)?this.launchOAuthWindow(this.addonInfo):this.onEditBackupTask("repo_panel")},onResumeNow:function(){this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"resume",params:{task_id:this.taskId},scope:this,callback:this.onResumeDone})},getBackupErrorString:function(e){if(!e.errors)return SYNO.SDS.Backup.GetErrorStringEx(e);const t=e.errors;return e.code===SYNO.SDS.Backup.ERR_REPOSITORY_PERM_DENIED&&Ext.isString(t.owner_name)&&Ext.isString(t.repo_share_name)?String.format(SYNO.SDS.Backup.String("error","no_repo_permission_action_for_task_owner_ex"),e.errors.owner_name,e.errors.repo_share_name):e.code===SYNO.SDS.Backup.ERR_TARGET_PERM_DENIED&&Ext.isString(t.owner_name)&&Ext.isString(t.target_share_path)?String.format(SYNO.SDS.Backup.String("error","no_target_permission_action_for_task_owner_ex"),e.errors.owner_name,e.errors.target_share_path):SYNO.SDS.Backup.GetErrorStringEx(e)},onBackupDone:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),this.getBackupErrorString(t));this.setTaskDetailStatus({state:this.taskState,status:"waiting"}),this.appWin.clearStatusBusy()},onRelinkDone:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code));this.setTaskDetailStatus({state:this.taskState,status:"relink_waiting"}),this.appWin.clearStatusBusy()},onReauthDone:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorString(t.code));this.setIsOnline(!0,""),this.setTaskDetailStatus({state:"backupable",status:"none"}),this.appWin.clearStatusBusy()},onResumeDone:function(e,t,s){if(!e)return this.appWin.clearStatusBusy(),void this.appWin.getMsgBox().alert(_T("leaf","backup"),SYNO.SDS.Backup.GetErrorStringEx(t));this.setTaskDetailStatus({state:this.taskState,status:"waiting"}),this.appWin.clearStatusBusy()},onVersionList:function(){this.isTaskVerified(this.appWin.getTaskById(this.taskId))?this.launchVersionList():this.launchPasswordWindow(this.launchVersionList)},launchVersionList:function(e){var t=this.appWin.getTaskById(this.taskId),s=new SYNO.SDS.Backup.Client.Common.Version.MainWindow({taskId:this.taskId,repoId:this.repoId,targetId:this.targetId,targetType:this.targetType,transferType:this.transferType,isDiscard:"discard"===this.taskLastResult,sessId:t.sess_id,sessKey:t.sess_key,taskState:this.taskState,appWin:this.appWin,owner:this.appWin,hideVersionDelete:SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.ABILITY_DISABLE===t.accountMeta.versionDelete||"discard"===this.taskLastResult,hideVersionLock:SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.ABILITY_DISABLE===t.accountMeta.versionLock,accountMeta:t.accountMeta,openVersion:e});this.openWindow(s)},onStatisticBrowse:function(){var e=this.appWin.getTaskById(this.taskId),t=SYNO.SDS.Backup.Client.Common.Utils.AccountMeta.STATISTICS_SOURCE!==e.accountMeta.statisticsDisplay,s=new SYNO.SDS.Backup.Client.Common.Statistic.MainWindow({title:SYNO.SDS.Backup.String("statistics","storage_statistics_title"),taskId:this.taskId,appWin:this.appWin,owner:this.appWin,supportTargetStatistic:t});this.openWindow(s)},onVersionBrowse:function(){this.isTaskVerified(this.appWin.getTaskById(this.taskId))?this.launchVersionBrowse():this.launchPasswordWindow(this.launchVersionBrowse)},isTaskVerified:function(e){return!e.data_enc||!Ext.isEmpty(e.sess_id)},launchVersionBrowse:function(){var e=this.appWin.getTaskById(this.taskId);SYNO.SDS.AppLaunch("SYNO.SDS.Backup.Client.Explore.AppInstance",{launchInstance:this.owner,taskId:this.taskId,sess_id:e.sess_id,sess_key:e.sess_key,launcher:"BackupAndRestore",backend:"HyperBackup-backend"})},launchOAuthWindow:function(e){var t=SYNO.Backup.Addon.Util.getOathWindowParams(e);return!!Ext.isObject(t)&&(this.winAuth||(Ext.isIE||Ext.isIE11||Ext.isIE10?window.cbDSCS=this.authCB.createDelegate(this):(this.cbDSCS=this.receiveMessage.createDelegate(this),window.addEventListener("message",this.cbDSCS))),this.winAuth=window.open(encodeURI(t.url),"",t.specs),!0)},authCB:function(e){this.winAuth=null,Ext.isEmpty(e.error)&&(this.isReAuth?this.reauthTask(e.access_token,e.refresh_token,e.openstack_token):this.launchImportWizard(e))},receiveMessage:function(e){"hyperbackup_oauth"===e.data.source&&(window.removeEventListener("message",this.cbDSCS),this.authCB(e.data))},launchImportWizard:function(e){var t={};Ext.isEmpty(e)?t.auth_response={}:t.auth_response=e;var s=new SYNO.SDS.Backup.TaskImportWizard(Ext.apply(t,{taskId:this.taskId,repoId:this.repoId,appWin:this.appWin,targetType:this.targetType,transferType:this.transferType,owner:this.appWin}));this.mon(s,"close",this.refreshTaskInfo,this),this.mon(s,"wizardResult",this.ImportWizardCB,this),this.openWindow(s)},ImportWizardCB:function(e){e&&setTimeout(Ext.createDelegate((function(){this.alertDetectTarget(1,!0)}),this),1e3)},reauthTask:function(e,t,s){var i={};"synocloud_swift"===this.transferType?(Ext.isEmpty(e)||(i.key=e),Ext.isEmpty(t)||(i.secret=t),Ext.isEmpty(s)||(i.tenant_id=s)):(Ext.isEmpty(e)||(i.remote_access_token=e),Ext.isEmpty(t)||(i.remote_refresh_token=t)),this.appWin.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"reauth",params:Ext.apply(i,{task_id:this.taskId}),callback:this.onReauthDone,scope:this})},updateLastResult:function(){this.skipCheckLastResult=!0,this.sendWebAPI({api:"SYNO.Backup.Target",version:1,method:"status",params:{task_id:this.taskId,update_last_result:!0},scope:this,callback:function(e,t,s){this.skipCheckLastResult=!1}})},remountFireball:function(){var e={};e.fireball_url=this.repo.dest,this.sendWebAPI({api:"SYNO.Backup.Repository",version:1,method:"mount_fireball",params:e,scope:this,callback:function(e,t,s){e&&(this.onStopPolling(),this.onStartPolling())}})}}),Ext.define("SYNO.SDS.Backup.Application",{extend:"SYNO.SDS.AppInstance",appWindowName:"SYNO.SDS.Backup.MainWindow"}),Ext.define("SYNO.SDS.Backup.EmptyPage",{extend:"SYNO.ux.Panel",initComponent:function(){this.callParent(arguments),this.addClass("syno-backup-empty-page"),this.emptyMessage=new Ext.Container({width:330,cls:"syno-backup-empty-page-container",items:[{xtype:"container",height:120,width:120,cls:"syno-backup-empty-page-icon"},{xtype:"container",html:SYNO.SDS.Backup.String("error","empty_page_message_btn_top"),cls:"syno-backup-empty-page-text"}]}),this.add(this.emptyMessage)},onStartPolling:function(){},onStopPolling:function(){}}),Ext.define("SYNO.SDS.Backup.MainWindow",{extend:"SYNO.SDS.Backup.PageListAppWindow",emptyPageId:"syno_backup_empty_page",emptyPageFn:"SYNO.SDS.Backup.EmptyPage",constructor:function(e){this.pollingID=null,this.listPanel=null,this.isRestoreWinShow=!1,this.loadFirstDone=!1;var t={xtype:"syno_button",btnStyle:"blue",tooltip:_T("common","create"),iconCls:"syno-sds-backup-create-icon",margins:"0 6px 0 0",cls:"syno-sds-backup-btn"};Ext.apply(t,{handler:this.openCreateWizard,scope:this});var s={xtype:"syno_button",tooltip:_S("is_admin")?_T("netbackup","netbkp_recovery"):SYNO.SDS.Backup.String("app","only_admin_able_restore"),iconCls:"syno-sds-backup-restore-icon",disabled:!_S("is_admin"),margins:"0 6px 0 0",cls:"syno-sds-backup-btn"};return Ext.apply(s,{handler:this.openRestoreWizard,scope:this}),this.callParent([Ext.apply({cls:"syno-app-backup",width:990,height:580,minWidth:1e3,minHeight:580,listPanel:this.getListPanel(),buttonItems:[t,s,{xtype:"syno_button",tooltip:_T("tree","leaf_log"),iconCls:"syno-sds-backup-log-icon",cls:"syno-sds-backup-btn",handler:this.openLogWindow,scope:this}]},e)])},getListPanel:function(){if(this.listPanel)return this.listPanel;var e=this,t={isRestore:!1,taskNameList:[],sendWebAPI:function(){var t=arguments;synowebapi.promises.request({api:"SYNO.Backup.Task",method:"correct_synorbd",version:1}).catch((function(e){SYNO.Debug.error("Failed to correct synorbd"),SYNO.Debug.error(e)})).then((function(){e.sendWebAPI.apply(e,t)}))},webapi:{api:"SYNO.Backup.Task",version:1,method:"list"},baseParams:{sort_by:"name",additional:["last_bkp_time","last_bkp_result","get_source","is_modified","progress_title_type"]},parseWebApiResponse:function(e,t){this.taskList=t.task_list;for(var s=0;s<this.taskList.length;s++)"sfr_s3"===this.taskList[s].transfer_type&&(this.taskList[s].state="unauth");return this.isRestore=t.is_restoring||t.is_snapshot_restoring,this.isSnapshotRestore=t.is_snapshot_restoring,e.ownerTree.owner.popUpWindowIfNeeded(t.is_data_restoring,t.is_lun_restoring),this.taskNameList=[],Ext.each(this.taskList,(function(e){this.taskNameList.push(e.name)}),this),this.taskList},getRepoIcon:function(e){var t={loclunbkp:"syno-backup-task-lun",netlunbkp:"syno-backup-task-lun"},s=SYNO.Backup.Addon.Config.addon_list;return Ext.each(s,(function(e){var s=e.target_type+":"+e.transfer_type;t[s]=e.taskIconCls})),e in t?t[e]:"syno-backup-task-local"},createNodeFn:function(e){"lun"===e.data_type?e.state||(e.state="backupable"):["data","entire_dsm","multi_ver_lun"].includes(e.data_type)||(e.state="backupable"),e.uiProvider="SYNO.SDS.Backup.TaskTreeNodeUI",e.leaf=!0,e.text=e.name,e.statusIcon=SYNO.SDS.Backup.getStatusIcon(e.state,e.status,e.last_bkp_result,e.is_modified,e.progress_title_type),e.iconCls=this.getRepoIcon(e.type),["data","entire_dsm","multi_ver_lun"].includes(e.data_type)?(e.id=""+e.task_id,e.fn="SYNO.SDS.Backup.Task.DataMainPage",e.pageConfig={taskState:e.state,taskStatus:e.status,taskLastResult:e.last_bkp_result,taskIcon:e.statusIcon,taskId:e.task_id,repoId:e.repo_id,targetId:e.target_id,targetType:e.target_type,transferType:e.transfer_type,dataType:e.data_type}):(e.id="Lun_"+e.task_id,e.fn="SYNO.SDS.Backup.Task.LunMainPage",e.pageConfig={taskState:e.state,taskStatus:e.status,taskIcon:e.statusIcon,taskName:e.name,taskType:e.type})}};return this.listPanel=new SYNO.SDS.Backup.ModuleList({layout:"fit",align:"stretch",border:!1,padding:"4px 16px 0 12px",flex:1,owner:this,loaderCfg:t}),this.listPanel},initEvents:function(){this.callParent(arguments),this.on("show",(function(){Ext.isEmpty(this.modalWin)&&this.onStartPolling()})),this.on("hide",this.onStopPolling),this.mon(this.listPanel.loader,"load",this.onLoadFirst,this,{single:!0}),this.mon(this.listPanel.loader,"loadexception",this.clearStatusBusy,this,{single:!0})},onLoadFirst:function(){SYNO.Backup.Addon.Config.updateAllowList(!1,[]),this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"get_support_cloud",scope:this,callback:function(e,t,s){this.clearStatusBusy(),e&&SYNO.Backup.Addon.Config.updateAllowList(t.allow_all,t.allow_list),this.loadFirstDone=!0;var i=this.listPanel.getRootNode(),a=this.getTaskList();i.childNodes.length>0?this.selectPage(i.childNodes[0].id):(this.launchEmptyPage(),this.isRestoreWinShow||this.openCreateWizard()),this.clearStatusBusy(),Ext.isEmpty(a)||this.alertMarkTask(a),Ext.isEmpty(this.modalWin)&&this.onStartPolling()}})},onOpen:function(){this.setStatusBusy(),this.callParent(arguments)},openWindow:function(e){this.onStopPolling(),e.on("close",this.onStartPolling,this),e.open()},popUpWindowIfNeeded:function(e,t){var s;this.isRestoreWinShow||(e||t)&&(this.isRestoreWinShow=!0,(s=e?new SYNO.SDS.Backup.Restore.ProgressWindow({restore_id:-1,owner:this}):new SYNO.SDS.Backup.Restore.LunProgressWindow({owner:this})).on("close",(function(){this.isRestoreWinShow=!1}),this),this.openWindow(s))},isRestore:function(){return this.listPanel.loader.isRestore},isSnapShotRestore:function(){return this.listPanel.loader.isSnapshotRestore},getCurrentTask:function(){var e=this.listPanel.getSelectionModel().getSelectedNode();return Ext.isEmpty(e)?null:e.attributes},setCurTaskSession:function(e){var t=this.getCurrentTask();t.sess_id=e.sess_id,t.sess_key=e.sess_key},clearCurTaskSession:function(){var e=this.getCurrentTask();delete e.sess_id,delete e.sess_key},getTaskById:function(e){return this.listPanel.getNodeById(e).attributes},getTaskList:function(){return this.listPanel.loader.taskList},getTaskNameList:function(){return this.listPanel.loader.taskNameList},getLunTaskId:function(e){return"Lun_"+e},onLunTaskRenamed:function(e,t,s){this.refreshAndSelectTask(this.getLunTaskId(e),t,s)},onDataTaskRenamed:function(e,t,s){this.refreshAndSelectTask(e,t,s,!0)},onLunTaskCreated:function(e,t,s){this.refreshAndSelectTask(this.getLunTaskId(e),t,s)},onTaskCreated:function(e,t,s){this.refreshAndSelectTask(e,t,s)},refreshAndSelectTask:function(e,t,s,i){var a=this.getListWebApi();a.scope=this,a.callback=function(a,n,r,o){var c=this.updateList(n);this.selectPage(e),i&&this.rearrangeNode(this.listPanel.getNodeById(e),this.listPanel.getRootNode(),c),t&&t.call(s)},this.sendWebAPI(a)},selectPageByIndex:function(e){var t=this.listPanel.getRootNode();t.childNodes.length>e&&e>-1?this.selectPage(t.childNodes[e].id):t.childNodes.length>0?this.selectPage(t.childNodes[t.childNodes.length-1].id):this.launchEmptyPage()},deleteCurrentTask:function(){var e=this.listPanel,t=e.getSelectionModel().getSelectedNode(),s=e.getRootNode(),i=s.childNodes.indexOf(t);e.loader.taskList=e.loader.taskList.filter((function(e){return e.id!==t.id})),e.loader.taskNameList=e.loader.taskNameList.filter((function(e){return e!=t.attributes.name})),s.removeChild(t),this.selectPageByIndex(i),this.pageContainer.remove(t.id),e.updateScroller()},openCreateWizard:function(){var e=new SYNO.SDS.Backup.TaskCreateWizard({appWin:this,owner:this});this.openWindow(e)},openRestoreWizard:function(){var e=new SYNO.SDS.Backup.Restore.RestoreWizard({restoreTaskPage:this,appWin:this,owner:this});this.openWindow(e)},openLogWindow:function(){var e=new SYNO.SDS.Backup.Client.Common.Log.LogsWindow({appWin:this,jsConfig:this.jsConfig,owner:this});this.openWindow(e)},getListWebApi:function(){return{api:"SYNO.Backup.Task",version:1,method:"list",params:{sort_by:"name",additional:["last_bkp_time","last_bkp_result","is_modified","progress_title_type"]}}},onStartPolling:function(){if(!this.pollingID&&this.loadFirstDone){this.pollingID=this.pollReg({webapi:this.getListWebApi(),interval:3,immediate:!1,scope:this,status_callback:this.onPollingDone});var e=this.getActivePage();e&&e.onStartPolling()}},onStopPolling:function(){if(this.pollingID){this.pollUnreg(this.pollingID),this.pollingID=null;var e=this.getActivePage();e&&e.onStopPolling()}},insertNode:function(e,t,s){var i;t.length>s+1&&(i=this.listPanel.getNodeById(t[s+1].id)),i?e.insertBefore(t[s],i):e.appendChild(t[s])},rearrangeNode:function(e,t,s){var i,a=e.id;Ext.each(s,(function(e,t){if(e.id===a)return i=t,!1})),t.childNodes[i].id!==a&&(t.removeChild(e),this.insertNode(t,s,i),this.selectPage(a))},setTaskStatusIcon:function(e,t){void 0===t&&(t=this.listPanel.getSelectionModel().getSelectedNode());var s=this.pageContainer.getComponent(t.id);"check"===e&&(Ext.isEmpty(s)||t.id!==this.listPanel.getSelectionModel().getSelectedNode().id&&!1===s.skipCheckLastResult)&&(e="failed"),Ext.fly(t.ui.statusIcon).replaceClass("task-status-icon-"+t.attributes.statusIcon,"task-status-icon-"+e),t.attributes.statusIcon=e},updateList:function(e){var t=this.listPanel,s=t.getRootNode(),i=s.childNodes.length,a=[],n=t.getLoader().parseWebApiResponse(s,e);return Ext.each(n,t.getLoader().createNodeFn,t.getLoader()),Ext.each(s.childNodes,(function(e,t){a.push(e.id)}),this),Ext.each(n,(function(e,i){var r=t.getNodeById(e.id);r?(a.remove(e.id),r.setText(e.text),this.setTaskStatusIcon(e.statusIcon,r)):this.insertNode(s,n,i)}),this),Ext.each(a,(function(e){var i=t.getNodeById(e),a=this.pageContainer.getComponent(e);s.removeChild(i),a&&a.onStopPolling(),this.pageContainer.remove(e)}),this),i!=s.childNodes.length&&t.updateScroller(),n},onPollingDone:function(e,t,s,i){if(e){var a=this.listPanel.getSelectionModel().getSelectedNode(),n=this.listPanel.getRootNode().childNodes.indexOf(a);this.updateList(t),null===this.listPanel.getSelectionModel().getSelectedNode()&&this.selectPageByIndex(n)}},alertMarkTask:function(e){var t=[],s=[];if(Ext.each(e,(function(e,i,a){Ext.isArray(e.ext3ShareList)&&0<e.ext3ShareList.length&&(t.push(e.name),Ext.each(e.ext3ShareList,(function(e,t,i){0>s.indexOf(e)&&s.push(e)}),this))}),this),0<t.length){var i=SYNO.SDS.Backup.String("app","ext3issue_fullbackup_hint")+"<br />"+_T("backup","task_name")+": "+t.join(", ");new SYNO.SDS.Backup.AlertWindow({appWin:this,owner:this,title:SYNO.SDS.Backup.String("app","ext3issue_fullbackup_title"),formItems:[{xtype:"syno_displayfield",htmlEncode:!1,value:i},{name:"notremind",xtype:"syno_checkbox",boxLabel:SYNO.SDS.Backup.String("app","remind_confirm")}],callback:Ext.createDelegate((function(e,t){"yes"!==e&&"true"!==t.notremind||(this.setStatusBusy(),this.sendWebAPI({api:"SYNO.Backup.Task",version:1,method:"mark",params:{markedShareList:s,fixTasks:"yes"===e,notRemind:t.notremind},scope:this,callback:function(e,t,s){this.clearStatusBusy()}}))}),this)}).open()}}}),Ext.define("SYNO.SDS.Backup.TaskTreeNodeUI",{extend:"Ext.tree.TreeNodeUI",renderElements:function(e,t,s,i){this.indentMarkup=e.parentNode?e.parentNode.ui.getChildIndent():"";var a,n=Ext.isBoolean(t.checked),r=this.getHref(t.href),o=['<li class="x-tree-node"><div ext:tree-node-id="',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="',t.icon||this.emptyIcon,'" class="x-tree-node-icon',t.icon?" x-tree-node-inline-icon":"",t.iconCls?" "+t.iconCls:"",'" unselectable="on" />',n?'<input class="x-tree-node-cb" type="checkbox" '+(t.checked?'checked="checked" />':"/>"):"",'<a hidefocus="on" class="x-tree-node-anchor" href="',r,'" tabIndex="1" ',t.hrefTarget?' target="'+t.hrefTarget+'"':"",'><span ext:qtip="',e.text,'" unselectable="on">',e.text,"</span></a>",'<img alt="" src="',this.emptyIcon,'" class="task-status-icon task-status-icon-',t.statusIcon,'" />',"</div>",'<ul class="x-tree-node-ct" style="display:none;"></ul>',"</li>"].join("");!0!==i&&e.nextSibling&&(a=e.nextSibling.ui.getEl())?this.wrap=Ext.DomHelper.insertHtml("beforeBegin",a,o):this.wrap=Ext.DomHelper.insertHtml("beforeEnd",s,o),this.elNode=this.wrap.childNodes[0],this.ctNode=this.wrap.childNodes[1];var c=this.elNode.childNodes;this.indentNode=c[0],this.ecNode=c[1],this.iconNode=c[2];var l=3;n&&(this.checkbox=c[3],this.checkbox.defaultChecked=this.checkbox.checked,l++),this.anchor=c[l],this.textNode=c[l].firstChild,this.statusIcon=c[l+1]},onTextChange:function(e,t,s){this.rendered&&(this.textNode.innerHTML=t,this.textNode.setAttribute("ext:qtip",t))}}),Ext.define("SYNO.SDS.Backup.Restore.AppUtil",{treePanel:null,constructor:function(e){Ext.apply(this,e)},convertLanguage:function(e,t){var s=SYNO.SDS.Backup.converLanString(e[t]);s&&(t+"_param"in e&&(s=String.format(s,e[t+"_param"])),e[t]=s)},onCreateAppNode:function(e){this.convertLanguage(e,"text"),this.convertLanguage(e,"qtip"),"warn"===e.type&&(e.text='<element class="red-status">'+e.text+"</element>",e.qtip='<element class="red-status">'+e.qtip+"</element>")},getAppCheckedSubTreeRoot:function(e){var t=[],s=function(e){e.eachChild((function(e){var i=e.getUI()||{};Ext.isFunction(i.getCheckValue)&&i.checkbox&&(!0!==i.getCheckValue()&&"gray"!==i.getCheckValue()||(t.push(e),s(e)))}))};return s(e),t},getAppList:function(e){var t=[];return Ext.each(this.getAppCheckedSubTreeRoot(this.treePanel.getNodeById("app_root")),(function(e){t.push(e.id)})),t},getCheckAppApi:function(){var e=[];return Ext.each(this.getAppList(),(function(t){var s,i={};if("mysql"===t){var a=this.treePanel.getNodeById("mysql_pwd");s=a?a.getUI().getInputValue():"",i.api="SYNO.Backup.App.Restore",i.version=1,i.method="mysql_check",i.params={},i.params.mysql_pwd=s,e.push(i)}else"surveillance"===t&&(i.api="SYNO.Backup.App.Restore",i.version=1,i.method="surveillance_check",e.push(i))}),this),e}});