Mercurial > gemma
annotate client/src/components/identify/formatter.js @ 4436:a66275cf4490
identify: gm availability infotext improved. More 2 come
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 19 Sep 2019 12:50:49 +0200 |
parents | 1604284d2597 |
children | ad271887fd8d |
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"; |
4230
f3b733fd119a
Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents:
4224
diff
changeset
|
3 |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 const formatter = { |
2441
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2439
diff
changeset
|
5 all(p) { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
6 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
|
7 if (p.key === "objname") p.key = app.$gettext("Name"); |
2509
3dc7c0f60a62
client: identify box: formatted fa_date_info and fa_critical
Markus Kottlaender <markus@intevation.de>
parents:
2458
diff
changeset
|
8 if (p.key === "staging_done" || p.key === "fa_critical") |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
9 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
|
10 if ( |
3635
6d6577a87963
Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents:
3505
diff
changeset
|
11 (p.key === "date_info" || |
6d6577a87963
Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents:
3505
diff
changeset
|
12 p.key === "fa_date_info" || |
6d6577a87963
Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents:
3505
diff
changeset
|
13 p.key === "gm_measuredate") && |
6d6577a87963
Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents:
3505
diff
changeset
|
14 p.val !== null |
3485
ef4803f87631
Add 'translation' and bottleneck attributes for measurement availability
Tom Gottfried <tom@intevation.de>
parents:
3362
diff
changeset
|
15 ) { |
2441
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2439
diff
changeset
|
16 p.val = new Date(p.val).toLocaleString(); |
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2439
diff
changeset
|
17 } |
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
|
18 |
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
|
19 // 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
|
20 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
|
21 if (propsToRemove.indexOf(p.key) !== -1) return null; |
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
|
22 |
2441
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2439
diff
changeset
|
23 return p; |
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2439
diff
changeset
|
24 }, |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 bottlenecks_geoserver: { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
26 label: app.$gettext("Bottleneck"), |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
27 props: p => { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
28 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
|
29 if (p.key === "responsible_country") |
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 if (p.key === "gauge_objname") p.key = app.$gettext("Reference Gauge"); |
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
34 if (p.key === "source_organization") |
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
35 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
|
36 if (p.key === "gm_measuredate") |
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 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
|
41 // remove certain props |
4224
bb66e144dece
client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents:
3636
diff
changeset
|
42 // * 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
|
43 // for display (if left in causes a |
bb66e144dece
client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents:
3636
diff
changeset
|
44 // TypeError: Converting circular structure to JSON |
bb66e144dece
client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents:
3636
diff
changeset
|
45 // somewhere later) |
4230
f3b733fd119a
Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents:
4224
diff
changeset
|
46 if (p.val instanceof Feature) { |
f3b733fd119a
Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents:
4224
diff
changeset
|
47 return null; |
f3b733fd119a
Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents:
4224
diff
changeset
|
48 } |
f3b733fd119a
Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents:
4224
diff
changeset
|
49 let propsToRemove = ["nobjnm", "reference_water_levels", "fa_data"]; |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
50 if (propsToRemove.indexOf(p.key) !== -1) return null; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
51 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
52 return p; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
53 } |
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 fairway_dimensions: { |
4286
1604284d2597
Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents:
4258
diff
changeset
|
56 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
|
57 props: p => { |
1604284d2597
Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents:
4258
diff
changeset
|
58 let propsToRemove = ["id"]; |
1604284d2597
Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents:
4258
diff
changeset
|
59 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
|
60 |
1604284d2597
Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents:
4258
diff
changeset
|
61 return p; |
1604284d2597
Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents:
4258
diff
changeset
|
62 } |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
63 }, |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
64 waterway_area: { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
65 label: app.$gettext("Waterway Area") |
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 distance_marks_geoserver: { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
68 label: app.$gettext("Distance Mark") |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
69 }, |
3081
9107c959bb3b
client: Changed distance marks ashore to WMS layer.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2743
diff
changeset
|
70 distance_marks_ashore_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 ashore") |
3081
9107c959bb3b
client: Changed distance marks ashore to WMS layer.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2743
diff
changeset
|
72 }, |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
73 waterway_axis: { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
74 label: app.$gettext("Waterway Axis") |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
75 }, |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
76 waterway_profiles: { |
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 Profile") |
2439
c3c014435e88
client: identify box: formatted streches
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
78 }, |
c3c014435e88
client: identify box: formatted streches
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
79 stretches_geoserver: { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
80 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
|
81 props: p => { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
82 if (p.key === "gm_measuredate") |
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 |
89a39783c20a
Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents:
3635
diff
changeset
|
87 return p; |
89a39783c20a
Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents:
3635
diff
changeset
|
88 } |
2458
204b0baac93c
client: identified box: added gauges to formatter
Markus Kottlaender <markus@intevation.de>
parents:
2441
diff
changeset
|
89 }, |
3309
80037790032d
client: fully implemented sections
Markus Kottlaender <markus@intevation.de>
parents:
3081
diff
changeset
|
90 sections_geoserver: { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
91 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
|
92 props: p => { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
93 if (p.key === "gm_measuredate") |
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 |
89a39783c20a
Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents:
3635
diff
changeset
|
98 return p; |
89a39783c20a
Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents:
3635
diff
changeset
|
99 } |
3309
80037790032d
client: fully implemented sections
Markus Kottlaender <markus@intevation.de>
parents:
3081
diff
changeset
|
100 }, |
2458
204b0baac93c
client: identified box: added gauges to formatter
Markus Kottlaender <markus@intevation.de>
parents:
2441
diff
changeset
|
101 gauges_geoserver: { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
102 label: app.$gettext("Gauge"), |
3362
bda4034304b1
client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents:
3359
diff
changeset
|
103 props: p => { |
4258
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
104 if (p.key === "gm_measuredate") |
57c38087fe18
client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4230
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 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
|
109 |
3505
d136ceed5d41
client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents:
3485
diff
changeset
|
110 // remove certain props |
d136ceed5d41
client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents:
3485
diff
changeset
|
111 let propsToRemove = ["nsc_data"]; |
d136ceed5d41
client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents:
3485
diff
changeset
|
112 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
|
113 |
3362
bda4034304b1
client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents:
3359
diff
changeset
|
114 return p; |
bda4034304b1
client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents:
3359
diff
changeset
|
115 } |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
116 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
117 }; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
118 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
119 export { formatter }; |