reformat jsx files

This commit is contained in:
yo000 2025-02-08 10:20:40 +01:00
parent 3544104196
commit 43d91b9bd1
4 changed files with 241 additions and 243 deletions

View File

@ -1,36 +1,35 @@
/* /*
* Copyright (C) 2024 johan@nosd.in * Copyright (C) 2024 johan@nosd.in
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1, * it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc. * as published by MongoDB, Inc.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details. * Server Side Public License for more details.
* *
* You should have received a copy of the Server Side Public License * You should have received a copy of the Server Side Public License
* along with this program. If not, see * along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>. * <http://www.mongodb.com/licensing/server-side-public-license>.
*/ */
/* eslint-disable react/no-unescaped-entities, no-template-curly-in-string */ import React from 'react';
import React from 'react';
class RedisLookupAdapterDocumentation extends React.Component {
class RedisLookupAdapterDocumentation extends React.Component { render() {
render() { const style = { marginBottom: 10 };
const style = { marginBottom: 10 }; return (
return ( <div>
<div> <p style={style}>
<p style={style}> The Redis Lookup data adapter lookup redis for the given key and returns the values.<br/>
The Redis Lookup data adapter lookup redis for the given key and returns the values.<br/> It supports writing key/values to Redis (SET command). <br/>
It supports writing key/values to Redis (SET command). <br/> All created keys will have the TTL configured for the data adapter.
All created keys will have the TTL configured for the data adapter. </p>
</p> </div>
</div> )
) ;
; }
} }
}
export default RedisLookupAdapterDocumentation;
export default RedisLookupAdapterDocumentation;

View File

@ -1,116 +1,115 @@
/* /*
* Copyright (C) 2024 johan@nosd.in * Copyright (C) 2024 johan@nosd.in
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1, * it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc. * as published by MongoDB, Inc.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details. * Server Side Public License for more details.
* *
* You should have received a copy of the Server Side Public License * You should have received a copy of the Server Side Public License
* along with this program. If not, see * along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>. * <http://www.mongodb.com/licensing/server-side-public-license>.
*/ */
import React, { useCallback, useEffect, useRef, useState } from 'react'; import React, { useCallback, useEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
//import { Button } from 'components/graylog'; //import { Button } from 'components/graylog';
import { Input } from 'components/bootstrap'; import { Input } from 'components/bootstrap';
class RedisLookupAdapterFieldSet extends React.Component { class RedisLookupAdapterFieldSet extends React.Component {
static propTypes = { static propTypes = {
config: PropTypes.shape({ config: PropTypes.shape({
redis_host: PropTypes.string.isRequired, redis_host: PropTypes.string.isRequired,
}).isRequired, }).isRequired,
updateConfig: PropTypes.func.isRequired, updateConfig: PropTypes.func.isRequired,
handleFormEvent: PropTypes.func.isRequired, handleFormEvent: PropTypes.func.isRequired,
validationState: PropTypes.func.isRequired, validationState: PropTypes.func.isRequired,
validationMessage: PropTypes.func.isRequired, validationMessage: PropTypes.func.isRequired,
}; };
handleSelect = (fieldName) => { handleSelect = (fieldName) => {
return (selectedIndicator) => { return (selectedIndicator) => {
const config = lodash.cloneDeep(this.props.config); const config = lodash.cloneDeep(this.props.config);
config[fieldName] = selectedIndicator; config[fieldName] = selectedIndicator;
this.props.updateConfig(config); this.props.updateConfig(config);
}; };
}; };
render() { render() {
const { config } = this.props; const { config } = this.props;
return ( return (
<fieldset> <fieldset>
<Input type="text" <Input type="text"
id="redis_host" id="redis_host"
name="redis_host" name="redis_host"
label="Redis host" label="Redis host"
required required
onChange={this.props.handleFormEvent} onChange={this.props.handleFormEvent}
help={this.props.validationMessage('redis_host', 'Your Redis Host')} help={this.props.validationMessage('redis_host', 'Your Redis Host')}
bsStyle={this.props.validationState('redis_host')} bsStyle={this.props.validationState('redis_host')}
value={config.redis_host} value={config.redis_host}
labelClassName="col-sm-3" labelClassName="col-sm-3"
wrapperClassName="col-sm-9" /> wrapperClassName="col-sm-9" />
<Input type="text" <Input type="text"
id="redis_port" id="redis_port"
name="redis_port" name="redis_port"
label="Redis port" label="Redis port"
required required
onChange={this.props.handleFormEvent} onChange={this.props.handleFormEvent}
help={this.props.validationMessage('redis_port', 'Redis port instance is listening on')} help={this.props.validationMessage('redis_port', 'Redis port instance is listening on')}
bsStyle={this.props.validationState('redis_port')} bsStyle={this.props.validationState('redis_port')}
value={config.redis_port} value={config.redis_port}
labelClassName="col-sm-3" labelClassName="col-sm-3"
wrapperClassName="col-sm-9" /> wrapperClassName="col-sm-9" />
<Input type="text" <Input type="text"
id="redis_database" id="redis_database"
name="redis_database" name="redis_database"
label="Redis database" label="Redis database"
required required
onChange={this.props.handleFormEvent} onChange={this.props.handleFormEvent}
help={this.props.validationMessage('redis_database', 'Redis database')} help={this.props.validationMessage('redis_database', 'Redis database')}
bsStyle={this.props.validationState('redis_database')} bsStyle={this.props.validationState('redis_database')}
value={config.redis_database} value={config.redis_database}
labelClassName="col-sm-3" labelClassName="col-sm-3"
wrapperClassName="col-sm-9" /> wrapperClassName="col-sm-9" />
<Input type="text" <Input type="text"
id="redis_ttl" id="redis_ttl"
name="redis_ttl" name="redis_ttl"
label="Redis key TTL" label="Redis key TTL"
required required
onChange={this.props.handleFormEvent} onChange={this.props.handleFormEvent}
help={this.props.validationMessage('redis_ttl', 'Redis key TTL in seconds. Set -1 to not expire keys')} help={this.props.validationMessage('redis_ttl', 'Redis key TTL in seconds. Set -1 to not expire keys')}
bsStyle={this.props.validationState('redis_ttl')} bsStyle={this.props.validationState('redis_ttl')}
value={config.redis_ttl} value={config.redis_ttl}
labelClassName="col-sm-3" labelClassName="col-sm-3"
wrapperClassName="col-sm-9" /> wrapperClassName="col-sm-9" />
<Input type="text" <Input type="text"
id="redis_username" id="redis_username"
name="redis_username" name="redis_username"
label="Redis username" label="Redis username"
onChange={this.props.handleFormEvent} onChange={this.props.handleFormEvent}
help={this.props.validationMessage('redis_username', 'Redis username. Leave empty for no auth or "requirepass" authentication')} help={this.props.validationMessage('redis_username', 'Redis username. Leave empty for no auth or "requirepass" authentication')}
bsStyle={this.props.validationState('redis_username')} bsStyle={this.props.validationState('redis_username')}
value={config.redis_username} value={config.redis_username}
labelClassName="col-sm-3" labelClassName="col-sm-3"
wrapperClassName="col-sm-9" /> wrapperClassName="col-sm-9" />
<Input type="password" <Input type="password"
id="redis_password" id="redis_password"
label="Redis password" label="Redis password"
onChange={this.props.handleFormEvent} onChange={this.props.handleFormEvent}
help={this.props.validationMessage('redis_password', 'Redis password. Leave empty for no auth')} help={this.props.validationMessage('redis_password', 'Redis password. Leave empty for no auth')}
bsStyle={this.props.validationState('redis_password')} bsStyle={this.props.validationState('redis_password')}
value={config.redis_password} value={config.redis_password}
labelClassName="col-sm-3" labelClassName="col-sm-3"
wrapperClassName="col-sm-9"> wrapperClassName="col-sm-9">
</Input> </Input>
</fieldset> </fieldset>
); );
} }
} }
export default RedisLookupAdapterFieldSet;
export default RedisLookupAdapterFieldSet;

View File

@ -1,52 +1,52 @@
/* /*
* Copyright (C) 2024 johan@nosd.in * Copyright (C) 2024 johan@nosd.in
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1, * it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc. * as published by MongoDB, Inc.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details. * Server Side Public License for more details.
* *
* You should have received a copy of the Server Side Public License * You should have received a copy of the Server Side Public License
* along with this program. If not, see * along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>. * <http://www.mongodb.com/licensing/server-side-public-license>.
*/ */
// eslint-disable-next-line react/prefer-stateless-function // eslint-disable-next-line react/prefer-stateless-function
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
class RedisLookupAdapterSummary extends React.Component { class RedisLookupAdapterSummary extends React.Component {
static propTypes = { static propTypes = {
dataAdapter: PropTypes.shape({ dataAdapter: PropTypes.shape({
config: PropTypes.shape({ config: PropTypes.shape({
redis_host: PropTypes.string.isRequired, redis_host: PropTypes.string.isRequired,
}), }),
}), }),
}; };
render() { render() {
const { config } = this.props.dataAdapter; const { config } = this.props.dataAdapter;
return ( return (
<dl> <dl>
<dt>Redis host</dt> <dt>Redis host</dt>
<dd>{config.redis_host || 'n/a'}</dd> <dd>{config.redis_host || 'n/a'}</dd>
<dt>Redis port</dt> <dt>Redis port</dt>
<dd>{config.redis_port || 'n/a'}</dd> <dd>{config.redis_port || 'n/a'}</dd>
<dt>Redis database</dt> <dt>Redis database</dt>
<dd>{config.redis_database}</dd> <dd>{config.redis_database}</dd>
<dt>Redis key TTL</dt> <dt>Redis key TTL</dt>
<dd>{config.redis_ttl || 'n/a'}</dd> <dd>{config.redis_ttl || 'n/a'}</dd>
<dt>Redis username</dt> <dt>Redis username</dt>
<dd>{config.redis_username || 'n/a'}</dd> <dd>{config.redis_username || 'n/a'}</dd>
<dt>Redis password</dt> <dt>Redis password</dt>
<dd>******</dd> <dd>******</dd>
</dl> </dl>
); );
} }
} }
export default RedisLookupAdapterSummary; export default RedisLookupAdapterSummary;

View File

@ -1,39 +1,39 @@
/* /*
* Copyright (C) 2024 johan@nosd.in * Copyright (C) 2024 johan@nosd.in
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1, * it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc. * as published by MongoDB, Inc.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details. * Server Side Public License for more details.
* *
* You should have received a copy of the Server Side Public License * You should have received a copy of the Server Side Public License
* along with this program. If not, see * along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>. * <http://www.mongodb.com/licensing/server-side-public-license>.
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
import webpackEntry from 'webpack-entry'; import webpackEntry from 'webpack-entry';
import { PluginManifest, PluginStore } from 'graylog-web-plugin/plugin'; import { PluginManifest, PluginStore } from 'graylog-web-plugin/plugin';
import packageJson from '../../package.json'; import packageJson from '../../package.json';
import RedisLookupAdapterDocumentation from './dataadapters/RedisLookupAdapterDocumentation'; import RedisLookupAdapterDocumentation from './dataadapters/RedisLookupAdapterDocumentation';
import RedisLookupAdapterFieldSet from './dataadapters/RedisLookupAdapterFieldSet'; import RedisLookupAdapterFieldSet from './dataadapters/RedisLookupAdapterFieldSet';
import RedisLookupAdapterSummary from './dataadapters/RedisLookupAdapterSummary'; import RedisLookupAdapterSummary from './dataadapters/RedisLookupAdapterSummary';
const manifest = new PluginManifest(packageJson, { const manifest = new PluginManifest(packageJson, {
lookupTableAdapters: [ lookupTableAdapters: [
{ {
type: 'RedisLookup', type: 'RedisLookup',
displayName: 'Redis Lookup', displayName: 'Redis Lookup',
formComponent: RedisLookupAdapterFieldSet, formComponent: RedisLookupAdapterFieldSet,
summaryComponent: RedisLookupAdapterSummary, summaryComponent: RedisLookupAdapterSummary,
documentationComponent: RedisLookupAdapterDocumentation, documentationComponent: RedisLookupAdapterDocumentation,
}, },
], ],
}); });
PluginStore.register(manifest); PluginStore.register(manifest);