mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 16:20:03 +00:00
First implementation of job system
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {Outlet, useHref, useNavigate} from 'react-router';
|
||||
import "./main.css";
|
||||
import "Frontend/util/custom-validators";
|
||||
import {HeroUIProvider} from "@heroui/react";
|
||||
import {ThemeProvider as NextThemesProvider} from "next-themes";
|
||||
import {themeNames} from "Frontend/theming/themes";
|
||||
|
||||
@@ -3,6 +3,7 @@ import ConfigFormField from "Frontend/components/administration/ConfigFormField"
|
||||
import withConfigPage from "Frontend/components/administration/withConfigPage";
|
||||
import Section from "Frontend/components/general/Section";
|
||||
import * as Yup from 'yup';
|
||||
import "Frontend/util/yup-extensions";
|
||||
import {addToast, Button, Divider, Tooltip, useDisclosure} from "@heroui/react";
|
||||
import {Plus} from "@phosphor-icons/react";
|
||||
import {LibraryEndpoint} from "Frontend/generated/endpoints";
|
||||
@@ -55,7 +56,7 @@ function LibraryManagementLayout({getConfig, formik}: any) {
|
||||
|
||||
<Section title="Metadata"/>
|
||||
<div className="flex flex-row items-baseline">
|
||||
<ConfigFormField configElement={getConfig("library.metadata.update.enabled")} isDisabled/>
|
||||
<ConfigFormField configElement={getConfig("library.metadata.update.enabled")}/>
|
||||
<ConfigFormField configElement={getConfig("library.metadata.update.schedule")}
|
||||
isDisabled={!formik.values.library.metadata.update.enabled}/>
|
||||
</div>
|
||||
@@ -95,8 +96,11 @@ const validationSchema = Yup.object({
|
||||
library: Yup.object({
|
||||
metadata: Yup.object({
|
||||
update: Yup.object({
|
||||
// @ts-ignore
|
||||
schedule: Yup.string().cron()
|
||||
enabled: Yup.boolean(),
|
||||
schedule: Yup.string().when("enabled", {
|
||||
is: true,
|
||||
then: (schema) => schema.cron()
|
||||
}),
|
||||
})
|
||||
}),
|
||||
scan: Yup.object({
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import * as Yup from "yup";
|
||||
import {isValidCron} from "cron-validator";
|
||||
|
||||
// Custom validator for cron expressions
|
||||
Yup.addMethod(Yup.string, 'cron', function (message) {
|
||||
return this.test('cron', message, function (value) {
|
||||
const {path, createError} = this;
|
||||
return isValidCron(value as string) || createError({path, message: message || 'Invalid cron expression'});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as Yup from 'yup';
|
||||
import {ConfigEndpoint} from 'Frontend/generated/endpoints';
|
||||
|
||||
Yup.addMethod(Yup.string, 'cron', function (message = 'Invalid cron expression') {
|
||||
return this.test('cron', message, async function (value) {
|
||||
const {path, createError} = this;
|
||||
if (!value) return true;
|
||||
try {
|
||||
const isValid = await ConfigEndpoint.validateCronExpression(value);
|
||||
return isValid || createError({path, message});
|
||||
} catch (e) {
|
||||
return createError({path, message: 'Error validating cron expression'});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// TypeScript: Extend Yup's type definitions
|
||||
declare module 'yup' {
|
||||
interface StringSchema {
|
||||
cron(message?: string): StringSchema;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user