diff --git a/package.json b/package.json index 31d6da4..b332395 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@fullcalendar/interaction": "5.10.0", "@fullcalendar/react": "5.10.0", "@fullcalendar/timegrid": "5.10.0", - "@kingsrook/qqq-frontend-core": "1.0.10", + "@kingsrook/qqq-frontend-core": "1.0.12", "@mui/icons-material": "5.4.1", "@mui/material": "5.4.1", "@mui/styled-engine": "5.4.1", diff --git a/src/qqq/pages/entity-list/index.tsx b/src/qqq/pages/entity-list/index.tsx index 0d85039..9c9c676 100644 --- a/src/qqq/pages/entity-list/index.tsx +++ b/src/qqq/pages/entity-list/index.tsx @@ -45,6 +45,9 @@ import QClient from "qqq/utils/QClient"; import QValueUtils from "qqq/utils/QValueUtils"; import Footer from "../../components/Footer"; import QProcessUtils from "../../utils/QProcessUtils"; +import {QActionsMenuButton, QCreateNewButton} from "qqq/components/QButtons"; +import QValueUtils from "qqq/utils/QValueUtils"; +import LinearProgress from "@mui/material/LinearProgress"; import "./styles.css"; const COLUMN_VISIBILITY_LOCAL_STORAGE_KEY_ROOT = "qqq.columnVisibility"; @@ -657,15 +660,11 @@ function EntityList({table}: Props): JSX.Element The {` ${selectedIds.length.toLocaleString()} `} records on this page are selected. - + ) } @@ -675,15 +674,11 @@ function EntityList({table}: Props): JSX.Element All {` ${totalRecords.toLocaleString()} `} records matching this query are selected. - + ) } diff --git a/src/qqq/pages/entity-list/styles.css b/src/qqq/pages/entity-list/styles.css deleted file mode 100644 index 5f4975c..0000000 --- a/src/qqq/pages/entity-list/styles.css +++ /dev/null @@ -1,26 +0,0 @@ -/* - * QQQ - Low-code Application Framework for Engineers. - * Copyright (C) 2021-2022. Kingsrook, LLC - * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States - * contact@kingsrook.com - * https://github.com/Kingsrook/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -.selectionTool -{ - margin-left: 40px; - font-size: 14px; -} diff --git a/src/qqq/pages/process-run/index.tsx b/src/qqq/pages/process-run/index.tsx index c2d7964..e85bc81 100644 --- a/src/qqq/pages/process-run/index.tsx +++ b/src/qqq/pages/process-run/index.tsx @@ -20,6 +20,7 @@ */ import {QComponentType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QComponentType"; +import {QException} from "@kingsrook/qqq-frontend-core/lib/exceptions/QException"; import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData"; import {QFrontendComponent} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFrontendComponent"; import {QFrontendStepMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFrontendStepMetaData"; @@ -53,6 +54,10 @@ interface Props process?: QProcessMetaData; } +const INITIAL_RETRY_MILLIS = 1_500; +const RETRY_MAX_MILLIS = 12_000; +const BACKOFF_AMOUNT = 1.5; + function ProcessRun({process}: Props): JSX.Element { const processNameParam = useParams().processName; @@ -62,6 +67,7 @@ function ProcessRun({process}: Props): JSX.Element // process state // /////////////////// const [processUUID, setProcessUUID] = useState(null as string); + const [retryMillis, setRetryMillis] = useState(INITIAL_RETRY_MILLIS); const [jobUUID, setJobUUID] = useState(null as string); const [qJobRunning, setQJobRunning] = useState(null as QJobRunning); const [qJobRunningDate, setQJobRunningDate] = useState(null as Date); @@ -343,8 +349,6 @@ function ProcessRun({process}: Props): JSX.Element return; } - // console.log(`Steps are: ${steps}`); - // console.log(`Setting step to ${newStep}`); let newIndex = null; if (typeof newStep === "number") { @@ -446,9 +450,6 @@ function ProcessRun({process}: Props): JSX.Element { if (activeStep && activeStep.formFields) { - console.log("In useEffect for disabledBulkEditFields"); - console.log(disabledBulkEditFields); - const newDynamicFormFields: any = {}; const newFormValidations: any = {}; activeStep.formFields.forEach((field) => @@ -519,22 +520,21 @@ function ProcessRun({process}: Props): JSX.Element if (lastProcessResponse) { setLastProcessResponse(null); + setRetryMillis(INITIAL_RETRY_MILLIS); + setQJobRunning(null); if (lastProcessResponse instanceof QJobComplete) { const qJobComplete = lastProcessResponse as QJobComplete; - console.log("Setting new step."); setJobUUID(null); setNewStep(qJobComplete.nextStep); setProcessValues(qJobComplete.values); - // console.log(`Updated process values: ${JSON.stringify(qJobComplete.values)}`); } else if (lastProcessResponse instanceof QJobStarted) { const qJobStarted = lastProcessResponse as QJobStarted; setJobUUID(qJobStarted.jobUUID); - console.log("setting need to check because started"); setNeedToCheckJobStatus(true); } else if (lastProcessResponse instanceof QJobRunning) @@ -542,7 +542,6 @@ function ProcessRun({process}: Props): JSX.Element const qJobRunning = lastProcessResponse as QJobRunning; setQJobRunning(qJobRunning); setQJobRunningDate(new Date()); - console.log("setting need to check because running"); setNeedToCheckJobStatus(true); } else if (lastProcessResponse instanceof QJobError) @@ -560,28 +559,50 @@ function ProcessRun({process}: Props): JSX.Element ///////////////////////////////////////////////////////////////////////// useEffect(() => { - console.log("In effect for checking status"); if (needToCheckJobStatus) { - console.log(" and the bool was true"); setNeedToCheckJobStatus(false); - if (jobUUID) + (async () => { - (async () => + setTimeout(async () => { - setTimeout(async () => + try { + console.log("OK"); const processResponse = await QClient.getInstance().processJobStatus( processName, processUUID, jobUUID, ); setLastProcessResponse(processResponse); - }, 1500); - })(); - } + } + catch (e) + { + if (e instanceof QException) + { + const qException = e as QException; + const status = Number(qException.status); + if (status !== undefined && !Number.isNaN(status) && status >= 500 && status <= 600) + { + if (retryMillis < RETRY_MAX_MILLIS) + { + console.log(`500 error, attempting to retry in ${retryMillis + retryMillis} millis`); + setRetryMillis(retryMillis * BACKOFF_AMOUNT); + setNeedToCheckJobStatus(true); + return; + } + + console.log(`Retry millis [${retryMillis}] is greater or equal to the max retry limit [${RETRY_MAX_MILLIS}], giving up...`); + setProcessError("Could not connect to server"); + } + } + + throw (e); + } + }, retryMillis); + })(); } - }, [needToCheckJobStatus]); + }, [needToCheckJobStatus, retryMillis]); ////////////////////////////////////////////////////////////////////////////////////////// // do the initial load of data for the process - that is, meta data, plus the init step // @@ -611,8 +632,6 @@ function ProcessRun({process}: Props): JSX.Element // queryStringForInit = `recordsParam=filterId&filterId=${urlSearchParams.get("filterId")}` // } - console.log(`@dk: Query String for init: ${queryStringForInit}`); - try { const processMetaData = await QClient.getInstance().loadProcessMetaData(processName); @@ -687,7 +706,6 @@ function ProcessRun({process}: Props): JSX.Element setTimeout(async () => { - console.log("Calling processStep..."); const processResponse = await QClient.getInstance().processStep( processName, processUUID, diff --git a/src/qqq/styles/qqq-override-styles.css b/src/qqq/styles/qqq-override-styles.css index e6c5891..4f865a0 100644 --- a/src/qqq/styles/qqq-override-styles.css +++ b/src/qqq/styles/qqq-override-styles.css @@ -103,4 +103,10 @@ .MuiInputAdornment-sizeMedium * { font-size: .875rem !important; -} \ No newline at end of file +} + +.MuiDataGrid-toolbarContainer .selectionTool +{ + margin-left: 40px; + font-size: 14px; +} diff --git a/src/qqq/utils/QClient.ts b/src/qqq/utils/QClient.ts index f64ee93..d7c90db 100644 --- a/src/qqq/utils/QClient.ts +++ b/src/qqq/utils/QClient.ts @@ -34,11 +34,7 @@ class QClient private static handleException(exception: QException) { console.log(`Caught Exception: ${JSON.stringify(exception)}`); - const {logout} = useAuth0(); - if (exception.status === "401") - { - logout(); - } + throw (exception); } public static getInstance()