D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
cp
/
public
/
javascript
/
app
/
log-browser
/
Filename :
browser.js
back
Copy
"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/log-browser/browser"],{3026:(e,t,s)=>{s.r(t),s.d(t,{LogsProblemPanel:()=>m});var o=s(286),n=s(89),l=s(3027),i=s(596),r=s.n(i),a=s(285);const c=n.Locale.getSection("components.lists.logbrowser"),d={manual:c.formatMessage("manual"),regular:c.formatMessage("regular")},m=({domainId:e,isDiagnosticEnabled:t=!1,isRegularCheckEnabled:s,problemsCount:n,checkType:i,olderThanDay:r})=>t?s||n&&!r?n?(0,a.jsx)(l.ProblemPanelWrapper,{domainId:e,title:(0,a.jsx)(o.Translate,{content:"issuesFoundInTheLogs"}),label:{content:n,intent:"danger",dataCy:"problem-alert"},image:(0,a.jsx)(o.Icon,{name:"exclamation-mark-circle-filled",intent:"danger",size:"24"}),panelContent:(0,a.jsx)(o.Translate,{content:"lastCheckDetectsProblems",params:{checkType:d[i]}})}):(0,a.jsx)(l.ProblemPanelWrapper,{title:(0,a.jsx)(o.Translate,{content:"noProblemsFound"}),image:(0,a.jsx)(o.Icon,{name:"check-mark-circle-filled",intent:"success",size:"24"}),panelContent:i?(0,a.jsx)(o.Translate,{content:"lastCheckDetectsNoProblems",params:{checkType:d[i]}}):(0,a.jsx)(o.Translate,{content:"noChecksResults"})}):(0,a.jsx)(l.ProblemPanelWrapper,{title:(0,a.jsx)(o.Translate,{content:"learnAboutProblemsFaster"}),label:{content:(0,a.jsx)(o.Translate,{content:"new"}),intent:"success",dataCy:"sucess-alert"},panelContent:(0,a.jsx)(o.Translate,{content:"enableRegularCheck"}),image:(0,a.jsx)(o.Icon,{name:"info-circle-filled",intent:"info",size:"24"}),actionButton:(0,a.jsx)(o.Translate,{content:"openCheckSettings"})}):null;m.propTypes={domainId:r().number.isRequired,isDiagnosticEnabled:r().bool,isRegularCheckEnabled:r().bool,problemsCount:r().number,checkType:r().string,olderThanDay:r().bool}},3027:(e,t,s)=>{s.r(t),s.d(t,{ProblemPanelWrapper:()=>r});var o=s(285),n=s(596),l=s.n(n),i=s(286);const r=({title:e,label:t,image:s,panelContent:n,actionButton:l,domainId:r})=>{const[a,c]=(0,o.useState)(!1),d=l??(0,o.jsx)(i.Translate,{content:"openCheckReport"}),m=r?`/cp/websites-diagnostic/id/${r}`:"/cp/websites-diagnostic";return(0,o.jsx)(i.Panel,{title:(0,o.jsxs)("div",{className:"problem-panel-wrapper__heading",children:[(0,o.jsx)("div",{children:(0,o.jsxs)(i.Heading,{level:4,children:[(0,o.jsx)("span",{className:"problem-panel-wrapper__title",children:e}),t&&(0,o.jsx)(i.Label,{className:"problem-panel-wrapper__label",intent:t.intent,children:(0,o.jsx)("span",{"data-cy":t.dataCy,children:t.content})})]})}),a&&(0,o.jsx)(i.Button,{ghost:!0,icon:"projects",component:"a",href:m,"data-cy":"open-diagnostic",children:d},"button")]}),collapsible:!0,collapsed:a,onToggle:c,children:(0,o.jsx)(i.Media,{image:(0,o.jsx)("div",{className:"problem-panel-wrapper__image",children:s}),imageSpacing:"xl",children:(0,o.jsxs)("div",{className:"problem-panel-wrapper__content",children:[(0,o.jsx)("p",{children:n}),(0,o.jsx)(i.Button,{icon:"projects",component:"a",href:m,"data-cy":"open-diagnostic",children:d})]})})})};r.propTypes={title:l().node.isRequired,image:l().node.isRequired,panelContent:l().node.isRequired,label:l().shape({content:l().oneOfType([l().node,l().number]),intent:l().string,dataCy:l().string}),actionButton:l().node,domainId:l().number}},3025:(e,t,s)=>{s.r(t),s.d(t,{default:()=>c});var o=s(89),n=s(286),l=s(3026),i=s(3028),r=s(285);class a extends o.ScrollableList{onSourceSearchFilterChange(){let e=(0,o.getComponent)("log-browser-files");const t=this;this._sourcesSelected=e.getSelected(),e.updateTextValue();const{realTimeEnabled:s}=t;s&&this.disableRealTime(),t._dataUrl=this.getDataUrl(!0);const n=t._onReloadSuccess;t._onReloadSuccess=function(...l){const i=e.isOpened();t._onReloadSuccess=n,n.apply(t,l),e=(0,o.getComponent)("log-browser-files"),e.setOpened(i),s&&(t.toggleControls(!0),t.enableRealTime())},t.reload()}getDataUrl(e){let t=this._defaultDataUrl;const s=this._sourcesSelected;return this._logFile&&!e?t+=`?file=${encodeURIComponent(this._logFile)}${this._isCustomLog?"&custom=true":""}`:s&&(t+=`?sources=${encodeURIComponent(JSON.stringify(s))}`),t}toggleControls(e=(0,o.getComponent)("log-browser").realTimeEnabled){const t=e?"hide":"show",s=e?"show":"hide";(0,o.getComponent)("log-browser-start-realtime")[t](),(0,o.getComponent)("log-browser-stop-realtime")[s](),(0,o.getComponent)("log-browser-refresh")[t](),(0,o.getComponent)("log-browser-clear")[s](),(0,o.getComponent)("log-browser-add-custom")[this._isCustomLog?"show":"hide"](),(0,o.getComponent)("log-browser-files")[this._isCustomLog?"hide":"show"]()}realTimeUpdate(){if(this.realTimeInProgress)return;const e=this._onReloadCreate;this._onReloadCreate=function(){this.realTimeInProgress=!0};const t=this._onReloadComplete;this._onReloadComplete=function(){this.realTimeRequest=null,this.realTimeInProgress=!1,this._onReloadCreate=e,this._onReloadComplete=t};const s=`?showAfter=${encodeURIComponent(JSON.stringify(this._additionalData.updateAfter))}&short=true`;this.realTimeRequest=this.reload(s,"after")}enableRealTime(){this.realTimeInterval=setInterval(this.realTimeUpdate.bind(this),1e3),this.realTimeEnabled=!0}disableRealTime(){clearInterval(this.realTimeInterval),this.realTimeEnabled=!1,this.realTimeInProgress=!1,this.realTimeRequest&&this.realTimeRequest.abort()}makeLinks({message:e},t){try{decodeURIComponent(e)}catch{return(0,o.escapeHtml)(e)}const s=[],n=e.replace(/(^|.)(\/|[a-zA-Z]?:?\\)([^\?\s]+)\.([^\s?'/:\.\(\)="]+)($|.)/gm,((e,n,l,i,r,a)=>{const c=`${l+i}.${r}`,d=n.trim(),m=a.trim();if(""!==d&&!/^['\(\["]$/.test(d)||""!==m&&!/^['\(\)\[\]\?=:"]$/.test(m))return e;let h=decodeURIComponent(i);const p=decodeURIComponent(r),g=`${l+h}.${p}`,u=h.split(/[\\/]/),b=`${u.pop()}.${p}`;let _=`/${this._domainRootDir}`;const C=this._domainHomeDir;if(h=l+u.join("/"),g.indexOf(C)>-1){const t=g.replace(C,"");if(/^[\\/]$/.test(t.trim())||""===t.trim())return e;const s=t.split(/[\\/]/);s.pop(),_=s.join("/")}else _+=h;if(t)return c.trim();const w=`${this._urls.codeEditor}?currentDir=${encodeURIComponent(_)}&subscriptionId=${this._webspaceId}&file=${encodeURIComponent(b)}&redirect=${encodeURIComponent(this._urls.returnUrl)}`;return s.push(`<a href="${(0,o.escapeHtml)(w)}" title="${(0,o.escapeHtml)(this.lmsg("linkInMessageToViewFile"))}">${(0,o.escapeHtml)(c)}</a>`),`${n}%%linkUrl${s.length-1}%%${a}`}));return s.reduce(((e,t,s)=>e.replaceAll(`%%linkUrl${s}%%`,t)),(0,o.escapeHtml)(n))}getRowClass({type:e}){const t=["log-browser-row"];switch(e){case"error":t.push("state-error");break;case"warning":t.push("state-warning")}return t.join(" ")}_initConfiguration(e){super._initConfiguration({id:"log-browser",cls:"log-browser",locale:o.Locale.getSection("components.lists.logbrowser"),pageable:!1,getRowClass:this.getRowClass,onRedraw:this.onRedraw,...e}),this._logFile=this._getConfigParam("logFile",null),this._isCustomLog=this._getConfigParam("isCustomLog",!1),this._sources=this._getConfigParam("sources",{}),this._sourcesSelected=this._getConfigParam("sourcesSelected",[]),this._domainRootDir=this._getConfigParam("domainRootDir",""),this._domainHomeDir=this._getConfigParam("domainHomeDir",""),this._webspaceId=this._getConfigParam("webspaceId",""),this._urls=this._getConfigParam("urls",{}),this._serverDateTime=this._getConfigParam("serverDateTime",(new Date).toISOString()),this._defaultDataUrl=this._dataUrl,this._dataUrl=this.getDataUrl(),this._initColumns(),this._initOperations()}_isColumnVisible(e){return!!this._getConfigParam("isColumnAvailable",{})[e]}_initColumns(){this._columns.push({header:this.lmsg("date"),dataIndex:"date",filter:{type:"date",placeholder:this.lmsg("dateFilterPlaceholder"),date:new Date(this._serverDateTime)},cls:"number state-default"}),this._columns.push({header:this.lmsg("type"),dataIndex:"type",filter:{type:"text",multi:!0,placeholder:this.lmsg("any"),options:[{type:"value",value:"access",label:"Access"},{type:"value",value:"warning",label:"Warning"},{type:"value",value:"error",label:"Error"}]},cls:"number",renderer:({type:e})=>e?e[0].toUpperCase()+e.substr(1):"",isVisible:this._isColumnVisible.bind(this,"type")}),this._columns.push({header:this.lmsg("ip"),dataIndex:"ip",filter:{type:"text",live:!0,placeholder:this.lmsg("ipFilterPlaceholder")},cls:"number",isVisible:this._isColumnVisible.bind(this,"ip")}),this._columns.push({header:this.lmsg("code"),dataIndex:"code",filter:{type:"text",live:!0,startsWith:!0,placeholder:this.lmsg("codeFilterPlaceholder")},cls:"number",isVisible:this._isColumnVisible.bind(this,"code")}),this._columns.push({header:this.lmsg("message"),dataIndex:"message",filter:{type:"text",live:!0,placeholder:this.lmsg("messageFilterPlaceholder")},renderer:e=>{const t=this.makeLinks(e),s=t.split("\n");if(s.length<=10)return t.replace(/\n/g,"<br/>");const o=s.slice(0,10),n=s.slice(10),l=`<a class="toggler js-more-link" href="#"><span>${this.lmsg("more")}>></span></a>`,i=`<a class="toggler js-more-link" href="#" style="display: none;"><span><<${this.lmsg("less")}</span></a>`;return`${o.join("<br/>")}<div class="js-more" style="display: none;">${n.join("<br/>")}</div><div>${l}${i}</div>`}}),this._columns.push({header:`${this.lmsg("referer")}<span class="tooltipData">${this.lmsg("refererHint")}</span>`,dataIndex:"referer",cls:"min",renderer:({referer:e})=>{if("-"===e||""===e)return"";const t=(0,o.escapeHtml)(e);return`<span><span class="tooltipData">${t}</span><img src="${this._urls.iconReferer}" alt="${t.replace(/"/g,""")}" title="" /></span>`},isVisible:this._isColumnVisible.bind(this,"referer")}),this._columns.push({header:`${this.lmsg("agent")}<span class="tooltipData">${this.lmsg("agentHint")}</span>`,dataIndex:"agent",cls:"min",renderer:({agent:e})=>{let t,s=(0,o.escapeHtml)(e);if(""===e)return"";"-"===e?(t=this._urls.iconUnknown,s=this.lmsg("unknown")):t=e.match(/bot/i)?this._urls.iconRobot:this._urls.iconClient;return`<span><span class="tooltipData">${s}</span><img src="${t}" alt="${s.replace(/"/g,""")}" title="" /></span>`},isVisible:this._isColumnVisible.bind(this,"agent")}),this._columns.push({header:this.lmsg("size"),dataIndex:"size",cls:"state-default nowrap",isVisible:this._isColumnVisible.bind(this,"size")}),this._columns.push({header:this.lmsg("source"),dataIndex:"source",renderer:({source:e})=>this._sources[e],cls:"min nowrap state-default",isVisible:()=>this._sourcesSelected.length>1})}_initOperations(){this._operations=[{id:"log-browser-start-realtime",componentType:o.SmallButton,title:this.lmsg("buttonStartRealtime"),description:this.lmsg("buttonStartRealtimeHint"),addCls:"sb-start",handler:()=>{this._componentElement.querySelectorAll("tr.list-divider").forEach((e=>{e.classList.remove("list-divider")}));const e=document.getElementById("log-browser").querySelectorAll("tr.odd,tr.even");e.length>0&&e[e.length-1].classList.add("list-divider"),this.scrollToBottom(),this.toggleControls(!0),this.enableRealTime()}},{id:"log-browser-stop-realtime",componentType:o.SmallButton,title:this.lmsg("buttonStopRealtime"),description:this.lmsg("buttonStopRealtimeHint"),addCls:"sb-stop",hidden:!0,handler:()=>{this.toggleControls(!1),this.disableRealTime()}},{id:"log-browser-refresh",componentType:o.SmallButton,title:this.lmsg("buttonRefresh"),description:this.lmsg("buttonRefreshHint"),addCls:"sb-refresh",handler:()=>{this.reload()}},{id:"log-browser-clear",componentType:o.SmallButton,title:this.lmsg("buttonClear"),description:this.lmsg("buttonClearHint"),addCls:"sb-clean",hidden:!0,handler:()=>{this._additionalData.showMoreBefore=null,this._data=[],this.redraw()}},{componentType:o.bar.Separator},{id:"log-browser-manage-log-files",componentType:o.SmallButton,title:this.lmsg("manageLogFiles"),addCls:"sb-settings",href:this._urls.manageLogs},{id:"log-browser-log-rotation",componentType:o.SmallButton,title:this.lmsg("logRotation"),description:this.lmsg("logRotationHint"),addCls:"sb-log-rotation",hidden:!this._urls.logRotation,handler:()=>{new o.AjaxPopupForm({cls:"popup-panel",title:this.lmsg("logRotationTitle"),url:`${this._urls.logRotation}?redirectUrl=${encodeURIComponent(this._urls.returnUrl)}`,locale:{waitMsg:this.lmsg("loadingTitle")}})}},{componentType:o.bar.Separator},{id:"log-browser-add-custom",componentType:o.SmallButton,title:this.lmsg("buttonAddCustom"),description:this.lmsg("buttonAddCustomHint"),addCls:"sb-add-new",hidden:!this._isCustomLog,handler:()=>{this._isCustomLog=!1,o.api.post(this._urls.addCustomLog,{file:this._logFile}).then((e=>{(0,o.clearStatusMessages)(),e.isUnsupportedLog&&(0,o.addStatusMessage)("warning",this.lmsg("invalidLogFormat"))})),(0,o.getComponent)("log-browser-add-custom").hide(),(0,o.getComponent)("log-browser-files").show()}},new i.default({logBrowser:this,hidden:this._isCustomLog,webspaceId:this._webspaceId,urls:this._urls,locale:this.getLocale(),id:"log-browser-files"})].filter(Boolean)}onRedraw(){this.toggleControls();const e=document.getElementById(this._tableId);if(!e)return;if(e.querySelectorAll(".alert-container").forEach((e=>{e.parentNode.removeChild(e)})),!this._additionalData.showMoreBefore)return;const t=`<tr class="alert-container"><td colspan="${this._columns.length}"><div class="alert-wrapper"><div class="alert">${this.lmsg("loadMoreOrUseFilters",{loadMore:`<a href="#" class="log-browser-load-more" data-action-name="logBrowserLoadMore">${this.lmsg("loadMore")}</a>`})}</div></div></td></tr>`;(0,o.render)(e.querySelector("thead"),t,"after"),e.querySelector(".log-browser-load-more").addEventListener("click",(e=>{e.preventDefault(),e.target.closest(".alert-wrapper").innerHTML=`<div class="ajax-loading">${this.lmsg("loadingTitle")}</div>`;const t=`?showBefore=${encodeURIComponent(JSON.stringify(this._additionalData.showMoreBefore))}&short=true`;this.reload(t,"before")}))}_addEvents(){super._addEvents(),this._componentElement.addEventListener("click",(e=>{const t=e.target.closest("a.js-more-link");t&&(e.preventDefault(),[t.closest("td").querySelector(".js-more"),...t.closest("div").querySelectorAll("a")].forEach((e=>{e.style.display="none"===e.style.display?"":"none"})))}))}remove(){this.disableRealTime(),super.remove()}}const c={LogBrowser:a,createLogsProblemPanel:e=>(0,r.jsx)(n.LocaleProvider,{messages:o.Locale.getSection("components.lists.logbrowser").messages,children:(0,r.jsx)(l.LogsProblemPanel,{...e})})}},3028:(e,t,s)=>{s.r(t),s.d(t,{default:()=>l});var o=s(89),n=s(547);class l extends o.Component{_initConfiguration(e){super._initConfiguration({cls:"log-browser-options",...e}),this._logBrowser=this._getConfigParam("logBrowser"),this._urls=this._getConfigParam("urls",{}),this._webspaceId=this._getConfigParam("webspaceId")}isOpened(){return this._componentElement.querySelector(".dropdown").classList.contains("open")}setOpened(e){this._componentElement.querySelector(".dropdown").classList[e?"add":"remove"]("open")}getSelected(){return[...this._componentElement.querySelector(".dropdown-menu").querySelectorAll('input[type="checkbox"]:checked')].map((({value:e})=>e))}getTextValue(){const e=this._logBrowser._sourcesSelected;return!Object.keys(this._logBrowser._sources).length||e&&!e.length?this.lmsg("sourceFilterNoLogs"):e&&1===e.length?this._logBrowser._sources[e[0]]:e&&e.length!==Object.keys(this._logBrowser._sources).length?this.lmsg("sourceFilterFiles",{count:e.length}):this.lmsg("sourceFilterAllLogs")}updateTextValue(){this._componentElement.querySelector("input[type=text]").value=this.getTextValue()}addCustomLog(e){o.api.post(this._urls.addCustomLog,{file:e}).then((t=>{this._logBrowser._sources[e]=e.split("/").pop(),this._logBrowser._sourcesSelected.push(e),this._initComponentElement(),this._logBrowser.onSourceSearchFilterChange(),t.isUnsupportedLog&&(0,o.addStatusMessage)("warning",this.lmsg("invalidLogFormat"))}))}unlinkCustomLog(e){o.api.post(this._urls.unlinkCustomLog,{file:e}).then((()=>{delete this._logBrowser._sources[e],this._initComponentElement(),this._logBrowser.onSourceSearchFilterChange()}))}_initComponentElement(){super._initComponentElement();const e=this._logBrowser._sourcesSelected,t=document.createElement("div");t.className="dropdown",t.innerHTML=`<div class="input-group"><input type="text" readonly class="form-control" value="${this.getTextValue()}"><span class="input-group-btn"><button class="btn dropdown-toggle" type="button" data-action-name="logBrowserFilesOpen"><span class="caret"></span></button></span></div>`;const s=document.createElement("ul");s.className="dropdown-menu dropdown-menu-flip",s.addEventListener("click",(e=>{e.stopPropagation()})),(0,o.render)(t,s);const l={},i={};Object.keys(this._logBrowser._sources).forEach((e=>{e.startsWith("/")?i[e]=this._logBrowser._sources[e]:l[e]=this._logBrowser._sources[e]}));const r=(...e)=>{(0,o.render)(s,(0,o.createElement)("li",...e))},a=(t,s)=>{const n=Object.keys(t).map((n=>{let l=(0,o.createElement)("label",[(0,o.createElement)("input",{type:"checkbox",checked:e&&-1===e.indexOf(n)?null:"checked",value:(0,o.escapeHtml)(n),onclick:e=>{e.stopPropagation(),this._logBrowser.onSourceSearchFilterChange()},"data-input-name":"logBrowserFileCheckbox"}),s?(0,o.createElement)("span.tooltipData",(0,o.escapeHtml)(n)):"",(0,o.escapeHtml)(t[n])]);return n.startsWith("/")&&(l=(0,o.createElement)(".b-indent.b-indent-flip",[(0,o.createElement)("span.b-indent-icon",[(0,o.createElement)("a",{onclick:e=>{e.preventDefault(),this.setOpened(!1),o.messageBox.show({subtype:"unlink",text:this.lmsg("buttonUnlinkConfirmationDescription"),type:o.messageBox.TYPE_YESNO,buttonTitles:{yes:this.lmsg("buttonUnlinkConfirmationYes"),no:this.lmsg("buttonUnlinkConfirmationNo")},onYesClick:()=>{this.unlinkCustomLog(n)}})}},[(0,o.createElement)("span.tooltipData",this.lmsg("buttonUnlinkHint")),(0,o.createElement)("i.icon-unlink")])]),l])),l}));return(0,o.createElement)(".dropdown-menu-content.checkbox-group",n)};Object.keys(l).length&&(r(a(l)),r({class:"divider"})),Object.keys(i).length&&(r(a(i,!0)),r({class:"divider"})),r((0,o.createElement)("a.s-btn.sb-add-new",{onclick:e=>{e.preventDefault(),this.setOpened(!1),new o.DirectoryBrowser({subscriptionId:this._webspaceId,showFiles:!0,treeConfig:{filterNodes:e=>e.isDirectory||n.FTYPE_TEXT===e.type||n.FTYPE_UNKNOWN_TEXT===e.type},locale:{title:this.lmsg("customLogPopupTitle"),buttonOk:o.Locale.getSection("components.buttons").lmsg("ok"),buttonCancel:o.Locale.getSection("components.buttons").lmsg("cancel")},onSubmit:e=>{this.addCustomLog(`/${e}`)}})}},(0,o.createElement)("span",this.lmsg("addCustomLogFile")))),(0,o.render)(this._componentElement,t,"inner")}}}}]); //# sourceMappingURL=browser.js.map?753a16201a8af131aaf8