-
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 #23 from UdL-EPS-SoftArch/coordinate-entity
Coordinates all functionalities
- Loading branch information
Showing
26 changed files
with
633 additions
and
10 deletions.
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
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
42 changes: 42 additions & 0 deletions
42
src/app/coordinate/coordinate-create/coordinate-create.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,42 @@ | ||
<form id="user-form" (ngSubmit)="onSubmit()" #form="ngForm"> | ||
<fieldset> | ||
|
||
<!-- Title input --> | ||
<div class="form-group mb-3"> | ||
<label class="control-label" for="coordinate">Coordinate</label> | ||
<input id="coordinate" name="coordinate" type="text" class="form-control" required | ||
[(ngModel)]="coordinate.coordinate" | ||
pattern="^(-?([0-8]?[0-9](\.\d+)?|89(.[0]+)?)[,])+(-?([1]?[0-7]?[0-9](\.\d+)?|179((.[0]+)?)))$" | ||
#coordinate.coordinate="ngModel"> | ||
<div | ||
*ngIf="form.controls['coordinate']?.invalid && (form.controls['coordinate'].dirty || form.controls['coordinate'].touched)" | ||
class="alert alert-danger"> | ||
<div *ngIf="form.controls['coordinate'].errors.required"> | ||
Coordinate is required. | ||
</div> | ||
<div *ngIf="form.controls['coordinate'].errors.pattern"> | ||
Coordinate must be in the format: [-89.99999 <-> 89.99999],[-179.99999 <-> 179.99999]<br/> | ||
41.99999,2.11111 | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Description input --> | ||
<!--<div class="form-group mb-3"> | ||
<label class="control-label" for="route-version">Route version</label> | ||
<input id="route-version" name="route-version" type="text" class="form-control" [(ngModel)]="coordinate.coordinate" | ||
#coordinate="ngModel"> | ||
</div>--> | ||
|
||
<!-- Buttons --> | ||
<div class=" form-group fa-pull-right"> | ||
<button id="routeBack" type="button" (click)="goBackToPrevPage()" | ||
class="btn m-1 btn-outline-primary">Back | ||
</button> | ||
<button id="submit" type="submit" [disabled]="!form.form.valid" | ||
class="btn m-1 btn-success pull-right">Create | ||
</button> | ||
</div> | ||
|
||
</fieldset> | ||
</form> |
Empty file.
33 changes: 33 additions & 0 deletions
33
src/app/coordinate/coordinate-create/coordinate-create.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,33 @@ | ||
import {Component} from '@angular/core'; | ||
import {Coordinate} from "../coordinate.entity"; | ||
import {CoordinateService} from "../coordinate.service"; | ||
import {Router} from "@angular/router"; | ||
import {Location} from "@angular/common"; | ||
|
||
|
||
@Component({ | ||
selector: 'app-coordinate-create', | ||
templateUrl: './coordinate-create.component.html', | ||
styleUrls: ['./coordinate-create.component.scss'] | ||
}) | ||
export class CoordinateCreateComponent { | ||
public coordinate: Coordinate = new Coordinate(); | ||
|
||
constructor( | ||
private coordinateService: CoordinateService, | ||
private router: Router, | ||
private location: Location | ||
) { | ||
} | ||
|
||
onSubmit(): void { | ||
|
||
this.coordinateService.createResource({body: this.coordinate}).subscribe( | ||
(coordinate: Coordinate) => this.router.navigate([coordinate.uri])); | ||
} | ||
|
||
goBackToPrevPage(): void { | ||
this.location.back(); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/app/coordinate/coordinate-delete/coordinate-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,15 @@ | ||
<div class="panel panel-warning"> | ||
<div class="panel-heading"> | ||
<div class="panel-title">Please, confirm deletion:</div> | ||
</div> | ||
<div class="panel-body"> | ||
<div class="text-center"> | ||
<button id="deleteBtn" type="button" (click)="delete()" | ||
class="btn btn-outline-danger m-1">Delete | ||
</button> | ||
<button id="listBtn" type="button" [routerLink]="['routes', coordinate.id]" | ||
class="btn btn-outline-primary m-1">Cancel | ||
</button> | ||
</div> | ||
</div> | ||
</div> |
Empty file.
33 changes: 33 additions & 0 deletions
33
src/app/coordinate/coordinate-delete/coordinate-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,33 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {ActivatedRoute, Router} from "@angular/router"; | ||
import {Coordinate} from "../coordinate.entity"; | ||
import {CoordinateService} from "../coordinate.service"; | ||
|
||
@Component({ | ||
selector: 'app-coordinate-delete', | ||
templateUrl: './coordinate-delete.component.html', | ||
styleUrls: ['./coordinate-delete.component.scss'] | ||
}) | ||
export class CoordinateDeleteComponent implements OnInit { | ||
|
||
public coordinate: Coordinate = new Coordinate(); | ||
private id: string; | ||
|
||
constructor(private activatedRoute: ActivatedRoute, | ||
private router: Router, | ||
private coordinateService: CoordinateService) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.id = this.activatedRoute.snapshot.paramMap.get('id'); | ||
this.coordinateService.getResource(this.id).subscribe( | ||
c => this.coordinate = c); | ||
} | ||
|
||
delete(): void { | ||
this.coordinateService.deleteResource(this.coordinate).subscribe( | ||
() => { | ||
this.router.navigate(['coordinates']); | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/app/coordinate/coordinate-detail/coordinate-detail.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,40 @@ | ||
<form id="cooridnates-form" #form="ngForm"> | ||
<fieldset> | ||
|
||
<!-- Title input --> | ||
<div class="form-group mb-3"> | ||
<label class="control-label" for="coordinate">Coordinate</label> | ||
<input id="coordinate" name="coordinate" type="text" class="form-control" required | ||
[(ngModel)]="coordinatee.coordinate" | ||
pattern="^(-?([0-8]?[0-9](\.\d+)?|89(.[0]+)?)[,])+(-?([1]?[0-7]?[0-9](\.\d+)?|179((.[0]+)?)))$" | ||
#coordinate="ngModel" [readOnly]="true"> | ||
</div> | ||
|
||
<div class="form-group mb-3"> | ||
<label class="control-label" for="creationDate">Creation date</label> | ||
<input id="creationDate" name="creationDate" type="text" class="form-control" | ||
[(ngModel)]="coordinatee.creationDate" | ||
#creationDate="ngModel" [readOnly]="true"> | ||
</div> | ||
|
||
<!-- Description input --> | ||
<!--<div class="form-group mb-3"> | ||
<label class="control-label" for="route-version">Route version</label> | ||
<input id="route-version" name="route-version" type="text" class="form-control" [(ngModel)]="coordinate.coordinate" | ||
#coordinate="ngModel"> | ||
</div>--> | ||
|
||
<!-- Buttons --> | ||
|
||
<div class=" form-group fa-pull-right"> | ||
<button id="routeBack" type="button" (click)="goBackToPrevPage()" | ||
class="btn m-1 btn-outline-primary">Back | ||
</button> | ||
<button type="editButton" [routerLink]="['edit']" class="btn m-1 btn-outline-success">Edit</button> | ||
<button type="deleteButton" *ngIf="isRole('admin')" [routerLink]="['delete']" class="btn m-1 btn-outline-danger"> | ||
Delete | ||
</button> | ||
</div> | ||
|
||
</fieldset> | ||
</form> |
Empty file.
41 changes: 41 additions & 0 deletions
41
src/app/coordinate/coordinate-detail/coordinate-detail.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,41 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {ActivatedRoute, Router} from "@angular/router"; | ||
import {AuthenticationBasicService} from "../../login-basic/authentication-basic.service"; | ||
import {CoordinateService} from "../coordinate.service"; | ||
import {Coordinate} from "../coordinate.entity"; | ||
import {Location} from "@angular/common"; | ||
|
||
@Component({ | ||
selector: 'app-coordinate-detail', | ||
templateUrl: './coordinate-detail.component.html', | ||
styleUrls: ['./coordinate-detail.component.scss'] | ||
}) | ||
export class CoordinateDetailComponent implements OnInit { | ||
public coordinatee = new Coordinate(); | ||
|
||
constructor( | ||
public router: Router, | ||
private activatedRoute: ActivatedRoute, | ||
private coordinateService: CoordinateService, | ||
private authenticationService: AuthenticationBasicService, | ||
private location: Location) { | ||
} | ||
|
||
ngOnInit(): void { | ||
const id = this.activatedRoute.snapshot.paramMap.get('id'); | ||
this.coordinateService.getResource(id).subscribe( | ||
(c: Coordinate) => { | ||
this.coordinatee = c; | ||
}); | ||
} | ||
|
||
isRole(role: string): boolean { | ||
// return this.authenticationService.isRole(role); | ||
return true; | ||
} | ||
|
||
goBackToPrevPage(): void { | ||
this.location.back(); | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
src/app/coordinate/coordinate-list/coordinate-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,80 @@ | ||
<div> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<h3>Coordinates List</h3> | ||
</div> | ||
<div class="col-md-6"> | ||
<div style="text-align: right;"> | ||
<button *ngIf="isRole('admin')" type="button" [routerLink]="['/coordinates/create']" | ||
class="btn btn-outline-primary">Create | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="form-group mb-3"> | ||
<label class="control-label" for="type">Search coordinate</label> | ||
<input | ||
class="form-control" | ||
type="text" | ||
placeholder="Search coordinate" | ||
(keyup)="updateFilter($event)" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<ngx-datatable | ||
#tableCoordinates | ||
class="bootstrap" | ||
[columnMode]="ColumnMode.force" | ||
[headerHeight]="50" | ||
[footerHeight]="50" | ||
rowHeight="auto" | ||
[rows]="rows" | ||
[loadingIndicator]="loading" | ||
[externalPaging]="true" | ||
[count]="totalCoordinates" | ||
[offset]="currentPage" | ||
[limit]="pageSize" | ||
(page)="setPage($event)" | ||
> | ||
<!--<ngx-datatable-column name="id"> | ||
<ng-template let-column="column" let-sort="sortFn" ngx-datatable-header-template> | ||
<span (click)="sort()">{{ column.name.toString().toUpperCase() }}</span> | ||
</ng-template> | ||
<ng-template let-value="value" ngx-datatable-cell-template> | ||
{{ value }} | ||
</ng-template> | ||
</ngx-datatable-column>--> | ||
<ngx-datatable-column name="coordinate"> | ||
<ng-template let-column="column" let-sort="sortFn" ngx-datatable-header-template> | ||
<span (click)="sort()">{{ column.name }}</span> | ||
</ng-template> | ||
<ng-template let-row="row" let-value="value" ngx-datatable-cell-template> | ||
{{ value }} | ||
</ng-template> | ||
</ngx-datatable-column> | ||
<ngx-datatable-column name="actions"> | ||
<ng-template let-column="actions" ngx-datatable-header-template></ng-template> | ||
<ng-template let-row="row" let-value="actions" ngx-datatable-cell-template> | ||
<div style="text-align: right;"> | ||
<button type="button" [routerLink]="[row.uri]" | ||
class="btn btn-outline-primary">View | ||
</button> | ||
<span class="mx-2"></span> | ||
<button type="button" [routerLink]="[row.uri + '/edit']" | ||
class="btn btn-outline-success">Edit | ||
</button> | ||
<span class="mx-2"></span> | ||
<button *ngIf="isRole('admin')" type="button" [routerLink]="[row.uri + '/delete']" | ||
class="btn btn-outline-danger">Delete | ||
</button> | ||
|
||
</div> | ||
|
||
</ng-template> | ||
</ngx-datatable-column> | ||
</ngx-datatable> | ||
</div> |
Empty file.
Oops, something went wrong.