various changes

This commit is contained in:
2023-08-23 11:58:37 +02:00
parent eacaebd84b
commit c3179194b8
9 changed files with 102 additions and 49 deletions

View File

@@ -1,25 +1,21 @@
# Account view:
- create function that parses DB every 15 minutes and clears out junk --> Also update data in db when user goes to purchase to prevent clearing during purchase
- Require user to confirm email before purchasing
- Also update data in db when user goes to purchase to prevent clearing during purchase
- Load all orders of customer from db when selecting tickets and save to memory to check if ticket count has been exceeded or not.
- Create function that updates currency for every event when updating currency.
- Update files to import when deploying for included json files instead of secret.json files
- Fix text field overflow (text too big for box)
- Other optimization for seat plan editor
- Implement Permission system
- Seat numbering!!
- FUTURE: Implement Permission system
- FUTURE: Add Admin profile (page to change account settings per person like changing pwd)
- FUTURE add multi-language support
- FUTURE: Guest purchase

View File

@@ -62,6 +62,16 @@ class GETHandler {
} ).catch( error => {
reject( { 'code': 500, 'error': error } );
} );
} else if ( call === 'getEventStatus' ) {
db.getJSONDataSimple( 'events', query.event ).then( data => {
if ( Object.keys( data ) ) {
resolve( true );
} else {
resolve( false );
}
} ).catch( error => {
reject( { 'code': 500, 'error': error } );
} );
} else if ( call === 'getAllEvents' ) {
db.getJSONData( 'eventDrafts' ).then( data => {
db.getJSONData( 'events' ).then( dat => {

View File

@@ -11,6 +11,8 @@ const db = require( '../../backend/db/db.js' );
const fs = require( 'fs' );
const path = require( 'path' );
const letters = [ ',', '{' ];
class POSTHandler {
constructor ( settings ) {
this.settings = settings;
@@ -118,7 +120,19 @@ class POSTHandler {
this.settings[ 'twoFA' ] = data.twoFA;
this.settings[ 'currency' ] = data.currency;
this.settings[ 'payments' ] = data.payments;
fs.writeFileSync( path.join( __dirname + '/../../config/settings.config.json' ), JSON.stringify( this.settings ) );
this.settings[ 'ticketTimeout' ] = data.ticketTimeout;
const settingsString = JSON.stringify( this.settings );
let settingsToSave = '';
for ( let letter in settingsString ) {
if ( letters.includes( settingsString[ letter ] ) ) {
settingsToSave += settingsString[ letter ] + '\n\t';
} else if ( settingsString[ letter ] === '}' ) {
settingsToSave += '\n' + settingsString[ letter ];
} else {
settingsToSave += settingsString[ letter ];
}
}
fs.writeFileSync( path.join( __dirname + '/../../config/settings.config.json' ), settingsToSave );
db.getJSONData( 'events' ).then( dat => {
let updated = dat;
for ( let event in updated ) {

View File

@@ -52,6 +52,18 @@ class GETHandler {
} ).catch( error => {
reject( { 'code': 500, 'error': error } );
} );
} else if ( call === 'extendTicketDeletion' ) {
db.getDataSimple( 'temp', 'user_id', session.id ).then( res => {
if ( res[ 0 ] ) {
db.writeDataSimple( 'temp', 'user_id', session.id, { 'timestamp': new Date().toString() } );
// TODO: make sure it works, seems to be still unreliable
resolve( 'extended' );
} else {
reject( { 'code': 404, 'error': 'UserNotFound' } );
}
} ).catch( error => {
reject( { 'code': 500, 'error': error } );
} );
} else if ( call === 'getName' ) {
resolve( { 'name': settings.name } );
} else {

View File

@@ -1 +1 @@
{}
{"libreevent_temp":{"1":{"user_id":"Vw5d2Ak1jgC9Bj8Q-PzB2O0M1pc4QkR_","timestamp":"Wed Aug 23 2023 11:56:21 GMT+0200 (Central European Summer Time)","data":"{\"test4\":{\"secAr4s10\":{\"id\":\"secAr4s10\",\"component\":1,\"ticketOption\":\"2\",\"eventID\":\"test4\",\"category\":\"1\",\"name\":\"Row 5, Seat 11\"}}}"}},"libreevent_admin":{},"libreevent_orders":{},"libreevent_users":{}}

View File

@@ -208,7 +208,7 @@ const gc = () => {
*/
setInterval( () => {
gc();
}, parseInt( settings.gcInterval ) );
}, parseInt( settings.gcInterval ) * 1000 );
// TODO: Build garbage collector for DB (parse DB every so often (get from settings)
// and delete all items where timestamp is older than a certain amount of time (get from settings))

View File

@@ -10,6 +10,6 @@
"mailSender":"libreevent <info@libreevent.janishutz.com>",
"maxTickets":10,
"currency":"CHF",
"gcInterval": "600",
"ticketTimeout": "900"
"gcInterval":300,
"ticketTimeout":900
}

View File

@@ -87,6 +87,41 @@
},
}
},
'currency': {
'display': 'Currency',
'id': 'currency',
'tooltip':'Specify a currency in which the prices are displayed to the customer. Defaults to USD. Please use valid currency codes.',
'value': 'USD',
'type': 'text',
},
'ticketTimeout': {
'display': 'Ticket Timeout (s)',
'id': 'ticketTimeout',
'tooltip': 'Specify how long the user has to be inactive for their order to be canceled. Time is to be specified in seconds',
'value': 900,
'type': 'number',
'restrictions': {
'min': 0,
'max': 10000,
}
},
'paymentGateway': {
'display': 'Select the payment gateway to use',
'id': 'paymentGateway',
'tooltip':'With this setting you may change which payment gateway you want to use. You will need to provide details below! If you are not sure what this setting means, please click the link below.',
'value': 'stripe',
'type': 'select',
'restrictions': {
'payrexx': {
'displayName':'Payrexx',
'value': 'payrexx'
},
'stripe': {
'displayName':'Stripe',
'value': 'stripe'
},
}
},
// 'addressRequired': {
// 'display': 'Require user to provide address?',
// 'id': 'addressRequired',
@@ -108,30 +143,6 @@
// 'value': false,
// 'type': 'toggle',
// },
'currency': {
'display': 'Currency',
'id': 'currency',
'tooltip':'Specify a currency in which the prices are displayed to the customer. Defaults to USD. Please use valid currency codes.',
'value': 'USD',
'type': 'text',
},
'paymentGateway': {
'display': 'Select the payment gateway to use',
'id': 'paymentGateway',
'tooltip':'With this setting you may change which payment gateway you want to use. You will need to provide details below! If you are not sure what this setting means, please click the link below.',
'value': 'stripe',
'type': 'select',
'restrictions': {
'payrexx': {
'displayName':'Payrexx',
'value': 'payrexx'
},
'stripe': {
'displayName':'Stripe',
'value': 'stripe'
},
}
},
}
}
},
@@ -243,6 +254,7 @@
this.settings[ '2fa' ].value = json.twoFA;
this.settings.currency.value = json.currency;
this.settings.paymentGateway.value = json.payments;
this.settings.ticketTimeout.value = json.ticketTimeout;
} );
}
} );
@@ -250,7 +262,12 @@
save() {
let fetchOptions = {
method: 'post',
body: JSON.stringify( { 'twoFA': this.settings[ '2fa' ].value, 'currency': this.settings.currency.value, 'payments': this.settings.paymentGateway.value } ),
body: JSON.stringify( {
'twoFA': this.settings[ '2fa' ].value,
'currency': this.settings.currency.value,
'payments': this.settings.paymentGateway.value,
'ticketTimeout': this.settings.ticketTimeout.value,
} ),
headers: {
'Content-Type': 'application/json',
'charset': 'utf-8'
@@ -268,7 +285,7 @@
this.loadData();
}
};
// TODO: Load gateways and settings in general from server.
// TODO: Load gateways and settings for gateways from server.
</script>

View File

@@ -286,7 +286,11 @@
if ( !sessionStorage.getItem( 'selectedTicket' ) ) {
this.$router.push( '/admin/events' );
}
// TODO: Check if there is a live version of the event
fetch( localStorage.getItem( 'url' ) + '/admin/getAPI/getEventStatus' ).then( res => {
res.text().then( status => {
this.hasLiveVersion = Boolean( status );
} );
} );
this.eventID = sessionStorage.getItem( 'selectedTicket' );
fetch( localStorage.getItem( 'url' ) + '/admin/getAPI/getLocations' ).then( res => {
res.json().then( data => {