From 071d79348c3c7897679d9b847ce25514f236f29a Mon Sep 17 00:00:00 2001
From: Kevin Jackson <30411845+KevinJJackson@users.noreply.github.com>
Date: Thu, 12 Dec 2024 16:31:56 -0500
Subject: [PATCH] bugfix/cwms-data-plotting (#251)
---
package.json | 2 +-
.../project/batch-plotting/batch-plotting.jsx | 20 ++++++------
.../chart-content/scatter-line-plot.jsx | 10 ++++++
.../batch-plotting/components/cwms-errors.jsx | 32 +++++++++++++++++++
4 files changed, 54 insertions(+), 10 deletions(-)
create mode 100644 src/app-pages/project/batch-plotting/components/cwms-errors.jsx
diff --git a/package.json b/package.json
index bb7f4dc7..497a678b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "hhd-ui",
- "version": "0.18.6",
+ "version": "0.18.7",
"private": true,
"dependencies": {
"@ag-grid-community/client-side-row-model": "^30.0.3",
diff --git a/src/app-pages/project/batch-plotting/batch-plotting.jsx b/src/app-pages/project/batch-plotting/batch-plotting.jsx
index de8e941a..af2366a5 100644
--- a/src/app-pages/project/batch-plotting/batch-plotting.jsx
+++ b/src/app-pages/project/batch-plotting/batch-plotting.jsx
@@ -60,8 +60,7 @@ const BatchPlotting = connect(
const uri = `/projects/${projectId}/instruments/${id}/timeseries/cwms`;
return apiGet(uri);
},
- staleTime: Infinity,
- enabled: !!cwmsTimeseries.length,
+ enabled: !!instrumentIds.length,
})),
combine: (ret) => {
return {
@@ -72,23 +71,25 @@ const BatchPlotting = connect(
const cwmsTimeseriesIds = midasCwmsTimeseries.map(ts => ts?.cwms_timeseries_id);
- const { data: cwmsTimeseriesMeasurements } = useQueries({
- queries: cwmsTimeseriesIds.map(ts => ({
- queryKey: ['cwmsTimeseriesMeasurementsPlotting', ts, currentDateRange[0]],
+ const { data: cwmsTimeseriesMeasurements, errors: cwmsMeasurementsErrors } = useQueries({
+ queries: cwmsTimeseriesIds.map(cwmsId => ({
+ queryKey: ['cwmsTimeseriesMeasurementsPlotting', cwmsId, currentDateRange[0]],
queryFn: () => {
- const { cwms_timeseries_id, cwms_office_id, cwms_extent_earliest_time } = midasCwmsTimeseries.find(el => el.cwms_timeseries_id === ts);
+ const { cwms_timeseries_id, cwms_office_id, cwms_extent_earliest_time } = midasCwmsTimeseries.find(el => el.cwms_timeseries_id === cwmsId);
const beginDate = Math.max(DateTime.fromJSDate(currentDateRange[0]).toMillis(), DateTime.fromISO(cwms_extent_earliest_time).toMillis());
const uri = `/timeseries${buildQueryParams({ name: cwms_timeseries_id, office: cwms_office_id, begin: DateTime.fromMillis(beginDate).toUTC().toISO() })}`;
+
return apiGet(uri, 'CWMS');
},
staleTime: Infinity,
- enabled: !!midasCwmsTimeseries.length,
+ enabled: activeConfig && !!cwmsTimeseriesIds.length,
})),
combine: (ret) => {
return {
- data: ret.map((result) => result.data),
- }
+ data: ret.map(result => result.data),
+ errors: ret.map(result => result.isError),
+ };
},
});
@@ -126,6 +127,7 @@ const BatchPlotting = connect(
const cwmsProps = {
hasCwmsData: !!cwmsTimeseries.length,
cwmsData: cwmsTimeseriesMeasurements,
+ cwmsMeasurementsErrors,
midasCwmsTimeseries,
};
diff --git a/src/app-pages/project/batch-plotting/chart-content/scatter-line-plot.jsx b/src/app-pages/project/batch-plotting/chart-content/scatter-line-plot.jsx
index 05914de1..be0d842e 100644
--- a/src/app-pages/project/batch-plotting/chart-content/scatter-line-plot.jsx
+++ b/src/app-pages/project/batch-plotting/chart-content/scatter-line-plot.jsx
@@ -7,6 +7,7 @@ import BatchPlotChartSettings from '../components/batch-plot-chart-settings';
import Chart from '../../../../app-components/chart/chart';
import ChartErrors from '../components/batch-plot-errors';
import { determineDateRange, generateNewChartData } from '../helper';
+import CwmsErrors from '../components/cwms-errors';
const ScatterLinePlot = connect(
// 'doPrintSetData',
@@ -28,8 +29,11 @@ const ScatterLinePlot = connect(
hasCwmsData,
cwmsData,
midasCwmsTimeseries,
+ cwmsMeasurementsErrors,
}) => {
const { auto_range, date_range, display, show_masked, show_comments, show_nonvalidated, plot_type, id } = plotConfig || {};
+
+ console.log('test cwmsMeasurementsErrors:', cwmsMeasurementsErrors);
const plotTimeseriesIds = display?.traces?.map(el => el.timeseries_id) || [];
const plotTimeseries = timeseries.filter(ts => plotTimeseriesIds.includes(ts.id));
@@ -135,6 +139,12 @@ const ScatterLinePlot = connect(
timeseries={timeseries}
plotConfig={plotConfig}
/>
+ {hasCwmsData && (
+