waibu-db 2.29.1 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,8 +30,8 @@ async function btnExport () {
|
|
|
30
30
|
ftype: 'json',
|
|
31
31
|
toggle (val) {
|
|
32
32
|
if (val === 'clipboard') {
|
|
33
|
-
$refs.fkey.removeAttribute('disabled')
|
|
34
|
-
$refs.fvalue.removeAttribute('disabled')
|
|
33
|
+
// $refs.fkey.removeAttribute('disabled')
|
|
34
|
+
// $refs.fvalue.removeAttribute('disabled')
|
|
35
35
|
$refs.zip.setAttribute('disabled', '')
|
|
36
36
|
$refs.xlsx.setAttribute('disabled', '')
|
|
37
37
|
$refs.tsv.setAttribute('disabled', '')
|
|
@@ -39,8 +39,8 @@ async function btnExport () {
|
|
|
39
39
|
_.pull(this.options, 'zip')
|
|
40
40
|
if (!['json', 'csv'].includes(this.ftype)) this.ftype = 'json'
|
|
41
41
|
} else {
|
|
42
|
-
$refs.fkey.setAttribute('disabled', '')
|
|
43
|
-
$refs.fvalue.setAttribute('disabled', '')
|
|
42
|
+
// $refs.fkey.setAttribute('disabled', '')
|
|
43
|
+
// $refs.fvalue.setAttribute('disabled', '')
|
|
44
44
|
$refs.zip.removeAttribute('disabled')
|
|
45
45
|
$refs.xlsx.removeAttribute('disabled')
|
|
46
46
|
$refs.tsv.removeAttribute('disabled')
|
package/index.js
CHANGED
|
@@ -92,23 +92,22 @@ async function factory (pkgName) {
|
|
|
92
92
|
const model = get(params, 'payload.data.name')
|
|
93
93
|
const fields = get(params, 'payload.data.opts.fields')
|
|
94
94
|
const { id, file } = get(params, 'payload.data.download', {})
|
|
95
|
-
let dest = `${this.app.bajo.getDownloadDir()}/${file}`
|
|
96
95
|
const options = {
|
|
97
96
|
filter: get(params, 'payload.data.filter', {}),
|
|
98
|
-
|
|
97
|
+
exportOpts: get(params, 'payload.data.exportOpts', []),
|
|
98
|
+
opts: get(params, 'payload.data.opts', {}),
|
|
99
99
|
fields
|
|
100
100
|
}
|
|
101
101
|
options.filter.sort = 'id:1' // TODO: make this configurable
|
|
102
102
|
if (!this.app.sumba || !id) {
|
|
103
|
-
const result = await exportTo(model,
|
|
103
|
+
const result = await exportTo(model, file, options)
|
|
104
104
|
return result.file
|
|
105
105
|
}
|
|
106
|
-
const { downloadDir } = this.app.sumba
|
|
107
|
-
dest = `${downloadDir}/${file}`
|
|
108
106
|
const dmodel = this.app.dobo.getModel('SumbaDownload')
|
|
107
|
+
let dest
|
|
109
108
|
try {
|
|
110
109
|
await dmodel.updateRecord(id, { status: 'PROCESSING' })
|
|
111
|
-
const result = await exportTo(model,
|
|
110
|
+
const result = await exportTo(model, file, options)
|
|
112
111
|
dest = result.file
|
|
113
112
|
const { size } = fs.statSync(dest)
|
|
114
113
|
await dmodel.updateRecord(id, { size, status: 'COMPLETE' })
|
|
@@ -31,21 +31,26 @@ async function exportHandler (opts = {}) {
|
|
|
31
31
|
const { pascalCase } = this.app.lib.aneka
|
|
32
32
|
const { getSchemaExt } = this.app.waibuDb
|
|
33
33
|
const { buildUrl } = this.app.waibuMpa
|
|
34
|
+
const { callHandler, importModule } = this.app.bajo
|
|
34
35
|
model = pascalCase(model ?? req.params.model)
|
|
35
36
|
const mdl = this.app.dobo.getModel(model)
|
|
36
37
|
const { schema } = await getSchemaExt(model, 'add', merge({ args: [{ req, model: mdl }] }, { params }, options))
|
|
37
38
|
if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
|
|
38
39
|
const data = await prepCrud.call(this.app.getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
|
|
39
40
|
data.opts = omit(data.opts, ['req', 'reply'])
|
|
41
|
+
data.opts.lang = req.lang
|
|
42
|
+
data.opts.timeZone = get(req, 'site.setting.sumba.timeZone', this.app.bajo.config.intl.format.datetime.timeZone)
|
|
43
|
+
data.opts.dateStyle = get(req, 'site.setting.sumba.dateStyle', this.app.bajo.config.intl.format.datetime.dateStyle)
|
|
44
|
+
data.opts.timeStyle = get(req, 'site.setting.sumba.timeStyle', this.app.bajo.config.intl.format.datetime.timeStyle)
|
|
40
45
|
const source = `${this.name}:/export-handler`
|
|
41
46
|
const worker = 'waibuDb:exportData'
|
|
42
47
|
const type = get(data, 'input.ftype', 'json')
|
|
43
|
-
|
|
44
|
-
const ext =
|
|
48
|
+
data.exportOpts = get(data, 'input.options', '').split(',')
|
|
49
|
+
const ext = data.exportOpts.includes('zip') ? `${type}.gz` : type
|
|
45
50
|
// const file = `${kebabCase(model)}_${dayjs().format('YYYYMMDDhhmmss')}.${ext}`
|
|
46
51
|
const file = `${kebabCase(model)}.${ext}`
|
|
47
|
-
if (this.app.
|
|
48
|
-
await this.app.sumba.
|
|
52
|
+
if (this.app.sumbaXXX) {
|
|
53
|
+
await this.app.sumba.download({ file, type, worker, source, data, req })
|
|
49
54
|
req.flash('notify', req.t('exportInQueue'))
|
|
50
55
|
} else {
|
|
51
56
|
const _opts = {
|
|
@@ -53,15 +58,15 @@ async function exportHandler (opts = {}) {
|
|
|
53
58
|
data: {
|
|
54
59
|
name: model,
|
|
55
60
|
opts: data.opts,
|
|
61
|
+
exportOpts: data.exportOpts,
|
|
56
62
|
filter: data.filter,
|
|
57
|
-
download: {
|
|
63
|
+
download: { file }
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
|
-
const destFile = await
|
|
62
|
-
const { importModule } = this.app.bajo
|
|
67
|
+
const destFile = await callHandler(worker, _opts)
|
|
63
68
|
const { download } = await importModule('waibu:/lib/helper.js', { asDefaultImport: false })
|
|
64
|
-
await download.call(this, destFile, req, reply,
|
|
69
|
+
await download.call(this, destFile, req, reply, file)
|
|
65
70
|
}
|
|
66
71
|
const url = buildUrl({ url: req.url, base: req.body.handler })
|
|
67
72
|
return reply.redirectTo(url)
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-07-26
|
|
4
|
+
|
|
5
|
+
- [2.30.0] Canges in `exportTo()`
|
|
6
|
+
- [2.30.0] Bug fix in `btn-export.js`
|
|
7
|
+
- [2.30.0] Bug fix in `export-handler.js`
|
|
8
|
+
- [2.31.0] Add support for `i18n` options in `export-handler.js`
|
|
9
|
+
|
|
3
10
|
## 2026-07-25
|
|
4
11
|
|
|
5
12
|
- [2.29.1] Bug fix in `exportData()`
|