mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Update:Sleep timer presets and add custom time input #1357
This commit is contained in:
parent
22b8622c67
commit
b96f878d69
@ -9,10 +9,14 @@
|
|||||||
<div ref="container" class="w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
|
<div ref="container" class="w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
|
||||||
<div v-if="!timerSet" class="w-full">
|
<div v-if="!timerSet" class="w-full">
|
||||||
<template v-for="time in sleepTimes">
|
<template v-for="time in sleepTimes">
|
||||||
<div :key="time.text" class="flex items-center px-6 py-3 justify-center cursor-pointer hover:bg-bg relative" @click="setTime(time)">
|
<div :key="time.text" class="flex items-center px-6 py-3 justify-center cursor-pointer hover:bg-bg relative" @click="setTime(time.seconds)">
|
||||||
<p class="text-xl text-center">{{ time.text }}</p>
|
<p class="text-xl text-center">{{ time.text }}</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<form class="flex items-center justify-center px-6 py-3" @submit.prevent="submitCustomTime">
|
||||||
|
<ui-text-input v-model="customTime" type="number" step="any" min="0.1" placeholder="Time in minutes" class="w-48" />
|
||||||
|
<ui-btn color="success" type="submit" padding-x="0" class="h-9 w-12 flex items-center justify-center ml-1">Set</ui-btn>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="w-full p-4">
|
<div v-else class="w-full p-4">
|
||||||
<div class="mb-4 flex items-center justify-center">
|
<div class="mb-4 flex items-center justify-center">
|
||||||
@ -48,19 +52,28 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
customTime: null,
|
||||||
sleepTimes: [
|
sleepTimes: [
|
||||||
{
|
|
||||||
seconds: 10,
|
|
||||||
text: '10 seconds'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
seconds: 60 * 5,
|
seconds: 60 * 5,
|
||||||
text: '5 minutes'
|
text: '5 minutes'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
seconds: 60 * 15,
|
||||||
|
text: '15 minutes'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
seconds: 60 * 20,
|
||||||
|
text: '20 minutes'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
seconds: 60 * 30,
|
seconds: 60 * 30,
|
||||||
text: '30 minutes'
|
text: '30 minutes'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
seconds: 60 * 45,
|
||||||
|
text: '45 minutes'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
seconds: 60 * 60,
|
seconds: 60 * 60,
|
||||||
text: '60 minutes'
|
text: '60 minutes'
|
||||||
@ -72,10 +85,6 @@ export default {
|
|||||||
{
|
{
|
||||||
seconds: 60 * 120,
|
seconds: 60 * 120,
|
||||||
text: '2 hours'
|
text: '2 hours'
|
||||||
},
|
|
||||||
{
|
|
||||||
seconds: 60 * 180,
|
|
||||||
text: '3 hours'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -97,8 +106,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setTime(time) {
|
submitCustomTime() {
|
||||||
this.$emit('set', time.seconds)
|
if (!this.customTime || isNaN(this.customTime) || Number(this.customTime) <= 0) {
|
||||||
|
this.customTime = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeInSeconds = Math.round(Number(this.customTime) * 60)
|
||||||
|
this.setTime(timeInSeconds)
|
||||||
|
},
|
||||||
|
setTime(seconds) {
|
||||||
|
this.$emit('set', seconds)
|
||||||
},
|
},
|
||||||
increment(amount) {
|
increment(amount) {
|
||||||
this.$emit('increment', amount)
|
this.$emit('increment', amount)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="wrapper" class="relative">
|
<div ref="wrapper" class="relative">
|
||||||
<input :id="inputId" ref="input" v-model="inputValue" :type="actualType" :readonly="readonly" :disabled="disabled" :placeholder="placeholder" class="rounded bg-primary text-gray-200 focus:border-gray-300 focus:bg-bg focus:outline-none border border-gray-600 h-full w-full" :class="classList" @keyup="keyup" @change="change" @focus="focused" @blur="blurred" />
|
<input :id="inputId" ref="input" v-model="inputValue" :type="actualType" :step="step" :min="min" :readonly="readonly" :disabled="disabled" :placeholder="placeholder" class="rounded bg-primary text-gray-200 focus:border-gray-300 focus:bg-bg focus:outline-none border border-gray-600 h-full w-full" :class="classList" @keyup="keyup" @change="change" @focus="focused" @blur="blurred" />
|
||||||
<div v-if="clearable && inputValue" class="absolute top-0 right-0 h-full px-2 flex items-center justify-center">
|
<div v-if="clearable && inputValue" class="absolute top-0 right-0 h-full px-2 flex items-center justify-center">
|
||||||
<span class="material-icons text-gray-300 cursor-pointer" style="font-size: 1.1rem" @click.stop.prevent="clear">close</span>
|
<span class="material-icons text-gray-300 cursor-pointer" style="font-size: 1.1rem" @click.stop.prevent="clear">close</span>
|
||||||
</div>
|
</div>
|
||||||
@ -32,7 +32,9 @@ export default {
|
|||||||
noSpinner: Boolean,
|
noSpinner: Boolean,
|
||||||
textCenter: Boolean,
|
textCenter: Boolean,
|
||||||
clearable: Boolean,
|
clearable: Boolean,
|
||||||
inputId: String
|
inputId: String,
|
||||||
|
step: [String, Number],
|
||||||
|
min: [String, Number]
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user