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,39 +1,42 @@
<template>
<v-app-bar
app
clipped-left
clipped-right
color="blue accent-4"
class="elevation-4"
dark
dense
>
<v-btn icon @click="reload()">
<v-img src="@/assets/logo-64.png" contain height="40"></v-img>
</v-btn>
<v-toolbar-title>Flaschengeist</v-toolbar-title>
<v-spacer />
<v-btn icon v-if="getRouteName == 'priceListNoLogin'" @click="goHome()">
<v-icon>
{{ back }}
</v-icon>
</v-btn>
<v-btn icon v-if="isFinanzer" :disabled="locked" @click="goTo('overview')">
<v-icon>{{ attach_money }}</v-icon>
</v-btn>
<v-btn icon v-if="isGastro" :disabled="locked" @click="goTo('gastroPricelist')">
<v-icon>{{ gastro }}</v-icon>
</v-btn>
<v-btn icon v-if="isBar" @click="goTo('geruecht')">
<v-icon>{{ local_bar }}</v-icon>
</v-btn>
<v-btn icon v-if="isUser" :disabled="locked" @click="goTo('add')">
<v-icon>{{ person }}</v-icon>
</v-btn>
<v-btn icon @click="goTo('priceListNoLogin')">
<v-icon>{{ list }}</v-icon>
</v-btn>
</v-app-bar>
<div>
<v-app-bar
app
clipped-left
clipped-right
color="blue accent-4"
class="elevation-4"
dark
dense
>
<v-btn icon @click="reload()">
<v-img src="@/assets/logo-64.png" contain height="40"></v-img>
</v-btn>
<v-toolbar-title>Flaschengeist</v-toolbar-title>
<v-spacer/>
<v-btn icon v-if="getRouteName == 'priceListNoLogin'" @click="goHome()">
<v-icon>
{{ back }}
</v-icon>
</v-btn>
<v-btn icon v-if="isFinanzer" :disabled="locked" @click="goTo('overview')">
<v-icon>{{ attach_money }}</v-icon>
</v-btn>
<v-btn icon v-if="isGastro" :disabled="locked" @click="goTo('gastroPricelist')">
<v-icon>{{ gastro }}</v-icon>
</v-btn>
<v-btn icon v-if="isBar" @click="goTo('geruecht')">
<v-icon>{{ local_bar }}</v-icon>
</v-btn>
<v-btn icon v-if="isUser" :disabled="locked" @click="goTo('add')">
<v-icon>{{ person }}</v-icon>
</v-btn>
<v-btn icon @click="goTo('priceListNoLogin')">
<v-icon>{{ list }}</v-icon>
</v-btn>
</v-app-bar>
<ConnectionError/>
</div>
</template>
<script>
@ -46,9 +49,11 @@ import {
mdiFoodForkDrink,
mdiArrowLeftBoldCircle
} from '@mdi/js'
import ConnectionError from "@/components/ConnectionError";
export default {
name: 'TitleBar',
components: {ConnectionError},
data() {
return {
attach_money: mdiCurrencyEur,

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import axios from 'axios'
import url from '@/plugins/routes'
const timeout = 5000
const state = {
users: [],
allUsers: [],
@ -27,7 +27,14 @@ const mutations = {
return user === a.username
})
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) {
existuser.sername = users[user].username
@ -61,7 +68,8 @@ const mutations = {
})
)
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 => {
state.users = state.users.sort((a, b) => {
@ -84,7 +92,10 @@ const mutations = {
addMessage: (state, data) => {
var message = null
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]
if ((new Date() - state.messages[0].date) / 1000 < 2) {
clearTimeout(message.timeout)
@ -92,7 +103,9 @@ const mutations = {
message.visible = true
message.date = new Date()
message.timeout = setTimeout(() => {
message.visible = false
if (!message.error) {
message.visible = false
}
}, 5000)
return
} else {
@ -109,7 +122,9 @@ const mutations = {
amount: data.amount,
date: new Date(),
timeout: setTimeout(() => {
message2.visible = false
if (!message2.error) {
message2.visible = false
}
}, 5000)
}
state.messages.unshift(message2)
@ -137,11 +152,15 @@ const actions = {
commit('setUsersLoading', true)
try {
const response = await axios.get(url.bar, {
headers: { Token: rootState.login.user.accessToken }
headers: { Token: rootState.login.user.accessToken },
timeout
})
commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
@ -160,7 +179,7 @@ const actions = {
const response = await axios.post(
url.barAddAmount,
{ 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('addMessage', {
@ -170,6 +189,13 @@ const actions = {
})
dispatch('getLifeTime', null, { root: true })
} 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', {
user: data.user,
amount: data.amount,
@ -197,11 +223,14 @@ const actions = {
const response = await axios.post(
url.barGetUser,
{ userId: data.username },
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
commit('setUsers', { [response.data.username]: response.data })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
@ -209,7 +238,11 @@ const actions = {
}
}
try {
commit('updateUser', { username: data.username, loading: false, last_seen: new Date() })
commit('updateUser', {
username: data.username,
loading: false,
last_seen: new Date()
})
} catch {
// error
}
@ -218,11 +251,15 @@ const actions = {
commit('setAllUsersLoading', true)
try {
const response = await axios.get(url.searchUser, {
headers: { Token: rootState.login.user.accessToken }
headers: { Token: rootState.login.user.accessToken },
timeout
})
commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.data === 401) {
dispatch('getLifeTime', null, { root: true })
@ -240,13 +277,15 @@ const actions = {
userId: data.username,
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('updateMessage', { date: data.date, storno: true })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
@ -258,10 +297,14 @@ const actions = {
async getLocked({ commit, rootState, dispatch }) {
try {
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)
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
@ -274,10 +317,13 @@ const actions = {
const response = await axios.post(
url.barU.lock,
{ value: true },
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
commit('setLocked', response.data.value)
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) {
dispatch('getLifeTime', null, { root: true })
@ -290,7 +336,7 @@ const actions = {
const valid = await axios.post(
url.user.valid,
{ password: password },
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
if (valid.data.ok === 'ok') {
const response = await axios.post(
@ -301,6 +347,9 @@ const actions = {
commit('setLocked', response.data.value)
}
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) {
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'
// eslint-disable-next-line no-unused-vars
import url from '@/plugins/routes'
const timeout = 15000
const state = {
users: [],
activeUser: '',
@ -253,11 +253,15 @@ const actions = {
commit('setAllUsersLoading', true)
try {
const response = await axios.get(url.searchUser, {
headers: { Token: rootState.login.user.accessToken }
headers: { Token: rootState.login.user.accessToken },
timeout
})
commit('setAllUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response)
if (err.response.status === 401)
dispatch('logout', null, { root: true })
@ -268,11 +272,15 @@ const actions = {
commit('setUsersLoading', true)
try {
const response = await axios.get(url.getFinanzerMain, {
headers: { Token: rootState.login.user.accessToken }
headers: { Token: rootState.login.user.accessToken },
timeout
})
commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response)
if (err.response.status === 401)
dispatch('logout', null, { root: true })
@ -293,7 +301,7 @@ const actions = {
year: data.year,
month: data.month
},
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
const creditLists = { ...response.data }
delete creditLists.locked
@ -304,6 +312,9 @@ const actions = {
})
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response)
if (err.response.status === 401)
dispatch('logout', null, { root: true })
@ -321,7 +332,7 @@ const actions = {
year: data.year,
month: data.month
},
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
const creditLists = { ...response.data }
delete creditLists.locked
@ -332,6 +343,9 @@ const actions = {
})
dispatch('getLifeTime', null, { root: true })
} catch (err) {
if (err.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (err.response)
if (err.response.status === 401)
dispatch('logout', null, { root: true })
@ -344,11 +358,14 @@ const actions = {
const response = await axios.post(
url.lockUser,
{ userId: data.user.username, locked: data.locked },
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
commit('updateUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
@ -364,11 +381,14 @@ const actions = {
limit: data.limit * 100,
autoLock: data.autoLock
},
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
commit('updateUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
@ -380,11 +400,14 @@ const actions = {
const response = await axios.post(
url.finanzerAddUser,
{ userId: data.username },
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
commit('setUsers', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
@ -394,11 +417,15 @@ const actions = {
commit('setEMailLoading', true)
try {
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)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
@ -410,11 +437,14 @@ const actions = {
const response = await axios.post(
url.finanzerSendOneMail,
{ userId: data.username },
{ headers: { Token: rootState.login.user.accessToken } }
{ headers: { Token: rootState.login.user.accessToken }, timeout }
)
commit('setMail', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true })
}
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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