Mercurial > gemma
comparison client/src/store/imports.js @ 1942:d1b7b1c70410
import stretch: listview with edit-function
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 21 Jan 2019 16:53:12 +0100 |
parents | 1aa864cccddc |
children | f64bc12c1719 |
comparison
equal
deleted
inserted
replaced
1941:d4249b07e719 | 1942:d1b7b1c70410 |
---|---|
12 * Thomas Junk <thomas.junk@intevation.de> | 12 * Thomas Junk <thomas.junk@intevation.de> |
13 */ | 13 */ |
14 | 14 |
15 import { HTTP } from "@/lib/http"; | 15 import { HTTP } from "@/lib/http"; |
16 import Vue from "vue"; | 16 import Vue from "vue"; |
17 import { WFS } from "ol/format.js"; | |
17 | 18 |
18 /* eslint-disable no-unused-vars */ | 19 /* eslint-disable no-unused-vars */ |
19 /* eslint-disable no-unreachable */ | 20 /* eslint-disable no-unreachable */ |
20 const STATES = { | 21 const STATES = { |
21 NEEDSAPPROVAL: "pending", | 22 NEEDSAPPROVAL: "pending", |
113 state: init(), | 114 state: init(), |
114 mutations: { | 115 mutations: { |
115 setStretches: (state, stretches) => { | 116 setStretches: (state, stretches) => { |
116 state.stretches = stretches; | 117 state.stretches = stretches; |
117 }, | 118 }, |
118 // only for prototype purposes delete after real backend is active | |
119 addStretch: (state, stretch) => { | |
120 state.stretches.push(stretch); | |
121 }, | |
122 clearCurrentSchedule: state => { | 119 clearCurrentSchedule: state => { |
123 state.currentSchedule = initializeCurrentSchedule(); | 120 state.currentSchedule = initializeCurrentSchedule(); |
124 }, | 121 }, |
125 setImportScheduleDetailInvisible: state => { | 122 setImportScheduleDetailInvisible: state => { |
126 state.importScheduleDetailVisible = false; | 123 state.importScheduleDetailVisible = false; |
217 } | 214 } |
218 } | 215 } |
219 }, | 216 }, |
220 actions: { | 217 actions: { |
221 loadStretches({ commit }) { | 218 loadStretches({ commit }) { |
222 throw new Error("Endpoint not activated!"); | 219 return new Promise((resolve, reject) => { |
223 return new Promise((resolve, reject) => { | 220 var stretchesFeatureCollectionRequest = new WFS().writeGetFeature({ |
224 HTTP.get("/imports/stretch", { | 221 srsName: "EPSG:4326", |
225 headers: { "X-Gemma-Auth": localStorage.getItem("token") } | 222 featureNS: "gemma", |
226 }) | 223 featurePrefix: "gemma", |
227 .then(response => { | 224 featureTypes: ["stretches"], |
228 commit("setStretches", response.data); | 225 outputFormat: "application/json" |
226 }); | |
227 HTTP.post( | |
228 "/internal/wfs", | |
229 new XMLSerializer().serializeToString( | |
230 stretchesFeatureCollectionRequest | |
231 ), | |
232 { | |
233 headers: { | |
234 "X-Gemma-Auth": localStorage.getItem("token"), | |
235 "Content-type": "text/xml; charset=UTF-8" | |
236 } | |
237 } | |
238 ) | |
239 .then(response => { | |
240 commit("setStretches", response.data.features); | |
229 resolve(response); | 241 resolve(response); |
230 }) | 242 }) |
231 .catch(error => { | 243 .catch(error => { |
232 reject(error); | 244 reject(error); |
233 }); | 245 }); |
237 return new Promise((resolve, reject) => { | 249 return new Promise((resolve, reject) => { |
238 HTTP.post("/imports/stretch", stretch, { | 250 HTTP.post("/imports/stretch", stretch, { |
239 headers: { "X-Gemma-Auth": localStorage.getItem("token") } | 251 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
240 }) | 252 }) |
241 .then(response => { | 253 .then(response => { |
242 commit("setStretches", response.data); | |
243 resolve(response); | 254 resolve(response); |
244 }) | 255 }) |
245 .catch(error => { | 256 .catch(error => { |
246 reject(error); | 257 reject(error); |
247 }); | 258 }); |