-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from UdL-EPS-SoftArch/Delete-RouteVersion
Delete route version
- Loading branch information
Showing
9 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/app/route-versions/route-versions-delete/route-versions-delete.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>route-versions-delete works!</p> |
Empty file.
10 changes: 10 additions & 0 deletions
10
src/app/route-versions/route-versions-delete/route-versions-delete.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/app/route-versions/route-versions-list/route-versions-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="row"> | ||
<div class="card col-lg-4 col-md-6 col-sm-12 col-xs-12" *ngFor="let version of routeVersions"> | ||
<div class="card-block"> | ||
<div class="card-header row m-1 text-center" > | ||
<h5>Route Version</h5> | ||
</div> | ||
<div class="card-body row m-1"> | ||
<div class="col-md-6 p-3"> | ||
<h6 class="card-subtitle text-muted">CreatedBy</h6> | ||
<p class="card-text">{{version.createdBy?.username}}</p> | ||
</div> | ||
<div class="col-md-6 p-3"> | ||
<h6 class="card-subtitle text-muted">Creation date</h6> | ||
<p class="card-text">{{version.creationDate | date: 'dd/MM/yyyy HH:mm:ss'}}</p> | ||
</div> | ||
<div class="col-md-6 p-3"> | ||
<h6 class="card-subtitle text-muted">Title</h6> | ||
<p class="card-text">{{version.title}}</p> | ||
</div> | ||
</div> | ||
<div class="card-footer text-right row"> | ||
<div class="btn-group" role="group" aria-label="Basic example"> | ||
<button type="button" *ngIf="!isRole('admin')" (click)="delete(version)" class="btn col-6 m-1 btn-outline-danger">Delete</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<ngb-pagination class="d-flex justify-content-center" [(page)]="page" [pageSize]="pageSize" [collectionSize]="totalRoutes" (pageChange)="changePage()"> | ||
</ngb-pagination> |
Empty file.
76 changes: 76 additions & 0 deletions
76
src/app/route-versions/route-versions-list/route-versions-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
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 implements OnInit { | ||
|
||
public routesPagedResource: PagedResourceCollection<RouteVersion>; | ||
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<RouteVersion>) => { | ||
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; | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
changePage(): void { | ||
this.routesPagedResource.customPage( | ||
{pageParams: {page: this.page - 1, size: this.pageSize}, | ||
sort: {name: 'ASC'}}).subscribe( | ||
(page: PagedResourceCollection<RouteVersion>) => { | ||
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); | ||
} | ||
|
||
delete(version : RouteVersion ): void { | ||
this.routeVersionService.deleteResource(version).subscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters