more frontend for clients

This commit is contained in:
miloschwartz 2025-02-21 17:13:23 -05:00
parent 204403da67
commit 3830ad65fc
No known key found for this signature in database
3 changed files with 22 additions and 21 deletions

View file

@ -77,11 +77,11 @@ export async function pickClientDefaults(
const parsedSite = sitesRequiredFields.safeParse(site); const parsedSite = sitesRequiredFields.safeParse(site);
if (!parsedSite.success) { if (!parsedSite.success) {
logger.error("Unable to pick client defaults because: " + fromError(parsedSite.error).toString());
return next( return next(
createHttpError( createHttpError(
HttpCode.BAD_REQUEST, HttpCode.BAD_REQUEST,
"Unable to pick client defaults because: " + "Site is not configured to accept client connectivity"
fromError(parsedSite.error).toString()
) )
); );
} }

View file

@ -20,7 +20,7 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
const newt = client as Newt; const newt = client as Newt;
logger.debug(JSON.stringify(message.data)); logger.debug(JSON.stringify(message.data));
logger.debug("Handling Newt get config message!"); logger.debug("Handling Newt get config message!");
@ -60,7 +60,7 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
let site: Site | undefined; let site: Site | undefined;
if (!site) { if (!site) {
const address = await getNextAvailableSubnet(); const address = await getNextAvailableSubnet();
const listenPort = await getNextAvailablePort(); const listenPort = await getNextAvailablePort();
// create a new exit node // create a new exit node
const [updateRes] = await db const [updateRes] = await db

View file

@ -110,10 +110,13 @@ export default function CreateClientForm({
const res = await api.get<AxiosResponse<ListSitesResponse>>( const res = await api.get<AxiosResponse<ListSitesResponse>>(
`/org/${orgId}/sites/` `/org/${orgId}/sites/`
); );
setSites(res.data.data.sites); const sites = res.data.data.sites.filter(
(s) => s.type === "newt" && s.subnet
);
setSites(sites);
if (res.data.data.sites.length > 0) { if (sites.length > 0) {
form.setValue("siteId", res.data.data.sites[0].siteId); form.setValue("siteId", sites[0].siteId);
} }
}; };
@ -289,32 +292,30 @@ export default function CreateClientForm({
</Popover> </Popover>
<FormDescription> <FormDescription>
The client will be have connectivity to this The client will be have connectivity to this
site. site. The site must be configured to accept
client connections.
</FormDescription> </FormDescription>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
<div className="w-full"> {olmCommand && (
<div className="mb-2"> <div className="w-full">
<Collapsible <div className="mb-2">
open={isOpen}
onOpenChange={setIsOpen}
className="space-y-2"
>
<div className="mx-auto"> <div className="mx-auto">
<CopyTextBox <CopyTextBox
text={olmCommand || ""} text={olmCommand}
wrapText={false} wrapText={false}
/> />
</div> </div>
</Collapsible> </div>
<span className="text-sm text-muted-foreground">
You will only be able to see the configuration
once.
</span>
</div> </div>
<span className="text-sm text-muted-foreground"> )}
You will only be able to see the configuration once.
</span>
</div>
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<Checkbox <Checkbox