]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blobdiff - frontend/js/app.js
Add file download button
[perso/Immae/Projets/Nodejs/Surfer.git] / frontend / js / app.js
index befed24f251ce893642c436df4a8241ccb972785..bf9b5348953abfc6d67effd7ce29394cddffd857 100644 (file)
@@ -135,6 +135,12 @@ function open(entry) {
     window.open(encode(path));
 }
 
+function download(entry) {
+    if (entry.isDirectory) return;
+
+    window.open(encode('/api/files/' + sanitize(app.path + '/' + entry.filePath)) + '?access_token=' + localStorage.accessToken);
+}
+
 function up() {
     window.location.hash = sanitize(app.path.split('/').slice(0, -1).filter(function (p) { return !!p; }).join('/'));
 }
@@ -329,6 +335,7 @@ var app = new Vue({
         logout: logout,
         loadDirectory: loadDirectory,
         open: open,
+        download: download,
         up: up,
         upload: upload,
         delAsk: delAsk,