Browse Source

add some description entries for the UI

Sven Czarnian 2 years ago
parent
commit
bb9044698d

+ 9 - 4
src/airport/airport.controller.ts

@@ -31,6 +31,7 @@ import { CoordinateConverter, WaypointConverter } from '../generic/converters';
 import { ActiveRunwaysDto } from './dto/activerunways.dto';
 import { Runway } from './models/runway.model';
 import { RunwayDto } from './dto/runway.dto';
+import { AirportOverviewDto } from './dto/airportoverview.dto';
 
 @Controller('airport')
 export class AirportController {
@@ -136,6 +137,8 @@ export class AirportController {
 
     return {
       icao: airport.icao,
+      name: airport.name,
+      flightInformationRegion: airport.flightInformationRegion,
       location: WaypointConverter.convert<WaypointDto, CoordinateDto>(
         airport.location,
       ),
@@ -166,6 +169,8 @@ export class AirportController {
 
     return {
       icao: airport.icao,
+      name: airport.name,
+      flightInformationRegion: airport.flightInformationRegion,
       location: WaypointConverter.convert<Waypoint, Coordinate>(
         airport.location,
       ),
@@ -241,14 +246,14 @@ export class AirportController {
     });
   }
 
-  @Get('/allCodes')
+  @Get('/all')
   @ApiResponse({
     status: 200,
     description: 'All available airports',
-    type: [String],
+    type: [AirportOverviewDto],
   })
-  async allCodes(): Promise<string[]> {
-    return this.airportService.airportsList();
+  async all(): Promise<AirportOverviewDto[]> {
+    return this.airportService.allAirports();
   }
 
   @Get('/get')

+ 11 - 4
src/airport/airport.service.ts

@@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
 import { InjectModel } from '@nestjs/mongoose';
 import { Model } from 'mongoose';
 import { ActiveRunwaysDto } from './dto/activerunways.dto';
+import { AirportOverviewDto } from './dto/airportoverview.dto';
 import { Airport, AirportDocument } from './models/airport.model';
 
 @Injectable()
@@ -17,11 +18,17 @@ export class AirportService {
       .then((response) => response && response.length !== 0);
   }
 
-  async airportsList(): Promise<string[]> {
+  async allAirports(): Promise<AirportOverviewDto[]> {
     return this.airportModel.find({}).then((response) => {
-      const icaoCodes: string[] = [];
-      response.forEach((airport) => icaoCodes.push(airport.icao));
-      return icaoCodes;
+      const retval: AirportOverviewDto[] = [];
+      response.forEach((airport) =>
+        retval.push({
+          icao: airport.icao,
+          name: airport.name,
+          flightInformationRegion: airport.flightInformationRegion,
+        }),
+      );
+      return retval;
     });
   }
 

+ 14 - 0
src/airport/dto/airport.dto.ts

@@ -15,6 +15,20 @@ export class AirportDto {
   })
   icao: string;
 
+  @IsNotEmpty()
+  @ApiProperty({
+    description: 'The name of the airport',
+    example: 'Berlin Brandenburg',
+  })
+  name: string;
+
+  @IsNotEmpty()
+  @ApiProperty({
+    description: 'The flight information region (FIR)',
+    example: 'FIR Bremen',
+  })
+  flightInformationRegion: string;
+
   @IsNotEmpty()
   @ApiProperty({
     description: 'The airport location',

+ 25 - 0
src/airport/dto/airportoverview.dto.ts

@@ -0,0 +1,25 @@
+import { IsNotEmpty } from 'class-validator';
+import { ApiProperty } from '@nestjs/swagger';
+
+export class AirportOverviewDto {
+  @IsNotEmpty()
+  @ApiProperty({
+    description: 'The unique ICAO code',
+    example: 'EDDB',
+  })
+  icao: string;
+
+  @IsNotEmpty()
+  @ApiProperty({
+    description: 'The name of the airport',
+    example: 'Berlin Brandenburg',
+  })
+  name: string;
+
+  @IsNotEmpty()
+  @ApiProperty({
+    description: 'The flight information region (FIR)',
+    example: 'FIR Bremen',
+  })
+  flightInformationRegion: string;
+}

+ 12 - 0
src/airport/models/airport.model.ts

@@ -18,6 +18,18 @@ export class Airport {
   })
   icao: string;
 
+  @Prop({
+    required: true,
+    type: String,
+  })
+  name: string;
+
+  @Prop({
+    required: true,
+    type: String,
+  })
+  flightInformationRegion: string;
+
   @Prop({
     required: true,
     type: Waypoint,