@samitouri / QOSami-HFS / commits / 0e94b6fa

admin/internet: domain box

Massimo Melina committed Aug 29, 2023 at 12:11 UTC 0e94b6fa35fe63e1d9d224254f773d97901ce237
2 files changed +19 -3
admin/src/FileForm.ts
+1 -1
@@ -278,7 +278,7 @@ export async function changeBaseUrl() {
278 h(MenuItem, {
279 selected: !v,
280 onClick: () => set(''),
281 - }, "Automatic / None", !v && check),
281 + }, "Automatic", !v && check),
282 urls.map(u => h(MenuItem, {
283 key: u,
284 selected: u === v,
admin/src/InternetPage.ts
+18 -2
@@ -1,5 +1,5 @@
1 import { createElement as h, useEffect, useState } from 'react'
2 -import { Alert, Box, Button, CircularProgress, LinearProgress, Link } from '@mui/material'
2 +import { Alert, Box, Button, Card, CardContent, CircularProgress, LinearProgress, Link } from '@mui/material'
3 import { HomeWorkTwoTone, PublicTwoTone, RouterTwoTone } from '@mui/icons-material'
4 import { apiCall, useApiEx } from './api'
5 import { closeDialog, with_ } from '@hfs/shared'
@@ -7,6 +7,7 @@ import { Flex, LinkBtn } from './misc'
7 import { alertDialog, confirmDialog, promptDialog, toast } from './dialog'
8 import { NumberField } from '@hfs/mui-grid-form'
9 import md from './md'
10 +import { changeBaseUrl } from './FileForm'
11
12 const PORT_FORWARD_URL = 'https://portforward.com/'
13 const HIGHER_PORT = 1080
@@ -17,7 +18,7 @@ export default function InternetPage() {
18 const [checking, setChecking] = useState(false)
19 const [mapping, setMapping] = useState(false)
20 const [verifyAgain, setVerifyAgain] = useState(false)
20 - const { data: status } = useApiEx('get_status')
21 + const { data: status, reload: reloadStatus } = useApiEx('get_status')
22 const localColor = with_([status?.http?.error, status?.https?.error], ([h, s]) =>
23 h && s ? 'error' : h || s ? 'warning' : 'success')
24 const { data: nat, reload, error, loading } = useApiEx('get_nat')
@@ -31,9 +32,24 @@ export default function InternetPage() {
32 }, [verifyAgain, nat, loading])
33 return h(Flex, { vert: true },
34 h(Alert, { severity: 'info' }, "This page helps you making your server work on the Internet"),
35 + baseUrlBox(),
36 networkBox(),
37 )
38
39 + function baseUrlBox() {
40 + if (!status) return h(CircularProgress)
41 + return h(Card, {}, h(CardContent, {},
42 + h(Box, { fontSize: 'x-large', mb: 2 }, "Address / Domain"),
43 + h(Flex, { flexWrap: 'wrap', alignItems: 'center' },
44 + status?.baseUrl || "Automatic, not configured",
45 + h(Button, {
46 + size: 'small',
47 + onClick() { changeBaseUrl().then(reloadStatus) }
48 + }, "Change"),
49 + )
50 + ))
51 + }
52 +
53 function networkBox() {
54 if (error) return "Error"
55 if (!nat) return h(CircularProgress)