admin/accounts/csv: added "redirect" field
Massimo Melina committed
Apr 3, 2023 at 16:35 UTC
0b7fcd89ea582215155687d29745d2d2b454e613
1 file changed
+9
-3
admin/src/importAccountsCsv.ts
+9
-3
@@ -22,6 +22,7 @@ export async function importAccountsCsv(cb?: () => void) {
22
usernameColumn: 1,
23
passwordColumn: 2,
24
groupColumn: 3,
25
+ redirectColumn: 4,
26
overwriteExistingAccounts: false,
27
}
28
const cfg = await formDialog<typeof initialConfig>({
@@ -35,9 +36,10 @@ export async function importAccountsCsv(cb?: () => void) {
36
save: { startIcon: h(Upload), children: 'Go' },
37
fields: [
38
h(Box, { p: 1 }, "Total lines:", rows.length),
38
- { k: 'skipFirstLines', comp: NumberField, min: 0, max: rows.length-1, typing: true,
39
- helperText: h(Fragment, {}, "First line: ", h('code', {}, row) ),
39
+ { k: 'skipFirstLines', comp: NumberField, min: 0, max: rows.length-1, typing: true, md: 6,
40
+ helperText: h(Fragment, {}, "First line: ", h('code', {}, row.join(', ')) ),
41
},
42
+ { k: 'overwriteExistingAccounts', comp: BoolField, md: 6 },
43
{ k: 'usernameColumn', ...colField,
44
helperText: h(Fragment, {}, "First username: ", rec.u),
45
},
@@ -47,7 +49,9 @@ export async function importAccountsCsv(cb?: () => void) {
49
{ k: 'groupColumn', ...colField,
50
helperText: h(Fragment, {}, "First group: ", rec.g),
51
},
50
- { k: 'overwriteExistingAccounts', comp: BoolField, xs: 6 },
52
+ { k: 'redirectColumn', ...colField,
53
+ helperText: h(Fragment, {}, "First redirect: ", rec.r),
54
+ },
55
],
56
}
57
},
@@ -80,6 +84,7 @@ export async function importAccountsCsv(cb?: () => void) {
84
await apiCall('add_account', {
85
username: rec.u,
86
belongs: rec.g?.split(','),
87
+ redirect: rec.r,
88
overwrite: cfg.overwriteExistingAccounts
89
}).then(() => {
90
if (rec.p)
@@ -117,6 +122,7 @@ export async function importAccountsCsv(cb?: () => void) {
122
u: row[config.usernameColumn - 1],
123
p: row[config.passwordColumn - 1],
124
g: row[config.groupColumn - 1],
125
+ r: row[config.redirectColumn - 1],
126
}
127
}
128
}, { multiple: false, accept: '.csv' })