Skip to content

Commit

Permalink
refactor(webapp): replace vue-clipboard2
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslihotzki authored and Rotzbua committed Jul 12, 2023
1 parent d97827b commit 9444de9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
1 change: 0 additions & 1 deletion www/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"date-fns": "^2.30.0",
"pinia": "^2.0.30",
"vue": "~2.7.14",
"vue-clipboard2": "^0.3.3",
"vue-router": "~3.6.5",
"vuelidate": "^0.7.7",
"vuetify": "^2.6.13"
Expand Down
3 changes: 0 additions & 3 deletions www/webapp/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Vue from 'vue'
import App from '@/App.vue'
import router from '@/router'
import vuetify from '@/plugins/vuetify'
import VueClipboard from 'vue-clipboard2'
import VueRouter from 'vue-router'
import Vuelidate from 'vuelidate'
import "@fontsource/roboto/300.css" /* light */
Expand All @@ -15,8 +14,6 @@ import {createPinia, PiniaVuePlugin} from "pinia";


Vue.config.productionTip = false
VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)
Vue.use(Vuelidate)
// `Pinia` replaces `vuex` as store.
Vue.use(PiniaVuePlugin)
Expand Down
26 changes: 15 additions & 11 deletions www/webapp/src/views/DomainSetup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
<pre class="pa-3">{{ ns.join('\n') }}</pre>
<v-card-actions>
<v-btn
v-clipboard:copy="ns.join('\n')"
v-clipboard:success="copySuccess"
v-clipboard:error="copyError"
@click="copyToClipboard(ns.join('\n'))"
outlined
text
>
Expand Down Expand Up @@ -88,9 +86,7 @@
<pre class="pa-3">{{ t.data }}</pre>
<v-card-actions>
<v-btn
v-clipboard:copy="t.data"
v-clipboard:success="copySuccess"
v-clipboard:error="copyError"
@click="copyToClipboard(t.data)"
outlined
text
>
Expand Down Expand Up @@ -193,11 +189,19 @@ export default {
},
},
methods: {
copySuccess: function () {
this.showSnackbar("Copied to clipboard.");
},
copyError: function () {
this.showSnackbar("Copy to clipboard failed. Please try again manually.");
copyToClipboard: async function (text) {
try {
await navigator.clipboard.writeText(text).then(
() => {
this.showSnackbar("Copied to clipboard.");
},
() => {
this.showSnackbar("Copy to clipboard not allowed. Please try again manually.");
},
);
} catch (e) {
this.showSnackbar("Copy to clipboard failed. Please try again manually.");
}
},
showSnackbar: function (text) {
this.snackbar_text = text;
Expand Down

0 comments on commit 9444de9

Please sign in to comment.