diff --git a/src/app/adoptions/adoption-create/adoption-create.component.html b/src/app/adoptions/adoption-create/adoption-create.component.html new file mode 100644 index 0000000..3d33be6 --- /dev/null +++ b/src/app/adoptions/adoption-create/adoption-create.component.html @@ -0,0 +1,32 @@ +
diff --git a/src/app/adoptions/adoption-create/adoption-create.component.ts b/src/app/adoptions/adoption-create/adoption-create.component.ts new file mode 100644 index 0000000..eddcff7 --- /dev/null +++ b/src/app/adoptions/adoption-create/adoption-create.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; +import { Adoption } from '../adoption'; +import { Router } from '@angular/router'; +import { AdoptionService } from '../adoption.service'; + +@Component({ + selector: 'app-adoption-add', + templateUrl: './adoption-create.component.html', +}) +export class AdoptionCreateComponent implements OnInit{ + public adoption: Adoption; + public date: Date; + + constructor(private router: Router, + private adoptionService: AdoptionService) { + } + ngOnInit(): void { + this.adoption = new Adoption(); + } + + onSubmit(): void { + this.adoptionService.createResource({body: this.adoption}).subscribe( + (adoption:Adoption) => this.router.navigate([adoption.uri]) + ); + } +} diff --git a/src/app/adoptions/adoption-delete/adoption-delete.component.ts b/src/app/adoptions/adoption-delete/adoption-delete.component.ts new file mode 100644 index 0000000..27f43e8 --- /dev/null +++ b/src/app/adoptions/adoption-delete/adoption-delete.component.ts @@ -0,0 +1,31 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Adoption } from '../adoption'; +import { AdoptionService } from '../adoption.service'; + +@Component({ + selector: 'app-adoption-delete', + templateUrl: './adoption.delete.component.html' +}) +export class AdoptionDeleteComponent implements OnInit { + public adoption: Adoption = new Adoption(); + public adoptionId: string; + + constructor(private route: ActivatedRoute, + private router: Router, + private adoptionService: AdoptionService) { + } + + ngOnInit(): void { + this.adoptionId = this.route.snapshot.paramMap.get('id'); + this.adoptionService.getResource(this.adoptionId).subscribe( + adoption => this.adoption = adoption); + } + + delete(): void { + this.adoptionService.deleteResource(this.adoption).subscribe( + () => { + this.router.navigate(['id']); + }); + } +} diff --git a/src/app/adoptions/adoption-delete/adoption.delete.component.html b/src/app/adoptions/adoption-delete/adoption.delete.component.html new file mode 100644 index 0000000..97d4922 --- /dev/null +++ b/src/app/adoptions/adoption-delete/adoption.delete.component.html @@ -0,0 +1 @@ +adoption-delete works!
diff --git a/src/app/adoptions/adoption-detail/adoption-detail.component.html b/src/app/adoptions/adoption-detail/adoption-detail.component.html new file mode 100644 index 0000000..a3ac23c --- /dev/null +++ b/src/app/adoptions/adoption-detail/adoption-detail.component.html @@ -0,0 +1 @@ +adoptions-detail works!
diff --git a/src/app/adoptions/adoption-detail/adoption-detail.component.ts b/src/app/adoptions/adoption-detail/adoption-detail.component.ts new file mode 100644 index 0000000..657dbf4 --- /dev/null +++ b/src/app/adoptions/adoption-detail/adoption-detail.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { AdoptionService } from '../adoption.service'; +import { Adoption } from '../adoption'; + +@Component({ + selector: 'app-adoption-detail', + templateUrl: './adoption-detail.component.html' +}) +export class AdoptionDetailComponent implements OnInit { + public adoption: Adoption = new Adoption(); + public adoptionId: string; + + constructor(private route: ActivatedRoute, + private adoptionService: AdoptionService) { + } + + ngOnInit(): void { + this.adoptionId = this.route.snapshot.paramMap.get('id'); + this.adoptionService.getResource(this.adoptionId).subscribe( + adoption => { + this.adoption = adoption; + }); + } +} diff --git a/src/app/adoptions/adoption-edit/adoption-edit.component.html b/src/app/adoptions/adoption-edit/adoption-edit.component.html new file mode 100644 index 0000000..8c0a19d --- /dev/null +++ b/src/app/adoptions/adoption-edit/adoption-edit.component.html @@ -0,0 +1 @@ +adoptions-edit works!
diff --git a/src/app/adoptions/adoption-edit/adoption-edit.component.ts b/src/app/adoptions/adoption-edit/adoption-edit.component.ts new file mode 100644 index 0000000..c38c2f8 --- /dev/null +++ b/src/app/adoptions/adoption-edit/adoption-edit.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { Router } from '@angular/router'; +import { AuthenticationBasicService } from '../../login-basic/authentication-basic.service'; +import { AdoptionService } from '../adoption.service'; +import { Adoption } from '../adoption'; + +@Component({ + selector: 'app-adoption-edit', + templateUrl: './adoption-edit.component.html', +}) +export class AdoptionEditComponent implements OnInit { + public adoption: Adoption = new Adoption(); + + constructor(private route: ActivatedRoute, + private router: Router, + private adoptionsService: AdoptionService, + private authenticationService: AuthenticationBasicService) { + } + + ngOnInit(): void { + const id = this.route.snapshot.paramMap.get('id'); + this.adoptionsService.getResource(id).subscribe( + (adoption: Adoption) => this.adoption = adoption ); + } + + getCurrentUserName(): string { + return this.authenticationService.getCurrentUser().username; + } +} diff --git a/src/app/adoptions/adoption-list/adoption-list.component.html b/src/app/adoptions/adoption-list/adoption-list.component.html new file mode 100644 index 0000000..c94c4f8 --- /dev/null +++ b/src/app/adoptions/adoption-list/adoption-list.component.html @@ -0,0 +1,26 @@ +{{adoption.pet}}
+{{adoption.user}}
+{{adoption.localDateTime}}
+adoption-search works!
diff --git a/src/app/adoptions/adoption-search/adoption-search.component.ts b/src/app/adoptions/adoption-search/adoption-search.component.ts new file mode 100644 index 0000000..70364d4 --- /dev/null +++ b/src/app/adoptions/adoption-search/adoption-search.component.ts @@ -0,0 +1,42 @@ +import { Component, EventEmitter, Output } from '@angular/core'; +import { AdoptionService } from '../adoption.service'; +import { Adoption } from '../adoption'; +import { Observable, of, OperatorFunction } from 'rxjs'; +import { catchError, debounceTime, distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators'; +import { ResourceCollection } from '@lagoshny/ngx-hateoas-client'; + +@Component({ + selector: 'app-adoption-search', + templateUrl: './adoption-search.component.html' +}) + +export class AdoptionSearchComponent { + @Output() emitResults: EventEmitter