Skip to content
Snippets Groups Projects
Unverified Commit 10957c03 authored by abriggs-usgs's avatar abriggs-usgs Committed by GitHub
Browse files

Merge pull request #1413 from abriggs-usgs/IOW-866_add_approvals_to_groundwater_levels_table

Iow 866 add approvals to groundwater levels table
parents 3af7a5ae ffee3e9c
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased](https://github.com/usgs/waterdataui/compare/waterdataui-0.42.0...master)
### Added
- A column indicating the approval status of the data shows in the DV Data Table.
### Fixed
- The converted Fahrenheit line no longer drops off graph with zero values.
- Locations with only some flood level indicators no longer show NaN
......
......@@ -14,12 +14,12 @@ const TABLE_CAPTION = {
const COLUMN_HEADINGS = {
iv: ['Parameter', 'Time', 'Result', 'Approval', 'Masks'],
gw: ['Parameter', 'Time', 'Result']
gw: ['Parameter', 'Time', 'Result', 'Approval']
};
const VALUE_NAMES = {
iv: ['parameterName', 'dateTime', 'result', 'approvals', 'masks'],
gw: ['parameterName', 'dateTime', 'result']
gw: ['parameterName', 'dateTime', 'result', 'approvals']
};
const CONTAINER_ID = {
......
......@@ -130,19 +130,19 @@ const TEST_DATA = {
},
values: [{
value: '0',
qualifiers: [],
qualifiers: ['A', '1'],
dateTime: 1520351100000
}, {
value: '0.01',
qualifiers: [],
qualifiers: ['P', '1'],
dateTime: 1520352000000
}, {
value: '0.02',
qualifiers: [],
qualifiers: ['R', '1'],
dateTime: 1520352900000
}, {
value: '0.03',
qualifiers: [],
qualifiers: ['A', '1'],
dateTime: 1520353800000
}]
}
......@@ -190,5 +190,6 @@ describe('monitoring-location/components/hydrograph/data-table', () => {
expect(testDiv.selectAll('table').size()).toBe(1);
expect(testDiv.select('#gw-table-container').select('caption').text()).toEqual('Field visit data');
expect(testDiv.select('tbody').selectAll('tr').size()).toBe(2);
expect(testDiv.selectAll('.approvals').size()).toBe(2);
});
});
\ No newline at end of file
});
......@@ -33,6 +33,22 @@ export const getVisibleGroundwaterLevelPoints = createSelector(
}
);
/*
* When given an approval code, will return the text equivalent
* @param {String} approvalCode - Usually a letter such as 'A'
* @return {String} - an easy to understand text version of an approval code
*/
const approvalCodeText = function(approvalCode) {
const approvalText = {
P: 'Provisional',
A: 'Approved',
R: 'Revised',
default: `unknown code: ${approvalCode}`
};
return approvalText[approvalCode] || approvalText.default;
};
/*
* Selector function which returns a function that returns an array of gw data appropriate
* for use in a table.
......@@ -46,6 +62,7 @@ export const getVisibleGroundwaterLevelsTableData = createSelector(
getVisibleGroundwaterLevelPoints,
getIanaTimeZone,
(currentVariable, gwLevels, timeZone) => {
return gwLevels.map((point) => {
return {
parameterName: currentVariable.variableName,
......@@ -53,7 +70,8 @@ export const getVisibleGroundwaterLevelsTableData = createSelector(
dateTime: DateTime.fromMillis(point.dateTime, {zone: timeZone}).toISO({
suppressMilliseconds: true,
suppressSeconds: true
})
}),
approvals: approvalCodeText(point.qualifiers[0])
};
});
}
......
......@@ -47,10 +47,10 @@ describe('monitoring-location/components/hydrograph/selectors/discrete-data', ()
oid: '45807042'
},
values: [
{value: '12.0', dateTime: 1489672800000},
{value: '13.0', dateTime: 1490536800000},
{value: '14.5', dateTime: 1490882400000},
{value: '14.0', dateTime: 1491055200000}
{value: '12.0', qualifiers: 'P', dateTime: 1489672800000},
{value: '13.0', qualifiers: 'P', dateTime: 1490536800000},
{value: '14.5', qualifiers: 'A', dateTime: 1490882400000},
{value: '14.0', qualifiers: 'E', dateTime: 1491055200000}
]
}
}
......@@ -85,10 +85,12 @@ describe('monitoring-location/components/hydrograph/selectors/discrete-data', ()
expect(result).toHaveLength(2);
expect(result[0]).toEqual({
'qualifiers': 'P',
value: 13.0,
dateTime: 1490536800000
});
expect(result[1]).toEqual({
'qualifiers': 'A',
value: 14.5,
dateTime: 1490882400000
});
......@@ -123,11 +125,13 @@ describe('monitoring-location/components/hydrograph/selectors/discrete-data', ()
expect(result).toHaveLength(2);
expect(result[0]).toEqual({
approvals: 'Provisional',
parameterName: 'Depth to water level',
result: '13',
dateTime: '2017-03-26T09:00-05:00'
});
expect(result[1]).toEqual({
'approvals': 'Approved',
parameterName: 'Depth to water level',
result: '14.5',
dateTime: '2017-03-30T09:00-05:00'
......
......@@ -290,3 +290,20 @@ export const getNearestTime = function(data, time) {
// Return the nearest data point and its index.
return datum;
};
/*
* When given an approval code, will return the text equivalent
* @param {String} approvalCode - Usually a letter such as 'A'
* @return {String} - an easy to understand text version of an approval code
*/
export const approvalCodeText = function(approvalCode) {
const approvalText = {
P: 'Provisional',
A: 'Approved',
R: 'Revised',
E: 'Estimated',
default: `unknown code: ${approvalCode}`
};
return approvalText[approvalCode] || approvalText.default;
};
import {select} from 'd3-selection';
import {
unicodeHtmlEntity, getHtmlFromString, replaceHtmlEntities, setEquality,
wrap, mediaQuery, calcStartTime, callIf, parseRDB, convertFahrenheitToCelsius,
calcStartTime, callIf, parseRDB, convertFahrenheitToCelsius,
convertCelsiusToFahrenheit, sortedParameters, getNearestTime} from './utils';
describe('Utils module', () => {
describe('unicodeHtmlEntity', () => {
it('Can determine the unicode of a decimal entity', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment