web-interface.assets.07ba022f-6717.aeb98ff1f77c52272654.js Maven / Gradle / Ivy
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["07ba022f-6717"],{SfPIQIJE:(J,b,n)=>{n.d(b,{Z:()=>m});var e=n("Z7aTuO5B"),s=n("J6y4/h8P"),l=n("uZqmR+ju"),B=n("ty2gyrHp"),K=n("/GOzvPf6"),C=n("NV1/EHMi");const R=(0,s.default)(l.ButtonToolbar)`
margin-bottom: 10px;
`,w=(0,s.default)(l.Button)(({theme:v})=>(0,s.css)`
font-family: ${v.fonts.family.navigation};
font-size: ${v.fonts.size.navigation};
&&&& {
color: ${v.colors.variant.darker.default};
&:hover,
&:focus {
text-decoration: none;
}
> div {
&:hover,
&:focus {
color: ${v.colors.variant.darker.default};
}
}
&:hover {
${(0,C.RF)(v)}
}
&.active {
color: ${v.colors.global.textDefault};
${(0,C.A7)(v)}
&:hover,
&:focus {
${(0,C.A7)(v)}
}
}
}
`);w.displayName="Button";const m=({items:v})=>e.createElement(R,null,v.map(({path:S,title:p,permissions:x,exactPathMatch:D})=>S?e.createElement(K.AE,{permissions:x!=null?x:[],key:S},e.createElement(B.J,{to:S,relativeActive:!D},e.createElement(w,{bsStyle:"link"},e.createElement(C.ZP,null,p)))):null))},IFFKjdia:(J,b,n)=>{n.d(b,{$Z:()=>B,JG:()=>s,Qk:()=>e,oT:()=>l});const e="system-notifications-v1",s="event_definitions",l={pageSize:20,sort:{attributeId:"title",direction:"asc"},displayedColumns:["title","description","priority","scheduling","status","matched_at"],columnsOrder:["title","description","priority","matched_at","status","scheduling"]},B=[{id:"scheduling",title:"Scheduling",sortable:!1},{id:"matched_at",title:"Last Matched",sortable:!0}]},jvpdvVQ7:(J,b,n)=>{n.d(b,{Z:()=>R});var e=n("Z7aTuO5B"),s=n("SfPIQIJE"),l=n("d4kzUuQm"),B=n("uZqmR+ju");const K=[{title:"Alerts & Events",path:l.ZP.ALERTS.LIST,exactPathMatch:!0},{title:"Event Definitions",path:l.ZP.ALERTS.DEFINITIONS.LIST},{title:"Notifications",path:l.ZP.ALERTS.NOTIFICATIONS.LIST}],R=()=>e.createElement(B.Row,null,e.createElement(s.Z,{items:K}))},leXY1Rul:(J,b,n)=>{n.d(b,{Z:()=>w});var e=n("DUKaTDO2"),s=n("eFxcQyPT"),l=n("MdYBRjRJ"),B=n("U1Iufsob"),K=n("jAGDuYSC");function C(){return(0,s.ZP)("GET",(0,l.DC)(B.Z.EntityScopeController.getScope().url))}const w=W=>{var m;const{data:v,isLoading:S,error:p}=(0,e.useQuery)(["scope-permissions"],C,{onError:()=>K.Z.error(p.message),retry:1,cacheTime:108e5,staleTime:108e5}),x=((m=W==null?void 0:W._scope)==null?void 0:m.toUpperCase())||"DEFAULT",D=S?{is_mutable:!1}:v.entity_scopes[x];return{loadingScopePermissions:S,scopePermissions:D}}},"3CnfofFa":(J,b,n)=>{n.r(b),n.d(b,{default:()=>Ne});var e=n("Z7aTuO5B"),s=n("uZqmR+ju"),l=n("/GOzvPf6"),B=n("rVdVsuGH"),K=n("+BJjAwAf"),C=n("ty2gyrHp"),R=n("d4kzUuQm"),w=n("Dg3D5NJi"),W=n("qO9czYNI"),m=n("MdYBRjRJ"),v=n("8OvTct/Z"),S=n("0t7Ye+61"),p=n("v4GbOr/o"),x=n("leXY1Rul"),D=n("cd5HAK44"),le=n("HqzDVmZB"),ie=n("HQjpSCKK"),q=n("HhRuy6uH"),z=n("jAGDuYSC");const f={COPY:"copy",DELETE:"delete",DISABLE:"disable",ENABLE:"enable"},ee={[f.COPY]:{dialogTitle:"Copy Event Definition",dialogBody:t=>`Are you sure you want to create a copy of "${t}"?`},[f.DELETE]:{dialogTitle:"Delete Event Definition",dialogBody:t=>`Are you sure you want to delete "${t}"?`},[f.DISABLE]:{dialogTitle:"Disable Event Definition",dialogBody:t=>`Are you sure you want to disable "${t}"?`},[f.ENABLE]:{dialogTitle:"Enable Event Definition",dialogBody:t=>`Are you sure you want to enable "${t}"?`}},se=({eventDefinition:t,refetchEventDefinitions:a})=>{const{scopePermissions:o}=(0,x.Z)(t),[d,r]=(0,e.useState)(null),[c,u]=(0,e.useState)(!1),[E,h]=(0,e.useState)(null),[L,P]=(0,e.useState)(!1),{pathname:T}=(0,S.Z)(),y=(0,v.Z)(),_=()=>o==null?void 0:o.is_mutable,g=()=>{var i;return((i=t==null?void 0:t.config)==null?void 0:i.type)==="system-notifications-v1"},Q=()=>{var i;return((i=t==null?void 0:t.config)==null?void 0:i.type)==="aggregation-v1"},M=({show:i,type:O,definition:H})=>{u(i),h(O),r(H)},F=(i,O)=>{switch(i){case f.COPY:y(p.A.EVENTDEFINITION_LIST.ROW_ACTION_COPY_CLICKED,{app_pathname:(0,m.av)(T),app_section:"event-definition-row",app_action_value:"copy-menuitem"}),M({show:!0,type:f.COPY,definition:O});break;case f.DELETE:y(p.A.EVENTDEFINITION_LIST.ROW_ACTION_DELETE_CLICKED,{app_pathname:(0,m.av)(T),app_section:"event-definition-row",app_action_value:"delete-menuitem"}),M({show:!0,type:f.DELETE,definition:O});break;case f.ENABLE:y(p.A.EVENTDEFINITION_LIST.ROW_ACTION_ENABLE_CLICKED,{app_pathname:(0,m.av)(T),app_section:"event-definition-row",app_action_value:"enable-menuitem"}),M({show:!0,type:f.ENABLE,definition:O});break;case f.DISABLE:y(p.A.EVENTDEFINITION_LIST.ROW_ACTION_DISABLE_CLICKED,{app_pathname:(0,m.av)(T),app_section:"event-definition-row",app_action_value:"disable-menuitem"}),M({show:!0,type:f.DISABLE,definition:O});break;default:break}},I=()=>{y(p.A.EVENTDEFINITION_LIST.ROW_ACTION_SHARE_CLICKED,{app_pathname:(0,m.av)(T),app_section:"event-definition-list",app_action_value:"share-button"}),P(!0)},N=()=>{M({show:!1,type:null,definition:null}),a()},$=()=>{switch(E){case"copy":D.y.copy(d).finally(()=>{N()});break;case"delete":D.y.delete(d).then(()=>{z.Z.success("Event Definition deleted successfully",`Event Definition "${t.title}" was deleted successfully.`)},i=>{var O,H,oe;const Oe=((oe=(H=(O=i==null?void 0:i.additional)==null?void 0:O.body)==null?void 0:H.errors)==null?void 0:oe.dependency.join(" "))||i;z.Z.error(`Deleting Event Definition "${t.title}" failed with status: ${Oe}`,"Could not delete Event Definition")}).finally(()=>{N()});break;case"enable":D.y.enable(d).finally(()=>{N()});break;case"disable":D.y.disable(d).finally(()=>{N()});break;default:break}},G=(t==null?void 0:t.state)==="ENABLED";return e.createElement(e.Fragment,null,e.createElement(s.ButtonToolbar,{key:`actions-${t.id}`},e.createElement(l.Tz,{entityId:t.id,entityType:"event_definition",onClick:I,bsSize:"xsmall"}),e.createElement(ie.Z,{title:q.zN,buttonTitle:q.V,bsSize:"xsmall",dropdownZIndex:1e3},_()&&e.createElement(l.AE,{permissions:`eventdefinitions:edit:${t.id}`},e.createElement(C.J,{to:R.ZP.ALERTS.DEFINITIONS.edit(t.id)},e.createElement(s.MenuItem,{"data-testid":"edit-button"},"Edit"))),!g()&&e.createElement(s.MenuItem,{onClick:()=>F(f.COPY,t)},"Duplicate"),e.createElement(s.MenuItem,{divider:!0}),e.createElement(s.MenuItem,{disabled:g(),title:g()?"System Event Definition cannot be disabled":void 0,onClick:g()?void 0:()=>F(G?f.DISABLE:f.ENABLE,t)},G?"Disable":"Enable"),_()&&e.createElement(l.AE,{permissions:`eventdefinitions:delete:${t.id}`},e.createElement(s.MenuItem,{divider:!0}),e.createElement(s.MenuItem,{disabled:g(),title:g()?"System Event Definition cannot be deleted":void 0,onClick:g()?void 0:()=>F(f.DELETE,t),"data-testid":"delete-button"},"Delete")),Q()&&e.createElement(e.Fragment,null,e.createElement(s.MenuItem,{divider:!0}),e.createElement(C.J,{to:R.ZP.ALERTS.DEFINITIONS.replay_search(t.id)},e.createElement(s.MenuItem,null,"Replay search"))))),c&&e.createElement(l.QH,{title:ee[E].dialogTitle,show:!0,onConfirm:$,onCancel:N},ee[E].dialogBody(d.title)),L&&e.createElement(le.Z,{entityId:t.id,entityType:"event_definition",entityTypeTitle:"event definition",entityTitle:t.title,description:"Search for a User or Team to add as collaborator on this event definition.",onClose:()=>P(!1)}))};var re=n("9oVghaOd"),te=n.n(re),Z=n("J6y4/h8P");const ce=(0,Z.default)(s.Popover)`
max-width: 500px;
`,k=Z.default.dt`
float: left;
clear: left;
`,V=Z.default.dd(({theme:t})=>(0,Z.css)`
margin-left: 180px;
word-wrap: break-word;
&:not(:last-child) {
border-bottom: 1px solid ${t.colors.variant.lightest.default};
margin-bottom: 5px;
padding-bottom: 5px;
}
`),de=(0,Z.default)(s.Button)`
padding: 6px 8px;
`,ue=t=>{var a,o;const d=(a=t==null?void 0:t.data)==null?void 0:a.timerange_from,r=(o=t==null?void 0:t.data)==null?void 0:o.timerange_to;return e.createElement(e.Fragment,null,e.createElement(k,null,"Next time range:"),e.createElement(V,null,e.createElement(l.EK,{dateTime:d})," ",e.createElement(l.JO,{name:"arrow-circle-right"})," ",e.createElement(l.EK,{dateTime:r})))},Ee=(t,a,o)=>e.createElement(ce,{id:"event-definition-details",title:`${t} details.`},e.createElement("dl",null,e.createElement(k,null,"Status:"),e.createElement(V,null,a.status),a.triggered_at&&e.createElement(e.Fragment,null,e.createElement(k,null,"Last execution:"),e.createElement(V,null,e.createElement(l.EK,{dateTime:a.triggered_at}))),a.next_time&&e.createElement(e.Fragment,null,e.createElement(k,null,"Next execution:"),e.createElement(V,null,e.createElement(l.EK,{dateTime:a.next_time}))),ue(a),e.createElement(k,null,"Queued notifications:"),e.createElement(V,null,a.queued_notifications,a.queued_notifications>0&&e.createElement(s.Button,{bsStyle:"link",bsSize:"xsmall",onClick:()=>o()},"clear")))),me=({executeEveryMs:t,searchWithinMs:a,scheduler:o,title:d,clearNotifications:r})=>{const c=te().duration(t).format("d [days] h [hours] m [minutes] s [seconds]",{trim:"all",usePlural:!1}),u=te().duration(a).format("d [days] h [hours] m [minutes] s [seconds]",{trim:"all"});return e.createElement(e.Fragment,null,`Runs every ${c}, searching within the last ${u}. `,e.createElement(l.Ox,{trigger:"click",rootClose:!0,placement:"left",overlay:Ee(d,o,r)},e.createElement(de,{bsStyle:"link"},e.createElement(l.JO,{name:"circle-info"}))))},ve=({definition:t})=>{var a,o;if(!((a=t==null?void 0:t.config)!=null&&a.search_within_ms)&&!((o=t==null?void 0:t.config)!=null&&o.execute_every_ms))return e.createElement(e.Fragment,null,"Not Scheduled.");const d=h=>()=>{window.confirm(`Are you sure you want to clear queued notifications for "${h.title}"?`)&&D.y.clearNotificationQueue(h)},{title:r,config:{search_within_ms:c,execute_every_ms:u},scheduler:E}=t;return e.createElement(me,{executeEveryMs:u,searchWithinMs:c,title:r,scheduler:E,clearNotifications:d(t)})},pe=(0,Z.default)(s.Label)`
display: inline-flex;
justify-content: center;
gap: 4px;
`,fe=Z.default.div`
border-left: 1px solid currentColor;
height: 1em;
`,Te=(t,a,o)=>a?o:t?"Enable":"Disable",ye=({eventDefinition:t,refetchEventDefinitions:a})=>{var o;const[d,r]=(0,e.useState)(!1),c=(t==null?void 0:t.state)==="ENABLED",u=((o=t==null?void 0:t.config)==null?void 0:o.type)==="system-notifications-v1",E=c?"enabled":"disabled",h=Te(!c,u,E),L=(0,e.useCallback)(async()=>{c?r(!0):(await D.y.enable(t),await a())},[c,t,a]),P=(0,e.useCallback)(async()=>{await D.y.disable(t),await a(),r(!1)},[t,a]);return e.createElement(e.Fragment,null,e.createElement(pe,{bsStyle:c?"success":"warning",onClick:u?void 0:L,title:h,"aria-label":h,role:"button",$clickable:!u},E,!u&&e.createElement(e.Fragment,null,e.createElement(fe,null),e.createElement(l.JO,{name:c?"pause":"play"}))),d&&e.createElement(s.BootstrapModalConfirm,{showModal:!0,title:"Disable event definition",onConfirm:P,onCancel:()=>r(!1)},`Do you really want to disable event definition '${t.title}'?`))};var ne=n("DUKaTDO2"),j=n("U1Iufsob"),ge=n("eFxcQyPT"),ae=n("TJOheZRu"),Ie=n("Z2BtcgLJ");const A={DELETE:"delete",DISABLE:"disable",ENABLE:"enable"},Y=t=>ae.Z.pluralize(t,"event definition","event definitions"),X={[A.DELETE]:{dialogTitle:"Delete Event Definitions",dialogBody:t=>`Are you sure you want to delete ${t} ${Y(t)}?`,bulkActionUrl:j.Z.EventDefinitionsApiController.bulkDelete().url},[A.DISABLE]:{dialogTitle:"Disable Event Definitions",dialogBody:t=>`Are you sure you want to disable ${t} ${Y(t)}?`,bulkActionUrl:j.Z.EventDefinitionsApiController.bulkUnschedule().url},[A.ENABLE]:{dialogTitle:"Enable Event Definitions",dialogBody:t=>`Are you sure you want to enable ${t} ${Y(t)}?`,bulkActionUrl:j.Z.EventDefinitionsApiController.bulkSchedule().url}},De=({selectedDefinitionsIds:t,setSelectedEventDefinitionsIds:a})=>{var o,d;const r=(0,ne.useQueryClient)(),[c,u]=(0,e.useState)(!1),[E,h]=(0,e.useState)(null),L=t==null?void 0:t.length,{pathname:P}=(0,S.Z)(),T=(0,v.Z)(),y=(0,e.useCallback)(()=>r.invalidateQueries(["eventDefinition","overview"]),[r]),_=({show:I,type:N})=>{u(I),h(N)},g=I=>{switch(I){case A.DELETE:T(p.A.EVENTDEFINITION_LIST.BULK_ACTION_DELETE_CLICKED,{app_pathname:(0,m.av)(P),app_section:"event-definition-bulk",app_action_value:"delete-menuitem"}),_({show:!0,type:A.DELETE});break;case A.ENABLE:T(p.A.EVENTDEFINITION_LIST.BULK_ACTION_ENABLE_CLICKED,{app_pathname:(0,m.av)(P),app_section:"event-definition-bulk",app_action_value:"enable-menuitem"}),_({show:!0,type:A.ENABLE});break;case A.DISABLE:T(p.A.EVENTDEFINITION_LIST.BULK_ACTION_DISABLE_CLICKED,{app_pathname:(0,m.av)(P),app_section:"event-definition-bulk",app_action_value:"disable-menuitem"}),_({show:!0,type:A.DISABLE});break;default:break}},Q=()=>{_({show:!1,type:null}),y()},M=(0,e.useCallback)(()=>{(0,ge.ZP)("POST",(0,m.DC)(X[E].bulkActionUrl),{entity_ids:t}).then(({failures:I})=>{if(I!=null&&I.length){const N=I.map(({entity_id:$})=>$);a(N)}else a([]),z.Z.success(`${L} ${Y(L)} ${ae.Z.pluralize(L,"was","were")} ${E}d successfully.`,"Success")}).catch(I=>{z.Z.error(`An error occurred while ${E} event definition. ${I}`)}).finally(()=>{y()})},[E,y,t,L,a]),F=()=>{M(),u(!1)};return e.createElement(Ie.Z,{selectedEntities:t,setSelectedEntities:a},e.createElement(s.MenuItem,{onSelect:()=>g(A.ENABLE)},"Enable"),e.createElement(s.MenuItem,{onSelect:()=>g(A.DISABLE)},"Disable"),e.createElement(s.MenuItem,{onSelect:()=>g(A.DELETE)},"Delete"),c&&e.createElement(l.QH,{title:(o=X[E])==null?void 0:o.dialogTitle,show:!0,onConfirm:F,onCancel:Q},(d=X[E])==null?void 0:d.dialogBody(L)))},Ae=(t,{enabled:a}={enabled:!0})=>{const{data:o,refetch:d,isInitialLoading:r}=(0,ne.useQuery)(["eventDefinition","overview",t],()=>D.B.searchPaginated(t.page,t.pageSize,t.query,{sort:t==null?void 0:t.sort.attributeId,order:t==null?void 0:t.sort.direction}),{onError:c=>{z.Z.error(`Loading Event Definitions failed with status: ${c}`,"Could not load Event definition")},keepPreviousData:!0,enabled:a});return{data:o,refetch:d,isInitialLoading:r}};var U=n("IFFKjdia");const Ce=t=>({attributes:{title:{renderCell:(a,o)=>e.createElement(C.r,{to:R.ZP.ALERTS.DEFINITIONS.show(o.id)},a)},matched_at:{renderCell:(a,o)=>o.matched_at?e.createElement(l.ij,{dateTime:o.matched_at}):"Never"},scheduling:{renderCell:(a,o)=>e.createElement(ve,{definition:o})},status:{renderCell:(a,o)=>e.createElement(ye,{eventDefinition:o,refetchEventDefinitions:t}),staticWidth:100},priority:{staticWidth:100}}}),Se=()=>{const[t,a]=(0,e.useState)(""),{layoutConfig:o,isInitialLoading:d}=(0,w.Z)({entityTableId:U.JG,defaultPageSize:U.oT.pageSize,defaultDisplayedAttributes:U.oT.displayedColumns,defaultSort:U.oT.sort}),r=(0,B.ZP)(void 0,20),{mutate:c}=(0,W.Z)(U.JG),{data:u,refetch:E,isInitialLoading:h}=Ae({query:t,page:r.page,pageSize:o.pageSize,sort:o.sort}),L=Ce(E),P=(0,e.useMemo)(()=>{var i;return[...(i=u==null?void 0:u.attributes)!=null?i:[],...U.$Z]},[u==null?void 0:u.attributes]),{pathname:T}=(0,S.Z)(),y=(0,v.Z)(),_=(0,e.useCallback)(i=>{r.resetPage(),a(i)},[r]),g=(0,e.useCallback)(()=>{_("")},[_]),Q=(0,e.useCallback)(i=>{y(p.A.EVENTDEFINITION_LIST.COLUMNS_CHANGED,{app_pathname:(0,m.av)(T),app_section:"event-definition-list",app_action_value:"columns-select",columns:i}),c({displayedAttributes:i})},[T,y,c]),M=(0,e.useCallback)(i=>{y(p.A.EVENTDEFINITION_LIST.PAGE_SIZE_CHANGED,{app_pathname:(0,m.av)(T),app_section:"event-definition-list",app_action_value:"page-size-select",page_size:i}),r.setPagination({page:1,pageSize:i}),c({perPage:i})},[r,T,y,c]),F=(0,e.useCallback)(i=>{y(p.A.EVENTDEFINITION_LIST.SORT_CHANGED,{app_pathname:(0,m.av)(T),app_section:"event-definition-list",app_action_value:"sort-select",sort:i}),r.resetPage(),c({sort:i})},[r,T,y,c]),I=(0,e.useCallback)(i=>e.createElement(se,{eventDefinition:i,refetchEventDefinitions:E}),[E]),N=(i,O)=>e.createElement(De,{selectedDefinitionsIds:i,setSelectedEventDefinitionsIds:O});if(d||h)return e.createElement(l.$j,null);const{elements:$,pagination:{total:G}}=u;return e.createElement(l.l9,{pageSize:o.pageSize,showPageSizeSelect:!1,totalItems:G},e.createElement("div",{style:{marginBottom:5}},e.createElement(l.UI,{onSearch:_,onReset:g,queryHelpComponent:e.createElement(l.y8,{entityName:"event definition"})})),e.createElement("div",null,($==null?void 0:$.length)===0?e.createElement(l.pJ,null,"No Event Definition has been found"):e.createElement(l.$E,{data:$,visibleColumns:o.displayedAttributes,columnsOrder:U.oT.columnsOrder,onColumnsChange:Q,onSortChange:F,onPageSizeChange:M,pageSize:o.pageSize,bulkSelection:{actions:N},activeSort:o.sort,actionsCellWidth:160,rowActions:I,columnRenderers:L,columnDefinitions:P,entityAttributesAreCamelCase:!1})))};var he=n("E+CaPsQD"),Le=n("jvpdvVQ7"),_e=n("/7OuCFNo");const Ne=()=>{const t=(0,_e.Z)(),{pathname:a}=(0,S.Z)(),o=(0,v.Z)();return e.createElement(l.$4,{title:"Event Definitions"},e.createElement(Le.Z,null),e.createElement(l.mr,{title:"Event Definitions",actions:e.createElement(l.AE,{permissions:"eventdefinitions:create"},e.createElement(s.Button,{bsStyle:"success",onClick:()=>{o(p.A.EVENTDEFINITION_CREATE_BUTTON_CLICKED,{app_pathname:(0,m.av)(a),app_section:"event-definitions",app_action_value:"create-event-definition-button"}),t.push(R.ZP.ALERTS.DEFINITIONS.CREATE)}},"Create event definition")),documentationLink:{title:"Alerts documentation",path:he.Z.PAGES.ALERTS}},e.createElement("span",null,"Create new Event Definitions that will allow you to search for different Conditions and alert on them.")),e.createElement(s.Row,{className:"content"},e.createElement(s.Col,{md:12},e.createElement(Se,null))))}}}]);})();
//# sourceMappingURL=07ba022f-6717.aeb98ff1f77c52272654.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy