owntone-server/web-src/src/components/ModalDialogRemotePairing.vue

81 lines
2.3 KiB
Vue
Raw Normal View History

<template>
<div>
<transition name="fade">
<div v-if="show" class="modal is-active">
<div class="modal-background" @click="$emit('close')" />
<div class="modal-content fd-modal-card">
<div class="card">
<div class="card-content">
2022-05-20 07:44:22 -04:00
<p class="title is-4" v-text="$t('dialog.remote-pairing.title')" />
<form @submit.prevent="kickoff_pairing">
2022-05-20 07:44:22 -04:00
<label class="label" v-text="pairing.remote" />
<div class="field">
<div class="control">
2022-05-20 07:44:22 -04:00
<input ref="pin_field" v-model="pairing_req.pin" class="input" type="text" placeholder="Enter pairing code" />
</div>
</div>
</form>
</div>
<footer class="card-footer">
2022-05-20 07:44:22 -04:00
<a class="card-footer-item has-text-danger" @click="$emit('close')">
<mdicon class="icon" name="cancel" size="16" />
<span class="is-size-7" v-text="$t('dialog.remote-pairing.cancel')" />
</a>
2022-05-20 07:44:22 -04:00
<a class="card-footer-item has-background-info has-text-white has-text-weight-bold" @click="kickoff_pairing">
<mdicon class="icon" name="cellphone" size="16" />
<span class="is-size-7" v-text="$t('dialog.remote-pairing.pair')" />
</a>
</footer>
</div>
</div>
2022-05-20 07:44:22 -04:00
<button class="modal-close is-large" aria-label="close" @click="$emit('close')" />
</div>
</transition>
</div>
</template>
<script>
import webapi from '@/webapi'
export default {
name: 'ModalDialogRemotePairing',
props: ['show'],
2022-02-19 01:05:59 -05:00
emits: ['close'],
data() {
return {
pairing_req: { pin: '' }
}
},
computed: {
pairing() {
return this.$store.state.pairing
}
},
watch: {
show() {
if (this.show) {
this.loading = false
// We need to delay setting the focus to the input field until the field is part of the dom and visible
setTimeout(() => {
this.$refs.pin_field.focus()
}, 10)
}
}
},
methods: {
kickoff_pairing() {
webapi.pairing_kickoff(this.pairing_req).then(() => {
this.pairing_req.pin = ''
})
}
}
}
</script>
<style></style>