Skip to content

Commit

Permalink
deploy v0.14.1 (#193)
Browse files Browse the repository at this point in the history
deploy v0.14.1
  • Loading branch information
KevinJJackson authored Nov 16, 2023
2 parents de018c3 + 8dc26f9 commit 00a5674
Show file tree
Hide file tree
Showing 54 changed files with 2,253 additions and 442 deletions.
467 changes: 282 additions & 185 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hhd-ui",
"version": "0.13.2",
"version": "0.14.1",
"private": true,
"dependencies": {
"@ag-grid-community/client-side-row-model": "^30.0.3",
Expand All @@ -10,6 +10,7 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.0",
"@mui/material": "^5.14.2",
"@tanstack/react-table": "^8.9.3",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
Expand Down Expand Up @@ -69,8 +70,8 @@
"scripts": {
"start": "vite",
"build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build",
"build:test": "env-cmd -f .env.test vite build",
"build:prod": "env-cmd -f .env.production vite build",
"build:test": "env-cmd -f .env.test vite build --mode test",
"build:prod": "env-cmd -f .env.production vite build --mode production",
"serve-local-build": "npx serve -s build",
"preview": "vite preview",
"pretty": "prettier --write \"./**/*.{js,jsx,json,html,scss,css}\"",
Expand Down
34 changes: 23 additions & 11 deletions src/app-bundles/chart-editor-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ const chartEditorBundle = {

Object.keys(dataByInstrumentId).forEach((id) => {
const { timeseries } = dataByInstrumentId[id];

if (!timeseries || !timeseries.length) return undefined;

timeseries.sort((a, b) => {
Expand All @@ -300,7 +301,7 @@ const chartEditorBundle = {

const x = [];
const y = [];
let plotData = [];
const plotData = [];

if (isInclinometer) {
const negateDepth = val => val < 0 ? val : -val;
Expand Down Expand Up @@ -339,46 +340,57 @@ const chartEditorBundle = {
y.push(item.value);
});

plotData = [{
plotData.push({
type: 'scattergl',
name: `${instrumentName} - ${name}`,
x: x,
y: y,
...style,
}];
});
}

const domainName = getDomainName(domains, parameter_id);
const unitName = domains['unit'].find(el => el.id === unit_id)?.value;

if (!chartData.find(y => y.name === parameter_id)) {
if (!chartData.find(x => x.name === parameter_id)) {
chartData.push({
id: series.id,
name: parameter_id,
domainName,
unitName,
unit: unit_id,
data: plotData,
});
} else if (
chartData.find(x => x.name === parameter_id).unit !== unit_id &&
chartData.findIndex(y => y.name === parameter_id) !== -1
) {
} else if (chartData.find(x => x.name === parameter_id).unit !== unit_id && chartData.findIndex(y => y.name === parameter_id) !== -1) {
chartData.push({
id: series.id,
name: parameter_id,
domainName,
unitName,
unit: unit_id,
data: plotData,
});
} else {
const found = chartData.find(x => x.name === parameter_id);
found.id = series.id;
found.data.concat(plotData);
const foundIndex = chartData.findIndex(x => x.name === parameter_id);
const item = chartData[foundIndex];

chartData.splice(foundIndex, 1);

chartData.push({
id: series.id,
name: parameter_id,
domainName,
unitName,
unit: unit_id,
data: [...item.data, ...plotData],
});
}
});
});
if (showRainfall) {
chartData.push(...rainfallData);
}

return chartData;
}
),
Expand Down
27 changes: 23 additions & 4 deletions src/app-bundles/data-logger-equivalency-bundle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { tUpdateError, tUpdateSuccess } from "../common/helpers/toast-helpers";

export default {
name: 'dataLoggerEquivalency',
getReducer: () => {
Expand Down Expand Up @@ -65,7 +67,7 @@ export default {
});
},

doUpdateDataLoggerEquivalency: (data) => ({ store, apiPut }) => {
doUpdateSingleDataLoggerEquivalency: (data) => ({ store, apiPut }) => {
const { dataLoggerId, id, fieldName, displayName, instrumentId, timeseriesId } = data;
const uri = `/datalogger/${dataLoggerId}/equivalency_table`;
// const toastId = toast.loading('Updating Field Mapping...');
Expand Down Expand Up @@ -95,9 +97,26 @@ export default {
});
},

// doDeleteDataLoggerEquivalency: ({ dataLoggerId }) => ({ dispatch, store, apiDelete }) => {
// const uri = `/datalogger/${dataLoggerId}/equivalency_table`;
// },
// For use in auto-assigning only.
doUpdateMultipleDataLoggerEquivalency: (dataLoggerId, rows, toastId) => ({ store, apiPut }) => {
const uri = `/datalogger/${dataLoggerId}/equivalency_table`;

const payload = {
datalogger_id: dataLoggerId,
rows,
};

apiPut(uri, payload, (err, _body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('test err: ', JSON.stringify(err));
tUpdateError(toastId, 'Failed to assign timeseries to field names. Please try again later.');
} else {
tUpdateSuccess(toastId, 'Successfully assigned timeseries to field names!');
store.doFetchDataLoggerEquivalency({ dataLoggerId });
}
});
},

doDeleteDataLoggerEquivalencyRow: ({ dataLoggerId, id, refreshData = true }) => ({ store, apiDelete }) => {
const uri = `/datalogger/${dataLoggerId}/equivalency_table/row?id=${id}`;
Expand Down
11 changes: 9 additions & 2 deletions src/app-bundles/district-rollup-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ export default {
selectDistrictRollupMeasurement: (state) => state.districtRollup.measurement,

// one of [`evaluation`, `measurement`]
doFetchDistrictRollup: (type) => ({ dispatch, store, apiGet }) => {
doFetchDistrictRollup: (type, fromDate = '', toDate = '') => ({ dispatch, store, apiGet }) => {
dispatch({ type: 'ROLLUP_FETCH_START' });
const { projectId } = store.selectProjectsIdByRoute();

const url = `/projects/${projectId}/district_rollup/${type}_submittals`;
let query = '';
if (fromDate && toDate) {
const formattedFrom = fromDate.toISOString();
const formattedTo = toDate.toISOString();
query = `?from_timestamp_month=${formattedFrom}&to_timestamp_month=${formattedTo}`;
}

const url = `/projects/${projectId}/district_rollup/${type}_submittals${query}`;

apiGet(url, (err, body) => {
if (err) {
Expand Down
36 changes: 35 additions & 1 deletion src/app-bundles/inclinometer-measurements.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default createRestBundle({
// TODO: default before and after time periods should be implemented on
// the backend.
getTemplate: '/timeseries/:timeseriesId/inclinometer_measurements?before=2025-01-01T00:00:00.00Z&after=1900-01-01T00:00:00.00Z',

putTemplate: '',
postTemplate: '/timeseries/:timeseriesId/inclinometer_measurements',
deleteTemplate: '/timeseries/:timeseriesId/inclinometer_measurements?time={:item.date}',
Expand All @@ -33,4 +32,39 @@ export default createRestBundle({

return whitelist.includes(hash) || pathnameWhitelist.some(elem => url.pathname.includes(elem));
},
addons: {
doFetchInclinometerMeasurementsByTimeseriesId: (timeseriesId) => ({ dispatch, apiGet }) => {
const uri = `/timeseries/${timeseriesId}/inclinometer_measurements?before=2025-01-01T00:00:00.00Z&after=1900-01-01T00:00:00.00Z`;

apiGet(uri, (err, body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('error: ', err);
} else {
dispatch({
type: 'SET_CURRENT_INCLINOMETER_MEASUREMENTS',
payload: {
timeseriesId,
measurements: body,
},
});
}
});
},

selectCurrentInclinometerMeasurements: state => state.inclinometerMeasurements.currentMeasurements,
},
reduceFurther: (state, { type, payload }) => {
if (type === 'SET_CURRENT_INCLINOMETER_MEASUREMENTS') {
return {
...state,
'currentMeasurements': {
...state['currentMeasurements'],
[payload.timeseriesId]: payload.measurements,
},
};
} else {
return state;
}
},
});
2 changes: 2 additions & 0 deletions src/app-bundles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import instrumentGroupInstrumentsBundle from './instrument-group-instruments-bun
import instrumentGroupMapBundle from './instrument-group-map-bundle';
import instrumentMapBundle from './instrument-map-bundle';
import instrumentNotesBundle from './instrument-notes-bundle';
import instrumentSensorsBundle from './instrument-sensors-bundle';
import instrumentStatusBundle from './instrument-status-bundle';
import mapsBundle from './maps-bundle';
import modalBundle from './modal-bundle';
Expand Down Expand Up @@ -138,6 +139,7 @@ export default composeBundles(
instrumentGroupInstrumentsBundle,
instrumentMapBundle,
instrumentNotesBundle,
instrumentSensorsBundle,
instrumentStatusBundle,
mapsBundle,
modalBundle,
Expand Down
91 changes: 91 additions & 0 deletions src/app-bundles/instrument-sensors-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
export default {
name: 'instrumentSensors',
getReducer: () => {
const initialState = {
sensors: [],
measurements: [],
_lastFetched: null,
};

return (state = initialState, { type, payload }) => {
switch (type) {
case 'INSTRUMENT_SENSORS_UPDATED':
return {
...state,
sensors: payload,
_lastFetched: new Date(),
};
case 'SENSOR_MEASUREMENTS_UPDATED':
return {
...state,
measurements: payload,
};
default:
return state;
}
};
},

selectInstrumentSensorsRaw: (state) => state.instrumentSensors,
selectInstrumentSensors: (state) => state.instrumentSensors.sensors,
selectInstrumentSensorsMeasurements: (state) => state.instrumentSensors.measurements,
selectInstrumentSensorsLastFetched: (state) => state.instrumentSensors._lastFetched,

doFetchInstrumentSensorsById: () => ({ dispatch, store, apiGet }) => {
dispatch({ type: 'INSTRUMENT_SENSORS_BY_ID_FETCH_START' });
const { instrumentId } = store.selectInstrumentsIdByRoute();

const url = `/instruments/saa/${instrumentId}/segments`;

apiGet(url, (err, body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('error: ', err);
} else {
dispatch({
type: 'INSTRUMENT_SENSORS_UPDATED',
payload: body,
});
}

dispatch({ type: 'INSTRUMENT_SENSORS_BY_ID_FETCH_FINISHED' });
});
},

doUpdateInstrumentSensor: (formData) => ({ dispatch, store, apiPut }) => {
dispatch({ type: 'INSTRUMENT_SENSOR_UPDATE_START' });

const { instrumentId } = store.selectInstrumentsIdByRoute();
const url = `/instruments/saa/${instrumentId}/segments`;

apiPut(url, formData, (err, _body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('todo', err);
} else {
store.doFetchInstrumentSensorsById();
}
});
},

doFetchInstrumentSensorMeasurements: (before, after) => ({ dispatch, store, apiGet }) => {
dispatch({ type: 'SENSOR_MEASUREMENTS_FETCH_START' });
const { instrumentId } = store.selectInstrumentsIdByRoute();
const url = `/instruments/saa/${instrumentId}/measurements?before=${before}&after=${after}`;

apiGet(url, (err, body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('todo', err);
} else {
dispatch({
type: 'SENSOR_MEASUREMENTS_UPDATED',
payload: body,
});
}
});

dispatch({ type: 'SENSOR_MEASUREMENTS_FETCH_FINISHED' });

},
};
19 changes: 18 additions & 1 deletion src/app-bundles/submittals-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,27 @@ export default {
} else {
store.doFetchMissingSubmittalsByProjectId();
store.doFetchProjectAlertConfigs();
// store.doFetchAlertConfigSubmittals(alertConfigId);
}

dispatch({ type: 'PUT_VERIFY_ALL_MISSING_SUBMITTALS_FINISHED' });
});
},

doVerifySingleSubmittals: (submittalId) => ({ dispatch, store, apiPut }) => {
dispatch({ type: 'PUT_VERIFY_SINGLE_SUBMITTAL_START' });

const url = `/submittals/${submittalId}/verify_missing`;

apiPut(url, {}, (err, _body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('error: ', err);
} else {
store.doFetchHistoricalSubmittalsByProjectId();
store.doFetchProjectAlertConfigs();
}

dispatch({ type: 'PUT_VERIFY_SINGLE_SUBMITTAL_FISISHED' });
});
},
};
Loading

0 comments on commit 00a5674

Please sign in to comment.