web-interface.assets.bb8c8232-8288.6812618135ea3c8c8e22.js Maven / Gradle / Ivy
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-8288"],{rDZEPRYo:(k,b,n)=>{n.d(b,{A:()=>F});var e=n("Z7aTuO5B"),A=n("P98ee3gW"),i=n("HhRuy6uH");const l=({children:S,disabled:U})=>e.createElement(A.A,{title:i.$N,bsSize:"xsmall",pullRight:!0,buttonTitle:i.qE,disabled:U},S);l.defaultProps={disabled:!1};const F=l},SfPIQIJE:(k,b,n)=>{n.d(b,{A:()=>w});var e=n("Z7aTuO5B"),A=n("J6y4/h8P"),i=n("rIl5IEuP"),l=n("ty2gyrHp"),F=n("IOI9nV80"),S=n("NV1/EHMi");const U=(0,A.default)(i.ButtonToolbar)`
margin-bottom: 10px;
`,Y=(0,A.default)(i.Button)(({theme:T})=>(0,A.css)`
font-family: ${T.fonts.family.navigation};
font-size: ${T.fonts.size.navigation};
color: ${T.colors.variant.darker.default};
&:hover,
&:focus {
background: inherit;
text-decoration: none;
}
&:hover {
color: inherit;
${(0,S.WS)(T)}
}
&.active {
color: ${T.colors.global.textDefault};
${(0,S.at)(T)}
&:hover,
&:focus {
${(0,S.at)(T)}
}
`);Y.displayName="Button";const w=({items:T})=>e.createElement(U,null,T.map(({path:m,title:Z,permissions:_,exactPathMatch:G})=>m?e.createElement(F.Wj,{permissions:_!=null?_:[],key:m},e.createElement(l.m,{to:m,relativeActive:!G},e.createElement(Y,{bsStyle:"link"},e.createElement(S.Ay,null,Z)))):null))},IFFKjdia:(k,b,n)=>{n.d(b,{PI:()=>A,S2:()=>l,eD:()=>e,zR:()=>i});const e="system-notifications-v1",A="event_definitions",i={pageSize:20,sort:{attributeId:"title",direction:"asc"},displayedColumns:["title","description","priority","scheduling","status","matched_at"],columnsOrder:["title","description","priority","matched_at","status","scheduling"]},l=[{id:"scheduling",title:"Scheduling",sortable:!1},{id:"matched_at",title:"Last Matched",sortable:!0}]},jvpdvVQ7:(k,b,n)=>{n.d(b,{A:()=>U});var e=n("Z7aTuO5B"),A=n("SfPIQIJE"),i=n("d4kzUuQm"),l=n("rIl5IEuP");const F=[{title:"Alerts & Events",path:i.Ay.ALERTS.LIST,exactPathMatch:!0},{title:"Event Definitions",path:i.Ay.ALERTS.DEFINITIONS.LIST},{title:"Notifications",path:i.Ay.ALERTS.NOTIFICATIONS.LIST}],U=()=>e.createElement(l.Row,null,e.createElement(A.A,{items:F}))},ldS1FYyb:(k,b,n)=>{n.r(b),n.d(b,{default:()=>Ne});var e=n("Z7aTuO5B"),A=n("ty2gyrHp"),i=n("rIl5IEuP"),l=n("IOI9nV80"),F=n("rVdVsuGH"),S=n("d4kzUuQm"),U=n("Dg3D5NJi"),Y=n("qO9czYNI"),f=n("MdYBRjRJ"),w=n("8OvTct/Z"),T=n("0t7Ye+61"),m=n("v4GbOr/o"),Z=n("leXY1Rul"),_=n("cd5HAK44"),G=n("HqzDVmZB"),H=n("jAGDuYSC"),q=n("JNPySgKz"),ie=n("rDZEPRYo");const v={COPY:"copy",DELETE:"delete",DISABLE:"disable",ENABLE:"enable"},ee={[v.COPY]:{dialogTitle:"Copy Event Definition",dialogBody:t=>`Are you sure you want to create a copy of "${t}"?`},[v.DELETE]:{dialogTitle:"Delete Event Definition",dialogBody:t=>`Are you sure you want to delete "${t}"?`},[v.DISABLE]:{dialogTitle:"Disable Event Definition",dialogBody:t=>`Are you sure you want to disable "${t}"?`},[v.ENABLE]:{dialogTitle:"Enable Event Definition",dialogBody:t=>`Are you sure you want to enable "${t}"?`}},se=({eventDefinition:t,refetchEventDefinitions:o})=>{const{deselectEntity:a}=(0,q.A)(),{scopePermissions:E}=(0,Z.A)(t),[s,r]=(0,e.useState)(null),[c,u]=(0,e.useState)(!1),[y,L]=(0,e.useState)(null),[O,D]=(0,e.useState)(!1),{pathname:p}=(0,T.A)(),g=(0,w.A)(),W=()=>E==null?void 0:E.is_mutable,N=()=>{var C;return((C=t==null?void 0:t.config)==null?void 0:C.type)==="system-notifications-v1"},V=()=>{var C;return((C=t==null?void 0:t.config)==null?void 0:C.type)==="aggregation-v1"},P=({show:C,type:M,definition:j})=>{u(C),L(M),r(j)},I=(C,M)=>{switch(C){case v.COPY:g(m.g.EVENTDEFINITION_LIST.ROW_ACTION_COPY_CLICKED,{app_pathname:(0,f.i)(p),app_section:"event-definition-row",app_action_value:"copy-menuitem"}),P({show:!0,type:v.COPY,definition:M});break;case v.DELETE:g(m.g.EVENTDEFINITION_LIST.ROW_ACTION_DELETE_CLICKED,{app_pathname:(0,f.i)(p),app_section:"event-definition-row",app_action_value:"delete-menuitem"}),P({show:!0,type:v.DELETE,definition:M});break;case v.ENABLE:g(m.g.EVENTDEFINITION_LIST.ROW_ACTION_ENABLE_CLICKED,{app_pathname:(0,f.i)(p),app_section:"event-definition-row",app_action_value:"enable-menuitem"}),P({show:!0,type:v.ENABLE,definition:M});break;case v.DISABLE:g(m.g.EVENTDEFINITION_LIST.ROW_ACTION_DISABLE_CLICKED,{app_pathname:(0,f.i)(p),app_section:"event-definition-row",app_action_value:"disable-menuitem"}),P({show:!0,type:v.DISABLE,definition:M});break;default:break}},B=()=>{g(m.g.EVENTDEFINITION_LIST.ROW_ACTION_SHARE_CLICKED,{app_pathname:(0,f.i)(p),app_section:"event-definition-list",app_action_value:"share-button"}),D(!0)},R=()=>{P({show:!1,type:null,definition:null}),o()},d=()=>{switch(y){case"copy":_.a.copy(s).finally(()=>{R()});break;case"delete":_.a.delete(s).then(()=>{a(s.id),H.A.success("Event Definition deleted successfully",`Event Definition "${t.title}" was deleted successfully.`)},C=>{var M,j,oe;const be=((oe=(j=(M=C==null?void 0:C.additional)==null?void 0:M.body)==null?void 0:j.errors)==null?void 0:oe.dependency.join(" "))||C;H.A.error(`Deleting Event Definition "${t.title}" failed with status: ${be}`,"Could not delete Event Definition")}).finally(()=>{R()});break;case"enable":_.a.enable(s).finally(()=>{R()});break;case"disable":_.a.disable(s).finally(()=>{R()});break;default:break}},le=(t==null?void 0:t.state)==="ENABLED";return e.createElement(e.Fragment,null,e.createElement(i.ButtonToolbar,{key:`actions-${t.id}`},e.createElement(l.wD,{entityId:t.id,entityType:"event_definition",onClick:B,bsSize:"xsmall"}),e.createElement(ie.A,null,e.createElement(l.Wj,{permissions:`eventdefinitions:edit:${t.id}`},e.createElement(A.m,{to:S.Ay.ALERTS.DEFINITIONS.edit(t.id)},e.createElement(i.MenuItem,{"data-testid":"edit-button"},"Edit"))),!N()&&e.createElement(i.MenuItem,{onClick:()=>I(v.COPY,t)},"Duplicate"),e.createElement(i.MenuItem,{divider:!0}),e.createElement(i.MenuItem,{disabled:N(),title:N()?"System Event Definition cannot be disabled":void 0,onClick:N()?void 0:()=>I(le?v.DISABLE:v.ENABLE,t)},le?"Disable":"Enable"),W()&&e.createElement(l.Wj,{permissions:`eventdefinitions:delete:${t.id}`},e.createElement(i.MenuItem,{divider:!0}),e.createElement(i.MenuItem,{disabled:N(),title:N()?"System Event Definition cannot be deleted":void 0,onClick:N()?void 0:()=>I(v.DELETE,t),"data-testid":"delete-button"},"Delete")),V()&&e.createElement(e.Fragment,null,e.createElement(i.MenuItem,{divider:!0}),e.createElement(A.m,{to:S.Ay.ALERTS.DEFINITIONS.replay_search(t.id)},e.createElement(i.MenuItem,null,"Replay search"))))),c&&e.createElement(l.TM,{title:ee[y].dialogTitle,show:!0,onConfirm:d,onCancel:R},ee[y].dialogBody(s.title)),O&&e.createElement(G.A,{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:()=>D(!1)}))};var re=n("9oVghaOd"),te=n.n(re),$=n("J6y4/h8P"),ne=n("+Ej1FZHV");const z=$.default.dt`
float: left;
clear: left;
`,x=$.default.dd(({theme:t})=>(0,$.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;
}
`),ce=(0,$.default)(ne.A)`
padding: 6px 8px;
`,de=t=>{var o,a;const E=(o=t==null?void 0:t.data)==null?void 0:o.timerange_from,s=(a=t==null?void 0:t.data)==null?void 0:a.timerange_to;return e.createElement(e.Fragment,null,e.createElement(z,null,"Next time range:"),e.createElement(x,null,e.createElement(l.Dc,{dateTime:E})," ",e.createElement(l.In,{name:"arrow_circle_right"})," ",e.createElement(l.Dc,{dateTime:s})))},Ee=(t,o)=>e.createElement("dl",null,e.createElement(z,null,"Status:"),e.createElement(x,null,t.status),t.triggered_at&&e.createElement(e.Fragment,null,e.createElement(z,null,"Last execution:"),e.createElement(x,null,e.createElement(l.Dc,{dateTime:t.triggered_at}))),t.next_time&&e.createElement(e.Fragment,null,e.createElement(z,null,"Next execution:"),e.createElement(x,null,e.createElement(l.Dc,{dateTime:t.next_time}))),de(t),e.createElement(z,null,"Queued notifications:"),e.createElement(x,null,t.queued_notifications,t.queued_notifications>0&&e.createElement(ne.A,{bsStyle:"link",bsSize:"xsmall",onClick:()=>o()},"clear"))),ue=({executeEveryMs:t,searchWithinMs:o,scheduler:a,title:E,clearNotifications:s})=>{const r=te().duration(t).format("d [days] h [hours] m [minutes] s [seconds]",{trim:"all",usePlural:!1}),c=te().duration(o).format("d [days] h [hours] m [minutes] s [seconds]",{trim:"all"});return e.createElement(e.Fragment,null,`Runs every ${r}, searching within the last ${c}. `,e.createElement(l.N,{trigger:"click",rootClose:!0,placement:"left",title:`${E} details.`,overlay:Ee(a,s),width:500},e.createElement(ce,{bsStyle:"link"},e.createElement(l.In,{name:"info"}))))},me=({definition:t})=>{var o,a;if(!((o=t==null?void 0:t.config)!=null&&o.search_within_ms)&&!((a=t==null?void 0:t.config)!=null&&a.execute_every_ms))return e.createElement(e.Fragment,null,"Not Scheduled.");const E=y=>()=>{window.confirm(`Are you sure you want to clear queued notifications for "${y.title}"?`)&&_.a.clearNotificationQueue(y)},{title:s,config:{search_within_ms:r,execute_every_ms:c},scheduler:u}=t;return e.createElement(ue,{executeEveryMs:c,searchWithinMs:r,title:s,scheduler:u,clearNotifications:E(t)})},ve=(0,$.default)(i.Label)(({$clickable:t})=>(0,$.css)`
cursor: ${t?"pointer":"default"};
display: inline-flex;
justify-content: center;
gap: 4px;
`),pe=$.default.div`
border-left: 1px solid currentColor;
height: 1em;
`,Ie=(t,o,a)=>o?a:t?"Enable":"Disable",Ae=({eventDefinition:t,refetchEventDefinitions:o})=>{var a;const[E,s]=(0,e.useState)(!1),r=(t==null?void 0:t.state)==="ENABLED",c=((a=t==null?void 0:t.config)==null?void 0:a.type)==="system-notifications-v1",u=r?"enabled":"disabled",y=Ie(!r,c,u),L=(0,e.useCallback)(async()=>{r?s(!0):(await _.a.enable(t),await o())},[r,t,o]),O=(0,e.useCallback)(async()=>{await _.a.disable(t),await o(),s(!1)},[t,o]);return e.createElement(e.Fragment,null,e.createElement(ve,{bsStyle:r?"success":"warning",onClick:c?void 0:L,title:y,"aria-label":y,role:"button",$clickable:!c},u,!c&&e.createElement(e.Fragment,null,e.createElement(pe,null),e.createElement(l.In,{name:r?"pause":"play_arrow"}))),E&&e.createElement(i.BootstrapModalConfirm,{showModal:!0,title:"Disable event definition",onConfirm:O,onCancel:()=>s(!1)},`Do you really want to disable event definition '${t.title}'?`))};var fe=n("DUKaTDO2"),J=n("U1Iufsob"),Te=n("eFxcQyPT"),ae=n("TJOheZRu"),ge=n("Z2BtcgLJ");const h={DELETE:"delete",DISABLE:"disable",ENABLE:"enable"},Q=t=>ae.A.pluralize(t,"event definition","event definitions"),X={[h.DELETE]:{dialogTitle:"Delete Event Definitions",dialogBody:t=>`Are you sure you want to delete ${t} ${Q(t)}?`,bulkActionUrl:J.A.EventDefinitionsApiController.bulkDelete().url},[h.DISABLE]:{dialogTitle:"Disable Event Definitions",dialogBody:t=>`Are you sure you want to disable ${t} ${Q(t)}?`,bulkActionUrl:J.A.EventDefinitionsApiController.bulkUnschedule().url},[h.ENABLE]:{dialogTitle:"Enable Event Definitions",dialogBody:t=>`Are you sure you want to enable ${t} ${Q(t)}?`,bulkActionUrl:J.A.EventDefinitionsApiController.bulkSchedule().url}},ye=()=>{var t,o;const a=(0,fe.useQueryClient)(),{selectedEntities:E,setSelectedEntities:s}=(0,q.A)(),[r,c]=(0,e.useState)(!1),[u,y]=(0,e.useState)(null),L=E==null?void 0:E.length,{pathname:O}=(0,T.A)(),D=(0,w.A)(),p=(0,e.useCallback)(()=>a.invalidateQueries(["eventDefinition","overview"]),[a]),g=({show:I,type:B})=>{c(I),y(B)},W=I=>{switch(I){case h.DELETE:D(m.g.EVENTDEFINITION_LIST.BULK_ACTION_DELETE_CLICKED,{app_pathname:(0,f.i)(O),app_section:"event-definition-bulk",app_action_value:"delete-menuitem"}),g({show:!0,type:h.DELETE});break;case h.ENABLE:D(m.g.EVENTDEFINITION_LIST.BULK_ACTION_ENABLE_CLICKED,{app_pathname:(0,f.i)(O),app_section:"event-definition-bulk",app_action_value:"enable-menuitem"}),g({show:!0,type:h.ENABLE});break;case h.DISABLE:D(m.g.EVENTDEFINITION_LIST.BULK_ACTION_DISABLE_CLICKED,{app_pathname:(0,f.i)(O),app_section:"event-definition-bulk",app_action_value:"disable-menuitem"}),g({show:!0,type:h.DISABLE});break;default:break}},N=()=>{g({show:!1,type:null}),p()},V=(0,e.useCallback)(()=>{(0,Te.Ay)("POST",(0,f.H3)(X[u].bulkActionUrl),{entity_ids:E}).then(({failures:I})=>{if(I!=null&&I.length){const B=I.map(({entity_id:R})=>R);s(B)}else s([]),H.A.success(`${L} ${Q(L)} ${ae.A.pluralize(L,"was","were")} ${u}d successfully.`,"Success")}).catch(I=>{H.A.error(`An error occurred while ${u} event definition. ${I}`)}).finally(()=>{p()})},[u,p,E,L,s]),P=()=>{V(),c(!1)};return e.createElement(e.Fragment,null,e.createElement(ge.A,null,e.createElement(i.MenuItem,{onSelect:()=>W(h.ENABLE)},"Enable"),e.createElement(i.MenuItem,{onSelect:()=>W(h.DISABLE)},"Disable"),e.createElement(i.MenuItem,{onSelect:()=>W(h.DELETE),variant:"danger"},"Delete")),r&&e.createElement(l.TM,{title:(t=X[u])==null?void 0:t.dialogTitle,show:!0,onConfirm:P,onCancel:N},(o=X[u])==null?void 0:o.dialogBody(L)))};var De=n("jhzeTBRS"),K=n("IFFKjdia");const Ce=t=>({attributes:{title:{renderCell:(o,a)=>e.createElement(A.N,{to:S.Ay.ALERTS.DEFINITIONS.show(a.id)},o)},matched_at:{renderCell:(o,a)=>a.matched_at?e.createElement(l.sR,{dateTime:a.matched_at}):"Never"},scheduling:{renderCell:(o,a)=>e.createElement(me,{definition:a})},status:{renderCell:(o,a)=>e.createElement(Ae,{eventDefinition:a,refetchEventDefinitions:t}),staticWidth:100},priority:{staticWidth:100}}}),Se=()=>{const[t,o]=(0,e.useState)(""),{layoutConfig:a,isInitialLoading:E}=(0,U.A)({entityTableId:K.PI,defaultPageSize:K.zR.pageSize,defaultDisplayedAttributes:K.zR.displayedColumns,defaultSort:K.zR.sort}),s=(0,F.Ay)(void 0,20),{mutate:r}=(0,Y.A)(K.PI),{data:c,refetch:u,isInitialLoading:y}=(0,De.A)({query:t,page:s.page,pageSize:a.pageSize,sort:a.sort}),L=Ce(u),O=(0,e.useMemo)(()=>{var d;return[...(d=c==null?void 0:c.attributes)!=null?d:[],...K.S2]},[c==null?void 0:c.attributes]),{pathname:D}=(0,T.A)(),p=(0,w.A)(),g=(0,e.useCallback)(d=>{s.resetPage(),o(d)},[s]),W=(0,e.useCallback)(()=>{g("")},[g]),N=(0,e.useCallback)(d=>{p(m.g.EVENTDEFINITION_LIST.COLUMNS_CHANGED,{app_pathname:(0,f.i)(D),app_section:"event-definition-list",app_action_value:"columns-select",columns:d}),r({displayedAttributes:d})},[D,p,r]),V=(0,e.useCallback)(d=>{p(m.g.EVENTDEFINITION_LIST.PAGE_SIZE_CHANGED,{app_pathname:(0,f.i)(D),app_section:"event-definition-list",app_action_value:"page-size-select",page_size:d}),s.setPagination({page:1,pageSize:d}),r({perPage:d})},[s,D,p,r]),P=(0,e.useCallback)(d=>{p(m.g.EVENTDEFINITION_LIST.SORT_CHANGED,{app_pathname:(0,f.i)(D),app_section:"event-definition-list",app_action_value:"sort-select",sort:d}),s.resetPage(),r({sort:d})},[s,D,p,r]),I=(0,e.useCallback)(d=>e.createElement(se,{eventDefinition:d,refetchEventDefinitions:u}),[u]);if(E||y)return e.createElement(l.y$,null);const{elements:B,pagination:{total:R}}=c;return e.createElement(l.OW,{pageSize:a.pageSize,showPageSizeSelect:!1,totalItems:R},e.createElement("div",{style:{marginBottom:5}},e.createElement(l.B9,{onSearch:g,onReset:W,queryHelpComponent:e.createElement(l.xf,{entityName:"event definition"})})),e.createElement("div",null,(B==null?void 0:B.length)===0?e.createElement(l.EO,null,"No Event Definition has been found"):e.createElement(l.UA,{data:B,visibleColumns:a.displayedAttributes,columnsOrder:K.zR.columnsOrder,onColumnsChange:N,onSortChange:P,onPageSizeChange:V,pageSize:a.pageSize,bulkSelection:{actions:e.createElement(ye,null)},activeSort:a.sort,actionsCellWidth:160,rowActions:I,columnRenderers:L,columnDefinitions:O,entityAttributesAreCamelCase:!1})))};var he=n("E+CaPsQD"),Le=n("jvpdvVQ7");const Ne=()=>{const{pathname:t}=(0,T.A)(),o=(0,w.A)();return e.createElement(l.Qc,{title:"Event Definitions"},e.createElement(Le.A,null),e.createElement(l.zY,{title:"Event Definitions",actions:e.createElement(l.Wj,{permissions:"eventdefinitions:create"},e.createElement(A.m,{to:S.Ay.ALERTS.DEFINITIONS.CREATE},e.createElement(i.Button,{bsStyle:"success",onClick:()=>{o(m.g.EVENTDEFINITION_CREATE_BUTTON_CLICKED,{app_pathname:(0,f.i)(t),app_section:"event-definitions",app_action_value:"create-event-definition-button"})}},"Create event definition"))),documentationLink:{title:"Alerts documentation",path:he.A.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(i.Row,{className:"content"},e.createElement(i.Col,{md:12},e.createElement(Se,null))))}}}]);})();
//# sourceMappingURL=bb8c8232-8288.6812618135ea3c8c8e22.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy