2022-08-17 01:24:47 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full h-full px-4 py-1 mb-4">
|
|
|
|
<div class="flex items-center justify-between mb-4">
|
|
|
|
<p class="text-lg">Schedule Automatic Library Scans</p>
|
|
|
|
<ui-checkbox v-model="enableAutoScan" @input="toggleEnableAutoScan" label="Enable" checkbox-bg="bg" label-class="pl-2 text-base" />
|
|
|
|
</div>
|
2022-08-18 01:44:21 +02:00
|
|
|
<widgets-cron-expression-builder ref="cronExpressionBuilder" v-if="enableAutoScan" v-model="cronExpression" @input="updatedCron" />
|
2022-08-17 01:24:47 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
library: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
|
|
|
},
|
|
|
|
processing: Boolean
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
cronExpression: null,
|
|
|
|
enableAutoScan: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {},
|
|
|
|
methods: {
|
2022-08-18 01:44:21 +02:00
|
|
|
checkBlurExpressionInput() {
|
|
|
|
// returns true if advanced cron input is focused
|
|
|
|
if (!this.$refs.cronExpressionBuilder) return false
|
|
|
|
return this.$refs.cronExpressionBuilder.checkBlurExpressionInput()
|
|
|
|
},
|
2022-08-17 01:24:47 +02:00
|
|
|
toggleEnableAutoScan(v) {
|
|
|
|
if (!v) this.updatedCron(null)
|
2022-08-18 00:37:20 +02:00
|
|
|
else if (!this.cronExpression) {
|
|
|
|
this.cronExpression = '0 0 * * 1'
|
|
|
|
this.updatedCron(this.cronExpression)
|
|
|
|
}
|
2022-08-17 01:24:47 +02:00
|
|
|
},
|
|
|
|
updatedCron(expression) {
|
|
|
|
this.$emit('update', {
|
|
|
|
settings: {
|
|
|
|
autoScanCronExpression: expression
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
init() {
|
|
|
|
this.cronExpression = this.library.settings.autoScanCronExpression
|
|
|
|
this.enableAutoScan = !!this.cronExpression
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|