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: //usr/local/packages/@appstore/StorageManager/ui/storage.js
/* Copyright (c) 2025 Synology Inc. All rights reserved. */

Ext.define("SYNO.SDS.StorageManager.Instance",{extend:"SYNO.SDS.AppInstance",appWindowName:"SYNO.SDS.StorageManager.MainWindow",shouldNotifyMsg:function(e,t){return!this.window||this.window.isDestroyed||!this.window.isVisible()||this.window.shouldNotifyMsg(e,t)}}),Ext.define("SYNO.SDS.StorageManager.MainWindow",{extend:"SYNO.SDS.AppWindow",constructor:function(e){var t={update_err_count:0,cls:SYNO.SDS.StorageUtils.isVDSM?"syno-app-storage-manager is-vdsm":"syno-app-storage-manager",width:1200,height:580,minWidth:1200,minHeight:580,defaultMaximized:!0,firstTime:!0,items:this.createVuePanel(e)};this.callParent([Ext.apply(t,e)]),this.addManagedComponent(this.vuePanel),this.mon(this,"beforeclose",this.onBeforeWindowClose.bind(this))},initEvents(){this.callParent(arguments);const e=()=>{SYNO.API.RequestPromise({api:"SYNO.Backup.Config.AutoBackup",method:"backup",params:{instant:!1},version:1})};this.mon(this,"close",(function(){e(),Ext.EventManager.un(window,"beforeunload",e)})),Ext.EventManager.on(window,"beforeunload",e),this.mon(SYNO.SDS.StatusNotifier,"halt",(function(){Ext.EventManager.un(window,"beforeunload",e)}))},createVuePanel:function(e){return this.vuePanel=new SYNO.SDS.VuePanel({vueClass:SYNO.SDS.StorageManager.Vue.StoragePanel,mountId:"storage-manager",layout:"fit",cls:"v-storage-manager",owner:this}),this.vuePanel},onOpen:function(e){this.openParam=e,this.callParent(arguments),this.setStatusBusy(),this.cleanMask=!0,this.createPollTask(),this.startPollTask(),this.vuePanel._$vueInst.$refs.storagemgr.$emit("winopen")},onRequest:function(e){this.callParent(arguments),this.checkModalOrMask()||(this.openParam=e,this.setStatusBusy(),this.cleanMask=!0,this.stopPollTask(),this.startPollTask())},onBeforeWindowClose(){return this.getVueInstance().close()},getVueInstance:function(){return this.vuePanel._$vueInst.$refs.storagemgr},createPollTask:function(){var e={api:"SYNO.Storage.CGI.Storage",method:"load_info",version:1,timeout:6e5},t=[e,{api:"SYNO.Core.ISCSI.LUN",version:1,method:"list",additional:["is_action_locked","is_mapped","extent_size","allocated_size","status","allow_bkpobj","flashcache_status","family_config","sync_progress"]}];if(SYNO.SDS.SocketInst.register({api:"SYNO.Storage.CGI.Spare",version:1,method:"list"},(e=>{e&&e.success&&(this.hotSpares=e.data.hotSpares)}),!0),SYNO.SDS.StorageUtils.isSupportCableOverviewUI()){var o="";switch(SYNO.SDS.StorageUtils.getCableOverviewId()){case"SYNO.SDS.StorageManager.DualHeadCableOverview.Main":o="DualEnclosure";break;case"SYNO.SDS.StorageManager.DualChainCableOverview.Main":case"SYNO.SDS.StorageManager.CableOverview.Main":o="Enclosure";break;default:return void SYNO.Debug("no matching cable overview class")}t.push({api:"SYNO.Storage.CGI."+o,method:"load",version:1})}else SYNO.SDS.StorageUtils.isSupportTaipeiOverviewUI()&&t.push({api:"SYNO.Storage.CGI.TaipeiEnclosure",method:"load",version:1});return SYNO.SDS.StorageUtils.isSHA&&(t.push(SYNO.SDS.StorageUtils.ReplaceWebapiSHA(!0,Object.assign({},e))),t.push({api:"SYNO.SHA.Util",method:"load_cluster_info",version:1})),this.pollTask=this.pollTask||this.addWebAPITask({api:"SYNO.Entry.Request",version:1,method:"request",compound:{mode:"parallel",params:t},interval:6e3,callback:this.pollResultHandler,scope:this,timeout:6e5}),this.pollTask},stopPollTask:function(){this.pollTask&&this.pollTask.stop()},startPollTask:function(e){this.pollOnce=e,this.pollTask&&this.pollTask.start()},pollResultHandler:function(e,t,o,a){var i=this,n=this.getVueInstance();if(!e||i.pollShouldReportError(t)){if(t.isAbort)return;if(i.update_err_count+=1,i.update_err_count<3)return void SYNO.Debug("tolerant connection fail, retry")}else i.update_err_count=0;return i.cleanMask&&(i.clearStatusBusy(),i.cleanMask=!1),i.pollOnce&&(i.pollOnce=!1,i.pollTask.stop()),e?i.pollShouldReportError(t)?(Ext.each(t.result,(function(e){e.success||(SYNO.SDS.StorageUtils.HARemoteCheckErrParsing(e.error),SYNO.SDS.StorageUtils.ReportWebapiFailure(i,e.error))})),void i.stopPollTask()):void(n&&n.loadInfo(t,this.hotSpares).then((()=>{this.openParam&&this.handleOpenPage(),i.highlightNodeId&&(i.getVueInstance().highlightNode(i.highlightNodeId),i.highlightNodeId=null),this.fireEvent("storageinfoloaded")}))):(i.getMsgBox().alert("",_T("error","error_subject")),void i.pollTask.stop())},pollShouldReportError:function(e){return!!e.has_fail&&e.result.some((function(t){return"SYNO.Core.ISCSI.LUN"!==t.api&&!1===e.success}))},handleOpenPage:function(){if(!this.checkModalOrMask()&&this.openParam){var{fn:e,tab:t,dlg:o,vueWizard:a,wizard:i,modalParam:n,windowParam:s,skipFirstTime:r,openSpaceReclaimWin:l,openEncVolFieldset:u}=this.openParam;if(n=n||{},e){let o={diskPanel:"disk-tab",general:"settings-tab"}[t];o&&(t=o),this.getVueInstance().openPage(e),"settings-tab"===t&&"SYNO.SDS.StorageManager.Disk.Main"===e&&(a="HDDSettingWindow")}if(o)"FirmwareUpgrade"===o&&(o="SYNO.SDS.StorageManager.Wizard.FirmwareUpgrade",n=Object.assign(n,{requireDiskMap:!0,requirePassiveDiskMapIfSHA:!0})),this.getVueInstance().openWindow(o,n,s);else if(a){var S=this.getVueInstance();Object.keys(SYNO.SDS.StorageManager.Vue).some((e=>a===e))||(a="CreateWizardWindow");var d=`SYNO.SDS.StorageManager.Vue.${a}`,p=null,h=null,c=!1;if("CreateWizardWindow"===a){({component:h}=S.openWindow(d,null,{openVueWin:!0,fromVueWin:c}));if(!n||!["pool","volume","both"].some((e=>n.mode===e))||"string"!=typeof n.title){var g=0<S.pools.length;(n={}).mode=g?"volume":"both",n.title=g?_T("volume","create_volume"):_T("storage_pool","wizard_title_create_both")}h.setMode(n.mode),h.title=n.title}else if("ManageIdleDriveWindow"===a){S.disks.some((e=>e.isIdle().result))?(({window:p,component:h}=S.openWindow(d,null,{openVueWin:!0,fromVueWin:c})),h.$root.$options.window=p):S.getRootWindow().getMsgBox().alert("",_T("disk_info","no_free_disk_to_manage"))}else if("DedupeVolumeConfigWindow"===a){let e=S.volumes.find((e=>e.vol_path===n.vol_path));if(!e||!e.dedup_info||!e.dedup_info.show_config_btn||""!==e.dedup_info.btn_alert)return;({component:h}=S.openWindow(d,null,{openVueWin:!0,fromVueWin:c})),h.init(n.vol_path)}else"HDDSettingWindow"===a&&(({window:p,component:h}=S.openWindow(d,null,{openVueWin:!0,fromVueWin:c})),h.$root.$options.window=p,h.$root.activeTabKey="advance-tab")}else i?this.getVueInstance().openWizard(i,n):l||SYNO.SDS.StorageUtils.supportVolumeEncryption&&u?this.getVueInstance().navigateAndOpenGlobalSetting():!r&&this.firstTime&&(this.getVueInstance().checkIfOpenFirstTimeWizard(),this.firstTime=!1);this.openParam=null}}});