waibu-db 2.31.0 → 2.32.1
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.
- package/extend/bajo/intl/en-US.json +6 -6
- package/extend/bajo/intl/id.json +6 -6
- package/extend/waibuBootstrap/theme/component/widget/btn-export.js +6 -6
- package/index.js +2 -19
- package/lib/crud/export-handler.js +19 -11
- package/lib/method/create-record.js +2 -2
- package/package.json +1 -1
- package/wiki/CHANGES.md +11 -0
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"yes": "Yes",
|
|
23
23
|
"no": "No",
|
|
24
24
|
"db": "DB",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
25
|
+
"fileXlsx": "Excel File",
|
|
26
|
+
"fileCsv": "CSV File",
|
|
27
|
+
"fileXml": "XML File",
|
|
28
|
+
"fileJson": "JSON File",
|
|
29
29
|
"addMoreAfterSubmit": "Add more after submit",
|
|
30
30
|
"clonePrevious": "Clone previous",
|
|
31
31
|
"actionPermanentlyDisabled%s": "Sorry, action '%s' is permanently disabled at database level. For more information, please contact your Admin immediately, thank you!",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"uncheckAll": "Uncheck All",
|
|
35
35
|
"attachment": "Attachment",
|
|
36
36
|
"exportInQueue": "Data export in queue. Please check your download list for progress",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"fileTsv": "TSV File",
|
|
38
|
+
"fileNdjson": "NDJSON File",
|
|
39
39
|
"dataValue": "Data value",
|
|
40
40
|
"suppressedError": "Error occured and suppressed. Please check error log for details",
|
|
41
41
|
"queryHint%s": "Search by %s",
|
package/extend/bajo/intl/id.json
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"yes": "Ya",
|
|
23
23
|
"no": "Tidak",
|
|
24
24
|
"db": "DB",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
25
|
+
"fileXlsx": "Berkas Excel",
|
|
26
|
+
"fileCsv": "Berkas CSV",
|
|
27
|
+
"fileXml": "Berkas XML",
|
|
28
|
+
"fileJson": "Berkas JSON",
|
|
29
29
|
"addMoreAfterSubmit": "Tambah lagi setelah kirim",
|
|
30
30
|
"clonePrevious": "Duplikasi sebelumnya",
|
|
31
31
|
"actionPermanentlyDisabled%s": "Sorry, action '%s' is permanently disabled at database level. For more information, please contact your Admin immediately, thank you!",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"uncheckAll": "Uncheck Semua",
|
|
35
35
|
"attachment": "Attachment",
|
|
36
36
|
"exportInQueue": "Ekspor data sedang dalam antrian. Silahkan cek daftar unduh Anda untuk perkembangan terakhir",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"fileTsv": "Berkas TSV",
|
|
38
|
+
"fileNdjson": "Berkas NDJSON",
|
|
39
39
|
"dataValue": "Nilai data",
|
|
40
40
|
"suppressedError": "Kesalahan terjadi dan tidak ditampilkan. Silahkan cek log kesalahan untuk detilnya",
|
|
41
41
|
"queryHint%s": "Cari berdasarkan %s",
|
|
@@ -95,7 +95,7 @@ async function btnExport () {
|
|
|
95
95
|
},
|
|
96
96
|
async submit () {
|
|
97
97
|
const instance = wbs.getInstance('Modal', $refs.export)
|
|
98
|
-
const handler = '${this.params.attr.handler ?? ''}'
|
|
98
|
+
const handler = '${this.params.attr.noBase ? '' : (this.params.attr.handler ?? '')}'
|
|
99
99
|
if (this.delivery === 'clipboard') {
|
|
100
100
|
const selector = '${this.params.attr.selector}'
|
|
101
101
|
if (_.isEmpty(selector)) {
|
|
@@ -128,11 +128,11 @@ async function btnExport () {
|
|
|
128
128
|
</c:grid-col>
|
|
129
129
|
<c:grid-col col="6-md">
|
|
130
130
|
<c:fieldset t:legend="fileType" legend-type="6">
|
|
131
|
-
<c:form-radio x-ref="xlsx" x-model="ftype" value="xlsx" t:label="
|
|
132
|
-
<c:form-radio x-ref="csv" x-model="ftype" value="csv" t:label="
|
|
133
|
-
<c:form-radio x-ref="tsv" x-model="ftype" value="tsv" t:label="
|
|
134
|
-
<c:form-radio x-ref="json" x-model="ftype" value="json" t:label="
|
|
135
|
-
<c:form-radio x-ref="ndjson" x-model="ftype" value="ndjson" t:label="
|
|
131
|
+
<c:form-radio x-ref="xlsx" x-model="ftype" value="xlsx" t:label="fileXlsx" />
|
|
132
|
+
<c:form-radio x-ref="csv" x-model="ftype" value="csv" t:label="fileCsv" />
|
|
133
|
+
<c:form-radio x-ref="tsv" x-model="ftype" value="tsv" t:label="fileTsv" />
|
|
134
|
+
<c:form-radio x-ref="json" x-model="ftype" value="json" t:label="fileJson" />
|
|
135
|
+
<c:form-radio x-ref="ndjson" x-model="ftype" value="ndjson" t:label="fileNdjson" />
|
|
136
136
|
</c:fieldset />
|
|
137
137
|
</c:grid-col>
|
|
138
138
|
</c:grid-row>
|
package/index.js
CHANGED
|
@@ -87,34 +87,17 @@ async function factory (pkgName) {
|
|
|
87
87
|
*/
|
|
88
88
|
exportData = async (params) => {
|
|
89
89
|
const { get } = this.app.lib._
|
|
90
|
-
const { fs } = this.app.lib
|
|
91
90
|
const { exportTo } = this.app.doboExtra
|
|
92
91
|
const model = get(params, 'payload.data.name')
|
|
93
92
|
const fields = get(params, 'payload.data.opts.fields')
|
|
94
|
-
const
|
|
93
|
+
const file = get(params, 'payload.data.file', {})
|
|
95
94
|
const options = {
|
|
96
95
|
filter: get(params, 'payload.data.filter', {}),
|
|
97
96
|
exportOpts: get(params, 'payload.data.exportOpts', []),
|
|
98
97
|
opts: get(params, 'payload.data.opts', {}),
|
|
99
98
|
fields
|
|
100
99
|
}
|
|
101
|
-
|
|
102
|
-
if (!this.app.sumba || !id) {
|
|
103
|
-
const result = await exportTo(model, file, options)
|
|
104
|
-
return result.file
|
|
105
|
-
}
|
|
106
|
-
const dmodel = this.app.dobo.getModel('SumbaDownload')
|
|
107
|
-
let dest
|
|
108
|
-
try {
|
|
109
|
-
await dmodel.updateRecord(id, { status: 'PROCESSING' })
|
|
110
|
-
const result = await exportTo(model, file, options)
|
|
111
|
-
dest = result.file
|
|
112
|
-
const { size } = fs.statSync(dest)
|
|
113
|
-
await dmodel.updateRecord(id, { size, status: 'COMPLETE' })
|
|
114
|
-
} catch (err) {
|
|
115
|
-
await dmodel.updateRecord(id, { status: 'FAIL' })
|
|
116
|
-
}
|
|
117
|
-
return dest
|
|
100
|
+
return await exportTo(model, file, options)
|
|
118
101
|
}
|
|
119
102
|
|
|
120
103
|
/**
|
|
@@ -27,7 +27,7 @@ async function exportHandler (opts = {}) {
|
|
|
27
27
|
options = {}
|
|
28
28
|
} = opts
|
|
29
29
|
// const { dayjs } = this.app.lib
|
|
30
|
-
const { omit, kebabCase, get, merge } = this.app.lib._
|
|
30
|
+
const { omit, kebabCase, get, merge, isEmpty } = this.app.lib._
|
|
31
31
|
const { pascalCase } = this.app.lib.aneka
|
|
32
32
|
const { getSchemaExt } = this.app.waibuDb
|
|
33
33
|
const { buildUrl } = this.app.waibuMpa
|
|
@@ -36,21 +36,28 @@ async function exportHandler (opts = {}) {
|
|
|
36
36
|
const mdl = this.app.dobo.getModel(model)
|
|
37
37
|
const { schema } = await getSchemaExt(model, 'add', merge({ args: [{ req, model: mdl }] }, { params }, options))
|
|
38
38
|
if (schema.disabled.includes('find')) return await reply.view(templateDisabled, { action: 'list' })
|
|
39
|
-
const
|
|
40
|
-
data
|
|
39
|
+
const crud = await prepCrud.call(this.app.getPlugin('waibuDb'), { model, req, reply, args: ['model'] })
|
|
40
|
+
const data = {
|
|
41
|
+
name: model,
|
|
42
|
+
filter: crud.filter,
|
|
43
|
+
opts: omit(crud.opts, ['req', 'reply', 'model'])
|
|
44
|
+
}
|
|
41
45
|
data.opts.lang = req.lang
|
|
46
|
+
data.opts.fields = isEmpty(req.query.fields) ? get(schema, 'view.fields', []) : req.query.fields.split(',')
|
|
47
|
+
|
|
42
48
|
data.opts.timeZone = get(req, 'site.setting.sumba.timeZone', this.app.bajo.config.intl.format.datetime.timeZone)
|
|
43
49
|
data.opts.dateStyle = get(req, 'site.setting.sumba.dateStyle', this.app.bajo.config.intl.format.datetime.dateStyle)
|
|
44
50
|
data.opts.timeStyle = get(req, 'site.setting.sumba.timeStyle', this.app.bajo.config.intl.format.datetime.timeStyle)
|
|
45
|
-
const source = `${this.
|
|
46
|
-
const worker =
|
|
47
|
-
const type = get(
|
|
48
|
-
data.exportOpts = get(
|
|
51
|
+
const source = `${this.ns}:/export-handler`
|
|
52
|
+
const worker = `${this.ns}:exportData`
|
|
53
|
+
const type = get(crud, 'input.ftype', 'json')
|
|
54
|
+
data.exportOpts = get(crud, 'input.options', '').split(',')
|
|
49
55
|
const ext = data.exportOpts.includes('zip') ? `${type}.gz` : type
|
|
50
56
|
// const file = `${kebabCase(model)}_${dayjs().format('YYYYMMDDhhmmss')}.${ext}`
|
|
51
57
|
const file = `${kebabCase(model)}.${ext}`
|
|
52
|
-
if (this.app.
|
|
53
|
-
|
|
58
|
+
if (this.app.sumba) {
|
|
59
|
+
const description = kebabCase(model).split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')
|
|
60
|
+
await this.app.sumba.pushDownload({ file, description, type, worker, source, data, req })
|
|
54
61
|
req.flash('notify', req.t('exportInQueue'))
|
|
55
62
|
} else {
|
|
56
63
|
const _opts = {
|
|
@@ -60,7 +67,7 @@ async function exportHandler (opts = {}) {
|
|
|
60
67
|
opts: data.opts,
|
|
61
68
|
exportOpts: data.exportOpts,
|
|
62
69
|
filter: data.filter,
|
|
63
|
-
|
|
70
|
+
file
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
}
|
|
@@ -68,7 +75,8 @@ async function exportHandler (opts = {}) {
|
|
|
68
75
|
const { download } = await importModule('waibu:/lib/helper.js', { asDefaultImport: false })
|
|
69
76
|
await download.call(this, destFile, req, reply, file)
|
|
70
77
|
}
|
|
71
|
-
const
|
|
78
|
+
const base = isEmpty(req.body.handler) ? undefined : req.body.handler
|
|
79
|
+
const url = buildUrl({ url: req.url, base })
|
|
72
80
|
return reply.redirectTo(url)
|
|
73
81
|
}
|
|
74
82
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { prepCrud, processHandler } from '../util.js'
|
|
2
2
|
|
|
3
|
-
async function createRecord ({ model, req, reply, options = {}, transaction } = {}) {
|
|
3
|
+
async function createRecord ({ model, req, body, reply, options = {}, transaction } = {}) {
|
|
4
4
|
const { model: mdl, opts, attachment, stats, mimeType } = await prepCrud.call(this, { model, req, reply, options, args: ['model'], transaction })
|
|
5
5
|
|
|
6
6
|
async function handler (trx) {
|
|
7
7
|
if (opts.trx === true) opts.trx = trx
|
|
8
|
-
const ret = await mdl.createRecord(req.body, { ...opts, partial: true, strict: true })
|
|
8
|
+
const ret = await mdl.createRecord(body ?? req.body, { ...opts, partial: true, strict: true })
|
|
9
9
|
if (attachment) ret.data._attachment = await mdl.findAttachment(ret.data.id, { stats, mimeType })
|
|
10
10
|
return ret
|
|
11
11
|
}
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-07-28
|
|
4
|
+
|
|
5
|
+
- [2.32.1] Bug fix in `exportData()`
|
|
6
|
+
- [2.32.1] Bug fix in `btn-export.js`
|
|
7
|
+
- [2.32.1] Bug fix in `export-handler.js`
|
|
8
|
+
- [2.32.1] Bug fix in `create-record.js`
|
|
9
|
+
|
|
10
|
+
## 2026-07-27
|
|
11
|
+
|
|
12
|
+
- [2.32.0] Add support for `sumba.download()` through `export-handler.js`
|
|
13
|
+
|
|
3
14
|
## 2026-07-26
|
|
4
15
|
|
|
5
16
|
- [2.30.0] Canges in `exportTo()`
|