Fix copy base64 link on download tab

pull/159/head
MattIPv4 2020-06-18 17:37:01 +01:00
parent 9e54885d17
commit 824b0312fd
2 changed files with 11 additions and 8 deletions

View File

@ -100,7 +100,7 @@ THE SOFTWARE.
},
},
mounted() {
this.setupCopy();
this.setupCopy(this.$refs.copyTar);
},
methods: {
tabClass(tab) {
@ -148,27 +148,27 @@ THE SOFTWARE.
const b64 = btoa(String.fromCharCode(...contents));
return `echo '${b64}' | base64 --decode | tee ${this.$props.data.global.nginx.nginxConfigDirectory.computed}/${this.tarName} > /dev/null`;
},
setupCopy() {
const originalText = this.$refs.copyTar.textContent;
setupCopy(elm) {
const originalText = elm.textContent;
const resetText = () => {
setTimeout(() => {
this.$refs.copyTar.textContent = originalText;
elm.textContent = originalText;
}, 5000);
};
const clipboard = new ClipboardJS(this.$refs.copyTar, {
const clipboard = new ClipboardJS(elm, {
text: this.copyTar,
});
clipboard.on('success', e => {
this.$refs.copyTar.textContent = 'Copied';
elm.textContent = 'Copied';
e.clearSelection();
resetText();
});
clipboard.on('error', () => {
this.$refs.copyTar.textContent = 'Press Ctrl + C to copy';
elm.textContent = 'Press Ctrl + C to copy';
resetText();
});
},

View File

@ -39,7 +39,7 @@ THE SOFTWARE.
<p>
{{ i18n.templates.setupSections.download.or }}
<b>
<a @click="$parent.copyTar">
<a ref="copyTar">
{{ i18n.templates.setupSections.download.copyBase64StringOfCompressedConfig }}</a>
</b>
<span v-html="i18n.templates.setupSections.download.pasteItInYourServersCommandLineAndExecute"></span>
@ -94,5 +94,8 @@ THE SOFTWARE.
i18n,
};
},
mounted() {
this.$parent.setupCopy(this.$refs.copyTar);
},
};
</script>