zet-lib 1.3.32 → 1.3.33
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/lib/Form.js +7 -2
- package/lib/zAppRouter.js +30 -0
- package/lib/zRoute.js +1 -0
- package/package.json +2 -1
package/lib/Form.js
CHANGED
|
@@ -494,7 +494,12 @@ Form.field = (obj) => {
|
|
|
494
494
|
break
|
|
495
495
|
|
|
496
496
|
case 'dropzoneview':
|
|
497
|
-
|
|
497
|
+
let countFiles = obj.value && obj.value.length ? obj.value.length + ' Files' : ''
|
|
498
|
+
let bodydropzoneview =
|
|
499
|
+
countFiles == '' ? '' : `<div class="card-header">${countFiles} <div class="float-end"><span class="icon-small icons-light" title="Download"><img onclick="location.href= '/zdownloads-dropzone/${obj.routeName}/${obj.key}/${obj.dataId}'" class="icons-bg-black gridview icon-image" src="/assets/icons/download.svg"></span></div> </div>`
|
|
500
|
+
displayForm = `<div class="card">
|
|
501
|
+
${bodydropzoneview}
|
|
502
|
+
<div class="card-body">`
|
|
498
503
|
if (obj.value && obj.value.length > 0) {
|
|
499
504
|
obj.value.map((item) => {
|
|
500
505
|
let extFile = Util.fileExtension(item)
|
|
@@ -506,7 +511,7 @@ Form.field = (obj) => {
|
|
|
506
511
|
}
|
|
507
512
|
})
|
|
508
513
|
}
|
|
509
|
-
displayForm += `</div>`
|
|
514
|
+
displayForm += `</div></div>`
|
|
510
515
|
|
|
511
516
|
break
|
|
512
517
|
default:
|
package/lib/zAppRouter.js
CHANGED
|
@@ -20,6 +20,7 @@ const zCache = require('./zCache')
|
|
|
20
20
|
const pm2 = require('pm2')
|
|
21
21
|
const zFunction = require('./zFunction')
|
|
22
22
|
const qs = require('qs')
|
|
23
|
+
const zip = require('express-zip')
|
|
23
24
|
|
|
24
25
|
/*
|
|
25
26
|
ajax Post
|
|
@@ -1569,4 +1570,33 @@ router.post('/zhistory-data', async (req, res) => {
|
|
|
1569
1570
|
}
|
|
1570
1571
|
})
|
|
1571
1572
|
|
|
1573
|
+
router.get('/zdownloads-dropzone/:table/:field/:id', async (req, res) => {
|
|
1574
|
+
try {
|
|
1575
|
+
let table = req.params.table
|
|
1576
|
+
let field = req.params.field
|
|
1577
|
+
let id = req.params.id
|
|
1578
|
+
const room = res.locals.token
|
|
1579
|
+
let result = await connection.result({
|
|
1580
|
+
table: table,
|
|
1581
|
+
where: {
|
|
1582
|
+
id: id,
|
|
1583
|
+
},
|
|
1584
|
+
})
|
|
1585
|
+
let dir = `${dirRoot}/public/uploads/${table}/${field}/`
|
|
1586
|
+
let arr = []
|
|
1587
|
+
let files = result[field]
|
|
1588
|
+
for (const file of files) {
|
|
1589
|
+
if (Util.fileExist(dir + file)) {
|
|
1590
|
+
let filename = file.substring(13)
|
|
1591
|
+
arr.push({ path: dir + file, name: filename })
|
|
1592
|
+
io.to(room).emit('info', `Zip file ${filename}`)
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
io.to(room).emit('info', `Zip file completed...`)
|
|
1596
|
+
res.zip(arr, `${field}_${table}_${id}.zip`)
|
|
1597
|
+
} catch (e) {
|
|
1598
|
+
console.log(e)
|
|
1599
|
+
res.json(e + '')
|
|
1600
|
+
}
|
|
1601
|
+
})
|
|
1572
1602
|
module.exports = router
|
package/lib/zRoute.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zet-lib",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.33",
|
|
4
4
|
"description": "zet is a library that part of zet generator.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"dotenv": "^16.3.1",
|
|
35
35
|
"ejs": "^3.1.9",
|
|
36
36
|
"exceljs": "^4.4.0",
|
|
37
|
+
"express-zip": "^3.0.0",
|
|
37
38
|
"fs-extra": "^11.1.1",
|
|
38
39
|
"html-minifier-terser": "^7.2.0",
|
|
39
40
|
"js-sha256": "^0.9.0",
|