+ refreshAccessTokens: function () {
+ var that = this;
+
+ superagent.get('/api/tokens').query({ access_token: localStorage.accessToken }).end(function (error, result) {
+ if (error && !result) return that.$message.error(error.message);
+
+ that.accessTokens = result.body.accessTokens;
+ });
+ },
+ onCopyAccessToken: function (event) {
+ event.target.select();
+ document.execCommand('copy');
+
+ this.$message({ type: 'success', message: 'Access token copied to clipboard' });
+ },
+ onCreateAccessToken: function () {
+ var that = this;
+
+ superagent.post('/api/tokens').query({ access_token: localStorage.accessToken }).end(function (error, result) {
+ if (error && !result) return that.$message.error(error.message);
+
+ that.refreshAccessTokens();
+ });
+ },
+ onDeleteAccessToken: function (token) {
+ var that = this;
+
+ this.$confirm('All actions from apps using this token will fail!', 'Really delete this access token?', { confirmButtonText: 'Yes Delete', cancelButtonText: 'No' }).then(function () {
+ superagent.delete('/api/tokens/' + token).query({ access_token: localStorage.accessToken }).end(function (error, result) {
+ if (error && !result) return that.$message.error(error.message);
+
+ that.refreshAccessTokens();
+ });
+ }).catch(function () {});
+
+ },