File tree Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change 55
55
startDate = urlParams .has (' start_day' ) ? new Date (urlParams .get (' start_day' )) : param .sparkLineTimeFrame .min ;
56
56
endDate = urlParams .has (' end_day' ) ? new Date (urlParams .get (' end_day' )) : param .sparkLineTimeFrame .max ;
57
57
58
- // Also normalize the dates to the current timezone
58
+ // Normalize the datest to the current timezone by *subtracting* the timezone
59
+ // offset (to account for negative timezones), multiplied by 60000 (minutes -> ms)
59
60
startDate = new Date (startDate .getTime () - startDate .getTimezoneOffset () * - 60000 );
60
61
endDate = new Date (endDate .getTime () - endDate .getTimezoneOffset () * - 60000 );
61
62
}
88
89
89
90
// Populate region based on URL params... but let the user override this later
90
91
if (urlParams .has (' geo_value' ) && ! geoURLSet) {
91
- let infos = infosByLevel[geoType].filter ((d ) => d .propertyId == urlParams .get (' geo_value' ));
92
+ let infos = infosByLevel[geoType].filter ((d ) => d .propertyId == urlParams .get (' geo_value' ). toUpperCase () );
92
93
addRegion (infos[0 ]);
93
94
geoURLSet = true ;
94
95
}
Original file line number Diff line number Diff line change 96
96
<HistoryLineChart {sensor } {date } {region } {fetcher } />
97
97
</div >
98
98
</div >
99
- <IndicatorAbout {sensor } />
99
+ <IndicatorAbout {sensor } { region } { date } />
100
100
<div class =" grid-3-11" >
101
101
<hr />
102
102
<GeoTable {sensor } {region } {date } {fetcher } />
Original file line number Diff line number Diff line change 1
1
<script >
2
2
import { modeByID } from ' ..' ;
3
+ import { formatDateISO } from ' ../../formats' ;
3
4
import { currentMode } from ' ../../stores' ;
4
5
import AboutSection from ' ../../components/AboutSection.svelte' ;
5
6
6
7
/**
7
- * @type {import('../../stores/params').SensorParam}
8
+ * @type {import("../stores/params").DateParam}
9
+ */
10
+ export let date;
11
+ /**
12
+ * @type {import("../stores/params").RegionParam}
13
+ */
14
+ export let region;
15
+ /**
16
+ * @type {import("../stores/params").SensorParam}
8
17
*/
9
18
export let sensor;
10
19
13
22
// switch to export mode
14
23
currentMode .set (modeByID .export );
15
24
}
25
+
26
+ function buildExportURL () {
27
+ let exportURL = ' ' ;
28
+ if (sensor .key .split (' -' ).length >= 2 ) {
29
+ // account for dashes in the sensor
30
+ let [first, ... rest] = sensor .key .split (' -' );
31
+ rest = rest .join (' -' );
32
+ exportURL += ` data_source=${ first} &signal=${ rest} ` ;
33
+ }
34
+ if (region) {
35
+ exportURL += ` &geo_type=${ region .level } &geo_value=${ region .propertyId } ` ;
36
+ }
37
+ if (date) {
38
+ console .log (date);
39
+ exportURL += ` &start_day=${ formatDateISO (date .value )} &end_day=${ formatDateISO (date .value )} ` ;
40
+ }
41
+ return exportURL;
42
+ }
16
43
</script >
17
44
18
45
{#if sensor .value .description }
33
60
</li >
34
61
{/each }
35
62
<li >
36
- <a href ={` ../${modeByID .export .id }?sensor=${ sensor . key } ` } on:click |preventDefault ={exportData }
63
+ <a href ={` ../${modeByID .export .id }/?${ buildExportURL () } ` } on:click |preventDefault ={exportData }
37
64
>Export Data</a
38
65
>
39
66
</li >
You can’t perform that action at this time.
0 commit comments