ui(admin): add new node page

This commit is contained in:
Matthew Penner 2021-09-12 21:22:33 -06:00
parent 3c01dbbcc5
commit d0a78ec067
No known key found for this signature in database
GPG key ID: 030E4AB751DC756F
15 changed files with 362 additions and 176 deletions

View file

@ -35,7 +35,7 @@ function CreateAllocationForm ({ nodeId }: { nodeId: string | number }) {
}, [ nodeId ]);
const isValidIP = (inputValue: string): boolean => {
// TODO: Better way of checking for a valid ip (and CIDR).
// TODO: Better way of checking for a valid ip (and CIDR)
return inputValue.match(/^([0-9a-f.:/]+)$/) !== null;
};
@ -44,11 +44,11 @@ function CreateAllocationForm ({ nodeId }: { nodeId: string | number }) {
return inputValue.match(/^([0-9-]+)$/) !== null;
};
const submit = (values: Values, { setSubmitting }: FormikHelpers<Values>) => {
const submit = ({ ips, ports, alias }: Values, { setSubmitting }: FormikHelpers<Values>) => {
setSubmitting(false);
values.ips.forEach(async (ip) => {
const allocations = await createAllocation(nodeId, { ip, ports: values.ports, alias: values.alias }, [ 'server' ]);
ips.forEach(async (ip) => {
const allocations = await createAllocation(nodeId, { ip, ports, alias }, [ 'server' ]);
await mutate(data => ({ ...data!, items: { ...data!.items!, ...allocations } }));
});
};