Mercurial > gemma
annotate client/src/components/Search.vue @ 5521:3cfbc5769e8b
Make invalid output of ISRSrange_area() less likely
Since ST_Transform() might produce an invalid polygon, add an extra
ST_MakeValid().
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 21 Oct 2021 20:20:30 +0200 |
parents | 1cf9b043dca1 |
children | 84d01a536bec |
rev | line source |
---|---|
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 <template> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
2 <div :class="searchbarContainerStyle"> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
3 <div class="input-group-prepend m-0 d-print-none"> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
4 <span @click="toggleSearchbar" :class="searchButtonStyle" for="search"> |
2919
6c5364ff0abb
client: removed a lot of unnecessary closing tags
Markus Kottlaender <markus@intevation.de>
parents:
2871
diff
changeset
|
5 <font-awesome-icon icon="search" /> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
6 </span> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 </div> |
1449 | 8 <div |
1480 | 9 :class="[ |
10 'searchgroup', | |
11 { | |
5450
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
12 searchgroupwidthbottlenecks: |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
13 this.showSearchbar && this.contextBoxContent === 'bottlenecks', |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
14 sgnobottlenecks: |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
15 this.showSearchbar && this.contextBoxContent !== 'bottlenecks', |
1480 | 16 'searchgroup-collapsed': !showSearchbar, |
17 big: | |
18 showContextBox && | |
1797
67340ceecc5f
feat: define sections and stretches etd
Thomas Junk <thomas.junk@intevation.de>
parents:
1670
diff
changeset
|
19 ['bottlenecks', 'staging', 'stretches'].indexOf( |
67340ceecc5f
feat: define sections and stretches etd
Thomas Junk <thomas.junk@intevation.de>
parents:
1670
diff
changeset
|
20 contextBoxContent |
67340ceecc5f
feat: define sections and stretches etd
Thomas Junk <thomas.junk@intevation.de>
parents:
1670
diff
changeset
|
21 ) !== -1 |
1480 | 22 } |
23 ]" | |
1449 | 24 > |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
25 <input |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
26 @keyup.enter="triggerEnter" |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
27 id="search" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
28 v-model="searchQuery" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
29 type="text" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
30 :class="searchInputStyle" |
1480 | 31 /> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
32 </div> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
33 <div |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
34 v-if="showSearchbar && searchResults !== null && !showContextBox" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
35 class="searchresults border-top ui-element bg-white rounded-bottom d-print-none position-absolute" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
36 > |
1480 | 37 <div |
3575
818cc2deff98
search: fix index issue
Thomas Junk <thomas.junk@intevation.de>
parents:
3391
diff
changeset
|
38 v-for="(entry, index) of searchResults" |
818cc2deff98
search: fix index issue
Thomas Junk <thomas.junk@intevation.de>
parents:
3391
diff
changeset
|
39 :key="index" |
1480 | 40 class="border-top text-left" |
41 > | |
42 <a | |
43 href="#" | |
44 @click.prevent="moveToSearchResult(entry)" | |
45 class="p-2 d-block text-nowrap" | |
46 > | |
1441
a4554e942954
Client: add a set of marked translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1425
diff
changeset
|
47 <font-awesome-icon |
a4554e942954
Client: add a set of marked translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1425
diff
changeset
|
48 icon="ship" |
a4554e942954
Client: add a set of marked translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1425
diff
changeset
|
49 v-if="entry.type === 'bottleneck'" |
a4554e942954
Client: add a set of marked translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1425
diff
changeset
|
50 class="mr-1" |
a4554e942954
Client: add a set of marked translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1425
diff
changeset
|
51 fixed-width |
a4554e942954
Client: add a set of marked translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1425
diff
changeset
|
52 /> |
1480 | 53 <font-awesome-icon |
54 icon="water" | |
55 v-if="entry.type === 'rhm'" | |
56 class="mr-1" | |
57 fixed-width | |
58 /> | |
59 <font-awesome-icon | |
60 icon="city" | |
61 v-if="entry.type === 'city'" | |
62 class="mr-1" | |
63 fixed-width | |
64 /> | |
2454
219c5b57ef5b
Added icon to gouges in search result.
Sascha Wilde <wilde@intevation.de>
parents:
2440
diff
changeset
|
65 <font-awesome-icon |
2464
bc0f1771497a
Use better suited icon for gauges in search results.
Sascha Wilde <wilde@intevation.de>
parents:
2454
diff
changeset
|
66 icon="ruler-vertical" |
2454
219c5b57ef5b
Added icon to gouges in search result.
Sascha Wilde <wilde@intevation.de>
parents:
2440
diff
changeset
|
67 v-if="entry.type === 'gauge'" |
219c5b57ef5b
Added icon to gouges in search result.
Sascha Wilde <wilde@intevation.de>
parents:
2440
diff
changeset
|
68 class="mr-1" |
219c5b57ef5b
Added icon to gouges in search result.
Sascha Wilde <wilde@intevation.de>
parents:
2440
diff
changeset
|
69 fixed-width |
219c5b57ef5b
Added icon to gouges in search result.
Sascha Wilde <wilde@intevation.de>
parents:
2440
diff
changeset
|
70 /> |
3391
11379474a1b1
Added preliminary icon for sections in search.
Sascha Wilde <wilde@intevation.de>
parents:
3074
diff
changeset
|
71 <font-awesome-icon |
3760
aea53775a3a7
client: search: set item from sidebar for sections/stretches
Markus Kottlaender <markus@intevation.de>
parents:
3753
diff
changeset
|
72 icon="road" |
aea53775a3a7
client: search: set item from sidebar for sections/stretches
Markus Kottlaender <markus@intevation.de>
parents:
3753
diff
changeset
|
73 v-if="['stretch', 'section'].includes(entry.type)" |
3391
11379474a1b1
Added preliminary icon for sections in search.
Sascha Wilde <wilde@intevation.de>
parents:
3074
diff
changeset
|
74 class="mr-1" |
11379474a1b1
Added preliminary icon for sections in search.
Sascha Wilde <wilde@intevation.de>
parents:
3074
diff
changeset
|
75 fixed-width |
11379474a1b1
Added preliminary icon for sections in search.
Sascha Wilde <wilde@intevation.de>
parents:
3074
diff
changeset
|
76 /> |
3779
33180c25bd87
Added extra information to search results (wwname, ISRS code)
Sascha Wilde <wilde@intevation.de>
parents:
3760
diff
changeset
|
77 {{ entry.name }} |
33180c25bd87
Added extra information to search results (wwname, ISRS code)
Sascha Wilde <wilde@intevation.de>
parents:
3760
diff
changeset
|
78 <span v-if="entry.location || entry.locationcode" |
33180c25bd87
Added extra information to search results (wwname, ISRS code)
Sascha Wilde <wilde@intevation.de>
parents:
3760
diff
changeset
|
79 >({{ entry.location |
33180c25bd87
Added extra information to search results (wwname, ISRS code)
Sascha Wilde <wilde@intevation.de>
parents:
3760
diff
changeset
|
80 }}<span v-if="entry.location && entry.locationcode">, </span |
33180c25bd87
Added extra information to search results (wwname, ISRS code)
Sascha Wilde <wilde@intevation.de>
parents:
3760
diff
changeset
|
81 >{{ entry.locationcode }})</span |
33180c25bd87
Added extra information to search results (wwname, ISRS code)
Sascha Wilde <wilde@intevation.de>
parents:
3760
diff
changeset
|
82 > |
1399
8e2c9e518440
improved search style
Markus Kottlaender <markus@intevation.de>
parents:
1398
diff
changeset
|
83 </a> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
84 </div> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
85 </div> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
86 </div> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
87 </template> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
88 |
1449 | 89 <style lang="scss" scoped> |
90 .searchcontainer { | |
91 opacity: 0.96; | |
5450
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
92 } |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
93 |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
94 .searchcontainerwitdh { |
4981
9f0830a1845d
squashed the total layout to enable display of long fm importnames
Thomas Junk <thomas.junk@intevation.de>
parents:
4869
diff
changeset
|
95 width: 860px; |
5450
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
96 transition: 0.1s; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
97 transition-timing-function: ease; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
98 } |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
99 |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
100 .searchcontainerwitdhbottlenecks { |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
101 width: 650px; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
102 transition: 0.1s; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
103 transition-timing-function: ease; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
104 } |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
105 |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
106 .searchgroupwidth { |
5468 | 107 min-width: 852px; |
5450
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
108 max-width: 860px; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
109 transition: 0.1s; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
110 transition-timing-function: ease; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
111 } |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
112 |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
113 .sgnobottlenecks { |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
114 width: 817px; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
115 transition: 0.1s; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
116 transition-timing-function: ease; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
117 } |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
118 |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
119 .searchgroupwidthbottlenecks { |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
120 width: 617px; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
121 transition: 0.1s; |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
122 transition-timing-function: ease; |
1449 | 123 } |
124 | |
125 .searchcontainer .searchbar { | |
126 border-top-left-radius: 0 !important; | |
127 border-bottom-left-radius: 0 !important; | |
128 } | |
129 | |
130 .searchgroup { | |
131 overflow: hidden; | |
132 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
133 |
1449 | 134 .searchgroup-collapsed { |
135 width: 0; | |
136 } | |
1286
ac6edfb83cf1
improved contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1282
diff
changeset
|
137 |
1449 | 138 .searchbar { |
139 height: 2rem !important; | |
140 box-shadow: none !important; | |
141 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
142 |
1449 | 143 .searchbar.rounded-top-right { |
144 border-radius: 0 !important; | |
145 border-top-right-radius: 0.25rem !important; | |
146 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
147 |
1449 | 148 .searchlabel.rounded-top-left { |
149 border-radius: 0 !important; | |
150 border-top-left-radius: 0.25rem !important; | |
151 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
152 |
1449 | 153 .input-group-text { |
154 height: 2rem; | |
155 width: 2rem; | |
156 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
157 |
1449 | 158 .input-group-prepend svg path { |
159 fill: #666; | |
160 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
161 |
1449 | 162 .searchresults { |
163 box-shadow: 0 0.1rem 0.5rem rgba(0, 0, 0, 0.2); | |
164 top: 2rem; | |
165 left: 0; | |
166 right: 0; | |
167 max-height: 24rem; | |
168 overflow: auto; | |
169 } | |
170 | |
171 .searchresults > div:first-child { | |
172 border-top: 0 !important; | |
173 } | |
174 | |
175 .searchresults a { | |
176 text-decoration: none; | |
177 } | |
178 | |
179 .searchresults a:hover { | |
180 background: #f8f8f8; | |
181 } | |
2283
1169f18a0f11
make room for searchbar
Thomas Junk <thomas.junk@intevation.de>
parents:
2136
diff
changeset
|
182 |
1169f18a0f11
make room for searchbar
Thomas Junk <thomas.junk@intevation.de>
parents:
2136
diff
changeset
|
183 .smallbox { |
1169f18a0f11
make room for searchbar
Thomas Junk <thomas.junk@intevation.de>
parents:
2136
diff
changeset
|
184 width: 2rem; |
1169f18a0f11
make room for searchbar
Thomas Junk <thomas.junk@intevation.de>
parents:
2136
diff
changeset
|
185 } |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
186 </style> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
187 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
188 <script> |
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1361
diff
changeset
|
189 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
190 * without warranty, see README.md and license for details. |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
191 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
192 * SPDX-License-Identifier: AGPL-3.0-or-later |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
193 * License-Filename: LICENSES/AGPL-3.0.txt |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
194 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
195 * Copyright (C) 2018 by via donau |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
196 * – Österreichische Wasserstraßen-Gesellschaft mbH |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
197 * Software engineering by Intevation GmbH |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
198 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
199 * Author(s): |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
200 * Markus Kottländer <markus.kottlaender@intevation.de> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
201 */ |
4463
1cdd246860ae
remove lodash.debounce
Thomas Junk <thomas.junk@intevation.de>
parents:
3779
diff
changeset
|
202 import debounce from "debounce"; |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
203 import { mapState, mapGetters } from "vuex"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
204 |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2919
diff
changeset
|
205 import { displayError } from "@/lib/errors"; |
1613
f2d24dceecc7
refac: cleanup import paths
Thomas Junk <thomas.junk@intevation.de>
parents:
1558
diff
changeset
|
206 import { HTTP } from "@/lib/http"; |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
207 import { format } from "date-fns"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
209 const setFocus = () => document.querySelector("#search").focus(); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
210 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
211 export default { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
212 name: "search", |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
213 data() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
214 return { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
215 searchQueryIsDirty: false, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
216 searchResults: null, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
217 isSearching: false |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
218 }; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
219 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
220 computed: { |
1282
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
221 ...mapState("application", [ |
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
222 "showSearchbar", |
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
223 "showContextBox", |
5132
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
224 "contextBoxContent", |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
225 "showTimeSlider", |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
226 "currentVisibleTime" |
1282
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
227 ]), |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
228 ...mapState("imports", ["startDate", "endDate"]), |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
229 ...mapGetters("imports", ["filters"]), |
3749
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
230 ...mapGetters("map", ["openLayersMap"]), |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
231 searchQuery: { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
232 get() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
233 return this.$store.state.application.searchQuery; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
234 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
235 set(value) { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
236 this.$store.commit("application/searchQuery", value); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
237 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
238 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
239 searchIndicator: function() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
240 if (this.isSearching) { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
241 return "⟳"; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
242 } else if (this.searchQueryIsDirty) { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
243 return ""; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
244 } else { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
245 return "✓"; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
246 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
247 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
248 searchbarContainerStyle() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
249 return [ |
3074
85f7f8981a71
client: search: fixed rounded corners
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
250 "input-group searchcontainer shadow-xs rounded", |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
251 { |
1282
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
252 "d-flex": this.contextBoxContent !== "imports", |
2283
1169f18a0f11
make room for searchbar
Thomas Junk <thomas.junk@intevation.de>
parents:
2136
diff
changeset
|
253 "d-none": this.contextBoxContent === "imports" && this.showContextBox, |
5450
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
254 smallbox: !this.showSearchbar, |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
255 searchcontainerwidth: |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
256 this.showSearchbar && this.contextBoxContent !== "bottlenecks", |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
257 searchgroupwidth: |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
258 this.showSearchbar && this.contextBoxContent !== "bottlenecks", |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
259 searchcontainerwidthbottlenecks: |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
260 this.showSearchbar && this.contextBoxContent === "bottlenecks", |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
261 searchgroupwidthbottleneks: |
62caee603217
Make BN-Overview smaller.
Thomas Junk <thomas.junk@intevation.de>
parents:
5263
diff
changeset
|
262 this.showSearchbar && this.contextBoxContent === "bottlenecks" |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
263 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
264 ]; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
265 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
266 searchInputStyle() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
267 return [ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
268 "form-control ui-element search searchbar d-print-none border-0", |
1282
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
269 { "rounded-top-right": this.showContextBox || this.searchResults } |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
270 ]; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
271 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
272 searchButtonStyle() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
273 return [ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
274 "ui-element input-group-text p-0 d-flex border-0 justify-content-center searchlabel bg-white d-print-none", |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
275 { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
276 rounded: !this.showSearchbar, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
277 "rounded-left": this.showSearchbar, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
278 "rounded-top-left": |
1282
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
279 this.showSearchbar && (this.showContextBox || this.searchResults) |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
280 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
281 ]; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
282 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
283 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
284 watch: { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
285 searchQuery: function() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
286 this.searchQueryIsDirty = true; |
2750
6446bf6d2a89
search: use global search only in global context
Thomas Junk <thomas.junk@intevation.de>
parents:
2464
diff
changeset
|
287 if (!this.showContextBox) this.triggerSearch(); |
5132
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
288 }, |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
289 currentVisibleTime() { |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
290 this.doSearch(); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
291 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
292 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
293 methods: { |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
294 loadLogs() { |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
295 this.$store |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
296 .dispatch("imports/getImports", { |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
297 filter: this.filters, |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
298 from: format(this.startDate, "YYYY-MM-DDTHH:mm:ss.SSS"), |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
299 to: format(this.endDate, "YYYY-MM-DDTHH:mm:ss.SSS"), |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
300 query: this.searchQuery |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
301 }) |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
302 .then(() => {}) |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
303 .catch(error => { |
4869
6b054b91d9b2
backend not reachable as error message etd. Login adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
4868
diff
changeset
|
304 let message = "Backend not reachable"; |
4868
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
305 if (error.response) { |
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
306 const { status, data } = error.response; |
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
307 message = `${status}: ${data.message || data}`; |
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
308 } |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
309 displayError({ |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
310 title: this.$gettext("Backend Error"), |
4868
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
311 message: message |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
312 }); |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
313 }); |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
314 }, |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
315 triggerEnter() { |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
316 if (this.showContextBox && this.contextBoxContent === "importoverview") { |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
317 this.loadLogs(); |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2750
diff
changeset
|
318 } |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
319 if (!this.searchResults || this.searchResults.length != 1) return; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
320 this.moveToSearchResult(this.searchResults[0]); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
321 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
322 triggerSearch: debounce(function() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
323 this.doSearch(); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
324 }, 500), |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
325 doSearch() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
326 this.isCalculating = true; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
327 this.searchResults = null; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
328 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
329 if (this.searchQuery == "") { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
330 return; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
331 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
332 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
333 HTTP.post( |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
334 "/search", |
5132
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
335 this.showTimeSlider |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
336 ? { |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
337 string: this.searchQuery, |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
338 time: this.currentVisibleTime.toISOString() |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
339 } |
8d5e3ce27d20
client: Time based search
Fadi Abbud <fadi.abbud@intevation.de>
parents:
4981
diff
changeset
|
340 : { string: this.searchQuery }, |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
341 { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
342 headers: { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
343 "X-Gemma-Auth": localStorage.getItem("token"), |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
344 "Content-type": "text/xml; charset=UTF-8" |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
345 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
346 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
347 ) |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
348 .then(response => { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
349 this.searchResults = response.data; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
350 }) |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
351 .catch(error => { |
4869
6b054b91d9b2
backend not reachable as error message etd. Login adjusted
Thomas Junk <thomas.junk@intevation.de>
parents:
4868
diff
changeset
|
352 let message = "Backend not reachable"; |
4868
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
353 if (error.response) { |
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
354 const { status, data } = error.response; |
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
355 message = `${status}: ${data.message || data}`; |
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
356 } |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
357 displayError({ |
1441
a4554e942954
Client: add a set of marked translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1425
diff
changeset
|
358 title: this.$gettext("Backend Error"), |
4868
008bc1ae8897
exception handling
Thomas Junk <thomas.junk@intevation.de>
parents:
4774
diff
changeset
|
359 message: message |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
360 }); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
361 }); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
362 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
363 this.isCalculating = false; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
364 this.searchQueryIsDirty = false; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
365 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
366 moveToSearchResult(resultEntry) { |
3749
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
367 let zoom = 16; |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
368 if (resultEntry.type === "bottleneck") { |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
369 this.openLayersMap() |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
370 .getLayer("BOTTLENECKS") |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
371 .setVisible(true); |
5263
19715261750e
client: set bottleneck for pdf-export from search and Map popup
Fadi Abbud <fadi.abbud@intevation.de>
parents:
5132
diff
changeset
|
372 this.$store.commit( |
19715261750e
client: set bottleneck for pdf-export from search and Map popup
Fadi Abbud <fadi.abbud@intevation.de>
parents:
5132
diff
changeset
|
373 "bottlenecks/setBottleneckForPrint", |
19715261750e
client: set bottleneck for pdf-export from search and Map popup
Fadi Abbud <fadi.abbud@intevation.de>
parents:
5132
diff
changeset
|
374 resultEntry.name |
19715261750e
client: set bottleneck for pdf-export from search and Map popup
Fadi Abbud <fadi.abbud@intevation.de>
parents:
5132
diff
changeset
|
375 ); |
3749
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
376 } |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
377 if (resultEntry.type === "rhm") { |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
378 this.openLayersMap() |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
379 .getLayer("DISTANCEMARKSAXIS") |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
380 .setVisible(true); |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
381 } |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
382 if (resultEntry.type === "gauge") { |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
383 this.openLayersMap() |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
384 .getLayer("GAUGES") |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
385 .setVisible(true); |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
386 } |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
387 if (resultEntry.type === "stretch") { |
3753
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
388 this.$store.commit( |
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
389 "imports/selectedStretchId", |
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
390 "stretches_geoserver." + resultEntry.id |
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
391 ); |
3749
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
392 this.openLayersMap() |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
393 .getLayer("STRETCHES") |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
394 .setVisible(true); |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
395 } |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
396 if (resultEntry.type === "section") { |
3753
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
397 this.$store.commit( |
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
398 "imports/selectedSectionId", |
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
399 "sections_geoserver." + resultEntry.id |
78ba9b2574ff
search: include id in search result to mark sections/stretches as selected
Markus Kottlaender <markus@intevation.de>
parents:
3749
diff
changeset
|
400 ); |
3749
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
401 this.openLayersMap() |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
402 .getLayer("SECTIONS") |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
403 .setVisible(true); |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
404 } |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
405 if (resultEntry.type === "city") zoom = 13; |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
406 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
407 if (resultEntry.geom.type == "Point") { |
3044
c71373594719
client: map: prepared store to hold multiple map objects
Markus Kottlaender <markus@intevation.de>
parents:
3012
diff
changeset
|
408 this.$store.dispatch("map/moveMap", { |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
409 coordinates: resultEntry.geom.coordinates, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
410 zoom, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
411 preventZoomOut: true |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
412 }); |
3749
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
413 } else if (resultEntry.geom.type == "Polygon") { |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
414 const boundingBox = [ |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
415 Math.min(...resultEntry.geom.coordinates[0].map(c => c[0])), |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
416 Math.min(...resultEntry.geom.coordinates[0].map(c => c[1])), |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
417 Math.max(...resultEntry.geom.coordinates[0].map(c => c[0])), |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
418 Math.max(...resultEntry.geom.coordinates[0].map(c => c[1])) |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
419 ]; |
f20bd1aee549
client: search: zoom to bounding box if feature has one
Markus Kottlaender <markus@intevation.de>
parents:
3584
diff
changeset
|
420 this.$store.dispatch("map/moveToBoundingBox", { boundingBox, zoom }); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
421 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
422 // this.searchQuery = ""; // clear search query again |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
423 this.toggleSearchbar(); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
424 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
425 toggleSearchbar() { |
1282
a7dd8a3356fc
fixed contextBox animations
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
426 if (!this.showContextBox) { |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
427 if (!this.showSearchbar) { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
428 setTimeout(setFocus, 300); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
429 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
430 this.$store.commit("application/showSearchbar", !this.showSearchbar); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
431 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
432 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
433 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
434 }; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
435 </script> |