From bb400f29d05842f0fb587182beea10570e71f6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 5 Jan 2020 14:17:06 +0100 Subject: [PATCH] added actions for finanzer to send automaticly emails some bugfixes --- src/components/finanzer/Overview.vue | 31 ++++++++++++++++++++++++++++ src/components/finanzer/User.vue | 27 ++++++++++++++++++++++++ src/plugins/restService.js | 11 ++++++++-- src/views/BarView.vue | 4 ++-- src/views/FinanzerView.vue | 22 ++++++++++++++++++-- 5 files changed, 89 insertions(+), 6 deletions(-) diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index 3521d18..8c9168f 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -10,9 +10,26 @@ + Emails senden + + + + + + $expand + + + {{errorMessage(error)}} + + +
@@ -107,10 +124,13 @@ components: {Table}, props: { users: Array, + emailErrors: Array, }, data () { return { + errorExpand: false, + year: new Date().getFullYear(), filter: "", filteredUsers: [], @@ -196,6 +216,17 @@ }, getLockedColor (value) { return value ? 'red' : 'green' + }, + sendMails() { + this.$emit("send:mails") + }, + computeError(error) { + if (error) return 'error' + else return 'success' + }, + errorMessage(error) { + if (error.error) return 'Konnte Email an ' + error.user.firstname + ' ' + error.user.lastname + ' nicht senden!' + else return 'Email wurde an ' + error.user.firstname + ' ' + error.user.lastname + ' versandt.' } }, computed: { diff --git a/src/components/finanzer/User.vue b/src/components/finanzer/User.vue index 3b7de68..3330ed2 100644 --- a/src/components/finanzer/User.vue +++ b/src/components/finanzer/User.vue @@ -2,7 +2,18 @@
{{user.lastname}}, {{user.firstname}} + + + Email senden + + + + + {{errorMessage(emailError)}} + + + Konfiguration @@ -105,6 +116,7 @@ components: {Table}, props: { user: Object, + emailError: null, }, data () { return { @@ -181,6 +193,21 @@ this.selectedMonth = {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember" ][new Date().getMonth()]} + }, + sendEmail() { + this.$emit("send:mail", {username: this.user.username}) + }, + computeError(error) { + if (error) { + if (error.error) return 'error' + else return 'success' + } + }, + errorMessage(error) { + if (error) { + if (error.error) return 'Konnte Email an ' + error.user.firstname + ' ' + error.user.lastname + ' nicht senden!' + else return 'Email wurde an ' + error.user.firstname + ' ' + error.user.lastname + ' versandt.' + } } }, computed: { diff --git a/src/plugins/restService.js b/src/plugins/restService.js index ebb646f..6ad61c6 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -41,10 +41,17 @@ class Service { finanzerAddUser(token, data) { return axios.post(this.url+'finanzerAddUser', {...data}, {headers: {Token: token}}) } + finanzerSendAllMail(token) { + return axios.get(this.url+"finanzerSendAllMail", {headers: {Token: token}}) + } + finanzerSendOneMail(token, data) { + return axios.post(this.url+"finanzerSendOneMail", {...data}, {headers: {Token: token}}) + } } -const httpClient = new Service("http://localhost:5000/") +//const httpClient = new Service("http://localhost:5000/") //const httpClient = new Service("http://192.168.5.118:5000/") -//const httpClient = new Service("http://groeger-clan.duckdns.org:5000/") +//const httpClient = new Service("http://192.168.5.128:5000/") +const httpClient = new Service("http://groeger-clan.duckdns.org:5000/") export default httpClient diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 8d15574..0cfadd3 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -91,8 +91,8 @@ firstname: response.data.firstname, lastname: response.data.lastname, locked: response.data.locked, - amount: 0, - type: null + amount: response.data.amount, + type: response.data.type }) }) diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 262b6da..5c6d143 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -39,10 +39,12 @@ - + @@ -76,15 +78,19 @@ username: null, }, allUsers: [], - user: null + user: null, + errorMails: null, + errorMail: null, } }, methods: { test (e) { if (this.activeUser.username === e.username) { this.activeUser = {username: null} + this.errorMail = null } else { this.activeUser = e + this.errorMail = null } }, createAmount(creditList) { @@ -319,6 +325,18 @@ } } }) + }, + sendMails() { + httpClient.finanzerSendAllMail(this.$store.getters.getToken) + .then(response => { + this.errorMails = response.data + }) + }, + sendMail(data) { + httpClient.finanzerSendOneMail(this.$store.getters.getToken, {userId: data.username}) + .then(response => { + this.errorMail = response.data + }) } }