various small changes and fixes

This commit is contained in:
2023-08-19 13:35:46 +02:00
parent 6051b18796
commit 71a2927372
11 changed files with 35 additions and 15 deletions

View File

@@ -75,9 +75,13 @@ class GETHandler {
} else if ( call === 'getCurrency' ) {
resolve( this.settings.currency );
} else if ( call === 'getAdminAccounts' ) {
// TODO: Finish
db.getData( 'admin' ).then( data => {
resolve( data );
} ).catch( err => {
reject( { 'code': 500, 'message': 'ERR_DB: ' + err } );
} );
} else if ( call === 'getPaymentGatewaySettings' ) {
// TODO: Finish
// TODO: Finish with plugin manager
} else if ( call === 'getSettings' ) {
resolve( this.settings );
} else {

View File

@@ -29,11 +29,11 @@ class POSTHandler {
}
}
console.log( this.ticketTotals );
// console.log( this.ticketTotals );
// for ( let order in this.allSelectedSeats ) {
// }
console.log( this.allSelectedSeats );
// console.log( this.allSelectedSeats );
} );
} );
} );

View File

@@ -36,6 +36,16 @@ module.exports.getDataSimple = ( db, column, searchQuery ) => {
} );
};
module.exports.getData = ( db ) => {
return new Promise( ( resolve, reject ) => {
dbh.query( { 'command': 'getAllData' }, dbRef[ db ] ).then( data => {
resolve( data );
} ).catch( error => {
reject( error );
} );
} );
};
module.exports.writeDataSimple = ( db, column, searchQuery, data ) => {
return new Promise( ( resolve, reject ) => {
dbh.query( { 'command': 'checkDataAvailability', 'property': column, 'searchQuery': searchQuery }, dbRef[ db ] ).then( res => {

View File

@@ -65,7 +65,7 @@ class SQLDB {
} );
this.sqlConnection.query( 'CREATE TABLE libreevent_users ( account_id INT ( 10 ) NOT NULL AUTO_INCREMENT, email TINYTEXT NOT NULL, pass TEXT, name TEXT, first_name TEXT, two_fa TINYTEXT, user_data VARCHAR( 60000 ), mail_confirmed TINYTEXT, marketing TINYTEXT, PRIMARY KEY ( account_id ) ) ENGINE=INNODB;', ( error ) => {
if ( error ) if ( error.code !== 'ER_TABLE_EXISTS_ERROR' ) throw error;
this.sqlConnection.query( 'CREATE TABLE libreevent_orders ( order_id INT ( 10 ) NOT NULL AUTO_INCREMENT, order_name TINYTEXT, account_id INT ( 10 ) NOT NULL, tickets VARCHAR( 60000 ), processed TINYTEXT, PRIMARY KEY ( order_id ), FOREIGN KEY ( account_id ) REFERENCES libreevent_users( account_id ) ) ENGINE=INNODB;', ( error ) => {
this.sqlConnection.query( 'CREATE TABLE libreevent_orders ( order_id INT ( 10 ) NOT NULL AUTO_INCREMENT, order_name TINYTEXT, account_id INT ( 10 ) NOT NULL, tickets VARCHAR( 60000 ), processed TINYTEXT, timestamp TINYTEXT, PRIMARY KEY ( order_id ), FOREIGN KEY ( account_id ) REFERENCES libreevent_users( account_id ) ) ENGINE=INNODB;', ( error ) => {
if ( error ) if ( error.code !== 'ER_TABLE_EXISTS_ERROR' ) throw error;
this.sqlConnection.query( 'CREATE TABLE libreevent_admin ( account_id INT NOT NULL AUTO_INCREMENT, email TINYTEXT, pass TEXT, permissions VARCHAR( 1000 ), username TINYTEXT, two_fa TINYTEXT, PRIMARY KEY ( account_id ) );', ( error ) => {
if ( error ) if ( error.code !== 'ER_TABLE_EXISTS_ERROR' ) throw error;

View File

@@ -33,9 +33,19 @@ class TicketGenerator {
this.events = events;
} );
this.runningTickets = {};
db.getData( 'orders' ).then( orders => {
for ( let order in orders ) {
if ( orders[ order ][ 'processed' ] != 'true' ) {
this.ticketQueue[ this.jobId ] = { 'order': orders[ order ][ 'order_name' ] };
this.jobId += 1;
}
}
if ( this.jobId > 0 ) {
this.queueHandler();
}
} );
}
// TODO: continue processing once back online
generateTickets ( order ) {
this.ticketQueue[ this.jobId ] = { 'order': order };
this.runningTickets[ order.tok ] = 'processing';
@@ -96,7 +106,6 @@ class TicketGenerator {
} ).catch( error => {
console.error( '[ PDF GENERATOR ] ERROR: ' + error );
this.isRunning = false;
// TODO: Add to FAILED db
} );
}
}