mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
fix hc port NaN issue
This commit is contained in:
@@ -1510,14 +1510,15 @@
|
|||||||
"enableHealthChecksDescription": "Monitor the health of this target. You can monitor a different endpoint than the target if required.",
|
"enableHealthChecksDescription": "Monitor the health of this target. You can monitor a different endpoint than the target if required.",
|
||||||
"healthScheme": "Method",
|
"healthScheme": "Method",
|
||||||
"healthSelectScheme": "Select Method",
|
"healthSelectScheme": "Select Method",
|
||||||
|
"healthCheckPortInvalid": "Health check port must be between 1 and 65535",
|
||||||
"healthCheckPath": "Path",
|
"healthCheckPath": "Path",
|
||||||
"healthHostname": "IP / Host",
|
"healthHostname": "IP / Host",
|
||||||
"healthPort": "Port",
|
"healthPort": "Port",
|
||||||
"healthCheckPathDescription": "The path to check for health status.",
|
"healthCheckPathDescription": "The path to check for health status.",
|
||||||
"healthyIntervalSeconds": "Healthy Interval",
|
"healthyIntervalSeconds": "Healthy Interval (sec)",
|
||||||
"unhealthyIntervalSeconds": "Unhealthy Interval",
|
"unhealthyIntervalSeconds": "Unhealthy Interval (sec)",
|
||||||
"IntervalSeconds": "Healthy Interval",
|
"IntervalSeconds": "Healthy Interval",
|
||||||
"timeoutSeconds": "Timeout",
|
"timeoutSeconds": "Timeout (sec)",
|
||||||
"timeIsInSeconds": "Time is in seconds",
|
"timeIsInSeconds": "Time is in seconds",
|
||||||
"retryAttempts": "Retry Attempts",
|
"retryAttempts": "Retry Attempts",
|
||||||
"expectedResponseCodes": "Expected Response Codes",
|
"expectedResponseCodes": "Expected Response Codes",
|
||||||
|
|||||||
@@ -691,6 +691,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
target.port <= 0 ||
|
target.port <= 0 ||
|
||||||
isNaN(target.port)
|
isNaN(target.port)
|
||||||
);
|
);
|
||||||
|
console.log(targetsWithInvalidFields);
|
||||||
if (targetsWithInvalidFields.length > 0) {
|
if (targetsWithInvalidFields.length > 0) {
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
@@ -1833,9 +1834,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
30
|
30
|
||||||
}}
|
}}
|
||||||
onChanges={async (config) => {
|
onChanges={async (config) => {
|
||||||
console.log("here");
|
|
||||||
if (selectedTargetForHealthCheck) {
|
if (selectedTargetForHealthCheck) {
|
||||||
console.log(config);
|
|
||||||
updateTargetHealthCheck(
|
updateTargetHealthCheck(
|
||||||
selectedTargetForHealthCheck.targetId,
|
selectedTargetForHealthCheck.targetId,
|
||||||
config
|
config
|
||||||
|
|||||||
@@ -80,17 +80,33 @@ export default function HealthCheckDialog({
|
|||||||
hcMethod: z
|
hcMethod: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, { message: t("healthCheckMethodRequired") }),
|
.min(1, { message: t("healthCheckMethodRequired") }),
|
||||||
hcInterval: z.int()
|
hcInterval: z
|
||||||
|
.int()
|
||||||
.positive()
|
.positive()
|
||||||
.min(5, { message: t("healthCheckIntervalMin") }),
|
.min(5, { message: t("healthCheckIntervalMin") }),
|
||||||
hcTimeout: z.int()
|
hcTimeout: z
|
||||||
|
.int()
|
||||||
.positive()
|
.positive()
|
||||||
.min(1, { message: t("healthCheckTimeoutMin") }),
|
.min(1, { message: t("healthCheckTimeoutMin") }),
|
||||||
hcStatus: z.int().positive().min(100).optional().nullable(),
|
hcStatus: z.int().positive().min(100).optional().nullable(),
|
||||||
hcHeaders: z.array(z.object({ name: z.string(), value: z.string() })).nullable().optional(),
|
hcHeaders: z
|
||||||
|
.array(z.object({ name: z.string(), value: z.string() }))
|
||||||
|
.nullable()
|
||||||
|
.optional(),
|
||||||
hcScheme: z.string().optional(),
|
hcScheme: z.string().optional(),
|
||||||
hcHostname: z.string(),
|
hcHostname: z.string(),
|
||||||
hcPort: z.number().positive().gt(0).lte(65535),
|
hcPort: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: t("healthCheckPortInvalid") })
|
||||||
|
.refine(
|
||||||
|
(val) => {
|
||||||
|
const port = parseInt(val);
|
||||||
|
return port > 0 && port <= 65535;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: t("healthCheckPortInvalid")
|
||||||
|
}
|
||||||
|
),
|
||||||
hcFollowRedirects: z.boolean(),
|
hcFollowRedirects: z.boolean(),
|
||||||
hcMode: z.string(),
|
hcMode: z.string(),
|
||||||
hcUnhealthyInterval: z.int().positive().min(5)
|
hcUnhealthyInterval: z.int().positive().min(5)
|
||||||
@@ -126,7 +142,9 @@ export default function HealthCheckDialog({
|
|||||||
hcHeaders: initialConfig?.hcHeaders,
|
hcHeaders: initialConfig?.hcHeaders,
|
||||||
hcScheme: getDefaultScheme(),
|
hcScheme: getDefaultScheme(),
|
||||||
hcHostname: initialConfig?.hcHostname,
|
hcHostname: initialConfig?.hcHostname,
|
||||||
hcPort: initialConfig?.hcPort,
|
hcPort: initialConfig?.hcPort
|
||||||
|
? initialConfig.hcPort.toString()
|
||||||
|
: "",
|
||||||
hcFollowRedirects: initialConfig?.hcFollowRedirects,
|
hcFollowRedirects: initialConfig?.hcFollowRedirects,
|
||||||
hcMode: initialConfig?.hcMode,
|
hcMode: initialConfig?.hcMode,
|
||||||
hcUnhealthyInterval: initialConfig?.hcUnhealthyInterval
|
hcUnhealthyInterval: initialConfig?.hcUnhealthyInterval
|
||||||
@@ -139,10 +157,15 @@ export default function HealthCheckDialog({
|
|||||||
try {
|
try {
|
||||||
const currentValues = form.getValues();
|
const currentValues = form.getValues();
|
||||||
const updatedValues = { ...currentValues, [fieldName]: value };
|
const updatedValues = { ...currentValues, [fieldName]: value };
|
||||||
await onChanges({
|
|
||||||
|
// Convert hcPort from string to number before passing to parent
|
||||||
|
const configToSend: HealthCheckConfig = {
|
||||||
...updatedValues,
|
...updatedValues,
|
||||||
|
hcPort: parseInt(updatedValues.hcPort),
|
||||||
hcStatus: updatedValues.hcStatus || null
|
hcStatus: updatedValues.hcStatus || null
|
||||||
});
|
};
|
||||||
|
|
||||||
|
await onChanges(configToSend);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast({
|
toast({
|
||||||
title: t("healthCheckError"),
|
title: t("healthCheckError"),
|
||||||
@@ -210,14 +233,20 @@ export default function HealthCheckDialog({
|
|||||||
{t("healthScheme")}
|
{t("healthScheme")}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
onValueChange={(value) => {
|
onValueChange={(
|
||||||
field.onChange(value);
|
value
|
||||||
|
) => {
|
||||||
|
field.onChange(
|
||||||
|
value
|
||||||
|
);
|
||||||
handleFieldChange(
|
handleFieldChange(
|
||||||
"hcScheme",
|
"hcScheme",
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
defaultValue={field.value}
|
defaultValue={
|
||||||
|
field.value
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
@@ -281,10 +310,8 @@ export default function HealthCheckDialog({
|
|||||||
{...field}
|
{...field}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value =
|
const value =
|
||||||
parseInt(
|
e.target
|
||||||
e.target
|
.value;
|
||||||
.value
|
|
||||||
);
|
|
||||||
field.onChange(
|
field.onChange(
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
@@ -483,10 +510,6 @@ export default function HealthCheckDialog({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormDescription>
|
|
||||||
{t("timeIsInSeconds")}
|
|
||||||
</FormDescription>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Expected Response Codes */}
|
{/* Expected Response Codes */}
|
||||||
@@ -544,7 +567,9 @@ export default function HealthCheckDialog({
|
|||||||
<HeadersInput
|
<HeadersInput
|
||||||
value={field.value}
|
value={field.value}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
field.onChange(value);
|
field.onChange(
|
||||||
|
value
|
||||||
|
);
|
||||||
handleFieldChange(
|
handleFieldChange(
|
||||||
"hcHeaders",
|
"hcHeaders",
|
||||||
value
|
value
|
||||||
|
|||||||
Reference in New Issue
Block a user