frontend: ok button to input dialogs

Massimo Melina committed May 7, 2022 at 16:00 UTC 51dabcbcca4e38150343ba1dc4960c0d91890087
2 files changed +11 -7
frontend/src/dialog.ts
+11 -6
@@ -15,7 +15,7 @@ export async function promptDialog(msg: string, { def, type }:PromptOptions={})
15 }) )
16
17 function Content() {
18 - const ref = useRef()
18 + const ref = useRef<HTMLInputElement>()
19 useEffect(()=>{
20 const e = ref.current
21 if (!e) return
@@ -33,13 +33,18 @@ export async function promptDialog(msg: string, { def, type }:PromptOptions={})
33 onKeyDown(ev: KeyboardEvent) {
34 const { key } = ev
35 if (key === 'Escape')
36 - closeDialog(null)
37 - if (key === 'Enter') {
38 - closeDialog((ev.target as any).value as string)
39 - }
36 + return closeDialog(null)
37 + if (key === 'Enter')
38 + return go()
39 }
41 - })
40 + }),
41 + h('div', { style: { textAlign: 'right', marginTop: '.8em' } },
42 + h('button', { onClick: go }, "Continue")),
43 )
44 +
45 + function go() {
46 + closeDialog(ref.current?.value)
47 + }
48 }
49 }
50
todo.md
-1
@@ -11,7 +11,6 @@
11 - admin/stats: total bytes sent
12 - admin/stats: list of IPs seen
13 - if specified config is a folder, check for file config.yaml inside
14 -- frontend: ok button to inputDialogs
14 - admin: in a group, show linked accounts
15 - admin: warn in case of items with same name
16 - command line help --help