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

@@ -15,8 +15,9 @@ const bodyParser = require( 'body-parser' );
const cookieParser = require( 'cookie-parser' ); const cookieParser = require( 'cookie-parser' );
const http = require( 'http' ); const http = require( 'http' );
const fs = require( 'fs' ); const fs = require( 'fs' );
const pm = require( './backend/plugins/manager.js' ); const token = require( './backend/token.js' );
const pluginManager = new pm(); // const pm = require( './backend/plugins/manager.js' );
// const pluginManager = new pm();
console.log( ` console.log( `
@@ -59,11 +60,10 @@ if ( settings.init ) {
app.use( express.static( '../webapp/setup/dist' ) ); app.use( express.static( '../webapp/setup/dist' ) );
} }
console.log( '[ Server ] loading and initializing middlewares' );
// initialise express with middlewares // initialise express with middlewares
// TODO: Generate random secret console.log( '[ Server ] loading and initializing middlewares' );
app.use( expressSession( { app.use( expressSession( {
secret: 'gaoevgoawefgo083tq2rfvöfaf0p8', secret: token.generateToken( 60 ),
resave: false, resave: false,
saveUninitialized: true, saveUninitialized: true,
cookie: { cookie: {

View File

View File

@@ -9,19 +9,27 @@
const pdfme = require( '@pdfme/generator' ); const pdfme = require( '@pdfme/generator' );
const db = require( '../db/db.js' );
class TicketGenerator { class TicketGenerator {
constructor () { constructor () {
this.ticketQueue = {}; this.ticketQueue = {};
} }
generateTicket ( ) { generateTicket ( data ) {
} }
ticketGenerator () { ticketGenerator ( event, data ) {
return new Promise( ( resolve, reject ) => { return new Promise( ( resolve, reject ) => {
db.getJSONDataSimple( event ).then( template => {
pdfme.generate( { template, data } ).then( pdf => {
resolve( pdf );
// TODO: Maybe write to disk
} ).catch( error => {
reject( error );
} );
} );
} ); } );
} }
} }

View File

@@ -9,7 +9,6 @@
<template> <template>
<div id="window"> <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> <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="parent" id="parent">
<div class="content-parent"> <div class="content-parent">
@@ -80,6 +79,7 @@
historyPos: 0, historyPos: 0,
generalSettings: { 'namingScheme': 'numeric' }, generalSettings: { 'namingScheme': 'numeric' },
seatCountInfo: { 'data': {}, 'count': 0 }, seatCountInfo: { 'data': {}, 'count': 0 },
autoSave: null,
} }
}, },
methods: { methods: {
@@ -93,6 +93,9 @@
reliably according to testing done. reliably according to testing done.
*/ */
runHook () { runHook () {
if ( !sessionStorage.getItem( 'locationID' ) ) {
this.$router.push( '/admin/events' );
}
let self = this; let self = this;
this.zoomFactor = sessionStorage.getItem( 'zoom' ) ? parseFloat( sessionStorage.getItem( 'zoom' ) ) : 1; 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) Calculate scale factor (this adds support for differently sized screens)
@@ -165,7 +169,7 @@
} ); } );
if ( !sessionStorage.getItem( 'seatplan-history' ) ) { 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' ) ) : {}; let history = sessionStorage.getItem( 'seatplan-history' ) ? JSON.parse( sessionStorage.getItem( 'seatplan-history' ) ) : {};
@@ -407,6 +411,7 @@
}, },
unmounted() { unmounted() {
clearInterval( this.sizePoll ); clearInterval( this.sizePoll );
clearInterval( this.autoSave );
}, },
} }
</script> </script>

View File

@@ -25,7 +25,8 @@
}, },
data () { data () {
return { return {
code: { '1': '', '2': '' } code: { '1': '', '2': '' },
serverPing: null,
} }
}, },
computed: { computed: {
@@ -61,14 +62,37 @@
}, false) }, false)
}, 300 ); }, 300 );
} else { } else {
// TODO: Add ping method (pings every 5 sec)
setTimeout( () => { setTimeout( () => {
this.$refs.notification.createNotification( 'Unsupported browser detected. Redirection might take longer to occur!', 20, 'warning', 'normal' ); this.$refs.notification.createNotification( 'Unsupported browser detected. Redirection might take longer to occur!', 20, 'warning', 'normal' );
}, 300 ); }, 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' ) : ''; let code = sessionStorage.getItem( '2faCode' ) ? sessionStorage.getItem( '2faCode' ) : '';
this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) }; this.code = { '1': code.slice( 0, 3 ), '2': code.substring( 3 ) };
}, },
unmounted() {
clearInterval( this.serverPing );
}
} }
</script> </script>

View File

View File

View File