From cd4b0a28c07b5ee3bb67364fa5c7168920d58bd0 Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 8 May 2024 18:14:58 +0200 Subject: [PATCH 01/13] adoptions --- .../adoptions-add.component.html | 0 .../adoptions-add/adoptions-add.component.ts | 0 .../adoptions-delete.component.ts | 33 +++++++++++++++ .../adoptions.add.component.html | 0 .../adoptions-detail.component.html | 0 .../adoptions-detail.component.ts | 27 ++++++++++++ .../adoptions-edit.component.html | 0 .../adoptions-edit.component.ts | 0 .../adoptions-list.component.html | 0 .../adoptions-list.component.ts | 41 +++++++++++++++++++ .../adoptions-search.component.html | 0 .../adoptions-search.component.ts | 0 src/app/adoptions/adoptions.service.ts | 17 ++++++++ src/app/adoptions/adoptions.ts | 17 ++++++++ 14 files changed, 135 insertions(+) create mode 100644 src/app/adoptions/adoptions-add/adoptions-add.component.html create mode 100644 src/app/adoptions/adoptions-add/adoptions-add.component.ts create mode 100644 src/app/adoptions/adoptions-delete/adoptions-delete.component.ts create mode 100644 src/app/adoptions/adoptions-delete/adoptions.add.component.html create mode 100644 src/app/adoptions/adoptions-detail/adoptions-detail.component.html create mode 100644 src/app/adoptions/adoptions-detail/adoptions-detail.component.ts create mode 100644 src/app/adoptions/adoptions-edit/adoptions-edit.component.html create mode 100644 src/app/adoptions/adoptions-edit/adoptions-edit.component.ts create mode 100644 src/app/adoptions/adoptions-list/adoptions-list.component.html create mode 100644 src/app/adoptions/adoptions-list/adoptions-list.component.ts create mode 100644 src/app/adoptions/adoptions-search/adoptions-search.component.html create mode 100644 src/app/adoptions/adoptions-search/adoptions-search.component.ts create mode 100644 src/app/adoptions/adoptions.service.ts create mode 100644 src/app/adoptions/adoptions.ts diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.html b/src/app/adoptions/adoptions-add/adoptions-add.component.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.ts b/src/app/adoptions/adoptions-add/adoptions-add.component.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts b/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts new file mode 100644 index 0000000..18a3bee --- /dev/null +++ b/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts @@ -0,0 +1,33 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Adoptions } from '../adoptions'; +import { AdoptionsService } from '../adoptions.service'; + +@Component({ + selector: 'app-adoptions-delete', + templateUrl: './adoptions.add.component.html', + standalone: true, + imports: [] +}) +export class AdoptionsDeleteComponent implements OnInit { + public adoptions: Adoptions = new Adoptions(); + public adoptionsId: string; + + constructor(private route: ActivatedRoute, + private router: Router, + private adoptionsService: AdoptionsService) { + } + + ngOnInit(): void { + this.adoptionsId = this.route.snapshot.paramMap.get('id'); + this.adoptionsService.getResource(this.adoptionsId).subscribe( + adoptions => this.adoptions = adoptions); + } + + delete(): void { + this.adoptionsService.deleteResource(this.adoptions).subscribe( + () => { + this.router.navigate(['']); + }); + } +} diff --git a/src/app/adoptions/adoptions-delete/adoptions.add.component.html b/src/app/adoptions/adoptions-delete/adoptions.add.component.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-detail/adoptions-detail.component.html b/src/app/adoptions/adoptions-detail/adoptions-detail.component.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-detail/adoptions-detail.component.ts b/src/app/adoptions/adoptions-detail/adoptions-detail.component.ts new file mode 100644 index 0000000..4d97de6 --- /dev/null +++ b/src/app/adoptions/adoptions-detail/adoptions-detail.component.ts @@ -0,0 +1,27 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { AdoptionsService } from '../adoptions.service'; +import { Adoptions } from '../adoptions'; + +@Component({ + selector: 'app-adoptions-detail', + templateUrl: './adoptions-detail.component.html', + standalone: true, + imports: [] +}) +export class AdoptionsDetailComponent implements OnInit { + public adoptions: Adoptions = new Adoptions(); + public adoptionsId: string; + + constructor(private route: ActivatedRoute, + private adoptionsService: AdoptionsService) { + } + + ngOnInit(): void { + this.adoptionsId = this.route.snapshot.paramMap.get('id'); + this.adoptionsService.getResource(this.adoptionsId).subscribe( + adoptions => { + this.adoptions = adoptions; + }); + } +} diff --git a/src/app/adoptions/adoptions-edit/adoptions-edit.component.html b/src/app/adoptions/adoptions-edit/adoptions-edit.component.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts b/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-list/adoptions-list.component.html b/src/app/adoptions/adoptions-list/adoptions-list.component.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-list/adoptions-list.component.ts b/src/app/adoptions/adoptions-list/adoptions-list.component.ts new file mode 100644 index 0000000..891dd70 --- /dev/null +++ b/src/app/adoptions/adoptions-list/adoptions-list.component.ts @@ -0,0 +1,41 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { Adoptions } from '../adoptions'; +import { AdoptionsService } from '../adoptions.service'; +import { PagedResourceCollection } from '@lagoshny/ngx-hateoas-client'; + +@Component({ + selector: 'app-adoptions-list', + standalone: true, + imports: [], + templateUrl: './adoptions-list.component.html' +}) +export class AdoptionsListComponent implements OnInit{ + public adoptions: Adoptions[] = []; + public pageSize = 5; + public page = 1; + public totalAdoptions = 0; + + constructor( + public router: Router, + private adoptionsService: AdoptionsService) { + } + + ngOnInit(): void { + this.adoptionsService.getPage({ pageParams: { size: this.pageSize }, sort: { id: 'ASC' } }).subscribe( + (page: PagedResourceCollection) => { + this.adoptions = page.resources; + this.totalAdoptions = page.totalElements; + }); + } + + changePage(): void { + this.adoptionsService.getPage({ pageParams: { page: this.page - 1, size: this.pageSize }, sort: { id: 'ASC' } }).subscribe( + (page: PagedResourceCollection) => this.adoptions = page.resources); + } + + detail(adoptions: Adoptions): void { + this.router.navigate(['adoptions', adoptions.id]); + } + +} diff --git a/src/app/adoptions/adoptions-search/adoptions-search.component.html b/src/app/adoptions/adoptions-search/adoptions-search.component.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions-search/adoptions-search.component.ts b/src/app/adoptions/adoptions-search/adoptions-search.component.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/app/adoptions/adoptions.service.ts b/src/app/adoptions/adoptions.service.ts new file mode 100644 index 0000000..e3fc5c9 --- /dev/null +++ b/src/app/adoptions/adoptions.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/internal/Observable'; +import { HateoasResourceOperation, ResourceCollection } from '@lagoshny/ngx-hateoas-client'; +import { Adoptions } from "./adoptions" + +@Injectable({providedIn: 'root'}) +export class AdoptionsService extends HateoasResourceOperation { + + constructor() { + super(Adoptions); + } + + public findById(query: string): Observable> { + return this.searchCollection('findById', { params: { text: query } }); + } +} + diff --git a/src/app/adoptions/adoptions.ts b/src/app/adoptions/adoptions.ts new file mode 100644 index 0000000..231c5bf --- /dev/null +++ b/src/app/adoptions/adoptions.ts @@ -0,0 +1,17 @@ +import { HateoasResource, Resource } from '@lagoshny/ngx-hateoas-client'; +import {User} from "../login-basic/user"; + +@HateoasResource('users') +export class Adoptions extends Resource { + localDateTime: Date; + id: string; + pet: string; + user: User; + + + + constructor(values: object = {}) { + super(); + Object.assign(this as any, values); + } +} From dbec58ec483834a59d754feddcc2f9543bb7bc49 Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 8 May 2024 18:29:49 +0200 Subject: [PATCH 02/13] adoptions --- .../adoptions-add/adoptions-add.component.ts | 34 +++++++++++++++++++ .../adoptions-delete.component.ts | 2 +- .../adoptions-edit.component.ts | 32 +++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.ts b/src/app/adoptions/adoptions-add/adoptions-add.component.ts index e69de29..3cd58aa 100644 --- a/src/app/adoptions/adoptions-add/adoptions-add.component.ts +++ b/src/app/adoptions/adoptions-add/adoptions-add.component.ts @@ -0,0 +1,34 @@ +import { Component, OnInit } from '@angular/core'; +import { Adoptions } from '../adoptions'; +import { Router } from '@angular/router'; +import { AdoptionsService } from '../adoptions.service'; +import { AuthenticationBasicService } from 'src/app/login-basic/authentication-basic.service'; +import { User } from 'src/app/login-basic/user'; +import { UserService } from 'src/app/user/user.service'; + +@Component({ + selector: 'app-adoptions-add', + templateUrl: './take-add.component.html', + imports: [], + standalone: true +}) +export class AdoptionsAddComponent implements OnInit{ + public adoptions: Adoptions; + public user: User; + + constructor(private router: Router, + private adoptionsService: AdoptionsService, + private userService: UserService, + private authenticationService: AuthenticationBasicService) { + } + + ngOnInit(): void { + this.adoptions = new Adoptions(); + this.userService.getResource(this.getCurrentUserName()).subscribe( + (user: User) => this.user = user ); + } + + getCurrentUserName(): string { + return this.authenticationService.getCurrentUser().username; + } +} diff --git a/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts b/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts index 18a3bee..65353e8 100644 --- a/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts +++ b/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts @@ -27,7 +27,7 @@ export class AdoptionsDeleteComponent implements OnInit { delete(): void { this.adoptionsService.deleteResource(this.adoptions).subscribe( () => { - this.router.navigate(['']); + this.router.navigate(['id']); }); } } diff --git a/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts b/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts index e69de29..e06325b 100644 --- a/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts +++ b/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts @@ -0,0 +1,32 @@ +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 { AdoptionsService } from '../adoptions.service'; +import { Adoptions } from '../adoptions'; + +@Component({ + selector: 'app-adoptions-edit', + templateUrl: './adoptions-edit.component.html', + standalone: true, + imports: [] +}) +export class AdoptionsEditComponent implements OnInit { + public adoptions: Adoptions = new Adoptions(); + + constructor(private route: ActivatedRoute, + private router: Router, + private adoptionsService: AdoptionsService, + private authenticationService: AuthenticationBasicService) { + } + + ngOnInit(): void { + const id = this.route.snapshot.paramMap.get('id'); + this.adoptionsService.getResource(id).subscribe( + (adoptions: Adoptions) => this.adoptions = adoptions ); + } + + getCurrentUserName(): string { + return this.authenticationService.getCurrentUser().username; + } +} From 9811a64e48f804ad4ddb925ab4b6a349f9ed9b80 Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 8 May 2024 18:35:50 +0200 Subject: [PATCH 03/13] adoptions --- .../adoptions-search.component.html | 1 + .../adoptions-search.component.ts | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/app/adoptions/adoptions-search/adoptions-search.component.html b/src/app/adoptions/adoptions-search/adoptions-search.component.html index e69de29..27b3e56 100644 --- a/src/app/adoptions/adoptions-search/adoptions-search.component.html +++ b/src/app/adoptions/adoptions-search/adoptions-search.component.html @@ -0,0 +1 @@ +

adoptions-search works!

diff --git a/src/app/adoptions/adoptions-search/adoptions-search.component.ts b/src/app/adoptions/adoptions-search/adoptions-search.component.ts index e69de29..03f1dcc 100644 --- a/src/app/adoptions/adoptions-search/adoptions-search.component.ts +++ b/src/app/adoptions/adoptions-search/adoptions-search.component.ts @@ -0,0 +1,44 @@ +import { Component, EventEmitter, Output } from '@angular/core'; +import { AdoptionsService } from '../adoptions.service'; +import { Adoptions } from '../adoptions'; +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-propagator-search', + templateUrl: './propagator-search.component.html', + standalone: true, + imports: [] +}) + +export class AdoptionsSearchComponent { + @Output() emitResults: EventEmitter = new EventEmitter(); + searchFailed = false; + searching = false; + + constructor(private AdoptionsService: AdoptionsService) { + } + + autocomplete: OperatorFunction = (text$: Observable) => + text$.pipe( + debounceTime(500), + distinctUntilChanged(), + tap(() => this.searching = true), + switchMap(term => term.length < 3 ? of([]) : + this.AdoptionsService.findById(term).pipe( + map((collection: ResourceCollection) => collection.resources), + tap(() => this.searchFailed = false), + catchError(() => { + this.searchFailed = true; + return of([]); + }) + ) + ), + tap(() => this.searching = false ) + ) + + select(item: any): void { + this.emitResults.emit(item as Adoptions); + } +} From b6fc37b14d02b3cb9f6f7d0be8c2d1decf0846c3 Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 15 May 2024 17:38:23 +0200 Subject: [PATCH 04/13] adoptions --- .../adoptions-add/adoptions-add.component.ts | 2 -- .../adoptions-delete/adoptions-delete.component.ts | 4 +--- .../adoptions-detail/adoptions-detail.component.ts | 4 +--- .../adoptions-edit/adoptions-edit.component.ts | 2 -- .../adoptions-list/adoptions-list.component.ts | 2 -- .../adoptions-search/adoptions-search.component.ts | 6 ++---- src/app/app-routing.module.ts | 13 +++++++++++++ src/app/app.module.ts | 14 +++++++++++++- 8 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.ts b/src/app/adoptions/adoptions-add/adoptions-add.component.ts index 3cd58aa..40cd4e8 100644 --- a/src/app/adoptions/adoptions-add/adoptions-add.component.ts +++ b/src/app/adoptions/adoptions-add/adoptions-add.component.ts @@ -9,8 +9,6 @@ import { UserService } from 'src/app/user/user.service'; @Component({ selector: 'app-adoptions-add', templateUrl: './take-add.component.html', - imports: [], - standalone: true }) export class AdoptionsAddComponent implements OnInit{ public adoptions: Adoptions; diff --git a/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts b/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts index 65353e8..0666226 100644 --- a/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts +++ b/src/app/adoptions/adoptions-delete/adoptions-delete.component.ts @@ -5,9 +5,7 @@ import { AdoptionsService } from '../adoptions.service'; @Component({ selector: 'app-adoptions-delete', - templateUrl: './adoptions.add.component.html', - standalone: true, - imports: [] + templateUrl: './adoptions.add.component.html' }) export class AdoptionsDeleteComponent implements OnInit { public adoptions: Adoptions = new Adoptions(); diff --git a/src/app/adoptions/adoptions-detail/adoptions-detail.component.ts b/src/app/adoptions/adoptions-detail/adoptions-detail.component.ts index 4d97de6..fb5ba00 100644 --- a/src/app/adoptions/adoptions-detail/adoptions-detail.component.ts +++ b/src/app/adoptions/adoptions-detail/adoptions-detail.component.ts @@ -5,9 +5,7 @@ import { Adoptions } from '../adoptions'; @Component({ selector: 'app-adoptions-detail', - templateUrl: './adoptions-detail.component.html', - standalone: true, - imports: [] + templateUrl: './adoptions-detail.component.html' }) export class AdoptionsDetailComponent implements OnInit { public adoptions: Adoptions = new Adoptions(); diff --git a/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts b/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts index e06325b..2835f6d 100644 --- a/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts +++ b/src/app/adoptions/adoptions-edit/adoptions-edit.component.ts @@ -8,8 +8,6 @@ import { Adoptions } from '../adoptions'; @Component({ selector: 'app-adoptions-edit', templateUrl: './adoptions-edit.component.html', - standalone: true, - imports: [] }) export class AdoptionsEditComponent implements OnInit { public adoptions: Adoptions = new Adoptions(); diff --git a/src/app/adoptions/adoptions-list/adoptions-list.component.ts b/src/app/adoptions/adoptions-list/adoptions-list.component.ts index 891dd70..522ddeb 100644 --- a/src/app/adoptions/adoptions-list/adoptions-list.component.ts +++ b/src/app/adoptions/adoptions-list/adoptions-list.component.ts @@ -6,8 +6,6 @@ import { PagedResourceCollection } from '@lagoshny/ngx-hateoas-client'; @Component({ selector: 'app-adoptions-list', - standalone: true, - imports: [], templateUrl: './adoptions-list.component.html' }) export class AdoptionsListComponent implements OnInit{ diff --git a/src/app/adoptions/adoptions-search/adoptions-search.component.ts b/src/app/adoptions/adoptions-search/adoptions-search.component.ts index 03f1dcc..696e582 100644 --- a/src/app/adoptions/adoptions-search/adoptions-search.component.ts +++ b/src/app/adoptions/adoptions-search/adoptions-search.component.ts @@ -6,10 +6,8 @@ import { catchError, debounceTime, distinctUntilChanged, map, switchMap, tap } f import { ResourceCollection } from '@lagoshny/ngx-hateoas-client'; @Component({ - selector: 'app-propagator-search', - templateUrl: './propagator-search.component.html', - standalone: true, - imports: [] + selector: 'app-adoptions-search', + templateUrl: './adoptions-search.component.html' }) export class AdoptionsSearchComponent { diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 1f6d256..43d23e2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,6 +8,13 @@ import { UserDetailComponent } from './user/user-detail/user-detail.component'; import { UserRegisterComponent } from './user/user-register/user-register.component'; import { UserEditComponent } from './user/user-edit/user-edit.component'; import { UserDeleteComponent } from './user/user-delete/user-delete.component'; +import {AdoptionsSearchComponent} from './adoptions/adoptions-search/adoptions-search.component'; +import {AdoptionsListComponent} from './adoptions/adoptions-list/adoptions-list.component'; +import {AdoptionsEditComponent} from './adoptions/adoptions-edit/adoptions-edit.component'; +import {AdoptionsDetailComponent} from './adoptions/adoptions-detail/adoptions-detail.component'; +import {AdoptionsDeleteComponent} from './adoptions/adoptions-delete/adoptions-delete.component'; +import {AdoptionsAddComponent} from "./adoptions/adoptions-add/adoptions-add.component"; + const routes: Routes = [ { path: 'users/create', component: UserRegisterComponent}, @@ -18,6 +25,12 @@ const routes: Routes = [ { path: 'about', component: AboutComponent}, { path: '404', component: NotFoundComponent}, { path: '', redirectTo: 'about', pathMatch: 'full'}, + { path: 'adoptions', component: AdoptionsListComponent }, + { path: 'adoptions/create', component: AdoptionsAddComponent }, + { path: 'adoptions/edit', component: AdoptionsEditComponent }, + { path: 'adoptions/delete', component: AdoptionsDeleteComponent }, + { path: 'adoptions/detail', component: AdoptionsDetailComponent }, + { path: 'adoptions/search', component: AdoptionsSearchComponent } ]; @NgModule({ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 40c973a..b33207d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,6 +23,12 @@ import {HttpErrorInterceptor} from './error-handler/http-error-interceptor'; import {AuthenticationBasicService} from './login-basic/authentication-basic.service'; import {LoggedInGuard} from './login-basic/loggedin.guard'; import {UserService} from './user/user.service'; +import {AdoptionsSearchComponent} from './adoptions/adoptions-search/adoptions-search.component'; +import {AdoptionsListComponent} from './adoptions/adoptions-list/adoptions-list.component'; +import {AdoptionsEditComponent} from './adoptions/adoptions-edit/adoptions-edit.component'; +import {AdoptionsDetailComponent} from './adoptions/adoptions-detail/adoptions-detail.component'; +import {AdoptionsDeleteComponent} from './adoptions/adoptions-delete/adoptions-delete.component'; +import {AdoptionsAddComponent} from "./adoptions/adoptions-add/adoptions-add.component"; @NgModule({ declarations: [ @@ -35,7 +41,13 @@ import {UserService} from './user/user.service'; UserRegisterComponent, UserEditComponent, UserDeleteComponent, - UserSearchComponent + UserSearchComponent, + AdoptionsSearchComponent, + AdoptionsAddComponent, + AdoptionsDeleteComponent, + AdoptionsDetailComponent, + AdoptionsEditComponent, + AdoptionsListComponent ], imports: [ BrowserModule, From fe8d6917d5dc283d740da089445bb99eaecf0cb8 Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 15 May 2024 17:43:53 +0200 Subject: [PATCH 05/13] error per obrir ng serve --- src/app/adoptions/adoptions-add/adoptions-add.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.ts b/src/app/adoptions/adoptions-add/adoptions-add.component.ts index 40cd4e8..6b082c3 100644 --- a/src/app/adoptions/adoptions-add/adoptions-add.component.ts +++ b/src/app/adoptions/adoptions-add/adoptions-add.component.ts @@ -8,7 +8,7 @@ import { UserService } from 'src/app/user/user.service'; @Component({ selector: 'app-adoptions-add', - templateUrl: './take-add.component.html', + templateUrl: './adoptions-add.component.html', }) export class AdoptionsAddComponent implements OnInit{ public adoptions: Adoptions; From 9fbe63dbef09cf53342d7eb931b61353543bab6e Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 15 May 2024 18:06:49 +0200 Subject: [PATCH 06/13] adoptions --- .../adoptions-add.component.html | 30 +++++++++++++++++++ .../adoptions-add/adoptions-add.component.ts | 13 ++++---- src/app/adoptions/adoptions.ts | 1 + 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.html b/src/app/adoptions/adoptions-add/adoptions-add.component.html index e69de29..009d39b 100644 --- a/src/app/adoptions/adoptions-add/adoptions-add.component.html +++ b/src/app/adoptions/adoptions-add/adoptions-add.component.html @@ -0,0 +1,30 @@ +
+
+ + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+
diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.ts b/src/app/adoptions/adoptions-add/adoptions-add.component.ts index 6b082c3..db5f4fa 100644 --- a/src/app/adoptions/adoptions-add/adoptions-add.component.ts +++ b/src/app/adoptions/adoptions-add/adoptions-add.component.ts @@ -5,6 +5,7 @@ import { AdoptionsService } from '../adoptions.service'; import { AuthenticationBasicService } from 'src/app/login-basic/authentication-basic.service'; import { User } from 'src/app/login-basic/user'; import { UserService } from 'src/app/user/user.service'; +import {FormControl, FormGroup} from "@angular/forms"; @Component({ selector: 'app-adoptions-add', @@ -13,20 +14,20 @@ import { UserService } from 'src/app/user/user.service'; export class AdoptionsAddComponent implements OnInit{ public adoptions: Adoptions; public user: User; + public date: Date; constructor(private router: Router, private adoptionsService: AdoptionsService, private userService: UserService, - private authenticationService: AuthenticationBasicService) { + private authenticationService: AuthenticationBasicService){ } - ngOnInit(): void { this.adoptions = new Adoptions(); - this.userService.getResource(this.getCurrentUserName()).subscribe( - (user: User) => this.user = user ); } - getCurrentUserName(): string { - return this.authenticationService.getCurrentUser().username; + onSubmit(): void { + this.adoptionsService.createResource({body: this.adoptions}).subscribe( + (adoptions:Adoptions) => this.router.navigate([adoptions.uri]) + ); } } diff --git a/src/app/adoptions/adoptions.ts b/src/app/adoptions/adoptions.ts index 231c5bf..2b7461d 100644 --- a/src/app/adoptions/adoptions.ts +++ b/src/app/adoptions/adoptions.ts @@ -7,6 +7,7 @@ export class Adoptions extends Resource { id: string; pet: string; user: User; + uri: string; From e9599c07f4b534f30fdf965d56cc1d7854ccd9d4 Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 15 May 2024 18:14:33 +0200 Subject: [PATCH 07/13] adoptions --- .../adoptions-list.component.html | 21 +++++++++++++++++++ .../adoptions-list.component.ts | 3 ++- src/app/app-routing.module.ts | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/app/adoptions/adoptions-list/adoptions-list.component.html b/src/app/adoptions/adoptions-list/adoptions-list.component.html index e69de29..65f282b 100644 --- a/src/app/adoptions/adoptions-list/adoptions-list.component.html +++ b/src/app/adoptions/adoptions-list/adoptions-list.component.html @@ -0,0 +1,21 @@ + + +
+
+
+
+
Id
+ {{adoptions.id}} +
+
+
Time
+

{{adoptions.localDateTime}}

+
+
+
+
+ + + diff --git a/src/app/adoptions/adoptions-list/adoptions-list.component.ts b/src/app/adoptions/adoptions-list/adoptions-list.component.ts index 522ddeb..aab25c6 100644 --- a/src/app/adoptions/adoptions-list/adoptions-list.component.ts +++ b/src/app/adoptions/adoptions-list/adoptions-list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, EventEmitter, OnInit, Output} from '@angular/core'; import { Router } from '@angular/router'; import { Adoptions } from '../adoptions'; import { AdoptionsService } from '../adoptions.service'; @@ -13,6 +13,7 @@ export class AdoptionsListComponent implements OnInit{ public pageSize = 5; public page = 1; public totalAdoptions = 0; + @Output() emitResults = new EventEmitter(); constructor( public router: Router, diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 43d23e2..fbbd488 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -25,7 +25,7 @@ const routes: Routes = [ { path: 'about', component: AboutComponent}, { path: '404', component: NotFoundComponent}, { path: '', redirectTo: 'about', pathMatch: 'full'}, - { path: 'adoptions', component: AdoptionsListComponent }, + { path: 'adoptions/list' , component: AdoptionsListComponent }, { path: 'adoptions/create', component: AdoptionsAddComponent }, { path: 'adoptions/edit', component: AdoptionsEditComponent }, { path: 'adoptions/delete', component: AdoptionsDeleteComponent }, From 54cd10fac5a192a65e5aa603edae4be4f4268df8 Mon Sep 17 00:00:00 2001 From: gerardmallol Date: Wed, 15 May 2024 18:29:00 +0200 Subject: [PATCH 08/13] adoptions --- .../adoptions-add/adoptions-add.component.html | 10 ++++++---- .../adoptions-delete/adoptions-delete.component.ts | 2 +- .../adoptions-delete/adoptions.add.component.html | 0 .../adoptions-delete/adoptions.delete.component.html | 1 + .../adoptions-detail/adoptions-detail.component.html | 1 + .../adoptions-edit/adoptions-edit.component.html | 1 + 6 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 src/app/adoptions/adoptions-delete/adoptions.add.component.html create mode 100644 src/app/adoptions/adoptions-delete/adoptions.delete.component.html diff --git a/src/app/adoptions/adoptions-add/adoptions-add.component.html b/src/app/adoptions/adoptions-add/adoptions-add.component.html index 009d39b..fceffa4 100644 --- a/src/app/adoptions/adoptions-add/adoptions-add.component.html +++ b/src/app/adoptions/adoptions-add/adoptions-add.component.html @@ -1,22 +1,24 @@
- -
- +
+ + +
+
-