From 0dd2122a19de391e2a00de4b61ccd9f5cc54388f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 29 Dec 2019 12:37:46 +0100 Subject: [PATCH] add template to set Config for user with finanzer fixed bugs --- src/components/TitleBar.vue | 3 +- src/components/baruser/SearchBar.vue | 6 --- src/components/finanzer/Overview.vue | 4 -- src/components/finanzer/User.vue | 74 +++++++++++++++++++++++----- src/plugins/restService.js | 13 +++-- src/store/index.js | 8 --- src/views/BarView.vue | 15 ++---- src/views/FinanzerView.vue | 69 +++++++++++++++----------- 8 files changed, 113 insertions(+), 79 deletions(-) diff --git a/src/components/TitleBar.vue b/src/components/TitleBar.vue index 4f42380..0359649 100644 --- a/src/components/TitleBar.vue +++ b/src/components/TitleBar.vue @@ -1,9 +1,8 @@ @@ -51,8 +51,6 @@ }, methods: { test (e) { - // eslint-disable-next-line no-console - console.log("event: ", e) if (this.activeUser.username === e.username) { this.activeUser = {username: null} } else { @@ -121,31 +119,25 @@ getUser() { httpClient.getFinanzerMain(this.$store.getters.getToken) .then(response => { - // eslint-disable-next-line no-console - console.log("ich bin hier. response: ", response.data) for (let user in response.data) { - // eslint-disable-next-line no-console - console.log("user: ", user) const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0 // eslint-disable-next-line no-unused-vars let list = {} for (let creditList in response.data[user]['creditList']) { - // eslint-disable-next-line no-unused-vars - // eslint-disable-next-line no-console - console.log('creditList: ', creditList, response.data[user]['creditList']) let amount = this.createAmount(response.data[user]['creditList'][creditList]) let credit = this.createCredit(response.data[user]['creditList'][creditList]) let sum = this.createSum(credit, amount) list[creditList] = [{...credit}, {...amount}, {...sum}] - // eslint-disable-next-line no-console - console.log("creditList list:", creditList, list) } this.users.push({ id: lastId + 1, username: response.data[user].username, firstname: response.data[user].firstname, lastname: response.data[user].lastname, + limit: response.data[user].limit, + locked: response.data[user].locked, + autoLock: response.data[user].autoLock, creditList: list, expand: false, active: false @@ -153,7 +145,7 @@ }}) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -169,34 +161,27 @@ }) // eslint-disable-next-line no-console - console.log("this.users: ", this.users) + console.log(this.users) }, addAmount(data) { httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month}) .then(response => { - // eslint-disable-next-line no-console - console.log(response.data) let user = this.users.find(user => {return user.username === data.user.username}) let index = this.users.indexOf(user) let list = {} for (let creditList in response.data) { - // eslint-disable-next-line no-unused-vars - // eslint-disable-next-line no-console - console.log('creditList: ', creditList, response.data[creditList]) let amount = this.createAmount(response.data[creditList]) let credit = this.createCredit(response.data[creditList]) let sum = this.createSum(credit, amount) list[creditList] = [{...credit}, {...amount}, {...sum}] - // eslint-disable-next-line no-console - console.log("creditList list:", creditList, list) } this.users[index].creditList = list }) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -207,29 +192,22 @@ httpClient.addCreditFinanzer(this.$store.getters.getToken, {userId: data.user.username, credit: data.credit * 100, year: data.year, month: data.month}) .then(response => { - // eslint-disable-next-line no-console - console.log(response.data) let user = this.users.find(user => {return user.username === data.user.username}) let index = this.users.indexOf(user) let list = {} for (let creditList in response.data) { - // eslint-disable-next-line no-unused-vars - // eslint-disable-next-line no-console - console.log('creditList: ', creditList, response.data[creditList]) let amount = this.createAmount(response.data[creditList]) let credit = this.createCredit(response.data[creditList]) let sum = this.createSum(credit, amount) list[creditList] = [{...credit}, {...amount}, {...sum}] - // eslint-disable-next-line no-console - console.log("creditList list:", creditList, list) } this.users[index].creditList = list }) .catch(error => { if (error.response) { - if (error.response.status == 401) { + if (error.response.status === 401) { this.$store.dispatch('logout') } } @@ -240,6 +218,37 @@ for (let user in this.users) { user.active = false } + }, + doLock(data) { + httpClient.lockUser(this.$store.getters.getToken, {userId: data.user.username, locked: data.locked}) + .then(response => { + let user = this.users.find(user => {return user.username === data.user.username}) + let index = this.users.indexOf(user) + this.users[index].locked = response.data.locked + }) + .catch(error => { + if (error.response) { + if (error.response.status === 401) { + this.$store.dispatch('logout') + } + } + }) + }, + saveConfig(data) { + httpClient.finanzerSetConfig(this.$store.getters.getToken, {userId: data.user.username, limit: data.limit * 100, autoLock: data.autoLock}) + .then(response => { + let user = this.users.find(user => {return user.username === data.user.username}) + let index = this.users.indexOf(user) + this.users[index].limit = response.data.limit + this.users[index].autoLock = response.data.autoLock + }) + .catch(error => { + if (error.response) { + if (error.response.status === 401) { + this.$store.dispatch('logout') + } + } + }) } }