view client/src/systemconfiguration/systemconfiguration.vue @ 1217:ba8cd80d68b6

made more use of bootstrap classes instead of custom css
author Markus Kottlaender <markus@intevation.de>
date Mon, 19 Nov 2018 15:20:22 +0100
parents b23622905a3f
children
line wrap: on
line source

<template>
    <div class="d-flex flex-row">
        <div class="card sysconfig mt-3 mx-auto">
            <div class="card-header shadow-sm text-white bg-info mb-6">
                Systemconfiguration
            </div>
            <div class="card-body config">
                <section class="configsection">
                    <h4 class="card-title">Bottleneck Areas stroke-color</h4>
                    <compact-picker v-model="strokeColor" />
                </section>
                <section>
                    <h4 class="card-title">Bottleneck Areas fill-color</h4>
                    <chrome-picker v-model="fillColor" />
                </section>
                <div class="sendbutton">
                    <a @click.prevent="submit" class="btn btn-info">Send</a>
                </div>
            </div> <!-- card-body -->
        </div>
    </div>
</template>

<style scoped lang="sass">
.config
  text-align: left
  
.configsection
  margin-bottom: $large-offset
  
.sendbutton
  position: absolute
  right: $offset
  bottom: $offset
  
.inputs
  margin-left: auto
  margin-right: auto
  
.sysconfig
  width: 30vw
</style>

<script>
/*
 * This is Free Software under GNU Affero General Public License v >= 3.0
 * without warranty, see README.md and license for details.
 * 
 * SPDX-License-Identifier: AGPL-3.0-or-later
 * License-Filename: LICENSES/AGPL-3.0.txt
 * 
 * Copyright (C) 2018 by via donau 
 *   – Österreichische Wasserstraßen-Gesellschaft mbH
 * Software engineering by Intevation GmbH
 * 
 * Author(s):
 * Thomas Junk <thomas.junk@intevation.de>
 */
import { Chrome } from "vue-color";
import { Compact } from "vue-color";

import { HTTP } from "../application/lib/http";
import { displayError } from "../application/lib/errors.js";
export default {
  name: "systemconfiguration",
  data() {
    return {
      sent: false,
      strokeColor: { r: 0, g: 0, b: 0, a: 1.0 },
      fillColor: { r: 0, g: 0, b: 0, a: 1.0 },
      currentConfig: null
    };
  },
  components: { "chrome-picker": Chrome, "compact-picker": Compact },
  methods: {
    submit() {
      HTTP.put("/system/style/Bottlenecks/stroke", this.strokeColor.rgba, {
        headers: {
          "X-Gemma-Auth": localStorage.getItem("token"),
          "Content-type": "application/json"
        }
      })
        .then()
        .catch(error => {
          const { status, data } = error.response;
          displayError({
            title: "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: "Backend Error",
            message: `${status}: ${data.message || data}`
          });
        });
    }
  },
  mounted() {
    HTTP.get("/system/style/Bottlenecks/stroke", {
      headers: {
        "X-Gemma-Auth": localStorage.getItem("token"),
        "Content-type": "application/json"
      }
    })
      .then(response => {
        this.strokeColor = response.data.colour;
      })
      .catch(error => {
        const { status, data } = error.response;
        displayError({
          title: "Backend Error",
          message: `${status}: ${data.message || data}`
        });
      });

    HTTP.get("/system/style/Bottlenecks/fill", {
      headers: {
        "X-Gemma-Auth": localStorage.getItem("token"),
        "Content-type": "application/json"
      }
    })
      .then(response => {
        this.fillColor = response.data.colour;
      })
      .catch(error => {
        const { status, data } = error.response;
        displayError({
          title: "Backend Error",
          message: `${status}: ${data.message || data}`
        });
      });
  }
};
</script>