changeset 851:c0bb673d360e

mailbtn
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 28 Sep 2018 13:07:38 +0200
parents fcb38cedc680
children a3b2626cef49
files client/src/usermanagement/Userdetail.vue
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/usermanagement/Userdetail.vue	Fri Sep 28 12:53:08 2018 +0200
+++ b/client/src/usermanagement/Userdetail.vue	Fri Sep 28 13:07:38 2018 +0200
@@ -60,6 +60,10 @@
                     <div>
                         <button type="submit" :disabled="submitted" class="shadow-sm btn btn-info pull-right">Submit</button>
                     </div>
+                    <div v-if="currentUser.role !='waterway_user' " class="form-group row d-flex flex-row justify-content-start mailbutton">
+                        <a @click="sendTestMail" class="btn btn-light"><i class="fa fa-telegram"> Send testmail</i></a>
+                        <div v-if="mailsent">Mail was sent</div>
+                    </div>
                 </form>
             </div>
         </div>
@@ -67,6 +71,9 @@
 </template>
 
 <style lang="scss">
+.mailbutton {
+  width: 12vw;
+}
 .formfields {
   width: 10vw;
 }
@@ -84,6 +91,7 @@
 }
 </style>
 <script>
+import { HTTP } from "../application/lib/http";
 import { displayError } from "../application/lib/errors.js";
 import { mapGetters } from "vuex";
 import PasswordField from "./Passwordfield";
@@ -127,6 +135,7 @@
   },
   data() {
     return {
+      mailsent: false,
       passwordLabel: "Password",
       passwordReLabel: "Repeat Password",
       passwordPlaceholder: "password",
@@ -180,6 +189,27 @@
     }
   },
   methods: {
+    sendTestMail() {
+      if (this.mailsent) return;
+      HTTP.get("/testmail/" + this.currentUser.user, {
+        headers: {
+          "X-Gemma-Auth": localStorage.getItem("token"),
+          "Content-type": "text/xml; charset=UTF-8"
+        }
+      })
+        .then(() => {
+          this.mailsent = true;
+        })
+        .catch(error => {
+          this.loginFailed = true;
+          this.submitted = false;
+          const { status, data } = error.response;
+          displayError({
+            title: "Backend Error",
+            message: `${status}: ${data.message || data}`
+          });
+        });
+    },
     passwordChanged(value) {
       this.password = value;
       this.validatePassword();