Mercurial > gemma
annotate client/src/store/gauges.js @ 3515:c64c47ff2ab1 password
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 29 May 2019 09:56:42 +0200 |
parents | c5c7cc24fe72 |
children | 796b923269a6 |
rev | line source |
---|---|
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
2 * without warranty, see README.md and license for details. |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
3 * |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
6 * |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
9 * Software engineering by Intevation GmbH |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
10 * |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 * Author(s): |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 * Markus Kottländer <markus@intevation.de> |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
13 */ |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
14 import { HTTP } from "@/lib/http"; |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2830
diff
changeset
|
15 import { WFS } from "ol/format"; |
2764
f0846d200ce4
client: waterlevel diagram: remove past predictions from waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2761
diff
changeset
|
16 import { isPast } from "date-fns"; |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
17 |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
18 let dateFrom = new Date(); |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
19 dateFrom.setDate(dateFrom.getDate() - 30); |
2775
2feb9f8f6c66
client: waterlevel diagram: implemented display of forecast data
Markus Kottlaender <markus@intevation.de>
parents:
2764
diff
changeset
|
20 let dateTo = new Date(); |
2feb9f8f6c66
client: waterlevel diagram: implemented display of forecast data
Markus Kottlaender <markus@intevation.de>
parents:
2764
diff
changeset
|
21 dateTo.setDate(dateTo.getDate() + 3); |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
22 |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
23 const init = () => { |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
24 return { |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
25 gauges: [], |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
26 selectedGaugeISRS: null, |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
27 waterlevels: [], |
3403
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
28 waterlevelsCSV: "", |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
29 longtermWaterlevels: [], |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
30 longtermInterval: [], |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
31 yearWaterlevels: [], |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
32 nashSutcliffe: null, |
3501
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
33 nashSutcliffeOverview: [], |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
34 dateFrom: dateFrom, |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
35 dateTo: dateTo, |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
36 yearCompare: new Date().getFullYear() |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
37 }; |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
38 }; |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
39 |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
40 export default { |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
41 init, |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
42 namespaced: true, |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
43 state: init(), |
2604
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
44 getters: { |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
45 selectedGauge: state => { |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
46 return state.gauges.find( |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
47 g => g.properties.isrs_code === state.selectedGaugeISRS |
2604
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
48 ); |
3501
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
49 }, |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
50 nashSutcliffeOverview: state => feature => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
51 return state.nashSutcliffeOverview.find( |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
52 d => d.feature.get("id") === feature.get("id") |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
53 ); |
2604
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
54 } |
85f9bf4a6eba
client: gauge waterlevel diagram: draw reference waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2596
diff
changeset
|
55 }, |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
56 mutations: { |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
57 gauges: (state, gauges) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
58 state.gauges = gauges; |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
59 }, |
2643
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
60 selectedGaugeISRS: (state, isrs) => { |
27933e66e848
client: gauges: use isrs_code as unique id for gauges
Markus Kottlaender <markus@intevation.de>
parents:
2604
diff
changeset
|
61 state.selectedGaugeISRS = isrs; |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
62 }, |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
63 waterlevels: (state, data) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
64 state.waterlevels = data; |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
65 }, |
3403
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
66 waterlevelsCSV: (state, data) => { |
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
67 state.waterlevelsCSV = data; |
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
68 }, |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
69 longtermWaterlevels: (state, data) => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
70 state.longtermWaterlevels = data; |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
71 }, |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
72 longtermInterval: (state, interval) => { |
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
73 state.longtermInterval = interval; |
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
74 }, |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
75 yearWaterlevels: (state, data) => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
76 state.yearWaterlevels = data; |
2761
71e7237110ba
client: spuc8: prepared diagram
Markus Kottlaender <markus@intevation.de>
parents:
2751
diff
changeset
|
77 }, |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
78 nashSutcliffe: (state, data) => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
79 state.nashSutcliffe = data; |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
80 }, |
3501
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
81 addNashSutcliffeOverviewEntry: (state, data) => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
82 let existingIndex = state.nashSutcliffeOverview.findIndex( |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
83 d => d.feature.get("id") === data.feature.get("id") |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
84 ); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
85 if (existingIndex !== -1) |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
86 state.nashSutcliffeOverview.splice(existingIndex, 1); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
87 state.nashSutcliffeOverview.push(data); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
88 }, |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
89 dateFrom: (state, dateFrom) => { |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
90 state.dateFrom = dateFrom; |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
91 }, |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
92 dateTo: (state, dateTo) => { |
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
93 state.dateTo = dateTo; |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
94 }, |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
95 yearCompare: (state, year) => { |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
96 state.yearCompare = year; |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
97 } |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
98 }, |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
99 actions: { |
3152
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
100 selectedGaugeISRS: ({ commit, dispatch, state }, isrs) => { |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
101 if (state.selectedGaugeISRS !== isrs) { |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
102 commit("selectedGaugeISRS", isrs); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
103 commit("application/showGauges", true, { root: true }); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
104 dispatch("loadWaterlevels"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
105 dispatch("loadLongtermWaterlevels"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
106 dispatch("loadYearWaterlevels"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
107 dispatch("loadNashSutcliffe"); |
8e31e5b9b37a
client: gauge diagrams: refresh data when switching between gauges
Markus Kottlaender <markus@intevation.de>
parents:
3042
diff
changeset
|
108 } |
2596
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
109 }, |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
110 loadGauges: ({ commit }) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
111 return new Promise((resolve, reject) => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
112 var gaugesFeatureCollectionRequest = new WFS().writeGetFeature({ |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
113 srsName: "EPSG:4326", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
114 featureNS: "gemma", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
115 featurePrefix: "gemma", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
116 featureTypes: ["gauges_geoserver"], |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
117 outputFormat: "application/json" |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
118 }); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
119 HTTP.post( |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
120 "/internal/wfs", |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
121 new XMLSerializer().serializeToString(gaugesFeatureCollectionRequest), |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
122 { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
123 headers: { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
124 "X-Gemma-Auth": localStorage.getItem("token"), |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
125 "Content-type": "text/xml; charset=UTF-8" |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
126 } |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
127 } |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
128 ) |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
129 .then(response => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
130 commit("gauges", response.data.features); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
131 resolve(response); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
132 }) |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
133 .catch(error => { |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
134 reject(error); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
135 }); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
136 }); |
8774054959a7
client: added Gauges dialog/tool to show waterlevel diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2590
diff
changeset
|
137 }, |
2744
7dcca9649a61
client: waterlevel diagram: use selectedGaugeISRS to load waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2716
diff
changeset
|
138 loadWaterlevels({ state, commit }) { |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
139 // include the last day |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
140 let dateTo = new Date(state.dateTo.getTime() + 86400); |
2657
b6865a08c905
client: waterlevel diagram: use real test data
Markus Kottlaender <markus@intevation.de>
parents:
2643
diff
changeset
|
141 |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
142 return new Promise((resolve, reject) => { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
143 HTTP.get( |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
144 `/data/waterlevels/${ |
2744
7dcca9649a61
client: waterlevel diagram: use selectedGaugeISRS to load waterlevels
Markus Kottlaender <markus@intevation.de>
parents:
2716
diff
changeset
|
145 state.selectedGaugeISRS |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
146 }?from=${state.dateFrom |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
147 .toISOString() |
2710
f393fabfdd35
client: waterlevel diagram: chart extent based on selected dates instead of data
Markus Kottlaender <markus@intevation.de>
parents:
2701
diff
changeset
|
148 .substr(0, 23)}&to=${dateTo.toISOString().substr(0, 23)}`, |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
149 { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
150 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
151 } |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
152 ) |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
153 .then(response => { |
3403
d7cc5cda82a9
client: waterlevel diagrams: implemented csv export
Markus Kottlaender <markus@intevation.de>
parents:
3152
diff
changeset
|
154 commit("waterlevelsCSV", response.data); |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
155 let data = response.data |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
156 .split("\n") |
2828
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
157 // remove empty rows and rows starting with # |
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
158 .filter(wl => wl && wl[0] !== "#") |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
159 .map(wl => { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
160 wl = wl.split(","); |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
161 return { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
162 date: new Date(wl[0]), |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
163 waterlevel: Number(wl[1]), |
2793
16d08532c420
client: waterlevel diagram: added prediction's min max values to parsing of waterlevel csv
Markus Kottlaender <markus@intevation.de>
parents:
2791
diff
changeset
|
164 min: Number(wl[2]), |
16d08532c420
client: waterlevel diagram: added prediction's min max values to parsing of waterlevel csv
Markus Kottlaender <markus@intevation.de>
parents:
2791
diff
changeset
|
165 max: Number(wl[3]), |
16d08532c420
client: waterlevel diagram: added prediction's min max values to parsing of waterlevel csv
Markus Kottlaender <markus@intevation.de>
parents:
2791
diff
changeset
|
166 predicted: wl[4] === "f" ? false : true |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
167 }; |
2764
f0846d200ce4
client: waterlevel diagram: remove past predictions from waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2761
diff
changeset
|
168 }) |
f0846d200ce4
client: waterlevel diagram: remove past predictions from waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2761
diff
changeset
|
169 .filter(wl => !(wl.predicted && isPast(wl.date))); |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
170 data = data.sort((a, b) => a.date - b.date); |
2692
966c94e699fa
client: waterlevel diagram: simulate loading time and removed old demo code
Markus Kottlaender <markus@intevation.de>
parents:
2657
diff
changeset
|
171 commit("waterlevels", data); |
966c94e699fa
client: waterlevel diagram: simulate loading time and removed old demo code
Markus Kottlaender <markus@intevation.de>
parents:
2657
diff
changeset
|
172 resolve(data); |
2701
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
173 }) |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
174 .catch(error => { |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
175 commit("waterlevels", []); |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
176 reject(error); |
e622689d73bd
client: waterlevel diagram: use endpoint
Markus Kottlaender <markus@intevation.de>
parents:
2692
diff
changeset
|
177 }); |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
178 }); |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
179 }, |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
180 loadLongtermWaterlevels({ state, commit }) { |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
181 return new Promise((resolve, reject) => { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
182 HTTP.get(`/data/longterm-waterlevels/${state.selectedGaugeISRS}`, { |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
183 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
184 }) |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
185 .then(response => { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
186 const now = new Date(); |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
187 let data = response.data.split("\n"); |
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
188 // get result interval from first line |
3042
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
189 let interval = data[0] |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
190 .split(",")[0] |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
191 .split(" ")[1] |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
192 .split("-") |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
193 .map(y => Number(y)); |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
194 if (interval[0] === interval[1]) interval = [interval[0]]; |
762b140e91a0
client: gauges: if interval is only one year display only that one year
Markus Kottlaender <markus@intevation.de>
parents:
2985
diff
changeset
|
195 commit("longtermInterval", interval); |
2830
0632d543a427
client: spuc7/8: show time periods in diagram titles
Markus Kottlaender <markus@intevation.de>
parents:
2829
diff
changeset
|
196 data = data |
2828
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
197 // remove empty rows and rows starting with # |
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
198 .filter(wl => wl && wl[0] !== "#") |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
199 .map(wl => { |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
200 wl = wl.split(","); |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
201 let dayAndMonth = wl[0].split("-").map(n => Number(n)); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
202 let date = new Date( |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
203 now.getFullYear(), |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
204 dayAndMonth[1] - 1, |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
205 dayAndMonth[0] |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
206 ); |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
207 return { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
208 date: date, |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
209 min: Number(wl[1]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
210 max: Number(wl[2]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
211 mean: Number(wl[3]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
212 median: Number(wl[4]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
213 q25: Number(wl[5]), |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
214 q75: Number(wl[6]) |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
215 }; |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
216 }); |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
217 data = data.sort((a, b) => a.date - b.date); |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
218 commit("longtermWaterlevels", data); |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
219 resolve(data); |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
220 }) |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
221 .catch(error => { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
222 commit("longtermWaterlevels", []); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
223 reject(error); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
224 }); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
225 }); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
226 }, |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
227 loadYearWaterlevels({ state, commit }) { |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
228 return new Promise((resolve, reject) => { |
2829
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
229 HTTP.get( |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
230 `/data/year-waterlevels/${state.selectedGaugeISRS}/${ |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
231 state.yearCompare |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
232 }`, |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
233 { |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
234 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
235 } |
4a1211727d5f
client: spuc8: implemented year controls
Markus Kottlaender <markus@intevation.de>
parents:
2828
diff
changeset
|
236 ) |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
237 .then(response => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
238 const now = new Date(); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
239 let data = response.data |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
240 .split("\n") |
2828
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
241 // remove empty rows and rows starting with # |
c2b90cb426ed
client: waterlevels: better filtering of comment lines in API results
Markus Kottlaender <markus@intevation.de>
parents:
2815
diff
changeset
|
242 .filter(wl => wl && wl[0] !== "#") |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
243 .map(wl => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
244 wl = wl.split(","); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
245 let dayAndMonth = wl[0].split("-").map(n => Number(n)); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
246 let date = new Date( |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
247 now.getFullYear(), |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
248 dayAndMonth[1] - 1, |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
249 dayAndMonth[0] |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
250 ); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
251 return { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
252 date: date, |
2815
12f053763be2
client: spuc8: finished drawing charts, optimized code
Markus Kottlaender <markus@intevation.de>
parents:
2813
diff
changeset
|
253 mean: Number(wl[1]) |
2813
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
254 }; |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
255 }); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
256 data = data.sort((a, b) => a.date - b.date); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
257 commit("yearWaterlevels", data); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
258 resolve(data); |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
259 }) |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
260 .catch(error => { |
49c1570919ae
client: spuc8: use new endpoints to fetch year based and longterm waterlevel data
Markus Kottlaender <markus@intevation.de>
parents:
2793
diff
changeset
|
261 commit("yearWaterlevels", []); |
2791
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
262 reject(error); |
2b79c0871138
client: spuc8: draw diagrams
Markus Kottlaender <markus@intevation.de>
parents:
2775
diff
changeset
|
263 }); |
2761
71e7237110ba
client: spuc8: prepared diagram
Markus Kottlaender <markus@intevation.de>
parents:
2751
diff
changeset
|
264 }); |
71e7237110ba
client: spuc8: prepared diagram
Markus Kottlaender <markus@intevation.de>
parents:
2751
diff
changeset
|
265 }, |
2751
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
266 loadNashSutcliffe({ state, commit }) { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
267 return new Promise((resolve, reject) => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
268 HTTP.get(`/data/nash-sutcliffe/${state.selectedGaugeISRS}`, { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
269 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
270 }) |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
271 .then(response => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
272 commit("nashSutcliffe", response.data); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
273 resolve(response.data); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
274 }) |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
275 .catch(error => { |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
276 commit("nashSutcliffe", null); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
277 reject(error); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
278 }); |
5da81634bdc4
client: waterlevel diagram: implemented nash-sutcliffe
Markus Kottlaender <markus@intevation.de>
parents:
2744
diff
changeset
|
279 }); |
3501
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
280 }, |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
281 loadNashSutcliffeForOverview(context, isrsCode) { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
282 return new Promise((resolve, reject) => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
283 HTTP.get(`/data/nash-sutcliffe/${isrsCode}`, { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
284 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
285 }) |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
286 .then(response => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
287 resolve(response.data); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
288 }) |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
289 .catch(error => { |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
290 reject(error); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
291 }); |
c5c7cc24fe72
client: spuc12: implemented nash sutcliffe for forcast vs reality accuracy indicator
Markus Kottlaender <markus@intevation.de>
parents:
3403
diff
changeset
|
292 }); |
2590
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
293 } |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
294 } |
1686ec185155
client: added gauge waterlevel example diagram
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
295 }; |