# HG changeset patch # User Markus Kottlaender # Date 1562684433 -7200 # Node ID 6c2ef463b958f590031c193ad9b33abbe917adf3 # Parent f52f9d2dc8bd48df85685810524d8f9f1f17333e client: configuration: make color settings resettable diff -r f52f9d2dc8bd -r 6c2ef463b958 client/src/components/systemconfiguration/ColorSettings.vue --- a/client/src/components/systemconfiguration/ColorSettings.vue Tue Jul 09 16:52:19 2019 +0200 +++ b/client/src/components/systemconfiguration/ColorSettings.vue Tue Jul 09 17:00:33 2019 +0200 @@ -29,6 +29,9 @@ Send + + Reset to defaults + @@ -66,7 +69,8 @@ */ import { Chrome, Compact } from "vue-color"; import { HTTP } from "@/lib/http"; -import { displayError } from "@/lib/errors"; +import { displayError, displayInfo } from "@/lib/errors"; +import defaults from "./defaults"; export default { name: "colorsettings", @@ -83,33 +87,42 @@ "compact-picker": Compact }, methods: { + reset() { + this.strokeColor = defaults.feature_colours_bottlenecks_stroke; + this.fillColor = defaults.feature_colours_bottlenecks_fill; + }, submit() { - HTTP.put("/system/style/Bottlenecks/stroke", this.strokeColor.rgba, { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "application/json" - } - }) - .then() + Promise.all([ + HTTP.put( + "/system/style/Bottlenecks/stroke", + this.strokeColor.rgba || this.strokeColor, + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "application/json" + } + } + ), + HTTP.put( + "/system/style/Bottlenecks/fill", + this.fillColor.rgba || this.fillColor, + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "application/json" + } + } + ) + ]) + .then(() => { + displayInfo({ + message: "Configuration saved!" + }); + }) .catch(error => { const { status, data } = error.response; displayError({ - title: this.$gettext("Backend Error"), - message: `${status}: ${data.message || data}` - }); - }); - - HTTP.put("/system/style/Bottlenecks/fill", this.fillColor.rgba, { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "application/json" - } - }) - .then() - .catch(error => { - const { status, data } = error.response; - displayError({ - title: this.$gettext("Backend Error"), + title: "Backend Error", message: `${status}: ${data.message || data}` }); });