admin/config: suggested ports that make sense instead of 1

Massimo Melina committed Feb 13, 2022 at 21:05 UTC f863504721d5e600a8947378425302e6a44fd337
1 file changed +4 -4
admin/src/ConfigPage.ts
+4 -4
@@ -48,8 +48,8 @@ export default function ConfigPage() {
48 return { md: shortField ? 3 : 6 }
49 },
50 fields: [
51 - { k: 'port', comp: ServerPort, label:'HTTP port', status: status?.http||true },
52 - { k: 'https_port', comp: ServerPort, label: 'HTTPS port', status: status?.https||true },
51 + { k: 'port', comp: ServerPort, label:'HTTP port', status: status?.http||true, suggestedPort: 80 },
52 + { k: 'https_port', comp: ServerPort, label: 'HTTPS port', status: status?.https||true, suggestedPort: 443 },
53 config.https_port >= 0 && { k: 'cert', comp: StringField, label: 'HTTPS certificate file' },
54 config.https_port >= 0 && { k: 'private_key', comp: StringField, label: 'HTTPS private key file' },
55 { k: 'admin_port', comp: ServerPort, label: 'Admin port' },
@@ -92,8 +92,8 @@ function recalculateChanges() {
92 state.changes = changes
93 }
94
95 -function ServerPort({ label, value, onChange, status }: FieldProps<number | null>) {
96 - const lastCustom = useRef(1)
95 +function ServerPort({ label, value, onChange, status, suggestedPort=1 }: FieldProps<number | null>) {
96 + const lastCustom = useRef(suggestedPort)
97 if (value! > 0)
98 lastCustom.current = value!
99 const selectValue = Number(value! > 0 ? lastCustom.current : value) || 0