finished ##217

fixed bug that when you search in barCreditList or finanzerOverview, with 2 strings e.g. full name

fixed bug when you click on a name in searchbar in finanzerOverview, that you get the profile of the user
you dont need to click button "hinzufügen"
This commit is contained in:
Tim Gröger 2020-03-07 15:00:52 +01:00
parent 00bffe665d
commit 53676763ea
15 changed files with 289 additions and 35 deletions

View File

@ -3,9 +3,35 @@
<TitleBar />
<router-view />
<v-footer app>
<span class="px-4"
<span class="px-4 d-none d-sm-flex"
>&copy; {{ new Date().getFullYear() }} Studentenclub Wu 5 e.v.</span
>
<v-spacer />
<div v-if="isLoggedIn && !change" :key="render">
<v-hover v-slot:default="{ hover }" open-delay="200" close-delay="200">
<v-sheet
:elevation="hover ? 16 : 0"
color="#f5f5f5"
@click="change = !change"
>{{ calcTime }}</v-sheet
>
</v-hover>
</div>
<v-dialog v-model="change" max-width="300">
<v-card>
<v-card-title>
Zeit bis zum Logout ändern
</v-card-title>
<v-card-text>
<v-combobox solo :items="lifeTimes" item-text="text" item-value="value" v-model="selectLifeTime" return-object />
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text @click="change=false">Abbrechen</v-btn>
<v-btn color="primary" text @click="save()">Speichern</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<CookieNotification />
</v-footer>
</v-app>
@ -13,12 +39,123 @@
<script>
import TitleBar from './components/TitleBar'
import CookieNotification from "./components/CookieNotification";
import CookieNotification from './components/CookieNotification'
import { mapGetters, mapActions } from 'vuex'
export default {
name: 'App',
components: { CookieNotification, TitleBar },
data: () => ({
//
})
render: 0,
timer: null,
change: false,
selectLifeTime: { text: '30 Minuten', value: 1800 },
lifeTimes: [
{
text: '5 Minuten',
value: 300
},
{
text: '10 Minuten',
value: 600
},
{
text: '15 Minuten',
value: 900
},
{
text: '30 Minuten',
value: 1800
},
{
text: '1 Stunde',
value: 3600
},
{
text: '2 Stunden',
value: 7200
},
{
text: '3 Stunden',
value: 10800
},
{
text: '1 Tag',
value: 86400
},
{
text: '2 Tage',
value: 172800
},
{
text: '1 Woche',
value: 604800
},
{
text: '1 Monat',
value: 2678400
}
]
}),
created() {
if (this.isLoggedIn) {
this.getLifeTime()
}
this.timer = setInterval(this.test, 1000)
},
methods: {
...mapActions(['setLifeTime', 'saveLifeTime', 'logout', 'getLifeTime']),
test() {
if (this.isLoggedIn) {
if (this.lifeTime == 0) this.logout()
this.setLifeTime(this.lifeTime - 1)
}
},
save() {
this.saveLifeTime(this.selectLifeTime.value)
this.change = false
}
},
computed: {
...mapGetters(['isLoggedIn', 'lifeTime', 'getMinute', 'getSeconds']),
calcTime() {
var minutes = this.lifeTime / 60
var seconds = this.lifeTime % 60
var minutesString =
minutes < 10 ? '0' + Math.floor(minutes % 60) : Math.floor(minutes % 60)
var secondsString =
seconds < 10 ? '0' + Math.floor(seconds) : Math.floor(seconds)
if (minutes > 60) {
var hours = minutes / 60
if (hours > 24) {
var days = hours / 24
var now = new Date()
var dayMonth = new Date(
now.getFullYear(),
now.getMonth() + 1,
0
).getDate()
if (days >= dayMonth) {
return Math.floor(days / dayMonth) + ' Monate bis zum Logout'
} else {
return Math.floor(days) + ' Tage bis zum Logout'
}
} else {
return (
Math.floor(hours) +
':' +
minutesString +
':' +
secondsString +
' Stunden bis zum Logout'
)
}
} else {
return minutesString + ':' + secondsString + ' Minuten bis zum Logout'
}
}
},
beforeDestroy() {
clearInterval(this.timer)
}
}
</script>

View File

@ -1,6 +1,6 @@
<template>
<v-app-bar app clipped-left clipped-right color="blue accent-4" class="elevation-4" dark dense>
<v-btn icon to="/">
<v-btn icon to="/login">
<v-img src="@/assets/logo-64.png" contain height="40"></v-img>
</v-btn>
<v-toolbar-title>Flaschengeist</v-toolbar-title>

View File

@ -161,10 +161,21 @@
</v-btn>
</v-col>
<v-col cols="8">
<v-text-field outlined type="number" v-model="user.value" label="Benutzerdefinierter Betrag" :disabled="user.locked"></v-text-field>
<v-text-field
outlined
type="number"
v-model="user.value"
label="Benutzerdefinierter Betrag"
:disabled="user.locked"
></v-text-field>
</v-col>
<v-col cols="4">
<v-btn fab :color="color" @click="addAmountMore(user)" :disabled="user.locked">
<v-btn
fab
:color="color"
@click="addAmountMore(user)"
:disabled="user.locked"
>
<v-icon>{{ plus }}</v-icon>
</v-btn>
</v-col>
@ -247,16 +258,26 @@ export default {
},
isFiltered(user) {
try {
return (
user.firstname.toLowerCase().includes(this.filter.toLowerCase()) ||
user.lastname.toLowerCase().includes(this.filter.toLowerCase())
)
var filters = this.filter.split(' ')
for (var filter in filters) {
if (
user.firstname.toLowerCase().includes(filters[filter].toLowerCase()) ||
user.lastname.toLowerCase().includes(filters[filter].toLowerCase())
) {
return true
}
}
return false
} catch (e) {
return true
}
},
addAmountMore(user) {
this.addAmount({username: user.username, amount: user.value * 100, user: user})
this.addAmount({
username: user.username,
amount: user.value * 100,
user: user
})
setTimeout(() => {
user.value = null
}, 300)

View File

@ -28,16 +28,12 @@
full-width
:loading="allUsersLoading"
:search-input.sync="filter"
@change="addToUser(user)"
>
<template v-slot:prepend-inner>
<v-icon>{{search_person}}</v-icon>
</template>
</v-autocomplete>
<v-btn
text
@click="addToUser(user)"
>Hinzufügen</v-btn
>
</v-toolbar-items>
</v-toolbar>
<v-expand-transition>
@ -333,10 +329,16 @@ export default {
},
isFiltered(user) {
try {
return (
user.firstname.toLowerCase().includes(this.filter.toLowerCase()) ||
user.lastname.toLowerCase().includes(this.filter.toLowerCase())
)
var filters = this.filter.split(' ')
for (var filter in filters) {
if (
user.firstname.toLowerCase().includes(filters[filter].toLowerCase()) ||
user.lastname.toLowerCase().includes(filters[filter].toLowerCase())
) {
return true
}
}
return false
} catch (e) {
return true
}

View File

@ -10,10 +10,9 @@
<v-icon>{{ keyboard_arrow_left }}</v-icon>
</v-btn>
<v-list-item>
<v-list-item-title class="title"
>{{ monthArray[date.getMonth()] }}
{{ date.getFullYear() }}</v-list-item-title
>
<v-list-item-title class="title">
{{ monthArray[date.getMonth()] }} {{ date.getFullYear() }}
</v-list-item-title>
</v-list-item>
<v-btn text icon @click="changeMonth(1)">
<v-icon>{{ keyboard_arrow_right }}</v-icon>
@ -78,7 +77,13 @@ export default {
},
created() {
for (let intDate = 1; intDate < 7; intDate++) {
if (new Date(this.date.getFullYear(), this.date.getMonth(), intDate).getDay() === 3)
if (
new Date(
this.date.getFullYear(),
this.date.getMonth(),
intDate
).getDay() === 3
)
if (this.date.getDate() < intDate)
this.date = new Date(this.date.getFullYear(), this.date.getMonth(), 0)
}
@ -117,8 +122,7 @@ export default {
computed: {
...mapGetters({
month: 'sm/month'
}),
})
}
}
</script>

View File

@ -5,6 +5,7 @@ const main = 'http://localhost:5000/'
const url = {
login: main + 'login',
logout: main + 'logout',
getUsers: main + 'getUsers',
pricelist: main + 'pricelist',
getTypes: main + 'drinkTypes',
@ -23,6 +24,8 @@ const url = {
finanzerSendOneMail: main + 'finanzerSendOneMail',
userMain: main + 'user/main',
userAddAmount: main + 'user/addAmount',
saveLifeTime: main + 'saveLifeTime',
getLifeTime: main + 'getLifeTime',
vorstand: {
sm: {
addUser: main + 'sm/addUser',

View File

@ -128,6 +128,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -152,6 +153,7 @@ const actions = {
amount: data.amount,
error: false
})
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('addMessage', {
user: data.user,
@ -180,6 +182,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setUsers', { [response.data.username]: response.data })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -197,6 +200,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
@ -216,6 +220,7 @@ const actions = {
)
commit('setUsers', { [response.data.username]: response.data })
commit('updateMessage', { date: data.date, storno: true })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })

View File

@ -247,6 +247,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.response)
if (err.response.status === 401)
@ -261,6 +262,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.response)
if (err.response.status === 401)
@ -291,6 +293,7 @@ const actions = {
locked: response.data.locked,
username: data.user.username
})
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.response)
if (err.response.status === 401)
@ -318,6 +321,7 @@ const actions = {
locked: response.data.locked,
username: data.user.username
})
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.response)
if (err.response.status === 401)
@ -334,6 +338,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -353,6 +358,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -368,6 +374,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -381,6 +388,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setMails', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -396,6 +404,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setMail', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })

View File

@ -82,6 +82,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setTransactJobs', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
@ -98,6 +99,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setRequestJobs', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
@ -113,6 +115,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateRequestJob', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
@ -126,6 +129,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('deleteTransactJobactJob', data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })

View File

@ -211,6 +211,7 @@ const actions = {
users: response.data,
username: rootState.login.user.username
})
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
@ -247,6 +248,7 @@ const actions = {
day: response.data.day
})
commit('setDayNotLoading', { date: data.startdatetime, getters })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -262,6 +264,7 @@ const actions = {
}
)
commit('updateMonth', { ...response.data[0], com: 'add' })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -280,6 +283,7 @@ const actions = {
user: rootState.login.user,
com: 'delete'
})
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -292,6 +296,7 @@ const actions = {
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })

View File

@ -13,7 +13,8 @@ const state = {
loggingIn: false,
loginError: null,
cookieNotification: true,
cookieAccepted: false
cookieAccepted: false,
lifeTime: 1800
}
const mutations = {
@ -50,6 +51,9 @@ const mutations = {
},
setCookieAccepted(state, value) {
state.cookieAccepted = value
},
setLifeTime(state, value) {
state.lifeTime = value
}
}
@ -100,13 +104,17 @@ const actions = {
fetchAccessToken({ commit }) {
commit('updateAccessToken', localStorage.getItem('user'))
},
logout({ commit }) {
logout({ commit, rootState }) {
var accessToken = rootState.login.user.accessToken
localStorage.removeItem('user')
localStorage.removeItem('cookie:accepted')
commit('setCookieNotification', true)
commit('setCookieAccepted', false)
commit('logout')
router.push('/login')
axios.get(url.logout, {
headers: { Token: accessToken }
})
},
resetLoginError({ commit }) {
commit('loginStop')
@ -122,6 +130,36 @@ const actions = {
getCookieAccepted({ commit }) {
var cookie = localStorage.getItem('cookie:accepted')
commit('setCookieAccepted', cookie)
},
setLifeTime({ commit }, value) {
commit('setLifeTime', value)
},
async saveLifeTime({ commit, rootState, dispatch }, value) {
try {
const response = await axios.post(
url.saveLifeTime,
{ value: value },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setLifeTime', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async getLifeTime({ commit, rootState, dispatch }) {
try {
if (!rootState.login.user.accessToken) {
return
}
const response = await axios.get(url.getLifeTime, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setLifeTime', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
}
}
@ -201,6 +239,9 @@ const getters = {
},
cookieAccepted: state => {
return state.cookieAccepted
},
lifeTime: state => {
return state.lifeTime
}
}

View File

@ -95,22 +95,24 @@ const mutations = {
}
const actions = {
async getPriceList({ commit }) {
async getPriceList({ commit, dispatch }) {
try {
commit('setPriceListLoading', true)
const response = await axios.get(url.pricelist)
commit('setPriceList', response.data)
commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setPriceListLoading', false)
}
},
async getTypes({ commit }) {
async getTypes({ commit, dispatch }) {
try {
commit('setTypesLoading', true)
const response = await axios.get(url.getTypes)
commit('setTypes', response.data)
commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setTypesLoading', false)
}
@ -125,6 +127,7 @@ const actions = {
)
commit('updatePriceList', response.data)
commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setPriceListLoading', false)
if (e.response)
@ -141,6 +144,7 @@ const actions = {
)
commit('updatePriceList', response.data)
commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setPriceListLoading', false)
if (e.response)
@ -157,6 +161,7 @@ const actions = {
)
commit('deleteDrinkPrice', data)
commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setPriceListLoading', false)
if (e.response)
@ -173,6 +178,7 @@ const actions = {
)
commit('updateDrinkType', response.data)
commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setTypesLoading', false)
if (e.response)
@ -189,6 +195,7 @@ const actions = {
)
commit('updateDrinkType', response.data)
commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setTypesLoading', false)
if (e.response)
@ -205,6 +212,7 @@ const actions = {
)
commit('deleteDrinkType', data)
commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setTypesLoading', false)
if (e.response)

View File

@ -204,6 +204,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
@ -220,6 +221,7 @@ const actions = {
}
)
commit('updateMonth', { ...response.data[0], com: 'add' })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -245,6 +247,7 @@ const actions = {
day: response.data.day
})
commit('setDayNotLoading', { date: data.startdatetime, getters })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -260,6 +263,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateMonth', { ...data, com: 'delete' })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -273,6 +277,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateMonth', { start: response.data.date, day: response.data })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })

View File

@ -210,6 +210,7 @@ const actions = {
})
commit('setUser', response.data)
commit('setError', '')
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -231,6 +232,7 @@ const actions = {
error: false
})
commit('setError', '')
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('addMessage', {
user: rootState.login.user,
@ -252,6 +254,7 @@ const actions = {
)
commit('setUser', response.data)
commit('setError', '')
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response) {
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -274,6 +277,7 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateDay', { ...response.data, date: data.date })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response) {
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -296,6 +300,7 @@ const actions = {
)
commit('setUser', response.data)
commit('updateMessage', { date: data.date, storno: true })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -308,6 +313,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }
})
commit('setStatus', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })

View File

@ -71,6 +71,7 @@ const actions = {
})
commit('setUsers', response.data)
commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setUsersLoading', false)
if (e.response)
@ -85,6 +86,7 @@ const actions = {
})
commit('setStatus', response.data)
commit('setStatusLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setStatusLoading', false)
if (e.response)
@ -101,6 +103,7 @@ const actions = {
)
commit('updateUser', response.data)
commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setUsersLoading', false)
if (e.response)
@ -117,6 +120,7 @@ const actions = {
)
commit('updateUser', response.data)
commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setUsersLoading', false)
if (e.response)