Skip to content

Commit cd448c3

Browse files
committed
Fix review comments
1 parent 0d5d149 commit cd448c3

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

src/modes/exportdata/ExportData.svelte

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
const urlParams = new URLSearchParams(window.location.search);
3333
3434
// Overwrite default source & sensor if these are present in the URL
35-
if (urlParams.has('source')) {
36-
sourceValue = urlParams.get('source');
35+
if (urlParams.has('data_source')) {
36+
sourceValue = urlParams.get('data_source');
3737
38-
if (urlParams.has('sensor')) {
39-
sensorValue = urlParams.get('sensor');
38+
if (urlParams.has('signal')) {
39+
sensorValue = urlParams.get('signal');
4040
}
4141
}
4242
@@ -52,8 +52,14 @@
5252
const param = new DateParam(date);
5353
5454
// Populate date based on URL params or, if absent, the current date
55-
startDate = urlParams.has('start') ? new Date(urlParams.get('start')) : param.sparkLineTimeFrame.min;
56-
endDate = urlParams.has('end') ? new Date(urlParams.get('end')) : param.sparkLineTimeFrame.max;
55+
if (sensor && !sensor.active) {
56+
// If the sensor is inactive, set the start and end dates to its historical range rather than current date
57+
startDate = urlParams.has('start_day') ? new Date(urlParams.get('start_day')) : sensor.meta.minTime;
58+
endDate = urlParams.has('end_day') ? new Date(urlParams.get('end_day')) : sensor.meta.maxTime;
59+
} else {
60+
startDate = urlParams.has('start_day') ? new Date(urlParams.get('start_day')) : param.sparkLineTimeFrame.min;
61+
endDate = urlParams.has('end_day') ? new Date(urlParams.get('end_day')) : param.sparkLineTimeFrame.max;
62+
}
5763
}
5864
$: initDate($currentDateObject);
5965
@@ -83,8 +89,8 @@
8389
}
8490
8591
// Populate region based on URL params... but let the user override this later
86-
if (urlParams.has('geo_id') && !geoURLSet) {
87-
let infos = infosByLevel[geoType].filter((d) => d.propertyId == urlParams.get('geo_id'));
92+
if (urlParams.has('geo_value') && !geoURLSet) {
93+
let infos = infosByLevel[geoType].filter((d) => d.propertyId == urlParams.get('geo_value'));
8894
addRegion(infos[0]);
8995
geoURLSet = true;
9096
}
@@ -113,6 +119,11 @@
113119
}
114120
}
115121
$: usesAsOf = asOfMode !== 'latest' && asOfDate instanceof Date;
122+
// set as_of based on URL params, if it's a valid date
123+
if (urlParams.has('as_of') && !isNaN(new Date(urlParams.get('as_of')))) {
124+
asOfMode = 'single';
125+
asOfDate = new Date(urlParams.get('as_of'));
126+
}
116127
117128
let form = null;
118129
@@ -127,6 +138,14 @@
127138
);
128139
});
129140
}
141+
// Fix up the UI if we got an inactive sensor from the URL parameters.
142+
if (sensor && !sensor.active) {
143+
showInActive = true;
144+
// Force an update to sourceValue to set related reactive statements correctly.
145+
let temp = sourceValue;
146+
sourceValue = '';
147+
sourceValue = temp;
148+
}
130149
});
131150
132151
function addRegion(detail) {

0 commit comments

Comments
 (0)