diff --git a/README.md b/README.md index cf3c0ee..7e596e2 100644 --- a/README.md +++ b/README.md @@ -46,5 +46,6 @@ Responses (Only for directory traversals): ## Credit - Samuel Thornton: [Material Design Box Shadows]("https://codepen.io/sdthornton/pen/wBZdXq") +- Chris Pratt: [File Download via Ajax]('https://codepen.io/chrisdpratt/pen/RKxJNo') - StackOverflow: Troubleshooting errors - Google: All knowing \ No newline at end of file diff --git a/index.js b/index.js index 0abcd1f..27ccb38 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,7 @@ let inDir = (dircheck,dirmain) => !path.relative(path.normalize(dircheck), dirma //Get folder details app.post('/files/cat',(req,res,next)=>{ + console.log(req.body) const location = processing.mergedir(req.body.loc,settings) //const nloc = path.normalize(req.body.loc); const nloc = path.normalize(path.relative(settings.dirname,location)) @@ -67,6 +68,8 @@ app.put('/files/upload',(req,res)=>{ console.log("Upload attempted") res.json({'error':500}) }) +// Use font-awesome +app.use('/fa',express.static(path.join(__dirname,'node_modules','@fortawesome','fontawesome-free'))) // Use jquery app.use('/jquery', express.static( path.join(__dirname ,'node_modules','jquery','dist') ) ) @@ -86,6 +89,7 @@ app.listen(port,()=>{ }) app.use((err,req,res,next)=>{ + console.log(err) res.status(500).json({error:`Internal error.Try again.`}) }) diff --git a/static/base.css b/static/base.css index f09d55c..f18a2f2 100644 --- a/static/base.css +++ b/static/base.css @@ -65,9 +65,9 @@ body{ background-color:aliceblue; z-index:2; padding:0.5rem; - height: 1.5rem; + height: 2rem; width:100%; - + font-size:1.5em; } .nav-bottom-button-container{ width:100%; @@ -94,6 +94,14 @@ body{ margin-top:0.5rem; } +.icon-tabs{ + float:right; + padding-right:1em; +} +.icon-tabs .file-download-button,.icon-tabs .file-rename-button{ + margin-left:0.5em; +} + table#files-details{ width:100%; } diff --git a/static/base.js b/static/base.js index 4d320b2..0a07622 100644 --- a/static/base.js +++ b/static/base.js @@ -1,15 +1,16 @@ -let currDir = {'loc':'','contents':null}; -let currSel = {'loc':'','path':''} +let currDir = {'loc':'','contents':null} +let currSel = {'loc':null,'name':null} function doUpdate(ele,isDir=false){ //console.log(ele.attr('data-choice')); if(ele.hasClass('file-isDir')){ - currDir.loc = ele.attr('data-choice'); + currDir.loc = ele.attr('data-choice') populateContents(); } if(!isDir){ - $('.nav-bottom-text').html(ele.html()) + currSel.loc = ele.attr('data-choice') + $('.nav-bottom-text').html(currSel.name = ele.html()) } //$() @@ -57,5 +58,21 @@ function populateContents(){ $(document).ready(()=>{ populateContents(); - //updateContents(); + $('.file-download-button').click(()=>{ + console.log(currSel) + $.ajax('/files/cat',{ + method:'post', + data:currSel, + xhrFields: { + responseType: 'blob' + }, + success:(msg)=>{ + //console.log(msg) + $('.file-download-button').after(``) + document.getElementById('down-temp').click() + $('#down-temp').remove(); + }, + error: err=>console.log(err) + }) + }) }) diff --git a/static/index.html b/static/index.html index 10d71b8..3ece0da 100644 --- a/static/index.html +++ b/static/index.html @@ -5,13 +5,14 @@ FM + @@ -25,14 +26,7 @@ - + @@ -44,7 +38,18 @@