Skip to content

Commit 08b9c09

Browse files
committed
feat: add API port configuration to node modal and localization updates
1 parent 28428af commit 08b9c09

File tree

5 files changed

+46
-2
lines changed

5 files changed

+46
-2
lines changed

dashboard/public/statics/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,8 @@
13141314
"addressPlaceholder": "Enter node address",
13151315
"port": "Node Port",
13161316
"portPlaceholder": "Enter node port",
1317+
"apiPort": "API Port",
1318+
"apiPortPlaceholder": "Enter API port (e.g. 62051)",
13171319
"usageRatio": "Usage Ratio",
13181320
"usageRatioPlaceholder": "Enter usage ratio",
13191321
"connectionType": "Connection Type",

dashboard/public/statics/locales/fa.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,8 @@
11551155
"addressPlaceholder": "آدرس گره را وارد کنید",
11561156
"port": "پورت گره",
11571157
"portPlaceholder": "پورت گره را وارد کنید",
1158+
"apiPort": "پورت API",
1159+
"apiPortPlaceholder": "پورت API را وارد کنید (مثال: 62051)",
11581160
"usageRatio": "نسبت استفاده",
11591161
"usageRatioPlaceholder": "نسبت استفاده را وارد کنید",
11601162
"connectionType": "نوع اتصال",

dashboard/public/statics/locales/ru.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,8 @@
12121212
"addressPlaceholder": "Введите адрес узла",
12131213
"port": "Порт узла",
12141214
"portPlaceholder": "Введите порт узла",
1215+
"apiPort": "API Порт",
1216+
"apiPortPlaceholder": "Введите API порт (например: 62051)",
12151217
"usageRatio": "Коэффициент использования",
12161218
"usageRatioPlaceholder": "Введите коэффициент использования",
12171219
"connectionType": "Тип подключения",

dashboard/public/statics/locales/zh.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,8 @@
12701270
"addressPlaceholder": "输入节点地址",
12711271
"port": "节点端口",
12721272
"portPlaceholder": "输入节点端口",
1273+
"apiPort": "API 端口",
1274+
"apiPortPlaceholder": "输入 API 端口 (例如: 62051)",
12731275
"usageRatio": "使用系数",
12741276
"usageRatioPlaceholder": "输入使用系数",
12751277
"connectionType": "连接类型",

dashboard/src/components/dialogs/node-modal.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const nodeFormSchema = z.object({
2525
name: z.string().min(1, 'Name is required'),
2626
address: z.string().min(1, 'Address is required'),
2727
port: z.number().min(1, 'Port is required'),
28+
api_port: z.number().min(1).optional().nullable(),
2829
usage_coefficient: z.number().optional(),
2930
connection_type: z.enum([NodeConnectionType.grpc, NodeConnectionType.rest]),
3031
server_ca: z.string().min(1, 'Server CA is required'),
@@ -136,6 +137,7 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
136137
name: node.name,
137138
address: node.address,
138139
port: node.port,
140+
api_port: node.api_port ?? null,
139141
usage_coefficient: node.usage_coefficient,
140142
connection_type: node.connection_type,
141143
server_ca: node.server_ca,
@@ -196,6 +198,7 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
196198
name: nodeData.name,
197199
address: nodeData.address,
198200
port: nodeData.port,
201+
api_port: nodeData.api_port ?? null,
199202
usage_coefficient: nodeData.usage_coefficient,
200203
connection_type: nodeData.connection_type,
201204
server_ca: nodeData.server_ca,
@@ -230,6 +233,7 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
230233
name: nodeData.name,
231234
address: nodeData.address,
232235
port: nodeData.port,
236+
api_port: nodeData.api_port ?? null,
233237
usage_coefficient: nodeData.usage_coefficient,
234238
connection_type: nodeData.connection_type,
235239
server_ca: nodeData.server_ca,
@@ -258,6 +262,7 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
258262
name: '',
259263
address: '',
260264
port: 62050,
265+
api_port: 62051,
261266
usage_coefficient: 1,
262267
connection_type: NodeConnectionType.grpc,
263268
server_ca: '',
@@ -333,6 +338,7 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
333338
keep_alive_unit: undefined,
334339
data_limit: gbToBytes(values.data_limit),
335340
reset_time: values.reset_time !== null && values.reset_time !== undefined ? values.reset_time : -1,
341+
api_port: values.api_port ?? undefined,
336342
}
337343

338344
let nodeId: number | undefined
@@ -398,7 +404,7 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
398404
<div className="flex items-center gap-2">
399405
<div
400406
className={`h-2 w-2 rounded-full ${
401-
statusChecking || currentNode?.status === 'connecting'
407+
currentNode?.status === 'connecting' || (statusChecking && !currentNode?.status)
402408
? 'bg-yellow-500 dark:bg-yellow-400'
403409
: currentNode?.status === 'connected'
404410
? 'bg-green-500 dark:bg-green-400'
@@ -408,7 +414,7 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
408414
}`}
409415
/>
410416
<span className="text-sm font-medium text-foreground">
411-
{statusChecking || currentNode?.status === 'connecting'
417+
{currentNode?.status === 'connecting' || (statusChecking && !currentNode?.status)
412418
? t('nodeModal.status.connecting')
413419
: currentNode?.status === 'connected'
414420
? t('nodeModal.status.connected')
@@ -596,6 +602,36 @@ export default function NodeModal({ isDialogOpen, onOpenChange, form, editingNod
596602
</FormItem>
597603
)}
598604
/>
605+
<FormField
606+
control={form.control}
607+
name="api_port"
608+
render={({ field }) => (
609+
<FormItem className="flex-1">
610+
<FormLabel>{t('nodeModal.apiPort')}</FormLabel>
611+
<FormControl>
612+
<Input
613+
isError={!!form.formState.errors.api_port}
614+
type="number"
615+
placeholder={t('nodeModal.apiPortPlaceholder')}
616+
{...field}
617+
value={field.value ?? ''}
618+
onChange={e => {
619+
const value = e.target.value
620+
if (value === '') {
621+
field.onChange(null)
622+
} else {
623+
const numValue = parseInt(value)
624+
if (!isNaN(numValue) && numValue > 0) {
625+
field.onChange(numValue)
626+
}
627+
}
628+
}}
629+
/>
630+
</FormControl>
631+
<FormMessage />
632+
</FormItem>
633+
)}
634+
/>
599635
</div>
600636

601637
<FormField

0 commit comments

Comments
 (0)