diff --git a/libs/fileBin.js b/libs/fileBin.js
index 455fc6d1..0c83c74e 100644
--- a/libs/fileBin.js
+++ b/libs/fileBin.js
@@ -196,7 +196,7 @@ module.exports = function(s,config,lang,app,io){
},(response) => {
response.forEach(function(v){
v.details = s.parseJSON(v.details)
- v.href = '/'+req.params.auth+'/fileBin/'+req.params.ke+'/'+req.params.id+'/'+v.details.year+'/'+v.details.month+'/'+v.details.day+'/'+v.name;
+ v.href = '/'+req.params.auth+'/fileBin/'+req.params.ke+'/'+req.params.id+'/'+v.name;
})
s.closeJsonResponse(res,{
ok: true,
@@ -208,55 +208,48 @@ module.exports = function(s,config,lang,app,io){
/**
* API : Get fileBin file
*/
- app.get([
- config.webPaths.apiPrefix+':auth/fileBin/:ke/:id/:file',
- config.webPaths.apiPrefix+':auth/fileBin/:ke/:id/:year/:month/:day/:file',
- ], async (req,res) => {
+ app.get(config.webPaths.apiPrefix+':auth/fileBin/:ke/:id/:file', async (req,res) => {
s.auth(req.params,function(user){
var failed = function(){
res.end(user.lang['File Not Found'])
}
- if (!s.group[req.params.ke].fileBin[req.params.id+'/'+req.params.file]){
- const groupKey = req.params.ke
- const monitorId = req.params.id
- const monitorRestrictions = s.getMonitorRestrictions(user.details,monitorId)
- if(user.details.sub && user.details.allmonitors === '0' && (user.permissions.get_monitors === "0" || monitorRestrictions.length === 0)){
- s.closeJsonResponse(res,{
- ok: false,
- msg: lang['Not Permitted']
- })
- return
- }
- s.knexQuery({
- action: "select",
- columns: "*",
- table: "Files",
- where: [
- ['ke','=',groupKey],
- ['mid','=',req.params.id],
- ['name','=',req.params.file],
- monitorRestrictions
- ]
- },(err,r) => {
- if(r && r[0]){
- r = r[0]
- r.details = JSON.parse(r.details)
- const filePath = s.dir.fileBin + req.params.ke + '/' + req.params.id + (r.details.year && r.details.month && r.details.day ? '/' + r.details.year + '/' + r.details.month + '/' + r.details.day : '') + '/' + req.params.file;
- fs.stat(filePath,function(err,stats){
- if(!err){
- res.on('finish',function(){res.end()})
- fs.createReadStream(filePath).pipe(res)
- }else{
- failed()
- }
- })
- }else{
- failed()
- }
+ const groupKey = req.params.ke
+ const monitorId = req.params.id
+ const monitorRestrictions = s.getMonitorRestrictions(user.details,monitorId)
+ if(user.details.sub && user.details.allmonitors === '0' && (user.permissions.get_monitors === "0" || monitorRestrictions.length === 0)){
+ s.closeJsonResponse(res,{
+ ok: false,
+ msg: lang['Not Permitted']
})
- }else{
- res.end(user.lang['Please Wait for Completion'])
+ return
}
+ s.knexQuery({
+ action: "select",
+ columns: "*",
+ table: "Files",
+ where: [
+ ['ke','=',groupKey],
+ ['mid','=',req.params.id],
+ ['name','=',req.params.file],
+ monitorRestrictions
+ ]
+ },(err,r) => {
+ if(r && r[0]){
+ r = r[0]
+ r.details = JSON.parse(r.details)
+ const filePath = s.dir.fileBin + req.params.ke + '/' + req.params.id + (r.details.year && r.details.month && r.details.day ? '/' + r.details.year + '/' + r.details.month + '/' + r.details.day : '') + '/' + req.params.file;
+ fs.stat(filePath,function(err,stats){
+ if(!err){
+ res.on('finish',function(){res.end()})
+ fs.createReadStream(filePath).pipe(res)
+ }else{
+ failed()
+ }
+ })
+ }else{
+ failed()
+ }
+ })
},res,req);
});
}
diff --git a/web/assets/css/dashboard.css b/web/assets/css/dashboard.css
index dd15cd50..96e83054 100644
--- a/web/assets/css/dashboard.css
+++ b/web/assets/css/dashboard.css
@@ -425,3 +425,8 @@ ul.squeeze {
transform: translate3d(4px, 0, 0);
}
}
+
+.bg-dark .bootstrap-table .table,
+.bg-dark .bootstrap-table .table td {
+ color: #fff!important;
+}
diff --git a/web/assets/js/bs5.fileBin.js b/web/assets/js/bs5.fileBin.js
index ece510c3..2fd3bc97 100644
--- a/web/assets/js/bs5.fileBin.js
+++ b/web/assets/js/bs5.fileBin.js
@@ -53,17 +53,25 @@ $(document).ready(function(e){
search: true,
columns: [
{
- field: 'filename',
+ field: 'name',
title: lang['Filename']
- }, {
+ },
+ {
field: 'time',
title: lang['Time Created']
- }, {
+ },
+ {
field: 'href',
title: 'Download'
}
],
- data: data.files
+ data: data.files.map((file) => {
+ return {
+ name: file.name,
+ time: file.time,
+ href: ``,
+ }
+ })
})
})
}
diff --git a/web/pages/blocks/home/fileBin.ejs b/web/pages/blocks/home/fileBin.ejs
index 536a47f2..9d243404 100644
--- a/web/pages/blocks/home/fileBin.ejs
+++ b/web/pages/blocks/home/fileBin.ejs
@@ -12,5 +12,5 @@
drawBlock(theBlock)
}) %>
-
+