diff --git a/index.js b/index.js index db6c6ff..5821677 100644 --- a/index.js +++ b/index.js @@ -23,26 +23,43 @@ app.get('/files',(req,res,next)=>{ next(err) } else{ - res.json({"filename":`${DIR}`,"rootdir":processing.dirprocess(stream,settings)}); } }) }) -//Attempt to upload a file +//Attempt to upload a file - Placeholder app.put('/files/upload',(req,res)=>{ console.log("Upload attempted") -}) - -//Get file details -app.post('/files/ls',(req,res)=>{ - console.log("Request attempted") + res.json({'error':500}) }) -app.get( '/*', express.static( path.join(__dirname,'static') ) ); +//Get folder details +app.post('/files/ls',(req,res,next)=>{ + const location = processing.mergedir(req.body.loc,settings) + fs.readdir(location,(err,files)=>{ + if(err){ + next(err) + } + else{ + res.json({ + "location": location , + "contents":files + }) + } + }) + + //next() +}) +//console.log(path.join(__dirname ,'node_modules','jquery','dist')) +app.use('/jquery', express.static( path.join(__dirname ,'node_modules','jquery','dist') ) ) +app.get( '/*', express.static( path.join(__dirname,'static') ) ) + + +//All non-matched end up in this route app.all('*',(req,res)=>{ res.status(404).json({'error':404}); diff --git a/package-lock.json b/package-lock.json index 3163b43..915720f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -192,6 +192,11 @@ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" }, + "jquery": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz", + "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", diff --git a/package.json b/package.json index 6de3251..6508297 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "homepage": "https://github.com/chrisvrose/nodejs-fm#readme", "dependencies": { "body-parser": "^1.19.0", - "express": "^4.17.0" + "express": "^4.17.0", + "jquery": "^3.4.1" } } diff --git a/processing.js b/processing.js index a1bc99e..30ebafa 100644 --- a/processing.js +++ b/processing.js @@ -1,3 +1,8 @@ +const paths = require('path') +module.exports.mergedir = (dirname,settings)=>{ + return paths.join(settings.dirname,dirname); +} + module.exports.dirprocess = (dirstream,settings)=>{ if(!settings.showHidden){ let fdirstream = dirstream.filter((ele)=>{ @@ -5,6 +10,8 @@ module.exports.dirprocess = (dirstream,settings)=>{ }) return fdirstream } - else return dirstream + else{ + return dirstream + } } diff --git a/static/base.css b/static/base.css index 898029b..b0f8b71 100644 --- a/static/base.css +++ b/static/base.css @@ -83,6 +83,22 @@ body{ margin-top:0.5rem; } +table#files-details{ + width:100%; +} +table{ + border-collapse: collapse; +} +table tr{ + border-bottom: 1px #c5c0c0 solid; +} +table td{ + padding:0.25em; +} +tbody tr:last-child{ + border:0; +} + .box-shadow-1{ box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); diff --git a/static/base.js b/static/base.js new file mode 100644 index 0000000..689b972 --- /dev/null +++ b/static/base.js @@ -0,0 +1,8 @@ + +let currDir = '/'; + + +//set table details +function setList(){ + +} diff --git a/static/index.html b/static/index.html index f96039e..3667ca9 100644 --- a/static/index.html +++ b/static/index.html @@ -4,6 +4,8 @@