add repositioning

This commit is contained in:
2020-12-05 10:43:11 +05:30
parent 4f9ee6ba1c
commit 223a9cb197
3 changed files with 33 additions and 18 deletions

View File

@@ -5,13 +5,14 @@ const fs = require('fs')
const path = require('path') const path = require('path')
const processing = require('./processing') const processing = require('./processing')
const busboy = require('connect-busboy') const busboy = require('connect-busboy')
const morgan = require('morgan');
// Import settings // Import settings
const settings = JSON.parse(fs.readFileSync("settings.json")) const settings = JSON.parse(fs.readFileSync("settings.json"))
app = express() app = express()
app.use(bodyParser.urlencoded({extended:false})) app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json()) app.use(bodyParser.json())
app.use(morgan('tiny'))
app.use(busboy()) app.use(busboy())
///Make the directory if it doesnt exist ///Make the directory if it doesnt exist

View File

@@ -94,10 +94,15 @@ label[for="fileUpload"]{
height: 2rem; height: 2rem;
width:100%; width:100%;
font-size:1.5em; font-size:1.5em;
position:fixed;
bottom:0;
} }
.nav-bottom-button-container{ .nav-bottom-button-container{
width:100%; width:100%;
text-align: right; text-align: right;
position: fixed;
/* float: right; */
bottom:2.8rem;
} }
.nav-bottom-button{ .nav-bottom-button{
margin-bottom: 1rem; margin-bottom: 1rem;

View File

@@ -37,8 +37,8 @@ async function postLS(inputPath){
///Send request to move/rename files ///Send request to move/rename files
async function postMV(oldLocation,newLocation){ async function postMV(oldLocation,newLocation){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
$.ajax({ $.ajax('/files/mv',{
method:"post", method:'post',
data: makeMVRequest(oldLocation,newLocation), data: makeMVRequest(oldLocation,newLocation),
success:response=>{ success:response=>{
resolve(response) resolve(response)
@@ -111,10 +111,12 @@ function closeUploadWindow(){
} }
$(document).ready(()=>{ $(()=>{
postLS(".").then(e=>{updateContents(e)},e=>console.log(e)) postLS(".")
.then(e=>{updateContents(e)})
.catch(err=>console.log(err))
//postLS(currDir.loc); //postLS(currDir.loc);
$('.file-download-button').click(()=>{ $('.file-download-button').on('click',()=>{
console.log(currSel) console.log(currSel)
if(currSel.loc===null){ if(currSel.loc===null){
// This shouldn't happen but ok // This shouldn't happen but ok
@@ -122,44 +124,46 @@ $(document).ready(()=>{
} }
else{ else{
$('.file-download-button').after(`<a id="down-temp" href="/files/cat?loc=${currSel.loc}" download="${currSel.name}"></a>`) $('.file-download-button').after(`<a id="down-temp" href="/files/cat?loc=${currSel.loc}" download="${currSel.name}"></a>`)
document.getElementById('down-temp').click() document.getElementById('down-temp').on('click',)
$('#down-temp').remove(); $('#down-temp').remove();
} }
}) })
$('.close-rename').click(()=>{ $('.close-rename').on('click',()=>{
closeRenameWindow(); closeRenameWindow();
}) })
$('.close-upload').click(()=>{ $('.close-upload').on('click',()=>{
closeUploadWindow(); closeUploadWindow();
}) })
$('.file-rename-button').click(()=>{ $('.file-rename-button').on('click',()=>{
if(currSel.loc===null){ if(currSel.loc===null){
alert("No file selected") alert("No file selected")
} }
else{ else{
$("#nloc-input").val(currSel.loc) $("#nloc-input").val(currSel.loc)
$('#cover').fadeIn('fast')
$('.rename-window').fadeIn('fast')
} }
$('#cover').fadeIn('fast')
$('.rename-window').fadeIn('fast')
}) })
$('.nav-bottom-button').click(()=>{ $('.nav-bottom-button').on('click',()=>{
$('#cover').fadeIn('fast') $('#cover').fadeIn('fast')
$('.upload-window').fadeIn('fast') $('.upload-window').fadeIn('fast')
}) })
$('.done-rename').click(()=>{ $('.done-rename').on('click',()=>{
if(currSel.loc===null){ if(currSel.loc===null){
alert("Please select a file"); alert("Please select a file");
} }
else{ else{
postMV(currSel.loc,$("#nloc-input").val()) postMV(currSel.loc,$("#nloc-input").val())
.then(response=>{ .then(response=>{
postLS(currDir.loc) postLS(currDir.loc).then(e=>{updateContents(e)})
.catch(err=>console.log(err))
}) })
.then(response=>{ .then(response=>{
alert("Moved") alert("Moved")
}, },
err=>{ err=>{
console.log('E',err);
alert("Not moved") alert("Not moved")
}) })
.catch(err=>{ .catch(err=>{
@@ -168,11 +172,11 @@ $(document).ready(()=>{
} }
}) })
$("#fileInput").change((e)=>{ $("#fileInput").on('change',(e)=>{
console.log(e.target.files) console.log(e.target.files)
$("#fileLabel").html(e.target.files[0].name); $("#fileLabel").html(e.target.files[0].name);
}) })
$(".done-upload").click(()=>{ $(".done-upload").on('click',()=>{
$("#fileLabel").html("Uploading") $("#fileLabel").html("Uploading")
$("#upload-directory").val(currDir.loc) $("#upload-directory").val(currDir.loc)
$.ajax("/files/upload",{ $.ajax("/files/upload",{
@@ -183,9 +187,14 @@ $(document).ready(()=>{
success:msg=>{ success:msg=>{
alert("Uploaded") alert("Uploaded")
closeUploadWindow(); closeUploadWindow();
postLS(currDir.loc); postLS(currDir.loc).then(e=>{updateContents(e)})
.catch(err=>console.log(err));
}, },
error:msg=>alert("Error") error:msg=>alert("Error")
}).progress(function (){
console.log('prog');
// $("#fileLabel").html("Uploading",progress)
}) })
}) })
}) })