changeset 1370:92bce41c4fa2

merge
author Fadi Abbud <fadi.abbud@intevation.de>
date Tue, 27 Nov 2018 11:09:03 +0100
parents 7550a4707863 (current diff) d1d8c7bd16a1 (diff)
children 5b9b8eabcd01
files
diffstat 9 files changed, 112 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/client/Makefile	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/Makefile	Tue Nov 27 11:09:03 2018 +0100
@@ -1,15 +1,15 @@
 #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>
+# * Thomas Junk <thomas.junk@intevation.de>
 
 # On OSX the PATH variable isn't exported unless "SHELL" is also set, see: http://stackoverflow.com/a/25506676
 SHELL = /bin/bash
--- a/client/package.json	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/package.json	Tue Nov 27 11:09:03 2018 +0100
@@ -27,7 +27,6 @@
     "animate.css": "^3.7.0",
     "axios": "^0.18.0",
     "bootstrap": "^4.1.1",
-    "cxlt-vue2-toastr": "^1.1.0",
     "d3": "^5.7.0",
     "debounce": "^1.2.0",
     "font-awesome": "^4.7.0",
@@ -42,6 +41,7 @@
     "vue-color": "^2.6.0",
     "vue-highlightjs": "^1.3.3",
     "vue-router": "^3.0.1",
+    "vue-snotify": "^3.2.1",
     "vuex": "^3.0.1",
     "webpack-cli": "^3.1.2"
   },
--- a/client/public/index.html	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/public/index.html	Tue Nov 27 11:09:03 2018 +0100
@@ -1,15 +1,13 @@
 <!--
   This is Free Software under GNU Affero General Public License v >= 3.0
-   without warranty, see README.md and license for details.
+  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>
 -->
 <!DOCTYPE html>
 <html>
--- a/client/src/assets/application.sass	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/src/assets/application.sass	Tue Nov 27 11:09:03 2018 +0100
@@ -12,6 +12,7 @@
  * Thomas Junk <thomas.junk@intevation.de>
  * Markus Kottländer <markus.kottlaender@intevation>
  */
+
 $shadow-xs: 0 0.1rem 0.5rem rgba(0, 0, 0, 0.2)
 $border-radius: 0.25rem
 $icon-height: 2rem
--- a/client/src/components/App.vue	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/src/components/App.vue	Tue Nov 27 11:09:03 2018 +0100
@@ -30,6 +30,7 @@
     <div class="d-flex flex-column">
       <router-view/>
     </div>
+    <vue-snotify></vue-snotify>
   </div>
 </template>
 
--- a/client/src/lib/errors.js	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/src/lib/errors.js	Tue Nov 27 11:09:03 2018 +0100
@@ -12,21 +12,23 @@
  * Thomas Junk <thomas.junk@intevation.de>
  */
 
-/** facade to wrap calls to vue2-toastr */
 import app from "../main";
 
+const displayOptions = {
+  timeout: 2000,
+  showProgressBar: false,
+  closeOnClick: false,
+  pauseOnHover: true,
+  oneAtTime: true,
+  bodyMaxLength: 250
+};
+
 const displayError = ({ title, message }) => {
-  app.$toast.error({
-    title: title,
-    message: message
-  });
+  app.$snotify.error(message, title, displayOptions);
 };
 
 const displayInfo = ({ title, message }) => {
-  app.$toast.info({
-    title: title,
-    message: message
-  });
+  app.$snotify.info(message, title, displayOptions);
 };
 
 export { displayError, displayInfo };
--- a/client/src/main.js	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/src/main.js	Tue Nov 27 11:09:03 2018 +0100
@@ -20,12 +20,12 @@
 import GetTextPlugin from "vue-gettext";
 import translations from "./locale/translations.json";
 import locale2 from "locale2";
-import CxltToastr from "cxlt-vue2-toastr";
+import Snotify, { SnotifyPosition } from "vue-snotify";
 import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
 import "../node_modules/animate.css/animate.min.css";
 import "../node_modules/ol/ol.css";
-import "../node_modules/cxlt-vue2-toastr/dist/css/cxlt-vue2-toastr.css";
 import "../node_modules/highlight.js/styles/paraiso-dark.css";
+import "../node_modules/vue-snotify/styles/material.css";
 import VTooltip from "v-tooltip";
 import { library } from "@fortawesome/fontawesome-svg-core";
 import {
@@ -113,16 +113,15 @@
 
 Vue.use(VTooltip);
 
-Vue.use(VueClipboard);
-
-var toastrConfigs = {
-  position: "bottom center",
-  showDuration: 2000,
-  timeOut: 8000,
-  closeButton: true
+const options = {
+  toast: {
+    position: SnotifyPosition.centerBottom
+  }
 };
 
-Vue.use(CxltToastr, toastrConfigs);
+Vue.use(Snotify, options);
+
+Vue.use(VueClipboard);
 
 let browserLanguage = locale2;
 
--- a/client/yarn.lock	Tue Nov 27 10:53:56 2018 +0100
+++ b/client/yarn.lock	Tue Nov 27 11:09:03 2018 +0100
@@ -3119,13 +3119,6 @@
   dependencies:
     array-find-index "^1.0.1"
 
-cxlt-vue2-toastr@^1.1.0:
-  version "1.1.0"
-  resolved "https://registry.yarnpkg.com/cxlt-vue2-toastr/-/cxlt-vue2-toastr-1.1.0.tgz#b2cddab6b436f86a9ac3b1d6edcaa7f2cbf5597c"
-  integrity sha1-ss3atrQ2+Gqaw7HW7cqn8sv1WXw=
-  dependencies:
-    vue "^2.2.2"
-
 cyclist@~0.2.2:
   version "0.2.2"
   resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640"
@@ -10798,6 +10791,11 @@
   resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.0.1.tgz#d9b05ad9c7420ba0f626d6500d693e60092cc1e9"
   integrity sha512-vLLoY452L+JBpALMP5UHum9+7nzR9PeIBCghU9ZtJ1eWm6ieUI8Zb/DI3MYxH32bxkjzYV1LRjNv4qr8d+uX/w==
 
+vue-snotify@^3.2.1:
+  version "3.2.1"
+  resolved "https://registry.yarnpkg.com/vue-snotify/-/vue-snotify-3.2.1.tgz#1e093838b67ecb4141d6227b6b19175735f4e259"
+  integrity sha512-7kETtCAK3key/mDkz47FY/LuPzDGNwHHrYmS037JuVac2FW/9GTtoCNIrOp+SNbpMHeXFdLIDktkBK0IdPdHew==
+
 vue-style-loader@^4.1.0:
   version "4.1.2"
   resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-4.1.2.tgz#dedf349806f25ceb4e64f3ad7c0a44fba735fcf8"
@@ -10819,7 +10817,7 @@
   resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18"
   integrity sha512-x3LV3wdmmERhVCYy3quqA57NJW7F3i6faas++pJQWtknWT+n7k30F4TVdHvCLn48peTJFRvCpxs3UuFPqgeELg==
 
-vue@^2.2.2, vue@^2.5.16:
+vue@^2.5.16:
   version "2.5.17"
   resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.17.tgz#0f8789ad718be68ca1872629832ed533589c6ada"
   integrity sha512-mFbcWoDIJi0w0Za4emyLiW72Jae0yjANHbCVquMKijcavBGypqlF7zHRgMa5k4sesdv7hv2rB4JPdZfR+TPfhQ==
--- a/pkg/config/config.go	Tue Nov 27 10:53:56 2018 +0100
+++ b/pkg/config/config.go	Tue Nov 27 11:09:03 2018 +0100
@@ -30,35 +30,79 @@
 // This is not part of the persistent config.
 var configFile string
 
-func DBHost() string     { return viper.GetString("db-host") }
-func DBPort() uint       { return uint(viper.GetInt32("db-port")) }
-func DBName() string     { return viper.GetString("db-name") }
-func DBUser() string     { return viper.GetString("db-user") }
+// DBHost is the hostname of the database.
+func DBHost() string { return viper.GetString("db-host") }
+
+// DBPort is the port of the database.
+func DBPort() uint { return uint(viper.GetInt32("db-port")) }
+
+// DBName is the name of the database.
+func DBName() string { return viper.GetString("db-name") }
+
+// DBUser is the name of the user to connect to the database.
+func DBUser() string { return viper.GetString("db-user") }
+
+// DBPassword is the password to connect to the database.
 func DBPassword() string { return viper.GetString("db-password") }
-func DBSSLMode() string  { return viper.GetString("db-ssl") }
 
+// DBSSLMode selects the SSL mode to encrypt the connection to the database.
+func DBSSLMode() string { return viper.GetString("db-ssl") }
+
+// SessionStore is the path to the session store.
+// If empty the session store is kept in memory only.
 func SessionStore() string { return viper.GetString("sessions") }
 
-func Web() string     { return viper.GetString("web") }
+// Web is the root folder of the served web content.
+func Web() string { return viper.GetString("web") }
+
+// WebHost is the host to bind the web server to.
 func WebHost() string { return viper.GetString("host") }
-func WebPort() uint   { return uint(viper.GetInt32("port")) }
+
+// WebPort is the port to bind the web server to.
+func WebPort() uint { return uint(viper.GetInt32("port")) }
+
+// MailHost is the server of the SMTP server.
+func MailHost() string { return viper.GetString("mail-host") }
 
-func MailHost() string     { return viper.GetString("mail-host") }
-func MailPort() uint       { return uint(viper.GetInt32("mail-port")) }
-func MailUser() string     { return viper.GetString("mail-user") }
+// MailPort is the port of the SMTP server.
+func MailPort() uint { return uint(viper.GetInt32("mail-port")) }
+
+// MailUser is the user to connect to the SMTP server.
+func MailUser() string { return viper.GetString("mail-user") }
+
+// MailPassword is the password of the user to connect to the SMTP server.
 func MailPassword() string { return viper.GetString("mail-password") }
-func MailFrom() string     { return viper.GetString("mail-from") }
-func MailHelo() string     { return viper.GetString("mail-helo") }
+
+// MailFrom is the sender in the 'from' header in mails send.
+func MailFrom() string { return viper.GetString("mail-from") }
 
+// MailHelo is the helo message send to the SMTP server.
+func MailHelo() string { return viper.GetString("mail-helo") }
+
+// AllowedOrigins is a list of allowed host for CORS headers.
 func AllowedOrigins() []string { return viper.GetStringSlice("allowed-origins") }
 
-func Proxies(key string) map[string]interface{} { return viper.GetStringMap(key) }
+// GeoServerURL is the URL of the GeoServer used by gemma to serve map data.
+func GeoServerURL() string { return viper.GetString("geoserver-url") }
+
+// GeoServerUser is the adminstrative user to connect to the GeoServer.
+func GeoServerUser() string { return viper.GetString("geoserver-user") }
+
+// GeoServerPassword is the password of the adminstrative user
+// to connect to the GeoServer.
+func GeoServerPassword() string { return viper.GetString("geoserver-password") }
 
-func GeoServerURL() string      { return viper.GetString("geoserver-url") }
-func GeoServerUser() string     { return viper.GetString("geoserver-user") }
-func GeoServerPassword() string { return viper.GetString("geoserver-password") }
-func GeoServerClean() bool      { return viper.GetBool("geoserver-clean") }
+// GeoServerClean is a flag to indicate that the GeoServer setup for
+// gemma should be freshly created at boot time.
+// This is useful in case of gemma update.
+// If false the only missing parts are added to the GeoServer setup.
+// This should be the default mode when running gemma after an update
+// as it reduces the pressure on the GeoServer and enables faster
+// rebooting.
+func GeoServerClean() bool { return viper.GetBool("geoserver-clean") }
 
+// TmpDir is the path where to store temporary files.
+// If left empty the system default for temporary files is used.
 func TmpDir() string { return viper.GetString("tmp-dir") }
 
 var (
@@ -69,6 +113,12 @@
 	proxyPrefix     string
 )
 
+// ProxyKey is a crytographic key to sign the URLs generated by the proxy.
+// Use this to ensure that only known URLs are reachable over the proxy.
+// If left blank a random key is generated a gemma boot time.
+// Setting this value in the configuration will allow browsing proxy
+// generated URL across gemma reboot.
+// Use a strong secret key here (like pwgen -s 20).
 func ProxyKey() []byte {
 	fetchKey := func() {
 		if proxyKey == nil {
@@ -85,6 +135,10 @@
 	return proxyKey
 }
 
+// ProxyPrefix is the prefix used in generated URLs by the proxy.
+// It defauls to http://${WebHost}:${WebPort}".
+// You may need to set this if you run gemma behind a proxy
+// on a specific domain.
 func ProxyPrefix() string {
 	fetchPrefix := func() {
 		if proxyPrefix == "" {
@@ -95,6 +149,7 @@
 	return proxyPrefix
 }
 
+// RootCmd is cobra command to be bound th the cobra/viper infrastructure.
 var RootCmd = &cobra.Command{
 	Use:   "gemma",
 	Short: "gemma is a server for waterway monitoring and management",
@@ -175,6 +230,7 @@
 	configReady bool
 )
 
+// Ready tells if the configuration is ready to use..
 func Ready() {
 	configCond.L.Lock()
 	defer configCond.L.Unlock()
@@ -182,6 +238,10 @@
 	configCond.Broadcast()
 }
 
+// WaitReady blocks until the configuration is ready to use.
+// Call this if you have a go routine that needs configuration
+// support. This guarantees that the initialization is done
+// before accessing the configuration data.
 func WaitReady() {
 	configCond.L.Lock()
 	defer configCond.L.Unlock()