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