From 9138d7d40ba6570347dd21fc95d03641360c7461 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 1 Mar 2016 16:07:44 +0100 Subject: [PATCH] Implement file deletion --- app/index.html | 20 +++++++++++++++++++- app/js/app.js | 27 ++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/app/index.html b/app/index.html index 721ec25..bc9ac22 100644 --- a/app/index.html +++ b/app/index.html @@ -31,6 +31,24 @@ + +
@@ -102,7 +120,7 @@ {{ entry.filePath }} {{ entry.size }} {{ entry.mtime }} - + diff --git a/app/js/app.js b/app/js/app.js index e2fe621..823e4f7 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -101,6 +101,28 @@ function upload() { app.$els.upload.click(); } +function delAsk(entry) { + $('#modalDelete').modal('show'); + app.deleteData = entry; +} + +function del(entry) { + app.busy = true; + + var path = encode(sanitize(app.path + '/' + entry.filePath)); + + superagent.del('/api/files' + path).query({ username: app.session.username, password: app.session.password, recursive: true }).end(function (error, result) { + app.busy = false; + + if (error) return console.error(error); + if (result.statusCode !== 200) return console.error('Error deleting file: ', result.statusCode); + + refresh(); + + $('#modalDelete').modal('hide'); + }); +} + var app = new Vue({ el: '#app', data: { @@ -111,6 +133,7 @@ var app = new Vue({ valid: false }, loginData: {}, + deleteData: {}, entries: [] }, methods: { @@ -119,7 +142,9 @@ var app = new Vue({ loadDirectory: loadDirectory, open: open, up: up, - upload: upload + upload: upload, + delAsk: delAsk, + del: del } }); -- 2.41.0