diff --git a/src/components/user/Config.vue b/src/components/user/Config.vue index 6d4fa8b..2cd036c 100644 --- a/src/components/user/Config.vue +++ b/src/components/user/Config.vue @@ -162,11 +162,83 @@ append-icon > +
+ Gespeicherte Sessions +
+ + + + OS: + + {{ + token.platform === 'macos' || token.platform === 'iphone' + ? apple + : token.platform === 'windows' + ? windows + : token.platfrom === 'android' + ? android + : token.platform + }} + + + {{ token.platform === 'macos' ? mac : iphone }} + + + + Browser: + + {{ + token.browser === 'chrome' + ? chrome + : token.browser === 'firefox' + ? firefox + : token.browser === 'opera' + ? opera + : token.browser === 'safari' + ? safari + : token.browser + }} + + + + Letzter Aktualisierung: {{ token.timestamp.day }}.{{ + token.timestamp.month + }}.{{ token.timestamp.year }} um + {{ + 10 > token.timestamp.hour + ? '0' + String(token.timestamp.hour) + : token.timestamp.hour + }}:{{ + 10 > token.timestamp.minute + ? '0' + String(token.timestamp.minute) + : token.timestamp.minute + }}:{{ + 10 > token.timestamp.second + ? '0' + String(token.timestamp.second) + : token.timestamp.second + }} + + Lebenszeit: {{ calcLifefime(token.lifetime) }} + + + + {{trashCan}} + + + + + + @@ -184,13 +256,34 @@ import { mdiAccount, mdiGlassCocktail, mdiCurrencyEur, - mdiFoodForkDrink + mdiFoodForkDrink, + mdiApple, + mdiGoogleChrome, + mdiFirefox, + mdiOpera, + mdiInternetExplorer, + mdiAppleSafari, + mdiLaptopMac, + mdiCellphoneIphone, + mdiTrashCan, + mdiAndroid, + mdiWindows } from '@mdi/js' import { mapGetters, mapActions } from 'vuex' export default { name: 'Config', data() { return { + apple: mdiApple, + mac: mdiLaptopMac, + iphone: mdiCellphoneIphone, + android: mdiAndroid, + mdiWindows: mdiWindows, + chrome: mdiGoogleChrome, + firefox: mdiFirefox, + opera: mdiOpera, + ie: mdiInternetExplorer, + safari: mdiAppleSafari, person: mdiAccount, bar: mdiGlassCocktail, finanzer: mdiCurrencyEur, @@ -201,6 +294,7 @@ export default { lastname: null, password: null, controlPassword: null, + trashCan: mdiTrashCan, isFulllineText: false, equal_password: value => this.password === value || 'Passwörter sind nicht identisch.', @@ -222,7 +316,9 @@ export default { methods: { ...mapActions({ saveConfig: 'user/saveConfig', - getStatus: 'user/getStatus' + getStatus: 'user/getStatus', + getTokens: 'user/getTokens', + deleteToken: 'user/deleteToken' }), getWindowWidth() { this.isFulllineText = document.documentElement.clientWidth <= 600 @@ -241,6 +337,21 @@ export default { this.saveConfig({ oldUsername: user.username, ...user }) this.password = null this.controlPassword = null + }, + calcLifefime(time) { + if (time < 60) return String(time) + 'Sekunden' + time = Math.round(time / 60) + if (time < 60) return String(time) + 'Minuten' + time = Math.round(time / 60) + if (time < 24) return String(time) + 'Stunden' + time = Math.round(time / 24) + if (time < 7) return String(time) + 'Tage' + time = Math.round(time / 7) + if (time < 30) return String(time) + 'Wochen' + time = Math.round(time / 30) + if (time < 12) return String(time) + 'Monate' + time = Math.round(time / 12) + return String(time) + 'Jahre' } }, computed: { @@ -248,7 +359,8 @@ export default { user: 'user/user', error: 'user/error', loading: 'user/loading', - status: 'user/status' + status: 'user/status', + tokens: 'user/tokens' }), lock() { return this.user.locked ? 'gesperrt' : 'nicht gesperrt' @@ -272,6 +384,7 @@ export default { }, created() { this.getStatus() + this.getTokens() } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 57d97c4..f0c7d92 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -72,7 +72,8 @@ const url = { storno: main + 'user/storno', getAllStatus: main + 'getAllStatus', getStatus: main + 'getStatus', - valid: main + 'valid' + valid: main + 'valid', + getAccessTokens: main + 'user/getAccessTokens' }, barU: { storno: main + 'bar/storno', diff --git a/src/store/modules/jobRequests.js b/src/store/modules/jobRequests.js index cf9af9e..92c8df1 100644 --- a/src/store/modules/jobRequests.js +++ b/src/store/modules/jobRequests.js @@ -158,13 +158,11 @@ const mutations = { : [] } }) - console.log(mop) }, setDayLoading: (state, { getters, date, value }) => { let day = getters.getDayToMe(date) day.forEach(a => { a.day.loading = value - console.log('day', value ? 'loading' : 'not loading', day, a.day.loading) }) }, deleteJobRequestFromMe: (state, jobrequest) => { @@ -240,7 +238,6 @@ const actions = { to_me.data, { headers: { Token: rootState.login.user.accessToken } } ) - console.log(to_me.data) commit('setJobRequestsToMe', to_me.data) workers_to_me.data.forEach(item => { var date = new Date( diff --git a/src/store/modules/login.js b/src/store/modules/login.js index f199244..dc45cd0 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -157,9 +157,7 @@ const actions = { }) commit('setLifeTime', response.data.value) var user = JSON.parse(localStorage.getItem('user')) - console.log('user',user) user.group = response.data.group - console.log('after',user) localStorage.setItem('user', JSON.stringify(user)) commit('updateAccessToken', user) } catch (e) { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 7c3fce4..26d2686 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -9,7 +9,8 @@ const state = { error: '', days: [], messages: [], - status: [] + status: [], + tokens: [] } const mutations = { @@ -29,6 +30,10 @@ const mutations = { state.creditList = [] state.error = '' }, + setTokens: (state, tokens) => { + state.tokens = tokens + console.log(state.tokens) + }, createAmount(creditList) { let amount = { type: 'Schulden', @@ -317,6 +322,28 @@ const actions = { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) } + }, + async getTokens({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.user.getAccessTokens, {headers: {Token: rootState.login.user.accessToken}}) + commit('setTokens', response.data) + dispatch('getLifeTime', null, { root: true }) + console.log('hier bin ich') + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteToken({ commit, rootState, dispatch }, token) { + try { + const response = await axios.post(url.user.getAccessTokens, token,{headers: {Token: rootState.login.user.accessToken}}) + commit('setTokens', response.data) + dispatch('getLifeTime', null, { root: true }) + console.log('hier bin ich') + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } } } @@ -349,6 +376,9 @@ const getters = { }, status: state => { return state.status + }, + tokens: state => { + return state.tokens } }