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 5555 startDate = urlParams .has (' start_day' ) ? new Date (urlParams .get (' start_day' )) : param .sparkLineTimeFrame .min ;
5656 endDate = urlParams .has (' end_day' ) ? new Date (urlParams .get (' end_day' )) : param .sparkLineTimeFrame .max ;
5757
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)
5960 startDate = new Date (startDate .getTime () - startDate .getTimezoneOffset () * - 60000 );
6061 endDate = new Date (endDate .getTime () - endDate .getTimezoneOffset () * - 60000 );
6162 }
8889
8990 // Populate region based on URL params... but let the user override this later
9091 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 () );
9293 addRegion (infos[0 ]);
9394 geoURLSet = true ;
9495 }
Original file line number Diff line number Diff line change 9696 <HistoryLineChart {sensor } {date } {region } {fetcher } />
9797 </div >
9898 </div >
99- <IndicatorAbout {sensor } />
99+ <IndicatorAbout {sensor } { region } { date } />
100100 <div class =" grid-3-11" >
101101 <hr />
102102 <GeoTable {sensor } {region } {date } {fetcher } />
Original file line number Diff line number Diff line change 11<script >
22 import { modeByID } from ' ..' ;
3+ import { formatDateISO } from ' ../../formats' ;
34 import { currentMode } from ' ../../stores' ;
45 import AboutSection from ' ../../components/AboutSection.svelte' ;
56
67 /**
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}
817 */
918 export let sensor;
1019
1322 // switch to export mode
1423 currentMode .set (modeByID .export );
1524 }
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+ }
1643 </script >
1744
1845{#if sensor .value .description }
3360 </li >
3461 {/each }
3562 <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 }
3764 >Export Data</a
3865 >
3966 </li >
You can’t perform that action at this time.
0 commit comments