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

Ext.define("SYNO.SDS.WebStation.Web.AliasPortalEditor",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.store=e.store,this.webapi=e.webapi,this.uuid="",this.preserve=e.preserve,this.isEditPanel=e.isEditPanel,this.panel=new SYNO.SDS.WebStation.Web.AliasPortalPanel({module:this.module,preserve:this.preserve,owner:this}),this.callParent([Ext.apply({width:520,autoHeight:!0,items:[this.panel],closeAction:"onCancel",buttons:[{text:_T("common","cancel"),scope:this,handler:this.onCancel},{text:this.isEditPanel?_T("common","save"):_T("common","create"),btnStyle:"blue",disabled:this._S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this,handler:this.onApply}],listeners:{scope:this,show:this.onShow}},e)])},sendRequest:function(e){var t=this.panel.getData();this.sendWebAPI({api:this.webapi.api,method:this.webapi.method,version:this.webapi.version,params:{portal:t},callback:function(e,t){this.clearStatusBusy(),e?(this.fireEvent("close"),this.close()):this.onError(t.code,t.errors)},scope:this})},onShow:function(){this.panel.loadStores()},onForceAcl:function(){this.panel.getForm().isValid()&&(this.panel.getForm().isDirty()?(this.setStatusBusy(),this.sendRequest(!0)):this.close())},onApply:function(){this.panel.getForm().isValid()?this.panel.getForm().isDirty()?(this.setStatusBusy(),this.sendRequest(!1)):this.close():this.setStatusError({text:_T("error","error_bad_field"),clear:!0})},onCancel:async function(){if(!this.panel.getForm().isDirty())return this.close();this.confirmLostChangePromise({save:()=>this.onApply(),cancel:Ext.emptyFn,dontSave:()=>this.close(),confirmText:this.panel.isEditPanel?_TT("SYNO.SDS.WebStation.Application","common","confirm_edit_page"):_TT("SYNO.SDS.WebStation.Application","common","confirm_create_page")},this)},onError:async function(e,t){var i=SYNO.SDS.WebStation.Errors.GetMessage(e);switch(e){case 1022:this.getMsgBox().confirm("",i,(e=>{"yes"===e&&this.onForceAcl()}),this,{yes:_T("common","apply"),cancel:!0});break;case 1310:this.panel.getForm().findField("alias").markInvalid(i),this.setStatusError({text:i,clear:!0});break;default:this.setStatusError({text:i,clear:!0})}},setData:function(e){return this.panel.setData(e)}}),Ext.define("SYNO.SDS.WebStation.Web.AliasPortalPanel",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.module=e.module,this.owner=e.owner,this.preserve=e.preserve,this.dirty=!1;var t=Ext.apply({monitorValid:!0,autoFlexcroll:!0,height:150,fieldWidth:270,padding:0,labelSeparator:_T("common","colon"),items:[{xtype:"syno_combobox",name:"service_id",fieldLabel:_TT("SYNO.SDS.WebStation.Application","common","service"),displayField:"service",valueField:"id",validator:this.serviceValidator,allowBlank:!1,hidden:this.preserve,store:new SYNO.API.JsonStore({appWindow:this.module.appWin,defaultSortable:!0,autoDestroy:!0,autoLoad:!1,root:"services",idProperty:"id",fields:["id",{name:"service",convert:function(e,t){return SYNO.SDS.WebStation.Util.geti18nString(t.display_name_i18n,t.display_name)}}],api:"SYNO.WebStation.WebService.Service",version:1,method:"list",listeners:{scope:this,load:this.onServiceLoad}})},{xtype:"syno_displayfield",name:"service_id_fix",width:250,fieldLabel:_TT("SYNO.SDS.WebStation.Application","common","service"),allowBlank:!1,emptyText:"Service Name",hidden:!this.preserve},{xtype:"syno_textfield",vtype:"aliasname",vtypeText:_TT("SYNO.SDS.WebStation.Application","alias","bad_alias_detail"),maxlength:255,allowBlank:!1,fieldLabel:_T("app_port_alias","desc_alias"),name:"alias"},{xtype:"syno_combobox",name:"acl",fieldLabel:_T("app_port_alias","desc_acl"),displayField:"name",valueField:"UUID",store:new SYNO.API.JsonStore({appWindow:this.module.appWin,defaultSortable:!0,autoDestroy:!0,autoLoad:!1,root:"entries",idProperty:"UUID",fields:["UUID","name"],api:"SYNO.Core.AppPortal.AccessControl",version:1,method:"list",listeners:{scope:this,load:this.onAvailableAclLoad}}),tpl:'<tpl for="."><div ext:qtip="{[SYNO.SDS.WebStation.Util.htmlDoubleEncode(values.name)]}" class="x-combo-list-item">{name:htmlEncode}</div></tpl>'},{xtype:"syno_combobox",fieldLabel:_TT("SYNO.SDS.WebStation.Application","custom_error_page","error_page_profile"),name:"error_page",valueField:"id",displayField:"desc",store:new SYNO.API.JsonStore({appWindow:this.module.appWin,defaultSortable:!0,autoDestroy:!0,autoLoad:!0,root:"profiles",idProperty:"id",fields:["id","desc"],api:"SYNO.WebStation.ErrorPage",version:1,method:"list",listeners:{scope:this,load:this.onAvailableErrorPageLoaded}}),tpl:'<tpl for="."><div ext:qtip="{[SYNO.SDS.WebStation.Util.htmlDoubleEncode(values.desc)]}" class="x-combo-list-item">{desc:htmlEncode}</div></tpl>'}]},e);this.callParent([t]),this.doLayout(),this.mon(this,"afterlayout",this.addToolTip,this,{single:!0})},addToolTip:function(){let e=this.getForm().findField("service_id"),t=this.getForm().findField("acl"),i=this.getForm().findField("error_page");SYNO.ux.AddTip(e.getEl(),_TT("SYNO.SDS.WebStation.Application","common","tip_service_no_available")),SYNO.ux.AddTip(t.getEl(),_TT("SYNO.SDS.WebStation.Application","common","no_acl_profile_available")),SYNO.ux.AddTip(i.getEl(),_TT("SYNO.SDS.WebStation.Application","common","tip_error_page_profile"))},loadStores:function(){this.setStatusBusy();let e=this.getForm().findField("service_id").getStore(),t=this.getForm().findField("acl").getStore();e.load(),t.load()},onServiceLoad:function(e,t){const i={id:null,service:_TT("SYNO.SDS.WebStation.Application","common","status_not_available")},a=this.getForm().findField("service_id"),o=this.getForm().findField("service_id_fix"),s=a.getValue(),r=t.find((e=>e.get("id")===s));let n;if(0===t.length){const e=a.getStore();e.insert(0,new e.recordType(i)),n=i}else r?n={id:r.get("id"),service:r.get("service")}:(n=t[0],this.dirty=!0);a.setValue(n.id),o.setValue(n.service),this.storeLoaded("service")},onAvailableAclLoad:function(e,t){const i={UUID:null,name:_TT("SYNO.SDS.WebStation.Application","default","not_configured")},a=this.getForm().findField("acl"),o=a.getStore();let s;o.insert(0,new o.recordType(i));const r=a.getValue();t.some((e=>e.get("UUID")===r))?s=r:(s=null,null!==r&&(this.dirty=!0)),a.setValue(s),this.storeLoaded("acl")},onAvailableErrorPageLoaded:function(e,t){const i=this.getForm().findField("error_page"),a=i.getValue(),o=t.find((e=>"default"===e.id));let s;void 0!==o&&(o.data.desc=_TT("SYNO.SDS.WebStation.Application","custom_error_page","default_profile")),t.some((e=>e.get("id")===a))?s=a:(s="default",this.dirty=!0),i.setValue(s),this.storeLoaded("error_page")},setStatusBusy:function(){this.owner.setStatusBusy()},storeLoaded:function(e){"service"===e?this.serviceLoaded=!0:"acl"===e?this.aclLoaded=!0:"error_page"===e&&(this.errorPageLoaded=!0),this.serviceLoaded&&this.aclLoaded&&this.errorPageLoaded&&(this.dirty||this.flushDirtyState(),this.owner.clearStatusBusy())},serviceValidator:function(e){return e!==_TT("SYNO.SDS.WebStation.Application","common","status_not_available")&&""!==e||_TT("SYNO.SDS.WebStation.Application","error","bad_service")},getData:function(){let e=this.getForm().getValues(),t={};return this.uuid&&(t.id=this.uuid),t.service=e.service_id,t.alias=e.alias,t.acl=e.acl,t.error_page=e.error_page,t.type="alias",this.portal_data?t.enable=this.portal_data.enable:t.enable=!0,t},setData:function(e){var t={};e.id&&(this.uuid=e.id),t.service_id=e.service,t.alias=e.alias,t.acl=e.acl,t.error_page=e.error_page,t.enable=e.enable,this.portal_data=t,this.getForm().setValues(this.portal_data)},flushDirtyState:function(){this.getForm().items.items.forEach((e=>{e.originalValue=e.getValue()}))}}),Ext.define("SYNO.SDS.WebStation.Dialog.DefaultServer",{extend:"SYNO.SDS.ModalWindow",constructor:function(e){this.module=e.module,this.owner=e.owner,this.panel=this.createPanel(e),this.callParent([Ext.apply({width:650,autoHeight:!0,items:[this.panel],closeAction:"cancel",buttons:[{text:_T("common","cancel"),scope:this,handler:function(){return this.cancel()}},{text:_T("common","save"),btnStyle:"blue",disabled:_S("demo_mode"),tooltip:_S("demo_mode")?_JSLIBSTR("uicommon","error_demo"):"",scope:this,handler:function(){return this.submit()}}]},e)]),this.setStatusBusy()},createPanel:function(e){return new SYNO.SDS.WebStation.DefaultServer({module:e.module,appWin:e.owner,owner:this})},submit:function(){if(this.panel.getForm().isValid())if(this.panel.getForm().isDirty()){this.el.mask(),this.setStatusBusy();var e=this.panel.getData();this.sendWebAPI({api:"SYNO.WebStation.Default",method:"set",version:1,params:e,callback:function(e,t){this.el.unmask(),this.clearStatusBusy(),e?(this.fireEvent("close"),this.close()):this.setStatusError({text:_T("error","error_bad_field")})},scope:this})}else this.close();else this.setStatusError({text:_T("error","error_bad_field")})},cancel:async function(){if(!this.panel.getForm().isDirty())return this.close();this.confirmLostChangePromise({save:()=>this.submit(),cancel:Ext.emptyFn,dontSave:()=>this.close(),confirmText:_TT("SYNO.SDS.WebStation.Application","common","confirm_edit_page")},this)}}),Ext.define("SYNO.SDS.WebStation.DefaultServer",{extend:"SYNO.SDS.Utils.FormPanel",constructor:function(e){this.appWin=e.appWin,this.owner=e.owner,this.webapiDefault={api:"SYNO.WebStation.Default",methods:{get:"get",set:"set"},version:1},this.webapiStatus={api:"SYNO.WebStation.Status",methods:{get:"get"},version:1},this.webapiPHPProfile={api:"SYNO.WebStation.PHP.Profile",methods:{get:"list"},version:1},this.webapiHomeService={api:"SYNO.Core.Share",methods:{get:"get"},version:1};var t=this.fillConfig(e);this.status_data=void 0,this.saveResolve=null,this.serverData=null,this.userdirServerData=null,this.phpData=null,this.callParent([t]),this.loadForm(),this.mon(this,"afterlayout",this.addToolTip,this,{single:!0}),this.mon(SYNO.SDS.StatusNotifier,"thirdpartychanged",this.loadForm,this),this.mon(SYNO.SDS.StatusNotifier,"sharefolderchanged",this.loadForm,this)},fillConfig:function(e){var t={autoScroll:!0,autoHeight:!0,webapi:this.webapiDefault,padding:0,labelSeparator:_T("common","colon"),items:[this.createItems()]};return Ext.apply(t,e),t},createItems:function(){var e=[];return e.push({xtype:"syno_combobox",name:"backend",fieldLabel:_TT("SYNO.SDS.WebStation.Application","default","http_backend"),valueField:"backend_id",displayField:"backend_name",store:new Ext.data.SimpleStore({fields:["backend_id","backend_name"],listeners:{load:{scope:this,fn:this.onAvailableDefaultServerLoad}}}),validator:this.validatorBackend.createDelegate(this),allowBlank:!1}),e.push({xtype:"syno_combobox",name:"php",fieldLabel:"PHP",valueField:"uuid",displayField:"profile_name",store:new Ext.data.SimpleStore({fields:["uuid","profile_name"],listeners:{load:{scope:this,fn:this.onAvailableDefaultServerPHPLoad}}}),validator:this.validatorPHP.createDelegate(this),allowBlank:!1,tpl:'<tpl for="."><div ext:qtip="{[SYNO.SDS.WebStation.Util.htmlDoubleEncode(values.profile_name)]}" class="x-combo-list-item">{profile_name:htmlEncode}</div></tpl>'}),e.push({xtype:"syno_checkbox",name:"userdir",boxLabel:_TT("SYNO.SDS.WebStation.Application","default","enable_userdir"),listeners:{check:{scope:this,fn:function(e,t){let i=!1;t&&(i=this.userHomeCheckHandler()),this.handleUserdirEnableStatus(i)}},disable:{scope:this,fn:function(e){this.handleUserdirEnableStatus(!1)}}}},{xtype:"syno_displayfield",indent:1,value:_TT("SYNO.SDS.WebStation.Application","default","enable_userdir_desc")},{xtype:"syno_combobox",indent:1,name:"userdir_backend",fieldLabel:_TT("SYNO.SDS.WebStation.Application","default","http_backend"),valueField:"backend_id",displayField:"backend_name",store:new Ext.data.SimpleStore({fields:["backend_id","backend_name"],listeners:{load:{scope:this,fn:this.onAvailableUserdirServerLoad}}}),validator:this.validatorBackend.createDelegate(this),allowBlank:!1},{xtype:"syno_combobox",indent:1,name:"userdir_php",fieldLabel:"PHP",valueField:"uuid",displayField:"profile_name",store:new Ext.data.SimpleStore({fields:["uuid","profile_name"],listeners:{load:{scope:this,fn:this.onAvailableUserdirPHPLoad}}}),validator:this.validatorPHP.createDelegate(this),allowBlank:!1,tpl:'<tpl for="."><div ext:qtip="{[SYNO.SDS.WebStation.Util.htmlDoubleEncode(values.profile_name)]}" class="x-combo-list-item">{profile_name:htmlEncode}</div></tpl>'}),e.push({xtype:"syno_displayfield",htmlEncode:!1,value:'<font class="note-font">'+_TT("SYNO.SDS.WebStation.Application","common","note_header")+"</font>"+_TT("SYNO.SDS.WebStation.Application","php","no_php_profile_available")}),e},addToolTip:function(){let e=this.getForm().findField("userdir");SYNO.ux.AddTip(e.getEl(),_TT("SYNO.SDS.WebStation.Application","default","install_apache_for_enable_userdir_tips"))},userHomeCheckHandler:function(){var e=this.status_data.home_share_status;if(e===SYNO.SDS.WebStation.Util.HomeShareStatus.StatusNotEnable)this.owner.getMsgBox().confirm("",_TT("SYNO.SDS.WebStation.Application","default","userdir_warning"),(e=>{"yes"===e&&SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",Ext.apply({fn:"SYNO.SDS.AdminCenter.User.Main",userHomeDialog:!0}))}),this,{yes:_T("common","apply"),cancel:!0});else if(e===SYNO.SDS.WebStation.Util.HomeShareStatus.StatusIsEncrypted)this.owner.getMsgBox().confirm("",_TT("SYNO.SDS.WebStation.Application","default","userdir_encrypt_warning"),(e=>{"yes"===e&&SYNO.SDS.AppLaunch("SYNO.SDS.AdminCenter.Application",Ext.apply({fn:"SYNO.SDS.AdminCenter.Share.Main"}))}),this,{yes:_T("common","apply"),cancel:!0});else{if(!Object.prototype.hasOwnProperty.call(this.home_share_data,"is_cold_storage_share")||!this.home_share_data.is_cold_storage_share)return!0;this.owner.getMsgBox().alert("",_TT("SYNO.SDS.WebStation.Application","default","userdir_pata_warning"))}return this.getForm().findField("userdir").reset(),!1},processParams:function(e,t){this.callParent(arguments);var i={api:this.webapiStatus.api,method:this.webapiStatus.methods.get,version:this.webapiStatus.version};t.push(i);var a={api:this.webapiPHPProfile.api,method:this.webapiPHPProfile.methods.get,version:this.webapiPHPProfile.version};t.push(a);var o={api:this.webapiHomeService.api,method:this.webapiHomeService.methods.get,params:{additional:["is_cold_storage_share"],name:"homes"},version:this.webapiHomeService.version};return t.push(o),t},handleUserdirEnableStatus(e){["userdir_backend","userdir_php"].forEach((function(t){var i=this.getForm().findField(t);i.disabled===e&&i.setDisabled(!e)}),this)},processReturnData:async function(e,t,i){if(t.has_fail){let e=t.result.filter((e=>!e.success));if(!(402===e.find((e=>"SYNO.Core.Share"===e.api)).error.code)||e.length>1)return void this.errorHandling(e[0].error.code)}var a={api:this.webapiStatus.api,method:this.webapiStatus.methods.get,version:this.webapiStatus.version};this.status_data=SYNO.SDS.WebStation.Util.getSuccessRespCompoundData(a,t);var o={api:this.webapiHomeService.api,method:this.webapiHomeService.methods.get,version:this.webapiHomeService.version};this.home_share_data=SYNO.SDS.WebStation.Util.getSuccessRespCompoundData(o,t);var s={api:this.webapiPHPProfile.api,method:this.webapiPHPProfile.methods.get,version:this.webapiPHPProfile.version};this.profile_list=SYNO.SDS.WebStation.Util.getSuccessRespCompoundData(s,t);var r=this.getForm().findField("userdir");this.getForm().loadRecords(t.result,i.compound),this.status_data.home_share_status===SYNO.SDS.WebStation.Util.HomeShareStatus.StatusBackendNotExist&&!1===r.getValue()?r.disable():(r.enable(),this.handleUserdirEnableStatus(r.getValue()));let n=await SYNO.SDS.WebStation.Util.PackageInfo.Get();var l=this.status_data.available_server_backend;this.serverData=l.map((e=>[e,n.backendData.server.find((t=>t.id===e)).name])),this.userdirServerData=this.serverData.filter((e=>0!==e[0])),this.phpData=[[null,_TT("SYNO.SDS.WebStation.Application","default","php_not_configured")]].concat(this.profile_list.profiles.filter((e=>null===e.default_profile)).map((e=>[e.uuid,`${e.profile_name} ( ${n.backendData.php.find((t=>t.id===e.backend)).name} )`]))),[{field:"backend",data:this.serverData},{field:"php",data:this.phpData},{field:"userdir_backend",data:this.userdirServerData},{field:"userdir_php",data:this.phpData}].forEach((e=>{this.getForm().findField(e.field).getStore().loadData(e.data)})),this.owner.clearStatusBusy(),this.el.unmask()},onPageActivate:function(){this.loadForm()},onAvailableDefaultServerLoad:function(e,t){var i=this.getForm().findField("backend");this.onAvailableServerLoad(e,t,i)},onAvailableUserdirServerLoad:function(e,t){var i=this.getForm().findField("userdir_backend");this.onAvailableServerLoad(e,t,i)},onAvailableServerLoad:function(e,t,i){for(var a=i.getValue(),o=0;o<t.length;o++)if(t[o].get("backend_id")===a)return i.reset(),0;if(i.disabled){var s=t.length?t[0].get("backend_id"):"";i.setValue(s)}else i.clearValue();i.originalValue=i.getValue(),i.validate()},onApiSuccess:function(){this.callParent(arguments),this.saveResolve&&(this.saveResolve(),this.saveResolve=null)},onAvailableDefaultServerPHPLoad:function(e,t){var i=this.getForm().findField("php");this.onAvailablePHPLoad(e,t,i)},onAvailableUserdirPHPLoad:function(e,t){var i=this.getForm().findField("userdir_php");this.onAvailablePHPLoad(e,t,i)},onAvailablePHPLoad:function(e,t,i){var a=i.getValue();if("nan"===a)return i.reset(),0;for(var o=0;o<t.length;o++)if(t[o].get("uuid")===a)return i.reset(),0;i.clearValue(),i.originalValue=i.getValue(),i.validate()},validatorBackend:function(e){return this.validatorComboBox(e,this.serverData)},validatorPHP:function(e){return this.validatorComboBox(e,this.phpData)},validatorComboBox:function(e,t){if(!t)return!0;var i=!1;return t.forEach((function(t){t[1]===e&&(i=!0)}),i),!!i||_TT("SYNO.SDS.WebStation.Application","error","err_backend_not_found")},errorHandling:function(e){this.owner.getMsgBox().alert(this.title,SYNO.API.getErrorString(e))},onPageConfirmLostChangeSave:function(){var e=this;return new Promise((function(t,i){e.saveResolve=t,e.applyHandler()}))},cancelHandler:function(){this.loadForm()},getData:function(){return this.getForm().getValues()}});