From 24cc9762b28c68cf00d1cd1069a9e4f5a892078c Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Tue, 26 Nov 2024 15:04:39 -0800 Subject: [PATCH 1/4] IO-3040 Report Selector Date Range Restriction Signed-off-by: Allan Carr --- .../job-detail-lines/job-lines.component.jsx | 4 +++- .../report-center-modal.component.jsx | 19 ++++++++++++++++++- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index 070798452..a774bac6b 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -216,7 +216,9 @@ export function JobLinesComponent({ { title: t("joblines.fields.part_qty"), dataIndex: "part_qty", - key: "part_qty" + key: "part_qty", + sorter: (a, b) => a.part_qty - b.part_qty, + sortOrder: state.sortedInfo.columnKey === "part_qty" && state.sortedInfo.order }, // { // title: t('joblines.fields.tax_part'), diff --git a/client/src/components/report-center-modal/report-center-modal.component.jsx b/client/src/components/report-center-modal/report-center-modal.component.jsx index 974e62de7..f518fd94e 100644 --- a/client/src/components/report-center-modal/report-center-modal.component.jsx +++ b/client/src/components/report-center-modal/report-center-modal.component.jsx @@ -110,7 +110,13 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) { to: values.to, subject: Templates[values.key]?.subject }, - values.sendbytext === "text" ? values.sendbytext : values.sendbyexcel === "excel" ? "x" : values.sendby === "email" ? "e" : "p", + values.sendbytext === "text" + ? values.sendbytext + : values.sendbyexcel === "excel" + ? "x" + : values.sendby === "email" + ? "e" + : "p", id ); setLoading(false); @@ -274,6 +280,17 @@ export function ReportCenterModalComponent({ reportCenterModal, bodyshop }) { { required: true //message: t("general.validation.required"), + }, + { + validator: (_, value) => { + if (value && value[0] && value[1] && process.env.NODE_ENV === "production") { + const diffInDays = (value[1] - value[0]) / (1000 * 3600 * 24); + if (diffInDays > 92) { + return Promise.reject(t("general.validation.dateRangeExceeded")); + } + } + return Promise.resolve(); + } } ]} > diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index b743b209a..c6b2cff6b 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1289,6 +1289,7 @@ "unsavedchangespopup": "You have unsaved changes. Are you sure you want to leave?" }, "validation": { + "dateRangeExceeded": "The date range has been exceeded.", "invalidemail": "Please enter a valid email.", "invalidphone": "Please enter a valid phone number.", "required": "{{label}} is required." diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 4a5a39a9f..8468a8424 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1289,6 +1289,7 @@ "unsavedchangespopup": "" }, "validation": { + "dateRangeExceeded": "", "invalidemail": "Por favor introduzca una dirección de correo electrónico válida.", "invalidphone": "", "required": "Este campo es requerido." diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index df418a823..94157f10f 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1289,6 +1289,7 @@ "unsavedchangespopup": "" }, "validation": { + "dateRangeExceeded": "", "invalidemail": "S'il vous plaît entrer un email valide.", "invalidphone": "", "required": "Ce champ est requis." From 0770e7b50de8b72a455ccb91e9951a37833703c6 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Tue, 26 Nov 2024 16:12:03 -0800 Subject: [PATCH 2/4] IO-3040 Re-add Translations after Merge from Release Signed-off-by: Allan Carr --- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 3 files changed, 3 insertions(+) diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 217064827..e86e9936e 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1289,6 +1289,7 @@ "unsavedchangespopup": "You have unsaved changes. Are you sure you want to leave?" }, "validation": { + "dateRangeExceeded": "The date range has been exceeded.", "invalidemail": "Please enter a valid email.", "invalidphone": "Please enter a valid phone number.", "required": "{{label}} is required." diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 303349825..8b9026489 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1289,6 +1289,7 @@ "unsavedchangespopup": "" }, "validation": { + "dateRangeExceeded": "", "invalidemail": "Por favor introduzca una dirección de correo electrónico válida.", "invalidphone": "", "required": "Este campo es requerido." diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 9cdf64349..8f9330ea0 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1289,6 +1289,7 @@ "unsavedchangespopup": "" }, "validation": { + "dateRangeExceeded": "", "invalidemail": "S'il vous plaît entrer un email valide.", "invalidphone": "", "required": "Ce champ est requis." From 77f340d08c6cda12ed3633f43583eed93c840737 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Wed, 27 Nov 2024 08:40:55 -0800 Subject: [PATCH 3/4] IO-3037 Supplement Existing Lines Signed-off-by: Allan Carr --- client/src/graphql/jobs-lines.queries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/graphql/jobs-lines.queries.js b/client/src/graphql/jobs-lines.queries.js index b755ee705..653cbb9f1 100644 --- a/client/src/graphql/jobs-lines.queries.js +++ b/client/src/graphql/jobs-lines.queries.js @@ -2,7 +2,7 @@ import { gql } from "@apollo/client"; export const GET_ALL_JOBLINES_BY_PK = gql` query GET_ALL_JOBLINES_BY_PK($id: uuid!) { - joblines(where: { jobid: { _eq: $id } }, order_by: { line_no: asc }) { + joblines(where: { jobid: { _eq: $id }, removed: { _eq: false } }, order_by: { line_no: asc }) { id line_no unq_seq From 5e8d0fddbd6d0e5d68dc6a172d888b22899751dc Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 27 Nov 2024 09:44:42 -0800 Subject: [PATCH 4/4] IO-2959 Remove debug for crisp status and add sig term handler. --- server.js | 41 +++++++++++++++++++++++++++++++++- server/utils/statusReporter.js | 16 ++++++------- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/server.js b/server.js index bba9edb77..a408742a3 100644 --- a/server.js +++ b/server.js @@ -24,6 +24,8 @@ const { ElastiCacheClient, DescribeCacheClustersCommand } = require("@aws-sdk/cl const { InstanceRegion } = require("./server/utils/instanceMgr"); const StartStatusReporter = require("./server/utils/statusReporter"); +const cleanupTasks = []; +let isShuttingDown = false; const CLUSTER_RETRY_BASE_DELAY = 100; const CLUSTER_RETRY_MAX_DELAY = 5000; const CLUSTER_RETRY_JITTER = 100; @@ -298,7 +300,14 @@ const main = async () => { applyRoutes({ app }); redisSocketEvents({ io: ioRedis, redisHelpers, ioHelpers, logger }); - StartStatusReporter(); + const StatusReporter = StartStatusReporter(); + registerCleanupTask(async () => { + StatusReporter.end(); + }); + + // Add SIGTERM signal handler + process.on("SIGTERM", handleSigterm); + process.on("SIGINT", handleSigterm); // Optional: Handle Ctrl+C try { await server.listen(port); @@ -317,3 +326,33 @@ main().catch((error) => { // Note: If we want the app to crash on all uncaught async operations, we would // need to put a `process.exit(1);` here }); + +// Register a cleanup task +function registerCleanupTask(task) { + cleanupTasks.push(task); +} + +// SIGTERM handler +async function handleSigterm() { + if (isShuttingDown) { + logger.log("sigterm-api", "WARN", null, null, { message: "Shutdown already in progress, ignoring signal." }); + return; + } + + isShuttingDown = true; + + logger.log("sigterm-api", "WARN", null, null, { message: "SIGTERM Received. Starting graceful shutdown." }); + + try { + for (const task of cleanupTasks) { + logger.log("sigterm-api", "WARN", null, null, { message: `Running cleanup task: ${task.name}` }); + + await task(); + } + logger.log("sigterm-api", "WARN", null, null, { message: `All cleanup tasks completed.` }); + } catch (error) { + logger.log("sigterm-api-error", "ERROR", null, null, { message: error.message, stack: error.stack }); + } + + process.exit(0); +} diff --git a/server/utils/statusReporter.js b/server/utils/statusReporter.js index a2e9bdc26..fc425da33 100644 --- a/server/utils/statusReporter.js +++ b/server/utils/statusReporter.js @@ -11,7 +11,7 @@ const InstanceManager = require("../utils/instanceMgr").default; function StartStatusReporter() { //For ImEX Online. - InstanceManager({ + return InstanceManager({ executeFunction: true, args: [], imex: () => { @@ -31,14 +31,14 @@ function StartStatusReporter() { service_id: process.env.CRISP_SERVICE_IDENTIFIER, // Service ID containing the parent Node for Replica (given by Crisp) node_id: process.env.CRISP_NODE_IDENTIFIER, // Node ID containing Replica (given by Crisp) replica_id: getHostNameOrIP(), // Unique Replica ID for instance (ie. your IP on the LAN) - interval: 30, // Reporting interval (in seconds; defaults to 30 seconds if not set) + interval: 30 // Reporting interval (in seconds; defaults to 30 seconds if not set) - console: { - debug: (log_message, data) => logger.log("crisp-status-update", "DEBUG", null, null, { log_message, data }), - log: (log_message, data) => logger.log("crisp-status-update", "DEBUG", null, null, { log_message, data }), - warn: (log_message, data) => logger.log("crisp-status-update", "WARN", null, null, { log_message, data }), - error: (log_message, data) => logger.log("crisp-status-update", "ERROR", null, null, { log_message, data }) - } // Console instance if you need to debug issues, + // console: { + // debug: (log_message, data) => logger.log("crisp-status-update", "DEBUG", null, null, { log_message, data }), + // log: (log_message, data) => logger.log("crisp-status-update", "DEBUG", null, null, { log_message, data }), + // warn: (log_message, data) => logger.log("crisp-status-update", "WARN", null, null, { log_message, data }), + // error: (log_message, data) => logger.log("crisp-status-update", "ERROR", null, null, { log_message, data }) + // } // Console instance if you need to debug issues, }); return crispStatusReporter;