mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-06 04:10:13 +00:00
add protocol filter
This commit is contained in:
@@ -123,6 +123,16 @@ const listResourcesSchema = z.object({
|
|||||||
description:
|
description:
|
||||||
"Filter resources based on health status of their targets. `healthy` means all targets are healthy. `degraded` means at least one target is unhealthy, but not all are unhealthy. `offline` means all targets are unhealthy. `unknown` means all targets have unknown health status."
|
"Filter resources based on health status of their targets. `healthy` means all targets are healthy. `degraded` means at least one target is unhealthy, but not all are unhealthy. `offline` means all targets are unhealthy. `unknown` means all targets have unknown health status."
|
||||||
}),
|
}),
|
||||||
|
protocol: z
|
||||||
|
.enum(["http", "https", "tcp", "udp", "ssh", "rdp", "vnc"])
|
||||||
|
.optional()
|
||||||
|
.catch(undefined)
|
||||||
|
.openapi({
|
||||||
|
type: "string",
|
||||||
|
enum: ["http", "https", "tcp", "udp", "ssh", "rdp", "vnc"],
|
||||||
|
description:
|
||||||
|
"Filter resources by protocol. `http` and `https` match HTTP resources without and with SSL respectively."
|
||||||
|
}),
|
||||||
siteId: z.coerce.number<string>().int().positive().optional().openapi({
|
siteId: z.coerce.number<string>().int().positive().optional().openapi({
|
||||||
type: "integer",
|
type: "integer",
|
||||||
description:
|
description:
|
||||||
@@ -437,6 +447,7 @@ export async function listResources(
|
|||||||
enabled,
|
enabled,
|
||||||
query,
|
query,
|
||||||
healthStatus,
|
healthStatus,
|
||||||
|
protocol,
|
||||||
sort_by,
|
sort_by,
|
||||||
order,
|
order,
|
||||||
siteId,
|
siteId,
|
||||||
@@ -632,6 +643,28 @@ export async function listResources(
|
|||||||
if (typeof healthStatus !== "undefined") {
|
if (typeof healthStatus !== "undefined") {
|
||||||
conditions.push(eq(resources.health, healthStatus));
|
conditions.push(eq(resources.health, healthStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof protocol !== "undefined") {
|
||||||
|
switch (protocol) {
|
||||||
|
case "http":
|
||||||
|
conditions.push(
|
||||||
|
and(
|
||||||
|
eq(resources.mode, "http"),
|
||||||
|
eq(resources.ssl, false)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "https":
|
||||||
|
conditions.push(
|
||||||
|
and(eq(resources.mode, "http"), eq(resources.ssl, true))
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
conditions.push(eq(resources.mode, protocol));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (siteId != null) {
|
if (siteId != null) {
|
||||||
const resourcesWithSite = db
|
const resourcesWithSite = db
|
||||||
.select({ resourceId: targets.resourceId })
|
.select({ resourceId: targets.resourceId })
|
||||||
|
|||||||
@@ -278,7 +278,50 @@ export default function PublicResourcesTable({
|
|||||||
accessorKey: "protocol",
|
accessorKey: "protocol",
|
||||||
friendlyName: t("protocol"),
|
friendlyName: t("protocol"),
|
||||||
enableHiding: true,
|
enableHiding: true,
|
||||||
header: () => <span className="p-3">{t("protocol")}</span>,
|
header: () => (
|
||||||
|
<ColumnFilterButton
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
value: "http",
|
||||||
|
label: t("editInternalResourceDialogModeHttp")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "https",
|
||||||
|
label: t("editInternalResourceDialogModeHttps")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "tcp",
|
||||||
|
label: t("editInternalResourceDialogTcp")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "udp",
|
||||||
|
label: t("editInternalResourceDialogUdp")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "ssh",
|
||||||
|
label: t("editInternalResourceDialogModeSsh")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "rdp",
|
||||||
|
label: t("rdpTitle")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "vnc",
|
||||||
|
label: t("vncTitle")
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
selectedValue={
|
||||||
|
searchParams.get("protocol") ?? undefined
|
||||||
|
}
|
||||||
|
onValueChange={(value) =>
|
||||||
|
handleFilterChange("protocol", value)
|
||||||
|
}
|
||||||
|
searchPlaceholder={t("searchPlaceholder")}
|
||||||
|
emptyMessage={t("emptySearchOptions")}
|
||||||
|
label={t("protocol")}
|
||||||
|
className="p-3"
|
||||||
|
/>
|
||||||
|
),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const resourceRow = row.original;
|
const resourceRow = row.original;
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user