-
+
+
+
-
-
-
-
-
-
-
-
- Use random background image.
-
-
+
+
+
+
+
+
+
+
+
+ Use random background image.
+
+ Reload
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+ How visible the background image should be.
+
+
-
-
- How visible the background image should be.
-
-
+
+
+
+
+
+
+
+
+
+ Reduce the usage of confirm boxes in the WebUI.
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+ Show notification toasts. If disabled, you will not see errors reported or anything else.
+
+
+
-
-
- Change the displayed picture.
-
@@ -96,5 +118,7 @@ defineProps({
const bg_enable = useStorage('random_bg', true)
const bg_opacity = useStorage('random_bg_opacity', 0.85)
const selectedTheme = useStorage('theme', 'auto')
+const allow_toasts = useStorage('allow_toasts', true)
+const reduce_confirm = useStorage('reduce_confirm', false)
diff --git a/ui/components/TaskForm.vue b/ui/components/TaskForm.vue
index d544a7fa..a6d1e183 100644
--- a/ui/components/TaskForm.vue
+++ b/ui/components/TaskForm.vue
@@ -232,11 +232,12 @@
import { useStorage } from '@vueuse/core'
import { CronExpressionParser } from 'cron-parser'
-const emitter = defineEmits(['cancel', 'submit']);
-const toast = useNotification();
-const config = useConfigStore();
-const showImport = useStorage('showImport', false);
-const import_string = ref('');
+const emitter = defineEmits(['cancel', 'submit'])
+const toast = useNotification()
+const config = useConfigStore()
+const showImport = useStorage('showImport', false)
+const import_string = ref('')
+const box = useConfirm()
const props = defineProps({
reference: {
@@ -255,49 +256,49 @@ const props = defineProps({
},
})
-const form = reactive(props.task);
+const form = reactive(props.task)
onMounted(() => {
if (!props.task?.preset || '' === props.task.preset) {
- form.preset = toRaw(config.app.default_preset);
+ form.preset = toRaw(config.app.default_preset)
}
})
const checkInfo = async () => {
- const required = ['name', 'url'];
+ const required = ['name', 'url']
for (const key of required) {
if (!form[key]) {
- toast.error(`The ${key} field is required.`);
- return;
+ toast.error(`The ${key} field is required.`)
+ return
}
}
if (form.timer) {
try {
- CronExpressionParser.parse(form.timer);
+ CronExpressionParser.parse(form.timer)
} catch (e) {
console.error(e)
- toast.error(`Invalid CRON expression. ${e.message}`);
- return;
+ toast.error(`Invalid CRON expression. ${e.message}`)
+ return
}
}
try {
- new URL(form.url);
+ new URL(form.url)
} catch (e) {
- toast.error('Invalid URL');
- return;
+ toast.error('Invalid URL')
+ return
}
if (form?.cli && '' !== form.cli) {
- const options = await convertOptions(form.cli);
+ const options = await convertOptions(form.cli)
if (null === options) {
return
}
form.cli = form.cli.trim(" ")
}
- emitter('submit', { reference: toRaw(props.reference), task: toRaw(form) });
+ emitter('submit', { reference: toRaw(props.reference), task: toRaw(form) })
}
const importItem = async () => {
@@ -327,7 +328,7 @@ const importItem = async () => {
}
if (form.url || form.timer) {
- if (false === confirm('This will overwrite the current form fields. Are you sure?')) {
+ if (false === box.confirm('This will overwrite the current form fields. Are you sure?', true)) {
return
}
}
@@ -391,7 +392,7 @@ const convertOptions = async args => {
toast.error(e.message)
}
- return null;
+ return null
}
const hasFormatInConfig = computed(() => {
diff --git a/ui/composables/useConfirm.ts b/ui/composables/useConfirm.ts
new file mode 100644
index 00000000..45976a4d
--- /dev/null
+++ b/ui/composables/useConfirm.ts
@@ -0,0 +1,19 @@
+import { useStorage } from '@vueuse/core'
+
+const reduceConfirm = useStorage
('reduce_confirm', false)
+
+function confirm(msg: string, force: boolean = false): boolean {
+ if (false === force && true === reduceConfirm.value) {
+ return true
+ }
+
+ return window.confirm(msg)
+}
+
+function alert(msg: string): boolean {
+ return window.confirm(msg)
+}
+
+export default function useConfirm() {
+ return { confirm, alert, reduceConfirm }
+}
diff --git a/ui/pages/conditions.vue b/ui/pages/conditions.vue
index 075efb03..96433fa9 100644
--- a/ui/pages/conditions.vue
+++ b/ui/pages/conditions.vue
@@ -116,6 +116,7 @@ import { request } from '~/utils/index'
const toast = useNotification()
const config = useConfigStore()
const socket = useSocketStore()
+const box = useConfirm()
const items = ref([])
const item = ref({})
@@ -213,7 +214,7 @@ const updateItems = async items => {
}
const deleteItem = async (item) => {
- if (true !== confirm(`Delete '${item.name}'?`)) {
+ if (true !== box.confirm(`Delete '${item.name}'?`, true)) {
return
}
diff --git a/ui/pages/index.vue b/ui/pages/index.vue
index 2486aaff..b0e1f7ae 100644
--- a/ui/pages/index.vue
+++ b/ui/pages/index.vue
@@ -62,6 +62,8 @@ const emitter = defineEmits(['getInfo'])
const config = useConfigStore()
const stateStore = useStateStore()
const socket = useSocketStore()
+const box = useConfirm()
+
const get_info = ref('')
const bg_enable = useStorage('random_bg', true)
const bg_opacity = useStorage('random_bg_opacity', 0.85)
@@ -91,7 +93,7 @@ watch(() => stateStore.queue, () => {
}, { deep: true })
const pauseDownload = () => {
- if (false === confirm('Are you sure you want to pause all non-active downloads?')) {
+ if (false === box.confirm('Are you sure you want to pause all non-active downloads?')) {
return false
}
diff --git a/ui/pages/notifications.vue b/ui/pages/notifications.vue
index dc57249f..9a3457a4 100644
--- a/ui/pages/notifications.vue
+++ b/ui/pages/notifications.vue
@@ -143,6 +143,7 @@ import { request } from '~/utils/index'
const toast = useNotification()
const config = useConfigStore()
const socket = useSocketStore()
+const box = useConfirm()
const allowedEvents = ref([])
const notifications = ref([])
@@ -234,7 +235,7 @@ const updateData = async notifications => {
}
const deleteItem = async item => {
- if (true !== confirm(`Are you sure you want to delete notification target (${item.name})?`)) {
+ if (true !== box.confirm(`Are you sure you want to delete notification target (${item.name})?`)) {
return
}
@@ -294,7 +295,7 @@ const editItem = item => {
const join_events = events => (!events || events.length < 1) ? 'ALL' : events.map(e => ucFirst(e)).join(', ')
const sendTest = async () => {
- if (true !== confirm('Are you sure you want to send a test notification?')) {
+ if (true !== box.confirm('Are you sure you want to send a test notification?')) {
return
}
diff --git a/ui/pages/presets.vue b/ui/pages/presets.vue
index 90864b17..fc9a80b3 100644
--- a/ui/pages/presets.vue
+++ b/ui/pages/presets.vue
@@ -152,6 +152,7 @@ import { request } from '~/utils/index'
const toast = useNotification()
const config = useConfigStore()
const socket = useSocketStore()
+const box = useConfirm()
const presets = ref([])
const preset = ref({})
@@ -249,7 +250,7 @@ const updatePresets = async (items) => {
}
const deleteItem = async (item) => {
- if (true !== confirm(`Delete preset '${item.name}'?`)) {
+ if (true !== box.confirm(`Delete preset '${item.name}'?`, true)) {
return
}
diff --git a/ui/pages/tasks.vue b/ui/pages/tasks.vue
index c8e19e8b..1d3171b5 100644
--- a/ui/pages/tasks.vue
+++ b/ui/pages/tasks.vue
@@ -125,6 +125,7 @@ import { request } from '~/utils/index'
const toast = useNotification()
const config = useConfigStore()
const socket = useSocketStore()
+const box = useConfirm()
const tasks = ref([])
const task = ref({})
@@ -216,7 +217,7 @@ const updateTasks = async items => {
}
const deleteItem = async item => {
- if (true !== confirm(`Are you sure you want to delete (${item.name})?`)) {
+ if (true !== box.confirm(`Are you sure you want to delete (${item.name})?`, true)) {
return
}
@@ -290,7 +291,7 @@ const tryParse = expression => {
}
const runNow = item => {
- if (true !== confirm(`Run '${item.name}' now? it will also run at the scheduled time.`)) {
+ if (true !== box.confirm(`Run '${item.name}' now? it will also run at the scheduled time.`)) {
return
}