-
Notifications
You must be signed in to change notification settings - Fork 9
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 #143 from cvazquezlos/dev
Dev
- Loading branch information
Showing
16 changed files
with
233 additions
and
118 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
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+81 Bytes
(100%)
backend/target/classes/appSpring/service/LogicService.class
Binary file not shown.
Empty file.
52 changes: 49 additions & 3 deletions
52
frontend/src/app/component/admin/manage-fines/manage-fines.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 |
---|---|---|
@@ -1,3 +1,49 @@ | ||
<p> | ||
manage-fines works! | ||
</p> | ||
<section class="content-header"> | ||
<h1> | ||
Administración de multas | ||
<small>Administra las multas de los usuarios</small> | ||
</h1> | ||
<ol class="breadcrumb"> | ||
<li><a href="/admin/"><i class="fa fa-dashboard"></i> Inicio</a></li> | ||
<li class="active">Multas</li> | ||
</ol> | ||
</section> | ||
<section class="content"> | ||
<table class="table table-bordered table-striped" style="background-color: white !important;"> | ||
<thead> | ||
<tr> | ||
<th width="10%">Identificador</th> | ||
<th width="15%">Usuario</th> | ||
<th width="20%">Recurso</th> | ||
<th width="10%">Razón</th> | ||
<th width="20%">Tiempo</th> | ||
<th width="3%">Administrar</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<ng-template ngFor let-fine [ngForOf]="fines"> | ||
<tr> | ||
<td>{{fine?.id}}</td> | ||
<td>{{fine.user?.name}}</td> | ||
<td>{{fine.resourceCopy?.title}}</td> | ||
<td>Default</td> | ||
<td>{{fine?.initDate}} - {{fine?.finishDate}}</td> | ||
<td> | ||
<button type="button" class="btn btn-warning" (click)="delete(fine.id)"> | ||
<span class="fa fa-trash"></span> | ||
</button> | ||
</td> | ||
</tr> | ||
</ng-template> | ||
</tbody> | ||
</table><div> | ||
<div class="pull-right"> | ||
<button *ngIf="showPreviousPage" type="button" class="btn btn-primary" (click)="previousPage()"> | ||
<i class="fa fa-arrow-left" aria-hidden="true"></i> | ||
</button> | ||
<button *ngIf="showNextPage" type="button" class="btn btn-primary" (click)="nextPage()"> | ||
<i class="fa fa-arrow-right" aria-hidden="true"></i> | ||
</button> | ||
</div> | ||
</div> | ||
</section> |
25 changes: 0 additions & 25 deletions
25
frontend/src/app/component/admin/manage-fines/manage-fines.component.spec.ts
This file was deleted.
Oops, something went wrong.
109 changes: 104 additions & 5 deletions
109
frontend/src/app/component/admin/manage-fines/manage-fines.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 |
---|---|---|
@@ -1,15 +1,114 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import {Component, OnInit} from '@angular/core'; | ||
import {Router} from '@angular/router'; | ||
|
||
import {FineService} from '../../../service/fine.service'; | ||
import {SessionService} from '../../../service/session.service'; | ||
|
||
import {Fine} from '../../../model/fine.model'; | ||
|
||
@Component({ | ||
selector: 'app-manage-fines', | ||
templateUrl: './manage-fines.component.html', | ||
styleUrls: ['./manage-fines.component.css'] | ||
templateUrl: 'manage-fines.component.html' | ||
}) | ||
export class ManageFinesComponent implements OnInit { | ||
|
||
constructor() { } | ||
errorMessage: boolean; | ||
message: String; | ||
pageFines: number; | ||
showNextPage: boolean; | ||
showPreviousPage: boolean; | ||
successMessage: boolean; | ||
fines: Fine[]; | ||
|
||
constructor(private router: Router, private sessionService: SessionService, private fineService: FineService) { | ||
this.successMessage = false; | ||
this.errorMessage = false; | ||
this.pageFines = 0; | ||
this.showNextPage = false; | ||
this.showPreviousPage = false; | ||
} | ||
|
||
ngOnInit() { | ||
if (!this.sessionService.checkCredentials()) | ||
this.router.navigate(['/login']); | ||
else { | ||
this.getFines(); | ||
this.checkNextPage(); | ||
this.checkPreviousPage(); | ||
} | ||
} | ||
|
||
getFines() { | ||
this.fineService.getAllFines(this.pageFines).subscribe( | ||
fines => this.fines = fines, | ||
error => console.log('Fail trying to get all fines.') | ||
); | ||
} | ||
|
||
nextPage() { | ||
this.showNextPage = false; | ||
this.showPreviousPage = false; | ||
this.pageFines++; | ||
this.getFines(); | ||
this.checkNextPage(); | ||
this.showPreviousPage = true; | ||
} | ||
|
||
previousPage() { | ||
this.showNextPage = false; | ||
this.showPreviousPage = false; | ||
this.pageFines--; | ||
this.getFines(); | ||
this.checkPreviousPage(); | ||
this.showNextPage = true; | ||
} | ||
|
||
checkNextPage() { | ||
this.fineService.getAllFines(this.pageFines + 1).subscribe( | ||
fines => { | ||
if (Object.keys(fines).length === 0) { | ||
this.showNextPage = false; | ||
} else { | ||
this.showNextPage = true; | ||
} | ||
} | ||
); | ||
} | ||
|
||
checkPreviousPage() { | ||
if (this.pageFines > 0) { | ||
this.fineService.getAllFines(this.pageFines - 1).subscribe( | ||
fines => { | ||
if (Object.keys(fines).length === 0) { | ||
this.showPreviousPage = false; | ||
} else { | ||
this.showPreviousPage = true; | ||
} | ||
} | ||
); | ||
} else { | ||
this.showPreviousPage = false; | ||
} | ||
} | ||
|
||
delete(id: number) { | ||
this.fineService.deleteFine(id).subscribe( | ||
response => { | ||
this.successMessage = true; | ||
this.errorMessage = false; | ||
this.message = 'Multa eliminada correctamente.'; | ||
this.pageFines = 0; | ||
console.log('Fine successfully deleted.'); | ||
this.getFines(); | ||
this.checkNextPage(); | ||
this.checkPreviousPage(); | ||
}, | ||
error => { | ||
this.successMessage = false; | ||
this.errorMessage = true; | ||
this.message = 'No se ha podido eliminar la multa. Está activa.'; | ||
console.log('Fail trying to delete selected fine.'); | ||
} | ||
); | ||
} | ||
|
||
} |
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
Oops, something went wrong.