-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
1 lines (1 loc) · 6.33 KB
/
index.js
1
(()=>{(function(){"use strict";var u=function(){var t=this,s=t.$createElement,e=t._self._c||s;return e("k-inside",[e("k-view",{staticClass:"k-logbook-view"},[e("k-header",[t._v(" "+t._s(t.title)+" ")]),t.logfiles.length>0?e("section",{staticClass:"k-logbook-actions"},[e("k-grid",{attrs:{gutter:"medium"}},[e("k-column",{staticClass:"k-logbook-column-select",attrs:{width:"1/3"}},[e("k-select-field",{attrs:{options:t.logfilesOptions,label:"Logfile",name:"k-logbook__log-select",type:"select",icon:"angle-down"},on:{input:function(i){return t.fetch()}},model:{value:t.selectedLogfile,callback:function(i){t.selectedLogfile=i},expression:"selectedLogfile"}})],1),this.logLevels.length>1?e("k-column",{attrs:{width:"1/3"}},[e("k-select-field",{attrs:{options:t.logLevels,label:"Level",type:"select",icon:"angle-down"},on:{input:function(i){return t.filter()}},model:{value:t.filterLevel,callback:function(i){t.filterLevel=i},expression:"filterLevel"}})],1):t._e(),e("k-column",{attrs:{width:"1/3"}},[e("k-text-field",{attrs:{type:"text",label:"Search",placeholder:"Search",icon:"search"},on:{change:function(i){return t.filter()}},model:{value:t.filterText,callback:function(i){t.filterText=i},expression:"filterText"}})],1),t.logData.length==t.maxLogLines?e("k-column",[e("k-info-field",{attrs:{text:t.maxLogLinesReachedMessage}})],1):t._e()],1)],1):t._e(),this.total>0?e("section",{staticClass:"k-system-view-section"},[e("div",{staticClass:"k-system-info-box k-logbook-pane"},[t.isKirbyLogPluginLog?[e("table",[e("thead",[e("tr",[e("th",{staticClass:"column-timestamp"},[t._v("Timestamp")]),e("th",{staticClass:"column-level"},[t._v("Level")]),e("th",[t._v("Entry")])])]),t._l(t.pagedLogLines,function(i){return e("tbody",{key:i},[e("tr",[e("td",{staticClass:"column-timestamp"},[e("pre",[t._v(t._s(i.timestamp))])]),e("td",{staticClass:"column-level"},[e("pre",[t._v(t._s(i.type))])]),i.extra!=""?[e("td",{staticClass:"column-entry column-entry__with-extras"},[e("span",{staticClass:"extras-trigger",on:{click:function(n){return t.showExtras(n)}}},[e("k-icon",{attrs:{type:"add"}})],1),e("pre",[t._v(t._s(i.content))])])]:[e("td",{staticClass:"column-entry"},[e("pre",[t._v(t._s(i.content))])])]],2),i.extra!=""?[e("tr",{staticClass:"line-with-extras--hidden"},[e("td",{attrs:{colspan:"3"}},[e("ol",{staticClass:"line__extras"},t._l(i.extra,function(n,r){return e("li",{key:r},[t._v(t._s(n))])}),0)])])]:t._e()],2)})],2)]:[e("ol",t._l(t.pagedLogLines,function(i,n){return e("li",{key:n},[e("pre",[t._v(t._s(i))])])}),0)]],2),e("div",{staticClass:"k-logbook-pane-caption"},[e("k-grid",{attrs:{gutter:"medium"}},[e("k-column",{staticClass:"k-logbook-column-pagination-summary",attrs:{width:"2/3"}},[t._v(" Showing "+t._s(t.pageStart+1)+" to "+t._s(t.pageEnd)+" from "+t._s(t.total)+" log entries ")]),e("k-column",{staticClass:"k-logbook-column-pagination",attrs:{width:"1/3"}},[e("k-pagination",{attrs:{details:!1,page:t.page,limit:t.limit,total:t.total},on:{paginate:t.paginate}})],1)],1)],1)]):t._e(),this.logData.length==0&&t.logfiles.length!=0?e("section",{staticClass:"k-system-view-section"},[e("div",{staticClass:"k-system-info-box"},[e("k-empty",{attrs:{icon:"book"}},[t._v("Logfile is empty")])],1)]):t._e(),this.logData.length>0&&this.total==0&&t.logfiles.length!=0?e("section",{staticClass:"k-system-view-section"},[e("div",{staticClass:"k-system-info-box"},[e("k-empty",{attrs:{icon:"book"}},[t._v("No matches found")])],1)]):t._e(),t.logfiles.length==0?e("section",{staticClass:"k-system-view-section"},[e("div",{staticClass:"k-system-info-box"},[e("k-empty",{attrs:{icon:"book"}},[t._v("No logfiles found")])],1)]):t._e()],1)],1)},p=[],C="";function d(t,s,e,i,n,r,g,L){var o=typeof t=="function"?t.options:t;s&&(o.render=s,o.staticRenderFns=e,o._compiled=!0),i&&(o.functional=!0),r&&(o._scopeId="data-v-"+r);var a;if(g?(a=function(l){l=l||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!l&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(l=__VUE_SSR_CONTEXT__),n&&n.call(this,l),l&&l._registeredComponents&&l._registeredComponents.add(g)},o._ssrRegister=a):n&&(a=L?function(){n.call(this,(o.functional?this.parent:this).$root.$options.shadowRoot)}:n),a)if(o.functional){o._injectStyles=a;var y=o.render;o.render=function(b,h){return a.call(h),y(b,h)}}else{var f=o.beforeCreate;o.beforeCreate=f?[].concat(f,a):[a]}return{exports:t,options:o}}const _={name:"LogBookArea",props:["title","logfiles","selectedLogfile","hasKirbyLogPlugin","maxLogLines","limit"],data(){return{page:1,logData:[],logLines:[],logLevels:[],filterLevel:"",filterText:""}},methods:{fetch:function(){fetch("/kirbylogbook/"+this.selectedLogfile).then(t=>t.json()).then(t=>{this.initializeComponent(t)})},initializeComponent:function(t){if(this.page=1,this.logLevels=[],this.filterLevel="",this.filterText="",Array.isArray(t)){this.logLines=this.logData=t;var s=this.logLines.map(i=>i.type),e=[...new Set(s)];this.logLevels=e.map(i=>({value:i,text:i}))}else this.logLines=this.logData=Object.entries(t).map(i=>i[1])},filter:function(){var t=this.logData;this.filterLevel!=""&&(t=t.filter(s=>s.type==this.filterLevel)),this.filterText!=""&&(this.isKirbyLogPluginLog?t=t.filter(s=>s.content.includes(this.filterText)):t=t.filter(s=>s.includes(this.filterText))),this.logLines=t},paginate:function({page:t,limit:s}){this.page=t,this.limit=s},showExtras:function(t){let s=t.target.closest("tr");s.closest("table").rows[s.rowIndex+1].classList.toggle("line-with-extras--hidden")}},computed:{logfilesOptions:function(){return this.logfiles.map(t=>({value:t,text:t}))},isKirbyLogPluginLog:function(){if(this.logData.length==0)return!1;var t=["timestamp","type","content","extra"];return this.hasKirbyLogPlugin&&JSON.stringify(Object.keys(this.logData[0]))==JSON.stringify(t)},pagedLogLines:function(){return this.logLines.slice(this.pageStart,this.pageEnd)},total:function(){return this.logLines.length},pageStart:function(){return(this.page-1)*this.limit},pageEnd:function(){var t=(this.page-1)*this.limit+this.limit;return t>=this.total?this.total:t},maxLogLinesReachedMessage:function(){return"\u26A0\uFE0F Only last "+this.maxLogLines+" log lines fetched.<br>Increase threshold to fetch more, or tail log on the server."}},created(){this.fetch()}},c={};var m=d(_,u,p,!1,v,null,null,null);function v(t){for(let s in c)this[s]=c[s]}var k=function(){return m.exports}();window.panel.plugin("bvdputte/logbook",{components:{"k-logbook-area":k}})})();})();