-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
6 lines (6 loc) · 5.47 KB
/
index.js
1
2
3
4
5
6
(function(){"use strict";function d(a,e,t,n,o,i,c,_){var r=typeof a=="function"?a.options:a;e&&(r.render=e,r.staticRenderFns=t,r._compiled=!0),n&&(r.functional=!0),i&&(r._scopeId="data-v-"+i);var s;if(c?(s=function(l){l=l||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!l&&typeof __VUE_SSR_CONTEXT__<"u"&&(l=__VUE_SSR_CONTEXT__),o&&o.call(this,l),l&&l._registeredComponents&&l._registeredComponents.add(c)},r._ssrRegister=s):o&&(s=_?function(){o.call(this,(r.functional?this.parent:this).$root.$options.shadowRoot)}:o),s)if(r.functional){r._injectStyles=s;var k=r.render;r.render=function(C,u){return s.call(u),k(C,u)}}else{var h=r.beforeCreate;r.beforeCreate=h?[].concat(h,s):[s]}return{exports:a,options:r}}const v={props:{channels:[],levels:[]},data(){return{logs:[],term:null,level:null,channel:null,page:1,limit:50,total:0}},computed:{channelOptions(){return this.channels.map(a=>({value:a,text:a}))},levelOptions(){return this.levels.map(a=>({value:a,text:a}))}},created(){this.fetchLogs()},methods:{onSearch(a){if(a.length>2){this.term=a,this.fetchLogs();return}this.term=null,this.fetchLogs()},async fetchLogs(a=null){this.page=(a==null?void 0:a.page)||this.page,this.limit=(a==null?void 0:a.limit)||this.limit;const e=await window.panel.api.post("logs.json",{page:this.page,limit:this.limit,level:this.level,channel:this.channel,term:this.term});this.logs=e.logs,this.total=e.total},resetFilters(){this.page=1,this.level=[],this.channel=[],this.term=null,this.fetchLogs()},onLevelChange(a){this.level=a,this.fetchLogs()},onChannelChange(a){this.channel=a,this.fetchLogs()},onPreview(a){window.panel.drawer.open({component:"k-logger-drawer",props:{icon:"preview",title:`[${a.level}] ${this.$library.dayjs(a.datetime).format("DD.MM.YYYY HH:mm:ss")}: ${a.channel}`,text:a,options:[{icon:"cancel",title:"Schließen",click:()=>window.panel.drawer.close()}]}})},getLevelBackground(a){switch(a){case"DEBUG":return{backgroundColor:"var(--color-gray-400"};case"INFO":return{backgroundColor:"var(--color-blue-400"};case"WARNING":return{backgroundColor:"var(--color-yellow-400"};case"ERROR":return{backgroundColor:"var(--color-red-400"};case"CRITICAL":return{backgroundColor:"var(--color-pink-400"};default:return{backgroundColor:"transparent"}}}}};var m=function(){var e=this,t=e._self._c;return t("k-panel-inside",{staticClass:"k-logger-area"},[t("k-header",{scopedSlots:e._u([{key:"buttons",fn:function(){return[t("k-button-group",[t("k-button",{attrs:{icon:"undo",variant:"filled"},on:{click:e.resetFilters}},[e._v("Zurücksetzten ")]),t("k-button",{attrs:{icon:"refresh",variant:"filled"},on:{click:e.fetchLogs}},[e._v("Neu laden ")])],1)]},proxy:!0}])},[e._v(" Logs ("+e._s(e.total)+") ")]),t("k-grid",{staticStyle:{gap:"1rem","--columns":"3","margin-bottom":"2rem"}},[t("k-text-field",{attrs:{name:"search",label:"Suche",icon:"search",placeholder:"Logs durchsuchen ...",value:e.term},on:{input:e.onSearch}}),t("k-multiselect-field",{attrs:{name:"levels",label:"Log Level",icon:"filter",options:e.levelOptions,value:e.level},on:{input:e.onLevelChange}}),t("k-multiselect-field",{attrs:{name:"channel",label:"Channel",icon:"filter",options:e.channelOptions,value:e.channel},on:{input:e.onChannelChange}})],1),t("div",{staticClass:"k-table"},[t("table",[t("thead",[t("tr",[t("th",{staticStyle:{width:"12rem"},attrs:{"data-mobile":"true"}},[e._v("Date")]),t("th",{staticStyle:{width:"8rem"},attrs:{"data-mobile":"true"}},[e._v("Level")]),t("th",{staticStyle:{width:"10rem"},attrs:{"data-mobile":"true"}},[e._v("Channel")]),t("th",[e._v("Message")]),t("th",[e._v("Context")]),t("th",{staticClass:"k-table-options-column",attrs:{"data-mobile":"true"}})])]),t("tbody",[e.logs.length>0?e._l(e.logs,function(n){return t("tr",{key:e.i},[t("td",{attrs:{"data-mobile":"true"}},[e._v(e._s(e.$library.dayjs(n.created_at).format("DD.MM.YYYY HH:mm:ss")))]),t("td",{attrs:{"data-mobile":"true"}},[t("k-bubble",{style:e.getLevelBackground(n.level),attrs:{text:n.level}})],1),t("td",{attrs:{"data-mobile":"true"}},[e._v(e._s(n.channel))]),t("td",[e._v(e._s(n.message))]),t("td",[t("div",{staticClass:"context"},[e._v(e._s(n.context))])]),t("td",{staticClass:"k-table-options-column",attrs:{"data-mobile":"true"}},[t("k-button",{attrs:{icon:"preview"},on:{click:function(o){return e.onPreview(n)}}})],1)])}):[t("tr",[t("td",{staticClass:"k-table-empty",attrs:{colspan:"10"}},[e._v("Keine Logs gefunden")])])]],2)]),t("k-pagination",{staticClass:"k-table-pagination",attrs:{details:!0,limit:e.limit,page:e.page,total:e.total},on:{paginate:e.fetchLogs}})],1)],1)},p=[],f=d(v,m,p,!1,null,"5bacaa39",null,null);const g=f.exports;window.panel.plugin("michnhokn/logger",{icons:{"file-search":'<path d="M15 4H5V20H19V8H15V4ZM3 2.9918C3 2.44405 3.44749 2 3.9985 2H16L20.9997 7L21 20.9925C21 21.5489 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM13.529 14.4464C11.9951 15.3524 9.98633 15.1464 8.66839 13.8284C7.1063 12.2663 7.1063 9.73367 8.66839 8.17157C10.2305 6.60948 12.7631 6.60948 14.3252 8.17157C15.6432 9.48951 15.8492 11.4983 14.9432 13.0322L17.1537 15.2426L15.7395 16.6569L13.529 14.4464ZM12.911 12.4142C13.6921 11.6332 13.6921 10.3668 12.911 9.58579C12.13 8.80474 10.8637 8.80474 10.0826 9.58579C9.30156 10.3668 9.30156 11.6332 10.0826 12.4142C10.8637 13.1953 12.13 13.1953 12.911 12.4142Z"></path>'},components:{"k-logger-area":g,"k-logger-drawer":{extends:"k-text-drawer",template:`<k-drawer
ref="drawer"
class="k-text-drawer"
v-bind="$props">
<k-code language="json">{{ text }}</k-code>
</k-drawer>`}}})})();