From 8afe477620afcbcbc38382f5498aece8c6e7c56a Mon Sep 17 00:00:00 2001 From: Eneko Nieto Date: Tue, 9 Feb 2021 13:29:17 +0100 Subject: [PATCH] Fixes in edit/create travel --- src/app/auth.config.ts | 2 +- src/app/entities/user-info.ts | 1 + src/app/entities/user.ts | 1 + .../edit-travel/edit-travel.component.ts | 8 ++-- src/app/pages/home/home.component.ts | 3 +- .../pages/new-travel/new-travel.component.ts | 3 +- src/app/views/list/list.component.html | 41 ++++++++----------- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/app/auth.config.ts b/src/app/auth.config.ts index 3416eab..be83559 100644 --- a/src/app/auth.config.ts +++ b/src/app/auth.config.ts @@ -37,7 +37,7 @@ export const authConfig: AuthConfig = { useSilentRefresh: useSilentRefreshForCodeFlow, - showDebugInformation: true, + showDebugInformation: false, sessionChecksEnabled: true, sessionCheckIntervall: 10000, diff --git a/src/app/entities/user-info.ts b/src/app/entities/user-info.ts index 0f268bf..e3f9c8d 100644 --- a/src/app/entities/user-info.ts +++ b/src/app/entities/user-info.ts @@ -2,6 +2,7 @@ export type UserId = string; export interface UserInfo { id: UserId; + username: string; matrixId?: string; name: string; } diff --git a/src/app/entities/user.ts b/src/app/entities/user.ts index 5ec140a..9f11ae2 100644 --- a/src/app/entities/user.ts +++ b/src/app/entities/user.ts @@ -2,6 +2,7 @@ export type UserId = string; export interface User { id: UserId; + username: string; matrixId?: string; name: string; } diff --git a/src/app/pages/edit-travel/edit-travel.component.ts b/src/app/pages/edit-travel/edit-travel.component.ts index 72f6107..b2a1010 100644 --- a/src/app/pages/edit-travel/edit-travel.component.ts +++ b/src/app/pages/edit-travel/edit-travel.component.ts @@ -1,7 +1,6 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { TravelFormComponent } from 'src/app/views/travel-form/travel-form.component'; -import { PUBLIC_API_URL } from '../../app.config'; import { Travel, TravelId } from '../../entities/travel'; import { ApiService } from '../../services/api.service'; @@ -32,21 +31,22 @@ export class EditTravelComponent implements OnInit { this.travel = res.data; } else { - console.error('Error getting travel ' + travelId + ': ' + res.error); + console.error('Error getting travel ' + travelId + ': ' + res.error.code + ' ' + res.error.msg); } }); }); } editTravel(travel: Travel): void { - this.apiService.createTravel(travel) + this.apiService.editTravel(travel) .subscribe(res => { if (res.success) { console.log('Travel edited'); this.router.navigateByUrl('/'); } else { - console.error('Error creating travel: ' + res.error); + console.error('Error editing travel: ' + res.error.code + ' ' + res.error.msg); + this.form.submitted = false; } }); } diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts index c19f2f5..62da92b 100644 --- a/src/app/pages/home/home.component.ts +++ b/src/app/pages/home/home.component.ts @@ -15,10 +15,11 @@ export class HomeComponent implements OnInit { userTravels: Travel[]; displayedColumns = [ - 'driver', 'departureDate', 'origin', 'destination', + 'availablePlaces', + 'driver', 'description', ]; travelsApiCall = this.apiService.getTravels; diff --git a/src/app/pages/new-travel/new-travel.component.ts b/src/app/pages/new-travel/new-travel.component.ts index 9f87ccd..3b6dd1f 100644 --- a/src/app/pages/new-travel/new-travel.component.ts +++ b/src/app/pages/new-travel/new-travel.component.ts @@ -30,7 +30,8 @@ export class NewTravelComponent implements OnInit { this.router.navigateByUrl('/'); } else { - console.error('Error creating travel: ' + res.error); + console.error('Error creating travel: ' + res.error.code + ' ' + res.error.msg); + this.form.submitted = false; } }); } diff --git a/src/app/views/list/list.component.html b/src/app/views/list/list.component.html index 939778b..14f3609 100644 --- a/src/app/views/list/list.component.html +++ b/src/app/views/list/list.component.html @@ -7,45 +7,44 @@ - - - # - {{ travel.driverId }} - - + Departure date {{ travel.departureDate - }} + }} Origin {{ travel.origin - }} + }} Destination {{ travel.destination - }} + }} + + + + Available places + {{ travel.places - travel.travelersInfo.length }} + + + + Driver + {{ travel.driverInfo.name }} Description {{ travel.description - }} + }} @@ -53,9 +52,5 @@ - - + + \ No newline at end of file