Mercurial > gemma
changeset 2586:bc1b43885a4d
Expose axis snapping tolerance in bottleneck upload import
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 11 Mar 2019 17:31:39 +0100 |
parents | 0b25c75a3a63 |
children | 857bb070b9f1 |
files | client/src/components/importschedule/Importscheduledetail.vue client/src/components/importschedule/importtypes/Bottleneck.vue pkg/controllers/uploadedimports.go |
diffstat | 3 files changed, 31 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue Mon Mar 11 16:53:48 2019 +0100 +++ b/client/src/components/importschedule/Importscheduledetail.vue Mon Mar 11 17:31:39 2019 +0100 @@ -94,11 +94,12 @@ :url="url" ></Availablefairwaydepth> <Bottleneck - v-if="import_ == $options.IMPORTTYPES.BOTTLENECK && !directImport" + v-if="import_ == $options.IMPORTTYPES.BOTTLENECK" @urlChanged="setUrl" @toleranceChanged="setTolerance" :url="url" :tolerance="tolerance" + :directImport="directImport" ></Bottleneck> <Distancemarksvirtual v-if="import_ == $options.IMPORTTYPES.DISTANCEMARKSVIRTUAL" @@ -586,12 +587,12 @@ }, isValid() { if (!this.import_) return false; + if (this.isToleranceRequired && !this.tolerance) return false; if (this.directImport && !this.uploadFile) return false; else if (!this.directImport) { if (this.isURLRequired && !this.url) return false; if (this.isSortbyRequired && !this.sortBy) return false; if (this.isFeatureTypeRequired && !this.featureType) return false; - if (this.isToleranceRequired && !this.tolerance) return false; if (this.isCredentialsRequired && (!this.username || !this.password)) return false; if (this.import_ == this.$options.IMPORTTYPES.FAIRWAYDIMENSION) { @@ -720,6 +721,7 @@ let routeParam = ""; switch (this.import_) { case this.$options.IMPORTTYPES.BOTTLENECK: + formData.append("tolerance", this.tolerance); routeParam = "ubn"; break; case this.$options.IMPORTTYPES.FAIRWAYAVAILABILITY:
--- a/client/src/components/importschedule/importtypes/Bottleneck.vue Mon Mar 11 16:53:48 2019 +0100 +++ b/client/src/components/importschedule/importtypes/Bottleneck.vue Mon Mar 11 17:31:39 2019 +0100 @@ -2,17 +2,19 @@ <div> <div class="d-flex flex-row"> <div class="flex-column mt-3 mr-3 w-100"> - <div class="flex-row text-left"> - <small class="text-muted"> <translate>URL</translate> </small> - </div> - <div class="w-100"> - <input - @input="urlChanged" - class="url form-control" - type="url" - :value="url" - /> - </div> + <template v-if="!directImport"> + <div class="flex-row text-left"> + <small class="text-muted"> <translate>URL</translate> </small> + </div> + <div class="w-100"> + <input + @input="urlChanged" + class="url form-control" + type="url" + :value="url" + /> + </div> + </template> </div> <div v-if="false" class="flex-column mt-3 text-left"> <div class="d-flex flex-row"> @@ -89,7 +91,7 @@ */ export default { name: "bottleneckimport", - props: ["url", "tolerance"], + props: ["url", "tolerance", "directImport"], methods: { urlChanged(e) { this.$emit("urlChanged", e.target.value);
--- a/pkg/controllers/uploadedimports.go Mon Mar 11 16:53:48 2019 +0100 +++ b/pkg/controllers/uploadedimports.go Mon Mar 11 17:31:39 2019 +0100 @@ -91,9 +91,19 @@ return uploadedImport( imports.UBNJobKind, "data.xml", - func(_ *http.Request, dir string) (imports.Job, error) { - // TODO expose tolerance to endpoint - return &imports.UploadedBottleneck{Dir: dir, Tolerance: 5}, nil + func(req *http.Request, dir string) (imports.Job, error) { + + var tolerance float64 + if t := req.FormValue("tolerance"); t != "" { + v, err := strconv.ParseFloat(t, 64) + if err != nil { + return nil, BadUploadParameterError( + fmt.Sprintf("Invalid 'tolerance' parameter: %v", err)) + } + tolerance = v + } + + return &imports.UploadedBottleneck{Dir: dir, Tolerance: tolerance}, nil }, ) }