admin/configuration: new layout

Massimo Melina committed Mar 12, 2022 at 21:18 UTC 14d778ce2b647234ebd9fbaed12b48761ec643b3
1 file changed +13 -12
admin/src/ConfigPage.ts
+13 -12
@@ -31,7 +31,7 @@ export default function ConfigPage() {
31 onChange: (v: any) => v < 1 ? '' : v
32 }
33 return h(Form, {
34 - sx: { maxWidth: '90em' },
34 + sx: { maxWidth: '60em' },
35 values: config,
36 set(v, { k }) {
37 if (v || config[k])
@@ -42,6 +42,7 @@ export default function ConfigPage() {
42 onClick: save,
43 disabled: !Object.keys(changes).length,
44 },
45 + barSx: { gap: 2 },
46 addToBar: [h(Button, {
47 onClick() {
48 reloadConfig()
@@ -51,10 +52,10 @@ export default function ConfigPage() {
52 }, "Reload")],
53 defaults({ comp }) {
54 if (comp === ServerPort)
54 - return { md: 6, lg: 3, xl: 2 }
55 + return { md: 6, lg: 3 }
56 if (comp === NumberField)
56 - return { md:3, xl: 2 }
57 - return { md: 6, xl: 4 }
57 + return { md:3 }
58 + return { md: 6 }
59 },
60 fields: [
61 { k: 'port', comp: ServerPort, label:"HTTP port", status: status?.http||true, suggestedPort: 80 },
@@ -63,23 +64,23 @@ export default function ConfigPage() {
64 config.https_port >= 0 && { k: 'private_key', comp: StringField, label: "HTTPS private key file" },
65 { k: 'max_kbps', ...maxSpeedDefaults, label: "Limit output KB/s" },
66 { k: 'max_kbps_per_ip', ...maxSpeedDefaults, label: "Limit output KB/s per-ip" },
66 - { k: 'log', xl: 4, comp: StringField, label: "Main log file" },
67 - { k: 'error_log', xl: 4, comp: StringField, label: "Error log file" },
68 - { k: 'log_rotation', xl: 4, comp: SelectField, options: [{ value:'', label:"disabled" }, 'daily', 'weekly', 'monthly' ],
67 + { k: 'log', comp: StringField, label: "Main log file" },
68 + { k: 'error_log', comp: StringField, label: "Error log file" },
69 + { k: 'log_rotation', comp: SelectField, options: [{ value:'', label:"disabled" }, 'daily', 'weekly', 'monthly' ],
70 helperText: "To avoid an endlessly-growing single log file, you can opt for rotation"
71 },
72 { k: 'accounts', comp: StringField, label: "Accounts file" },
73 { k: 'open_browser_at_start', comp: BoolField },
73 - { k: 'zip_calculate_size_for_seconds', comp: NumberField, md: 6, xl:4, label: "Calculate ZIP size for seconds",
74 + { k: 'zip_calculate_size_for_seconds', comp: NumberField, md: 6, label: "Calculate ZIP size for seconds",
75 helperText: "If time is not enough, the browser will not show download percentage" },
75 - { k: 'block', label: "Blocked IPs", comp: StringField, multiline: true, minRows:3, helperText: "Enter an IP for each line",
76 - fromField: (all:string) => all.split('\n').map(s => s.trim()).filter(Boolean).map(ip => ({ ip })),
77 - toField: (all: any) => !Array.isArray(all) ? '' : all.map(x => x?.ip).filter(Boolean).join('\n')
78 - },
76 { k: 'mime', comp: StringStringField,
77 keyLabel: "Files", keyWidth: 7,
78 valueLabel: "Mime type", valueWidth: 4
79 },
80 + { k: 'block', label: "Blocked IPs", comp: StringField, multiline: true, minRows:3, helperText: "Enter an IP for each line",
81 + fromField: (all:string) => all.split('\n').map(s => s.trim()).filter(Boolean).map(ip => ({ ip })),
82 + toField: (all: any) => !Array.isArray(all) ? '' : all.map(x => x?.ip).filter(Boolean).join('\n')
83 + },
84 ]
85 })
86