diff options
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/js/app.js | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/frontend/js/app.js b/frontend/js/app.js index be5705f..0a6ada1 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js | |||
@@ -1,6 +1,11 @@ | |||
1 | (function () { | 1 | (function () { |
2 | 'use strict'; | 2 | 'use strict'; |
3 | 3 | ||
4 | /* global superagent */ | ||
5 | /* global Vue */ | ||
6 | /* global $ */ | ||
7 | /* global filesize */ | ||
8 | |||
4 | // poor man's async | 9 | // poor man's async |
5 | function asyncForEach(items, handler, callback) { | 10 | function asyncForEach(items, handler, callback) { |
6 | var cur = 0; | 11 | var cur = 0; |
@@ -86,6 +91,16 @@ function refresh() { | |||
86 | loadDirectory(app.path); | 91 | loadDirectory(app.path); |
87 | } | 92 | } |
88 | 93 | ||
94 | function logout() { | ||
95 | superagent.post('/api/logout').query({ access_token: localStorage.accessToken }).end(function (error) { | ||
96 | if (error) console.error(error); | ||
97 | |||
98 | app.session.valid = false; | ||
99 | |||
100 | delete localStorage.accessToken; | ||
101 | }); | ||
102 | } | ||
103 | |||
89 | function loadDirectory(filePath) { | 104 | function loadDirectory(filePath) { |
90 | app.busy = true; | 105 | app.busy = true; |
91 | 106 | ||
@@ -278,8 +293,6 @@ var app = new Vue({ | |||
278 | }); | 293 | }); |
279 | }, | 294 | }, |
280 | onOptionsMenu: function (command) { | 295 | onOptionsMenu: function (command) { |
281 | var that = this; | ||
282 | |||
283 | if (command === 'folderListing') { | 296 | if (command === 'folderListing') { |
284 | superagent.put('/api/settings').send({ folderListingEnabled: this.folderListingEnabled }).query({ access_token: localStorage.accessToken }).end(function (error) { | 297 | superagent.put('/api/settings').send({ folderListingEnabled: this.folderListingEnabled }).query({ access_token: localStorage.accessToken }).end(function (error) { |
285 | if (error) console.error(error); | 298 | if (error) console.error(error); |
@@ -295,13 +308,7 @@ var app = new Vue({ | |||
295 | center: true | 308 | center: true |
296 | }).then(function () {}).catch(function () {}); | 309 | }).then(function () {}).catch(function () {}); |
297 | } else if (command === 'logout') { | 310 | } else if (command === 'logout') { |
298 | superagent.post('/api/logout').query({ access_token: localStorage.accessToken }).end(function (error) { | 311 | logout(); |
299 | if (error) console.error(error); | ||
300 | |||
301 | that.session.valid = false; | ||
302 | |||
303 | delete localStorage.accessToken; | ||
304 | }); | ||
305 | } | 312 | } |
306 | }, | 313 | }, |
307 | onDownload: function (entry) { | 314 | onDownload: function (entry) { |