-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a69d4a
commit 5c178e3
Showing
12 changed files
with
450 additions
and
226 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<v-card> | ||
<v-card-title> | ||
<v-text-field | ||
v-model="search" | ||
append-icon="mdi-magnify" | ||
label="Search" | ||
single-line | ||
hide-details | ||
></v-text-field> | ||
</v-card-title> | ||
<v-data-table | ||
:headers="headers" | ||
:items="bookings" | ||
:search="search" | ||
> | ||
<template slot="headers" scope="props"> | ||
<tr> | ||
<th> | ||
</th> | ||
<th v-for="header in props.headers" :key="header.text" | ||
:class="['column sortable', pagination.descending ? 'desc' : 'asc', header.value === pagination.sortBy ? 'active' : '']" | ||
@click="changeSort(header.value)" | ||
> | ||
<v-icon>arrow_upward</v-icon> | ||
{{ header.text }} | ||
</th> | ||
</tr> | ||
</template> | ||
<template slot="items" scope="props"> | ||
<tr :active="props.selected" @click="props.selected = !props.selected"> | ||
<td class="text-left">{{ booking.id }}</td> | ||
<td class="text-left">{{ booking.name }}</td> | ||
<td class="text-left">{{ booking.flight_id }}</td> | ||
<td class="text-left">{{ booking.departure_airport_iata }}</td> | ||
<td class="text-left">{{ booking.arrival_airport_iata }}</td> | ||
<td class="text-left">{{ booking.estimated_time_departure }}</td> | ||
<td class="text-left">{{ booking.estimated_time_arrival }}</td> | ||
</tr> | ||
</template> | ||
</v-data-table> | ||
</v-card> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Vue } from 'vue-property-decorator' | ||
import { Booking } from '../entity/booking' | ||
@Component({ | ||
components: { | ||
} | ||
}) | ||
export default class BookingList extends Vue { | ||
bookings: Array<Booking> = [] | ||
dateFormat = 'MM/dd HHmm' | ||
search = '' | ||
headers = [ | ||
{ text: 'ID', value: 'id' }, | ||
{ text: 'Name', value: 'name' }, | ||
{ text: 'Flight ID', value: 'flight_id' }, | ||
{ text: 'DEP', value: 'departure_airport_iata' }, | ||
{ text: 'ARR', value: 'arrival_airport_iata' }, | ||
{ text: 'ETD', value: 'estimated_time_departure' }, | ||
{ text: 'ETA', value: 'estimated_time_arrival' }] | ||
pagination = { | ||
sortBy: 'name', | ||
descending: false | ||
} | ||
changeSort (column :string) { | ||
if (this.pagination.sortBy === column) { | ||
this.pagination.descending = !this.pagination.descending | ||
} else { | ||
this.pagination.sortBy = column | ||
this.pagination.descending = false | ||
} | ||
} | ||
mounted () { | ||
console.log('Mounted Booking List Component') | ||
this.$store.dispatch('ENSURE_LOADED_BOOKINGS').then(() => { | ||
this.bookings = this.$store.state.bookings | ||
}) | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
<v-card> | ||
<v-card-text> | ||
<form id="submit-booking-form" @submit.prevent="addBooking"> | ||
<span class="mx-2">Create Booking </span> | ||
<input v-model="name" placeholder="passenger name" class="mx-2"> | ||
<button type="submit" class="button is-danger mx-2">Submit</button> | ||
</form> | ||
</v-card-text> | ||
<v-snackbar v-model="snackbar" :timeout="snackbarTimeout"> | ||
{{ snackbarText }} | ||
<template v-slot:action="{ attrs }"> | ||
<v-btn | ||
color="blue" | ||
text | ||
v-bind="attrs" | ||
@click="snackbar = false" | ||
> | ||
Close | ||
</v-btn> | ||
</template> | ||
</v-snackbar> | ||
</v-card> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Prop, Vue } from 'vue-property-decorator' | ||
import { Flight } from '../../entity/flight' | ||
import { Booking } from '../../entity/booking' | ||
@Component({ | ||
components: { | ||
} | ||
}) | ||
export default class FlightPassengerBooking extends Vue { | ||
@Prop() readonly flight! :Flight | ||
name = '' | ||
snackbar = false | ||
snackbarText = '' | ||
snackbarTimeout = 3000 | ||
created () { | ||
} | ||
mounted () { | ||
} | ||
addBooking () { | ||
var booking = new Booking({ | ||
name: this.name, | ||
flight_id: this.flight.id, | ||
departure_airport_iata: this.flight.departure_airport.iata, | ||
arrival_airport_iata: this.flight.arrival_airport.iata, | ||
estimated_time_departure: this.flight.estimated_time_departure, | ||
estimated_time_arrival: this.flight.estimated_time_arrival | ||
}) | ||
this.$store.commit('ADD_BOOKING', booking) | ||
this.snackbarText = 'Added Booking for ' + this.name | ||
this.snackbar = true | ||
this.name = '' | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable camelcase */ | ||
import * as luxon from 'luxon' | ||
export class Booking { | ||
id: number = 0; | ||
flight_id: number = 0; | ||
departure_airport_iata: string; | ||
arrival_airport_iata: string; | ||
estimated_time_departure: luxon.DateTime = luxon.DateTime.utc(); | ||
estimated_time_arrival: luxon.DateTime = luxon.DateTime.utc(); | ||
name: string; | ||
|
||
public constructor (init?:Partial<Booking>) { | ||
Object.assign(this, init) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable camelcase */ | ||
export class Delay { | ||
code: number = 0; | ||
name: string = ''; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Booking } from '@/entity/booking' | ||
|
||
const bookingApiUrl = process.env.VUE_APP_BOOKING_API_URL | ||
|
||
export async function GetAllBookings () { | ||
const bookings = [ | ||
new Booking({ id: 1, name: 'Chandan Gudla', departure_airport_iata: 'IAH', arrival_airport_iata: 'ORD', flight_id: 1234 }), | ||
new Booking({ id: 2, name: 'John Gammon', departure_airport_iata: 'IAH', arrival_airport_iata: 'SYD', flight_id: 1235 }), | ||
new Booking({ id: 3, name: 'Shelby Thomas', departure_airport_iata: 'DXB', arrival_airport_iata: 'HKG', flight_id: 1236 }), | ||
new Booking({ id: 4, name: 'Vince Tsugranes', departure_airport_iata: 'RDU', arrival_airport_iata: 'ATL', flight_id: 1237 }) | ||
] | ||
return bookings | ||
/* | ||
const bookingRequestUrl = bookingApiUrl | ||
console.log('Getting Bookings from ' + bookingRequestUrl) | ||
const bookingsResponse = await fetch(bookingRequestUrl) | ||
const jsonBookings = JSON.parse(await bookingsResponse.text()) | ||
return jsonBookings | ||
*/ | ||
} | ||
|
||
export async function UpsertBooking (booking: Booking) { | ||
const bookingPostUrl = bookingApiUrl | ||
console.log('Sending Booking to ' + bookingPostUrl) | ||
|
||
const response = await fetch(bookingPostUrl, { | ||
method: 'POST', | ||
body: JSON.stringify(booking), | ||
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' } | ||
}) | ||
|
||
if (!response.ok) { | ||
console.log('Exception Posting Booking to ' + bookingPostUrl + ': ' + response.text) | ||
} | ||
|
||
if (response.body !== null) { | ||
const data = JSON.parse(response.json.toString()) as Response | ||
return data.json | ||
} | ||
} |
Oops, something went wrong.