first commit

This commit is contained in:
2024-02-03 14:07:41 +01:00
commit 1ff3f557a7
39 changed files with 165488 additions and 0 deletions

View File

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

View File

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

View File

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

50
src/web/index.jsx Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
// eslint-disable-next-line no-unused-vars
import webpackEntry from 'webpack-entry';
import { PluginManifest, PluginStore } from 'graylog-web-plugin/plugin';
import packageJson from '../../package.json';
//import StoreProvider from 'injection/StoreProvider';
// https://github.com/Graylog2/graylog2-server/blob/master/graylog2-web-interface/src/stores/plugins/PluginsStore.js ?
//const PStore = StoreProvider.getStore('core.Plugins')
debugger;
console.error('Before registering RedisLookup type lookupTableAdapters');
import RedisLookupAdapterDocumentation from './dataadapters/RedisLookupAdapterDocumentation';
import RedisLookupAdapterFieldSet from './dataadapters/RedisLookupAdapterFieldSet';
import RedisLookupAdapterSummary from './dataadapters/RedisLookupAdapterSummary';
const manifest = new PluginManifest(packageJson, {
lookupTableAdapters: [
{
type: 'RedisLookup',
displayName: 'Redis Lookup',
formComponent: RedisLookupAdapterFieldSet,
summaryComponent: RedisLookupAdapterSummary,
documentationComponent: RedisLookupAdapterDocumentation,
},
],
});
debugger;
console.error('Registering RedisLookup type lookupTableAdapters');
PluginStore.register(manifest);

42
src/web/index.jsx.raw Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import 'webpack-entry';
import { PluginManifest, PluginStore } from 'graylog-web-plugin/plugin';
import packageJson from '../../package.json';
const manifest = new PluginManifest(packageJson, {
/* This is the place where you define which entities you are providing to the web interface.
Right now you can add routes and navigation elements to it.
Examples: */
// Adding a route to /sample, rendering YourReactComponent when called:
// routes: [
// { path: '/sample', component: YourReactComponent, permissions: 'inputs:create' },
// ],
// Adding an element to the top navigation pointing to /sample named "Sample":
// navigation: [
// { path: '/sample', description: 'Sample' },
// ]
});
PluginStore.register(manifest);