From 7a2f22e3fdefe98b760988e4881a4fe5ae198135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Sun, 21 Jan 2024 23:52:48 +0100 Subject: [PATCH 1/8] Create component List RouteVersion --- src/app/app.module.ts | 4 +++- .../route-versions-list.component.html | 1 + .../route-versions-list.component.scss | 0 .../route-versions-list.component.ts | 10 ++++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/app/route-versions/route-versions-list/route-versions-list.component.html create mode 100644 src/app/route-versions/route-versions-list/route-versions-list.component.scss create mode 100644 src/app/route-versions/route-versions-list/route-versions-list.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f3be4a7..31da045 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -48,6 +48,7 @@ import {RouteFollowedDetailComponent} from "./routeFollowed/route-followed-detai import { RouteVersionsCreateComponent } from './route-versions/route-versions-create/route-versions-create.component'; import { ServiceWorkerModule } from '@angular/service-worker'; import {NgxDatatableModule} from "@swimlane/ngx-datatable"; +import { RouteVersionsListComponent } from './route-versions/route-versions-list/route-versions-list.component'; @NgModule({ declarations: [ @@ -78,7 +79,8 @@ import {NgxDatatableModule} from "@swimlane/ngx-datatable"; RouteFollowedEditComponent, RouteFollowedListComponent, RouteFollowedDetailComponent, - RouteVersionsCreateComponent + RouteVersionsCreateComponent, + RouteVersionsListComponent ], imports: [ BrowserModule, diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.html b/src/app/route-versions/route-versions-list/route-versions-list.component.html new file mode 100644 index 0000000..97f09bd --- /dev/null +++ b/src/app/route-versions/route-versions-list/route-versions-list.component.html @@ -0,0 +1 @@ +

route-versions-list works!

diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.scss b/src/app/route-versions/route-versions-list/route-versions-list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.ts b/src/app/route-versions/route-versions-list/route-versions-list.component.ts new file mode 100644 index 0000000..eb78ad8 --- /dev/null +++ b/src/app/route-versions/route-versions-list/route-versions-list.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-route-versions-list', + templateUrl: './route-versions-list.component.html', + styleUrls: ['./route-versions-list.component.scss'] +}) +export class RouteVersionsListComponent { + +} From 8e4348e6084469f01cf475bbbc7eacded180600f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Sun, 21 Jan 2024 23:56:58 +0100 Subject: [PATCH 2/8] Create Route Version List HTML --- .../route-versions-list.component.html | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.html b/src/app/route-versions/route-versions-list/route-versions-list.component.html index 97f09bd..d09735f 100644 --- a/src/app/route-versions/route-versions-list/route-versions-list.component.html +++ b/src/app/route-versions/route-versions-list/route-versions-list.component.html @@ -1 +1,23 @@ -

route-versions-list works!

+
+
+
+
+
Route Version
+
+
+
+
CreatedBy
+

{{version.createdBy?.username}}

+
+
+
Creation date
+

{{version.creationDate | date: 'dd/MM/yyyy HH:mm:ss'}}

+
+
+
Title
+

{{version.title}}

+
+
+
+
+
From 121cfd3aa11567a99b8503a2a27aadd04f9c1624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Mon, 22 Jan 2024 00:21:04 +0100 Subject: [PATCH 3/8] Create Route Version List Controller --- .../route-versions-list.component.ts | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.ts b/src/app/route-versions/route-versions-list/route-versions-list.component.ts index eb78ad8..4e566a5 100644 --- a/src/app/route-versions/route-versions-list/route-versions-list.component.ts +++ b/src/app/route-versions/route-versions-list/route-versions-list.component.ts @@ -1,10 +1,61 @@ -import { Component } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; +import {PagedResourceCollection} from "@lagoshny/ngx-hateoas-client"; +import {RouteVersion} from "../routeVersion.entity"; +import {Router} from "@angular/router"; +import {RouteVersionsService} from "../route-versions.service"; +import {AuthenticationBasicService} from "../../login-basic/authentication-basic.service"; +import {HttpClient} from "@angular/common/http"; +import {User} from "../../login-basic/user"; @Component({ selector: 'app-route-versions-list', templateUrl: './route-versions-list.component.html', styleUrls: ['./route-versions-list.component.scss'] }) -export class RouteVersionsListComponent { +export class RouteVersionsListComponent implements OnInit { + public routesPagedResource: PagedResourceCollection; + public routeVersions: RouteVersion[] = []; + public pageSize = 5; + public page = 1; + public totalRoutes = 0; + public types: []; + public type: string; + public params: any; + + constructor( + public router: Router, + private routeVersionService: RouteVersionsService, + private authenticationService: AuthenticationBasicService, + private http: HttpClient) { + //this.params = this.router.getCurrentNavigation().extras.state?.['param'] + } + + ngOnInit(): void { + this.routeVersionService.getPage({ pageParams: { size: this.pageSize }, sort: { username: 'ASC' } }).subscribe( + async (page: PagedResourceCollection) => { + function delay(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + await delay(2000) + this.routeVersions = page.resources; //Comprovar si hi es o no, i si no hi es li afegeix-ho jo. + this.totalRoutes = page.totalElements; + this.routesPagedResource = page; + this.routeVersions.map(routes => { + routes.getRelation('createdBy') + .subscribe((user: User) => { + routes.createdBy = user; + }); + }); + }); + } + + isRole(role: string): boolean { + return this.authenticationService.isRole(role); + } + + delete(version : RouteVersion ): void { + this.routeVersionService.deleteResource(version).subscribe(); + } } From 6ca48ad9050053e12e2d45f5eecd0ea7fbdb6c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Mon, 22 Jan 2024 00:26:30 +0100 Subject: [PATCH 4/8] Insert Route Version List on Route Detail --- src/app/routes/route-detail/route-detail.component.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/routes/route-detail/route-detail.component.html b/src/app/routes/route-detail/route-detail.component.html index 6cb7877..7a42593 100644 --- a/src/app/routes/route-detail/route-detail.component.html +++ b/src/app/routes/route-detail/route-detail.component.html @@ -36,3 +36,7 @@
Description
+
+
+
+ From 816a6e58698fab8d4f3525acc0c1428b76e98548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Mon, 22 Jan 2024 00:30:57 +0100 Subject: [PATCH 5/8] Insert Route Version List on Route Detail --- src/app/routes/route-detail/route-detail.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/routes/route-detail/route-detail.component.html b/src/app/routes/route-detail/route-detail.component.html index 7a42593..46cfbd6 100644 --- a/src/app/routes/route-detail/route-detail.component.html +++ b/src/app/routes/route-detail/route-detail.component.html @@ -39,4 +39,4 @@
Description

- + From efd28acd6e5f91ecdb9281275f3fc01920eec235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Mon, 22 Jan 2024 00:53:34 +0100 Subject: [PATCH 6/8] Insert Change Page on List Route Versions --- .../route-versions-list.component.html | 2 ++ .../route-versions-list.component.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.html b/src/app/route-versions/route-versions-list/route-versions-list.component.html index d09735f..5491251 100644 --- a/src/app/route-versions/route-versions-list/route-versions-list.component.html +++ b/src/app/route-versions/route-versions-list/route-versions-list.component.html @@ -21,3 +21,5 @@
Title
+ + diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.ts b/src/app/route-versions/route-versions-list/route-versions-list.component.ts index 4e566a5..cc5cfd1 100644 --- a/src/app/route-versions/route-versions-list/route-versions-list.component.ts +++ b/src/app/route-versions/route-versions-list/route-versions-list.component.ts @@ -51,6 +51,21 @@ export class RouteVersionsListComponent implements OnInit { }); } + changePage(): void { + this.routesPagedResource.customPage( + {pageParams: {page: this.page - 1, size: this.pageSize}, + sort: {name: 'ASC'}}).subscribe( + (page: PagedResourceCollection) => { + this.routeVersions = page.resources; + this.routeVersions.map(routes => { + routes.getRelation('createdBy') + .subscribe((user: User) => { + routes.createdBy = user; + }); + }); + }); + } + isRole(role: string): boolean { return this.authenticationService.isRole(role); } From 14e78579ec9a0d8ef10d82468229bcd187971c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Mon, 22 Jan 2024 01:09:18 +0100 Subject: [PATCH 7/8] Create Route Versions Delete Component --- src/app/app.module.ts | 4 +++- .../route-versions-delete.component.html | 1 + .../route-versions-delete.component.scss | 0 .../route-versions-delete.component.ts | 10 ++++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/app/route-versions/route-versions-delete/route-versions-delete.component.html create mode 100644 src/app/route-versions/route-versions-delete/route-versions-delete.component.scss create mode 100644 src/app/route-versions/route-versions-delete/route-versions-delete.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 31da045..9b8faab 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -49,6 +49,7 @@ import { RouteVersionsCreateComponent } from './route-versions/route-versions-cr import { ServiceWorkerModule } from '@angular/service-worker'; import {NgxDatatableModule} from "@swimlane/ngx-datatable"; import { RouteVersionsListComponent } from './route-versions/route-versions-list/route-versions-list.component'; +import { RouteVersionsDeleteComponent } from './route-versions/route-versions-delete/route-versions-delete.component'; @NgModule({ declarations: [ @@ -80,7 +81,8 @@ import { RouteVersionsListComponent } from './route-versions/route-versions-list RouteFollowedListComponent, RouteFollowedDetailComponent, RouteVersionsCreateComponent, - RouteVersionsListComponent + RouteVersionsListComponent, + RouteVersionsDeleteComponent ], imports: [ BrowserModule, diff --git a/src/app/route-versions/route-versions-delete/route-versions-delete.component.html b/src/app/route-versions/route-versions-delete/route-versions-delete.component.html new file mode 100644 index 0000000..5af9069 --- /dev/null +++ b/src/app/route-versions/route-versions-delete/route-versions-delete.component.html @@ -0,0 +1 @@ +

route-versions-delete works!

diff --git a/src/app/route-versions/route-versions-delete/route-versions-delete.component.scss b/src/app/route-versions/route-versions-delete/route-versions-delete.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/route-versions/route-versions-delete/route-versions-delete.component.ts b/src/app/route-versions/route-versions-delete/route-versions-delete.component.ts new file mode 100644 index 0000000..b2c6e3f --- /dev/null +++ b/src/app/route-versions/route-versions-delete/route-versions-delete.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-route-versions-delete', + templateUrl: './route-versions-delete.component.html', + styleUrls: ['./route-versions-delete.component.scss'] +}) +export class RouteVersionsDeleteComponent { + +} From 004ac83fb9a5a7b135d3c326da77f502d6a27b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreu=20P=C3=A9rez?= Date: Mon, 22 Jan 2024 01:26:45 +0100 Subject: [PATCH 8/8] Insert Button Delete Route Version --- src/app/app-routing.module.ts | 2 ++ .../route-versions-list/route-versions-list.component.html | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 5465f4b..81648b7 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -27,6 +27,7 @@ import {WaypointListComponent} from "./waypoint/waypoint-list/waypoint-list.comp import {WaypointDetailComponent} from "./waypoint/waypoint-detail/waypoint-detail.component"; import {WaypointEditComponent} from "./waypoint/waypoint-edit/waypoint-edit.component"; import {WaypointDeleteComponent} from "./waypoint/waypoint-delete/waypoint-delete.component"; +import {RouteVersionsDeleteComponent} from "./route-versions/route-versions-delete/route-versions-delete.component"; const routes: Routes = [ { path: 'users/create', component: UserRegisterComponent}, @@ -42,6 +43,7 @@ const routes: Routes = [ { path: 'routes', component: RouteListComponent, canActivate: [CheckLoggedInGuard] }, { path: 'route-versions-create', component: RouteVersionsCreateComponent, canActivate: [CheckIsNotAdminGuard] }, + { path: 'route-versions/delete', component: RouteVersionsDeleteComponent, canActivate: [CheckIsNotAdminGuard] }, { path: 'routeFollowed/create', component: RouteFollowedCreateComponent, canActivate: [CheckIsNotAdminGuard] }, { path: 'routeFollowed/:id/delete', component: RouteFollowedDeleteComponent, canActivate: [CheckIsNotAdminGuard]}, diff --git a/src/app/route-versions/route-versions-list/route-versions-list.component.html b/src/app/route-versions/route-versions-list/route-versions-list.component.html index 5491251..f41addb 100644 --- a/src/app/route-versions/route-versions-list/route-versions-list.component.html +++ b/src/app/route-versions/route-versions-list/route-versions-list.component.html @@ -18,6 +18,11 @@
Title

{{version.title}}

+