diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 1c506c0..12f8df2 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -30,10 +30,6 @@ export class AppComponent {
this.router.navigate(['/']);
}
});
-
- // Optional
- if (authConfig.useSilentRefresh) {
- this.oauthService.setupAutomaticSilentRefresh();
- }
+ this.oauthService.setupAutomaticSilentRefresh();
}
}
diff --git a/src/app/auth.config.ts b/src/app/auth.config.ts
index be83559..3416eab 100644
--- a/src/app/auth.config.ts
+++ b/src/app/auth.config.ts
@@ -37,7 +37,7 @@ export const authConfig: AuthConfig = {
useSilentRefresh: useSilentRefreshForCodeFlow,
- showDebugInformation: false,
+ showDebugInformation: true,
sessionChecksEnabled: true,
sessionCheckIntervall: 10000,
diff --git a/src/app/pages/edit-travel/edit-travel.component.html b/src/app/pages/edit-travel/edit-travel.component.html
index 8ddae6a..585a22b 100644
--- a/src/app/pages/edit-travel/edit-travel.component.html
+++ b/src/app/pages/edit-travel/edit-travel.component.html
@@ -1,4 +1,4 @@
\ No newline at end of file
diff --git a/src/app/pages/edit-travel/edit-travel.component.ts b/src/app/pages/edit-travel/edit-travel.component.ts
index 07d8043..72f6107 100644
--- a/src/app/pages/edit-travel/edit-travel.component.ts
+++ b/src/app/pages/edit-travel/edit-travel.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
+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';
@@ -12,10 +12,12 @@ import { ApiService } from '../../services/api.service';
})
export class EditTravelComponent implements OnInit {
travel: Travel;
+ acceptButtonText = 'Save';
@ViewChild(TravelFormComponent, { static: true }) form: TravelFormComponent;
constructor(
+ private router: Router,
private apiService: ApiService,
private route: ActivatedRoute
) { }
@@ -35,4 +37,21 @@ export class EditTravelComponent implements OnInit {
});
});
}
+
+ editTravel(travel: Travel): void {
+ this.apiService.createTravel(travel)
+ .subscribe(res => {
+ if (res.success) {
+ console.log('Travel edited');
+ this.router.navigateByUrl('/');
+ }
+ else {
+ console.error('Error creating travel: ' + res.error);
+ }
+ });
+ }
+
+ cancel(): void {
+ this.router.navigateByUrl('/');
+ }
}
diff --git a/src/app/pages/travel/travel.component.html b/src/app/pages/travel/travel.component.html
index 18845c4..e20d2b2 100644
--- a/src/app/pages/travel/travel.component.html
+++ b/src/app/pages/travel/travel.component.html
@@ -13,4 +13,4 @@
-
+
diff --git a/src/app/pages/travel/travel.component.ts b/src/app/pages/travel/travel.component.ts
index 5a3595f..4830eaa 100644
--- a/src/app/pages/travel/travel.component.ts
+++ b/src/app/pages/travel/travel.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
+import { OAuthService } from 'angular-oauth2-oidc';
import { Travel, TravelId } from '../../entities/travel';
import { ApiService } from '../../services/api.service';
@@ -15,6 +16,7 @@ export class TravelComponent implements OnInit {
constructor(
private router: Router,
+ private oauthService: OAuthService,
private apiService: ApiService,
private route: ActivatedRoute
) { }
@@ -40,6 +42,11 @@ export class TravelComponent implements OnInit {
}
edit(): void {
- this.router.navigateByUrl('/');
+ this.router.navigateByUrl(`/travel/${this.travelId}/edit`);
+ }
+
+ get logged(): boolean {
+ return this.oauthService.getIdentityClaims() != null;
+ // return this.oauthService.hasValidIdToken() && this.oauthService.hasValidAccessToken();
}
}
diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts
index 0e96d07..54d6e4d 100644
--- a/src/app/services/api.service.ts
+++ b/src/app/services/api.service.ts
@@ -39,6 +39,10 @@ export class ApiService {
return this.callApi(TRAVEL_API_URL + '/create', null, travel);
}
+ editTravel = (travel: Travel) => {
+ return this.callApi(TRAVEL_API_URL + '/edit', null, travel);
+ }
+
private callApi(
url: string,
params?: { [param: string]: any },
diff --git a/src/app/views/header/header.component.ts b/src/app/views/header/header.component.ts
index b12a09f..b566545 100644
--- a/src/app/views/header/header.component.ts
+++ b/src/app/views/header/header.component.ts
@@ -15,6 +15,7 @@ export class HeaderComponent implements OnInit {
) { }
ngOnInit(): void {
+ console.log('INIT logged=' + String(this.logged));
this.oauthService.configure(authConfig);
this.oauthService.loadDiscoveryDocumentAndTryLogin().then(success => {
console.log('Autologin success=' + success + ' logged=' + String(this.logged));
diff --git a/src/app/views/travel-form/travel-form.component.html b/src/app/views/travel-form/travel-form.component.html
index 04cf224..b0af5d2 100644
--- a/src/app/views/travel-form/travel-form.component.html
+++ b/src/app/views/travel-form/travel-form.component.html
@@ -1,8 +1,8 @@
-