aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/js/app.js')
-rw-r--r--frontend/js/app.js44
1 files changed, 43 insertions, 1 deletions
diff --git a/frontend/js/app.js b/frontend/js/app.js
index d99a840..05cbe9c 100644
--- a/frontend/js/app.js
+++ b/frontend/js/app.js
@@ -43,6 +43,8 @@ function initWithToken(accessToken) {
43 app.folderListingEnabled = !!result.body.folderListingEnabled; 43 app.folderListingEnabled = !!result.body.folderListingEnabled;
44 44
45 loadDirectory(decode(window.location.hash.slice(1))); 45 loadDirectory(decode(window.location.hash.slice(1)));
46
47 app.refreshAccessTokens();
46 }); 48 });
47 }); 49 });
48} 50}
@@ -278,7 +280,9 @@ var app = new Vue({
278 password: '', 280 password: '',
279 busy: false 281 busy: false
280 }, 282 },
281 entries: [] 283 entries: [],
284 accessTokens: [],
285 accessTokensDialogVisible: false
282 }, 286 },
283 methods: { 287 methods: {
284 onLogin: function () { 288 onLogin: function () {
@@ -312,6 +316,8 @@ var app = new Vue({
312 }).then(function () {}).catch(function () {}); 316 }).then(function () {}).catch(function () {});
313 } else if (command === 'logout') { 317 } else if (command === 'logout') {
314 logout(); 318 logout();
319 } else if (command === 'apiAccess') {
320 this.accessTokensDialogVisible = true;
315 } 321 }
316 }, 322 },
317 onDownload: function (entry) { 323 onDownload: function (entry) {
@@ -415,6 +421,42 @@ var app = new Vue({
415 }); 421 });
416 }).catch(function () {}); 422 }).catch(function () {});
417 }, 423 },
424 refreshAccessTokens: function () {
425 var that = this;
426
427 superagent.get('/api/tokens').query({ access_token: localStorage.accessToken }).end(function (error, result) {
428 if (error && !result) return that.$message.error(error.message);
429
430 that.accessTokens = result.body.accessTokens;
431 });
432 },
433 onCopyAccessToken: function (event) {
434 event.target.select();
435 document.execCommand('copy');
436
437 this.$message({ type: 'success', message: 'Access token copied to clipboard' });
438 },
439 onCreateAccessToken: function () {
440 var that = this;
441
442 superagent.post('/api/tokens').query({ access_token: localStorage.accessToken }).end(function (error, result) {
443 if (error && !result) return that.$message.error(error.message);
444
445 that.refreshAccessTokens();
446 });
447 },
448 onDeleteAccessToken: function (token) {
449 var that = this;
450
451 this.$confirm('All actions from apps using this token will fail!', 'Really delete this access token?', { confirmButtonText: 'Yes Delete', cancelButtonText: 'No' }).then(function () {
452 superagent.delete('/api/tokens/' + token).query({ access_token: localStorage.accessToken }).end(function (error, result) {
453 if (error && !result) return that.$message.error(error.message);
454
455 that.refreshAccessTokens();
456 });
457 }).catch(function () {});
458
459 },
418 prettyDate: function (row, column, cellValue, index) { 460 prettyDate: function (row, column, cellValue, index) {
419 var date = new Date(cellValue), 461 var date = new Date(cellValue),
420 diff = (((new Date()).getTime() - date.getTime()) / 1000), 462 diff = (((new Date()).getTime() - date.getTime()) / 1000),