import React from 'react'; import { dataqueryService, authenticationService } from '@/_services'; import { ToastContainer, toast } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; class QueryManager extends React.Component { constructor(props) { super(props); this.state = { currentUser: authenticationService.currentUserValue, appId: props.appId, dataSources: props.dataSources, }; } componentDidMount() { this.state = { appId: this.props.appId, dataSources: this.props.dataSources, }; } changeDataSource = (sourceId) => { const source = this.state.dataSources.find(source => source.id === sourceId); this.setState({ selectedDataSource: source }); } createDataQuery = () => { const { appId, options, selectedDataSource } = this.state; const name = selectedDataSource.name; const kind = selectedDataSource.kind; dataqueryService.create(appId, name, kind, options).then((data) => { this.setState( { showModal: false } ); toast.success('Datasource Added', { hideProgressBar: true, position: "top-center", }); }); } optionchanged = (option, value) => { this.setState( { options: { ...this.state.options, [option]: value } } ); } render() { const { dataSources, selectedDataSource } = this.state; return (
{dataSources && } {selectedDataSource &&
{ selectedDataSource.kind === 'postgresql' &&
}
}
) } } export { QueryManager };