Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#110] Add interaction buttons for displayed secret #111

Merged
merged 3 commits into from
Aug 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 72 additions & 6 deletions src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,57 @@
</template>
<template v-else>
<b-form-group>
<b-form-textarea
max-rows="25"
readonly
rows="5"
:value="secret"
/>
<b-input-group>
<b-form-textarea
max-rows="25"
readonly
rows="4"
:value="secret"
/>
<b-input-group-text class="d-flex align-items-start p-0">
<b-button-group vertical>
<b-button
v-if="hasClipboard"
:disabled="!secretUrl"
:variant="copyToClipboardSuccess ? 'success' : 'primary'"
title="Copy Secret to Clipboard"
@click="copySecret"
>
<i class="fas fa-fw fa-clipboard" />
</b-button>
<b-button
:href="`data:text/plain;charset=UTF-8,${secret}`"
download
title="Download Secret as Text File"
>
<i class="fas fa-fw fa-download" />
</b-button>
<b-button
v-if="!customize.disableQRSupport && secretContentQRDataURL"
id="secret-data-qrcode"
variant="secondary"
title="Display Content as QR-Code"
>
<i class="fas fa-fw fa-qrcode" />
</b-button>
</b-button-group>
</b-input-group-text>
</b-input-group>
</b-form-group>
<p v-html="$t('text-hint-burned')" />

<b-popover
v-id="!customize.disableQRSupport"
target="secret-data-qrcode"
triggers="focus"
placement="leftbottom"
>
<b-img
height="200"
:src="secretContentQRDataURL"
width="200"
/>
</b-popover>
</template>
</b-card>
</b-col>
Expand Down Expand Up @@ -311,6 +354,7 @@ export default {
secretExpiry: null,
secretId: '',
secretQRDataURL: '',
secretContentQRDataURL: '',
securePassword: '',
selectedExpiry: null,
showError: false,
Expand All @@ -335,6 +379,16 @@ export default {
})
},

copySecret() {
navigator.clipboard.writeText(this.secret)
.then(() => {
this.copyToClipboardSuccess = true
window.setTimeout(() => {
this.copyToClipboardSuccess = false
}, 500)
})
},

copySecretUrl() {
navigator.clipboard.writeText(this.secretUrl)
.then(() => {
Expand Down Expand Up @@ -503,6 +557,18 @@ export default {
window.setTheme(to ? 'dark' : 'light')
},

secret(to) {
if (this.customize.disableQRSupport || !to) {
return
}

qrcode.toDataURL(to, { width: 200 })
.then(url => {
this.secretContentQRDataURL = url
})
.catch(() => this.secretContentQRDataURL = null)
},

secretUrl(to) {
if (this.customize.disableQRSupport) {
return
Expand Down