mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
various fixes
This commit is contained in:
@@ -8,9 +8,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const db = require( '../../backend/db/db.js' );
|
const db = require( '../../backend/db/db.js' );
|
||||||
|
const pm = require( '../../backend/plugins/manager.js' );
|
||||||
|
|
||||||
class GETHandler {
|
class GETHandler {
|
||||||
constructor ( settings ) {
|
constructor ( settings ) {
|
||||||
|
this.pluginManager = new pm( settings );
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +93,7 @@ class GETHandler {
|
|||||||
reject( { 'code': 500, 'message': 'ERR_DB: ' + err } );
|
reject( { 'code': 500, 'message': 'ERR_DB: ' + err } );
|
||||||
} );
|
} );
|
||||||
} else if ( call === 'getPaymentGatewaySettings' ) {
|
} else if ( call === 'getPaymentGatewaySettings' ) {
|
||||||
// TODO: Finish with plugin manager
|
pluginManager.loadPaymentGatewaySettings();
|
||||||
} else if ( call === 'getSettings' ) {
|
} else if ( call === 'getSettings' ) {
|
||||||
resolve( this.settings );
|
resolve( this.settings );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,11 +10,13 @@
|
|||||||
const db = require( '../../backend/db/db.js' );
|
const db = require( '../../backend/db/db.js' );
|
||||||
const fs = require( 'fs' );
|
const fs = require( 'fs' );
|
||||||
const path = require( 'path' );
|
const path = require( 'path' );
|
||||||
|
const pm = require( '../../backend/plugins/manager.js' );
|
||||||
|
|
||||||
const letters = [ ',', '{' ];
|
const letters = [ ',', '{' ];
|
||||||
|
|
||||||
class POSTHandler {
|
class POSTHandler {
|
||||||
constructor ( settings ) {
|
constructor ( settings ) {
|
||||||
|
this.pluginManager = new pm( settings );
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"test4":{"secAr4s7":{"id":"secAr4s7","component":1,"ticketOption":"1","eventID":"test4","category":"1","name":"Row 5, Seat 8"}}}
|
{"test4":{"secAr4s7":{"id":"secAr4s7","component":1,"ticketOption":"1","eventID":"test4","category":"1","name":"Row 5, Seat 8"},"secAr6s14":{"id":"secAr6s14","component":1,"ticketOption":"2","eventID":"test4","category":"1","name":"Row 7, Seat 15"}}}
|
||||||
@@ -47,7 +47,6 @@ module.exports.getData = ( db ) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.writeDataSimple = ( db, column, searchQuery, data ) => {
|
module.exports.writeDataSimple = ( db, column, searchQuery, data ) => {
|
||||||
console.log( 'writingData' );
|
|
||||||
return new Promise( ( resolve, reject ) => {
|
return new Promise( ( resolve, reject ) => {
|
||||||
dbh.query( { 'command': 'checkDataAvailability', 'property': column, 'searchQuery': searchQuery }, dbRef[ db ] ).then( res => {
|
dbh.query( { 'command': 'checkDataAvailability', 'property': column, 'searchQuery': searchQuery }, dbRef[ db ] ).then( res => {
|
||||||
if ( res.length > 0 ) {
|
if ( res.length > 0 ) {
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ class JSONDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect () {
|
connect () {
|
||||||
let data = JSON.parse( fs.readFileSync( path.join( __dirname + '/data/db.json' ) ) );
|
let data = {};
|
||||||
|
try {
|
||||||
|
JSON.parse( fs.readFileSync( path.join( __dirname + '/data/db.json' ) ) );
|
||||||
|
} catch ( err ) {}
|
||||||
this.db = data[ 'db' ] ?? { 'libreevent_temp': {}, 'libreevent_admin': {}, 'libreevent_orders': {}, 'libreevent_users': {} };
|
this.db = data[ 'db' ] ?? { 'libreevent_temp': {}, 'libreevent_admin': {}, 'libreevent_orders': {}, 'libreevent_users': {} };
|
||||||
this.dbIndex = data[ 'index' ] ?? { 'libreevent_temp': 0, 'libreevent_admin': 0, 'libreevent_orders': 0, 'libreevent_users': 0 };
|
this.dbIndex = data[ 'index' ] ?? { 'libreevent_temp': 0, 'libreevent_admin': 0, 'libreevent_orders': 0, 'libreevent_users': 0 };
|
||||||
this.db[ 'libreevent_temp' ] = {};
|
this.db[ 'libreevent_temp' ] = {};
|
||||||
|
|||||||
@@ -11,13 +11,47 @@
|
|||||||
This is the plugin manager. It is responsible for installing, updating and uninstalling plugins.
|
This is the plugin manager. It is responsible for installing, updating and uninstalling plugins.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const fs = require( 'fs' );
|
||||||
|
const path = require( 'path' );
|
||||||
|
|
||||||
class PluginManager {
|
class PluginManager {
|
||||||
constructor () {}
|
constructor ( settings ) {
|
||||||
|
this.paymentGateway = settings.payments;
|
||||||
|
this.allPlugins = {};
|
||||||
|
fs.readdir( path.join( __dirname + '/others' ), ( err, ls ) => {
|
||||||
|
for ( let file in ls ) {
|
||||||
|
const pluginSettings = JSON.parse( fs.readFileSync( path.join( __dirname + '/others/' + ls[ file ] + '/plugin.json' ) ) );
|
||||||
|
this.allPlugins[ ls[ file ] ] = pluginSettings;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
loadSettings ( plugin ) {
|
getPlugins () {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPluginDetails ( plugin ) {
|
||||||
|
return new Promise( ( resolve, reject ) => {
|
||||||
|
fs.readFile( path.join( __dirname + '/others/' + plugin + '/plugin.json' ), ( err, file ) => {
|
||||||
|
resolve( file );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
loadPaymentGatewaySettings () {
|
||||||
|
return new Promise( ( resolve, reject ) => {
|
||||||
|
fs.readFile( path.join( __dirname + '/payments/' + this.paymentGateway + '/configOptions.json' ), ( err, options ) => {
|
||||||
|
fs.readFile( path.join( __dirname + '/payments/' + this.paymentGateway + '/config.payments.json' ), ( err, config ) => {
|
||||||
|
let f = options;
|
||||||
|
for ( let s in f ) {
|
||||||
|
f[ s ][ 'value' ] = config[ s ];
|
||||||
|
}
|
||||||
|
resolve( f );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
saveSettings ( plugin, settings ) {
|
saveSettings ( plugin, settings ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,11 +172,14 @@ module.exports = ( app, settings ) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.writeJSONData( 'booked', booked ).then( () => {
|
db.writeJSONData( 'booked', booked ).then( () => {
|
||||||
|
db.deleteDataSimple( 'temp', 'user_id', sessionReference[ event.data.object.id ][ 'tok' ] ).then( () => {
|
||||||
delete pendingPayments[ sessionReference[ event.data.object.id ][ 'tok' ] ];
|
delete pendingPayments[ sessionReference[ event.data.object.id ][ 'tok' ] ];
|
||||||
} );
|
} ).catch( error => {
|
||||||
db.deleteDataSimple( 'temp', 'user_id', sessionReference[ event.data.object.id ][ 'tok' ] ).catch( error => {
|
|
||||||
console.error( '[ STRIPE ] ERROR whilst deleting data from DB: ' + error );
|
console.error( '[ STRIPE ] ERROR whilst deleting data from DB: ' + error );
|
||||||
} );
|
} );
|
||||||
|
} ).catch( err => {
|
||||||
|
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Binary file not shown.
@@ -15,7 +15,7 @@
|
|||||||
<p>You may find more infos about this part <a href="https://libreevent.janishutz.com/docs/setup/setup#page-setup" target="_blank">here</a></p>
|
<p>You may find more infos about this part <a href="https://libreevent.janishutz.com/docs/setup/setup#page-setup" target="_blank">here</a></p>
|
||||||
|
|
||||||
<label for="template">Choose a template</label><br>
|
<label for="template">Choose a template</label><br>
|
||||||
<select name="template" id="template" >
|
<select name="template" id="template">
|
||||||
<option v-for="option in options" :key="option.id" :value="option.id">{{ option.name }}</option>
|
<option v-for="option in options" :key="option.id" :value="option.id">{{ option.name }}</option>
|
||||||
</select><br>
|
</select><br>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user