release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
2 changed files with 35 additions and 16 deletions
Showing only changes of commit 544d58889b - Show all commits

View File

@ -1,27 +1,27 @@
<template> <template>
<q-card class="col-12" height=""> <q-card class="col-12" height="">
<q-card-section v-if="isThisSession(session.token)" class="text-caption"> <q-card-section v-if="isThisSession(modelValue.token)" class="text-caption">
Diese Session. Diese Session.
</q-card-section> </q-card-section>
<q-card-section> <q-card-section>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
Browser: Browser:
<q-icon :name="getBrowserIcon(session.browser)" size="24px" /> <q-icon :name="getBrowserIcon(modelValue.browser)" size="24px" />
{{ session.browser }} {{ modelValue.browser }}
</div> </div>
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
Plattform: Plattform:
<q-icon :name="getPlatformIcon(session.platform)" size="24px" /> <q-icon :name="getPlatformIcon(modelValue.platform)" size="24px" />
{{ session.platform }} {{ modelValue.platform }}
</div> </div>
</div> </div>
<div v-if="!isEdit" class="row"> <div v-if="!isEdit" class="row">
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
Lebenszeit: Lebenszeit:
{{ session.lifetime }} {{ modelValue.lifetime }}
</div> </div>
<div class="col-xs-12 col-sm-6">Läuft aus: {{ dateTime(session.expires) }}</div> <div class="col-xs-12 col-sm-6">Läuft aus: {{ dateTime(modelValue.expires) }}</div>
</div> </div>
<div v-else class="row q-my-sm"> <div v-else class="row q-my-sm">
<q-input <q-input
@ -36,7 +36,7 @@
</q-card-section> </q-card-section>
<q-card-actions v-if="!isEdit" align="right"> <q-card-actions v-if="!isEdit" align="right">
<q-btn flat round dense icon="mdi-pencil" @click="edit(true)" /> <q-btn flat round dense icon="mdi-pencil" @click="edit(true)" />
<q-btn flat round dense icon="mdi-delete" @click="deleteSession(session.token)" /> <q-btn flat round dense icon="mdi-delete" @click="deleteSession(modelValue.token)" />
</q-card-actions> </q-card-actions>
<q-card-actions v-else align="right"> <q-card-actions v-else align="right">
<q-btn flat dense label="Abbrechen" @click="edit(false)" /> <q-btn flat dense label="Abbrechen" @click="edit(false)" />
@ -52,14 +52,18 @@ import { useMainStore } from 'src/store';
import { useSessionStore } from '../../store'; import { useSessionStore } from '../../store';
export default defineComponent({ export default defineComponent({
name: 'Sessions', name: 'Session',
props: { props: {
session: { modelValue: {
required: true, required: true,
type: Object as PropType<FG.Session>, type: Object as PropType<FG.Session>,
}, },
}, },
setup(props) { emits: {
'update:modelValue': (s: FG.Session) => !!s,
delete: () => true,
},
setup(props, { emit }) {
const sessionStore = useSessionStore(); const sessionStore = useSessionStore();
const mainStore = useMainStore(); const mainStore = useMainStore();
@ -94,6 +98,7 @@ export default defineComponent({
async function deleteSession(token: string) { async function deleteSession(token: string) {
await sessionStore.deleteSession(token); await sessionStore.deleteSession(token);
emit('delete');
} }
function isThisSession(token: string) { function isThisSession(token: string) {
return mainStore.session?.token === token; return mainStore.session?.token === token;
@ -131,14 +136,18 @@ export default defineComponent({
}); });
function edit(value: boolean) { function edit(value: boolean) {
lifetime.value = props.session.lifetime; lifetime.value = props.modelValue.lifetime;
isEdit.value = value; isEdit.value = value;
} }
async function save() { async function save() {
console.log(lifetime.value); console.log(lifetime.value);
isEdit.value = false; isEdit.value = false;
await sessionStore.updateSession(lifetime.value, props.session.token); await sessionStore.updateSession(lifetime.value, props.modelValue.token);
emit(
'update:modelValue',
Object.assign(Object.assign({}, props.modelValue), { lifetime: lifetime.value })
);
} }
return { return {

View File

@ -8,14 +8,19 @@
<MainUserSettings :user="currentUser" @update:user="updateUser" /> <MainUserSettings :user="currentUser" @update:user="updateUser" />
</q-card> </q-card>
<div class="col-12 text-left text-h6">Aktive Sessions:</div> <div class="col-12 text-left text-h6">Aktive Sessions:</div>
<sessions v-for="(session, index) in sessions" :key="'session' + index" :session="session" /> <Session
v-for="(session, index) in sessions"
:key="'session' + index"
v-model="sessions[index]"
@delete="removeSession(session)"
/>
</q-page> </q-page>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, onBeforeMount, ref } from 'vue'; import { defineComponent, onBeforeMount, ref } from 'vue';
import Sessions from '../components/settings/Sessions.vue'; import Session from '../components/settings/Sessions.vue';
import MainUserSettings from '../components/settings/MainUserSettings.vue'; import MainUserSettings from '../components/settings/MainUserSettings.vue';
import { useMainStore } from 'src/store'; import { useMainStore } from 'src/store';
import { useSessionStore } from '../store'; import { useSessionStore } from '../store';
@ -23,7 +28,7 @@ import { useUserStore } from '../store';
export default defineComponent({ export default defineComponent({
// name: 'PageName' // name: 'PageName'
components: { Sessions, MainUserSettings }, components: { Session, MainUserSettings },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();
const sessionStore = useSessionStore(); const sessionStore = useSessionStore();
@ -37,10 +42,15 @@ export default defineComponent({
await userStore.updateUser(value); await userStore.updateUser(value);
} }
function removeSession(s: FG.Session) {
sessions.value = sessions.value.filter((ss) => ss.token !== s.token);
}
return { return {
currentUser, currentUser,
sessions, sessions,
updateUser, updateUser,
removeSession,
}; };
}, },
}); });