diff --git a/client/pages/config/users/_id.vue b/client/pages/config/users/_id.vue
index 7b77915c..196c10d2 100644
--- a/client/pages/config/users/_id.vue
+++ b/client/pages/config/users/_id.vue
@@ -13,6 +13,9 @@
{{ username }}
+
+
API Token:
{{ userToken }}content_copy
+
Listening Stats (experimental)
@@ -87,6 +90,9 @@ export default {
}
},
computed: {
+ userToken() {
+ return this.user.token
+ },
coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio')
},
@@ -127,6 +133,9 @@ export default {
}
},
methods: {
+ copyToClipboard(str) {
+ this.$copyToClipboard(str, this)
+ },
async init() {
this.listeningSessions = await this.$axios.$get(`/api/users/${this.user.id}/listening-sessions`).catch((err) => {
console.error('Failed to load listening sesions', err)
diff --git a/client/plugins/init.client.js b/client/plugins/init.client.js
index 50582804..a565d4a4 100644
--- a/client/plugins/init.client.js
+++ b/client/plugins/init.client.js
@@ -125,6 +125,23 @@ Vue.prototype.$sanitizeFilename = (input, replacement = '') => {
return sanitized
}
+Vue.prototype.$copyToClipboard = (str, ctx) => {
+ return new Promise((resolve) => {
+ if (!navigator.clipboard) {
+ console.warn('Clipboard not supported')
+ return resolve(false)
+ }
+ navigator.clipboard.writeText(str).then(() => {
+ console.log('Clipboard copy success', str)
+ ctx.$toast.success('Copied to clipboard')
+ resolve(true)
+ }, (err) => {
+ console.error('Clipboard copy failed', str, err)
+ resolve(false)
+ })
+ })
+}
+
function xmlToJson(xml) {
const json = {};