-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added text and styling to SessionCheckerPopup, exported session check…
…ing from checkActiveSession
- Loading branch information
Felix Ruf
committed
Jul 11, 2024
1 parent
a5aab74
commit ddc29ea
Showing
7 changed files
with
93 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<template> | ||
<div> | ||
<PopupModal :isOpen="isOpen"> | ||
<div class="max-w-[300px] p-4"> | ||
<h4 class="text-center align-middle"> | ||
{{ t('session.timeout_header') }} | ||
</h4> | ||
<p class="text-center align-middle"> | ||
{{ t('session.timeout_text') }} | ||
</p> | ||
<CreateButton | ||
class="cursor-pointer" | ||
:btnText="t('session.reload')" | ||
:managed="true" | ||
@click="handleReload()" | ||
/> | ||
</div> | ||
</PopupModal> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import PopupModal from '@/components/misc/PopupModal.vue'; | ||
import CreateButton from '@/components/misc/CreateButton.vue'; | ||
import { onMounted, ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import { saveAndReload, isSessionActive } from '@/tools/checkActiveSession'; | ||
const { t } = useI18n(); | ||
// 600.000 | ||
const TEN_MINUTES_MILLIS = 600000; | ||
const isOpen = ref(false); | ||
const timestamp = ref<number>(0); | ||
onMounted(() => { | ||
timestamp.value = Date.now(); | ||
window.addEventListener('focus', () => checkSessionCallback()); | ||
}); | ||
function handleReload() { | ||
isOpen.value = false; | ||
saveAndReload(); | ||
} | ||
async function checkSessionCallback() { | ||
if (Date.now() - timestamp.value > TEN_MINUTES_MILLIS) { | ||
try { | ||
timestamp.value = Date.now(); | ||
const sessionActive = await isSessionActive(); | ||
isOpen.value = !sessionActive; | ||
} catch (error) { | ||
isOpen.value = true; | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters