mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-06-04 01:21:10 +00:00
Fix schedule input fields resetting automatically
This commit is contained in:
parent
0ba6169524
commit
e7f1921986
@ -15,6 +15,32 @@ import createAppriseNotificationUrl, {
|
|||||||
import deleteAppriseNotificationUrl from '../api/actions/deleteAppriseNotificationUrl';
|
import deleteAppriseNotificationUrl from '../api/actions/deleteAppriseNotificationUrl';
|
||||||
import { ApiError, ApiResponseType } from '../functions/APIClient';
|
import { ApiError, ApiResponseType } from '../functions/APIClient';
|
||||||
|
|
||||||
|
const getGroupedSchedule = (
|
||||||
|
scheduleResponse: ApiResponseType<ScheduleResponseType> | undefined,
|
||||||
|
) => {
|
||||||
|
const { data: scheduleResponseData } = scheduleResponse ?? {};
|
||||||
|
|
||||||
|
const groupedSchedules = Object.groupBy(scheduleResponseData || [], ({ name }) => name);
|
||||||
|
|
||||||
|
const { update_subscribed, download_pending, run_backup, check_reindex, thumbnail_check } =
|
||||||
|
groupedSchedules;
|
||||||
|
|
||||||
|
const updateSubscribedSchedule = update_subscribed?.pop();
|
||||||
|
const downloadPendingSchedule = download_pending?.pop();
|
||||||
|
const runBackup = run_backup?.pop();
|
||||||
|
const checkReindexSchedule = check_reindex?.pop();
|
||||||
|
const thumbnailCheckSchedule = thumbnail_check?.pop();
|
||||||
|
|
||||||
|
return {
|
||||||
|
updateSubscribedSchedule,
|
||||||
|
downloadPendingSchedule,
|
||||||
|
runBackup,
|
||||||
|
checkReindexSchedule,
|
||||||
|
thumbnailCheckSchedule,
|
||||||
|
download_pending,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const SettingsScheduling = () => {
|
const SettingsScheduling = () => {
|
||||||
const [refresh, setRefresh] = useState(false);
|
const [refresh, setRefresh] = useState(false);
|
||||||
|
|
||||||
@ -37,7 +63,6 @@ const SettingsScheduling = () => {
|
|||||||
const [thumnailCheckError, setThumnailCheckError] = useState<string | null>(null);
|
const [thumnailCheckError, setThumnailCheckError] = useState<string | null>(null);
|
||||||
const [zipBackupError, setZipBackupError] = useState<string | null>(null);
|
const [zipBackupError, setZipBackupError] = useState<string | null>(null);
|
||||||
|
|
||||||
const { data: scheduleResponseData } = scheduleResponse ?? {};
|
|
||||||
const { data: appriseNotificationData } = appriseNotification ?? {};
|
const { data: appriseNotificationData } = appriseNotification ?? {};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -49,6 +74,22 @@ const SettingsScheduling = () => {
|
|||||||
setScheduleResponse(scheduleResponse);
|
setScheduleResponse(scheduleResponse);
|
||||||
setAppriseNotification(appriseNotificationResponse);
|
setAppriseNotification(appriseNotificationResponse);
|
||||||
|
|
||||||
|
const {
|
||||||
|
checkReindexSchedule,
|
||||||
|
downloadPendingSchedule,
|
||||||
|
runBackup,
|
||||||
|
thumbnailCheckSchedule,
|
||||||
|
updateSubscribedSchedule,
|
||||||
|
} = getGroupedSchedule(scheduleResponse);
|
||||||
|
|
||||||
|
setUpdateSubscribed(updateSubscribedSchedule?.schedule || '');
|
||||||
|
setDownloadPending(downloadPendingSchedule?.schedule || '');
|
||||||
|
setCheckReindex(checkReindexSchedule?.schedule || '');
|
||||||
|
setCheckReindexDays(checkReindexSchedule?.config?.days || 0);
|
||||||
|
setThumbnailCheck(thumbnailCheckSchedule?.schedule || '');
|
||||||
|
setZipBackup(runBackup?.schedule || '');
|
||||||
|
setZipBackupDays(runBackup?.config?.rotate || 0);
|
||||||
|
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
@ -58,18 +99,14 @@ const SettingsScheduling = () => {
|
|||||||
setRefresh(true);
|
setRefresh(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const groupedSchedules = Object.groupBy(scheduleResponseData || [], ({ name }) => name);
|
const {
|
||||||
|
checkReindexSchedule,
|
||||||
console.log(groupedSchedules);
|
downloadPendingSchedule,
|
||||||
|
runBackup,
|
||||||
const { update_subscribed, download_pending, run_backup, check_reindex, thumbnail_check } =
|
thumbnailCheckSchedule,
|
||||||
groupedSchedules;
|
updateSubscribedSchedule,
|
||||||
|
download_pending,
|
||||||
const updateSubscribedSchedule = update_subscribed?.pop();
|
} = getGroupedSchedule(scheduleResponse);
|
||||||
const downloadPendingSchedule = download_pending?.pop();
|
|
||||||
const runBackup = run_backup?.pop();
|
|
||||||
const checkReindexSchedule = check_reindex?.pop();
|
|
||||||
const thumbnailCheckSchedule = thumbnail_check?.pop();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -146,7 +183,7 @@ const SettingsScheduling = () => {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={updateSubscribed || updateSubscribedSchedule?.schedule || ''}
|
value={updateSubscribed}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setUpdateSubscribed(e.currentTarget.value);
|
setUpdateSubscribed(e.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
@ -201,7 +238,7 @@ const SettingsScheduling = () => {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={downloadPending || downloadPendingSchedule?.schedule || ''}
|
value={downloadPending}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setDownloadPending(e.currentTarget.value);
|
setDownloadPending(e.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
@ -257,7 +294,7 @@ const SettingsScheduling = () => {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={checkReindex || checkReindexSchedule?.schedule || ''}
|
value={checkReindex}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setCheckReindex(e.currentTarget.value);
|
setCheckReindex(e.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
@ -293,7 +330,7 @@ const SettingsScheduling = () => {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
value={checkReindexDays || checkReindexSchedule?.config?.days || 0}
|
value={checkReindexDays}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setCheckReindexDays(Number(e.currentTarget.value));
|
setCheckReindexDays(Number(e.currentTarget.value));
|
||||||
}}
|
}}
|
||||||
@ -342,7 +379,7 @@ const SettingsScheduling = () => {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={thumbnailCheck || thumbnailCheckSchedule?.schedule || ''}
|
value={thumbnailCheck}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setThumbnailCheck(e.currentTarget.value);
|
setThumbnailCheck(e.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
@ -404,7 +441,7 @@ const SettingsScheduling = () => {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={zipBackup || runBackup?.schedule || ''}
|
value={zipBackup}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setZipBackup(e.currentTarget.value);
|
setZipBackup(e.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
@ -440,7 +477,7 @@ const SettingsScheduling = () => {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
value={(zipBackupDays || runBackup?.config?.rotate)?.toString() || 0}
|
value={zipBackupDays?.toString()}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setZipBackupDays(Number(e.currentTarget.value));
|
setZipBackupDays(Number(e.currentTarget.value));
|
||||||
}}
|
}}
|
||||||
@ -525,7 +562,7 @@ const SettingsScheduling = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Apprise notification URL"
|
placeholder="Apprise notification URL"
|
||||||
value={notificationUrl || ''}
|
value={notificationUrl}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setNotificationUrl(e.currentTarget.value);
|
setNotificationUrl(e.currentTarget.value);
|
||||||
}}
|
}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user