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

View File

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