Skip to content

Commit

Permalink
Fix incorrect report config request body schemas (#222)
Browse files Browse the repository at this point in the history
* npm audit fix

* fix create/update report config schema issues; add toast notifications

* clean up unused vars

* replace update with create in toast notification
  • Loading branch information
dennisgsmith authored Jun 27, 2024
1 parent 0f0442e commit b0238d1
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 32 deletions.
87 changes: 75 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions src/app-bundles/report-configurations-bundle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { toast } from 'react-toastify';

import { tUpdateError, tUpdateSuccess } from '../common/helpers/toast-helpers';

export default {
name: 'reportConfigurations',
getReducer: () => {
Expand Down Expand Up @@ -40,6 +44,7 @@ export default {
},

doCreateNewReportConfiguration: (data) => ({ store, apiPost }) => {
const toastId = toast.loading('Creating Report Configuration...');
const projectId = store.selectProjectsIdByRoute()?.projectId;
const uri = `/projects/${projectId}/report_configs`;

Expand All @@ -50,30 +55,24 @@ export default {

apiPost(uri, body, (err, _body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('todo', err);
tUpdateError(toastId, "Failed to create Report Configuration");
} else {
tUpdateSuccess(toastId, "Successfully created Report Configuration");
store.doFetchReportConfigurationsByProjectId();
}
});
},

doUpdateReportConfiguration: (data) => ({ store, apiPut }) => {
const { id, name, description, plot_configs } = data;
const toastId = toast.loading('Updating Report Configuration...');
const projectId = store.selectProjectsIdByRoute()?.projectId;
const uri = `/projects/${projectId}/report_configs/${data?.id}`;

const uri = `/projects/${projectId}/report_configs/${id}`;
const body = {
name,
description,
plot_configs,
};

apiPut(uri, body, (err, _body) => {
apiPut(uri, data, (err, _body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('todo', err);
tUpdateError(toastId, "Failed to update Report Configuration");
} else {
tUpdateSuccess(toastId, "Successfully updated Report Configuration");
store.doFetchReportConfigurationsByProjectId();
}
});
Expand Down
1 change: 1 addition & 0 deletions src/app-pages/project/batch-plotting/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const generateNewChartData = (measurements, timeseries, chartSettings, pl
} = timeseries.find(t => t.id === timeseries_id) || {};

if (!instrument) {
// eslint-disable-next-line no-console
console.error('Error: timeseries id (%s) does not exist in `timeseries` array.', String(timeseries_id));
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Button, Divider, FormControl, Input, InputLabel, MenuItem, Select } from '@mui/material';
import { Button, FormControl, Input, InputLabel, MenuItem, Select } from '@mui/material';
import { connect } from 'redux-bundler-react';

const generateTimeseriesOptions = (timeseriesIds = [], timeseries = []) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import ChartErrors from '../components/batch-plot-errors';
import { generateNewChartData } from '../helper';

const BatchPlotChart = connect(
'doPrintSetData',
// 'doPrintSetData',
'doTimeseriesMeasurementsFetchById',
'doBatchPlotConfigurationsSave',
'selectBatchPlotConfigurationsActiveId',
'selectBatchPlotConfigurationsItemsObject',
'selectTimeseriesMeasurementsItems',
'selectInstrumentTimeseriesItems',
({
doPrintSetData,
// doPrintSetData,
doTimeseriesMeasurementsFetchById,
doBatchPlotConfigurationsSave,
batchPlotConfigurationsActiveId: activeId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const initFormState = (initValue = {}) => {
},
show_masked: {
enabled: false,
value: '',
value: true,
},
show_nonvalidated: {
enabled: false,
value: '',
value: true,
}
},
} = initValue;
Expand Down Expand Up @@ -234,7 +234,7 @@ const NewReportConfigContent = connect(
size='small'
id='masked-select'
value={String(formState?.global_overrides?.show_masked?.value)}
onChange={e => setFormState(prev => setGlobalOverrides(prev, 'show_masked', 'value', String(e.target.value)))}
onChange={e => setFormState(prev => setGlobalOverrides(prev, 'show_masked', 'value', Boolean(e.target.value)))}
sx={{ width: '250px' }}
>
<MenuItem value='false'>Hide Masked Values</MenuItem>
Expand All @@ -254,7 +254,7 @@ const NewReportConfigContent = connect(
size='small'
id='non-validated-select'
value={String(formState?.global_overrides?.show_nonvalidated?.value)}
onChange={e => setFormState(prev => setGlobalOverrides(prev, 'show_nonvalidated', 'value', String(e.target.value)))}
onChange={e => setFormState(prev => setGlobalOverrides(prev, 'show_nonvalidated', 'value', Boolean(e.target.value)))}
sx={{ width: '250px' }}
>
<MenuItem value='false'>Hide Non-Validated Values</MenuItem>
Expand Down

0 comments on commit b0238d1

Please sign in to comment.