"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/log-browser/files"],{1301:(e,t,s)=>{s.r(t);var i=s(88),o=s(470);t.default=class extends i.List{_initConfiguration(e){super._initConfiguration({id:"log-file-list",locale:i.Locale.getSection("smb.components.lists.logfiles"),searchOveral:"name",isDisabledItem:e=>e.readOnly,...e}),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:e=>(0,i.escapeHtml)(e.modificationDisplayDate)},{header:this.lmsg("name"),sortable:!0,dataIndex:"name",renderer:({id:e,name:t})=>`<span class="tooltipData">${this.lmsg("viewHint")}</span><a href="${this._urls.browser}?file=${encodeURIComponent(e)}" class="log-file-name">${(0,i.escapeHtml)(t)}</a>`},{header:this.lmsg("path"),sortable:!0,dataIndex:"path"},{header:this.lmsg("fileSize"),sortable:!0,dataIndex:"fileSize",cls:"t-r number",renderer:e=>(0,i.escapeHtml)(e.fileDisplaySize)},{header:"",sortable:!1,cls:"action-icon-set t-r min",renderer:this._renderTools.bind(this)}]}_renderTools(e){const t=[];return e.isCustom&&t.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"})))),t.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"})))),t.push((0,i.createElement)("span",(0,i.createElement)("span",{class:"tooltipData"},this.lmsg("buttonDownloadHint")),(0,i.createElement)("a",{href:`${this._urls.download}?filename=${encodeURIComponent(e.id)}`,class:"i-link"},(0,i.createElement)("i",{class:"icon-download"})))),t}_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:e=>{this.execGroupOperation({url:this._urls.deleteFile,subtype:"delete",mouseEvent:e,locale:{confirmOnGroupOperation:this.lmsg("confirmOnDelete")}})}})}_addCustomLog(){new i.DirectoryBrowser({subscriptionId:this._webspaceId,showFiles:!0,treeConfig:{filterNodes:e=>e.isDirectory||o.FTYPE_TEXT===e.type||o.FTYPE_UNKNOWN_TEXT===e.type},locale:{title:this.lmsg("customLogPopupTitle"),buttonOk:i.Locale.getSection("components.buttons").lmsg("ok"),buttonCancel:i.Locale.getSection("components.buttons").lmsg("cancel")},onSubmit:e=>{new Ajax.Request(this._urls.addCustom,{method:"post",parameters:{file:`/${e}`},onCreate:()=>{this.disable()},onComplete:e=>{this.reload();JSON.parse(e.responseText).isUnsupportedLog&&(0,i.addStatusMessage)("warning",this.lmsg("invalidLogFormat"))}})}})}_unlinkCustomLog(e){i.messageBox.show({subtype:"unlink",text:this.lmsg("buttonUnlinkConfirmationDescription"),type:i.messageBox.TYPE_YESNO,buttonTitles:{yes:this.lmsg("buttonUnlinkConfirmationYes"),no:this.lmsg("buttonUnlinkConfirmationNo")},onYesClick:()=>{new Ajax.Request(this._urls.unlink,{method:"post",parameters:{file:e.id},onCreate:()=>{this.disable()},onComplete:()=>{this.reload()}})}})}_initActions(){this._itemActions.unlinkCustomLog=this._unlinkCustomLog.bind(this),this._itemActions.viewLog=e=>{const t=`${this._urls.view}?filename=${encodeURIComponent(e.id)}`;window.open(t,"_blank","toolbar=yes,scrollbars=yes,resizable=yes,width=600,height=500,innerWidth=1000,innerHeight=500")}}}}}]);
//# sourceMappingURL=files.js.map?939c95a5580336e9c8fa