All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web-interface.assets.bb8c8232-6486.4b2f65aa0218cd364901.js Maven / Gradle / Ivy

There is a newer version: 6.1.4
Show newest version
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-6486"],{LQfvSgYI:(W,T,d)=>{d.d(T,{A:()=>D});var t=d("Z7aTuO5B"),u=d("Nm+SUS6U");const D=()=>{const y=(0,t.useContext)(u.A);if(!y)throw new Error("useExpandedSections hook needs to be used inside ExpandedSectionsProvider");return y}},"6gJIQhoE":(W,T,d)=>{d.d(T,{A:()=>u});const u=h=>{if(h)return h.entrySeq().flatMap(([D,y])=>y.map(F=>`${D}:${F}`)).toArray()}},f6qZmSzy:(W,T,d)=>{d.d(T,{A:()=>F});var t=d("ZaccISJq"),u=d("Z7aTuO5B"),h=d("VPaD/Np4"),D=d.n(h);const F=()=>{const[P,L]=(0,t.useQueryParam)("filters",t.ArrayParam),_=(0,u.useMemo)(()=>(P!=null?P:[]).reduce((U,B)=>{var x;const[O,S]=B.split(/=(.*)/);return U.set(O,[...(x=U.get(O))!=null?x:[],S])},(0,h.OrderedMap)()),[P]),I=(0,u.useCallback)(U=>{const B=U.entrySeq().reduce((x,[O,S])=>[...x,...S.map(R=>`${O}=${R}`)],[]);L(B)},[L]);return[_,I]}},gjuIj59j:(W,T,d)=>{d.d(T,{A:()=>je});var t=d("Z7aTuO5B"),u=d("J6y4/h8P"),h=d("VPaD/Np4"),D=d("HQjpSCKK"),y=d("cB7h3AEX"),F=d("IOI9nV80");const P=({type:e})=>e==="DATE",L=({filter_options:e})=>!!(e!=null&&e.length),_=({related_collection:e})=>!!e;var I=d("4E3oowBb");const B=({allActiveFilters:e,attribute:n,filterValueRenderer:o,onSubmit:r})=>t.createElement(t.Fragment,null,n.filter_options.sort(({title:l},{title:i})=>(0,I.j)(l.toLowerCase(),i.toLowerCase())).map(({title:l,value:i})=>{var s;const c=!!((s=e==null?void 0:e.get(n.id))!=null&&s.find(({value:a})=>i===a));return t.createElement(y.A,{onSelect:()=>r({value:i,title:l}),key:`filter-value-${l}`,disabled:c},o?o(i,l):l)}));var x=d("Mx+G+HdB"),O=d.n(x),S=d("rIl5IEuP");const N=e=>{const[n,o]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{function r({key:i}){i===e&&o(!0)}function l({key:i}){i===e&&o(!1)}return window.addEventListener("keydown",r),window.addEventListener("keyup",l),()=>{window.removeEventListener("keydown",r),window.removeEventListener("keyup",l)}},[o,e]),n};var M=d("DUKaTDO2"),$=d("jAGDuYSC"),ie=d("gyRmhZSW"),G=d("eFxcQyPT"),Y=d("MdYBRjRJ");const se={pagination:{total:0},suggestions:[]},ae=async(e,{query:n,page:o,pageSize:r})=>{const l={collection:e,column:"title"},i=(0,ie.A)("entity_suggestions",o,r,n,l);return(0,G.Ay)("GET",(0,Y.H3)(i))},ce=(e,n,o)=>{if(!n)throw Error(`Attribute meta data for attribute "${e}" is missing related collection.`);const{data:r,isInitialLoading:l}=(0,M.useQuery)(["filters","suggestions",o],()=>ae(n,o),{onError:i=>{$.A.error(`Loading suggestions for filter failed with status: ${i}`,"Could not load filter suggestions")},retry:0,keepPreviousData:!0});return{data:r!=null?r:se,isInitialLoading:l}};var de=d("dsvqAVKU");const k={query:"",pageSize:10,page:1},ue=u.default.div(({theme:e})=>(0,u.css)`
  color: ${e.colors.global.textDefault};
  padding: 3px 10px;
`),me=(0,u.default)(S.Input)`
  margin-bottom: 6px;
`,fe=u.default.div`
  margin-bottom: 0;
`,ge=u.default.div(({theme:e})=>(0,u.css)`
  margin-top: 9px;
  font-size: ${e.fonts.size.small};
`),Ee=({attribute:e,filterValueRenderer:n,onSubmit:o,allActiveFilters:r,filter:l})=>{const i=N("Shift"),[s,c]=(0,t.useState)(k),{data:{pagination:a,suggestions:m},isInitialLoading:E}=ce(e.id,e.related_collection,s),f=(0,t.useCallback)(g=>{c(p=>({...p,page:k.page,query:g}))},[c]),v=(0,t.useCallback)(g=>{c(p=>({...p,page:g}))},[]),C=O()(g=>f(g),1e3);return t.createElement(ue,null,t.createElement(me,{type:"text",id:"search-filters-input",formGroupClassName:"",placeholder:`Search for ${e.title.toLowerCase()}`,onChange:({target:{value:g}})=>C(g)}),E&&t.createElement(de.A,null),!!(m!=null&&m.length)&&t.createElement(F.OW,{showPageSizeSelect:!1,totalItems:a.total,hidePreviousAndNextPageLinks:!0,hideFirstAndLastPageLinks:!0,activePage:s.page,pageSize:s.pageSize,onChange:v,useQueryParameter:!1},t.createElement(fe,null,m.map(g=>{var p;const A=!!((p=r==null?void 0:r.get(e.id))!=null&&p.find(({value:z})=>z===g.id)),w=()=>{A||o({value:g.id,title:g.value},!i)};return t.createElement(S.ListGroupItem,{onClick:w,key:`filter-value-${g.id}`,disabled:A},n?n(g.id,g.value):g.value)}))),!(m!=null&&m.length)&&t.createElement(F.EO,null,"No entities found"),!l&&t.createElement(ge,null,t.createElement("i",null,"Hold Shift to select multiple")))};var b=d("UiXZqrDE"),ve=d("9oVghaOd"),pe=d.n(ve),K=d("O/XpfGnR"),he=d("Y15zKX1V"),H=d("IZYxBTgT");const Z="><",j=e=>e.split(Z),X=(e,n)=>`${e||"All time"} - ${n||"Now"}`,ye=u.default.div`
  padding: 3px 10px;
  max-width: 250px;
`,Fe=u.default.p(({theme:e})=>(0,u.css)`
  font-size: ${e.fonts.size.small};
  margin: 0 0 10px;
`),Ce=u.default.div`
  margin-bottom: 10px;
`,J=u.default.div`
  &:not(:last-child) {
    margin-bottom: 10px;
  }
`,Ae=u.default.div`
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
`,Se=u.default.label`
  margin: 0;
`,Te=(0,u.default)(S.Checkbox)`
  &.checkbox {
    margin: 0;
  }
`,Oe=u.default.code`
  padding: 0;
`,De=u.default.span(({theme:e})=>(0,u.css)`
  color: ${e.colors.variant.dark.danger};
  font-size: ${e.fonts.size.small};
  font-style: italic;
  padding: 3px 3px 9px;
  height: 1.5em;
`),V=({name:e,label:n,checkboxLabel:o})=>{const{formatTime:r}=(0,K.A)();return t.createElement(b.Field,{name:e},({field:{value:l,onChange:i,name:s},meta:{error:c}})=>{const a=E=>i({target:{name:s,value:E}}),m=()=>a(l?void 0:r(new Date,"complete"));return t.createElement("div",null,t.createElement(Ae,null,t.createElement(Se,{htmlFor:`date-input-${s}`},n),t.createElement(Te,{onChange:m,checked:!l},o)),t.createElement(he.A,{name:"from",value:l,disabled:l===void 0,onChange:a}),c&&t.createElement(De,null,c))})},Pe=e=>{const{formatTime:n}=(0,K.A)();if(e){const[o,r]=j(e.value);return{from:o?n(o,"complete"):void 0,until:r?n(r,"complete"):void 0}}return{from:n(pe()().subtract(5,"minutes"),"complete"),until:void 0}},q="Format must be: YYYY-MM-DD [HH:mm:ss[.SSS]].",xe='The "Until" date must come after the "From" date.',Le=e=>{let n={};return e.from&&!(0,H.vd)(e.from)&&(n={...n,from:q}),e.until&&!(0,H.vd)(e.until)&&(n={...n,until:q}),e.from>=e.until&&(n={...n,until:xe}),e.from===void 0&&e.until===void 0&&(n={...n,from:'Remove filter to search from "All time" until "Now".'}),n},_e=({filter:e,onSubmit:n})=>{const{userTimezone:o}=(0,K.A)(),r=Pe(e),l=i=>{const s=m=>(0,H.to)((0,H.Uv)(m,o),"internal"),c=i.from?s(i.from):"",a=i.until?s(i.until):"";n({title:X(i.from,i.until),value:`${c}${Z}${a}`})};return t.createElement(ye,{"data-testid":"time-range-form"},t.createElement(b.Formik,{initialValues:r,onSubmit:l,validate:Le},({isValid:i})=>t.createElement(b.Form,null,t.createElement(Ce,null,t.createElement(J,null,t.createElement(V,{name:"from",label:"From",checkboxLabel:"All time"})),t.createElement(J,null,t.createElement(V,{name:"until",label:"Until",checkboxLabel:"Now"}))),t.createElement(Fe,null,"Format: ",t.createElement(Oe,null,"YYYY-MM-DD [HH:mm:ss[.SSS]]"),".",t.createElement("br",null),"All timezones using: ",t.createElement("b",null,o),"."),t.createElement(F.E6,{submitButtonText:`${e?"Update":"Create"} filter`,bsSize:"small",disabledSubmit:!i,displayCancel:!1}))))},ee=({allActiveFilters:e,attribute:n,filter:o,filterValueRenderer:r,onSubmit:l})=>t.createElement(t.Fragment,null,t.createElement(y.A,{header:!0},o?"Edit":"Create"," ",n.title.toLowerCase()," filter"),L(n)&&t.createElement(B,{attribute:n,filterValueRenderer:r,onSubmit:l,allActiveFilters:e}),_(n)&&t.createElement(Ee,{attribute:n,filterValueRenderer:r,onSubmit:l,allActiveFilters:e,filter:o}),P(n)&&t.createElement(_e,{onSubmit:l,filter:o}));ee.defaultProps={filter:void 0};const te=ee,Ie=u.default.div`
  margin-left: 5px;
`,Ue=({attributes:e,setSelectedAttributeId:n,activeFilters:o})=>t.createElement(t.Fragment,null,t.createElement(y.A,{header:!0},"Create Filter"),e.map(({id:r,title:l,type:i})=>{var s;const c=!!((s=o==null?void 0:o.get(r))!=null&&s.length),a=i==="BOOLEAN"?c:!1;return t.createElement(y.A,{onSelect:()=>n(r),key:`${l}-filter`,disabled:a},l,i==="BOOLEAN"&&a&&t.createElement(F.Zf,{displayLeftMargin:!0},"You can only create one filter for a boolean attribute.",t.createElement("br",null),"If you want to change the filter value, you can update the existing one."))})),Be=({filterableAttributes:e,filterValueRenderers:n,onCreateFilter:o,activeFilters:r})=>{const[l,i]=(0,t.useState)(),s=e.find(({id:a})=>a===l),c=()=>i(void 0);return t.createElement(Ie,null,t.createElement(D.A,{title:t.createElement(F.In,{name:"add"}),bsSize:"small",buttonTitle:"Create Filter",onToggle:c,closeOnSelect:!1,dropdownZIndex:1e3},({toggleDropdown:a})=>{const m=(E,f=!0)=>{f&&a(),o(l,{value:E.value,title:E.title})};return l?t.createElement(te,{onSubmit:m,allActiveFilters:r,attribute:s,filterValueRenderer:n==null?void 0:n[l]}):t.createElement(Ue,{attributes:e,setSelectedAttributeId:i,activeFilters:r})}))};var we=d("F3uT4N0K");const Re=u.default.div`
  display: flex;
`,Q=(0,u.default)(S.Button)`
  display: flex;
  align-items: center;
`,Me=({attribute:e,allActiveFilters:n,onChangeFilter:o,filterValueRenderer:r,filter:l})=>{const[i,s]=(0,t.useState)(!1),{value:c,title:a}=l,m=()=>{s(f=>!f)},E=f=>{o(e.id,c,{value:f.value,title:f.title}),m()};return t.createElement(we.A,{show:i,closeOnSelect:!1,toggleChild:t.createElement(Q,{bsSize:"xsmall",title:"Change filter value"},r?r(c,a):a),placement:"bottom",onToggle:m},t.createElement(te,{attribute:e,filterValueRenderer:r,onSubmit:E,filter:l,allActiveFilters:n}))},We=({attribute:e,allActiveFilters:n,filter:o,filterValueRenderer:r,onDeleteFilter:l,onChangeFilter:i})=>{const{value:s,title:c}=o,a=()=>{if(e.type==="BOOLEAN"){const m=e.filter_options.find(({value:E})=>E!==s);i(e.id,s,{value:m.value,title:m.title})}};return t.createElement(Re,{className:"btn-group","data-testid":`${e.id}-filter-${s}`},e.type==="BOOLEAN"&&t.createElement(Q,{bsSize:"xsmall",onClick:a,title:"Change filter value"},r?r(s,c):c),e.type!=="BOOLEAN"&&t.createElement(Me,{onChangeFilter:i,attribute:e,filter:o,allActiveFilters:n,filterValueRenderer:r}),t.createElement(Q,{bsSize:"xsmall",onClick:()=>l(e.id,s),title:"Delete filter"},t.createElement(F.In,{name:"close"})))},ne=34,$e=u.default.div`
  display: inline-flex;
  align-items: center;
  min-height: ${ne}px;
  gap: 3px;
  flex-wrap: wrap;
`,Ke=u.default.div`
  margin-right: 3px;
`,He=({attributes:e=[],filters:n,filterValueRenderers:o,onDeleteFilter:r,onChangeFilter:l})=>t.createElement(t.Fragment,null,n.entrySeq().map(([i,s])=>{const c=e.find(({id:a})=>a===i);return t.createElement($e,{key:i},t.createElement(Ke,null,c.title,":"),s.map(a=>t.createElement(We,{filter:a,allActiveFilters:n,key:`${c.id}-${a.value}`,attribute:c,filterValueRenderer:o==null?void 0:o[i],onChangeFilter:l,onDeleteFilter:r})))})),Ne=e=>e==null?void 0:e.reduce((n,{id:o,related_collection:r})=>r?{...n,[o]:r}:n,{}),le=(e,n)=>e.entrySeq().reduce((o,[r,l])=>(n==null?void 0:n[r])?o.set(r,l):o,(0,h.OrderedMap)()),oe=(e,n)=>({entities:e.entrySeq().reduce((o,[r,l])=>{const i=n[r];return[...o,...l.map(s=>({id:s,type:i}))]},[])}),be=(e,n,o,r,l,i)=>{var s,c;if(P(e)){const[a,m]=j(o),E=a?r(a):void 0,f=m?r(m):void 0;return X(E,f)}if(L(e)){const a=e.filter_options.find(({value:m})=>m===o);return(s=a==null?void 0:a.title)!=null?s:o}if(_(e)){if(i||l!=null&&l.includes(o))return o;const a=(c=n==null?void 0:n.find(({id:m,type:E})=>E===e.related_collection&&m===o))==null?void 0:c.title;return a!=null?a:"Loading..."}return o},Qe=(e,n,o,r,l,i)=>e.entrySeq().reduce((s,[c,a])=>{const m=o==null?void 0:o.find(({id:f})=>f===c),E=a.map(f=>({title:be(m,n,f,r,l,i),value:f}));return s.set(c,E)},(0,h.OrderedMap)()),ze=(e,n)=>e.entrySeq().reduce((o,[r,l])=>{var i;const s=(i=n==null?void 0:n.find(({id:c})=>c===r))==null?void 0:i.related_collection;return s?[...o,...l.map(({value:c,title:a})=>({id:c,type:s,title:a}))]:o},[]),Ge=e=>(0,G.Ay)("POST",Y.Ay.qualifyUrl("/system/catalog/entities/titles"),e),Ye=(e,n,o=!0)=>{var r;const l=(0,M.useQueryClient)(),{formatTime:i}=(0,K.A)(),s=Ne(n),c=le(e,s),a=oe(c,s),{data:m,isInitialLoading:E,isError:f}=(0,M.useQuery)(["entity_titles",a],()=>Ge(a),{onError:A=>{$.A.error(`Loading filter titles failed with status: ${A}`,"Could not load streams")},keepPreviousData:!0,enabled:o&&!!a.entities.length}),v=l.getQueryData(["entity_titles",a]),C=(r=v!=null?v:m)==null?void 0:r.entities,g=Qe(e,C,n,i,m==null?void 0:m.not_permitted_to_view,f),p=(0,t.useCallback)((A,w)=>{const z=le(w,s),Xe=oe(z,s),Je=ze(A,n);l.setQueryData(["entity_titles",Xe],{entities:Je})},[n,s,l]);return{data:g,isInitialLoading:E,onChange:p}},ke=["STRING","BOOLEAN","DATE"],Ze=u.default.div`
  display: inline-flex;
  height: ${ne}px;
  align-items: center;
  margin-left: 5px;
  
  && {
    margin-right: 10px;
  }
`,re=({attributes:e=[],filterValueRenderers:n,urlQueryFilters:o,setUrlQueryFilters:r})=>{const{data:l,onChange:i}=Ye(o,e,!!e),s=e.filter(({filterable:f,type:v})=>f&&ke.includes(v)),c=(0,t.useCallback)(f=>{const v=f.entrySeq().reduce((C,[g,p])=>{var A;return C.set(g,[...(A=C.get(g))!=null?A:[],...p.map(({value:w})=>w)])},(0,h.OrderedMap)());i(f,v),r(v)},[i,r]),a=(0,t.useCallback)((f,v)=>{var C;c((0,h.OrderedMap)(l).set(f,[...(C=l==null?void 0:l.get(f))!=null?C:[],v]))},[l,c]),m=(0,t.useCallback)((f,v)=>{const g=l.get(f).filter(({value:p})=>p!==v);return g.length?c(l.set(f,g)):c(l.remove(f))},[l,c]),E=(0,t.useCallback)((f,v,C)=>{const g=l.get(f),p=g.findIndex(({value:w})=>w===v),A=[...g];A[p]=C,c(l.set(f,A))},[l,c]);return s.length?t.createElement(t.Fragment,null,t.createElement(Ze,null,"Filters",t.createElement(Be,{filterableAttributes:s,onCreateFilter:a,activeFilters:l,filterValueRenderers:n})),l&&t.createElement(He,{filters:l,attributes:e,onChangeFilter:E,onDeleteFilter:m,filterValueRenderers:n})):null};re.defaultProps={filterValueRenderers:void 0};const je=re},HQjpSCKK:(W,T,d)=>{d.d(T,{A:()=>F});var t=d("Z7aTuO5B"),u=d("+Ej1FZHV"),h=d("F3uT4N0K"),D=d("IOI9nV80");const y=({alwaysShowCaret:P,bsSize:L,buttonTitle:_,children:I,closeOnSelect:U,disabled:B,dropdownZIndex:x,onToggle:O,title:S})=>{const[R,N]=(0,t.useState)(!1),M=()=>{typeof O=="function"&&O(!R),N($=>!$)};return t.createElement(h.A,{show:R,closeOnSelect:U,dropdownZIndex:x,alwaysShowCaret:P,toggleChild:t.createElement("div",{className:`dropdown btn-group ${R?"open":""}`},t.createElement(u.A,{bsSize:L,className:"dropdown-toggle","aria-label":_,title:_,disabled:B},S," ",t.createElement(D.In,{name:"arrow_drop_down"}))),placement:"bottom",onToggle:M},typeof I=="function"?I({toggleDropdown:M}):I)};y.defaultProps={alwaysShowCaret:!1,bsSize:void 0,buttonTitle:void 0,closeOnSelect:!0,disabled:!1,dropdownZIndex:void 0,onToggle:void 0};const F=y}}]);})();

//# sourceMappingURL=bb8c8232-6486.4b2f65aa0218cd364901.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy