2019-05-11 14:01:25 +01:00
|
|
|
<template>
|
2025-02-04 22:00:48 +01:00
|
|
|
<modal-dialog :show="show" @close="$emit('close')">
|
|
|
|
<template #content>
|
|
|
|
<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>
|
|
|
|
<template v-if="loading" #footer>
|
|
|
|
<a class="card-footer-item has-text-dark">
|
|
|
|
<mdicon class="icon" name="web" size="16" />
|
|
|
|
<span class="is-size-7" v-text="$t('dialog.add.stream.loading')" />
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
<template v-else #footer>
|
|
|
|
<a class="card-footer-item has-text-dark" @click="$emit('close')">
|
|
|
|
<mdicon class="icon" name="cancel" size="16" />
|
|
|
|
<span class="is-size-7" v-text="$t('dialog.add.stream.cancel')" />
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
:class="{ 'is-disabled': disabled }"
|
|
|
|
class="card-footer-item has-text-dark"
|
|
|
|
@click="add_stream"
|
|
|
|
>
|
|
|
|
<mdicon class="icon" name="playlist-plus" size="16" />
|
|
|
|
<span class="is-size-7" v-text="$t('dialog.add.stream.add')" />
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
:class="{ 'is-disabled': disabled }"
|
|
|
|
class="card-footer-item has-text-dark"
|
|
|
|
@click="play"
|
|
|
|
>
|
|
|
|
<mdicon class="icon" name="play" size="16" />
|
|
|
|
<span class="is-size-7" v-text="$t('dialog.add.stream.play')" />
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</modal-dialog>
|
2019-05-11 14:01:25 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2025-02-04 22:00:48 +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-04 22:00:48 +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'],
|
2019-05-11 14:01:25 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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: {
|
2023-06-07 21:25:54 +02:00
|
|
|
add_stream() {
|
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
|
|
|
|
})
|
|
|
|
},
|
2024-03-28 15:45:39 +01:00
|
|
|
check_url(event) {
|
|
|
|
const { validity } = event.target
|
|
|
|
this.disabled = validity.patternMismatch || validity.valueMissing
|
|
|
|
},
|
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>
|