mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-06 15:50:42 +00:00
Fix some ui form issues
This commit is contained in:
@@ -14,7 +14,6 @@ if (fs.existsSync(allowedDevOriginsPath)) {
|
|||||||
try {
|
try {
|
||||||
const data = fs.readFileSync(allowedDevOriginsPath, "utf-8");
|
const data = fs.readFileSync(allowedDevOriginsPath, "utf-8");
|
||||||
allowedDevOrigins = JSON.parse(data);
|
allowedDevOrigins = JSON.parse(data);
|
||||||
console.log("Loaded allowed development origins:", allowedDevOrigins);
|
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export * from "./verifyApiKeyAccess";
|
|||||||
export * from "./verifySiteProvisioningKeyAccess";
|
export * from "./verifySiteProvisioningKeyAccess";
|
||||||
export * from "./verifyDomainAccess";
|
export * from "./verifyDomainAccess";
|
||||||
export * from "./verifyUserIsOrgOwner";
|
export * from "./verifyUserIsOrgOwner";
|
||||||
export * from "./verifyUserFromSessionOrHeaders";
|
export * from "./verifyUserFromResourceSession";
|
||||||
export * from "./verifySiteResourceAccess";
|
export * from "./verifySiteResourceAccess";
|
||||||
export * from "./logActionAudit";
|
export * from "./logActionAudit";
|
||||||
export * from "./verifyOlmAccess";
|
export * from "./verifyOlmAccess";
|
||||||
|
|||||||
@@ -117,17 +117,28 @@ export async function listBrowserGatewayTargets(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const targets = await db
|
const rows = await db
|
||||||
.select()
|
.select({
|
||||||
|
browserGatewayTargetId:
|
||||||
|
browserGatewayTarget.browserGatewayTargetId,
|
||||||
|
resourceId: browserGatewayTarget.resourceId,
|
||||||
|
siteId: browserGatewayTarget.siteId,
|
||||||
|
authToken: browserGatewayTarget.authToken,
|
||||||
|
type: browserGatewayTarget.type,
|
||||||
|
destination: browserGatewayTarget.destination,
|
||||||
|
destinationPort: browserGatewayTarget.destinationPort,
|
||||||
|
siteName: sites.name
|
||||||
|
})
|
||||||
.from(browserGatewayTarget)
|
.from(browserGatewayTarget)
|
||||||
|
.leftJoin(sites, eq(sites.siteId, browserGatewayTarget.siteId))
|
||||||
.where(eq(browserGatewayTarget.resourceId, resourceId))
|
.where(eq(browserGatewayTarget.resourceId, resourceId))
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset);
|
.offset(offset);
|
||||||
|
|
||||||
return response<ListBrowserGatewayTargetsResponse>(res, {
|
return response<ListBrowserGatewayTargetsResponse>(res, {
|
||||||
data: {
|
data: {
|
||||||
targets: targets,
|
targets: rows as any,
|
||||||
total: targets.length,
|
total: rows.length,
|
||||||
limit,
|
limit,
|
||||||
offset
|
offset
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ const listOrgsSchema = z.object({
|
|||||||
.pipe(z.int().nonnegative())
|
.pipe(z.int().nonnegative())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ListOrgsResponseDataSchema = z.object({
|
||||||
|
orgs: z.array(z.object({}).passthrough()),
|
||||||
|
pagination: z.object({
|
||||||
|
total: z.number(),
|
||||||
|
limit: z.number(),
|
||||||
|
offset: z.number()
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: "get",
|
method: "get",
|
||||||
path: "/orgs",
|
path: "/orgs",
|
||||||
@@ -51,15 +60,6 @@ export type ListOrgsResponse = {
|
|||||||
pagination: { total: number; limit: number; offset: number };
|
pagination: { total: number; limit: number; offset: number };
|
||||||
};
|
};
|
||||||
|
|
||||||
const ListOrgsResponseDataSchema = z.object({
|
|
||||||
orgs: z.array(z.object({}).passthrough()),
|
|
||||||
pagination: z.object({
|
|
||||||
total: z.number(),
|
|
||||||
limit: z.number(),
|
|
||||||
offset: z.number()
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
export async function listOrgs(
|
export async function listOrgs(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
|
|||||||
@@ -524,9 +524,7 @@ export async function createSiteResource(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (roleIds.length > 0) {
|
if (roleIds.length > 0) {
|
||||||
await trx
|
await trx.insert(roleSiteResources).values(
|
||||||
.insert(roleSiteResources)
|
|
||||||
.values(
|
|
||||||
roleIds.map((roleId) => ({
|
roleIds.map((roleId) => ({
|
||||||
roleId,
|
roleId,
|
||||||
siteResourceId
|
siteResourceId
|
||||||
@@ -535,9 +533,7 @@ export async function createSiteResource(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (userIds.length > 0) {
|
if (userIds.length > 0) {
|
||||||
await trx
|
await trx.insert(userSiteResources).values(
|
||||||
.insert(userSiteResources)
|
|
||||||
.values(
|
|
||||||
userIds.map((userId) => ({
|
userIds.map((userId) => ({
|
||||||
userId,
|
userId,
|
||||||
siteResourceId
|
siteResourceId
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
useTransition
|
useTransition
|
||||||
} from "react";
|
} from "react";
|
||||||
import CreatePrivateResourceDialog from "@app/components/CreateInternalResourceDialog";
|
import CreatePrivateResourceDialog from "@app/components/CreatePrivateResourceDialog";
|
||||||
import EditPrivateResourceDialog from "@app/components/EditPrivateResourceDialog";
|
import EditPrivateResourceDialog from "@app/components/EditPrivateResourceDialog";
|
||||||
import type { PaginationState } from "@tanstack/react-table";
|
import type { PaginationState } from "@tanstack/react-table";
|
||||||
import { ControlledDataTable } from "./ui/controlled-data-table";
|
import { ControlledDataTable } from "./ui/controlled-data-table";
|
||||||
|
|||||||
@@ -62,16 +62,13 @@ export default function CreatePrivateResourceDialog({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ssh" mode maps to "host" in the backend with SSH settings
|
|
||||||
const backendMode = data.mode === "ssh" ? "host" : data.mode;
|
|
||||||
|
|
||||||
await api.put<
|
await api.put<
|
||||||
AxiosResponse<{ data: { siteResourceId: number } }>
|
AxiosResponse<{ data: { siteResourceId: number } }>
|
||||||
>(`/org/${orgId}/site-resource`, {
|
>(`/org/${orgId}/site-resource`, {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
siteIds: data.siteIds,
|
siteIds: data.siteIds,
|
||||||
mode: backendMode,
|
mode: data.mode,
|
||||||
destination: data.destination,
|
destination: data.destination ?? undefined,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
...(data.mode === "http" && {
|
...(data.mode === "http" && {
|
||||||
scheme: data.scheme,
|
scheme: data.scheme,
|
||||||
|
|||||||
@@ -66,15 +66,12 @@ export default function EditPrivateResourceDialog({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ssh" mode maps to "host" in the backend with SSH settings
|
|
||||||
const backendMode = data.mode === "ssh" ? "host" : data.mode;
|
|
||||||
|
|
||||||
await api.post(`/site-resource/${resource.id}`, {
|
await api.post(`/site-resource/${resource.id}`, {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
siteIds: data.siteIds,
|
siteIds: data.siteIds,
|
||||||
mode: backendMode,
|
mode: data.mode,
|
||||||
niceId: data.niceId,
|
niceId: data.niceId,
|
||||||
destination: data.destination,
|
destination: data.destination ?? undefined,
|
||||||
...(data.mode === "http" && {
|
...(data.mode === "http" && {
|
||||||
scheme: data.scheme,
|
scheme: data.scheme,
|
||||||
ssl: data.ssl ?? false,
|
ssl: data.ssl ?? false,
|
||||||
|
|||||||
@@ -478,14 +478,12 @@ export function PrivateResourceForm({
|
|||||||
|
|
||||||
const [sshServerMode, setSshServerMode] = useState<"standard" | "native">(
|
const [sshServerMode, setSshServerMode] = useState<"standard" | "native">(
|
||||||
() => {
|
() => {
|
||||||
if (
|
if (variant === "edit" && resource) {
|
||||||
variant === "edit" &&
|
return resource.authDaemonMode === "native"
|
||||||
resource &&
|
? "native"
|
||||||
resource.authDaemonMode === "native"
|
: "standard";
|
||||||
) {
|
|
||||||
return "native";
|
|
||||||
}
|
}
|
||||||
return "standard";
|
return "native";
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -559,7 +557,7 @@ export function PrivateResourceForm({
|
|||||||
tcpPortRangeString: "*",
|
tcpPortRangeString: "*",
|
||||||
udpPortRangeString: "*",
|
udpPortRangeString: "*",
|
||||||
disableIcmp: false,
|
disableIcmp: false,
|
||||||
authDaemonMode: "site",
|
authDaemonMode: "native",
|
||||||
authDaemonPort: null,
|
authDaemonPort: null,
|
||||||
pamMode: "passthrough",
|
pamMode: "passthrough",
|
||||||
roles: [],
|
roles: [],
|
||||||
@@ -624,7 +622,7 @@ export function PrivateResourceForm({
|
|||||||
tcpPortRangeString: "*",
|
tcpPortRangeString: "*",
|
||||||
udpPortRangeString: "*",
|
udpPortRangeString: "*",
|
||||||
disableIcmp: false,
|
disableIcmp: false,
|
||||||
authDaemonMode: "site",
|
authDaemonMode: "native",
|
||||||
authDaemonPort: null,
|
authDaemonPort: null,
|
||||||
pamMode: "passthrough",
|
pamMode: "passthrough",
|
||||||
roles: [],
|
roles: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user