Mercurial > gemma
annotate client/src/components/Bottlenecks.vue @ 2037:11cb57f85c60 unify_imports
Merged default into branch.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 25 Jan 2019 11:53:28 +0100 |
parents | f2d24dceecc7 |
children | 3138d60dd1a6 |
rev | line source |
---|---|
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 <template> |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
2 <div> |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
3 <h6 class="mb-0 py-2 px-3 border-bottom d-flex align-items-center"> |
1449 | 4 <font-awesome-icon icon="ship" class="mr-2"></font-awesome-icon> |
5 <translate>Bottlenecks</translate> | |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
6 </h6> |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
7 <div class="row p-2 text-left small"> |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
8 <div class="col-5"> |
1449 | 9 <a href="#" @click="sortBy('name')" class="sort-link"> |
10 <translate>Name</translate> | |
11 </a> | |
1480 | 12 <font-awesome-icon |
13 :icon="sortIcon" | |
14 class="ml-1" | |
15 v-if="sortColumn === 'name'" | |
16 ></font-awesome-icon> | |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
17 </div> |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
18 <div class="col-2"> |
1449 | 19 <a href="#" @click="sortBy('latestMeasurement')" class="sort-link"> |
1480 | 20 <translate>Latest</translate> <br /> |
1449 | 21 <translate>Measurement</translate> |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
22 </a> |
1480 | 23 <font-awesome-icon |
24 :icon="sortIcon" | |
25 class="ml-1" | |
26 v-if="sortColumn === 'latestMeasurement'" | |
27 ></font-awesome-icon> | |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
28 </div> |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
29 <div class="col-3"> |
1449 | 30 <a href="#" @click="sortBy('chainage')" class="sort-link"> |
31 <translate>Chainage</translate> | |
32 </a> | |
1480 | 33 <font-awesome-icon |
34 :icon="sortIcon" | |
35 class="ml-1" | |
36 v-if="sortColumn === 'chainage'" | |
37 ></font-awesome-icon> | |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
38 </div> |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
39 <div class="col-2"></div> |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
40 </div> |
1403
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
41 <div |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
42 class="bottleneck-list small text-left" |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
43 :style="'max-height: ' + (showSplitscreen ? 18 : 35) + 'rem'" |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
44 v-if="filteredAndSortedBottlenecks().length" |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
45 > |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
46 <div |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
47 v-for="bottleneck in filteredAndSortedBottlenecks()" |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
48 :key="bottleneck.properties.name" |
1415
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
49 class="border-top row bottleneck-row mx-0" |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
50 > |
1415
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
51 <div class="col-5 py-2 text-left"> |
1480 | 52 <a href="#" @click="selectBottleneck(bottleneck)">{{ |
53 bottleneck.properties.name | |
54 }}</a> | |
55 </div> | |
56 <div class="col-2 py-2"> | |
1521
276df8dadc14
bought localized datestrings
Thomas Junk <thomas.junk@intevation.de>
parents:
1520
diff
changeset
|
57 {{ formatSurveyDate(bottleneck.properties.current) }} |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
58 </div> |
1480 | 59 <div class="col-3 py-2"> |
60 {{ | |
61 displayCurrentChainage( | |
62 bottleneck.properties.from, | |
1512
aaa56ecdb573
Display chainage correctly in Bottlenecks overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1480
diff
changeset
|
63 bottleneck.properties.to |
1480 | 64 ) |
65 }} | |
66 </div> | |
1560
70421380142d
bottlenecks layout
Thomas Junk <thomas.junk@intevation.de>
parents:
1558
diff
changeset
|
67 <div class="col-2 pr-0 text-right d-flex flex-column"> |
70421380142d
bottlenecks layout
Thomas Junk <thomas.junk@intevation.de>
parents:
1558
diff
changeset
|
68 <a |
70421380142d
bottlenecks layout
Thomas Junk <thomas.junk@intevation.de>
parents:
1558
diff
changeset
|
69 class="text-info mt-auto mb-auto mr-2" |
1417
bd9253eec499
select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1415
diff
changeset
|
70 @click="loadSurveys(bottleneck.properties.name)" |
1415
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
71 v-if="bottleneck.properties.current" |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
72 > |
1449 | 73 <font-awesome-icon |
74 icon="spinner" | |
75 fixed-width | |
76 spin | |
77 v-if="loading === bottleneck.properties.name" | |
78 ></font-awesome-icon> | |
79 <font-awesome-icon | |
80 icon="angle-down" | |
81 fixed-width | |
1480 | 82 v-if=" |
83 loading !== bottleneck.properties.name && | |
84 openBottleneck !== bottleneck.properties.name | |
85 " | |
1449 | 86 ></font-awesome-icon> |
87 <font-awesome-icon | |
88 icon="angle-up" | |
89 fixed-width | |
1480 | 90 v-if=" |
91 loading !== bottleneck.properties.name && | |
92 openBottleneck === bottleneck.properties.name | |
93 " | |
1449 | 94 ></font-awesome-icon> |
1560
70421380142d
bottlenecks layout
Thomas Junk <thomas.junk@intevation.de>
parents:
1558
diff
changeset
|
95 </a> |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
96 </div> |
1449 | 97 <div |
1480 | 98 :class="[ |
99 'col-12 p-0', | |
100 'surveys', | |
101 { open: openBottleneck === bottleneck.properties.name } | |
102 ]" | |
1449 | 103 > |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
104 <a |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
105 href="#" |
1415
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
106 class="d-block px-3 py-2" |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
107 v-for="(survey, index) in openBottleneckSurveys" |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
108 :key="index" |
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
109 @click="selectSurvey(survey, bottleneck)" |
1521
276df8dadc14
bought localized datestrings
Thomas Junk <thomas.junk@intevation.de>
parents:
1520
diff
changeset
|
110 >{{ formatSurveyDate(survey.date_info) }}</a |
1480 | 111 > |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
112 </div> |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
113 </div> |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
114 </div> |
1449 | 115 <div v-else class="small text-center py-3 border-top"> |
116 <translate>No results.</translate> | |
117 </div> | |
1350
58d41573e530
staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1299
diff
changeset
|
118 </div> |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
119 </template> |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
120 |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
121 <script> |
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
122 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
123 * without warranty, see README.md and license for details. |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
124 * |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
125 * SPDX-License-Identifier: AGPL-3.0-or-later |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
126 * License-Filename: LICENSES/AGPL-3.0.txt |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
127 * |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
128 * Copyright (C) 2018 by via donau |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
129 * – Österreichische Wasserstraßen-Gesellschaft mbH |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
130 * Software engineering by Intevation GmbH |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
131 * |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
132 * Author(s): |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
133 * Markus Kottländer <markus.kottlaender@intevation.de> |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
134 */ |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
135 import { mapState } from "vuex"; |
1613
f2d24dceecc7
refac: cleanup import paths
Thomas Junk <thomas.junk@intevation.de>
parents:
1560
diff
changeset
|
136 import { HTTP } from "@/lib/http"; |
f2d24dceecc7
refac: cleanup import paths
Thomas Junk <thomas.junk@intevation.de>
parents:
1560
diff
changeset
|
137 import { displayError } from "@/lib/errors.js"; |
f2d24dceecc7
refac: cleanup import paths
Thomas Junk <thomas.junk@intevation.de>
parents:
1560
diff
changeset
|
138 import { formatSurveyDate } from "@/lib/date.js"; |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
139 |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
140 export default { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
141 name: "bottlenecks", |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
142 data() { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
143 return { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
144 sortColumn: "name", |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
145 sortDirection: "ASC", |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
146 openBottleneck: null, |
1415
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
147 openBottleneckSurveys: null, |
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
148 loading: null |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
149 }; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
150 }, |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
151 computed: { |
1403
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
152 ...mapState("application", [ |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
153 "searchQuery", |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
154 "showSearchbarLastState", |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
155 "showSplitscreen" |
f7139b814a6c
improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents:
1402
diff
changeset
|
156 ]), |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
157 ...mapState("bottlenecks", ["bottlenecks"]), |
1299
2738a6ae9ad8
fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents:
1282
diff
changeset
|
158 sortIcon() { |
2738a6ae9ad8
fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents:
1282
diff
changeset
|
159 return this.sortDirection === "ASC" |
2738a6ae9ad8
fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents:
1282
diff
changeset
|
160 ? "sort-amount-down" |
2738a6ae9ad8
fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents:
1282
diff
changeset
|
161 : "sort-amount-up"; |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
162 } |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
163 }, |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
164 methods: { |
1521
276df8dadc14
bought localized datestrings
Thomas Junk <thomas.junk@intevation.de>
parents:
1520
diff
changeset
|
165 formatSurveyDate(date) { |
276df8dadc14
bought localized datestrings
Thomas Junk <thomas.junk@intevation.de>
parents:
1520
diff
changeset
|
166 return formatSurveyDate(date); |
276df8dadc14
bought localized datestrings
Thomas Junk <thomas.junk@intevation.de>
parents:
1520
diff
changeset
|
167 }, |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
168 filteredAndSortedBottlenecks() { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
169 return this.bottlenecks |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
170 .filter(bn => { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
171 return bn.properties.name |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
172 .toLowerCase() |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
173 .includes(this.searchQuery.toLowerCase()); |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
174 }) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
175 .sort((bnA, bnB) => { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
176 switch (this.sortColumn) { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
177 case "name": |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
178 if ( |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
179 bnA.properties.name.toLowerCase() < |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
180 bnB.properties.name.toLowerCase() |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
181 ) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
182 return this.sortDirection === "ASC" ? -1 : 1; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
183 if ( |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
184 bnA.properties.name.toLowerCase() > |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
185 bnB.properties.name.toLowerCase() |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
186 ) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
187 return this.sortDirection === "ASC" ? 1 : -1; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
188 return 0; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
189 |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
190 case "latestMeasurement": { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
191 if ( |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
192 (bnA.properties.current || "") < (bnB.properties.current || "") |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
193 ) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
194 return this.sortDirection === "ASC" ? -1 : 1; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
195 if ( |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
196 (bnA.properties.current || "") > (bnB.properties.current || "") |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
197 ) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
198 return this.sortDirection === "ASC" ? 1 : -1; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
199 return 0; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
200 } |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
201 |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
202 case "chainage": |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
203 if (bnA.properties.from < bnB.properties.from) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
204 return this.sortDirection === "ASC" ? -1 : 1; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
205 if (bnA.properties.from > bnB.properties.from) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
206 return this.sortDirection === "ASC" ? 1 : -1; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
207 return 0; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
209 default: |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
210 return 0; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
211 } |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
212 }); |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
213 }, |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
214 selectSurvey(survey, bottleneck) { |
1516
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
215 this.$store |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
216 .dispatch( |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
217 "bottlenecks/setSelectedBottleneck", |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
218 bottleneck.properties.name |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
219 ) |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
220 .then(() => { |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
221 this.$store.commit("bottlenecks/selectedSurvey", survey); |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
222 }) |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
223 .then(() => { |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
224 this.$store.commit("map/moveMap", { |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
225 coordinates: bottleneck.geometry.coordinates, |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
226 zoom: 17, |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
227 preventZoomOut: true |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
228 }); |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
229 }); |
1417
bd9253eec499
select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1415
diff
changeset
|
230 }, |
bd9253eec499
select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1415
diff
changeset
|
231 selectBottleneck(bottleneck) { |
1516
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
232 this.$store |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
233 .dispatch( |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
234 "bottlenecks/setSelectedBottleneck", |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
235 bottleneck.properties.name |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
236 ) |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
237 .then(() => { |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
238 this.$store.commit("bottlenecks/setFirstSurveySelected"); |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
239 }) |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
240 .then(() => { |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
241 this.$store.commit("map/moveMap", { |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
242 coordinates: bottleneck.geometry.coordinates, |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
243 zoom: 17, |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
244 preventZoomOut: true |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
245 }); |
6b3756676bbe
refac: bottlenecks and surveydata are now retrieved via promises
Thomas Junk <thomas.junk@intevation.de>
parents:
1512
diff
changeset
|
246 }); |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
247 }, |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
248 sortBy(column) { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
249 this.sortColumn = column; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
250 this.sortDirection = this.sortDirection === "ASC" ? "DESC" : "ASC"; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
251 }, |
1417
bd9253eec499
select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1415
diff
changeset
|
252 loadSurveys(name) { |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
253 this.openBottleneckSurveys = null; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
254 if (name === this.openBottleneck) { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
255 this.openBottleneck = null; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
256 } else { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
257 this.openBottleneck = name; |
1415
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
258 this.loading = name; |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
259 |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
260 HTTP.get("/surveys/" + name, { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
261 headers: { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
262 "X-Gemma-Auth": localStorage.getItem("token"), |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
263 "Content-type": "text/xml; charset=UTF-8" |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
264 } |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
265 }) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
266 .then(response => { |
1449 | 267 this.openBottleneckSurveys = response.data.surveys.sort((a, b) => { |
268 return a.date_info < b.date_info ? 1 : -1; | |
269 }); | |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
270 }) |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
271 .catch(error => { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
272 const { status, data } = error.response; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
273 displayError({ |
1460 | 274 title: this.$gettext("Backend Error"), |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
275 message: `${status}: ${data.message || data}` |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
276 }); |
1415
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
277 }) |
d4fc5f3c1252
improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents:
1403
diff
changeset
|
278 .finally(() => (this.loading = null)); |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
279 } |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
280 }, |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
281 displayCurrentChainage(from, to) { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
282 return from / 10 + " - " + to / 10; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
283 } |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
284 }, |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
285 mounted() { |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
286 this.$store.dispatch("bottlenecks/loadBottlenecks"); |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
287 } |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
288 }; |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
289 </script> |
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
290 |
1449 | 291 <style lang="scss" scoped> |
292 .bottleneck-list { | |
293 overflow-y: auto; | |
294 } | |
295 | |
296 .bottleneck-list .bottleneck-row a { | |
297 text-decoration: none; | |
298 } | |
299 | |
300 .bottleneck-list .bottleneck-row:hover { | |
301 background: #fbfbfb; | |
302 } | |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
303 |
1449 | 304 .surveys { |
305 max-height: 0; | |
306 min-height: 0; | |
307 overflow: hidden; | |
308 } | |
309 | |
310 .surveys a:hover { | |
311 background: #f3f3f3; | |
312 } | |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
313 |
1449 | 314 .surveys.open { |
315 max-height: 250px; | |
316 overflow: auto; | |
317 } | |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
318 |
1449 | 319 .sort-link { |
320 color: #444; | |
321 font-weight: bold; | |
322 } | |
1276
aec9ed491dad
more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
323 </style> |