mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
fix bug in seat selector + more android stuff
This commit is contained in:
@@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val policy = ThreadPolicy.Builder().permitAll().build()
|
val policy = ThreadPolicy.Builder().permitAll().build()
|
||||||
StrictMode.setThreadPolicy(policy)
|
StrictMode.setThreadPolicy(policy)
|
||||||
|
|
||||||
val sharedPref = getPreferences( MODE_PRIVATE )
|
val sharedPref = getSharedPreferences( "login", MODE_PRIVATE )
|
||||||
|
|
||||||
val hasSwitched = intent.hasExtra("hasSwitched")
|
val hasSwitched = intent.hasExtra("hasSwitched")
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val res = ApiClient().authenticateUser( url, username, password )
|
val res = ApiClient().authenticateUser( url, username, password )
|
||||||
println( res )
|
println( res )
|
||||||
if ( res == "authOk" ) {
|
if ( res == "authOk" ) {
|
||||||
val sharedPref = getPreferences( MODE_PRIVATE )
|
val sharedPref = getSharedPreferences( "login", MODE_PRIVATE )
|
||||||
val editor = sharedPref.edit()
|
val editor = sharedPref.edit()
|
||||||
editor.putString( "username", username )
|
editor.putString( "username", username )
|
||||||
editor.putString( "password", password )
|
editor.putString( "password", password )
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.Manifest
|
|||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
@@ -28,7 +27,7 @@ class ScannerActivity : CaptureActivity() {
|
|||||||
|
|
||||||
val logoutButton = findViewById<Button>(R.id.logoutButton)
|
val logoutButton = findViewById<Button>(R.id.logoutButton)
|
||||||
logoutButton.setOnClickListener {
|
logoutButton.setOnClickListener {
|
||||||
val sharedPref = getPreferences( MODE_PRIVATE )
|
val sharedPref = getSharedPreferences( "login", MODE_PRIVATE )
|
||||||
val editor = sharedPref.edit()
|
val editor = sharedPref.edit()
|
||||||
editor.remove( "loginOk" )
|
editor.remove( "loginOk" )
|
||||||
editor.remove( "username" )
|
editor.remove( "username" )
|
||||||
@@ -64,8 +63,7 @@ class ScannerActivity : CaptureActivity() {
|
|||||||
|
|
||||||
private fun handleScanResult(result: String) {
|
private fun handleScanResult(result: String) {
|
||||||
if ( lastScanned != result ) {
|
if ( lastScanned != result ) {
|
||||||
println(result)
|
val sharedPref = getSharedPreferences( "login", MODE_PRIVATE )
|
||||||
val sharedPref = getPreferences( MODE_PRIVATE )
|
|
||||||
|
|
||||||
ApiClient().checkTicket( sharedPref.getString( "url", null ).toString(),
|
ApiClient().checkTicket( sharedPref.getString( "url", null ).toString(),
|
||||||
sharedPref.getString( "username", null ).toString(),
|
sharedPref.getString( "username", null ).toString(),
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class GETHandler {
|
|||||||
} else if ( call === 'getReservedSeats' ) {
|
} else if ( call === 'getReservedSeats' ) {
|
||||||
if ( query.event ) {
|
if ( query.event ) {
|
||||||
db.getDataSimple( 'temp', 'user_id', session.id ).then( dat => {
|
db.getDataSimple( 'temp', 'user_id', session.id ).then( dat => {
|
||||||
|
// console.log( dat[ 0 ] ? JSON.parse( dat[ 0 ].data )[ query.event ] ?? {} : {} );
|
||||||
resolve( { 'user': dat[ 0 ] ? JSON.parse( dat[ 0 ].data )[ query.event ] ?? {} : {} } );
|
resolve( { 'user': dat[ 0 ] ? JSON.parse( dat[ 0 ].data )[ query.event ] ?? {} : {} } );
|
||||||
} ).catch( () => {
|
} ).catch( () => {
|
||||||
reject( { 'code': 500, 'message': 'ERR_DB' } );
|
reject( { 'code': 500, 'message': 'ERR_DB' } );
|
||||||
|
|||||||
@@ -208,25 +208,33 @@ class POSTHandler {
|
|||||||
if ( this.allSelectedSeats[ data.eventID ][ data.id ] || this.temporarilySelected[ data.eventID ][ data.id ] ) {
|
if ( this.allSelectedSeats[ data.eventID ][ data.id ] || this.temporarilySelected[ data.eventID ][ data.id ] ) {
|
||||||
reject( { 'code': 409, 'message': 'ERR_ALREADY_SELECTED' } );
|
reject( { 'code': 409, 'message': 'ERR_ALREADY_SELECTED' } );
|
||||||
} else {
|
} else {
|
||||||
let info = {};
|
db.getDataSimple( 'temp', 'user_id', session.id ).then( dat => {
|
||||||
info[ data.eventID ] = {};
|
let info = {};
|
||||||
info[ data.eventID ][ data.id ] = data;
|
if ( dat[ 0 ] ) {
|
||||||
db.writeDataSimple( 'temp', 'user_id', session.id, { 'user_id': session.id, 'timestamp': new Date().toString(), 'data': JSON.stringify( info ) } ).then( () => {
|
info = JSON.parse( dat[ 0 ].data );
|
||||||
if ( !this.temporarilySelectedTotals[ session.id ] ) {
|
|
||||||
this.temporarilySelectedTotals[ session.id ] = {};
|
|
||||||
this.temporarilySelectedTotals[ session.id ][ data.eventID ] = {};
|
|
||||||
}
|
}
|
||||||
if ( !this.temporaryTotals[ data.eventID ] ) {
|
if ( !info[ data.eventID ] ) {
|
||||||
this.temporaryTotals[ data.eventID ] = 0;
|
info[ data.eventID ] = {};
|
||||||
}
|
}
|
||||||
this.temporarilySelected[ data.eventID ] = info[ data.eventID ];
|
info[ data.eventID ][ data.id ] = data;
|
||||||
this.temporaryTotals[ data.eventID ] += 1;
|
db.writeDataSimple( 'temp', 'user_id', session.id, { 'user_id': session.id, 'timestamp': new Date().toString(), 'data': JSON.stringify( info ) } ).then( () => {
|
||||||
this.temporarilySelectedTotals[ session.id ][ data.eventID ][ data.id ] = 1;
|
if ( !this.temporarilySelectedTotals[ session.id ] ) {
|
||||||
this.countFreeSeats();
|
this.temporarilySelectedTotals[ session.id ] = {};
|
||||||
resolve( 'ok' );
|
this.temporarilySelectedTotals[ session.id ][ data.eventID ] = {};
|
||||||
} ).catch( err => {
|
}
|
||||||
console.error( err );
|
if ( !this.temporaryTotals[ data.eventID ] ) {
|
||||||
|
this.temporaryTotals[ data.eventID ] = 0;
|
||||||
|
}
|
||||||
|
this.temporarilySelected[ data.eventID ] = info[ data.eventID ];
|
||||||
|
this.temporaryTotals[ data.eventID ] += 1;
|
||||||
|
this.temporarilySelectedTotals[ session.id ][ data.eventID ][ data.id ] = 1;
|
||||||
|
this.countFreeSeats();
|
||||||
|
resolve( 'ok' );
|
||||||
|
} ).catch( err => {
|
||||||
|
console.error( err );
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
|
// TODO: Add catch block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ( call === 'deselectTicket' ) {
|
} else if ( call === 'deselectTicket' ) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"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"},"secAr6s10":{"id":"secAr6s10","component":1,"ticketOption":"2","eventID":"test4","category":"1","name":"Row 7, Seat 11"},"comp1secAr5s11":{"id":"comp1secAr5s11","component":1,"ticketOption":"2","eventID":"test4","category":"1","name":"Row 6, Seat 12"}},"test3":{"ticket1_1":{"id":"ticket1_1","component":1,"ticketOption":"1","eventID":"test3","count":10,"category":"1","name":"Category 1 (Child)"},"ticket1":{"id":"ticket1_1","component":1,"ticketOption":"1","eventID":"test3","count":1,"category":"1","name":"Category 1 (Child)"}}}
|
{"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"},"secAr6s10":{"id":"secAr6s10","component":1,"ticketOption":"2","eventID":"test4","category":"1","name":"Row 7, Seat 11"},"comp1secAr5s11":{"id":"comp1secAr5s11","component":1,"ticketOption":"2","eventID":"test4","category":"1","name":"Row 6, Seat 12"}},"test3":{"ticket1_1":{"id":"ticket1_1","component":1,"ticketOption":"1","eventID":"test3","count":10,"category":"1","name":"Category 1 (Child)"},"ticket1":{"id":"ticket1_1","component":1,"ticketOption":"1","eventID":"test3","count":1,"category":"1","name":"Category 1 (Child)"}},"complexLocationTest":{"comp4secAr2s25":{"id":"comp4secAr2s25","component":4,"ticketOption":"2","eventID":"complexLocationTest","category":"2","name":"Row 3, Seat 26"},"comp4secAr2s26":{"id":"comp4secAr2s26","component":4,"ticketOption":"2","eventID":"complexLocationTest","category":"2","name":"Row 3, Seat 27"}}}
|
||||||
Reference in New Issue
Block a user