Skip to content
Snippets Groups Projects
Commit 17c8d649 authored by Briggs, Aaron Shane's avatar Briggs, Aaron Shane
Browse files

url working

parent efd277d8
No related branches found
No related tags found
1 merge request!372WDFN-734 Plot Secondary Time Series - add data retrieve option
......@@ -181,6 +181,7 @@ import {getIVServiceURL, getSiteMetaDataServiceURL} from 'ui/web-services/instan
import {getStatisticsServiceURL} from 'ui/web-services/statistics-data';
import {getGroundwaterServiceURL} from 'ui/web-services/groundwater-levels';
import {getPrimaryParameter} from 'ml/components/hydrograph/selectors/time-series-data';
import {getIVParameter} from 'ml/selectors/hydrograph-data-selector';
import {isCalculatedTemperature} from 'ml/parameter-code-utils';
import {
......@@ -189,6 +190,7 @@ import {
hasVisibleMedianStatisticsData
} from '../selectors/time-series-data';
export default {
name: 'DownloadData',
components: {
......@@ -208,7 +210,8 @@ export default {
hasVisibleCompareIVData: hasVisibleIVData('compare'),
hasVisibleMedianData: hasVisibleMedianStatisticsData,
hasVisibleGroundwaterLevels: hasVisibleGroundwaterLevels,
primaryParameter: getPrimaryParameter
primaryParameter: getPrimaryParameter,
secondaryParameter: getIVParameter('secondary')
});
const reduxStore = inject('store');
......@@ -226,13 +229,19 @@ export default {
return DateTime.fromMillis(inMillis, {zone: config.locationTimeZone}).toISO();
};
const getIVDataURL = function(reduxStore, siteno, timeRangeKind) {
const getIVDataURL = function(reduxStore, siteno, dataKind) {
const timeRangePrefix = {
primary: 'current',
secondary: 'current',
prioryear: 'compare'
};
const currentState = reduxStore.getState();
const timeRange = getTimeRange(timeRangeKind)(currentState);
const timeRange = getTimeRange(timeRangePrefix[dataKind])(currentState);
return getIVServiceURL({
siteno,
parameterCode: getPrimaryParameter(currentState).parameterCode,
parameterCode: dataKind === 'secondary' ? state.secondaryParameter.value.parameterCode : state.primaryParameter.value.parameterCode,
startTime: toISO(timeRange.start),
endTime: toISO(timeRange.end),
format: 'rdb'
......@@ -267,7 +276,10 @@ export default {
showErrorMessage.value = false;
switch (buttonSelected) {
case 'primary':
downloadUrl.value = getIVDataURL(reduxStore, siteno, 'current');
downloadUrl.value = getIVDataURL(reduxStore, siteno, 'primary');
break;
case 'secondary':
downloadUrl.value = getIVDataURL(reduxStore, siteno, 'secondary');
break;
case 'compare':
downloadUrl.value = getIVDataURL(reduxStore, siteno, 'prioryear');
......
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