2020-10-19 11:59:56 +00:00
|
|
|
<template>
|
|
|
|
<q-card class="col-12" height="">
|
|
|
|
<q-card-section v-if="isThisSession(session.token)" class="text-caption">
|
|
|
|
Diese Session.
|
|
|
|
</q-card-section>
|
|
|
|
<q-card-section>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12 col-sm-6">
|
|
|
|
Browser:
|
|
|
|
<q-icon :name="getBrowserIcon(session.browser)" size="24px" />
|
|
|
|
{{ session.browser }}
|
|
|
|
</div>
|
|
|
|
<div class="col-xs-12 col-sm-6">
|
|
|
|
Plattform:
|
|
|
|
<q-icon :name="getPlatformIcon(session.platform)" size="24px" />
|
|
|
|
{{ session.platform }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12 col-sm-6">
|
|
|
|
Lebenszeit:
|
|
|
|
{{ session.lifetime }}
|
|
|
|
</div>
|
|
|
|
<div class="col-xs-12 col-sm-6">Läuft aus: {{ session.expires }}</div>
|
|
|
|
</div>
|
|
|
|
</q-card-section>
|
|
|
|
<q-card-actions align="right">
|
|
|
|
<q-btn
|
|
|
|
flat
|
|
|
|
round
|
|
|
|
dense
|
|
|
|
icon="mdi-delete"
|
|
|
|
@click="deleteSession(session.token)"
|
|
|
|
/>
|
|
|
|
</q-card-actions>
|
|
|
|
</q-card>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-28 23:10:45 +00:00
|
|
|
import { defineComponent } from '@vue/composition-api';
|
2020-10-29 00:39:06 +00:00
|
|
|
import { Store } from 'vuex';
|
|
|
|
import { StateInterface } from 'src/store';
|
|
|
|
|
2020-10-19 11:59:56 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'Sessions',
|
|
|
|
props: {
|
|
|
|
session: {
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setup(_, { root }) {
|
2020-10-29 00:39:06 +00:00
|
|
|
const store = <Store<StateInterface>>root.$store;
|
|
|
|
|
2020-10-19 11:59:56 +00:00
|
|
|
function getBrowserIcon(browser: string) {
|
|
|
|
return browser == 'firefox'
|
|
|
|
? 'mdi-firefox'
|
|
|
|
: browser == 'chrome'
|
|
|
|
? 'mdi-google-chrome'
|
|
|
|
: browser == 'safari'
|
|
|
|
? 'mdi-apple-safari'
|
|
|
|
: 'mdi-help';
|
|
|
|
}
|
2020-10-29 00:39:06 +00:00
|
|
|
|
2020-10-19 11:59:56 +00:00
|
|
|
function getPlatformIcon(platform: string) {
|
|
|
|
return platform == 'linux'
|
|
|
|
? 'mdi-linux'
|
|
|
|
: platform == 'windows'
|
|
|
|
? 'mdi-microsoft-windows'
|
2020-10-31 18:33:05 +00:00
|
|
|
: platform == 'macos'
|
2020-10-19 11:59:56 +00:00
|
|
|
? 'mdi-apple'
|
2020-10-31 21:37:28 +00:00
|
|
|
: platform == 'iphone'
|
|
|
|
? 'mdi-cellphone-iphone'
|
|
|
|
: platform == 'android'
|
|
|
|
? 'mdi-cellphone-android'
|
2020-10-19 11:59:56 +00:00
|
|
|
: 'mdi-help';
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteSession(token: string) {
|
2020-10-29 00:39:06 +00:00
|
|
|
store.dispatch('sessions/deleteSession', token).catch(error => {
|
2020-10-28 23:10:45 +00:00
|
|
|
console.warn(error);
|
|
|
|
});
|
2020-10-19 11:59:56 +00:00
|
|
|
}
|
|
|
|
function isThisSession(token: string) {
|
2020-10-29 00:39:06 +00:00
|
|
|
return store.state.user.session.token == token;
|
2020-10-19 11:59:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
getBrowserIcon,
|
|
|
|
getPlatformIcon,
|
|
|
|
isThisSession,
|
|
|
|
deleteSession
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|