diff --git a/cert/server.crt b/cert/server.crt new file mode 100644 index 0000000..e804409 --- /dev/null +++ b/cert/server.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDazCCAlOgAwIBAgIJAJGH2ozWvd1RMA0GCSqGSIb3DQEBCwUAMFMxCzAJBgNV +BAYTAkRFMQ8wDQYDVQQIDAZTYXhvbnkxEDAOBgNVBAcMB0RyZXNkZW4xITAfBgNV +BAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMDAxMTcwOTA0MDFaFw0z +MDAxMDQwOTA0MDFaMEQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZTYXhvbnkxEDAO +BgNVBAcMB0RyZXNkZW4xEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBALlkr1UOQypLKicESRnse52d5mAX9MjZQpH0/Y5u +V5WxpPSasmOpt4MRj5MWTfTK2ukj/jLtPAMsggUh7wMXb1uytHj7T5mtiahXBM0H +1sUi2nScXR6doQZlmqKWDGrVS7WHULM01WhirsnxI8S8e6Evpk4F5/RafKA8FgYI +Ongg6S1B16+7T0e/FnILoMjKr1jpgzXnVkPFIneu/qVevSNco5/aw+bc6sjeS/ZA +65dXFGpDlw0lPRHLT5/CgNyMyiLYov7KwMycZw7uxa1ynO+73tqe5tvO/DiMpAPJ +EkrSz/StYBsGJxDhwq5RT31tHVtHhTf0rk1BmaoQJ0Aq7iECAwEAAaNRME8wHwYD +VR0jBBgwFoAUt8P5gBfN9hCUAiWhtPH5fTWnctAwCQYDVR0TBAIwADALBgNVHQ8E +BAMCBPAwFAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBCwUAA4IBAQCD +fBByVq8AbV1DMrY+MElb/nZA5/cuGnUpBpjSlk5OnYHWtywuQk6veiiJ0S2fNfqf +RzwOFuZDHKmIcH0574VssLfUynMKP3w3xb2ZNic3AxAdhzZ6LXLx6+qF5tYcL7oC +UWmj5Mo9SkX5HZLEGamQlVyGOGKNatxep4liyoSeKXr0AOHYfB4AkDhVZn7yQc/v +But42fLBg4mE+rk4UBYOHA4XdoFwqgTCNZq2RxKzvG9LIcok6lOc6gDnfTsH8GqE +byGpfIIQAXF8aftCm4dGXxtzMh8C5d0t2Ell9g+Rr8i/enebT2nJ9B9ptldDjhcZ +7I0ywGsXwrh0EwFsX74/ +-----END CERTIFICATE----- diff --git a/cert/server.key b/cert/server.key new file mode 100644 index 0000000..153fd6b --- /dev/null +++ b/cert/server.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC5ZK9VDkMqSyon +BEkZ7HudneZgF/TI2UKR9P2ObleVsaT0mrJjqbeDEY+TFk30ytrpI/4y7TwDLIIF +Ie8DF29bsrR4+0+ZrYmoVwTNB9bFItp0nF0enaEGZZqilgxq1Uu1h1CzNNVoYq7J +8SPEvHuhL6ZOBef0WnygPBYGCDp4IOktQdevu09HvxZyC6DIyq9Y6YM151ZDxSJ3 +rv6lXr0jXKOf2sPm3OrI3kv2QOuXVxRqQ5cNJT0Ry0+fwoDcjMoi2KL+ysDMnGcO +7sWtcpzvu97anubbzvw4jKQDyRJK0s/0rWAbBicQ4cKuUU99bR1bR4U39K5NQZmq +ECdAKu4hAgMBAAECggEABoMQ3Y34sf2d52zxHGYAGZM4SlvND1kCS5otZdleXjW1 +M5pTdci6V3JAdswrxNNzSQkonqVSnFHt5zw/5v3lvXTTfgRl0WIVGcKkuobx9k65 +Gat8YdzrkQv0mI1otj/zvtaX8ROEA3yj4xgDR5/PP+QqlUcD1MNw6TfzFhcn5pxB +/RDPmvarMhzMdDW60Uub6Z7e/kVPuXWrW4bDyULd1d1NoSibnFZi+vGY0Lc1ctDW +2Vl7A8RFTcQi6Cjx/FwgPGJTBE4UMjIBO3wnoPQBMrsSxeGhcarerqIlEafgT4XN +p9BMtRyaXE7TTb1BXc35ZYNJLDLJKQxABhrEHtFreQKBgQDpiGwuKAFK8BLPlbAx +zkShhKd9fhlwm2bfRv3cojPQZsxn0BjefmtrISbKCD79Ivyn7TnOyYAoKAxdp2q9 +wtz94aAXV2lfhUw2lhcb/aw4sXuY/s1XnVyoglOO8pYRCUN0o80pKuWFsaDyy/uL +LhINff1oMNCa7vmMdu8Ccz0o/wKBgQDLOqdTQhSFs4f1yhlDDH3pqT6eKvtFNeRJ +usxYDnAyRXHRqwhQ86z1nBZIgwXqq7PfO9V5Y/l6/2HmmA2ufjS8aBTNpCUMuvJk +y98Z4hTjKRdnVlMUjHq9ahCixJVQ8pcCnWRFdeAwSKhHQiJEFLYeYOIrUeCIYJI4 +FiCshSPI3wKBgGU0ErWZ7p18FprRIs8itYlNhIwUxo+POPCPwloIDO5GblSa0Pwy +yvhdIIMzOaDXtahMXN3pYtmEKX+4msBrnvuC+K7E2cxkZtfNCWy+7RCQkaCG45QR +hOMdv3pWVIRDgHEevz0U8uySQs6VaYgySe6A5/1sEiriX1DpBcEJEbsfAoGAKUCb +rGvSbJ1XsM24OQL1IBQJsON6o77fuxOe3RT5M0sjYnL8OipsZmKrp0ZpUgxOc7ba +i0x+3LewMLWWuV/G5qOd7WwvVRkxkMJNZByfLskthf1g2d/2HjLEc7XBtW+4tYAr +VWoq+sIU3noPKJCnsxzpa++vyx8HLzlWoo5YCDMCgYBJvGH2zMgInlQNO/2XY5nl +E53EZMex+RDq8Wzr4tRM3IrCGc2t8WKEQ/9teKNH0tg9xib0vhqqmiGl1xNfqJVo +ePJyfgFabeUx9goG3mgTdV9woSRlBJso62dM0DAC/jsJoHnVzgokysR4/BfW9Da+ +AYTxRZSNbfmsTHawXqG8Fw== +-----END PRIVATE KEY----- diff --git a/package.json b/package.json index 775126e..bce46ff 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,9 @@ "@vue/prettier", "eslint:recommended" ], - "rules": {}, + "rules": { + "no-console": "off" + }, "parserOptions": { "parser": "babel-eslint" } diff --git a/src/App.vue b/src/App.vue index 164699d..58a0a74 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,18 +1,20 @@ diff --git a/src/components/baruser/BarNavigation.vue b/src/components/baruser/BarNavigation.vue new file mode 100644 index 0000000..2542cc7 --- /dev/null +++ b/src/components/baruser/BarNavigation.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/src/components/finanzer/FinanzerNavigation.vue b/src/components/finanzer/FinanzerNavigation.vue new file mode 100644 index 0000000..065e4f1 --- /dev/null +++ b/src/components/finanzer/FinanzerNavigation.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/src/components/finanzer/Overview.vue b/src/components/finanzer/Overview.vue index ec0c0ae..edfcd5a 100644 --- a/src/components/finanzer/Overview.vue +++ b/src/components/finanzer/Overview.vue @@ -1,5 +1,5 @@ - + diff --git a/src/components/user/AddAmount.vue b/src/components/user/AddAmount.vue new file mode 100644 index 0000000..e60dfb4 --- /dev/null +++ b/src/components/user/AddAmount.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/components/user/CreditOverview.vue b/src/components/user/CreditOverview.vue new file mode 100644 index 0000000..01c0cbe --- /dev/null +++ b/src/components/user/CreditOverview.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/src/components/user/UserNavigation.vue b/src/components/user/UserNavigation.vue new file mode 100644 index 0000000..69a68db --- /dev/null +++ b/src/components/user/UserNavigation.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 4a9c8a2..3861d98 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,5 +1,5 @@ //const main = 'http://192.168.5.118:5000/' -const main = 'http://localhost:5000/' +const main = 'https://localhost:5000/' const url = { login: main + 'login', @@ -15,7 +15,9 @@ const url = { finanzerSetConfig: main + 'finanzerSetConfig', finanzerAddUser: main + 'finanzerAddUser', finanzerSendAllMail: main + 'finanzerSendAllMail', - finanzerSendOneMail: main + 'finanzerSendOneMail' + finanzerSendOneMail: main + 'finanzerSendOneMail', + userMain: main + 'user/main', + userAddAmount: main + 'user/addAmount' } export default url diff --git a/src/router/index.js b/src/router/index.js index e7f546e..a816fab 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -3,7 +3,17 @@ import VueRouter from 'vue-router' import FinanzerView from '@/views/FinanzerView' import Login from '@/views/Login' import store from '@/store/index' -import BarView from '@/views/BarView' +import GeruechteView from '../views/contents/GeruechteView' +import AddAmount from '../components/user/AddAmount' +import CreditOverview from '../components/user/CreditOverview' +import MainView from '../views/MainView' +import UserView from '../views/UserView' +import BarView from '../views/BarView' +import UserNavigation from '../components/user/UserNavigation' +import BarNavigation from '../components/baruser/BarNavigation' +import FinanzerNavigation from '../components/finanzer/FinanzerNavigation' +import Overview from '../components/finanzer/Overview' +import User from '../components/finanzer/User' Vue.use(VueRouter) @@ -14,14 +24,57 @@ const routes = [ component: Login }, { - path: '/finanzer', - name: 'finanzer', - component: FinanzerView - }, - { - path: '/bar', - name: 'bar', - component: BarView + path: '/main', + name: 'main', + component: MainView, + children: [ + { + path: 'user', + name: 'user', + components: { userNav: UserNavigation, default: UserView }, + children: [ + { + path: 'add', + name: 'add', + component: AddAmount + }, + { + path: 'overview', + name: 'userOverview', + component: CreditOverview + } + ] + }, + { + path: 'bar', + name: 'bar', + components: { userNav: BarNavigation, default: BarView }, + children: [ + { + path: 'geruecht', + name: 'geruecht', + component: GeruechteView + } + ] + }, + { + path: 'finanzer', + name: 'finanzer', + components: { default: FinanzerView, finanzerNav: FinanzerNavigation }, + children: [ + { + path: 'overview', + component: Overview + }, + { + path: 'user/:id', + name: 'activeUser', + props: true, + component: User + } + ] + } + ] }, { path: '*', @@ -39,18 +92,23 @@ const router = new VueRouter({ router.beforeEach((to, from, next) => { store.dispatch('fetchAccessToken') - let sites = ['/finanzer', '/bar'] - if (sites.includes(to.fullPath)) { - if (to.fullPath === '/finanzer') { + console.log('fullPath', to.fullPath) + if (to.fullPath.includes('/main')) { + if (to.fullPath.includes('/main/finanzer')) { if (!store.state.login.user.group.includes('moneymaster')) { next('/login') } } - if (to.fullPath === '/bar') { + if (to.fullPath.includes('/main/bar')) { if (!store.state.login.user.group.includes('bar')) { next('/login') } } + if (to.fullPath.includes('/main/user')) { + if (!store.state.login.user.group.includes('user')) { + next('/login') + } + } if (!store.state.login.user.accessToken) { next('/login') } @@ -58,9 +116,11 @@ router.beforeEach((to, from, next) => { if (to.fullPath === '/login') { if (store.state.login.user.accessToken) { if (store.state.login.user.group.includes('moneymaster')) { - next('/finanzer') + next('/main/finanzer') } else if (store.state.login.user.group.includes('bar')) { - next('/bar') + next('/main/bar/geruecht') + } else if (store.state.login.user.group.includes('user')) { + next('/main/user/add') } } } diff --git a/src/store/index.js b/src/store/index.js index e8ca7be..8687346 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -3,6 +3,7 @@ import Vuex from 'vuex' import login from './modules/login' import finanzerUsers from './modules/finanzerUsers' import barUsers from '@/store/modules/barUsers' +import user from '@/store/modules/user' Vue.use(Vuex) @@ -10,6 +11,7 @@ export default new Vuex.Store({ modules: { login, finanzerUsers, - barUsers + barUsers, + user } }) diff --git a/src/store/modules/finanzerUsers.js b/src/store/modules/finanzerUsers.js index 766f0f6..2f3984a 100644 --- a/src/store/modules/finanzerUsers.js +++ b/src/store/modules/finanzerUsers.js @@ -4,9 +4,7 @@ import url from '@/plugins/routes' const state = { users: [], - activeUser: { - username: null - }, + activeUser: '', allUsers: [], user: null, errorMails: null, @@ -38,13 +36,8 @@ const mutations = { state.allUsers[i].firstname + ' ' + state.allUsers[i].lastname } }, - setActiveUser: (state, user) => { - if (state.activeUser.username === user.username) { - state.activeUser = { username: null } - } else { - state.activeUser = user - } - state.errorMail = null + setActiveUser: (state, username) => { + state.activeUser = username }, setUsers: (state, users) => { for (let user in users) { @@ -256,8 +249,8 @@ const actions = { dispatch('logout', null, { root: true }) } }, - setActiveUser({ commit }, user) { - commit('setActiveUser', user) + setActiveUser({ commit }, username) { + commit('setActiveUser', username) }, async addAmount({ commit, rootState, dispatch }, data) { try { @@ -390,7 +383,9 @@ const getters = { return state.users }, activeUser: state => { - return state.activeUser + return state.users.find(user => { + return user.username === state.activeUser + }) }, allUsers: state => { return state.allUsers diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 8604395..5617825 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -55,9 +55,11 @@ const actions = { commit('loginStop', null) commit('updateAccessToken', response.data) if (state.user.group.includes('moneymaster')) { - router.push('/finanzer') + router.push('/main/finanzer/overview') } else if (state.user.group.includes('bar')) { - router.push('/bar') + router.push('/main/bar/geruecht') + } else if (state.user.group.includes('user')) { + router.push('/main/user/add') } } catch (err) { commit('loginStop', err.response.data.error) @@ -96,6 +98,30 @@ const getters = { }, loginError: state => { return state.loginError + }, + isBar: state => { + try { + return state.user.group.includes('bar') ? true : false + } catch (e) { + return false + } + }, + isFinanzer: state => { + try { + return state.user.group.includes('moneymaster') ? true : false + } catch (e) { + return false + } + }, + isUser: state => { + try { + return state.user.group.includes('user') ? true : false + } catch (e) { + return false + } + }, + isLoggedIn: state => { + return state.user.accessToken ? true : false } } diff --git a/src/store/modules/user.js b/src/store/modules/user.js new file mode 100644 index 0000000..4118304 --- /dev/null +++ b/src/store/modules/user.js @@ -0,0 +1,168 @@ +import axios from 'axios' +import url from '@/plugins/routes' + +const state = { + user: null, + creditList: [] +} + +const mutations = { + setUser: (state, user) => { + state.user = user + let list = {} + for (let creditList in user['creditList']) { + console.log(creditList) + let amount = mutations.createAmount(user['creditList'][creditList]) + let credit = mutations.createCredit(user['creditList'][creditList]) + let sum = mutations.createSum(credit, amount) + list[creditList] = [{ ...credit }, { ...amount }, { ...sum }] + } + state.user.creditList = list + state.creditList = [] + console.log(state.user) + }, + createAmount(creditList) { + let amount = { + type: 'Schulden', + jan_amount: 0 - creditList.jan.depts, + feb_amount: 0 - creditList.feb.depts, + maer_amount: 0 - creditList.maer.depts, + apr_amount: 0 - creditList.apr.depts, + mai_amount: 0 - creditList.mai.depts, + jun_amount: 0 - creditList.jun.depts, + jul_amount: 0 - creditList.jul.depts, + aug_amount: 0 - creditList.aug.depts, + sep_amount: 0 - creditList.sep.depts, + okt_amount: 0 - creditList.okt.depts, + nov_amount: 0 - creditList.nov.depts, + dez_amount: 0 - creditList.dez.depts, + last: 0 - creditList['last'] + } + + amount.sum = + amount.jan_amount + + amount.feb_amount + + amount.maer_amount + + amount.apr_amount + + amount.mai_amount + + amount.jun_amount + + amount.jul_amount + + amount.aug_amount + + amount.sep_amount + + amount.okt_amount + + amount.nov_amount + + amount.dez_amount + return amount + }, + createCredit(creditList) { + let credit = { + type: 'Guthaben', + jan_amount: creditList.jan.credit, + feb_amount: creditList.feb.credit, + maer_amount: creditList.maer.credit, + apr_amount: creditList.apr.credit, + mai_amount: creditList.mai.credit, + jun_amount: creditList.jun.credit, + jul_amount: creditList.jul.credit, + aug_amount: creditList.aug.credit, + sep_amount: creditList.sep.credit, + okt_amount: creditList.okt.credit, + nov_amount: creditList.nov.credit, + dez_amount: creditList.dez.credit + } + credit.sum = + credit.jan_amount + + credit.feb_amount + + credit.maer_amount + + credit.apr_amount + + credit.mai_amount + + credit.jun_amount + + credit.jul_amount + + credit.aug_amount + + credit.sep_amount + + credit.okt_amount + + credit.nov_amount + + credit.dez_amount + return credit + }, + createSum(credit, amount) { + let sum = { + type: 'Summe', + jan_amount: credit.jan_amount + amount.jan_amount, + feb_amount: credit.feb_amount + amount.feb_amount, + maer_amount: credit.maer_amount + amount.maer_amount, + apr_amount: credit.apr_amount + amount.apr_amount, + mai_amount: credit.mai_amount + amount.mai_amount, + jun_amount: credit.jun_amount + amount.jun_amount, + jul_amount: credit.jul_amount + amount.jul_amount, + aug_amount: credit.aug_amount + amount.aug_amount, + sep_amount: credit.sep_amount + amount.sep_amount, + okt_amount: credit.okt_amount + amount.okt_amount, + nov_amount: credit.nov_amount + amount.nov_amount, + dez_amount: credit.dez_amount + amount.dez_amount + } + sum.sum = + sum.jan_amount + + sum.feb_amount + + sum.maer_amount + + sum.apr_amount + + sum.mai_amount + + sum.jun_amount + + sum.jul_amount + + sum.aug_amount + + sum.sep_amount + + sum.okt_amount + + sum.nov_amount + + sum.dez_amount + return sum + } +} + +const actions = { + async getUser({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.userMain, { + headers: { Token: rootState.login.user.accessToken } + }) + commit('setUser', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async addAmount({ commit, rootState, dispatch }, amount) { + try { + const response = await axios.post( + url.userAddAmount, + { amount: amount }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setUser', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + } +} + +const getters = { + user: state => { + return state.user + }, + year: state => { + let year = 0 + for (let creditList in state.user.creditList) { + let currentYear = parseInt(creditList) + if (currentYear > year) year = currentYear + } + return year + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +} diff --git a/src/views/BarView.vue b/src/views/BarView.vue index 04a38a2..3487f61 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -1,29 +1,13 @@ - + diff --git a/src/views/FinanzerView.vue b/src/views/FinanzerView.vue index 067fd84..2341ee9 100644 --- a/src/views/FinanzerView.vue +++ b/src/views/FinanzerView.vue @@ -1,27 +1,14 @@ - + diff --git a/src/views/Login.vue b/src/views/Login.vue index c357464..b281b4c 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -1,6 +1,5 @@ - + diff --git a/src/views/MainView.vue b/src/views/MainView.vue new file mode 100644 index 0000000..d8661c6 --- /dev/null +++ b/src/views/MainView.vue @@ -0,0 +1,79 @@ + + + + + diff --git a/src/views/UserView.vue b/src/views/UserView.vue new file mode 100644 index 0000000..0463d74 --- /dev/null +++ b/src/views/UserView.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/src/views/contents/GeruechteView.vue b/src/views/contents/GeruechteView.vue new file mode 100644 index 0000000..204f650 --- /dev/null +++ b/src/views/contents/GeruechteView.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/vue.config.js b/vue.config.js index 6f7f0e0..2bb43cb 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,8 +1,12 @@ +//const fs = require('fs') + module.exports = { - "transpileDependencies": [ - "vuetify" - ], + transpileDependencies: ['vuetify'], devServer: { disableHostCheck: true + // https: { + // key: fs.readFileSync('./cert/server.key'), + // cert: fs.readFileSync('./cert/server.crt') + // } } }