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

web-interface.assets.07ba022f-1235.f297873291d379b3c9b4.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([["07ba022f-1235"],{uUb5y2xn:(G,D,a)=>{a.d(D,{Z:()=>O});var w=a("pmX897Fv"),h=a.n(w),e=a("DjJvgDaP"),T=a.n(e),P=T()(h());P.push([G.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:""}]),P.locals={contentPackEntity:"px9Gw1DZOqXRLhrnJC1w"};const O=P},FhPlv95w:(G,D,a)=>{a.d(D,{Z:()=>ke});var w=a("ii0bleBb"),h=a.n(w),e=a("Z7aTuO5B"),T=a("VgplIV7d"),P=a("/GOzvPf6"),O=a("znhYcHoq"),Z=a("IW7priiX"),R=a.n(Z),B=a("J6y4/h8P"),k=a("4E3oowBb"),l=a("uZqmR+ju"),j=a("S6FuRS7B"),x=a("PAFhOglk"),J=a("MdYBRjRJ"),I=a("Kz+u8q89"),d=a("dFpwyWHg"),f=a.n(d),v=a("C2ikvoS0"),b=a.n(v),W=a("1IntWRSu"),F=a.n(W),ne=a("8nGWeFnd"),ae=a.n(ne),se=a("TeAcaicX"),re=a.n(se),oe=a("eE3+5goe"),ie=a.n(oe),M=a("uUb5y2xn"),A={};A.styleTagTransform=ie(),A.setAttributes=ae(),A.insert=F().bind(null,"head"),A.domAPI=b(),A.insertStyleElement=re();var be=f()(M.Z,A);const H=M.Z&&M.Z.locals?M.Z.locals:void 0;var le=Object.defineProperty,ce=(i,s,n)=>s in i?le(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,C=(i,s,n)=>(ce(i,typeof s!="symbol"?s+"":s,n),n);const de=B.default.span`
  overflow-wrap: anywhere;
`,z=(0,B.default)(P.JO)(({theme:i})=>`
  padding-top: ${i.spacings.xxs};
  padding-right: ${i.spacings.xxs};
`),pe=i=>i instanceof x.Z?e.createElement(e.Fragment,null,e.createElement(z,{name:"archive",className:H.contentPackEntity})," ",e.createElement("span",null,i.title)):e.createElement(e.Fragment,null,e.createElement(z,{name:"server"})," ",e.createElement(de,null,i.title)),K=class te extends e.Component{constructor(s){super(s),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,J.er)(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,j.n6)(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=R()(r);c[m]=c[m]||[];const u=c[m].findIndex(E=>E.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,E=R()(r);c?E[t]?E[t]=[...E[t],...u[t]]:E[t]=u[t]:this._isGroupSelected(t)?E[t]=[]:E[t]=o[t],this._handleTouched("selection"),this._validate(E),m({selectedEntities:E})}),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:R()(r),isFiltered:!1,filter:o});return}const m=Object.keys(r).reduce((c,u)=>{const E=R()(c);return E[u]=r[u].filter(g=>RegExp(o,"i").test(g.title)),E},{});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(s){const n=s.split("_").join(" ");return n[0].toUpperCase()+n.substr(1)}UNSAFE_componentWillReceiveProps(s){this.setState({filteredEntities:s.entities,contentPack:s.contentPack});const{filter:n,isFiltered:p}=this.state;p&&this._filterEntities(n)}render(){const{filteredEntities:s={},errors:n,touched:p,isFiltered:t,contentPack:r}=this.state,{edit:o}=this.props,m=Object.keys(s).sort((c,u)=>(0,k.S)(c,u)).map(c=>{const u=s[c],E=u.sort((g,y)=>(0,k.S)(g.title,y.title)).map(g=>{const y=this._isSelected(g),L=pe(g);return e.createElement(P.oL,{onChange:()=>this._updateSelectionEntity(g),key:g.id,checked:y,expandable:!1,padded:!1,header:L})});return u.length<=0?null:e.createElement(P.oL,{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(P.BR,null,E))});return e.createElement("div",null,e.createElement(l.Row,null,e.createElement(l.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(l.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(l.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(l.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(l.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(l.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(l.Row,null,e.createElement(l.Col,{smOffset:1,lg:8},e.createElement("h2",null,"Content Pack selection"),o&&e.createElement(l.HelpBlock,null,"You can select between installed entities from the server (",e.createElement(P.JO,{name:"server"}),") or entities from the former content pack revision (",e.createElement(P.JO,{name:"archive",className:H.contentPackEntity}),")."))),e.createElement(l.Row,null,e.createElement(l.Col,{smOffset:1,lg:8},e.createElement(P.UI,{id:"filter-input",onSearch:this._onSetFilter,onReset:this._onClearFilter}))),e.createElement(l.Row,null,e.createElement(l.Col,{smOffset:1,sm:8,lg:8},p.selection&&n.selection&&e.createElement(I.Z,{error:n.selection}),e.createElement(P.BR,null,m))))}};C(K,"propTypes",{contentPack:h().object.isRequired,onStateChange:h().func,entities:h().object,selectedEntities:h().object,edit:h().bool}),C(K,"defaultProps",{edit:!1,onStateChange:()=>{},entities:{},selectedEntities:{}});const me=K;var Y=a("G9zy4OD/"),he=a("tq3qR0En"),Q=a("vyEB9hoZ"),_=a("4Bzr8nEu"),ue=Object.defineProperty,Pe=(i,s,n)=>s in i?ue(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,q=(i,s,n)=>(Pe(i,typeof s!="symbol"?s+"":s,n),n);class V 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(l.Button,{id:"download",bsStyle:"info",onClick:this.props.onSave},"Create and Download"))}render(){return e.createElement("div",null,e.createElement(l.Row,null,e.createElement(l.Col,{sm:6},e.createElement(Y.Z,{contentPack:this.props.contentPack})),e.createElement(l.Col,{sm:6},e.createElement(he.Z,{constraints:this.props.contentPack.constraints,isFulfilled:!0}),e.createElement(Q.Z,{contentPack:this.props.contentPack,readOnly:!0}),e.createElement(_.Z,{contentPack:this.props.contentPack,readOnly:!0}))),e.createElement(l.Row,null,e.createElement(l.Col,{sm:6},e.createElement(l.Button,{id:"create",bsStyle:"primary",onClick:this.props.onSave},"Create"),"\xA0",this._renderDownload())))}}q(V,"propTypes",{contentPack:h().object.isRequired,onSave:h().func}),q(V,"defaultProps",{onSave:()=>{}});const fe=V;var Ee=a("Jb16h681"),ee=a.n(Ee),N=a("QdZ7Yq43"),ve=Object.defineProperty,Ce=(i,s,n)=>s in i?ve(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,S=(i,s,n)=>(Ce(i,typeof s!="symbol"?s+"":s,n),n);class U extends e.Component{constructor(s){super(s),S(this,"_addNewParameter",(n,p)=>{let t=this.props.contentPack.toBuilder();const r=N.Z.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=N.Z.clone(this.props.appliedParameter);o[n]=o[n]||[],o[n].push(r),this.props.onStateChange({appliedParameter:o})}),S(this,"_onParameterClear",(n,p)=>{const t=N.Z.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=N.Z.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(l.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(l.Row,null,e.createElement(l.Col,{smOffset:1,sm:9},e.createElement(_.Z,{contentPack:this.props.contentPack,onAddParameter:this._addNewParameter,onDeleteParameter:this._openConfirmModal,appliedParameter:this.props.appliedParameter}),this._confirmationModal())),e.createElement(l.Row,null,e.createElement(l.Col,{smOffset:1,sm:9},e.createElement(Q.Z,{contentPack:this.props.contentPack,onParameterClear:this._onParameterClear,onParameterApply:this._onParameterApply,appliedParameter:this.props.appliedParameter}))))}}S(U,"propTypes",{contentPack:h().object.isRequired,onStateChange:h().func,appliedParameter:h().object.isRequired}),S(U,"defaultProps",{onStateChange:()=>{}}),S(U,"emptyParameter",{name:"",title:"",description:"",type:"string",default_value:""});const ge=U;var Se=Object.defineProperty,ye=(i,s,n)=>s in i?Se(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,X=(i,s,n)=>(ye(i,typeof s!="symbol"?s+"":s,n),n);class $ extends e.Component{constructor(s){super(s),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 s=this.props.contentPack,{selectedEntities:n}=this.props,p=Object.keys(n).reduce((t,r)=>t+n[r].length,0)>0;return!(s.name&&s.summary&&s.vendor&&p)}_disablePreview(){return this.state.selectedStep==="selection"||!this.state.selectedStep}_prepareForPreview(){const s=this.props.fetchedEntities.map(p=>{const t=this.props.appliedParameter[p.id]||[],r=p.toBuilder(),o=new O.Z(p.data),m=o.getPaths();return Object.keys(m).forEach(c=>{const u=t.findIndex(E=>E.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(s).build();this.props.onStateChange({contentPack:n})}render(){if(!this.props.contentPack)return e.createElement(P.$j,null);const s=e.createElement(me,{contentPack:this.props.contentPack,selectedEntities:this.props.selectedEntities,edit:this.props.edit,onStateChange:this.props.onStateChange,entities:this.props.entityIndex}),n=e.createElement(ge,{contentPack:this.props.contentPack,onStateChange:this.props.onStateChange,appliedParameter:this.props.appliedParameter}),p=e.createElement(fe,{contentPack:this.props.contentPack,onSave:this.props.onSave}),t=[{key:"selection",title:"Content Selection",component:s},{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(P.en,{steps:t,onStepChange:this._stepChanged,affixed:!0},this.state.selectedStep!=="preview"?e.createElement(T.P6,{viewportOffsetTop:65},e.createElement("div",null,e.createElement(Y.Z,{contentPack:this.props.contentPack}))):void 0),e.createElement(P.xE,{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 ke=$},FKyXQK1p:(G,D,a)=>{a.d(D,{h:()=>x,Z:()=>J});var w=a("JnTtTRmZ"),h=a.n(w),e=a("t5bvLtVB"),T=a.n(e),P=a("MdYBRjRJ"),O=a("U1Iufsob"),Z=a("eFxcQyPT"),R=a("VPaD/Np4"),B=a.n(R);class k{constructor(d,f,v){this._value={id:d,title:f,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:f,type:v}=this._value;return new l(B().Map({id:d,title:f,type:v}))}static create(d,f,v){return new k(d,f,v)}toJSON(){const{id:d,type:f}=this._value;return{id:d,type:f}}get isEntityIndex(){return!0}static[Symbol.hasInstance](d){return!!d.isEntityIndex}static fromJSON(d){const{id:f,title:v,type:b}=d;return k.create(f,v,b)}}class l{constructor(d=B().Map()){this.value=d}id(d){return new l(this.value.set("id",d))}title(d){return new l(this.value.set("title",d))}type(d){return new l(this.value.set("type",d))}build(){const{id:d,title:f,type:v}=this.value.toObject();return new k(d,f,v)}}var j=a("IA3Ku5lS");const x=(0,j.ei)("core.Catalog",()=>h().createActions({showEntityIndex:{asyncResult:!0},getSelectedEntities:{asyncResult:!0}})),J=(0,j.dS)("core.Catalog",()=>h().createStore({listenables:[x],getInitialState(){return{entityIndex:void 0}},showEntityIndex(){const I=P.DC(O.Z.CatalogsController.showEntityIndex().url),d=(0,Z.ZP)("GET",I).then(f=>{const v=T()(f.entities.map(b=>k.fromJSON(b)),"type.name");return this.trigger({entityIndex:v}),f});x.showEntityIndex.promise(d)},getSelectedEntities(I){const d=Object.keys(I).reduce((b,W)=>b.concat(I[W].filter(F=>F instanceof k).map(F=>F.toJSON())),[]),f=P.DC(O.Z.CatalogsController.queryEntities().url),v=(0,Z.ZP)("POST",f,{entities:d});x.getSelectedEntities.promise(v)}}))}}]);})();

//# sourceMappingURL=07ba022f-1235.f297873291d379b3c9b4.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy