Mercurial > gemma
annotate client/src/components/layers/Layerselect.vue @ 2412:0ed53a7a1221
login fixed
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 28 Feb 2019 12:29:12 +0100 |
parents | 33d2ef9f9e5d |
children | a7e31594959d |
rev | line source |
---|---|
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 <template> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
2 <div> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
3 <div class="form-check d-flex flex-row flex-start selection"> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
4 <input |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
5 class="form-check-input" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
6 @change="visibilityToggled" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
7 :id="layername" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
8 type="checkbox" |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
9 :checked="isVisible" |
1480 | 10 /> |
11 <LegendElement | |
12 :layername="layername" | |
13 :layerindex="layerindex" | |
14 ></LegendElement> | |
2154
a08e0f532304
staging: improve UI
Thomas Junk <thomas.junk@intevation.de>
parents:
1927
diff
changeset
|
15 <label |
a08e0f532304
staging: improve UI
Thomas Junk <thomas.junk@intevation.de>
parents:
1927
diff
changeset
|
16 class="pointer layername form-check-label" |
a08e0f532304
staging: improve UI
Thomas Junk <thomas.junk@intevation.de>
parents:
1927
diff
changeset
|
17 @click="visibilityToggled" |
a08e0f532304
staging: improve UI
Thomas Junk <thomas.junk@intevation.de>
parents:
1927
diff
changeset
|
18 >{{ layername }}</label |
a08e0f532304
staging: improve UI
Thomas Junk <thomas.junk@intevation.de>
parents:
1927
diff
changeset
|
19 > |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
20 </div> |
2343
33d2ef9f9e5d
client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2154
diff
changeset
|
21 <div v-if="isVisible && isBottleneckIsolineLayer"> |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1926
diff
changeset
|
22 <img class="rounded my-1 d-block" :src="isolinesLegendImgDataURL" /> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
23 </div> |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
24 </div> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 </template> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
26 |
1449 | 27 <style lang="scss" scoped> |
28 .selection { | |
29 text-align: left; | |
30 } | |
31 .layername { | |
32 margin-left: $small-offset; | |
33 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
34 </style> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
35 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
36 <script> |
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1361
diff
changeset
|
37 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
38 * without warranty, see README.md and license for details. |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
39 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
40 * SPDX-License-Identifier: AGPL-3.0-or-later |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
41 * License-Filename: LICENSES/AGPL-3.0.txt |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
42 * |
1926
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
43 * Copyright (C) 2018, 2019 by via donau |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
44 * – Österreichische Wasserstraßen-Gesellschaft mbH |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
45 * Software engineering by Intevation GmbH |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1277
diff
changeset
|
46 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
47 * Author(s): |
1926
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
48 * * Thomas Junk <thomas.junk@intevation.de> |
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
49 * * Bernhard Reiter <bernhard.reiter@intevation.de> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
50 */ |
1613
f2d24dceecc7
refac: cleanup import paths
Thomas Junk <thomas.junk@intevation.de>
parents:
1558
diff
changeset
|
51 import { HTTP } from "@/lib/http"; |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1926
diff
changeset
|
52 import { mapState } from "vuex"; |
2343
33d2ef9f9e5d
client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2154
diff
changeset
|
53 import { LAYERS } from "@/store/map.js"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
54 export default { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
55 props: ["layername", "layerindex", "isVisible"], |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
56 name: "layerselect", |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
57 components: { |
1669
16fb9667ddf8
refac: use dynamic imports for components
Thomas Junk <thomas.junk@intevation.de>
parents:
1613
diff
changeset
|
58 LegendElement: () => import("./LegendElement.vue") |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
59 }, |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1926
diff
changeset
|
60 computed: { |
2343
33d2ef9f9e5d
client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2154
diff
changeset
|
61 ...mapState("map", ["isolinesLegendImgDataURL"]), |
33d2ef9f9e5d
client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2154
diff
changeset
|
62 isBottleneckIsolineLayer() { |
33d2ef9f9e5d
client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2154
diff
changeset
|
63 return this.layername == LAYERS.BOTTLENECKISOLINE; |
33d2ef9f9e5d
client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2154
diff
changeset
|
64 } |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1926
diff
changeset
|
65 }, |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
66 methods: { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
67 visibilityToggled() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
68 this.$emit("visibilityToggled", this.layerindex); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
69 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
70 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
71 created() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
72 // fetch legend image for bottleneck isolines |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1926
diff
changeset
|
73 // directly read it as dataURL so it is reusable later |
2343
33d2ef9f9e5d
client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2154
diff
changeset
|
74 if (this.isBottleneckIsolineLayer) { |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
75 const src = |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
76 "/internal/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=sounding_results_contour_lines_geoserver&legend_options=columns:4;fontAntiAliasing:true"; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
77 HTTP.get(src, { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
78 headers: { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
79 Accept: "image/png", |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
80 "X-Gemma-Auth": localStorage.getItem("token") |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
81 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
82 responseType: "blob" |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
83 }).then(response => { |
1926
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
84 var that = this; |
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
85 const reader = new FileReader(); |
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
86 reader.onload = function() { |
1927
5a37ee321651
client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents:
1926
diff
changeset
|
87 that.$store.commit("map/isolinesLegendImgDataURL", this.result); |
1926
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
88 }; |
1220cfe96efd
client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents:
1669
diff
changeset
|
89 reader.readAsDataURL(response.data); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
90 }); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
91 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
92 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
93 }; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
94 </script> |