mirror of
https://github.com/Luzifer/ots.git
synced 2024-12-24 22:59:33 -05:00
[#91] Add Copy-to-Clipboard button to secret URL
closes #91 Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
1a2a6de9a7
commit
f5aebbb99a
30
src/app.vue
30
src/app.vue
@ -130,13 +130,20 @@
|
|||||||
readonly
|
readonly
|
||||||
@focus="$refs.secretUrl.select()"
|
@focus="$refs.secretUrl.select()"
|
||||||
/>
|
/>
|
||||||
<b-input-group-append
|
<b-input-group-append>
|
||||||
v-if="!customize.disableQRSupport"
|
|
||||||
>
|
|
||||||
<b-button
|
<b-button
|
||||||
|
v-if="hasClipboard"
|
||||||
|
:disabled="!secretUrl"
|
||||||
|
:variant="copyToClipboardSuccess ? 'success' : 'primary'"
|
||||||
|
@click="copySecretUrl"
|
||||||
|
>
|
||||||
|
<i class="fas fa-clipboard" />
|
||||||
|
</b-button>
|
||||||
|
<b-button
|
||||||
|
v-if="!customize.disableQRSupport"
|
||||||
id="secret-url-qrcode"
|
id="secret-url-qrcode"
|
||||||
:disabled="!secretQRDataURL"
|
:disabled="!secretQRDataURL"
|
||||||
variant="primary"
|
variant="secondary"
|
||||||
>
|
>
|
||||||
<i class="fas fa-qrcode" />
|
<i class="fas fa-qrcode" />
|
||||||
</b-button>
|
</b-button>
|
||||||
@ -216,6 +223,10 @@ const passwordLength = 20
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
|
hasClipboard() {
|
||||||
|
return Boolean(navigator.clipboard && navigator.clipboard.writeText)
|
||||||
|
},
|
||||||
|
|
||||||
secretUrl() {
|
secretUrl() {
|
||||||
return [
|
return [
|
||||||
window.location.href,
|
window.location.href,
|
||||||
@ -229,6 +240,7 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
copyToClipboardSuccess: false,
|
||||||
customize: {},
|
customize: {},
|
||||||
darkTheme: false,
|
darkTheme: false,
|
||||||
error: '',
|
error: '',
|
||||||
@ -243,6 +255,16 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
copySecretUrl() {
|
||||||
|
navigator.clipboard.writeText(this.secretUrl)
|
||||||
|
.then(() => {
|
||||||
|
this.copyToClipboardSuccess = true
|
||||||
|
window.setTimeout(() => {
|
||||||
|
this.copyToClipboardSuccess = false
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// createSecret executes the secret creation after encrypting the secret
|
// createSecret executes the secret creation after encrypting the secret
|
||||||
createSecret() {
|
createSecret() {
|
||||||
if (this.secret.trim().length < 1) {
|
if (this.secret.trim().length < 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user