admin/home: nicer
Massimo Melina committed
Jul 19, 2023 at 12:55 UTC
1d9c36485f5ad8b91d6f7f803928cf309fd7475b
1 file changed
+17
-19
admin/src/HomePage.ts
+17
-19
@@ -44,7 +44,7 @@ export default function HomePage() {
44
const [account] = useApi<Account>(username && 'get_account')
45
const { data: cfg, reload: reloadCfg } = useApiEx('get_config', { only: ['https_port', 'cert', 'private_key', 'proxies', 'update_to_beta'] })
46
const { list: plugins } = useApiList('get_plugins')
47
- const [updateInfo, setUpdateInfo] = useState<any>()
47
+ const [updates, setUpdates] = useState<undefined | any[]>()
48
if (statusEl || !status)
49
return statusEl
50
const { http, https } = status
@@ -64,7 +64,7 @@ export default function HomePage() {
64
"make one"
65
), " or ", SOLUTION_SEP, cfgLink("provide adequate files")
66
]]))
67
- return h(Box, { display:'flex', gap: 2, flexDirection:'column', height: '100%' },
67
+ return h(Box, { display:'flex', gap: 2, flexDirection:'column', alignItems: 'flex-start', height: '100%' },
68
username && entry('', "Welcome "+username),
69
errors.length ? dontBotherWithKeys(errors.map(msg => entry('error', dontBotherWithKeys(msg))))
70
: entry('success', "Server is working"),
@@ -99,23 +99,21 @@ export default function HomePage() {
99
h('li',{}, `disable "admin access for localhost" in HFS (safe, but you won't see users' IPs)`),
100
)),
101
entry('', h(Link, { target: 'support', href: REPO_URL + 'discussions' }, "Get support")),
102
- h(Box, { mt: 4 },
103
- status.updatePossible === 'local' ? h(Btn, {
104
- icon: UpdateIcon,
105
- onClick: () => update()
106
- }, "Update from local file")
107
- : !updateInfo ? h(Btn, {
108
- variant: 'outlined',
109
- icon: UpdateIcon,
110
- onClick: () => apiCall('check_update').then(x => setUpdateInfo(x.options), alertDialog)
111
- }, "Check for updates")
112
- : !updateInfo.length ? entry('', "No update available")
113
- : !status.updatePossible ? entry('', `Version ${updateInfo[0].name} available`)
114
- : h(Flex, { vert: true, alignItems: 'flex-start' },
115
- updateInfo.map((x: any) =>
116
- h(Btn, { icon: UpdateIcon, onClick: () => update(x.tag_name) }, prefix("Install ", x.name)) )
117
- )
118
- ),
102
+ status.updatePossible === 'local' ? h(Btn, {
103
+ icon: UpdateIcon,
104
+ onClick: () => update()
105
+ }, "Update from local file")
106
+ : !updates ? h(Btn, {
107
+ variant: 'outlined',
108
+ icon: UpdateIcon,
109
+ onClick: () => apiCall('check_update').then(x => setUpdates(x.options), alertDialog)
110
+ }, "Check for updates")
111
+ : !updates.length ? entry('', "No update available")
112
+ : !status.updatePossible ? entry('', `Version ${updates[0].name} available`)
113
+ : h(Flex, { vert: true },
114
+ updates.map((x: any) =>
115
+ h(Btn, { icon: UpdateIcon, onClick: () => update(x.tag_name) }, prefix("Install ", x.name)) )
116
+ ),
117
)
118
}
119