From 17c8d649b0bf09e12eeaf7e155c3e294f1190429 Mon Sep 17 00:00:00 2001
From: Aaron Briggs <abriggs@contractor.usgs.gov>
Date: Thu, 30 Jun 2022 18:35:06 -0500
Subject: [PATCH] url working

---
 .../vue-components/download-data.vue          | 22 ++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue
index e7b9aa6cf..b8eb99763 100644
--- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue
+++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.vue
@@ -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');
-- 
GitLab