mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-03 08:39:09 +00:00
Working on targets
This commit is contained in:
@@ -42,17 +42,14 @@ import {
|
||||
FaFreebsd,
|
||||
FaWindows
|
||||
} from "react-icons/fa";
|
||||
import {
|
||||
SiNixos,
|
||||
SiKubernetes
|
||||
} from "react-icons/si";
|
||||
import { SiNixos, SiKubernetes } from "react-icons/si";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
|
||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||
import {
|
||||
CreateClientBody,
|
||||
CreateClientResponse,
|
||||
PickClientDefaultsResponse,
|
||||
PickClientDefaultsResponse
|
||||
} from "@server/routers/client";
|
||||
import { ListSitesResponse } from "@server/routers/site";
|
||||
import { toast } from "@app/hooks/useToast";
|
||||
@@ -93,18 +90,7 @@ export default function Page() {
|
||||
.min(2, { message: t("nameMin", { len: 2 }) })
|
||||
.max(30, { message: t("nameMax", { len: 30 }) }),
|
||||
method: z.enum(["olm"]),
|
||||
siteIds: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
text: z.string()
|
||||
})
|
||||
)
|
||||
.refine((val) => val.length > 0, {
|
||||
message: t("siteRequired")
|
||||
}),
|
||||
subnet: z.union([z.ipv4(), z.ipv6()])
|
||||
.refine((val) => val.length > 0, {
|
||||
subnet: z.union([z.ipv4(), z.ipv6()]).refine((val) => val.length > 0, {
|
||||
message: t("subnetRequired")
|
||||
})
|
||||
});
|
||||
@@ -123,10 +109,6 @@ export default function Page() {
|
||||
]);
|
||||
|
||||
const [loadingPage, setLoadingPage] = useState(true);
|
||||
const [sites, setSites] = useState<Tag[]>([]);
|
||||
const [activeSitesTagIndex, setActiveSitesTagIndex] = useState<
|
||||
number | null
|
||||
>(null);
|
||||
|
||||
const [platform, setPlatform] = useState<Platform>("unix");
|
||||
const [architecture, setArchitecture] = useState("All");
|
||||
@@ -236,12 +218,11 @@ export default function Page() {
|
||||
}
|
||||
};
|
||||
|
||||
const form = useForm({
|
||||
const form = useForm<CreateClientFormValues>({
|
||||
resolver: zodResolver(createClientFormSchema),
|
||||
defaultValues: {
|
||||
name: "",
|
||||
method: "olm",
|
||||
siteIds: [],
|
||||
subnet: ""
|
||||
}
|
||||
});
|
||||
@@ -330,7 +311,7 @@ export default function Page() {
|
||||
const latestVersion = data.tag_name;
|
||||
olmVersion = latestVersion;
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.name === 'AbortError') {
|
||||
if (error instanceof Error && error.name === "AbortError") {
|
||||
console.error(t("olmErrorFetchTimeout"));
|
||||
} else {
|
||||
console.error(
|
||||
@@ -456,13 +437,17 @@ export default function Page() {
|
||||
<FormControl>
|
||||
<Input
|
||||
autoComplete="off"
|
||||
placeholder={t("subnetPlaceholder")}
|
||||
placeholder={t(
|
||||
"subnetPlaceholder"
|
||||
)}
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<FormDescription>
|
||||
{t("addressDescription")}
|
||||
{t(
|
||||
"addressDescription"
|
||||
)}
|
||||
</FormDescription>
|
||||
</FormItem>
|
||||
)}
|
||||
@@ -536,7 +521,9 @@ export default function Page() {
|
||||
{t("clientOlmCredentials")}
|
||||
</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
{t("clientOlmCredentialsDescription")}
|
||||
{t(
|
||||
"clientOlmCredentialsDescription"
|
||||
)}
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
<SettingsSectionBody>
|
||||
|
||||
@@ -86,19 +86,20 @@ export default function CreateInternalResourceDialog({
|
||||
.string()
|
||||
.min(1, t("createInternalResourceDialogNameRequired"))
|
||||
.max(255, t("createInternalResourceDialogNameMaxLength")),
|
||||
mode: z.enum(["host", "cidr", "port"]),
|
||||
// mode: z.enum(["host", "cidr", "port"]),
|
||||
mode: z.enum(["host", "cidr"]),
|
||||
destination: z.string().min(1),
|
||||
siteId: z.int().positive(t("createInternalResourceDialogPleaseSelectSite")),
|
||||
protocol: z.enum(["tcp", "udp"]),
|
||||
proxyPort: z.int()
|
||||
.positive()
|
||||
.min(1, t("createInternalResourceDialogProxyPortMin"))
|
||||
.max(65535, t("createInternalResourceDialogProxyPortMax")),
|
||||
destinationPort: z.int()
|
||||
.positive()
|
||||
.min(1, t("createInternalResourceDialogDestinationPortMin"))
|
||||
.max(65535, t("createInternalResourceDialogDestinationPortMax"))
|
||||
.nullish(),
|
||||
// proxyPort: z.int()
|
||||
// .positive()
|
||||
// .min(1, t("createInternalResourceDialogProxyPortMin"))
|
||||
// .max(65535, t("createInternalResourceDialogProxyPortMax")),
|
||||
// destinationPort: z.int()
|
||||
// .positive()
|
||||
// .min(1, t("createInternalResourceDialogDestinationPortMin"))
|
||||
// .max(65535, t("createInternalResourceDialogDestinationPortMax"))
|
||||
// .nullish(),
|
||||
alias: z.string().nullish(),
|
||||
roles: z.array(
|
||||
z.object({
|
||||
@@ -119,42 +120,42 @@ export default function CreateInternalResourceDialog({
|
||||
})
|
||||
).optional()
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
if (data.mode === "port") {
|
||||
return data.protocol !== undefined && data.protocol !== null;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
{
|
||||
message: t("createInternalResourceDialogProtocol") + " is required for port mode",
|
||||
path: ["protocol"]
|
||||
}
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
if (data.mode === "port") {
|
||||
return data.proxyPort !== undefined && data.proxyPort !== null;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
{
|
||||
message: t("createInternalResourceDialogSitePort") + " is required for port mode",
|
||||
path: ["proxyPort"]
|
||||
}
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
if (data.mode === "port") {
|
||||
return data.destinationPort !== undefined && data.destinationPort !== null;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
{
|
||||
message: t("targetPort") + " is required for port mode",
|
||||
path: ["destinationPort"]
|
||||
}
|
||||
);
|
||||
// .refine(
|
||||
// (data) => {
|
||||
// if (data.mode === "port") {
|
||||
// return data.protocol !== undefined && data.protocol !== null;
|
||||
// }
|
||||
// return true;
|
||||
// },
|
||||
// {
|
||||
// error: t("createInternalResourceDialogProtocol") + " is required for port mode",
|
||||
// path: ["protocol"]
|
||||
// }
|
||||
// )
|
||||
// .refine(
|
||||
// (data) => {
|
||||
// if (data.mode === "port") {
|
||||
// return data.proxyPort !== undefined && data.proxyPort !== null;
|
||||
// }
|
||||
// return true;
|
||||
// },
|
||||
// {
|
||||
// error: t("createInternalResourceDialogSitePort") + " is required for port mode",
|
||||
// path: ["proxyPort"]
|
||||
// }
|
||||
// )
|
||||
// .refine(
|
||||
// (data) => {
|
||||
// if (data.mode === "port") {
|
||||
// return data.destinationPort !== undefined && data.destinationPort !== null;
|
||||
// }
|
||||
// return true;
|
||||
// },
|
||||
// {
|
||||
// error: t("targetPort") + " is required for port mode",
|
||||
// path: ["destinationPort"]
|
||||
// }
|
||||
// );
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
@@ -177,9 +178,9 @@ export default function CreateInternalResourceDialog({
|
||||
siteId: availableSites[0]?.siteId || 0,
|
||||
mode: "host",
|
||||
protocol: "tcp",
|
||||
proxyPort: undefined,
|
||||
// proxyPort: undefined,
|
||||
destination: "",
|
||||
destinationPort: undefined,
|
||||
// destinationPort: undefined,
|
||||
alias: "",
|
||||
roles: [],
|
||||
users: [],
|
||||
@@ -196,9 +197,9 @@ export default function CreateInternalResourceDialog({
|
||||
siteId: availableSites[0].siteId,
|
||||
mode: "host",
|
||||
protocol: "tcp",
|
||||
proxyPort: undefined,
|
||||
// proxyPort: undefined,
|
||||
destination: "",
|
||||
destinationPort: undefined,
|
||||
// destinationPort: undefined,
|
||||
alias: "",
|
||||
roles: [],
|
||||
users: [],
|
||||
@@ -260,8 +261,8 @@ export default function CreateInternalResourceDialog({
|
||||
name: data.name,
|
||||
mode: data.mode,
|
||||
protocol: data.mode === "port" ? data.protocol : undefined,
|
||||
proxyPort: data.mode === "port" ? data.proxyPort : undefined,
|
||||
destinationPort: data.mode === "port" ? data.destinationPort : undefined,
|
||||
// proxyPort: data.mode === "port" ? data.proxyPort : undefined,
|
||||
// destinationPort: data.mode === "port" ? data.destinationPort : undefined,
|
||||
destination: data.destination,
|
||||
enabled: true,
|
||||
alias: data.alias && typeof data.alias === "string" && data.alias.trim() ? data.alias : undefined
|
||||
@@ -452,7 +453,7 @@ export default function CreateInternalResourceDialog({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/*
|
||||
{mode === "port" && (
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
@@ -510,7 +511,7 @@ export default function CreateInternalResourceDialog({
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
)} */}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -541,7 +542,7 @@ export default function CreateInternalResourceDialog({
|
||||
)}
|
||||
/>
|
||||
|
||||
{mode === "port" && (
|
||||
{/* {mode === "port" && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="destinationPort"
|
||||
@@ -568,7 +569,7 @@ export default function CreateInternalResourceDialog({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
)} */}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user