web-interface.assets.bb8c8232-2608.4c48be2d13205f6f53fe.js Maven / Gradle / Ivy
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-2608"],{uUb5y2xn:(W,D,s)=>{s.d(D,{A:()=>x});var B=s("pmX897Fv"),h=s.n(B),e=s("DjJvgDaP"),E=s.n(e),k=E()(h());k.push([W.id,`.px9Gw1DZOqXRLhrnJC1w {
color: rgba(158, 31, 99, 0.43);
}
`,"",{version:3,sources:["webpack://./src/components/content-packs/ContentPackSelection.css"],names:[],mappings:"AAAA;IACI,8BAA8B;AAClC",sourcesContent:[`:local(.contentPackEntity) {
color: rgba(158, 31, 99, 0.43);
}
`],sourceRoot:""}]),k.locals={contentPackEntity:"px9Gw1DZOqXRLhrnJC1w"};const x=k},FhPlv95w:(W,D,s)=>{s.d(D,{A:()=>ye});var B=s("ii0bleBb"),h=s.n(B),e=s("Z7aTuO5B"),E=s("IOI9nV80"),k=s("znhYcHoq"),x=s("IW7priiX"),A=s.n(x),j=s("J6y4/h8P"),T=s("4E3oowBb"),i=s("rIl5IEuP"),b=s("S6FuRS7B"),M=s("PAFhOglk"),O=s("MdYBRjRJ"),J=s("Kz+u8q89"),R=s("dFpwyWHg"),d=s.n(R),P=s("C2ikvoS0"),v=s.n(P),I=s("1IntWRSu"),K=s.n(I),F=s("8nGWeFnd"),ne=s.n(F),ae=s("TeAcaicX"),se=s.n(ae),re=s("eE3+5goe"),oe=s.n(re),N=s("uUb5y2xn"),w={};w.styleTagTransform=oe(),w.setAttributes=ne(),w.insert=K().bind(null,"head"),w.domAPI=v(),w.insertStyleElement=se();var ke=d()(N.A,w);const Z=N.A&&N.A.locals?N.A.locals:void 0;var ie=Object.defineProperty,le=(l,a,n)=>a in l?ie(l,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[a]=n,C=(l,a,n)=>(le(l,typeof a!="symbol"?a+"":a,n),n);const ce=j.default.span`
overflow-wrap: anywhere;
`,Y=(0,j.default)(E.In)(({theme:l})=>`
padding-top: ${l.spacings.xxs};
padding-right: ${l.spacings.xxs};
`),de=l=>l instanceof M.A?e.createElement(e.Fragment,null,e.createElement(Y,{name:"archive",className:Z.contentPackEntity})," ",e.createElement("span",null,l.title)):e.createElement(e.Fragment,null,e.createElement(Y,{name:"dns"})," ",e.createElement(ce,null,l.title)),V=class te extends e.Component{constructor(a){super(a),C(this,"_updateField",(t,r)=>{const{contentPack:o}=this.state,{onStateChange:m}=this.props,c=o.toBuilder()[t](r).build();m({contentPack:c}),this.setState({contentPack:c},this._validate)}),C(this,"_validate",t=>{const r=["name","summary","vendor"],{contentPack:o}=this.state,{selectedEntities:m}=this.props,c=t||m,u=r.reduce((g,y)=>{const L=g;return(!o[y]||o[y].length<=0)&&(L[y]="Must be filled out."),L},{});if(o.url)try{(0,O.uH)(o.url)||(u.url="Must use a URL starting with http or https.")}catch{u.url="Invalid URL"}Object.keys(c).reduce((g,y)=>g+c[y].length,0)<=0&&(u.selection="Select at least one entity."),this.setState({errors:u})}),C(this,"_bindValue",t=>{this._updateField(t.target.name,(0,b.yG)(t.target))}),C(this,"_handleTouched",t=>{this.setState(r=>({touched:{...r.touched,[t]:!0,selection:!0}}),this._validate)}),C(this,"_error",t=>this.state.touched[t]?this.state.errors[t]:void 0),C(this,"_updateSelectionEntity",t=>{const{selectedEntities:r,onStateChange:o}=this.props,m=t.type.name,c=A()(r);c[m]=c[m]||[];const u=c[m].findIndex(f=>f.id===t.id);u<0?c[m].push(t):c[m].splice(u,1),this._handleTouched("selection"),this._validate(c),o({selectedEntities:c})}),C(this,"_updateSelectionGroup",t=>{const{selectedEntities:r,entities:o,onStateChange:m}=this.props,{isFiltered:c,filteredEntities:u}=this.state,f=A()(r);c?f[t]?f[t]=[...f[t],...u[t]]:f[t]=u[t]:this._isGroupSelected(t)?f[t]=[]:f[t]=o[t],this._handleTouched("selection"),this._validate(f),m({selectedEntities:f})}),C(this,"_isUndetermined",t=>{const{selectedEntities:r,entities:o}=this.props;return r[t]?!(r[t].length===o[t].length||r[t].length===0):!1}),C(this,"_isSelected",t=>{const{selectedEntities:r}=this.props,o=t.type.name;return r[o]?r[o].findIndex(m=>m.id===t.id)>=0:!1}),C(this,"_isGroupSelected",t=>{const{selectedEntities:r,entities:o}=this.props;return r[t]?r[t].length===o[t].length:!1}),C(this,"_onSetFilter",t=>{this._filterEntities(t)}),C(this,"_onClearFilter",()=>{this._filterEntities("")}),C(this,"_filterEntities",t=>{const{entities:r}=this.props,o=t;if(o.length<=0){this.setState({filteredEntities:A()(r),isFiltered:!1,filter:o});return}const m=Object.keys(r).reduce((c,u)=>{const f=A()(c);return f[u]=r[u].filter(g=>RegExp(o,"i").test(g.title)),f},{});this.setState({filteredEntities:m,isFiltered:!0,filter:o})});const{entities:n,contentPack:p}=this.props;this.state={contentPack:p,filteredEntities:n,filter:"",isFiltered:!1,errors:{},touched:{}}}static _toDisplayTitle(a){const n=a.split("_").join(" ");return n[0].toUpperCase()+n.substr(1)}UNSAFE_componentWillReceiveProps(a){this.setState({filteredEntities:a.entities,contentPack:a.contentPack});const{filter:n,isFiltered:p}=this.state;p&&this._filterEntities(n)}render(){const{filteredEntities:a={},errors:n,touched:p,isFiltered:t,contentPack:r}=this.state,{edit:o}=this.props,m=Object.keys(a).sort((c,u)=>(0,T.j)(c,u)).map(c=>{const u=a[c],f=u.sort((g,y)=>(0,T.j)(g.title,y.title)).map(g=>{const y=this._isSelected(g),L=de(g);return e.createElement(E.m1,{onChange:()=>this._updateSelectionEntity(g),key:g.id,checked:y,expandable:!1,padded:!1,header:L})});return u.length<=0?null:e.createElement(E.m1,{key:c,onChange:()=>this._updateSelectionGroup(c),indetermined:this._isUndetermined(c),checked:this._isGroupSelected(c),stayExpanded:t,expanded:t,padded:!1,header:te._toDisplayTitle(c)},e.createElement(E.hG,null,f))});return e.createElement("div",null,e.createElement(i.Row,null,e.createElement(i.Col,{smOffset:1,lg:8},e.createElement("h2",null,"General Information"),e.createElement("br",null),e.createElement("form",{className:"content-selection-form",id:"content-selection-form",onSubmit:c=>{c.preventDefault()}},e.createElement("fieldset",null,e.createElement(i.Input,{name:"name",id:"name",type:"text",maxLength:250,value:r.name,onChange:this._bindValue,onBlur:()=>this._handleTouched("name"),label:"Name",help:"Required. Give a descriptive name for this content pack.",error:this._error("name"),required:!0}),e.createElement(i.Input,{name:"summary",id:"summary",type:"text",maxLength:250,value:r.summary,onChange:this._bindValue,onBlur:()=>this._handleTouched("summary"),label:"Summary",help:"Required. Give a short summary of the content pack.",error:this._error("summary"),required:!0}),e.createElement(i.Input,{name:"description",id:"description",type:"textarea",value:r.description,onChange:this._bindValue,onBlur:()=>this._handleTouched("description"),rows:6,label:"Description",help:"Give a long description of the content pack in markdown."}),e.createElement(i.Input,{name:"vendor",id:"vendor",type:"text",maxLength:250,value:r.vendor,onChange:this._bindValue,onBlur:()=>this._handleTouched("vendor"),label:"Vendor",help:"Required. Who did this content pack and how can they be reached, e.g. Name and email.",error:this._error("vendor"),required:!0}),e.createElement(i.Input,{name:"url",id:"url",type:"text",maxLength:250,value:r.url,onChange:this._bindValue,onBlur:()=>this._handleTouched("url"),label:"URL",help:"Where can I find the content pack. e.g. github url",error:this._error("url")}))))),e.createElement(i.Row,null,e.createElement(i.Col,{smOffset:1,lg:8},e.createElement("h2",null,"Content Pack selection"),o&&e.createElement(i.HelpBlock,null,"You can select between installed entities from the server (",e.createElement(E.In,{name:"dns"}),") or entities from the former content pack revision (",e.createElement(E.In,{name:"archive",className:Z.contentPackEntity}),")."))),e.createElement(i.Row,null,e.createElement(i.Col,{smOffset:1,lg:8},e.createElement(E.B9,{id:"filter-input",onSearch:this._onSetFilter,onReset:this._onClearFilter}))),e.createElement(i.Row,null,e.createElement(i.Col,{smOffset:1,sm:8,lg:8},p.selection&&n.selection&&e.createElement(J.A,{error:n.selection}),e.createElement(E.hG,null,m))))}};C(V,"propTypes",{contentPack:h().object.isRequired,onStateChange:h().func,entities:h().object,selectedEntities:h().object,edit:h().bool}),C(V,"defaultProps",{edit:!1,onStateChange:()=>{},entities:{},selectedEntities:{}});const pe=V;var z=s("G9zy4OD/"),me=s("tq3qR0En"),Q=s("vyEB9hoZ"),_=s("4Bzr8nEu"),he=Object.defineProperty,ue=(l,a,n)=>a in l?he(l,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[a]=n,q=(l,a,n)=>(ue(l,typeof a!="symbol"?a+"":a,n),n);class H extends e.Component{_renderDownload(){const n=`data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(this.props.contentPack,null,2))}`,p=`content-pack-${this.props.contentPack.id}-${this.props.contentPack.rev}.json`;return e.createElement("a",{download:p,href:n},e.createElement(i.Button,{id:"download",bsStyle:"info",onClick:this.props.onSave},"Create and Download"))}render(){return e.createElement("div",null,e.createElement(i.Row,null,e.createElement(i.Col,{sm:6},e.createElement(z.A,{contentPack:this.props.contentPack})),e.createElement(i.Col,{sm:6},e.createElement(me.A,{constraints:this.props.contentPack.constraints,isFulfilled:!0}),e.createElement(Q.A,{contentPack:this.props.contentPack,readOnly:!0}),e.createElement(_.A,{contentPack:this.props.contentPack,readOnly:!0}))),e.createElement(i.Row,null,e.createElement(i.Col,{sm:6},e.createElement(i.Button,{id:"create",bsStyle:"primary",onClick:this.props.onSave},"Create"),"\xA0",this._renderDownload())))}}q(H,"propTypes",{contentPack:h().object.isRequired,onSave:h().func}),q(H,"defaultProps",{onSave:()=>{}});const Pe=H;var fe=s("Jb16h681"),ee=s.n(fe),U=s("QdZ7Yq43"),Ee=Object.defineProperty,ve=(l,a,n)=>a in l?Ee(l,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[a]=n,S=(l,a,n)=>(ve(l,typeof a!="symbol"?a+"":a,n),n);class G extends e.Component{constructor(a){super(a),S(this,"_addNewParameter",(n,p)=>{let t=this.props.contentPack.toBuilder();const r=U.A.clone(this.props.appliedParameter);p&&(Object.keys(r).forEach(o=>{r[o]=r[o].map(m=>m.paramName===p.name?{configKey:m.configKey,paramName:n.name}:m)}),t=t.removeParameter(p)),t.addParameter(n),this.props.onStateChange({contentPack:t.build(),appliedParameter:r})}),S(this,"_onParameterApply",(n,p,t)=>{const r={configKey:p,paramName:t},o=U.A.clone(this.props.appliedParameter);o[n]=o[n]||[],o[n].push(r),this.props.onStateChange({appliedParameter:o})}),S(this,"_onParameterClear",(n,p)=>{const t=U.A.clone(this.props.appliedParameter);ee()(t[n],r=>r.configKey===p),this.props.onStateChange({appliedParameter:t})}),S(this,"_deleteParameter",n=>{const{contentPack:p}=this.props,t=U.A.clone(this.props.appliedParameter);Object.keys(t).forEach(o=>{ee()(t[o],m=>m.paramName===n.name),t[o].length<=0&&delete t[o]});const r=p.toBuilder().removeParameter(n).build();this.props.onStateChange({contentPack:r,appliedParameter:t}),this._closeConfirmModal()}),S(this,"_confirmationModal",()=>e.createElement(i.BootstrapModalConfirm,{showModal:this.state.showParameterModal,title:"Confirm deletion",onConfirm:()=>{this._deleteParameter(this.state.parameterToDelete)},onCancel:this._closeConfirmModal},`Are you sure you want to do delete this parameter: ${(this.state.parameterToDelete||{}).title}?`)),S(this,"_openConfirmModal",n=>{this.setState({showParameterModal:!0,parameterToDelete:n})}),S(this,"_closeConfirmModal",()=>{this.setState({showParameterModal:!1,parameterToDelete:void 0})}),this.state={showParameterModal:!1,parameterToDelete:void 0}}render(){return e.createElement("div",null,e.createElement(i.Row,null,e.createElement(i.Col,{smOffset:1,sm:9},e.createElement(_.A,{contentPack:this.props.contentPack,onAddParameter:this._addNewParameter,onDeleteParameter:this._openConfirmModal,appliedParameter:this.props.appliedParameter}),this._confirmationModal())),e.createElement(i.Row,null,e.createElement(i.Col,{smOffset:1,sm:9},e.createElement(Q.A,{contentPack:this.props.contentPack,onParameterClear:this._onParameterClear,onParameterApply:this._onParameterApply,appliedParameter:this.props.appliedParameter}))))}}S(G,"propTypes",{contentPack:h().object.isRequired,onStateChange:h().func,appliedParameter:h().object.isRequired}),S(G,"defaultProps",{onStateChange:()=>{}}),S(G,"emptyParameter",{name:"",title:"",description:"",type:"string",default_value:""});const Ce=G;var ge=Object.defineProperty,Se=(l,a,n)=>a in l?ge(l,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[a]=n,X=(l,a,n)=>(Se(l,typeof a!="symbol"?a+"":a,n),n);class $ extends e.Component{constructor(a){super(a),X(this,"_stepChanged",n=>{switch(n){case"parameters":{const p=this.props.contentPack.toBuilder().entities(this.props.fetchedEntities||[]).build();this.props.onStateChange({contentPack:p}),Object.keys(this.props.selectedEntities).length>0&&this.props.onGetEntities(this.props.selectedEntities);break}case"preview":{this._prepareForPreview();break}default:break}this.setState({selectedStep:n})}),this.state={selectedStep:"selection"}}_disableParameters(){const a=this.props.contentPack,{selectedEntities:n}=this.props,p=Object.keys(n).reduce((t,r)=>t+n[r].length,0)>0;return!(a.name&&a.summary&&a.vendor&&p)}_disablePreview(){return this.state.selectedStep==="selection"||!this.state.selectedStep}_prepareForPreview(){const a=this.props.fetchedEntities.map(p=>{const t=this.props.appliedParameter[p.id]||[],r=p.toBuilder(),o=new k.A(p.data),m=o.getPaths();return Object.keys(m).forEach(c=>{const u=t.findIndex(f=>f.configKey===c);u>=0&&m[c].setParameter(t[u].paramName)}),r.data(o.getData()).parameters(this.props.contentPack.parameters),r.build()}),n=this.props.contentPack.toBuilder().entities(a).build();this.props.onStateChange({contentPack:n})}render(){if(!this.props.contentPack)return e.createElement(E.y$,null);const a=e.createElement(pe,{contentPack:this.props.contentPack,selectedEntities:this.props.selectedEntities,edit:this.props.edit,onStateChange:this.props.onStateChange,entities:this.props.entityIndex}),n=e.createElement(Ce,{contentPack:this.props.contentPack,onStateChange:this.props.onStateChange,appliedParameter:this.props.appliedParameter}),p=e.createElement(Pe,{contentPack:this.props.contentPack,onSave:this.props.onSave}),t=[{key:"selection",title:"Content Selection",component:a},{key:"parameters",title:"Parameters",component:n,disabled:this._disableParameters()},{key:"preview",title:"Preview",component:p,disabled:this._disablePreview()}];return e.createElement("div",null,e.createElement(E.sQ,{steps:t,onStepChange:this._stepChanged,affixed:!0},this.state.selectedStep!=="preview"?e.createElement(z.A,{contentPack:this.props.contentPack}):void 0),e.createElement(E.sb,{position:"middle"}))}}X($,"propTypes",{contentPack:h().object,onGetEntities:h().func,onStateChange:h().func,onSave:h().func,fetchedEntities:h().array,entityIndex:h().object,selectedEntities:h().object,appliedParameter:h().object,edit:h().bool}),X($,"defaultProps",{edit:!1,contentPack:void 0,onGetEntities:()=>{},onStateChange:()=>{},onSave:()=>{},fetchedEntities:[],entityIndex:{},selectedEntities:{},appliedParameter:{}});const ye=$},FKyXQK1p:(W,D,s)=>{s.d(D,{V:()=>O,P:()=>J});var B=s("JnTtTRmZ"),h=s.n(B),e=s("t5bvLtVB"),E=s.n(e),k=s("MdYBRjRJ"),x=s("U1Iufsob"),A=s("eFxcQyPT"),j=s("VPaD/Np4"),T=s.n(j);class i{constructor(d,P,v){this._value={id:d,title:P,type:v}}get id(){return this._value.id}get type(){return this._value.type}get title(){return this._value.title}toBuilder(){const{id:d,title:P,type:v}=this._value;return new b(T().Map({id:d,title:P,type:v}))}static create(d,P,v){return new i(d,P,v)}toJSON(){const{id:d,type:P}=this._value;return{id:d,type:P}}get isEntityIndex(){return!0}static[Symbol.hasInstance](d){return!!d.isEntityIndex}static fromJSON(d){const{id:P,title:v,type:I}=d;return i.create(P,v,I)}}class b{constructor(d=T().Map()){this.value=d}id(d){return new b(this.value.set("id",d))}title(d){return new b(this.value.set("title",d))}type(d){return new b(this.value.set("type",d))}build(){const{id:d,title:P,type:v}=this.value.toObject();return new i(d,P,v)}}var M=s("IA3Ku5lS");const O=(0,M.rN)("core.Catalog",()=>h().createActions({showEntityIndex:{asyncResult:!0},getSelectedEntities:{asyncResult:!0}})),J=(0,M.Bv)("core.Catalog",()=>h().createStore({listenables:[O],getInitialState(){return{entityIndex:void 0}},showEntityIndex(){const R=k.H3(x.A.CatalogsController.showEntityIndex().url),d=(0,A.Ay)("GET",R).then(P=>{const v=E()(P.entities.map(I=>i.fromJSON(I)),"type.name");return this.trigger({entityIndex:v}),P});O.showEntityIndex.promise(d)},getSelectedEntities(R){const d=Object.keys(R).reduce((I,K)=>I.concat(R[K].filter(F=>F instanceof i).map(F=>F.toJSON())),[]),P=k.H3(x.A.CatalogsController.queryEntities().url),v=(0,A.Ay)("POST",P,{entities:d});O.getSelectedEntities.promise(v)}}))}}]);})();
//# sourceMappingURL=bb8c8232-2608.4c48be2d13205f6f53fe.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy