comparison client/src/store/fairwayavailability.js @ 4121:9f03eb3817d6 v4-preview20190726-fixes

Use UTC for FWA diagrams. This prevents problems on Month (quarter/year) borders.
author Sascha Wilde <wilde@intevation.de>
date Thu, 01 Aug 2019 14:10:25 +0200
parents 23f88a6c1e88
children 83eb99662a91
comparison
equal deleted inserted replaced
4104:aececbc3d047 4121:9f03eb3817d6
16 16
17 import { HTTP } from "@/lib/http"; 17 import { HTTP } from "@/lib/http";
18 import { 18 import {
19 format, 19 format,
20 subYears, 20 subYears,
21 startOfDay,
22 startOfMonth, 21 startOfMonth,
23 endOfDay,
24 endOfMonth, 22 endOfMonth,
25 startOfYear, 23 startOfYear,
26 endOfYear, 24 endOfYear,
27 startOfQuarter, 25 startOfQuarter,
28 endOfQuarter 26 endOfQuarter
238 if (limitingFactor === LIMITINGFACTORS.WIDTH) 236 if (limitingFactor === LIMITINGFACTORS.WIDTH)
239 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; 237 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`;
240 } else if (type == TYPES.SECTION || type == TYPES.STRETCH) { 238 } else if (type == TYPES.SECTION || type == TYPES.STRETCH) {
241 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; 239 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`;
242 } 240 }
241 const start = encodeURIComponent("00:00:00+00:00");
242 const end = encodeURIComponent("23:59:59+00:00");
243 const URL = `data/${endpoint}/fairway-depth/${encodeURIComponent( 243 const URL = `data/${endpoint}/fairway-depth/${encodeURIComponent(
244 name 244 name
245 )}?from=${encodeURIComponent( 245 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}${additionalParams}`;
246 format(startOfDay(from), "YYYY-MM-DDTHH:mm:ssZ")
247 )}&to=${encodeURIComponent(
248 format(endOfDay(to), "YYYY-MM-DDTHH:mm:ssZ")
249 )}&mode=${frequency}&los=${LOS}${additionalParams}`;
250 HTTP.get(URL, { 246 HTTP.get(URL, {
251 headers: { "X-Gemma-Auth": localStorage.getItem("token") } 247 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
252 }) 248 })
253 .then(response => { 249 .then(response => {
254 const { data } = response; 250 const { data } = response;
280 let { from, to } = options; 276 let { from, to } = options;
281 let name = feature.hasOwnProperty("properties") 277 let name = feature.hasOwnProperty("properties")
282 ? feature.properties.name 278 ? feature.properties.name
283 : feature.get("objnam"); 279 : feature.get("objnam");
284 [from, to] = getIntervallBorders(from, to, frequency); 280 [from, to] = getIntervallBorders(from, to, frequency);
281 const start = encodeURIComponent("00:00:00+00:00");
282 const end = encodeURIComponent("23:59:59+00:00");
285 let additionalParams = ""; 283 let additionalParams = "";
286 let endpoint = type || TYPES.BOTTLENECK; 284 let endpoint = type || TYPES.BOTTLENECK;
287 if (type === TYPES.BOTTLENECK) { 285 if (type === TYPES.BOTTLENECK) {
288 if (limitingFactor === LIMITINGFACTORS.DEPTH) 286 if (limitingFactor === LIMITINGFACTORS.DEPTH)
289 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; 287 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`;
292 } else if (type == TYPES.SECTION || type == TYPES.STRETCH) { 290 } else if (type == TYPES.SECTION || type == TYPES.STRETCH) {
293 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; 291 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`;
294 } 292 }
295 const URL = `data/${endpoint}/availability/${encodeURIComponent( 293 const URL = `data/${endpoint}/availability/${encodeURIComponent(
296 name 294 name
297 )}?from=${encodeURIComponent( 295 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}${additionalParams}`;
298 format(startOfDay(from), "YYYY-MM-DDTHH:mm:ssZ")
299 )}&to=${encodeURIComponent(
300 format(endOfDay(to), "YYYY-MM-DDTHH:mm:ssZ")
301 )}&mode=${frequency}&los=${LOS}${additionalParams}`;
302 HTTP.get(URL, { 296 HTTP.get(URL, {
303 headers: { "X-Gemma-Auth": localStorage.getItem("token") } 297 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
304 }) 298 })
305 .then(response => { 299 .then(response => {
306 const { data } = response; 300 const { data } = response;