X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=frontend%2Fjs%2Fapp.js;h=0875f1459e0d820299ab9cb075e91c1ee9256dbd;hb=c667d125938bbf6e89c89572646cd06f3e2bffd3;hp=b07560affa57d8bff120ad7c87d3ac92bbfd12a1;hpb=4a27fce742a75881cd84607f4237624d8c0a0a22;p=perso%2FImmae%2FProjets%2FNodejs%2FSurfer.git diff --git a/frontend/js/app.js b/frontend/js/app.js index b07560a..0875f14 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -27,7 +27,7 @@ function login(username, password) { app.busy = true; - superagent.post('/api/login').query({ username: username, password: password }).end(function (error, result) { + superagent.post('/api/login').send({ username: username, password: password }).end(function (error, result) { app.busy = false; if (error) return console.error(error); @@ -135,6 +135,12 @@ function open(entry) { window.open(encode(path)); } +function download(entry) { + if (entry.isDirectory) return; + + window.location.href = 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, @@ -344,7 +351,11 @@ var app = new Vue({ window.app = app; -getProfile(localStorage.accessToken); +getProfile(localStorage.accessToken, function (error) { + if (error) return console.error(error); + + loadDirectory(window.location.hash.slice(1)); +}); $(window).on('hashchange', function () { loadDirectory(window.location.hash.slice(1));