clean up some todos

This commit is contained in:
2023-07-31 15:47:10 +02:00
parent 6083ec262c
commit 9827bb2c69
8 changed files with 50 additions and 13 deletions

View File

@@ -9,7 +9,6 @@
<template>
<div id="window">
<!-- TODO: Add additional div with v-if to check if a location has been selected and warn if not so. -->
<properties class="properties" v-model:draggables="draggables" @updated="handleUpdate" :scale-factor="scaleFactor" :active="active" :history-pos="historyPos" :zoom-factor="zoomFactor" v-model:general-settings="generalSettings"></properties>
<div class="parent" id="parent">
<div class="content-parent">
@@ -80,6 +79,7 @@
historyPos: 0,
generalSettings: { 'namingScheme': 'numeric' },
seatCountInfo: { 'data': {}, 'count': 0 },
autoSave: null,
}
},
methods: {
@@ -93,6 +93,9 @@
reliably according to testing done.
*/
runHook () {
if ( !sessionStorage.getItem( 'locationID' ) ) {
this.$router.push( '/admin/events' );
}
let self = this;
this.zoomFactor = sessionStorage.getItem( 'zoom' ) ? parseFloat( sessionStorage.getItem( 'zoom' ) ) : 1;
@@ -128,7 +131,8 @@
}
};
// TODO: Create 1min interval saving
// Auto save every 60s (60K ms)
this.autoSave = setInterval( this.saveDraft(), 60000 );
/*
Calculate scale factor (this adds support for differently sized screens)
@@ -165,7 +169,7 @@
} );
if ( !sessionStorage.getItem( 'seatplan-history' ) ) {
sessionStorage.setItem( 'seatplan-history', JSON.stringify( { '1': this.scaleDown( this.draggables ) } ) );
sessionStorage.setItem( 'seatplaTODO:n-history', JSON.stringify( { '1': this.scaleDown( this.draggables ) } ) );
}
let history = sessionStorage.getItem( 'seatplan-history' ) ? JSON.parse( sessionStorage.getItem( 'seatplan-history' ) ) : {};
@@ -407,6 +411,7 @@
},
unmounted() {
clearInterval( this.sizePoll );
clearInterval( this.autoSave );
},
}
</script>

View File

@@ -25,7 +25,8 @@
},
data () {
return {
code: { '1': '', '2': '' }
code: { '1': '', '2': '' },
serverPing: null,
}
},
computed: {
@@ -61,14 +62,37 @@
}, false)
}, 300 );
} else {
// TODO: Add ping method (pings every 5 sec)
setTimeout( () => {
this.$refs.notification.createNotification( 'Unsupported browser detected. Redirection might take longer to occur!', 20, 'warning', 'normal' );
}, 300 );
// ping server every 5s to check if logged in
this.serverPing = setInterval( () => {
fetch( '/user/2fa/ping' ).then( res => {
if ( res.status === 200 ) {
res.json().then( data => {
if ( data ) {
if ( data.status === 'ok' ) {
this.userStore.setUserAuth( true );
this.$router.push( sessionStorage.getItem( 'redirect' ) ?? '/account' );
}
}
} );
} else {
console.error( 'Request failed' );
this.$refs.notification.createNotification( 'We are sorry, but an error occurred. You will not be redirected automatically', 300, 'error', 'normal' );
}
} ).catch( error => {
console.error( error );
this.$refs.notification.createNotification( 'We are sorry, but an error occurred. You will not be redirected automatically', 300, 'error', 'normal' );
} );
}, 5000 );
}
let code = sessionStorage.getItem( '2faCode' ) ? sessionStorage.getItem( '2faCode' ) : '';
this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) };
},
unmounted() {
clearInterval( this.serverPing );
}
}
</script>