added button to run task now
This commit is contained in:
parent
49bc28edc0
commit
c58faa28c9
4 changed files with 268 additions and 185 deletions
|
|
@ -208,21 +208,21 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast()
|
||||||
const convertInProgress = ref(false);
|
const convertInProgress = ref(false)
|
||||||
const form = reactive(props.preset);
|
const form = reactive( JSON.parse(JSON.stringify(props.preset)))
|
||||||
const opts = ref('');
|
const opts = ref('')
|
||||||
const json_preset = ref('');
|
const json_preset = ref('')
|
||||||
const importExpanded = ref(false);
|
const importExpanded = ref(false)
|
||||||
const convertExpanded = ref(false);
|
const convertExpanded = ref(false)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.preset?.args && (typeof props.preset.args === 'object')) {
|
if (props.preset?.args && (typeof props.preset.args === 'object')) {
|
||||||
form.args = JSON.stringify(props.preset.args, null, 2);
|
form.args = JSON.stringify(props.preset.args, null, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.preset?.postprocessors && (typeof props.preset.postprocessors === 'object')) {
|
if (props.preset?.postprocessors && (typeof props.preset.postprocessors === 'object')) {
|
||||||
form.postprocessors = JSON.stringify(props.preset.postprocessors, null, 2);
|
form.postprocessors = JSON.stringify(props.preset.postprocessors, null, 2)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -231,7 +231,7 @@ const checkInfo = async () => {
|
||||||
for (const key of required) {
|
for (const key of required) {
|
||||||
if (!form[key]) {
|
if (!form[key]) {
|
||||||
toast.error(`The ${key} field is required.`);
|
toast.error(`The ${key} field is required.`);
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<main class="columns mt-2">
|
<main class="columns mt-2">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<form id="taskForm" @submit.prevent="checkInfo()">
|
<form id="taskForm" @submit.prevent="checkInfo()" class="box">
|
||||||
<div class="box">
|
|
||||||
<div class="columns is-multiline is-mobile">
|
<div class="columns is-multiline is-mobile">
|
||||||
<div class="column is-12">
|
<div class="column is-12">
|
||||||
<h1 class="title is-6" style="border-bottom: 1px solid #dbdbdb;">
|
<h1 class="title is-6" style="border-bottom: 1px solid #dbdbdb;">
|
||||||
|
|
@ -15,25 +14,21 @@
|
||||||
|
|
||||||
<div class="column is-6-tablet is-12-mobile">
|
<div class="column is-6-tablet is-12-mobile">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="name">
|
<label class="label is-inline" for="name" v-text="'Name'" />
|
||||||
Task name
|
|
||||||
</label>
|
|
||||||
<div class="control has-icons-left">
|
<div class="control has-icons-left">
|
||||||
<input type="text" class="input" id="name" v-model="form.name" :disabled="addInProgress">
|
<input type="text" class="input" id="name" v-model="form.name" :disabled="addInProgress">
|
||||||
<span class="icon is-small is-left"><i class="fa-solid fa-user" /></span>
|
<span class="icon is-small is-left"><i class="fa-solid fa-user" /></span>
|
||||||
</div>
|
</div>
|
||||||
<span class="help">
|
<span class="help">
|
||||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||||
<span>Task name is used to identify the task in the task list.</span>
|
<span>Task name is used to identify the task in the task list and in logs.</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column is-6-tablet is-12-mobile">
|
<div class="column is-6-tablet is-12-mobile">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="url">
|
<label class="label is-inline" for="url" v-text="'URL'" />
|
||||||
URL
|
|
||||||
</label>
|
|
||||||
<div class="control has-icons-left">
|
<div class="control has-icons-left">
|
||||||
<input type="url" class="input" id="url" v-model="form.url" :disabled="addInProgress">
|
<input type="url" class="input" id="url" v-model="form.url" :disabled="addInProgress">
|
||||||
<span class="icon is-small is-left"><i class="fa-solid fa-link" /></span>
|
<span class="icon is-small is-left"><i class="fa-solid fa-link" /></span>
|
||||||
|
|
@ -109,7 +104,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column is-6-tablet is-12-mobile">
|
<div class="column is-6-tablet is-12-mobile" v-if="showAdvanced">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="output_template">
|
<label class="label is-inline" for="output_template">
|
||||||
Output template
|
Output template
|
||||||
|
|
@ -122,12 +117,15 @@
|
||||||
<span class="help">
|
<span class="help">
|
||||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||||
<span>The output template to use, if not set, it will defaults to
|
<span>The output template to use, if not set, it will defaults to
|
||||||
<code>{{ config.app.template }}</code></span>
|
<code>{{ config.app.output_template }}</code>.
|
||||||
|
For more information <NuxtLink href="https://github.com/yt-dlp/yt-dlp#output-template"
|
||||||
|
target="_blank">visit this url</NuxtLink>.
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column is-6-tablet is-12-mobile">
|
<div class="column is-6-tablet is-12-mobile" v-if="showAdvanced">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="config" v-tooltip="'Extends current global yt-dlp config. (JSON)'">
|
<label class="label is-inline" for="config" v-tooltip="'Extends current global yt-dlp config. (JSON)'">
|
||||||
JSON yt-dlp config or CLI options. <NuxtLink
|
JSON yt-dlp config or CLI options. <NuxtLink
|
||||||
|
|
@ -147,7 +145,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column is-6-tablet is-12-mobile">
|
<div class="column is-6-tablet is-12-mobile" v-if="showAdvanced">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="cookies" v-tooltip="'Netscape HTTP Cookie format.'">Cookies</label>
|
<label class="label is-inline" for="cookies" v-tooltip="'Netscape HTTP Cookie format.'">Cookies</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
|
@ -178,10 +176,14 @@
|
||||||
<span>Cancel</span>
|
<span>Cancel</span>
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
|
<p class="control">
|
||||||
|
<button class="button is-info" type="button" @click="showAdvanced = !showAdvanced">
|
||||||
|
<span class="icon"><i class="fa-solid fa-cog" /></span>
|
||||||
|
<span>Opts</span>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -192,6 +194,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { useStorage } from '@vueuse/core'
|
||||||
import { parseExpression } from 'cron-parser'
|
import { parseExpression } from 'cron-parser'
|
||||||
import { request } from '~/utils/index'
|
import { request } from '~/utils/index'
|
||||||
|
|
||||||
|
|
@ -199,6 +202,7 @@ const emitter = defineEmits(['cancel', 'submit']);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const config = useConfigStore();
|
const config = useConfigStore();
|
||||||
const convertInProgress = ref(false);
|
const convertInProgress = ref(false);
|
||||||
|
const showAdvanced = useStorage('task.showAdvanced', false);
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
reference: {
|
reference: {
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,9 @@ div.is-centered {
|
||||||
<div class="column is-6" v-for="item in presetsNoDefault" :key="item.id">
|
<div class="column is-6" v-for="item in presetsNoDefault" :key="item.id">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<header class="card-header">
|
<header class="card-header">
|
||||||
<div class="card-header-title is-text-overflow is-block">
|
<div class="card-header-title is-text-overflow is-block" v-text="item.name" />
|
||||||
<NuxtLink target="_blank" :href="item.url">{{ item.name }}</NuxtLink>
|
|
||||||
</div>
|
|
||||||
<div class="card-header-icon">
|
<div class="card-header-icon">
|
||||||
<a class="has-text-primary" v-tooltip="'Copy preset.'"
|
<a class="has-text-primary" v-tooltip="'Copy preset.'" @click.prevent="copyItem(item)">
|
||||||
@click.prevent="copyText(JSON.stringify(item))">
|
|
||||||
<span class="icon"><i class="fa-solid fa-copy" /></span>
|
<span class="icon"><i class="fa-solid fa-copy" /></span>
|
||||||
</a>
|
</a>
|
||||||
<button @click="item.raw = !item.raw">
|
<button @click="item.raw = !item.raw">
|
||||||
|
|
@ -83,7 +80,7 @@ div.is-centered {
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<div class="card-footer-item">
|
<div class="card-footer-item">
|
||||||
<button class="button is-warning is-fullwidth" @click="editItem(item);">
|
<button class="button is-warning is-fullwidth" @click="editItem(item);">
|
||||||
<span class="icon"><i class="fa-solid fa-trash-can" /></span>
|
<span class="icon"><i class="fa-solid fa-cog" /></span>
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -252,4 +249,24 @@ const editItem = item => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => socket.isConnected ? await reloadContent(true) : '')
|
onMounted(async () => socket.isConnected ? await reloadContent(true) : '')
|
||||||
|
|
||||||
|
const copyItem = item => {
|
||||||
|
let data = JSON.parse(JSON.stringify(item))
|
||||||
|
const keys = ['id', 'default', 'raw']
|
||||||
|
keys.forEach(key => {
|
||||||
|
if (key in data) {
|
||||||
|
delete data[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (data.args && (typeof data.args === 'string')) {
|
||||||
|
data.args = JSON.parse(data.args)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.postprocessors && (typeof data.postprocessors === 'string')) {
|
||||||
|
data.postprocessors = JSON.parse(data.postprocessors)
|
||||||
|
}
|
||||||
|
|
||||||
|
return copyText(JSON.stringify(data))
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -79,11 +79,11 @@ div.is-centered {
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span class="icon"><i class="fa-solid fa-folder" /></span>
|
<span class="icon"><i class="fa-solid fa-folder" /></span>
|
||||||
<span>{{ calcPath(item.folder) }}</span>
|
<span>{{ item.folder ? calcPath(item.folder) : config.app.download_path }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span class="icon"><i class="fa-solid fa-file" /></span>
|
<span class="icon"><i class="fa-solid fa-file" /></span>
|
||||||
<span>{{ item.template ?? config.app.output_template }}</span>
|
<span>{{ item.template ? item.template : config.app.output_template }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span class="icon"><i class="fa-solid fa-tv" /></span>
|
<span class="icon"><i class="fa-solid fa-tv" /></span>
|
||||||
|
|
@ -99,7 +99,7 @@ div.is-centered {
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<div class="card-footer-item">
|
<div class="card-footer-item">
|
||||||
<button class="button is-warning is-fullwidth" @click="editItem(item);">
|
<button class="button is-warning is-fullwidth" @click="editItem(item);">
|
||||||
<span class="icon"><i class="fa-solid fa-trash-can" /></span>
|
<span class="icon"><i class="fa-solid fa-cog" /></span>
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -109,6 +109,12 @@ div.is-centered {
|
||||||
<span>Delete</span>
|
<span>Delete</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card-footer-item">
|
||||||
|
<button class="button is-purple is-fullwidth" @click="runNow(item)">
|
||||||
|
<span class="icon"><i class="fa-solid fa-microchip" /></span>
|
||||||
|
<span>Run now</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -146,6 +152,7 @@ watch(() => config.app.basic_mode, async () => {
|
||||||
|
|
||||||
watch(() => socket.isConnected, async () => {
|
watch(() => socket.isConnected, async () => {
|
||||||
if (socket.isConnected && initialLoad.value) {
|
if (socket.isConnected && initialLoad.value) {
|
||||||
|
socket.on('status', statusHandler)
|
||||||
await reloadContent(true)
|
await reloadContent(true)
|
||||||
initialLoad.value = false
|
initialLoad.value = false
|
||||||
}
|
}
|
||||||
|
|
@ -278,7 +285,13 @@ const calcPath = path => {
|
||||||
return loc
|
return loc
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => socket.isConnected ? await reloadContent(true) : '')
|
onMounted(async () => {
|
||||||
|
if (!socket.isConnected){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
socket.on('status', statusHandler)
|
||||||
|
await reloadContent(true)
|
||||||
|
});
|
||||||
|
|
||||||
const tryParse = expression => {
|
const tryParse = expression => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -287,4 +300,53 @@ const tryParse = expression => {
|
||||||
return "Invalid"
|
return "Invalid"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const runNow = item => {
|
||||||
|
if (true !== confirm(`Run '${item.name}' now? it will also run at the scheduled time.`)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
url: item.url,
|
||||||
|
preset: item.preset,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.folder) {
|
||||||
|
data.folder = item.folder
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.template) {
|
||||||
|
data.template = item.template
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.cookies) {
|
||||||
|
data.cookies = item.cookies
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.config) {
|
||||||
|
if (typeof item.config === 'object') {
|
||||||
|
data.config = JSON.stringify(item.config)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.parse(data.config)
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(`Invalid JSON yt-dlp config. ${e.message}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.emit('add_url', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => socket.off('status', statusHandler))
|
||||||
|
|
||||||
|
const statusHandler = async stream => {
|
||||||
|
const { status, msg } = JSON.parse(stream)
|
||||||
|
|
||||||
|
if ('error' === status) {
|
||||||
|
toast.error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue