Skip to content

Commit

Permalink
stable - v0.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJJackson authored Jan 30, 2024
2 parents 00a5674 + ca8dc1b commit 7752351
Show file tree
Hide file tree
Showing 84 changed files with 1,710 additions and 830 deletions.
13 changes: 7 additions & 6 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
VITE_ALERT_EDITOR: false
VITE_FORMULA_EDITOR: true
VITE_INSTRUMENT_CHART: true
VITE_CROSS_SECTION: true
VITE_DEVELOPMENT_BANNER: false
VITE_API_URL: https://midas.sec.usace.army.mil/api
VITE_ALERT_EDITOR=false
VITE_FORMULA_EDITOR=true
VITE_INSTRUMENT_CHART=true
VITE_CROSS_SECTION=true
VITE_DEVELOPMENT_BANNER=false
VITE_API_URL=https://midas.sec.usace.army.mil/api
VITE_URL_BASE_PATH=/midas
13 changes: 7 additions & 6 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
VITE_ALERT_EDITOR: false
VITE_FORMULA_EDITOR: true
VITE_INSTRUMENT_CHART: true
VITE_CROSS_SECTION: true
VITE_DEVELOPMENT_BANNER: false
VITE_API_URL: https://midas-test.cwbi.us/api
VITE_ALERT_EDITOR=false
VITE_FORMULA_EDITOR=true
VITE_INSTRUMENT_CHART=true
VITE_CROSS_SECTION=true
VITE_DEVELOPMENT_BANNER=false
VITE_API_URL=https://midas-test.cwbi.us/api
VITE_URL_BASE_PATH=/midas
2 changes: 2 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
VITE_INSTRUMENT_CHART: true
VITE_CROSS_SECTION: true
VITE_DEVELOPMENT_BANNER: true
VITE_MOVING_BANNER: true
VITE_API_URL: https://develop-midas-api.rsgis.dev
VITE_URL_BASE_PATH: ''
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
env:
VITE_FORMULA_EDITOR: true
VITE_API_URL: https://midas-api.rsgis.dev
VITE_URL_BASE_PATH: ''
VITE_MOVING_BANNER: true
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hhd-ui",
"version": "0.14.1",
"version": "0.15.0",
"private": true,
"dependencies": {
"@ag-grid-community/client-side-row-model": "^30.0.3",
Expand Down
4 changes: 4 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { connect } from 'redux-bundler-react';
import { ToastContainer } from 'react-toastify';

import Modal from './app-components/modal';
import MovingBanner from './common/moving-banner';
import NavBar from './app-components/navigation';
import PageContent from './app-components/pageContent';

Expand All @@ -13,11 +14,14 @@ import './css/bootstrap/css/bootstrap.water.min.css';
import './css/ms/css/mapskin.min.css';
import './css/index.scss';

const isMovingBannerActive = import.meta.env.VITE_MOVING_BANNER === 'true';

export default connect('selectRoute', ({ route: Route }) => (
<>
<NavBar theme='primary' />
<ToastContainer autoClose={3500} hideProgressBar={false} />
<PageContent>
{isMovingBannerActive && <MovingBanner />}
<Route />
</PageContent>
<Modal closeWithEscape />
Expand Down
2 changes: 1 addition & 1 deletion src/app-bundles/batch-plot-configurations-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default createRestBundle({
selectInstrumentsByBatchPlotConfigurationsGeoJSON: createSelector(
'selectInstrumentsItems',
'selectBatchPlotConfigurationsItems',
'selectInstrumentTimeseriesItemsByRoute',
'selectInstrumentTimeseriesItems',
'selectBatchPlotConfigurationsActiveId',
(instruments, batchPlotConfigurations, timeseries, activeId) => {
const instrumentMap = {};
Expand Down
4 changes: 2 additions & 2 deletions src/app-bundles/collection-group-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default createRestBundle({
urlParamSelectors: ['selectProjectsIdByRoute'],
prefetch: (store) => {
const hash = store.selectHash();
const url = store.selectUrlObject();
const pathname = store.selectRelativePathname();
const whiteList = ['dashboard'];

return (
whiteList.includes(hash) || url.pathname.includes('/collection-groups/')
whiteList.includes(hash) || pathname.includes('/collection-groups/')
);
},
addons: {
Expand Down
4 changes: 2 additions & 2 deletions src/app-bundles/create-auth-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const createAuthBundle = (opts) => {
try {
xhr(url, (err, response, body) => {
if (err) {
throw new Error('Login Response not ok');
throw new Error(`Login Response not ok. ${err}`);
} else {
const token = typeof body === 'string' ? body : JSON.parse(body);
dispatch({
Expand Down Expand Up @@ -89,7 +89,7 @@ const createAuthBundle = (opts) => {
});
store.doRemoveProfile();
const redirect = store.selectAuthRedirectOnLogout();
if (redirect) store.doUpdateUrl(redirect);
if (redirect) store.doUpdateRelativeUrl(redirect);
}
},

Expand Down
1 change: 1 addition & 0 deletions src/app-bundles/create-jwt-api-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const createJwtApiBundle = (opts) => {
const options = {
method: 'GET',
};

if (!shouldSkipToken(options.method, path, unless)) {
const token = store[tokenSelector]();
if (!token) return null;
Expand Down
13 changes: 13 additions & 0 deletions src/app-bundles/create-url-base-path-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createSelector } from "redux-bundler";

export default ({ base }) => {
return {
name: 'urlBasePath',

selectRelativePathname: createSelector('selectPathname', pathname => pathname.replace(base, '')),

doUpdateRelativeUrl: (url, opts) => ({ store }) => {
store.doUpdateUrl(`${base}${url}`, opts)
},
}
};
4 changes: 2 additions & 2 deletions src/app-bundles/data-logger-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default {
});
},

doFetchDataLoggerPreview: ({ dataLoggerId }) => ({ dispatch, apiGet }) => {
const uri = `/datalogger/${dataLoggerId}/preview`;
doFetchDataLoggerPreview: ({ dataLoggerId, tableId }) => ({ dispatch, apiGet }) => {
const uri = `/datalogger/${dataLoggerId}/tables/${tableId}/preview`;

apiGet(uri, (err, body) => {
if (err) {
Expand Down
54 changes: 40 additions & 14 deletions src/app-bundles/data-logger-equivalency-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default {
selectDataLoggerEquivalencyRaw: state => state.dataLoggerEquivalency,
selectDataLoggerEquivalencyTable: state => state.dataLoggerEquivalency.table,

doFetchDataLoggerEquivalency: ({ dataLoggerId }) => ({ dispatch, apiGet }) => {
const uri = `/datalogger/${dataLoggerId}/equivalency_table`;
doFetchDataLoggerEquivalency: ({ dataLoggerId, tableId }) => ({ dispatch, apiGet }) => {
const uri = `/datalogger/${dataLoggerId}/tables/${tableId}/equivalency_table`;

apiGet(uri, (err, body) => {
if (err) {
Expand All @@ -39,18 +39,42 @@ export default {
});
},

doCreateDataLoggerEquivalency: ({ dataLoggerId, newRows = [], unusedRows = [], isDeleteChecked = false }) => ({ store, apiPost }) => {
doCreateEquivalencyByTableName: ({ dataLoggerId, tableName, newRows }) => ({ store, apiPost }) => {
const uri = `/datalogger/${dataLoggerId}/equivalency_table`;

const payload = {
datalogger_id: dataLoggerId,
datalogger_table_name: tableName,
rows: newRows.map(row => ({
field_name: row,
display_name: row,
})),
};

apiPost(uri, payload, (err, _body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('todo', err);
} else {
store.doFetchDataLoggersByProjectId();
}
});
},

doAutoMapDataLoggerEquivalency: ({ dataLoggerId, tableId, tableName, newRows = [], unusedRows = [], isDeleteChecked = false }) => ({ store, apiPost }) => {
const uri = `/datalogger/${dataLoggerId}/tables/${tableId}/equivalency_table`;

if (isDeleteChecked) {
unusedRows.forEach(el => {
const { id } = el;
store.doDeleteDataLoggerEquivalencyRow({ dataLoggerId, id, refreshData: false });
});
}

const payload = {
datalogger_id: dataLoggerId,
datalogger_table_id: tableId,
datalogger_table_name: tableName,
rows: newRows.map(row => ({
field_name: row,
display_name: row,
Expand All @@ -62,18 +86,19 @@ export default {
// eslint-disable-next-line no-console
console.log('todo', err);
} else {
store.doFetchDataLoggerEquivalency({ dataLoggerId });
store.doFetchDataLoggerEquivalency({ dataLoggerId, tableId });
}
});
},

doUpdateSingleDataLoggerEquivalency: (data) => ({ store, apiPut }) => {
const { dataLoggerId, id, fieldName, displayName, instrumentId, timeseriesId } = data;
const uri = `/datalogger/${dataLoggerId}/equivalency_table`;
const { dataLoggerId, tableId, id, fieldName, displayName, instrumentId, timeseriesId } = data;
const uri = `/datalogger/${dataLoggerId}/tables/${tableId}/equivalency_table`;
// const toastId = toast.loading('Updating Field Mapping...');

const payload = {
datalogger_id: dataLoggerId,
datalogger_table_id: tableId,
rows: [
{
id,
Expand All @@ -91,18 +116,19 @@ export default {
console.log('test err: ', JSON.stringify(err));
// tUpdateError(toastId, 'Failed');
} else {
store.doFetchDataLoggerEquivalency({ dataLoggerId });
store.doFetchDataLoggerEquivalency({ dataLoggerId, tableId });
// tUpdateSuccess(toastId, 'Successfully updated Field Mapping!');
}
});
},

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

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

Expand All @@ -113,21 +139,21 @@ export default {
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 });
store.doFetchDataLoggerEquivalency({ dataLoggerId, tableId });
}
});
},

doDeleteDataLoggerEquivalencyRow: ({ dataLoggerId, id, refreshData = true }) => ({ store, apiDelete }) => {
const uri = `/datalogger/${dataLoggerId}/equivalency_table/row?id=${id}`;
doDeleteDataLoggerEquivalencyRow: ({ dataLoggerId, tableId, id, refreshData = true }) => ({ store, apiDelete }) => {
const uri = `/datalogger/${dataLoggerId}/tables/${tableId}/equivalency_table/row/${id}`;

apiDelete(uri, (err, _body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('todo', err);
} else {
if (refreshData) {
store.doFetchDataLoggerEquivalency({ dataLoggerId });
store.doFetchDataLoggerEquivalency({ dataLoggerId, tableId });
}
}
});
Expand Down
36 changes: 36 additions & 0 deletions src/app-bundles/districts-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export default {
name: 'districts',
getReducer: () => {
const initData = {
districts: [],
};

return (state = initData, { type, payload }) => {
switch (type) {
case 'UPDATE_DISTRICT_DATA':
return {
...state,
districts: payload,
};
default:
return state;
}
};
},

selectDistrictsRaw: (state) => state.districts,
selectDistricts: (state) => state.districts.districts,

doFetchDistricts: () => ({ apiGet, dispatch }) => {
const url = `/districts`;

apiGet(url, (err, body) => {
if (err) {
// eslint-disable-next-line no-console
console.log('error: ', err);
} else {
dispatch({ type: 'UPDATE_DISTRICT_DATA', payload: body });
}
});
},
};
6 changes: 1 addition & 5 deletions src/app-bundles/home-data-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ export default createRestBundle({
getTemplate: '/home',
fetchActions: ['URL_UPDATED', 'AUTH_LOGGED_IN'],
forceFetchActions: [],
prefetch: store => {
const url = store.selectUrlObject();

return url.pathname === '/';
},
prefetch: store => store.selectRelativePathname() === '/',
addons: {
selectHomeData: createSelector('selectHomeItems', (items) => {
const data = items && items.length ? items[0] : null;
Expand Down
4 changes: 2 additions & 2 deletions src/app-bundles/inclinometer-measurements.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export default createRestBundle({
mergeItems: true,
prefetch: (store) => {
const hash = store.selectHash();
const url = store.selectUrlObject();
const pathname = store.selectRelativePathname();

const whitelist = [];
const pathnameWhitelist = ['/instruments/', '/groups/', '/collection-groups/'];

return whitelist.includes(hash) || pathnameWhitelist.some(elem => url.pathname.includes(elem));
return whitelist.includes(hash) || pathnameWhitelist.some(elem => pathname.includes(elem));
},
addons: {
doFetchInclinometerMeasurementsByTimeseriesId: (timeseriesId) => ({ dispatch, apiGet }) => {
Expand Down
Loading

0 comments on commit 7752351

Please sign in to comment.