UNPKG

harperdb

Version:

HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.

1 lines 10.1 kB
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[18],{4016:(e,l,s)=>{s.r(l),s.d(l,{default:()=>I});var a=s(9950),t=s(7176),r=s(6114),n=s(1646),o=s(5488),i=s(3452),c=s(6359),d=s(7348),m=s(6713),u=s(4084),x=s(8156),h=s(6685),g=s(1340),p=s(877),v=s(135),f=s(9435),j=s(625),b=s(5269),A=s(5553),N=s(5996),w=s(127);var y=s(7209),O=s(4414);const S=function(e){let{onRowClick:l,level:s,timestamp:a,message:n,tags:o,thread:i}=e;return(0,O.jsxs)(t.A,{xs:"12",md:"12",className:"item-row",onClick:l,children:[(0,O.jsx)(r.A,{xs:"2",md:"1",className:`text-nowrap ${null===s||void 0===s?void 0:s.toLowerCase()}`,children:(null===s||void 0===s?void 0:s.toUpperCase())||"UNKNOWN"}),(0,O.jsx)(r.A,{xs:"2",md:"2",lg:"1",children:new Date(a||null).toLocaleDateString()}),(0,O.jsx)(r.A,{xs:"2",md:"2",lg:"1",children:new Date(a||null).toLocaleTimeString()}),(0,O.jsx)(r.A,{xs:"2",md:"1",lg:"1",children:i}),(0,O.jsx)(r.A,{xs:"2",md:"2",lg:"1",children:null===o||void 0===o?void 0:o.join(", ")}),(0,O.jsx)(r.A,{xs:"2",md:"4",lg:"7",children:(0,y.A)(n)&&n.error?n.error:(0,O.jsx)("pre",{children:(0,O.jsx)("code",{children:n})})})]})};var k=s(3150),L=s(3628);let C;const F=async e=>{let{auth:l,url:s,logsFilter:a}=e;C=new AbortController,await(async e=>{let{auth:l,url:s,signal:a,logsFilter:t}=e;const r=await(0,w.A)({operation:{operation:"read_log",start:0,...t,order:"desc"},auth:l,url:s,signal:a});return b.A.update((e=>{e.logs=r.error?[]:(null===r||void 0===r?void 0:r.filter((e=>e.message)))||[],e.logsError=!1}))})({auth:l,url:s,signal:C.signal,logsFilter:a})};const T=function(e){var l,s,n,o,c;let{logsFilter:d}=e;const{compute_stack_id:w}=(0,j.g)(),y=(0,m.O$)(b.A,(e=>e.auth)),T=(0,m.O$)(b.A,(e=>e.url)),D=(0,m.O$)(b.A,(e=>e.logs),[w]),I=(0,m.O$)(b.A,(e=>e.logsError)),E=(0,m.O$)(A.A,(e=>e.theme)),[U,z]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!0),[$,_]=(0,a.useState)(!0),[M,V]=(0,a.useState)(!1),[W,q]=(0,a.useState)({}),G=()=>V(!M);return(0,a.useEffect)((()=>(y&&(R(!0),F({auth:y,url:T,logsFilter:d}),R(!1)),()=>{var e;null===(e=C)||void 0===e||e.abort()})),[y,$,d]),(0,v.A)((()=>y&&U&&_(Date.now())),N.A.refresh_content_interval),(0,O.jsxs)(f.tH,{onError:(e,l)=>(0,L.A)({error:{message:e.message,componentStack:l}}),FallbackComponent:k.A,children:[(0,O.jsxs)(t.A,{className:"floating-card-header",children:[(0,O.jsx)(r.A,{children:"logs"}),(0,O.jsxs)(r.A,{className:"text-end",children:[(0,O.jsx)(i.A,{color:"link",title:"Update Logs",className:"me-2",onClick:()=>_(Date.now()),children:(0,O.jsx)("i",{className:"fa "+(P?"fa-spinner fa-spin":"fa-sync-alt")})}),(0,O.jsxs)(i.A,{color:"link",title:"Turn on auto refresh",onClick:()=>z(!U),children:[(0,O.jsx)("span",{className:"me-2",children:"auto"}),(0,O.jsx)("i",{className:"fa fa-lg fa-toggle-"+(U?"on":"off")})]})]})]}),(0,O.jsx)(u.A,{className:"my-3",children:(0,O.jsxs)(x.A,{className:"item-list",children:[(0,O.jsxs)(t.A,{xs:"12",md:"12",className:"header",children:[(0,O.jsx)(r.A,{xs:"2",md:"1",className:"text-bold text-nowrap",children:"Status"}),(0,O.jsx)(r.A,{xs:"2",md:"2",lg:"1",className:"text-bold text-nowrap",children:"Date"}),(0,O.jsx)(r.A,{xs:"2",md:"2",lg:"1",className:"text-left text-bold text-nowrap",children:!P&&I?(0,O.jsxs)("span",{className:"text-danger",children:["log fetch error: ",(new Date).toLocaleTimeString().toLowerCase()]}):(0,O.jsx)("span",{children:"Time"})}),(0,O.jsx)(r.A,{xs:"2",md:"1",lg:"1",className:"text-bold text-nowrap",children:"Thread"}),(0,O.jsx)(r.A,{xs:"2",md:"2",lg:"1",className:"text-bold text-nowrap",children:"Tags"}),(0,O.jsx)(r.A,{xs:"2",md:"3",lg:"7",className:"text-bold text-nowrap",children:"Message"})]}),(0,O.jsx)("hr",{className:"mt-1 mb-0"}),(0,O.jsx)("div",{className:"item-scroller",children:!P||D||U?D&&D.length?D.map(((e,l)=>(0,O.jsx)(S,{level:e.level,timestamp:e.timestamp,message:e.message,tags:e.tags,thread:e.thread,onRowClick:()=>{q(e),G()}},e.timestamp+l))):D&&!D.length?(0,O.jsx)("div",{className:"pt-5 text-center",children:"no logs found"}):(0,O.jsx)("div",{className:"pt-5 text-center",children:"no logs found in this view"}):(0,O.jsx)("div",{className:"pt-5 text-center",children:(0,O.jsx)("i",{className:"fa fa-spinner fa-spin text-lightgrey"})})})]})}),(0,O.jsx)("br",{}),(0,O.jsxs)(h.A,{isOpen:M,className:E,centered:!0,fade:!1,id:"log-info-modal",children:[(0,O.jsx)(g.A,{toggle:G,children:"View Log Info"}),(0,O.jsx)(p.A,{children:W&&(0,O.jsxs)("div",{children:[(0,O.jsxs)("p",{children:[(0,O.jsx)("b",{children:"Level:"})," ",(0,O.jsx)("span",{className:`${null===W||void 0===W||null===(l=W.level)||void 0===l?void 0:l.toLowerCase()}`,children:null===W||void 0===W||null===(s=W.level)||void 0===s?void 0:s.toUpperCase()})]}),(0,O.jsx)("p",{className:"mb-1",children:(0,O.jsx)("b",{children:"Timestamp(UTC):"})}),(0,O.jsx)("span",{children:null===W||void 0===W?void 0:W.timestamp}),(0,O.jsxs)("p",{className:"mt-4",children:[(0,O.jsx)("b",{children:"Thread:"})," ",null===W||void 0===W?void 0:W.thread]}),(0,O.jsxs)("p",{children:[(0,O.jsx)("b",{children:"Tags:"})," ",null===W||void 0===W||null===(n=W.tags)||void 0===n?void 0:n.join(", ")]}),(0,O.jsx)("p",{className:"mb-2",children:(0,O.jsx)("b",{children:"Message:"})}),(0,O.jsx)("pre",{children:null!==W&&void 0!==W&&null!==(o=W.message)&&void 0!==o&&o.error?null===W||void 0===W||null===(c=W.message)||void 0===c?void 0:c.error:null===W||void 0===W?void 0:W.message})]})})]})]})},D={limit:1e3,level:void 0,from:void 0,until:void 0};const I=function(){const[e,l]=(0,a.useState)(D),s=(0,a.useRef)(),m=(0,a.useRef)(),u=(0,a.useRef)(),x=(0,d.MW)();return(0,O.jsxs)(t.A,{id:"logs",children:[(0,O.jsxs)(r.A,{lg:"2",xs:"12",children:[(0,O.jsx)("h2",{className:"mb-3 filters-header",children:"Log Filters"}),(0,O.jsx)("form",{onSubmit:e=>{var s,a;(e.preventDefault(),s=e.target.elements.logFromInput.value,a=e.target.elements.logUntilInput.value,!s&&!a||!s||!a||new Date(s)<=new Date(a))?l({limit:parseInt(e.target.elements.logLimitSelect.value,10)||1e3,level:e.target.elements.logLevelSelect.value||void 0,from:e.target.elements.logFromInput.value||void 0,until:e.target.elements.logUntilInput.value||void 0}):x.error("Please provide a valid date range.")},onReset:()=>{s.current.reset(),m.current.clearValue(),u.current.clearValue(),l(D)},ref:s,children:(0,O.jsxs)(t.A,{children:[(0,O.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,O.jsx)(c.Ay,{name:"logLimitSelect",isSearchable:!1,className:"react-select-container",classNamePrefix:"react-select",ref:m,placeholder:"Log Limit",options:[{value:1e3,label:"1000"},{value:500,label:"500"},{value:250,label:"250"},{value:100,label:"100"},{value:10,label:"10"}]})}),(0,O.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,O.jsx)(c.Ay,{name:"logLevelSelect",isSearchable:!1,className:"react-select-container",classNamePrefix:"react-select",ref:u,placeholder:"Log Level",defaultValue:null,options:[{value:null,label:"All"},{value:"notify",label:"Notify"},{value:"error",label:"Error"},{value:"warn",label:"Warn"},{value:"info",label:"Info"},{value:"debug",label:"Debug"},{value:"trace",label:"Trace"}]})}),(0,O.jsxs)(r.A,{xs:"8",lg:"12",className:"mb-3",children:[(0,O.jsx)(n.A,{htmlFor:"logFromInput",className:"input-label",children:"Start Date:"}),(0,O.jsx)(o.A,{name:"logFromInput",type:"datetime-local"})]}),(0,O.jsxs)(r.A,{xs:"8",lg:"12",className:"mb-3",children:[(0,O.jsx)(n.A,{htmlFor:"logUntilInput",className:"input-label",children:"End Date:"}),(0,O.jsx)(o.A,{name:"logUntilInput",type:"datetime-local"})]}),(0,O.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,O.jsx)(i.A,{type:"submit",className:"btn btn-purple px-4 w-100",children:"Apply"})}),(0,O.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,O.jsx)(i.A,{type:"reset",className:"btn btn-purple px-4 w-100",children:"Reset"})})]})})]}),(0,O.jsx)(r.A,{lg:"10",xs:"12",children:(0,O.jsx)(T,{logsFilter:e})})]})}},7209:(e,l,s)=>{s.d(l,{A:()=>a});const a=e=>"object"===typeof e&&!Array.isArray(e)&&null!==e},1646:(e,l,s)=>{s.d(l,{A:()=>j});var a=s(9950),t=s(1942),r=s.n(t),n=s(8738),o=s.n(n),i=s(1497),c=["className","cssModule","hidden","widths","tag","check","size","for"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var l=1;l<arguments.length;l++){var s=arguments[l];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},d.apply(this,arguments)}function m(e,l,s){return l in e?Object.defineProperty(e,l,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[l]=s,e}function u(e,l){if(null==e)return{};var s,a,t=function(e,l){if(null==e)return{};var s,a,t={},r=Object.keys(e);for(a=0;a<r.length;a++)s=r[a],l.indexOf(s)>=0||(t[s]=e[s]);return t}(e,l);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)s=r[a],l.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(t[s]=e[s])}return t}var x=["xs","sm","md","lg","xl","xxl"],h=r().oneOfType([r().number,r().string]),g=r().oneOfType([r().bool,r().string,r().number,r().shape({size:h,order:h,offset:h})]),p={children:r().node,hidden:r().bool,check:r().bool,size:r().string,for:r().string,tag:i.Wx,className:r().string,cssModule:r().object,xs:g,sm:g,md:g,lg:g,xl:g,xxl:g,widths:r().array},v=function(e,l,s){return!0===s||""===s?e?"col":"col-".concat(l):"auto"===s?e?"col-auto":"col-".concat(l,"-auto"):e?"col-".concat(s):"col-".concat(l,"-").concat(s)};function f(e){var l=e.className,s=e.cssModule,t=e.hidden,r=e.widths,n=void 0===r?x:r,h=e.tag,g=void 0===h?"label":h,p=e.check,f=e.size,j=e.for,b=u(e,c),A=[];n.forEach((function(l,a){var t=e[l];if(delete b[l],t||""===t){var r,n=!a;if((0,i.Gv)(t)){var c,d=n?"-":"-".concat(l,"-");r=v(n,l,t.size),A.push((0,i.qO)(o()((m(c={},r,t.size||""===t.size),m(c,"order".concat(d).concat(t.order),t.order||0===t.order),m(c,"offset".concat(d).concat(t.offset),t.offset||0===t.offset),c))),s)}else r=v(n,l,t),A.push(r)}}));var N=f||A.length,w=!(p||N),y=(0,i.qO)(o()(l,!!t&&"visually-hidden",!!p&&"form-check-label",!!f&&"col-form-label-".concat(f),A,!!N&&"col-form-label",!!w&&"form-label"),s);return a.createElement(g,d({htmlFor:j},b,{className:y}))}f.propTypes=p;const j=f}}]);