"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["app/log-browser/files"],{3171(t,e,i){i.r(e),i.d(e,{default:()=>o});var s=i(90),n=i(643);const o=class extends s.List{_initConfiguration(t){super._initConfiguration({id:"log-file-list",locale:s.Locale.getSection("smb.components.lists.logfiles"),searchOveral:"name",isDisabledItem:t=>t.readOnly,...t}),this._webspaceId=this._getConfigParam("webspaceId",""),this._urls=this._getConfigParam("urls",{}),this._initActions(),this._initColumns(),this._initOperations()}_initColumns(){this._columns=[s.list.COLUMN_SELECTION,{header:this.lmsg("modificationDate"),sortable:!0,dataIndex:"modificationDate",cls:"t-r number",renderer:t=>(0,s.escapeHtml)(t.modificationDisplayDate)},{header:this.lmsg("name"),sortable:!0,dataIndex:"name",renderer:({id:t,name:e})=>`<span class="tooltipData">${this.lmsg("viewHint")}</span><a href="${this._urls.browser}?file=${encodeURIComponent(t)}" class="log-file-name">${(0,s.escapeHtml)(e)}</a>`},{header:this.lmsg("path"),sortable:!0,dataIndex:"path"},{header:this.lmsg("fileSize"),sortable:!0,dataIndex:"fileSize",cls:"t-r number",renderer:t=>(0,s.escapeHtml)(t.fileDisplaySize)},{header:"",sortable:!1,cls:"action-icon-set t-r min",renderer:this._renderTools.bind(this)}]}_renderTools(t){const e=[];return t.isCustom&&this._urls.unlink&&e.push((0,s.createElement)("span",(0,s.createElement)("span",{class:"tooltipData"},this.lmsg("buttonUnlinkHint")),(0,s.createElement)("a",{class:"i-link",href:"#","data-action-name":"unlinkCustomLog","aria-label":this.lmsg("buttonUnlinkHint")},(0,s.createElement)("i",{class:"icon-unlink","aria-hidden":"true"})))),e.push((0,s.createElement)("span",(0,s.createElement)("span",{class:"tooltipData"},this.lmsg("buttonViewHint")),(0,s.createElement)("a",{class:"i-link",href:"#","data-action-name":"viewLog","aria-label":this.lmsg("buttonViewHint")},(0,s.createElement)("i",{class:"icon-logs","aria-hidden":"true"})))),e.push((0,s.createElement)("span",(0,s.createElement)("span",{class:"tooltipData"},this.lmsg("buttonDownloadHint")),(0,s.createElement)("a",{href:`${this._urls.download}?filename=${encodeURIComponent(t.id)}`,class:"i-link","aria-label":this.lmsg("buttonDownloadHint")},(0,s.createElement)("i",{class:"icon-download","aria-hidden":"true"})))),e}_initOperations(){this._operations=[],this._urls.addCustom&&this._operations.push({componentType:s.SmallButton,id:"buttonAddCustomLog",title:this.lmsg("addCustomLog"),description:this.lmsg("addCustomLogHint"),addCls:"sb-add-new",handler:this._addCustomLog.bind(this)}),this._urls.logRotation&&(this._operations.push({componentType:s.SmallButton,id:"buttonSettings",title:this.lmsg("logRotation"),description:this.lmsg("logRotationHint"),addCls:"sb-log-rotation",handler:()=>{new s.AjaxPopupForm({cls:"popup-panel",title:this.lmsg("logRotationTitle"),url:this._urls.logRotation,locale:{waitMsg:this.lmsg("loadingTitle")}})}}),this._operations.push({componentType:s.bar.Separator})),this._operations.push({componentType:s.SmallButton,id:"buttonRemoveLogFiles",title:this.lmsg("remove"),description:this.lmsg("hintRemove"),addCls:"sb-remove-selected",handler:t=>{this.execGroupOperation({url:this._urls.deleteFile,subtype:"delete",mouseEvent:t,locale:{confirmOnGroupOperation:this.lmsg("confirmOnDelete")}})}})}_addCustomLog(){new s.DirectoryBrowser({subscriptionId:this._webspaceId,showFiles:!0,treeConfig:{filterNodes:t=>t.isDirectory||n.FTYPE_TEXT===t.type||n.FTYPE_UNKNOWN_TEXT===t.type},locale:{title:this.lmsg("customLogPopupTitle"),buttonOk:s.Locale.getSection("components.buttons").lmsg("ok"),buttonCancel:s.Locale.getSection("components.buttons").lmsg("cancel")},onSubmit:t=>{this.disable(),s.api.post(this._urls.addCustom,{file:`/${t}`}).then(t=>{this.reload(),t.isUnsupportedLog&&(0,s.addStatusMessage)("warning",this.lmsg("invalidLogFormat"))})}})}_unlinkCustomLog(t){s.messageBox.show({subtype:"unlink",text:this.lmsg("buttonUnlinkConfirmationDescription"),type:s.messageBox.TYPE_YESNO,buttonTitles:{yes:this.lmsg("buttonUnlinkConfirmationYes"),no:this.lmsg("buttonUnlinkConfirmationNo")},onYesClick:()=>{this.disable(),s.api.post(this._urls.unlink,{file:t.id}).finally(()=>this.reload())}})}_initActions(){this._itemActions.unlinkCustomLog=this._unlinkCustomLog.bind(this),this._itemActions.viewLog=t=>{const e=`${this._urls.view}?filename=${encodeURIComponent(t.id)}`;window.open(e,"_blank","toolbar=yes,scrollbars=yes,resizable=yes,width=600,height=500,innerWidth=1000,innerHeight=500")}}}}}]);
//# sourceMappingURL=files.js.map?1c38def9df8e4fae9cca