web-interface.assets.bb8c8232-2340.5f288bc3bf486f8aa033.js Maven / Gradle / Ivy
(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-2340"],{"mNgGj/z+":(S,A,e)=>{"use strict";e.d(A,{A:()=>_});var n=e("J6y4/h8P"),t=e("Z7aTuO5B"),o=e("UiXZqrDE"),u=e("tr19tF7z"),y=e.n(u),i=e("IOI9nV80"),g=e("rIl5IEuP"),E=e("9kZNWwre"),x=e("A4KcNqtF"),I=e("4E3oowBb"),l=e("6oM+slHS");const a=n.styled.div`
flex-basis: 100%;
`,P=n.styled.div`
flex-grow: 1;
display: flex;
gap: 5px;
`,C=n.styled.div`
display: flex;
flex-direction: column;
`,v=n.styled.h5`
font-weight: bold;
margin-bottom: 5px;
`,R=n.styled.div`
display: flex;
gap: 5px;
`,U=(0,n.styled)(i.hP)`
margin-top: 30px;
`,Q=(r,m)=>{if(!r)return"Field is required";if((0,l.A)(r))return"Field is reserved";if(m>1)return"This field occurs several times"},K=r=>{const m={};r.name||(m.name="Profile name is required");const d=y()(r.customFieldMappings,"field"),s=r.customFieldMappings.map(({field:c,type:F})=>{if(!(c&&F&&d[c]===1))return{field:Q(c,d[c]),type:F?void 0:"Type is required"}});return s.filter(c=>c).length>0&&(m.customFieldMappings=s),m},M=({onChange:r,options:m,error:d,name:s,value:c,placeholder:F,allowCreate:O})=>t.createElement(a,null,t.createElement(g.Input,{error:d,name:s,id:s},t.createElement(i.l6,{options:m,value:c,inputId:s,onChange:h=>{r({target:{value:h,name:s}})},inputProps:{"aria-label":`Select ${s}`},placeholder:F,allowCreate:O}))),p=({initialValues:r,submitButtonText:m,submitLoadingText:d,onCancel:s,onSubmit:c})=>{const{data:F,isLoading:O}=(0,E.A)(void 0,void 0),{data:{fieldTypes:h},isLoading:T}=(0,x.A)(),D=(0,t.useMemo)(()=>Object.entries(h).sort(([,f],[,L])=>(0,I.j)(f,L)).map(([f,L])=>({value:f,label:L})),[h]),$=(0,t.useMemo)(()=>O?[]:F.map(({value:{name:f}})=>({value:f,label:f,disabled:(0,l.A)(f)})),[F,O]),z=f=>{c(f)};return t.createElement(g.Col,{lg:8},t.createElement(o.Formik,{initialValues:r,onSubmit:z,validate:K,validateOnChange:!0},({isSubmitting:f,isValid:L,isValidating:H,values:{customFieldMappings:Y}})=>t.createElement(o.Form,null,t.createElement(i.jF,{name:"name",label:"Profile name",id:"index-set-field-type-profile-name",placeholder:"Type a profile name",help:"A descriptive name of the new profile",required:!0}),t.createElement(i.jF,{name:"description",id:"index-set-field-type-profile-description",placeholder:"Type a profile description",label:t.createElement(t.Fragment,null,"Description ",t.createElement(i.Bt,null)),type:"textarea",help:"Longer description for profile",rows:6}),t.createElement(o.FieldArray,{name:"customFieldMappings",render:({remove:X,push:G})=>t.createElement(t.Fragment,null,t.createElement(v,null,"Set up mappings"),t.createElement(g.HelpBlock,null,"Here you can set up type mapping to any field."),t.createElement(C,null,O||T?t.createElement(i.y$,null):Y.map(({field:Z},B)=>t.createElement(R,{key:B,"data-testid":`custom-mapping-row-for-${Z}`},t.createElement(P,null,t.createElement(o.Field,{name:`customFieldMappings.${B}.field`,required:!0},({field:{name:W,value:N,onChange:j},meta:{error:b}})=>t.createElement(M,{value:N,onChange:j,options:$,name:W,error:b,placeholder:"Select or type field name",allowCreate:!0})),t.createElement(o.Field,{name:`customFieldMappings.${B}.type`,required:!0},({field:{name:W,value:N,onChange:j},meta:{error:b}})=>t.createElement(M,{value:N,onChange:j,options:D,name:W,error:b,placeholder:"Select field type",allowCreate:!1}))),Y.length>1&&t.createElement(i.K0,{name:"delete",onClick:()=>X(B),title:"Remove mapping"})))),t.createElement(g.Button,{bsSize:"xs",onClick:()=>G({}),name:"plus",title:"Add mapping"},"Add mapping"))}),t.createElement(U,{submitButtonText:m,onCancel:s,disabledSubmit:H||!L,isSubmitting:f,submitLoadingText:d}))))};p.defaultProps={initialValues:{name:"",description:"",customFieldMappings:[{type:"",field:""}]}};const _=p},"lzBUPFm/":(S,A,e)=>{"use strict";e.d(A,{A:()=>I});var n=e("DUKaTDO2"),t=e("MdYBRjRJ"),o=e("eFxcQyPT"),u=e("jAGDuYSC");const y="/system/indices/index_sets/profiles",i=async({profile:l,id:a})=>{const P=(0,t.H3)(y),C={id:a,name:l.name,description:l.description,custom_field_mappings:l.customFieldMappings};return(0,o.Ay)("PUT",P,C)},g=async l=>{const a=(0,t.H3)(y),P={name:l.name,description:l.description,custom_field_mappings:l.customFieldMappings};return(0,o.Ay)("POST",a,P)},E=async l=>{const a=(0,t.H3)(`${y}/${l}`);return(0,o.Ay)("DELETE",a)},I=()=>{const l=(0,n.useQueryClient)(),a=(0,n.useMutation)(g,{onError:v=>{u.A.error(`Creating index set field type profile failed with status: ${v}`,"Could not create index set field type profile")},onSuccess:()=>(u.A.success("Index set field type profile has been successfully created.","Success!"),l.refetchQueries({queryKey:["indexSetFieldTypeProfiles"],type:"active"}))}),P=(0,n.useMutation)(i,{onError:v=>{u.A.error(`Updating index set field type profile failed with status: ${v}`,"Could not update index set field type profile")},onSuccess:()=>(u.A.success("Index set field type profile has been successfully updated.","Success!"),l.refetchQueries({queryKey:["indexSetFieldTypeProfiles"],type:"active"}))}),C=(0,n.useMutation)(E,{onError:v=>{u.A.error(`Deleting index set field type profile failed with status: ${v}`,"Could not delete index set field type profile")},onSuccess:()=>(u.A.success("Index set field type profile has been successfully deleted.","Success!"),l.refetchQueries({queryKey:["indexSetFieldTypeProfiles"],type:"active"}))});return{editProfile:P.mutateAsync,isEditLoading:P.isLoading,createProfile:a.mutateAsync,isCreateLoading:a.isLoading,isLoading:a.mutateAsync||a.isLoading||C.isLoading,deleteProfile:C.mutateAsync}}},wQTcML4j:(S,A,e)=>{"use strict";e.r(A),e.d(A,{default:()=>K});var n=e("Z7aTuO5B"),t=e("yAXMqwrl"),o=e("IOI9nV80"),u=e("E+CaPsQD"),y=e("d4kzUuQm"),i=e("rIl5IEuP"),g=e("8OvTct/Z"),E=e("v4GbOr/o"),x=e("MdYBRjRJ"),I=e("0t7Ye+61"),l=e("mNgGj/z+"),a=e("lzBUPFm/"),P=e("/7OuCFNo");const v=()=>{var M;const p=(0,g.A)(),{pathname:_}=(0,I.A)(),r=(0,t.useNavigate)(),{createProfile:m}=(0,a.A)(),d=(0,n.useMemo)(()=>(0,x.i)(_),[_]),s=(0,I.A)(),c=(0,P.A)(),F=(0,n.useMemo)(()=>{var T;const D=(T=s==null?void 0:s.state)==null?void 0:T.customFieldMappings;if(D)return{customFieldMappings:D,name:null,description:null}},[(M=s==null?void 0:s.state)==null?void 0:M.customFieldMappings]),O=(0,n.useCallback)(T=>{m(T).then(()=>{var D;p(E.g.INDEX_SET_FIELD_TYPE_PROFILE.CREATED,{app_pathname:d,app_action_value:{mappingsQuantity:(D=T==null?void 0:T.customFieldMappings)==null?void 0:D.length}}),r(y.Ay.SYSTEM.INDICES.FIELD_TYPE_PROFILES.OVERVIEW)})},[m,r,p,d]);(0,n.useEffect)(()=>{p(E.g.INDEX_SET_FIELD_TYPE_PROFILE.NEW_OPENED,{app_pathname:d,app_action_value:"create-new-index-set-field-type-profile-opened"})},[p,d]);const h=(0,n.useCallback)(()=>{p(E.g.INDEX_SET_FIELD_TYPE_PROFILE.NEW_CANCELED,{app_pathname:d,app_action_value:"create-new-index-set-field-type-profile-canceled"}),c.goBack()},[c,p,d]);return n.createElement(l.A,{initialValues:F,onCancel:h,submitButtonText:"Create profile",submitLoadingText:"Creating profile...",onSubmit:O})};var R=e("+K2jZtwG"),U=e("Zr9SSA9t");const K=()=>{const M=(0,t.useNavigate)(),p=(0,R.A)();return(0,n.useEffect)(()=>{p||M(y.Ay.NOTFOUND)},[p,M]),n.createElement(o.Qc,{title:"Create Index Set Field Type Profile"},n.createElement(U.TC,null),n.createElement(o.zY,{title:"Create Index Set Field Type Profile",documentationLink:{title:"Index model documentation",path:u.A.PAGES.INDEX_MODEL}},n.createElement("span",null,"With index set field type profiles you can bundle up custom field types into profiles. Then you can assign this profile to any index set. On this page you can create a new profile.")),n.createElement(i.Row,{className:"content"},n.createElement(i.Col,{md:12},n.createElement(v,null))))}},tr19tF7z:(S,A,e)=>{var n=e("mKCr8FEe"),t=e("aB24O9M4"),o=Object.prototype,u=o.hasOwnProperty,y=t(function(i,g,E){u.call(i,E)?++i[E]:n(i,E,1)});S.exports=y}}]);})();
//# sourceMappingURL=bb8c8232-2340.5f288bc3bf486f8aa033.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy