Mercurial > gemma
changeset 549:b3f825c8445b
Merged
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Fri, 31 Aug 2018 11:38:42 +0200 |
parents | 7feeb341bb4d (current diff) b91791664554 (diff) |
children | 06907c875077 |
files | |
diffstat | 5 files changed, 93 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Maplayer.vue Thu Aug 30 14:59:13 2018 +0200 +++ b/client/src/components/Maplayer.vue Fri Aug 31 11:38:42 2018 +0200 @@ -39,9 +39,15 @@ </style> <script> +import { HTTP } from "../lib/http"; import "ol/ol.css"; import { Map, View } from "ol"; -import TileLayer from "ol/layer/Tile"; +// needed for vector filter example +// import { greaterThan as greaterThanFilter } from "ol/format/filter.js"; +import { WFS, GeoJSON } from "ol/format.js"; +import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer.js"; +import VectorSource from "ol/source/Vector.js"; +import { Stroke, Style } from "ol/style.js"; import OSM from "ol/source/OSM"; import TileWMS from "ol/source/TileWMS.js"; import Layerselect from "./Layerselect"; @@ -73,6 +79,19 @@ }) }), isVisible: true + }, + { + name: "Fairways Dimensions", + data: new VectorLayer({ + source: new VectorSource(), + style: new Style({ + stroke: new Stroke({ + color: "rgba(0, 0, 255, 1.0)", + width: 2 + }) + }) + }), + isVisible: true } ] }; @@ -91,6 +110,7 @@ } }, mounted() { + var that = this; this.openLayersMap = new Map({ layers: this.layerData, target: "map", @@ -100,6 +120,34 @@ projection: this.projection }) }); + + var featureRequest = new WFS().writeGetFeature({ + // srsName: "urn:ogc:def:crs:EPSG::4326", + srsName: "EPSG:3857", + featureNS: "gemma", + featurePrefix: "gemma", + featureTypes: ["fairway_dimensions"], + outputFormat: "application/json" + // example for a filter + //filter: greaterThanFilter("level_of_service", 0) + }); + + HTTP.post( + "/internal/wfs", + new XMLSerializer().serializeToString(featureRequest), + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "text/xml; charset=UTF-8" + } + } + ).then(function(response) { + var features = new GeoJSON().readFeatures(JSON.stringify(response.data)); + var vectorSrc = that.layers[2].data.getSource(); + vectorSrc.addFeatures(features); + // would scale to the extend of all resulting features + // that.openLayersMap.getView().fit(vectorSrc.getExtent()); + }); } }; </script>
--- a/client/src/components/Userdetail.vue Thu Aug 30 14:59:13 2018 +0200 +++ b/client/src/components/Userdetail.vue Fri Aug 31 11:38:42 2018 +0200 @@ -2,8 +2,10 @@ <div class="userdetails shadown fadeIn animated"> <div class="card"> <div class="card-header shadow-sm text-white bg-info mb-3"> - {{ this.cardHeader }} - <span @click="closeDetailview" class="pull-right"><i class="fa fa-close"></i></span> + {{ this.cardHeader }} + <span @click="closeDetailview" class="pull-right"> + <i class="fa fa-close"></i> + </span> </div> <div class="card-body"> <form @submit.prevent="save"> @@ -11,7 +13,10 @@ <div v-if="currentUser.isNew" class="form-group row"> <label for="user">Username</label> <input type="user" :placeholder="userNamePlaceholder" class="form-control form-control-sm" id="user" aria-describedby="userHelp" v-model="currentUser.user"> - <div v-show="errors.user" class="text-danger"><small><i class="fa fa-warning"></i> {{ errors.user }}</small></div> + <div v-show="errors.user" class="text-danger"> + <small> + <i class="fa fa-warning"></i> {{ errors.user }}</small> + </div> </div> <div class="form-group row"> <label for="country">Country</label> @@ -19,12 +24,18 @@ <option disabled value="">Please select one</option> <option v-for="country in countries" v-bind:value="country" v-bind:key="country">{{country}}</option> </select> - <div v-show="errors.country" class="text-danger"><small><i class="fa fa-warning"></i> {{ errors.country }}</small></div> + <div v-show="errors.country" class="text-danger"> + <small> + <i class="fa fa-warning"></i> {{ errors.country }}</small> + </div> </div> <div class="form-group row"> <label for="email">Email address</label> <input type="email" v-on:change="validateEmailaddress" class="form-control form-control-sm" id="email" aria-describedby="emailHelp" v-model="currentUser.email"> - <div v-show="errors.email" class="text-danger"><small><i class="fa fa-warning"></i> {{ errors.email }}</small></div> + <div v-show="errors.email" class="text-danger"> + <small> + <i class="fa fa-warning"></i> {{ errors.email }}</small> + </div> </div> <div class="form-group row"> <label for="role">Role</label> @@ -34,28 +45,23 @@ <option value="waterway_admin">Waterway Admin</option> <option value="waterway_user">Waterway User</option> </select> - <div v-show="errors.role" class="text-danger"><small><i class="fa fa-warning"></i> {{ errors.role }}</small></div> + <div v-show="errors.role" class="text-danger"> + <small> + <i class="fa fa-warning"></i> {{ errors.role }}</small> + </div> </div> <div class="form-group row"> - <PasswordField @fieldchange="passwordChanged" - :placeholder="passwordPlaceholder" - :label="passwordLabel" - :passworderrors="errors.password" - ></PasswordField> + <PasswordField @fieldchange="passwordChanged" :placeholder="passwordPlaceholder" :label="passwordLabel" :passworderrors="errors.password"></PasswordField> </div> <div class="form-group row"> - <PasswordField @fieldchange="passwordReChanged" - :placeholder="passwordRePlaceholder" - :label="passwordReLabel" - :passworderrors="errors.passwordre" - ></PasswordField> + <PasswordField @fieldchange="passwordReChanged" :placeholder="passwordRePlaceholder" :label="passwordReLabel" :passworderrors="errors.passwordre"></PasswordField> </div> </div> <div> <button type="submit" :disabled="submitted" class="shadow-sm btn btn-info pull-right">Submit</button> </div> </form> - </div> + </div> </div> </div> </template> @@ -238,7 +244,7 @@ const { status, data } = error.response; displayError({ title: "Backend Error", - message: `${status}: ${data.message}` + message: `${status}: ${data.message || data}` }); }); }) @@ -247,7 +253,7 @@ const { status, data } = error.response; displayError({ title: "Error while saving user", - message: `${status}: ${data.message}` + message: `${status}: ${data.message || data}` }); }); }
--- a/client/src/views/Login.vue Thu Aug 30 14:59:13 2018 +0200 +++ b/client/src/views/Login.vue Fri Aug 31 11:38:42 2018 +0200 @@ -91,6 +91,7 @@ <script> import { mapGetters } from "vuex"; import { HTTP } from "../lib/http"; +import { displayError } from "../lib/errors.js"; export default { name: "login", @@ -162,16 +163,20 @@ this.loginFailed = false; this.$router.push("/"); }) - .catch(() => { + .catch(error => { this.loginFailed = true; this.submitted = false; + const { status, data } = error.response; + displayError({ + title: "Backend Error", + message: `${status}: ${data.message || data}` + }); }); }, showPassword() { - // disable button when in reset mode - if (!this.showPasswordReset) { - this.readablePassword = !this.readablePassword; - } + // disallowing toggle when in reset mode + if (this.showPasswordReset) return; + this.readablePassword = !this.readablePassword; }, togglePasswordReset() { this.passwordJustResetted = false; @@ -181,7 +186,11 @@ resetPassword() { if (this.user) { HTTP.post("/users/passwordreset", { user: this.user }).catch(error => { - console.log("backend problem", error); + const { status, data } = error.response; + displayError({ + title: "Backend Error", + message: `${status}: ${data.message || data}` + }); }); this.togglePasswordReset(); this.passwordJustResetted = true;
--- a/client/src/views/Users.vue Thu Aug 30 14:59:13 2018 +0200 +++ b/client/src/views/Users.vue Fri Aug 31 11:38:42 2018 +0200 @@ -221,7 +221,7 @@ const { status, data } = error.response; displayError({ title: "Backend Error", - message: `${status}: ${data.message}` + message: `${status}: ${data.message || data}` }); }); }) @@ -229,7 +229,7 @@ const { status, data } = error.response; displayError({ title: "Backend Error", - message: `${status}: ${data.message}` + message: `${status}: ${data.message || data}` }); }); },