Flights now sortable.

This commit is contained in:
PeekabooSteam
2023-04-16 23:34:00 +01:00
parent 3eefe441b4
commit d77735581a
7 changed files with 276 additions and 48 deletions

View File

@@ -46,6 +46,15 @@ Flight.prototype.getData = function() {
}
Flight.prototype.setOrder = function( order ) {
this.order = order;
return true;
}
Flight.prototype.setStatus = function( status ) {
if ( [ "unknown", "checkedin", "readytotaxi", "clearedtotaxi", "halted", "terminated" ].indexOf( status ) < 0 ) {
@@ -172,6 +181,27 @@ app.patch( "/flight/:flightId", ( req, res ) => {
});
app.post( "/flight/order", ( req, res ) => {
if ( !req.body.boardId ) {
res.status( 400 ).send( "Invalid/missing boardId" );
}
if ( !req.body.order || !Array.isArray( req.body.order ) ) {
res.status( 400 ).send( "Invalid/missing boardId" );
}
req.body.order.forEach( ( flightId, i ) => {
dataHandler.getFlight( flightId ).setOrder( i );
});
res.send( "" );
});
app.post( "/flight", ( req, res ) => {
if ( !req.body.boardId ) {