|
32 | 32 | const urlParams = new URLSearchParams(window.location.search);
|
33 | 33 |
|
34 | 34 | // 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'); |
37 | 37 |
|
38 |
| - if (urlParams.has('sensor')) { |
39 |
| - sensorValue = urlParams.get('sensor'); |
| 38 | + if (urlParams.has('signal')) { |
| 39 | + sensorValue = urlParams.get('signal'); |
40 | 40 | }
|
41 | 41 | }
|
42 | 42 |
|
|
52 | 52 | const param = new DateParam(date);
|
53 | 53 |
|
54 | 54 | // 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 | + } |
57 | 63 | }
|
58 | 64 | $: initDate($currentDateObject);
|
59 | 65 |
|
|
83 | 89 | }
|
84 | 90 |
|
85 | 91 | // 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')); |
88 | 94 | addRegion(infos[0]);
|
89 | 95 | geoURLSet = true;
|
90 | 96 | }
|
|
113 | 119 | }
|
114 | 120 | }
|
115 | 121 | $: 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 | + } |
116 | 127 |
|
117 | 128 | let form = null;
|
118 | 129 |
|
|
127 | 138 | );
|
128 | 139 | });
|
129 | 140 | }
|
| 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 | + } |
130 | 149 | });
|
131 | 150 |
|
132 | 151 | function addRegion(detail) {
|
|
0 commit comments