Add API tokens support (#9)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Make it possible to create token authorized to query predetermined set of routes. Reviewed-on: #9 Co-authored-by: Pierre HUBERT <pierre.git@communiquons.org> Co-committed-by: Pierre HUBERT <pierre.git@communiquons.org>
This commit is contained in:
@ -22,14 +22,16 @@ export function IPInput(p: {
|
||||
export function IPInputWithMask(p: {
|
||||
label: string;
|
||||
editable: boolean;
|
||||
ipAndMask?: string;
|
||||
ip?: string;
|
||||
mask?: number;
|
||||
onValueChange?: (ip?: string, mask?: number) => void;
|
||||
onValueChange?: (ip?: string, mask?: number, ipAndMask?: string) => void;
|
||||
version: 4 | 6;
|
||||
}): React.ReactElement {
|
||||
const showSlash = React.useRef(!!p.mask);
|
||||
|
||||
const currValue =
|
||||
p.ipAndMask ??
|
||||
(p.ip ?? "") + (p.mask || showSlash.current ? "/" : "") + (p.mask ?? "");
|
||||
|
||||
const { onValueChange, ...props } = p;
|
||||
@ -38,7 +40,7 @@ export function IPInputWithMask(p: {
|
||||
onValueChange={(v) => {
|
||||
showSlash.current = false;
|
||||
if (!v) {
|
||||
onValueChange?.(undefined, undefined);
|
||||
onValueChange?.(undefined, undefined, undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -52,7 +54,11 @@ export function IPInputWithMask(p: {
|
||||
mask = sanitizeMask(p.version, split[1]);
|
||||
}
|
||||
|
||||
onValueChange?.(ip, mask);
|
||||
onValueChange?.(
|
||||
ip,
|
||||
mask,
|
||||
mask || showSlash.current ? `${ip}/${mask ?? ""}` : ip
|
||||
);
|
||||
}}
|
||||
value={currValue}
|
||||
{...props}
|
||||
|
@ -16,7 +16,7 @@ export interface SelectOption {
|
||||
export function SelectInput(p: {
|
||||
value?: string;
|
||||
editable: boolean;
|
||||
label: string;
|
||||
label?: string;
|
||||
options: SelectOption[];
|
||||
onValueChange: (o?: string) => void;
|
||||
}): React.ReactElement {
|
||||
@ -29,7 +29,7 @@ export function SelectInput(p: {
|
||||
|
||||
return (
|
||||
<FormControl fullWidth variant="standard" style={{ marginBottom: "15px" }}>
|
||||
<InputLabel>{p.label}</InputLabel>
|
||||
{p.label && <InputLabel>{p.label}</InputLabel>}
|
||||
<Select
|
||||
value={p.value ?? ""}
|
||||
label={p.label}
|
||||
|
Reference in New Issue
Block a user