"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/log-browser/files"],{1993:(t,e,s)=>{s.r(e),s.d(e,{default:()=>o});var i=s(90),n=s(679);const o=class extends i.List{_initConfiguration(t){super._initConfiguration({id:"log-file-list",locale:i.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=[i.list.COLUMN_SELECTION,{header:this.lmsg("modificationDate"),sortable:!0,dataIndex:"modificationDate",cls:"t-r number",renderer:t=>(0,i.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,i.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,i.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&&e.push((0,i.createElement)("span",(0,i.createElement)("span",{class:"tooltipData"},this.lmsg("buttonUnlinkHint")),(0,i.createElement)("a",{class:"i-link",href:"#","data-action-name":"unlinkCustomLog"},(0,i.createElement)("i",{class:"icon-unlink"})))),e.push((0,i.createElement)("span",(0,i.createElement)("span",{class:"tooltipData"},this.lmsg("buttonViewHint")),(0,i.createElement)("a",{class:"i-link",href:"#","data-action-name":"viewLog"},(0,i.createElement)("i",{class:"icon-logs"})))),e.push((0,i.createElement)("span",(0,i.createElement)("span",{class:"tooltipData"},this.lmsg("buttonDownloadHint")),(0,i.createElement)("a",{href:`${this._urls.download}?filename=${encodeURIComponent(t.id)}`,class:"i-link"},(0,i.createElement)("i",{class:"icon-download"})))),e}_initOperations(){this._operations=[],this._operations.push({componentType:i.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:i.SmallButton,id:"buttonSettings",title:this.lmsg("logRotation"),description:this.lmsg("logRotationHint"),addCls:"sb-log-rotation",handler:()=>{new i.AjaxPopupForm({cls:"popup-panel",title:this.lmsg("logRotationTitle"),url:this._urls.logRotation,locale:{waitMsg:this.lmsg("loadingTitle")}})}}),this._operations.push({componentType:i.bar.Separator})),this._operations.push({componentType:i.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 i.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:i.Locale.getSection("components.buttons").lmsg("ok"),buttonCancel:i.Locale.getSection("components.buttons").lmsg("cancel")},onSubmit:t=>{this.disable(),i.api.post(this._urls.addCustom,{file:`/${t}`}).then((t=>{this.reload(),t.isUnsupportedLog&&(0,i.addStatusMessage)("warning",this.lmsg("invalidLogFormat"))}))}})}_unlinkCustomLog(t){i.messageBox.show({subtype:"unlink",text:this.lmsg("buttonUnlinkConfirmationDescription"),type:i.messageBox.TYPE_YESNO,buttonTitles:{yes:this.lmsg("buttonUnlinkConfirmationYes"),no:this.lmsg("buttonUnlinkConfirmationNo")},onYesClick:()=>{this.disable(),i.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?43ec1c8d8ad42af4774f