Auto Reload the Process Lists on the home pages' in-progress, and complete tabs

This commit is contained in:
Dan 2022-11-25 11:56:37 -05:00
parent 7a926c690e
commit 43d46c5251
3 changed files with 44 additions and 23 deletions

View File

@ -32,7 +32,7 @@ import {
convertSecondsToFormattedTimeHoursMinutes, convertSecondsToFormattedTimeHoursMinutes,
getPageInfoFromSearchParams, getPageInfoFromSearchParams,
getProcessModelFullIdentifierFromSearchParams, getProcessModelFullIdentifierFromSearchParams,
modifyProcessIdentifierForPathParam, modifyProcessIdentifierForPathParam, refreshAtInterval,
} from '../helpers'; } from '../helpers';
import PaginationForTable from './PaginationForTable'; import PaginationForTable from './PaginationForTable';
@ -52,6 +52,9 @@ import {
import ProcessModelSearch from './ProcessModelSearch'; import ProcessModelSearch from './ProcessModelSearch';
import ProcessInstanceReportSearch from './ProcessInstanceReportSearch'; import ProcessInstanceReportSearch from './ProcessInstanceReportSearch';
const REFRESH_INTERVAL = 5;
const REFRESH_TIMEOUT = 600;
type OwnProps = { type OwnProps = {
filtersEnabled?: boolean; filtersEnabled?: boolean;
processModelFullIdentifier?: string; processModelFullIdentifier?: string;
@ -61,6 +64,7 @@ type OwnProps = {
reportIdentifier?: string; reportIdentifier?: string;
textToShowIfEmpty?: string; textToShowIfEmpty?: string;
paginationClassName?: string; paginationClassName?: string;
autoReload?: boolean;
}; };
interface dateParameters { interface dateParameters {
@ -76,6 +80,7 @@ export default function ProcessInstanceListTable({
reportIdentifier, reportIdentifier,
textToShowIfEmpty, textToShowIfEmpty,
paginationClassName, paginationClassName,
autoReload = false,
}: OwnProps) { }: OwnProps) {
const params = useParams(); const params = useParams();
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
@ -264,7 +269,8 @@ export default function ProcessInstanceListTable({
getProcessInstances(); getProcessInstances();
} }
const checkFiltersAndRun = () => {
console.log("Checking again!", filtersEnabled)
if (filtersEnabled) { if (filtersEnabled) {
// populate process model selection // populate process model selection
HttpService.makeCallToBackend({ HttpService.makeCallToBackend({
@ -274,6 +280,14 @@ export default function ProcessInstanceListTable({
} else { } else {
getProcessInstances(); getProcessInstances();
} }
};
checkFiltersAndRun();
if (autoReload) {
refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, checkFiltersAndRun);
} else {
}
}, [ }, [
searchParams, searchParams,
params, params,
@ -758,13 +772,13 @@ export default function ProcessInstanceListTable({
<> <>
<Grid fullWidth> <Grid fullWidth>
<Column <Column
className="filterIcon"
sm={{ span: 1, offset: 3 }} sm={{ span: 1, offset: 3 }}
md={{ span: 1, offset: 7 }} md={{ span: 1, offset: 7 }}
lg={{ span: 1, offset: 15 }} lg={{ span: 1, offset: 15 }}
> >
<Button <Button
data-qa="filter-section-expand-toggle" data-qa="filter-section-expand-toggle"
kind="ghost"
renderIcon={Filter} renderIcon={Filter}
iconDescription="Filter Options" iconDescription="Filter Options"
hasIconOnly hasIconOnly

View File

@ -6,7 +6,7 @@ import PaginationForTable from './PaginationForTable';
import { import {
convertSecondsToFormattedDateTime, convertSecondsToFormattedDateTime,
getPageInfoFromSearchParams, getPageInfoFromSearchParams,
modifyProcessIdentifierForPathParam, modifyProcessIdentifierForPathParam, refreshAtInterval,
} from '../helpers'; } from '../helpers';
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
import { PaginationObject } from '../interfaces'; import { PaginationObject } from '../interfaces';
@ -14,6 +14,8 @@ import TableCellWithTimeAgoInWords from './TableCellWithTimeAgoInWords';
const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5; const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5;
const paginationQueryParamPrefix = 'tasks_for_my_open_processes'; const paginationQueryParamPrefix = 'tasks_for_my_open_processes';
const REFRESH_INTERVAL = 5;
const REFRESH_TIMEOUT = 600;
export default function MyOpenProcesses() { export default function MyOpenProcesses() {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
@ -21,6 +23,7 @@ export default function MyOpenProcesses() {
const [pagination, setPagination] = useState<PaginationObject | null>(null); const [pagination, setPagination] = useState<PaginationObject | null>(null);
useEffect(() => { useEffect(() => {
const getTasks = () => {
const { page, perPage } = getPageInfoFromSearchParams( const { page, perPage } = getPageInfoFromSearchParams(
searchParams, searchParams,
PER_PAGE_FOR_TASKS_ON_HOME_PAGE, PER_PAGE_FOR_TASKS_ON_HOME_PAGE,
@ -35,6 +38,9 @@ export default function MyOpenProcesses() {
path: `/tasks/for-my-open-processes?per_page=${perPage}&page=${page}`, path: `/tasks/for-my-open-processes?per_page=${perPage}&page=${page}`,
successCallback: setTasksFromResult, successCallback: setTasksFromResult,
}); });
};
getTasks();
refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
}, [searchParams]); }, [searchParams]);
const buildTable = () => { const buildTable = () => {

View File

@ -15,6 +15,7 @@ export default function CompletedInstances() {
showReports={false} showReports={false}
textToShowIfEmpty="You have no completed instances at this time." textToShowIfEmpty="You have no completed instances at this time."
paginationClassName="with-large-bottom-margin" paginationClassName="with-large-bottom-margin"
autoReload
/> />
<h2>Tasks completed by me</h2> <h2>Tasks completed by me</h2>
<p className="data-table-description"> <p className="data-table-description">