diff --git a/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html b/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html
index 8322421..ed10cb3 100644
--- a/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html
+++ b/frontend/wendys-friends/src/app/component/list-owners/list-owners.component.html
@@ -29,6 +29,7 @@
{{ id + 1 }} |
{{ owner.name }} |
+
|
diff --git a/frontend/wendys-friends/src/app/component/owner/owner.component.html b/frontend/wendys-friends/src/app/component/owner/owner.component.html
index f2ceeb4..d1bdd5a 100644
--- a/frontend/wendys-friends/src/app/component/owner/owner.component.html
+++ b/frontend/wendys-friends/src/app/component/owner/owner.component.html
@@ -6,14 +6,28 @@
-
-
Well done!
-
Your application is up and running
-
-
This is the name of the owner with id 1 from your backend system:
- {{owner.name}}
-
-
+
Owner Info for {{ owner.name }}
+
+
Horses:
+
+
+
+ # |
+ Name |
+ Actions |
+
+
+
+
+ {{ id + 1 }} |
+ {{ horse.name }} |
+
+
+ |
+
+
+
+
+ Owner has no horses assigned.
+
-
-
diff --git a/frontend/wendys-friends/src/app/component/owner/owner.component.ts b/frontend/wendys-friends/src/app/component/owner/owner.component.ts
index 95d40fa..2684766 100644
--- a/frontend/wendys-friends/src/app/component/owner/owner.component.ts
+++ b/frontend/wendys-friends/src/app/component/owner/owner.component.ts
@@ -1,6 +1,8 @@
import {Component, OnInit} from '@angular/core';
import {OwnerService} from '../../service/owner.service';
import {Owner} from '../../dto/owner';
+import { ActivatedRoute } from '@angular/router';
+import { Horse } from 'src/app/dto/horse';
@Component({
selector: 'app-owner',
@@ -12,12 +14,15 @@ export class OwnerComponent implements OnInit {
error = false;
errorMessage = '';
owner: Owner;
+ horses: Array
- constructor(private ownerService: OwnerService) {
+ constructor(private ownerService: OwnerService, private route: ActivatedRoute) {
}
ngOnInit() {
- this.loadOwner(1);
+ const ownerId: string = this.route.snapshot.paramMap.get('id');
+ this.loadOwner(parseInt(ownerId));
+ this.loadOwnerHorses(parseInt(ownerId));
}
/**
@@ -42,6 +47,21 @@ export class OwnerComponent implements OnInit {
);
}
+ /**
+ * Load the horses of the owner
+ * @param id of the owner
+ */
+ private loadOwnerHorses(id: number) {
+ this.ownerService.getOwnerHorses(id).subscribe(
+ (horses: Array) => {
+ this.horses = horses;
+ },
+ error => {
+ console.log(error);
+ }
+ );
+ }
+
private defaultServiceErrorHandling(error: any) {
console.log(error);
this.error = true;
diff --git a/frontend/wendys-friends/src/app/service/owner.service.ts b/frontend/wendys-friends/src/app/service/owner.service.ts
index 67811db..e0072d4 100644
--- a/frontend/wendys-friends/src/app/service/owner.service.ts
+++ b/frontend/wendys-friends/src/app/service/owner.service.ts
@@ -3,6 +3,7 @@ import {HttpClient, HttpParams} from '@angular/common/http';
import {Globals} from '../global/globals';
import {Observable} from 'rxjs';
import {Owner} from '../dto/owner';
+import { Horse } from '../dto/horse';
@Injectable({
providedIn: 'root'
@@ -40,6 +41,15 @@ export class OwnerService {
return this.httpClient.get>(this.messageBaseUri, { params: filter });
}
+ /**
+ * Load all horses, owned by the specified owner, from the backend
+ * @param id
+ */
+ getOwnerHorses(id: number): Observable> {
+ console.log('Load all horses for owner ' + id);
+ return this.httpClient.get>(this.messageBaseUri + '/' + id + '/horses');
+ }
+
/**
* Adds a specific owner to the backend and loads it if successful
* @param owner