finished ##295 und kleinere bugs

Es wurden timouts gesetzt und es kam eine neue komponente hinzu.
Sobald der Timout erreicht wurde wird in jeder sicht 'Server nicht verfügbar' angezeigt.
This commit is contained in:
Tim Gröger 2020-06-23 21:35:53 +02:00
parent c80d345c63
commit 65decabfb5
18 changed files with 542 additions and 152 deletions

View File

@ -0,0 +1,40 @@
<template>
<div>
<v-snackbar :timeout="0" color="error" :value="visible" top>
<v-list color="error" dense>
<v-list-item v-for="(error, index) in errors" :key="index" dense>
<v-list-item-title class="caption" style="color: white;">
{{error.message}}
</v-list-item-title>
</v-list-item>
</v-list>
<v-btn icon color="white" @click="deleteErrors">
<v-icon>
mdi-close
</v-icon>
</v-btn>
</v-snackbar>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
export default {
name: "ConnectionError",
methods: {
...mapActions({
deleteErrors: 'connectionError/deleteErrors'
})
},
computed: {
...mapGetters({
errors: 'connectionError/errors',
visible: 'connectionError/visible'
})
}
}
</script>
<style scoped>
</style>

View File

@ -1,4 +1,5 @@
<template> <template>
<div>
<v-app-bar <v-app-bar
app app
clipped-left clipped-left
@ -12,7 +13,7 @@
<v-img src="@/assets/logo-64.png" contain height="40"></v-img> <v-img src="@/assets/logo-64.png" contain height="40"></v-img>
</v-btn> </v-btn>
<v-toolbar-title>Flaschengeist</v-toolbar-title> <v-toolbar-title>Flaschengeist</v-toolbar-title>
<v-spacer /> <v-spacer/>
<v-btn icon v-if="getRouteName == 'priceListNoLogin'" @click="goHome()"> <v-btn icon v-if="getRouteName == 'priceListNoLogin'" @click="goHome()">
<v-icon> <v-icon>
{{ back }} {{ back }}
@ -34,6 +35,8 @@
<v-icon>{{ list }}</v-icon> <v-icon>{{ list }}</v-icon>
</v-btn> </v-btn>
</v-app-bar> </v-app-bar>
<ConnectionError/>
</div>
</template> </template>
<script> <script>
@ -46,9 +49,11 @@ import {
mdiFoodForkDrink, mdiFoodForkDrink,
mdiArrowLeftBoldCircle mdiArrowLeftBoldCircle
} from '@mdi/js' } from '@mdi/js'
import ConnectionError from "@/components/ConnectionError";
export default { export default {
name: 'TitleBar', name: 'TitleBar',
components: {ConnectionError},
data() { data() {
return { return {
attach_money: mdiCurrencyEur, attach_money: mdiCurrencyEur,

View File

@ -56,7 +56,12 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-dialog v-if="overOverLimit" v-model="overOverLimit" max-width="290" persistent> <v-dialog
v-if="overOverLimit"
v-model="overOverLimit"
max-width="290"
persistent
>
<v-card> <v-card>
<v-card-title>Anschreiben nicht möglich</v-card-title> <v-card-title>Anschreiben nicht möglich</v-card-title>
<v-card-text> <v-card-text>
@ -93,9 +98,12 @@
<v-list-item-subtitle>{{ <v-list-item-subtitle>{{
createMessage(message) createMessage(message)
}}</v-list-item-subtitle> }}</v-list-item-subtitle>
<v-list-item-subtitle class="red--text" v-if="message.storno" <v-list-item-subtitle class="red--text" v-if="message.storno">
>STORNIERT!!!</v-list-item-subtitle STORNIERT!!!
> </v-list-item-subtitle>
<v-list-item-subtitle class="red--text" v-else-if="message.error">
ERROR!
</v-list-item-subtitle>
<v-list-item-action-text v-if="under5minutes(message.date)" <v-list-item-action-text v-if="under5minutes(message.date)"
>Klicken um zu Stornieren >Klicken um zu Stornieren
</v-list-item-action-text> </v-list-item-action-text>
@ -242,7 +250,13 @@
</v-card-text> </v-card-text>
</v-card> </v-card>
<v-snackbar <v-snackbar
color="success" :color="
messages.length > 0
? messages[0].error
? 'error'
: 'success'
: 'success'
"
bottom bottom
:timeout="0" :timeout="0"
:multi-line="true" :multi-line="true"
@ -252,7 +266,11 @@
<v-list-item <v-list-item
v-for="message in messages" v-for="message in messages"
:key="messages.indexOf(message)" :key="messages.indexOf(message)"
style="background-color: #4CAF50;" :style="
message.error
? 'background-color: #FF5252;'
: 'background-color: #4CAF50;'
"
v-show="message.visible" v-show="message.visible"
> >
<v-list-item-content> <v-list-item-content>
@ -260,6 +278,13 @@
{{ createMessage(message) }} {{ createMessage(message) }}
</v-list-item-title> </v-list-item-title>
</v-list-item-content> </v-list-item-content>
<v-list-item-action v-if="message.error">
<v-btn icon @click="message.visible = false">
<v-icon color="white">
mdi-close
</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item> </v-list-item>
</v-snackbar> </v-snackbar>
</v-container> </v-container>
@ -338,7 +363,10 @@ export default {
}, },
checkOverLimitIsValid(user) { checkOverLimitIsValid(user) {
if (user.toSetAmount) { if (user.toSetAmount) {
if (Math.abs(user.amount - Number.parseInt(user.toSetAmount)) > user.limit + 500) { if (
Math.abs(user.amount - Number.parseInt(user.toSetAmount)) >
user.limit + 500
) {
this.overOverLimit = user this.overOverLimit = user
user.toSetAmount = null user.toSetAmount = null
user.value = null user.value = null
@ -349,7 +377,7 @@ export default {
}, },
checkOverLimit(user) { checkOverLimit(user) {
if (user.toSetAmount) { if (user.toSetAmount) {
if (Math.abs( user.amount - user.toSetAmount) > user.limit) { if (Math.abs(user.amount - user.toSetAmount) > user.limit) {
return user.checkedOverLimit ? false : true return user.checkedOverLimit ? false : true
} }
} }
@ -411,8 +439,7 @@ export default {
if (this.checkOverLimitIsValid(user)) { if (this.checkOverLimitIsValid(user)) {
if (this.checkOverLimit(user)) { if (this.checkOverLimit(user)) {
this.overLimitUser = user this.overLimitUser = user
} } else {
else {
this.addAmount({ this.addAmount({
username: user.username, username: user.username,
amount: Math.round(Math.abs(user.value * 100)), amount: Math.round(Math.abs(user.value * 100)),
@ -452,9 +479,9 @@ export default {
var text = '' var text = ''
if (message.error) { if (message.error) {
text = text =
'Konnte ' + 'ERROR: Konnte ' +
(message.amount / 100).toFixed(2) + (message.amount / 100).toFixed(2) +
'€ zu ' + '€ nicht zu ' +
message.user.firstname + message.user.firstname +
' ' + ' ' +
message.user.lastname + message.user.lastname +

View File

@ -95,7 +95,10 @@
<v-list-item-subtitle class="red--text" v-if="message.storno" <v-list-item-subtitle class="red--text" v-if="message.storno"
>STORNIERT!!! >STORNIERT!!!
</v-list-item-subtitle> </v-list-item-subtitle>
<v-list-item-action-text v-if="under5minutes(message.date)" <v-list-item-subtitle class="red--text" v-else-if="message.error">
ERROR!
</v-list-item-subtitle>
<v-list-item-action-text v-if="under5minutes(message.date) && !message.error"
>Klicken um zu Stornieren >Klicken um zu Stornieren
</v-list-item-action-text> </v-list-item-action-text>
</v-list-item-content> </v-list-item-content>
@ -247,6 +250,7 @@
</v-icon> </v-icon>
</v-btn> </v-btn>
</v-snackbar> </v-snackbar>
<ConnectionError/>
</v-container> </v-container>
</template> </template>
@ -255,9 +259,10 @@ import { mapGetters, mapActions } from 'vuex'
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
import { mdiMenu, mdiPlus, mdiClose } from '@mdi/js' import { mdiMenu, mdiPlus, mdiClose } from '@mdi/js'
import AddAmountSkeleton from './Skeleton/AddAmountSkeleton' import AddAmountSkeleton from './Skeleton/AddAmountSkeleton'
import ConnectionError from "@/components/ConnectionError";
export default { export default {
name: 'AddAmount', name: 'AddAmount',
components: { AddAmountSkeleton }, components: {ConnectionError, AddAmountSkeleton },
data() { data() {
return { return {
color: 'green accent-4', color: 'green accent-4',

View File

@ -12,6 +12,7 @@ import wm from '@/store/modules/workgroupManagement'
import jkm from '@/store/modules/jobkindManager' import jkm from '@/store/modules/jobkindManager'
import jobInvites from '@/store/modules/jobInvites' import jobInvites from '@/store/modules/jobInvites'
import jobRequests from '@/store/modules/jobRequests' import jobRequests from '@/store/modules/jobRequests'
import connectionError from "@/store/modules/connectionError";
Vue.use(Vuex) Vue.use(Vuex)
@ -28,6 +29,7 @@ export default new Vuex.Store({
wm, wm,
jkm, jkm,
jobInvites, jobInvites,
jobRequests jobRequests,
connectionError
} }
}) })

View File

@ -1,6 +1,6 @@
import axios from 'axios' import axios from 'axios'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 5000
const state = { const state = {
users: [], users: [],
allUsers: [], allUsers: [],
@ -27,7 +27,14 @@ const mutations = {
return user === a.username return user === a.username
}) })
if (users[user].last_seen != null || users[user].last_seen != undefined) { if (users[user].last_seen != null || users[user].last_seen != undefined) {
users[user].last_seen = new Date(users[user].last_seen.year, users[user].last_seen.month -1, users[user].last_seen.day, users[user].last_seen.hour, users[user].last_seen.minute, users[user].last_seen.second) users[user].last_seen = new Date(
users[user].last_seen.year,
users[user].last_seen.month - 1,
users[user].last_seen.day,
users[user].last_seen.hour,
users[user].last_seen.minute,
users[user].last_seen.second
)
} }
if (existuser) { if (existuser) {
existuser.sername = users[user].username existuser.sername = users[user].username
@ -61,7 +68,8 @@ const mutations = {
}) })
) )
if (data.loading !== undefined) state.users[index].loading = data.loading if (data.loading !== undefined) state.users[index].loading = data.loading
if (data.last_seen !== undefined) state.users[index].last_seen = data.last_seen if (data.last_seen !== undefined)
state.users[index].last_seen = data.last_seen
}, },
sortUsers: state => { sortUsers: state => {
state.users = state.users.sort((a, b) => { state.users = state.users.sort((a, b) => {
@ -84,7 +92,10 @@ const mutations = {
addMessage: (state, data) => { addMessage: (state, data) => {
var message = null var message = null
if (state.messages.length > 0) { if (state.messages.length > 0) {
if (state.messages[0].user.username === data.user.username && !data.error) { if (
state.messages[0].user.username === data.user.username &&
!data.error
) {
message = state.messages[0] message = state.messages[0]
if ((new Date() - state.messages[0].date) / 1000 < 2) { if ((new Date() - state.messages[0].date) / 1000 < 2) {
clearTimeout(message.timeout) clearTimeout(message.timeout)
@ -92,7 +103,9 @@ const mutations = {
message.visible = true message.visible = true
message.date = new Date() message.date = new Date()
message.timeout = setTimeout(() => { message.timeout = setTimeout(() => {
if (!message.error) {
message.visible = false message.visible = false
}
}, 5000) }, 5000)
return return
} else { } else {
@ -109,7 +122,9 @@ const mutations = {
amount: data.amount, amount: data.amount,
date: new Date(), date: new Date(),
timeout: setTimeout(() => { timeout: setTimeout(() => {
if (!message2.error) {
message2.visible = false message2.visible = false
}
}, 5000) }, 5000)
} }
state.messages.unshift(message2) state.messages.unshift(message2)
@ -137,11 +152,15 @@ const actions = {
commit('setUsersLoading', true) commit('setUsersLoading', true)
try { try {
const response = await axios.get(url.bar, { const response = await axios.get(url.bar, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setUsers', response.data) commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) { if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
@ -160,7 +179,7 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.barAddAmount, url.barAddAmount,
{ userId: data.username, amount: data.amount }, { userId: data.username, amount: data.amount },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setUsers', { [response.data.username]: response.data }) commit('setUsers', { [response.data.username]: response.data })
commit('addMessage', { commit('addMessage', {
@ -170,6 +189,13 @@ const actions = {
}) })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
console.log(typeof e)
for (const [key, value] of Object.entries(e)) {
console.log(`${key}: ${value}`)
}
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('addMessage', { commit('addMessage', {
user: data.user, user: data.user,
amount: data.amount, amount: data.amount,
@ -197,11 +223,14 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.barGetUser, url.barGetUser,
{ userId: data.username }, { userId: data.username },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setUsers', { [response.data.username]: response.data }) commit('setUsers', { [response.data.username]: response.data })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) { if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
@ -209,7 +238,11 @@ const actions = {
} }
} }
try { try {
commit('updateUser', { username: data.username, loading: false, last_seen: new Date() }) commit('updateUser', {
username: data.username,
loading: false,
last_seen: new Date()
})
} catch { } catch {
// error // error
} }
@ -218,11 +251,15 @@ const actions = {
commit('setAllUsersLoading', true) commit('setAllUsersLoading', true)
try { try {
const response = await axios.get(url.searchUser, { const response = await axios.get(url.searchUser, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setAllUsers', response.data) commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.data === 401) { if (e.response.data === 401) {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
@ -240,13 +277,15 @@ const actions = {
userId: data.username, userId: data.username,
amount: data.amount amount: data.amount
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
console.log(response.data)
commit('setUsers', { [response.data.username]: response.data }) commit('setUsers', { [response.data.username]: response.data })
commit('updateMessage', { date: data.date, storno: true }) commit('updateMessage', { date: data.date, storno: true })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) { if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
@ -258,10 +297,14 @@ const actions = {
async getLocked({ commit, rootState, dispatch }) { async getLocked({ commit, rootState, dispatch }) {
try { try {
const response = await axios.get(url.barU.lock, { const response = await axios.get(url.barU.lock, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setLocked', response.data.value) commit('setLocked', response.data.value)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) { if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
@ -274,10 +317,13 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.barU.lock, url.barU.lock,
{ value: true }, { value: true },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setLocked', response.data.value) commit('setLocked', response.data.value)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) { if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
@ -290,7 +336,7 @@ const actions = {
const valid = await axios.post( const valid = await axios.post(
url.user.valid, url.user.valid,
{ password: password }, { password: password },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
if (valid.data.ok === 'ok') { if (valid.data.ok === 'ok') {
const response = await axios.post( const response = await axios.post(
@ -301,6 +347,9 @@ const actions = {
commit('setLocked', response.data.value) commit('setLocked', response.data.value)
} }
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) { if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })

View File

@ -0,0 +1,43 @@
const state = {
errors: []
}
const mutations = {
addError: state => {
state.errors.push({
message: 'Connection Error: Server nicht verfügbar!',
visible: true
})
},
deleteErrors: state => {
state.errors = []
}
}
const actions = {
addError: ({ commit }) => {
commit('addError')
},
deleteErrors: ({ commit }) => {
commit('deleteErrors')
}
}
const getters = {
errors: state => {
return state.errors
},
visible: state => {
return state.errors.find(error => {
return error.visible
})
}
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}

View File

@ -1,7 +1,7 @@
import axios from 'axios' import axios from 'axios'
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 15000
const state = { const state = {
users: [], users: [],
activeUser: '', activeUser: '',
@ -253,11 +253,15 @@ const actions = {
commit('setAllUsersLoading', true) commit('setAllUsersLoading', true)
try { try {
const response = await axios.get(url.searchUser, { const response = await axios.get(url.searchUser, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setAllUsers', response.data) commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (err) { } catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response) if (err.response)
if (err.response.status === 401) if (err.response.status === 401)
dispatch('logout', null, { root: true }) dispatch('logout', null, { root: true })
@ -268,11 +272,15 @@ const actions = {
commit('setUsersLoading', true) commit('setUsersLoading', true)
try { try {
const response = await axios.get(url.getFinanzerMain, { const response = await axios.get(url.getFinanzerMain, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setUsers', response.data) commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (err) { } catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response) if (err.response)
if (err.response.status === 401) if (err.response.status === 401)
dispatch('logout', null, { root: true }) dispatch('logout', null, { root: true })
@ -293,7 +301,7 @@ const actions = {
year: data.year, year: data.year,
month: data.month month: data.month
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
const creditLists = { ...response.data } const creditLists = { ...response.data }
delete creditLists.locked delete creditLists.locked
@ -304,6 +312,9 @@ const actions = {
}) })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (err) { } catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response) if (err.response)
if (err.response.status === 401) if (err.response.status === 401)
dispatch('logout', null, { root: true }) dispatch('logout', null, { root: true })
@ -321,7 +332,7 @@ const actions = {
year: data.year, year: data.year,
month: data.month month: data.month
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
const creditLists = { ...response.data } const creditLists = { ...response.data }
delete creditLists.locked delete creditLists.locked
@ -332,6 +343,9 @@ const actions = {
}) })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (err) { } catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response) if (err.response)
if (err.response.status === 401) if (err.response.status === 401)
dispatch('logout', null, { root: true }) dispatch('logout', null, { root: true })
@ -344,11 +358,14 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.lockUser, url.lockUser,
{ userId: data.user.username, locked: data.locked }, { userId: data.user.username, locked: data.locked },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateUsers', response.data) commit('updateUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -364,11 +381,14 @@ const actions = {
limit: data.limit * 100, limit: data.limit * 100,
autoLock: data.autoLock autoLock: data.autoLock
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateUsers', response.data) commit('updateUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -380,11 +400,14 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.finanzerAddUser, url.finanzerAddUser,
{ userId: data.username }, { userId: data.username },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setUsers', response.data) commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -394,11 +417,15 @@ const actions = {
commit('setEMailLoading', true) commit('setEMailLoading', true)
try { try {
const response = await axios.get(url.finanzerSendAllMail, { const response = await axios.get(url.finanzerSendAllMail, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout: 60000
}) })
commit('setMails', response.data) commit('setMails', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -410,11 +437,14 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.finanzerSendOneMail, url.finanzerSendOneMail,
{ userId: data.username }, { userId: data.username },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setMail', response.data) commit('setMail', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,6 +1,6 @@
import axios from 'axios' import axios from 'axios'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 20000
const state = { const state = {
jobInvitesFromMe: [], jobInvitesFromMe: [],
jobInvitesToMe: [], jobInvitesToMe: [],
@ -188,12 +188,12 @@ const actions = {
day: date.getDate() day: date.getDate()
} }
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
const workers_from_me = await axios.post( const workers_from_me = await axios.post(
url.user.getJobOnDates, url.user.getJobOnDates,
from_me.data, from_me.data,
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setJobInvitesFromMe', from_me.data) commit('setJobInvitesFromMe', from_me.data)
workers_from_me.data.forEach(item => { workers_from_me.data.forEach(item => {
@ -231,12 +231,12 @@ const actions = {
day: date.getDate() day: date.getDate()
} }
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
const workers_to_me = await axios.post( const workers_to_me = await axios.post(
url.user.getJobOnDates, url.user.getJobOnDates,
to_me.data, to_me.data,
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setJobInvitesToMe', to_me.data) commit('setJobInvitesToMe', to_me.data)
workers_to_me.data.forEach(item => { workers_to_me.data.forEach(item => {
@ -267,6 +267,9 @@ const actions = {
commit('setJobInvitesLoading', false) commit('setJobInvitesLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -275,12 +278,16 @@ const actions = {
try { try {
commit('setJobInvitesLoading', true) commit('setJobInvitesLoading', true)
const response = await axios.put(url.user.setJobInvites, data, { const response = await axios.put(url.user.setJobInvites, data, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setJobInvitesFromMe', response.data) commit('setJobInvitesFromMe', response.data)
commit('setJobInvitesLoading', false) commit('setJobInvitesLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -294,7 +301,8 @@ const actions = {
url.user.addJob, url.user.addJob,
{ ...data }, { ...data },
{ {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
} }
) )
commit('updateMonthWorker', { commit('updateMonthWorker', {
@ -307,6 +315,9 @@ const actions = {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
commit('setJobInvitesLoading', false) commit('setJobInvitesLoading', false)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -320,7 +331,8 @@ const actions = {
url.user.deleteJob, url.user.deleteJob,
{ ...data }, { ...data },
{ {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
} }
) )
console.log(response.data) console.log(response.data)
@ -333,7 +345,9 @@ const actions = {
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
commit('setJobInvitesLoading', false) commit('setJobInvitesLoading', false)
} catch (e) { } catch (e) {
console.log(e) if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -342,12 +356,16 @@ const actions = {
try { try {
commit('setJobInvitesLoading', true) commit('setJobInvitesLoading', true)
const response = await axios.post(url.user.setJobInvites, data, { const response = await axios.post(url.user.setJobInvites, data, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('updateJobInviteToMe', response.data) commit('updateJobInviteToMe', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
commit('setJobInvitesLoading', false) commit('setJobInvitesLoading', false)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -356,11 +374,15 @@ const actions = {
try { try {
commit('setJobInvitesLoading', true) commit('setJobInvitesLoading', true)
await axios.post(url.user.deletJobInvite, data, { await axios.post(url.user.deletJobInvite, data, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('deleteJobInviteFromMe', data) commit('deleteJobInviteFromMe', data)
commit('setJobInvitesLoading', false) commit('setJobInvitesLoading', false)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,6 +1,6 @@
import axios from 'axios' import axios from 'axios'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 20000
const state = { const state = {
jobRequestsFromMe: [], jobRequestsFromMe: [],
jobRequestsToMe: [], jobRequestsToMe: [],
@ -188,12 +188,12 @@ const actions = {
day: date.getDate() day: date.getDate()
} }
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
const workers_from_me = await axios.post( const workers_from_me = await axios.post(
url.user.getJobOnDates, url.user.getJobOnDates,
from_me.data, from_me.data,
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setJobRequestsFromMe', from_me.data) commit('setJobRequestsFromMe', from_me.data)
workers_from_me.data.forEach(item => { workers_from_me.data.forEach(item => {
@ -231,12 +231,12 @@ const actions = {
day: date.getDate() day: date.getDate()
} }
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
const workers_to_me = await axios.post( const workers_to_me = await axios.post(
url.user.getJobOnDates, url.user.getJobOnDates,
to_me.data, to_me.data,
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setJobRequestsToMe', to_me.data) commit('setJobRequestsToMe', to_me.data)
workers_to_me.data.forEach(item => { workers_to_me.data.forEach(item => {
@ -267,6 +267,9 @@ const actions = {
commit('setJobRequestsLoading', false) commit('setJobRequestsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -275,12 +278,16 @@ const actions = {
try { try {
commit('setJobRequestsLoading', true) commit('setJobRequestsLoading', true)
const response = await axios.put(url.user.setJobRequests, data, { const response = await axios.put(url.user.setJobRequests, data, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setJobRequestsFromMe', response.data) commit('setJobRequestsFromMe', response.data)
commit('setJobRequestsLoading', false) commit('setJobRequestsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -294,7 +301,8 @@ const actions = {
day: data.on_date.getDate() day: data.on_date.getDate()
} }
const response = await axios.post(url.user.setJobRequests, data, { const response = await axios.post(url.user.setJobRequests, data, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
response.data.on_date = new Date( response.data.on_date = new Date(
response.data.on_date.year, response.data.on_date.year,
@ -305,6 +313,9 @@ const actions = {
commit('setJobRequestsLoading', false) commit('setJobRequestsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -313,11 +324,15 @@ const actions = {
try { try {
commit('setJobRequestsLoading', true) commit('setJobRequestsLoading', true)
await axios.post(url.user.deletJobRequest, data, { await axios.post(url.user.deletJobRequest, data, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('deleteJobRequestFromMe', data) commit('deleteJobRequestFromMe', data)
commit('setJobRequestsLoading', false) commit('setJobRequestsLoading', false)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,6 +1,6 @@
import url from '@/plugins/routes' import url from '@/plugins/routes'
import axios from 'axios' import axios from 'axios'
const timeout = 20000
const state = { const state = {
jobkinds: [], jobkinds: [],
jobkindLoading: false jobkindLoading: false
@ -41,12 +41,16 @@ const actions = {
try { try {
commit('setJobkindsLoading', true) commit('setJobkindsLoading', true)
const response = await axios.get(url.vorstand.sm.getAllJobKindsbKinds, { const response = await axios.get(url.vorstand.sm.getAllJobKindsbKinds, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setJobkinds', response.data) commit('setJobkinds', response.data)
commit('setJobkindsLoading', false) commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -57,15 +61,20 @@ const actions = {
const response = await axios.put( const response = await axios.put(
url.vorstand.sm.jobkind, url.vorstand.sm.jobkind,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateJobKind', response.data) commit('updateJobKind', response.data)
commit('setJobkindsLoading', false) commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async updateJobKind({ commit, rootState, dispatch }, data) { async updateJobKind({ commit, rootState, dispatch }, data) {
try { try {
@ -73,12 +82,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.sm.jobkind, url.vorstand.sm.jobkind,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateJobKind', response.data) commit('updateJobKind', response.data)
commit('setJobkindsLoading', false) commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -89,12 +101,15 @@ const actions = {
await axios.post( await axios.post(
url.vorstand.sm.deleteJobKind, url.vorstand.sm.deleteJobKind,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('deleteJobKind', data) commit('deleteJobKind', data)
commit('setJobkindsLoading', false) commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,6 +1,6 @@
import axios from 'axios' import axios from 'axios'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 20000
const state = { const state = {
month: [], month: [],
allUsers: [], allUsers: [],
@ -299,7 +299,8 @@ const actions = {
async getAllUsers({ commit, rootState, dispatch }) { async getAllUsers({ commit, rootState, dispatch }) {
try { try {
const response = await axios.get(url.searchUser, { const response = await axios.get(url.searchUser, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setAllUsers', { commit('setAllUsers', {
users: response.data, users: response.data,
@ -307,6 +308,9 @@ const actions = {
}) })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true }) if (e.response.data === 401) dispatch('logout', null, { root: true })
} }
@ -328,7 +332,7 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.sm.getUsers, url.vorstand.sm.getUsers,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
for (var day in response.data) { for (var day in response.data) {
var date = new Date( var date = new Date(
@ -354,6 +358,9 @@ const actions = {
commit('setDayNotLoading', { date, getters }) commit('setDayNotLoading', { date, getters })
} }
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -366,7 +373,8 @@ const actions = {
url.user.addJob, url.user.addJob,
{ ...data }, { ...data },
{ {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
} }
) )
commit('updateMonthWorker', { commit('updateMonthWorker', {
@ -377,6 +385,9 @@ const actions = {
commit('setDayNotLoading', { date, getters }) commit('setDayNotLoading', { date, getters })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -390,7 +401,8 @@ const actions = {
url.user.deleteJob, url.user.deleteJob,
{ ...data }, { ...data },
{ {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
} }
) )
console.log(response.data) console.log(response.data)
@ -402,6 +414,9 @@ const actions = {
commit('setDayNotLoading', { date, getters }) commit('setDayNotLoading', { date, getters })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
console.log(e) console.log(e)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -412,10 +427,13 @@ const actions = {
await axios.post( await axios.post(
url.user.transactJob, url.user.transactJob,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,7 +1,7 @@
import axios from 'axios' import axios from 'axios'
import router from '@/router' import router from '@/router'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 20000
const state = { const state = {
user: { user: {
username: null, username: null,
@ -58,7 +58,7 @@ const mutations = {
} }
const actions = { const actions = {
async doLogin({ commit }, loginData) { async doLogin({ commit, dispatch }, loginData) {
commit('loginStart') commit('loginStart')
try { try {
const response = await axios.post(url.login, { ...loginData }) const response = await axios.post(url.login, { ...loginData })
@ -91,6 +91,9 @@ const actions = {
router.push('/main') router.push('/main')
} }
} catch (err) { } catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('loginStop', err.response.data.error) commit('loginStop', err.response.data.error)
commit('updateAccessToken', { commit('updateAccessToken', {
username: null, username: null,
@ -139,10 +142,13 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.saveLifeTime, url.saveLifeTime,
{ value: value }, { value: value },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setLifeTime', response.data.value) commit('setLifeTime', response.data.value)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -153,7 +159,8 @@ const actions = {
return return
} }
const response = await axios.get(url.getLifeTime, { const response = await axios.get(url.getLifeTime, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setLifeTime', response.data.value) commit('setLifeTime', response.data.value)
var user = JSON.parse(localStorage.getItem('user')) var user = JSON.parse(localStorage.getItem('user'))
@ -161,6 +168,9 @@ const actions = {
localStorage.setItem('user', JSON.stringify(user)) localStorage.setItem('user', JSON.stringify(user))
commit('updateAccessToken', user) commit('updateAccessToken', user)
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,6 +1,6 @@
import url from '@/plugins/routes' import url from '@/plugins/routes'
import axios from 'axios' import axios from 'axios'
const timeout = 20000
const state = { const state = {
priceListLoading: false, priceListLoading: false,
typesLoading: false, typesLoading: false,
@ -98,22 +98,28 @@ const actions = {
async getPriceList({ commit, dispatch }) { async getPriceList({ commit, dispatch }) {
try { try {
commit('setPriceListLoading', true) commit('setPriceListLoading', true)
const response = await axios.get(url.pricelist) const response = await axios.get(url.pricelist, { timeout })
commit('setPriceList', response.data) commit('setPriceList', response.data)
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
} }
}, },
async getTypes({ commit, dispatch }) { async getTypes({ commit, dispatch }) {
try { try {
commit('setTypesLoading', true) commit('setTypesLoading', true)
const response = await axios.get(url.getTypes) const response = await axios.get(url.getTypes, { timeout })
commit('setTypes', response.data) commit('setTypes', response.data)
commit('setTypesLoading', false) commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setTypesLoading', false) commit('setTypesLoading', false)
} }
}, },
@ -123,12 +129,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.gastro.setDrink, url.gastro.setDrink,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updatePriceList', response.data) commit('updatePriceList', response.data)
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -140,12 +149,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.gastro.updateDrink, url.gastro.updateDrink,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updatePriceList', response.data) commit('updatePriceList', response.data)
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -157,12 +169,15 @@ const actions = {
await axios.post( await axios.post(
url.gastro.deleteDrink, url.gastro.deleteDrink,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('deleteDrinkPrice', data) commit('deleteDrinkPrice', data)
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setPriceListLoading', false) commit('setPriceListLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -174,12 +189,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.gastro.setType, url.gastro.setType,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateDrinkType', response.data) commit('updateDrinkType', response.data)
commit('setTypesLoading', false) commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setTypesLoading', false) commit('setTypesLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -191,12 +209,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.gastro.updateType, url.gastro.updateType,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateDrinkType', response.data) commit('updateDrinkType', response.data)
commit('setTypesLoading', false) commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setTypesLoading', false) commit('setTypesLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -208,12 +229,15 @@ const actions = {
await axios.post( await axios.post(
url.gastro.deleteType, url.gastro.deleteType,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('deleteDrinkType', data) commit('deleteDrinkType', data)
commit('setTypesLoading', false) commit('setTypesLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setTypesLoading', false) commit('setTypesLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })

View File

@ -1,6 +1,6 @@
import axios from 'axios' import axios from 'axios'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 20000
const state = { const state = {
month: [], month: [],
allUsers: [], allUsers: [],
@ -270,11 +270,15 @@ const actions = {
async getAllUsers({ commit, rootState, dispatch }) { async getAllUsers({ commit, rootState, dispatch }) {
try { try {
const response = await axios.get(url.vorstand.sm.searchUser, { const response = await axios.get(url.vorstand.sm.searchUser, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setAllUsers', response.data) commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true }) if (e.response.data === 401) dispatch('logout', null, { root: true })
} }
@ -287,12 +291,16 @@ const actions = {
url.vorstand.sm.addUser, url.vorstand.sm.addUser,
{ ...data }, { ...data },
{ {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
} }
) )
//commit('updateMonth', { ...response.data[0], com: 'add' }) //commit('updateMonth', { ...response.data[0], com: 'add' })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -304,7 +312,7 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.sm.getUsers, url.vorstand.sm.getUsers,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
for (var day in response.data) { for (var day in response.data) {
var date = new Date( var date = new Date(
@ -330,6 +338,9 @@ const actions = {
commit('setDayNotLoading', { date, getters }) commit('setDayNotLoading', { date, getters })
} }
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -341,11 +352,14 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.sm.deleteUser, url.vorstand.sm.deleteUser,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
//commit('updateMonth', { ...data, com: 'delete' }) //commit('updateMonth', { ...data, com: 'delete' })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -355,7 +369,7 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.sm.lockDay, url.vorstand.sm.lockDay,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
console.log(response.data) console.log(response.data)
let date = new Date( let date = new Date(
@ -370,6 +384,9 @@ const actions = {
}) })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -383,12 +400,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.sm.updateJobKindDates, url.vorstand.sm.updateJobKindDates,
[...data], [...data],
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateMonthJobkind', { data: response.data, date, getters }) commit('updateMonthJobkind', { data: response.data, date, getters })
commit('setDayNotLoading', { date, getters }) commit('setDayNotLoading', { date, getters })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,6 +1,6 @@
import axios from 'axios' import axios from 'axios'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const timeout = 20000
const state = { const state = {
user: null, user: null,
creditList: [], creditList: [],
@ -134,9 +134,9 @@ const mutations = {
setAddLoading(state, value) { setAddLoading(state, value) {
state.addLoading = value state.addLoading = value
}, },
setError(state, {value, error}) { setError(state, { value, error }) {
//clearTimeout(state.error? state.error.timeout : null) //clearTimeout(state.error? state.error.timeout : null)
state.error = {value, error} state.error = { value, error }
state.error.timeout = setTimeout(() => { state.error.timeout = setTimeout(() => {
state.error = null state.error = null
}, 6000) }, 6000)
@ -169,7 +169,10 @@ const mutations = {
addMessage: (state, data) => { addMessage: (state, data) => {
var message = null var message = null
if (state.messages.length > 0) { if (state.messages.length > 0) {
if (state.messages[0].user.username === data.user.username && !data.error) { if (
state.messages[0].user.username === data.user.username &&
!data.error
) {
message = state.messages[0] message = state.messages[0]
if ((new Date() - state.messages[0].date) / 1000 < 2) { if ((new Date() - state.messages[0].date) / 1000 < 2) {
clearTimeout(message.timeout) clearTimeout(message.timeout)
@ -215,12 +218,16 @@ const actions = {
commit('setLoading', true) commit('setLoading', true)
try { try {
const response = await axios.get(url.userMain, { const response = await axios.get(url.userMain, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setUser', response.data) commit('setUser', response.data)
commit('setError', '') commit('setError', '')
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -232,7 +239,7 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.userAddAmount, url.userAddAmount,
{ amount: amount }, { amount: amount },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setUser', response.data) commit('setUser', response.data)
commit('addMessage', { commit('addMessage', {
@ -243,6 +250,9 @@ const actions = {
commit('setError', '') commit('setError', '')
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('addMessage', { commit('addMessage', {
user: rootState.login.user, user: rootState.login.user,
amount: amount, amount: amount,
@ -259,17 +269,20 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.user.config, url.user.config,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
console.log(response.data) console.log(response.data)
commit('setUser', response.data) commit('setUser', response.data)
commit('setError', {value: 'Daten gespeichert', error: false}) commit('setError', { value: 'Daten gespeichert', error: false })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) { if (e.response) {
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.data) { if (e.response.data) {
commit('setError', { value: e.response.data.error, error: true}) commit('setError', { value: e.response.data.error, error: true })
} }
} }
} }
@ -284,11 +297,14 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.user.job, url.user.job,
{ date: data.date.getTime() / 1000 }, { date: data.date.getTime() / 1000 },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateDay', { ...response.data, date: data.date }) commit('updateDay', { ...response.data, date: data.date })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) { if (e.response) {
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
if (e.response.data) { if (e.response.data) {
@ -306,12 +322,15 @@ const actions = {
{ {
amount: data.amount amount: data.amount
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('setUser', response.data) commit('setUser', response.data)
commit('updateMessage', { date: data.date, storno: true }) commit('updateMessage', { date: data.date, storno: true })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -320,11 +339,15 @@ const actions = {
async getStatus({ commit, rootState, dispatch }) { async getStatus({ commit, rootState, dispatch }) {
try { try {
const response = await axios.get(url.user.getAllStatus, { const response = await axios.get(url.user.getAllStatus, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setStatus', response.data) commit('setStatus', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -332,11 +355,15 @@ const actions = {
async getTokens({ commit, rootState, dispatch }) { async getTokens({ commit, rootState, dispatch }) {
try { try {
const response = await axios.get(url.user.getAccessTokens, { const response = await axios.get(url.user.getAccessTokens, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setTokens', response.data) commit('setTokens', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -344,11 +371,15 @@ const actions = {
async deleteToken({ commit, rootState, dispatch }, token) { async deleteToken({ commit, rootState, dispatch }, token) {
try { try {
const response = await axios.post(url.user.getAccessTokens, token, { const response = await axios.post(url.user.getAccessTokens, token, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setTokens', response.data) commit('setTokens', response.data)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -1,6 +1,6 @@
import url from '@/plugins/routes' import url from '@/plugins/routes'
import axios from 'axios' import axios from 'axios'
const timeout = 20000
const state = { const state = {
users: [], users: [],
status: [], status: [],
@ -77,12 +77,16 @@ const actions = {
try { try {
commit('setUsersLoading', true) commit('setUsersLoading', true)
const response = await axios.get(url.getUsers, { const response = await axios.get(url.getUsers, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setUsers', response.data) commit('setUsers', response.data)
commit('setUsersLoading', false) commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setUsersLoading', false) commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -92,12 +96,16 @@ const actions = {
try { try {
commit('setUsersLoading', true) commit('setUsersLoading', true)
const response = await axios.get(url.getUsers + '?extern=1', { const response = await axios.get(url.getUsers + '?extern=1', {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setUsers', response.data) commit('setUsers', response.data)
commit('setUsersLoading', false) commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setUsersLoading', false) commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -107,12 +115,16 @@ const actions = {
try { try {
commit('setStatusLoading', true) commit('setStatusLoading', true)
const response = await axios.get(url.user.getAllStatus, { const response = await axios.get(url.user.getAllStatus, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setStatus', response.data) commit('setStatus', response.data)
commit('setStatusLoading', false) commit('setStatusLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setStatusLoading', false) commit('setStatusLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -124,12 +136,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.um.updateStatusUser, url.vorstand.um.updateStatusUser,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateUser', response.data) commit('updateUser', response.data)
commit('setUsersLoading', false) commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setUsersLoading', false) commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -141,12 +156,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.um.updateVoting, url.vorstand.um.updateVoting,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateUser', response.data) commit('updateUser', response.data)
commit('setUsersLoading', false) commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setUsersLoading', false) commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -158,12 +176,15 @@ const actions = {
const response = await axios.post( const response = await axios.post(
url.vorstand.um.updateWorkgroups, url.vorstand.um.updateWorkgroups,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateWorkgroups', { id: data.id, workgroups: response.data }) commit('updateWorkgroups', { id: data.id, workgroups: response.data })
commit('setUsersLoading', false) commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setUsersLoading', false) commit('setUsersLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })

View File

@ -1,6 +1,6 @@
import url from '@/plugins/routes' import url from '@/plugins/routes'
import axios from 'axios' import axios from 'axios'
const timeout = 20000
const state = { const state = {
workgroupsLoading: false, workgroupsLoading: false,
workgroups: [] workgroups: []
@ -41,12 +41,16 @@ const actions = {
try { try {
commit('setWorkgroupLoading', true) commit('setWorkgroupLoading', true)
const response = await axios.get(url.vorstand.wm.getAllWorkgroups, { const response = await axios.get(url.vorstand.wm.getAllWorkgroups, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken },
timeout
}) })
commit('setWorkgroups', response.data) commit('setWorkgroups', response.data)
commit('setWorkgroupLoading', false) commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
commit('setWorkgroupLoading', false) commit('setWorkgroupLoading', false)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -58,12 +62,15 @@ const actions = {
const response = await axios.put( const response = await axios.put(
url.vorstand.wm.workgroup, url.vorstand.wm.workgroup,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateWorkgroup', response.data) commit('updateWorkgroup', response.data)
commit('setWorkgroupLoading', false) commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -74,12 +81,15 @@ const actions = {
const repsonse = await axios.post( const repsonse = await axios.post(
url.vorstand.wm.workgroup, url.vorstand.wm.workgroup,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('updateWorkgroup', repsonse.data) commit('updateWorkgroup', repsonse.data)
commit('setWorkgroupLoading', false) commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
@ -90,12 +100,15 @@ const actions = {
await axios.post( await axios.post(
url.vorstand.wm.deleteWorkgroup, url.vorstand.wm.deleteWorkgroup,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
commit('deleteWorkgroup', data) commit('deleteWorkgroup', data)
commit('setWorkgroupLoading', false) commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }