mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 05:36:00 +00:00
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import axios from 'axios';
|
|
import ModalBase from './ModalBase';
|
|
import { FormRow, FormLabel, FormValue, FormTextField, FormSelectField, FormSubmit } from '../utility/forms';
|
|
import { TextField } from '../utility/inputs';
|
|
import { Formik, Form } from 'formik';
|
|
// import FormikForm from '../utility/FormikForm';
|
|
|
|
export default function ConnectionModal({ modalState }) {
|
|
const [sqlConnectResult, setSqlConnectResult] = React.useState('Not connected');
|
|
|
|
const handleSubmit = async values => {
|
|
const resp = await axios.post('http://localhost:3000/connection/test', values);
|
|
console.log('resp.data', resp.data);
|
|
const { error, version } = resp.data;
|
|
|
|
setSqlConnectResult(error || version);
|
|
|
|
// modalState.close();
|
|
};
|
|
return (
|
|
<ModalBase modalState={modalState}>
|
|
<h2>Add connection</h2>
|
|
<Formik onSubmit={handleSubmit} initialValues={{ server: 'localhost', engine: 'mssql' }}>
|
|
<Form>
|
|
<FormSelectField label="Database engine" name="engine">
|
|
<option value="mssql">Microsoft SQL Server</option>
|
|
<option value="mysql">MySQL</option>
|
|
<option value="postgre">Postgre SQL</option>
|
|
</FormSelectField>
|
|
<FormTextField label="Server" name="server" />
|
|
<FormTextField label="Port" name="port" />
|
|
<FormTextField label="User" name="user" />
|
|
<FormTextField label="Password" name="password" />
|
|
<FormTextField label="Display name" name="displayName" />
|
|
|
|
<FormSubmit />
|
|
</Form>
|
|
</Formik>
|
|
<div>Connect result: {sqlConnectResult}</div>
|
|
</ModalBase>
|
|
);
|
|
}
|