annotate client/src/components/identify/formatter.js @ 5679:03dfbe675842 sr-v2

Simplified version handling.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 11 Feb 2024 12:37:09 +0100
parents 3c876c65cc43
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4230
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
1 import Feature from "ol/Feature";
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
2 import app from "@/main";
4691
65a67b3492fd client: formatter: unify date formatting
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4690
diff changeset
3 import filters from "@/lib/filters";
4230
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
4
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
5 const formatter = {
2441
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
6 all(p) {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
7 if (p.key === "objnam") p.key = app.$gettext("Name");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
8 if (p.key === "objname") p.key = app.$gettext("Name");
5309
3c876c65cc43 Client: Display "ZPG exception" attribute in the info window
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4863
diff changeset
9 if (
3c876c65cc43 Client: Display "ZPG exception" attribute in the info window
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4863
diff changeset
10 p.key === "staging_done" ||
3c876c65cc43 Client: Display "ZPG exception" attribute in the info window
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4863
diff changeset
11 p.key === "fa_critical" ||
3c876c65cc43 Client: Display "ZPG exception" attribute in the info window
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4863
diff changeset
12 p.key === "zpg_exception"
3c876c65cc43 Client: Display "ZPG exception" attribute in the info window
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4863
diff changeset
13 )
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
14 p.val = p.val ? app.$gettext("yes") : app.$gettext("no");
3485
ef4803f87631 Add 'translation' and bottleneck attributes for measurement availability
Tom Gottfried <tom@intevation.de>
parents: 3362
diff changeset
15 if (
3635
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
16 (p.key === "date_info" ||
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
17 p.key === "fa_date_info" ||
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
18 p.key === "gm_measuredate") &&
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
19 p.val !== null
3485
ef4803f87631 Add 'translation' and bottleneck attributes for measurement availability
Tom Gottfried <tom@intevation.de>
parents: 3362
diff changeset
20 ) {
4775
391cc6291ea4 identify: use same date formater as in bottleneck selection
Thomas Junk <thomas.junk@intevation.de>
parents: 4691
diff changeset
21 p.val = filters.surveyDate(p.val);
2441
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
22 }
2743
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
23
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
24 // remove certain props
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
25 let propsToRemove = ["bbox"];
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
26 if (propsToRemove.indexOf(p.key) !== -1) return null;
2441
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
27 return p;
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
28 },
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
29 bottlenecks_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
30 label: app.$gettext("Bottleneck"),
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
31 props: p => {
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
32 if (p.key === "bottleneck_id") p.key = "ID";
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
33 if (p.key === "responsible_country")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
34 p.key = app.$gettext("Responsible Country");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
35 if (p.key === "fa_date_info") p.key = app.$gettext("Fairway Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
36 if (p.key === "fa_critical") p.key = app.$gettext("Fairway Critical");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
37 if (p.key === "source_organization")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
38 p.key = app.$gettext("Source Organization");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
39 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
40 p.key = app.$gettext("Gauge Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
41 if (p.key === "gm_waterlevel") p.key = app.$gettext("Gauge Waterlevel");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
42 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
43 p.key = app.$gettext("G.W. Count in Last 14 Days");
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
44 // remove certain props
4224
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
45 // * gauge_obj is another feature object and we want to stay flat
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
46 // for display (if left in causes a
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
47 // TypeError: Converting circular structure to JSON
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
48 // somewhere later)
4230
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
49 if (p.val instanceof Feature) {
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
50 return null;
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
51 }
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
52 let propsToRemove = ["nobjnm", "reference_water_levels", "fa_data"];
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
53 if (propsToRemove.indexOf(p.key) !== -1) return null;
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
54
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
55 return p;
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
56 }
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
57 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
58 fairway_dimensions: {
4286
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
59 label: app.$gettext("Fairway Dimensions"),
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
60 props: p => {
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
61 let propsToRemove = ["id"];
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
62 if (propsToRemove.indexOf(p.key) !== -1) return null;
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
63
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
64 return p;
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
65 }
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
66 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
67 waterway_area: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
68 label: app.$gettext("Waterway Area")
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
69 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
70 distance_marks_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
71 label: app.$gettext("Distance Mark")
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
72 },
3081
9107c959bb3b client: Changed distance marks ashore to WMS layer.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2743
diff changeset
73 distance_marks_ashore_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
74 label: app.$gettext("Distance Mark ashore")
3081
9107c959bb3b client: Changed distance marks ashore to WMS layer.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2743
diff changeset
75 },
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
76 waterway_axis: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
77 label: app.$gettext("Waterway Axis")
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
78 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
79 waterway_profiles: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
80 label: app.$gettext("Waterway Profile")
2439
c3c014435e88 client: identify box: formatted streches
Markus Kottlaender <markus@intevation.de>
parents: 2405
diff changeset
81 },
c3c014435e88 client: identify box: formatted streches
Markus Kottlaender <markus@intevation.de>
parents: 2405
diff changeset
82 stretches_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
83 label: app.$gettext("Stretch"),
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
84 props: p => {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
85 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
86 p.key = app.$gettext("Min. Gauge Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
87 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
88 p.key = app.$gettext("Min. G.W. Count in Last 14 Days");
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
89
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
90 return p;
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
91 }
2458
204b0baac93c client: identified box: added gauges to formatter
Markus Kottlaender <markus@intevation.de>
parents: 2441
diff changeset
92 },
3309
80037790032d client: fully implemented sections
Markus Kottlaender <markus@intevation.de>
parents: 3081
diff changeset
93 sections_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
94 label: app.$gettext("Section"),
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
95 props: p => {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
96 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
97 p.key = app.$gettext("Min. Gauge Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
98 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
99 p.key = app.$gettext("Min. G.W. Count in Last 14 Days");
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
100
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
101 return p;
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
102 }
3309
80037790032d client: fully implemented sections
Markus Kottlaender <markus@intevation.de>
parents: 3081
diff changeset
103 },
2458
204b0baac93c client: identified box: added gauges to formatter
Markus Kottlaender <markus@intevation.de>
parents: 2441
diff changeset
104 gauges_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
105 label: app.$gettext("Gauge"),
3362
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
106 props: p => {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
107 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
108 p.key = app.$gettext("Latest Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
109 if (p.key === "gm_waterlevel") p.key = app.$gettext("Latest Waterlevel");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
110 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
111 p.key = app.$gettext("Measurement Count in Last 14 Days");
3362
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
112
3505
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
113 // remove certain props
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
114 let propsToRemove = ["nsc_data"];
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
115 if (propsToRemove.indexOf(p.key) !== -1) return null;
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
116
3362
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
117 return p;
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
118 }
4688
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
119 },
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
120 sounding_results_areas_geoserver: {
4690
b263d9ae0057 client: mark sounding results strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4688
diff changeset
121 label: app.$gettext("Sounding results"),
4688
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
122 props: p => {
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
123 let propsToRemove = ["height"];
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
124 if (propsToRemove.indexOf(p.key) !== -1) return null;
4690
b263d9ae0057 client: mark sounding results strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4688
diff changeset
125 if (p.key === "surtyp") p.key = app.$gettext("Survey type");
b263d9ae0057 client: mark sounding results strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4688
diff changeset
126 if (p.key === "bottleneck_id") p.key = app.$gettext("Bottleneck");
5309
3c876c65cc43 Client: Display "ZPG exception" attribute in the info window
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4863
diff changeset
127 if (p.key === "zpg_exception") p.key = app.$gettext("ZPG exception");
4688
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
128 return p;
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
129 }
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
130 }
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
131 };
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
132
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
133 export { formatter };