2019-05-11 14:01:25 +01:00
|
|
|
<template>
|
2025-02-09 08:05:03 +01:00
|
|
|
<modal-dialog :actions="actions" :show="show" @close="$emit('close')">
|
|
|
|
<template #content>
|
2025-02-04 22:00:48 +01:00
|
|
|
<form @submit.prevent="play">
|
|
|
|
<p class="title is-4" v-text="$t('dialog.add.stream.title')" />
|
|
|
|
<div class="field">
|
|
|
|
<p class="control has-icons-left">
|
|
|
|
<input
|
|
|
|
ref="url_field"
|
|
|
|
v-model="url"
|
|
|
|
class="input"
|
|
|
|
type="url"
|
|
|
|
pattern="http[s]?://.+"
|
|
|
|
required
|
|
|
|
:placeholder="$t('dialog.add.stream.placeholder')"
|
|
|
|
:disabled="loading"
|
|
|
|
@input="check_url"
|
|
|
|
/>
|
|
|
|
<mdicon class="icon is-left" name="web" size="16" />
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</template>
|
2025-02-08 14:35:25 +01:00
|
|
|
</modal-dialog>
|
2019-05-11 14:01:25 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2025-02-08 14:35:25 +01:00
|
|
|
import ModalDialog from '@/components/ModalDialog.vue'
|
2019-05-11 14:01:25 +01:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ModalDialogAddUrlStream',
|
2025-02-08 14:35:25 +01:00
|
|
|
components: { ModalDialog },
|
2024-02-27 17:18:58 +01:00
|
|
|
props: { show: Boolean },
|
2022-02-19 07:05:59 +01:00
|
|
|
emits: ['close'],
|
2022-02-19 06:39:14 +01:00
|
|
|
data() {
|
2019-05-11 14:01:25 +01:00
|
|
|
return {
|
2024-03-28 15:45:39 +01:00
|
|
|
disabled: true,
|
2024-03-26 15:00:17 +01:00
|
|
|
loading: false,
|
|
|
|
url: ''
|
2019-05-11 14:01:25 +01:00
|
|
|
}
|
|
|
|
},
|
2025-02-08 14:27:54 +01:00
|
|
|
computed: {
|
|
|
|
actions() {
|
|
|
|
if (this.loading) {
|
|
|
|
return [{ label: this.$t('dialog.add.stream.processing'), icon: 'web' }]
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: this.$t('dialog.add.stream.cancel'),
|
2025-02-09 08:05:03 +01:00
|
|
|
handler: this.cancel,
|
2025-02-08 14:27:54 +01:00
|
|
|
icon: 'cancel'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.$t('dialog.add.stream.add'),
|
|
|
|
disabled: this.disabled,
|
2025-02-09 08:05:03 +01:00
|
|
|
handler: this.add,
|
2025-02-08 14:27:54 +01:00
|
|
|
icon: 'playlist-plus'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.$t('dialog.add.stream.play'),
|
|
|
|
disabled: this.disabled,
|
2025-02-09 08:05:03 +01:00
|
|
|
handler: this.play,
|
2025-02-08 14:27:54 +01:00
|
|
|
icon: 'play'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2019-05-28 22:48:58 +02:00
|
|
|
watch: {
|
2022-02-19 06:39:14 +01:00
|
|
|
show() {
|
2019-05-28 22:48:58 +02:00
|
|
|
if (this.show) {
|
|
|
|
this.loading = false
|
2024-04-15 22:50:11 +02:00
|
|
|
// Delay setting the focus on the input field until it is part of the DOM and visible
|
2019-05-28 22:48:58 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
this.$refs.url_field.focus()
|
|
|
|
}, 10)
|
|
|
|
}
|
2019-05-11 14:01:25 +01:00
|
|
|
}
|
2022-02-19 06:39:14 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2025-02-08 14:27:54 +01:00
|
|
|
add() {
|
2022-02-19 06:39:14 +01:00
|
|
|
this.loading = true
|
|
|
|
webapi
|
|
|
|
.queue_add(this.url)
|
|
|
|
.then(() => {
|
|
|
|
this.$emit('close')
|
|
|
|
this.url = ''
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
},
|
2025-02-09 08:05:03 +01:00
|
|
|
cancel() {
|
|
|
|
this.$emit('close')
|
|
|
|
},
|
2024-03-28 15:45:39 +01:00
|
|
|
check_url(event) {
|
|
|
|
const { validity } = event.target
|
|
|
|
this.disabled = validity.patternMismatch || validity.valueMissing
|
|
|
|
},
|
2025-02-09 08:05:03 +01:00
|
|
|
|
2023-06-07 21:25:54 +02:00
|
|
|
play() {
|
2022-02-19 06:39:14 +01:00
|
|
|
this.loading = true
|
|
|
|
webapi
|
|
|
|
.player_play_uri(this.url, false)
|
|
|
|
.then(() => {
|
|
|
|
this.$emit('close')
|
|
|
|
this.url = ''
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
}
|
2019-05-11 14:01:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|