From 43d46c5251068ff33becec72cbc9e53e86fcae02 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 25 Nov 2022 11:56:37 -0500 Subject: [PATCH] Auto Reload the Process Lists on the home pages' in-progress, and complete tabs --- .../components/ProcessInstanceListTable.tsx | 32 ++++++++++++----- .../components/TasksForMyOpenProcesses.tsx | 34 +++++++++++-------- .../src/routes/CompletedInstances.tsx | 1 + 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx index e881451d..86432e10 100644 --- a/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx +++ b/spiffworkflow-frontend/src/components/ProcessInstanceListTable.tsx @@ -32,7 +32,7 @@ import { convertSecondsToFormattedTimeHoursMinutes, getPageInfoFromSearchParams, getProcessModelFullIdentifierFromSearchParams, - modifyProcessIdentifierForPathParam, + modifyProcessIdentifierForPathParam, refreshAtInterval, } from '../helpers'; import PaginationForTable from './PaginationForTable'; @@ -52,6 +52,9 @@ import { import ProcessModelSearch from './ProcessModelSearch'; import ProcessInstanceReportSearch from './ProcessInstanceReportSearch'; +const REFRESH_INTERVAL = 5; +const REFRESH_TIMEOUT = 600; + type OwnProps = { filtersEnabled?: boolean; processModelFullIdentifier?: string; @@ -61,6 +64,7 @@ type OwnProps = { reportIdentifier?: string; textToShowIfEmpty?: string; paginationClassName?: string; + autoReload?: boolean; }; interface dateParameters { @@ -76,6 +80,7 @@ export default function ProcessInstanceListTable({ reportIdentifier, textToShowIfEmpty, paginationClassName, + autoReload = false, }: OwnProps) { const params = useParams(); const [searchParams] = useSearchParams(); @@ -264,16 +269,25 @@ export default function ProcessInstanceListTable({ getProcessInstances(); } + const checkFiltersAndRun = () => { + console.log("Checking again!", filtersEnabled) + if (filtersEnabled) { + // populate process model selection + HttpService.makeCallToBackend({ + path: `/process-models?per_page=1000&recursive=true`, + successCallback: processResultForProcessModels, + }); + } else { + getProcessInstances(); + } + }; - if (filtersEnabled) { - // populate process model selection - HttpService.makeCallToBackend({ - path: `/process-models?per_page=1000&recursive=true`, - successCallback: processResultForProcessModels, - }); + checkFiltersAndRun(); + if (autoReload) { + refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, checkFiltersAndRun); } else { - getProcessInstances(); } + }, [ searchParams, params, @@ -758,13 +772,13 @@ export default function ProcessInstanceListTable({ <>