Add routing basics
Add jquery
This commit is contained in:
33
index.js
33
index.js
@@ -23,26 +23,43 @@ app.get('/files',(req,res,next)=>{
|
|||||||
next(err)
|
next(err)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
res.json({"filename":`${DIR}`,"rootdir":processing.dirprocess(stream,settings)});
|
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)=>{
|
app.put('/files/upload',(req,res)=>{
|
||||||
console.log("Upload attempted")
|
console.log("Upload attempted")
|
||||||
})
|
res.json({'error':500})
|
||||||
|
|
||||||
//Get file details
|
|
||||||
app.post('/files/ls',(req,res)=>{
|
|
||||||
console.log("Request attempted")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
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)=>{
|
app.all('*',(req,res)=>{
|
||||||
res.status(404).json({'error':404});
|
res.status(404).json({'error':404});
|
||||||
|
|
||||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@@ -192,6 +192,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
||||||
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
|
"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": {
|
"media-typer": {
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
"homepage": "https://github.com/chrisvrose/nodejs-fm#readme",
|
"homepage": "https://github.com/chrisvrose/nodejs-fm#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.0"
|
"express": "^4.17.0",
|
||||||
|
"jquery": "^3.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,8 @@
|
|||||||
|
const paths = require('path')
|
||||||
|
module.exports.mergedir = (dirname,settings)=>{
|
||||||
|
return paths.join(settings.dirname,dirname);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.dirprocess = (dirstream,settings)=>{
|
module.exports.dirprocess = (dirstream,settings)=>{
|
||||||
if(!settings.showHidden){
|
if(!settings.showHidden){
|
||||||
let fdirstream = dirstream.filter((ele)=>{
|
let fdirstream = dirstream.filter((ele)=>{
|
||||||
@@ -5,6 +10,8 @@ module.exports.dirprocess = (dirstream,settings)=>{
|
|||||||
})
|
})
|
||||||
return fdirstream
|
return fdirstream
|
||||||
}
|
}
|
||||||
else return dirstream
|
else{
|
||||||
|
return dirstream
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,6 +83,22 @@ body{
|
|||||||
margin-top:0.5rem;
|
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-1{
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||||
|
8
static/base.js
Normal file
8
static/base.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
let currDir = '/';
|
||||||
|
|
||||||
|
|
||||||
|
//set table details
|
||||||
|
function setList(){
|
||||||
|
|
||||||
|
}
|
@@ -4,6 +4,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>FM</title>
|
<title>FM</title>
|
||||||
<link rel="stylesheet" href="base.css" />
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<script src="jquery/jquery.min.js"></script>
|
||||||
|
<script src="base.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar-container box-shadow-1">
|
<div class="navbar-container box-shadow-1">
|
||||||
@@ -15,14 +17,20 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="content box-shadow-1">
|
<div class="content box-shadow-1">
|
||||||
<table id="files-details">
|
<table id="files-details">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>File Name</td>
|
||||||
|
<td>Actions</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>TEST1</td>
|
<td>TEST1</td>
|
||||||
<td>TEST2</td>
|
<td class="file-handlers">TEST2</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>TEST3</td>
|
<td>TEST3</td>
|
||||||
<td>TEST4</td>
|
<td class="file-handlers">TEST4</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Reference in New Issue
Block a user