const [clientName, setClientName] = useState('');
const [staticIp, setStaticIp] = useState('');
const [useStaticIp, setUseStaticIp] = useState(false);
+ // noinspection JSValidateTypes
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>Create New Client</DialogTitle>
value={useStaticIp}
onChange={(e) => setUseStaticIp(e.target.value)}
fullWidth
- >
+ variant='standard'>
<MenuItem value={false} >Dynamic IP</MenuItem>
<MenuItem value={true} >Static IP</MenuItem>
</Select>
const [password, setPassword] = useState('');*/
/*const [clientName, setClientName] = useState('');
const [staticIp, setStaticIp] = useState('');
- const [useStaticIp, setUseStaticIp] = useState(false);*/
- const [revokeClientName, setRevokeClientName] = useState('');
+ const [useStaticIp, setUseStaticIp] = useState(false);
+ const [revokeClientName, setRevokeClientName] = useState('');*/
const [clients, setClients] = useState([]);
const [availableClients, setAvailableClients] = useState( [] );
const [message, setMessage] = useState('');
const { clientName, useStaticIp, staticIp } = data;
e.preventDefault();
setMessage( await VPNService.createClient({ clientName, useStaticIp, staticIp }, fetchClients ) );
+ fetchAvailableClients().catch( e => setMessage( e ) );
setCreateOpen( false );
};
- const handleRevokeClientSubmit = async (e) => {
- e.preventDefault();
+ const handleRevokeClientSubmit = async ( revokeClientName ) => {
setMessage( await VPNService.revokeClient( { revokeClientName }, fetchClients ) );
+ fetchAvailableClients().catch( e => setMessage( e ) );
};
- console.log(availableClients);
-
return (
<Container>
<Button variant="contained" color="primary" onClick={() => setCreateOpen(true)}>Create Client</Button>
<Button type="submit" variant="contained" color="primary">Create Client</Button>
</form>*/}
- <Typography variant="h5" className="mt-6">Revoke OpenVPN Client</Typography>
+ {/*<Typography variant="h5" className="mt-6">Revoke OpenVPN Client</Typography>
<form onSubmit={handleRevokeClientSubmit} className="space-y-4">
<TextField
label="Client Name"
fullWidth
/>
<Button type="submit" variant="contained" color="secondary">Revoke Client</Button>
- </form>
+ </form>*/}
<Typography variant="h5" className="mt-6">Available OpenVPN Clients</Typography>
<MaterialReactTable
}, header: 'Active Certificate' },
{ accessorFn: row => clients.find( c => c.name === row.clientName ) ? 'Yes' : 'No', header: 'Connected' },
{ accessorFn: row => row.hasOvpn ? 'Yes' : 'No', header: 'Has Profile' },
+ {
+ header: 'Actions',
+ Cell: ({ row }) => (
+ <Button
+ variant="contained"
+ color="secondary"
+ onClick={() => handleRevokeClientSubmit(row.original.name)}
+ >
+ Delete
+ </Button>
+ ),
+ },
]}
data={availableClients}
/>