diff --git a/src/actions/catalog.action.ts b/src/actions/catalog.action.ts index 045108b1..d6e7a79c 100644 --- a/src/actions/catalog.action.ts +++ b/src/actions/catalog.action.ts @@ -317,7 +317,6 @@ export const catalogActionsThunk = { dispatch: ThunkDispatch, getState: () => RootState ) => { - dispatch(CatalogAppActions.updatePhase('processing')); dispatch(StorageActions.updateFirmwareBuildingTasks([])); const { storage } = getState(); const result = await storage.instance!.fetchFirmwareBuildingTasks( @@ -328,7 +327,6 @@ export const catalogActionsThunk = { return; } dispatch(StorageActions.updateFirmwareBuildingTasks(result.value)); - dispatch(CatalogAppActions.updatePhase('build')); }, deleteFirmwareBuildingTask: diff --git a/src/components/catalog/keyboard/build/CatalogBuild.tsx b/src/components/catalog/keyboard/build/CatalogBuild.tsx index 08247789..e0ea8bda 100644 --- a/src/components/catalog/keyboard/build/CatalogBuild.tsx +++ b/src/components/catalog/keyboard/build/CatalogBuild.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import './CatalogBuild.scss'; import { CatalogBuildActionsType, @@ -10,10 +10,12 @@ import { Card, CardActions, CardContent, + FormControlLabel, Paper, Step, StepLabel, Stepper, + Switch, Tab, Table, TableBody, @@ -51,6 +53,42 @@ export default function CatalogBuild(props: CatalogBuildProps) { useState(false); const [targetDeleteTask, setTargetDeleteTask] = useState(null); + const [autoReload, setAutoReload] = useState(false); + const autoStopRef = useRef(null); + + const autoReloadRef = useRef(null); + useEffect(() => { + if (autoReload) { + if (autoReloadRef.current !== null) return; + const reload = () => { + props.updateFirmwareBuildingTasks!(props.definitionDocument!.id); + autoReloadRef.current = window.setTimeout(reload, 30000); + }; + reload(); + autoStopRef.current = window.setTimeout(() => { + setAutoReload(false); + }, 180000); + } else { + if (autoReloadRef.current !== null) { + window.clearTimeout(autoReloadRef.current); + autoReloadRef.current = null; + } + if (autoStopRef.current !== null) { + window.clearTimeout(autoStopRef.current); + autoStopRef.current = null; + } + } + return () => { + if (autoReloadRef.current !== null) { + window.clearTimeout(autoReloadRef.current); + autoReloadRef.current = null; + } + if (autoStopRef.current !== null) { + window.clearTimeout(autoStopRef.current); + autoStopRef.current = null; + } + }; + }, [autoReload]); const createDefaultParameterValues = ( files: IBuildableFirmwareFile[] @@ -200,13 +238,23 @@ export default function CatalogBuild(props: CatalogBuildProps) { } }; + const onChangeAutoReload = (event: React.ChangeEvent) => { + setAutoReload(event.target.checked); + }; + return (
+ + } + label="Auto" + />