secrets migration & restitution
This commit is contained in:
21
html/ui/js/GetCopy.js
Normal file
21
html/ui/js/GetCopy.js
Normal file
@ -0,0 +1,21 @@
|
||||
export default {
|
||||
props: [ 'name', 'href', 'token' ],
|
||||
data() { return {showCopied: false} },
|
||||
template: `<span class="notif"><div v-if="showCopied">copied!</div><a :href="href" @click="fetchAndCopy()">{{name}}<small> 🗐</small></a></span>`,
|
||||
methods: {
|
||||
fetchAndCopy() {
|
||||
event.preventDefault()
|
||||
|
||||
fetch(this.href, {
|
||||
method: 'GET',
|
||||
headers: { 'Authorization': 'Bearer ' + this.token },
|
||||
}).then((resp) => resp.headers.get("content-type") == "application/json" ? resp.json() : resp.text())
|
||||
.then((value) => {
|
||||
window.navigator.clipboard.writeText(value)
|
||||
this.showCopied = true
|
||||
setTimeout(() => { this.showCopied = false }, 1000)
|
||||
})
|
||||
.catch((e) => { console.log("failed to get value:", e); alert('failed to get value') })
|
||||
},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user