Skip to content

Commit 9762509

Browse files
lukaslihotzkipeterthomassen
authored andcommitted
refactor(webapp): replace vue-clipboard2
1 parent 0ad7a6e commit 9762509

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

www/webapp/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"date-fns": "^2.30.0",
1818
"pinia": "^2.0.30",
1919
"vue": "~2.7.14",
20-
"vue-clipboard2": "^0.3.3",
2120
"vue-router": "~3.6.5",
2221
"vuelidate": "^0.7.7",
2322
"vuetify": "^2.6.13"

www/webapp/src/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Vue from 'vue'
22
import App from '@/App.vue'
33
import router from '@/router'
44
import vuetify from '@/plugins/vuetify'
5-
import VueClipboard from 'vue-clipboard2'
65
import VueRouter from 'vue-router'
76
import Vuelidate from 'vuelidate'
87
import "@fontsource/roboto/300.css" /* light */
@@ -15,8 +14,6 @@ import {createPinia, PiniaVuePlugin} from "pinia";
1514

1615

1716
Vue.config.productionTip = false
18-
VueClipboard.config.autoSetContainer = true
19-
Vue.use(VueClipboard)
2017
Vue.use(Vuelidate)
2118
// `Pinia` replaces `vuex` as store.
2219
Vue.use(PiniaVuePlugin)

www/webapp/src/views/DomainSetup.vue

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
<pre class="pa-3">{{ ns.join('\n') }}</pre>
4040
<v-card-actions>
4141
<v-btn
42-
v-clipboard:copy="ns.join('\n')"
43-
v-clipboard:success="copySuccess"
44-
v-clipboard:error="copyError"
42+
@click="copyToClipboard(ns.join('\n'))"
4543
outlined
4644
text
4745
>
@@ -88,9 +86,7 @@
8886
<pre class="pa-3">{{ t.data }}</pre>
8987
<v-card-actions>
9088
<v-btn
91-
v-clipboard:copy="t.data"
92-
v-clipboard:success="copySuccess"
93-
v-clipboard:error="copyError"
89+
@click="copyToClipboard(t.data)"
9490
outlined
9591
text
9692
>
@@ -193,11 +189,19 @@ export default {
193189
},
194190
},
195191
methods: {
196-
copySuccess: function () {
197-
this.showSnackbar("Copied to clipboard.");
198-
},
199-
copyError: function () {
200-
this.showSnackbar("Copy to clipboard failed. Please try again manually.");
192+
copyToClipboard: async function (text) {
193+
try {
194+
await navigator.clipboard.writeText(text).then(
195+
() => {
196+
this.showSnackbar("Copied to clipboard.");
197+
},
198+
() => {
199+
this.showSnackbar("Copy to clipboard not allowed. Please try again manually.");
200+
},
201+
);
202+
} catch (e) {
203+
this.showSnackbar("Copy to clipboard failed. Please try again manually.");
204+
}
201205
},
202206
showSnackbar: function (text) {
203207
this.snackbar_text = text;

0 commit comments

Comments
 (0)