annotate client/src/components/map/contextbox/Bottlenecks.vue @ 1449:bb47531bdd22

sass to scss
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 03 Dec 2018 10:19:59 +0100
parents 547bbe64d188
children 3d5aea677345
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
4 <font-awesome-icon icon="ship" class="mr-2"></font-awesome-icon>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
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
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
9 <a href="#" @click="sortBy('name')" class="sort-link">
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
10 <translate>Name</translate>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
11 </a>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
12 <font-awesome-icon :icon="sortIcon" class="ml-1" v-if="sortColumn === 'name'"></font-awesome-icon>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
13 </div>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
14 <div class="col-2">
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
15 <a href="#" @click="sortBy('latestMeasurement')" class="sort-link">
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
16 <translate>Latest</translate>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
17 <br>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
18 <translate>Measurement</translate>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
19 </a>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
20 <font-awesome-icon :icon="sortIcon" class="ml-1" v-if="sortColumn === 'latestMeasurement'"></font-awesome-icon>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
21 </div>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
22 <div class="col-3">
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
23 <a href="#" @click="sortBy('chainage')" class="sort-link">
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
24 <translate>Chainage</translate>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
25 </a>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
26 <font-awesome-icon :icon="sortIcon" class="ml-1" v-if="sortColumn === 'chainage'"></font-awesome-icon>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
27 </div>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
28 <div class="col-2"></div>
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
29 </div>
1403
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
30 <div
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
31 class="bottleneck-list small text-left"
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
32 :style="'max-height: ' + (showSplitscreen ? 18 : 35) + 'rem'"
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
33 v-if="filteredAndSortedBottlenecks().length"
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
34 >
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
35 <div
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
36 v-for="bottleneck in filteredAndSortedBottlenecks()"
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
37 :key="bottleneck.properties.name"
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
38 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
39 >
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
40 <div class="col-5 py-2 text-left">
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
41 <a href="#" @click="selectBottleneck(bottleneck)">{{ bottleneck.properties.name }}</a>
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
42 </div>
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
43 <div class="col-2 py-2">{{ displayCurrentSurvey(bottleneck.properties.current) }}</div>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
44 <div
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
45 class="col-3 py-2"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
46 >{{ displayCurrentChainage(bottleneck.properties.from, bottleneck.properties.from) }}</div>
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
47 <div class="col-2 pr-0 text-right">
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
48 <button
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
49 type="button"
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
50 class="btn btn-sm btn-info rounded-0 h-100"
1417
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
51 @click="loadSurveys(bottleneck.properties.name)"
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
52 v-if="bottleneck.properties.current"
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
53 >
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
54 <font-awesome-icon
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
55 icon="spinner"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
56 fixed-width
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
57 spin
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
58 v-if="loading === bottleneck.properties.name"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
59 ></font-awesome-icon>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
60 <font-awesome-icon
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
61 icon="angle-down"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
62 fixed-width
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
63 v-if="loading !== bottleneck.properties.name && openBottleneck !== bottleneck.properties.name"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
64 ></font-awesome-icon>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
65 <font-awesome-icon
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
66 icon="angle-up"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
67 fixed-width
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
68 v-if="loading !== bottleneck.properties.name && openBottleneck === bottleneck.properties.name"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
69 ></font-awesome-icon>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
70 </button>
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
71 </div>
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
72 <div
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
73 :class="['col-12 p-0', 'surveys', {open: openBottleneck === bottleneck.properties.name}]"
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
74 >
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
75 <a
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
76 href="#"
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
77 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
78 v-for="(survey, index) in openBottleneckSurveys"
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
79 :key="index"
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
80 @click="selectSurvey(survey, bottleneck)"
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
81 >{{ survey.date_info }}</a>
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
82 </div>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
83 </div>
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
84 </div>
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
85 <div v-else class="small text-center py-3 border-top">
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
86 <translate>No results.</translate>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
87 </div>
1350
58d41573e530 staging: now with real data from backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1299
diff changeset
88 </div>
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
89 </template>
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
90
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
91 <script>
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1299
diff changeset
92 /* 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
93 * without warranty, see README.md and license for details.
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
94 *
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
95 * SPDX-License-Identifier: AGPL-3.0-or-later
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
96 * License-Filename: LICENSES/AGPL-3.0.txt
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
97 *
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
98 * Copyright (C) 2018 by via donau
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
99 * – Österreichische Wasserstraßen-Gesellschaft mbH
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
100 * Software engineering by Intevation GmbH
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
101 *
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
102 * Author(s):
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
103 * Markus Kottländer <markus.kottlaender@intevation.de>
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
104 */
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
105 import { mapState } from "vuex";
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
106 import { HTTP } from "../../../lib/http";
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
107 import { displayError } from "../../../lib/errors.js";
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
108
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
109 export default {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
110 name: "bottlenecks",
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
111 data() {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
112 return {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
113 sortColumn: "name",
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
114 sortDirection: "ASC",
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
115 openBottleneck: null,
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
116 openBottleneckSurveys: null,
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
117 loading: null
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
118 };
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
119 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
120 computed: {
1403
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
121 ...mapState("application", [
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
122 "searchQuery",
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
123 "showSearchbarLastState",
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
124 "showSplitscreen"
f7139b814a6c improved bottleneck box height
Markus Kottlaender <markus@intevation.de>
parents: 1402
diff changeset
125 ]),
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
126 ...mapState("bottlenecks", ["bottlenecks"]),
1299
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
127 sortIcon() {
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
128 return this.sortDirection === "ASC"
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
129 ? "sort-amount-down"
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1282
diff changeset
130 : "sort-amount-up";
1276
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 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
133 methods: {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
134 filteredAndSortedBottlenecks() {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
135 return this.bottlenecks
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
136 .filter(bn => {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
137 return bn.properties.name
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
138 .toLowerCase()
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
139 .includes(this.searchQuery.toLowerCase());
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
140 })
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
141 .sort((bnA, bnB) => {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
142 switch (this.sortColumn) {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
143 case "name":
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
144 if (
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
145 bnA.properties.name.toLowerCase() <
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
146 bnB.properties.name.toLowerCase()
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
147 )
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
148 return this.sortDirection === "ASC" ? -1 : 1;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
149 if (
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
150 bnA.properties.name.toLowerCase() >
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
151 bnB.properties.name.toLowerCase()
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
152 )
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
153 return this.sortDirection === "ASC" ? 1 : -1;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
154 return 0;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
155
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
156 case "latestMeasurement": {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
157 if (
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
158 (bnA.properties.current || "") < (bnB.properties.current || "")
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
159 )
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
160 return this.sortDirection === "ASC" ? -1 : 1;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
161 if (
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
162 (bnA.properties.current || "") > (bnB.properties.current || "")
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 return this.sortDirection === "ASC" ? 1 : -1;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
165 return 0;
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 case "chainage":
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
169 if (bnA.properties.from < bnB.properties.from)
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
170 return this.sortDirection === "ASC" ? -1 : 1;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
171 if (bnA.properties.from > bnB.properties.from)
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
172 return this.sortDirection === "ASC" ? 1 : -1;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
173 return 0;
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 default:
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
176 return 0;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
177 }
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 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
180 selectSurvey(survey, bottleneck) {
1417
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
181 this.selectBottleneck(bottleneck);
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
182 this.$store.commit("bottlenecks/selectedSurvey", survey);
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
183 },
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
184 selectBottleneck(bottleneck) {
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
185 this.$store.dispatch(
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
186 "bottlenecks/setSelectedBottleneck",
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
187 bottleneck.properties.name
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
188 );
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
189 this.$store.commit("map/moveMap", {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
190 coordinates: bottleneck.geometry.coordinates,
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
191 zoom: 17,
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
192 preventZoomOut: true
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 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
195 sortBy(column) {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
196 this.sortColumn = column;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
197 this.sortDirection = this.sortDirection === "ASC" ? "DESC" : "ASC";
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
198 },
1417
bd9253eec499 select bottleneck when clicked in bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1415
diff changeset
199 loadSurveys(name) {
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
200 this.openBottleneckSurveys = null;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
201 if (name === this.openBottleneck) {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
202 this.openBottleneck = null;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
203 } else {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
204 this.openBottleneck = name;
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
205 this.loading = name;
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
206
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
207 HTTP.get("/surveys/" + name, {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
208 headers: {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
209 "X-Gemma-Auth": localStorage.getItem("token"),
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
210 "Content-type": "text/xml; charset=UTF-8"
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 .then(response => {
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
214 this.openBottleneckSurveys = response.data.surveys.sort((a, b) => {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
215 return a.date_info < b.date_info ? 1 : -1;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
216 });
1276
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 .catch(error => {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
219 const { status, data } = error.response;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
220 displayError({
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
221 title: "Backend Error",
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
222 message: `${status}: ${data.message || data}`
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
223 });
1415
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
224 })
d4fc5f3c1252 improved style of bottleneck list
Markus Kottlaender <markus@intevation.de>
parents: 1403
diff changeset
225 .finally(() => (this.loading = null));
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
226 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
227 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
228 displayCurrentSurvey(current) {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
229 return current ? current.substr(0, current.length - 1) : "";
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
230 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
231 displayCurrentChainage(from, to) {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
232 return from / 10 + " - " + to / 10;
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
233 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
234 },
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
235 mounted() {
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
236 this.$store.dispatch("bottlenecks/loadBottlenecks");
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
237 }
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
238 };
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
239 </script>
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
240
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
241 <style lang="scss" scoped>
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
242 .bottleneck-list {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
243 overflow-y: auto;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
244 }
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
245
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
246 .bottleneck-list .bottleneck-row a {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
247 text-decoration: none;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
248 }
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
249
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
250 .bottleneck-list .bottleneck-row:hover {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
251 background: #fbfbfb;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
252 }
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
253
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
254 .surveys {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
255 max-height: 0;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
256 min-height: 0;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
257 overflow: hidden;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
258 }
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
259
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
260 .surveys a:hover {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
261 background: #f3f3f3;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
262 }
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
263
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
264 .surveys.open {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
265 max-height: 250px;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
266 overflow: auto;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
267 }
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
268
1449
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
269 .sort-link {
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
270 color: #444;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
271 font-weight: bold;
bb47531bdd22 sass to scss
Thomas Junk <thomas.junk@intevation.de>
parents: 1418
diff changeset
272 }
1276
aec9ed491dad more cleanup in client/src
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
273 </style>