[web-src] change styling of url-modal, default to play the stream and

set focus after showing the modal
This commit is contained in:
chme 2019-05-28 22:48:58 +02:00
parent 4c15c40b07
commit 509141ebe3
2 changed files with 69 additions and 24 deletions

View File

@ -3,23 +3,40 @@
<transition name="fade"> <transition name="fade">
<div class="modal is-active" v-if="show"> <div class="modal is-active" v-if="show">
<div class="modal-background" @click="$emit('close')"></div> <div class="modal-background" @click="$emit('close')"></div>
<div class="modal-card"> <div class="modal-content fd-modal-card">
<section class="modal-card-body"> <div class="card">
<form v-on:submit.prevent="add_stream"> <div class="card-content">
<p class="title is-4">
Add stream URL
</p>
<form v-on:submit.prevent="play" class="fd-has-margin-bottom">
<div class="field"> <div class="field">
<p class="control is-expanded has-icons-left"> <p class="control is-expanded has-icons-left">
<input class="input is-rounded is-shadowless" type="text" placeholder="URL stream" v-model="url" ref="url_field"> <input class="input is-shadowless" type="text" placeholder="http://url-to-stream" v-model="url" :disabled="loading" ref="url_field">
<span class="icon is-left"> <span class="icon is-left">
<i class="mdi mdi-file-music"></i> <i class="mdi mdi-web"></i>
</span> </span>
</p> </p>
</div> </div>
</form> </form>
</section> </div>
<footer class="modal-card-foot"> <footer class="card-footer" v-if="loading">
<button class="button is-success" @click="add_stream" :disabled="url.length < 9">Add</button> <a class="card-footer-item has-text-dark">
<button class="button" @click="$emit('close')">Cancel</button> <span class="icon"><i class="mdi mdi-web"></i></span> <span class="is-size-7">Loading ...</span>
</a>
</footer> </footer>
<footer class="card-footer" v-else>
<a class="card-footer-item has-text-danger" @click="$emit('close')">
<span class="icon"><i class="mdi mdi-cancel"></i></span> <span class="is-size-7">Cancel</span>
</a>
<a class="card-footer-item has-text-dark" @click="add_stream">
<span class="icon"><i class="mdi mdi-playlist-plus"></i></span> <span class="is-size-7">Add</span>
</a>
<a class="card-footer-item has-background-info has-text-white has-text-weight-bold" @click="play">
<span class="icon"><i class="mdi mdi-play"></i></span> <span class="is-size-7">Play</span>
</a>
</footer>
</div>
</div> </div>
<button class="modal-close is-large" aria-label="close" @click="$emit('close')"></button> <button class="modal-close is-large" aria-label="close" @click="$emit('close')"></button>
</div> </div>
@ -36,15 +53,43 @@ export default {
data () { data () {
return { return {
url: '' url: '',
loading: false
} }
}, },
methods: { methods: {
add_stream: function () { add_stream: function () {
this.loading = true
webapi.queue_add(this.url).then(() => {
this.$emit('close') this.$emit('close')
webapi.queue_add(this.url)
this.url = '' this.url = ''
}).catch(() => {
this.loading = false
})
},
play: function () {
this.loading = true
webapi.player_play_uri(this.url, false).then(() => {
this.$emit('close')
this.url = ''
}).catch(() => {
this.loading = false
})
}
},
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.url_field.focus()
}, 10)
}
} }
} }
} }

View File

@ -12,11 +12,11 @@
</span> </span>
<span>Hide previous</span> <span>Hide previous</span>
</a> </a>
<a class="button is-small" @click="add_stream_dialog"> <a class="button is-small" @click="open_add_stream_dialog">
<span class="icon"> <span class="icon">
<i class="mdi mdi-web"></i> <i class="mdi mdi-web"></i>
</span> </span>
<span>Add URL Stream</span> <span>Add Stream</span>
</a> </a>
<!-- <!--
<a class="button" :class="{ 'is-info': edit_mode }" @click="edit_mode = !edit_mode"> <a class="button" :class="{ 'is-info': edit_mode }" @click="edit_mode = !edit_mode">
@ -133,7 +133,7 @@ export default {
this.show_details_modal = true this.show_details_modal = true
}, },
add_stream_dialog: function (item) { open_add_stream_dialog: function (item) {
this.show_url_modal = true this.show_url_modal = true
} }
} }