-
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.
- Loading branch information
Showing
16 changed files
with
329 additions
and
127 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
Binary file modified
BIN
+0 Bytes
(100%)
backend/target/classes/appSpring/service/LogicService.class
Binary file not shown.
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
46 changes: 46 additions & 0 deletions
46
frontend/src/app/component/admin/manage-loans/create/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,46 @@ | ||
<div *ngIf="errorMessage" class="alert alert-danger"> | ||
<strong>Algo ha ido mal...</strong> {{message}} | ||
</div> | ||
|
||
<section class="content-header"> | ||
<h1>Administración de préstamos <small>Administra los préstamos de los recursos</small></h1> | ||
<ol class="breadcrumb"> | ||
<li><a [routerLink]="['/admin']"><i class="fa fa-dashboard"></i> Inicio</a></li> | ||
<li><a [routerLink]="['/admin/loans']">Préstamo</a></li> | ||
<li class="active">Añadir préstamo</li> | ||
</ol> | ||
</section> | ||
|
||
<section class="content"> | ||
<div class="box box-default"> | ||
<div class="box-header with-border"> | ||
<h3 class="box-title">Nuevo préstamo</h3> | ||
</div> | ||
<div class="box-body"> | ||
<div class="row"> | ||
<div class="col-lg-8"> | ||
<div class="form-group"> | ||
<label>Recursos disponibles a prestar</label> | ||
<br> | ||
<select [(ngModel)]="resourceSelect"> | ||
<ng-template ngFor let-resource [ngForOf]="resources"> | ||
<option *ngIf="resource.noReservedCopies.length > 0" [ngValue]="resource">{{resource.title}}</option> | ||
</ng-template> | ||
</select> | ||
</div> | ||
<div class="form-group"> | ||
<label>Usuario</label> | ||
<br> | ||
<select [(ngModel)]="userSelect"> | ||
<option *ngFor="let user of users" [ngValue]="user">{{user.name}}</option> | ||
</select> | ||
</div> | ||
<br> | ||
<div class="pull-left"> | ||
<input type="submit" class="btn btn-success" (click)="createLoan()"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> |
82 changes: 82 additions & 0 deletions
82
frontend/src/app/component/admin/manage-loans/create/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,82 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
import { Observable } from 'rxjs/Observable'; | ||
|
||
import { Action } from 'app/model/action.model'; | ||
import { User } from 'app/model/user.model'; | ||
import { Resource } from 'app/model/resource.model'; | ||
import { ResourceCopy } from 'app/model/resource-copy.model'; | ||
|
||
import { SessionService } from 'app/service/session.service'; | ||
import { ActionService } from 'app/service/action.service'; | ||
import { UserService } from 'app/service/user.service'; | ||
import { ResourceService } from 'app/service/resource.service'; | ||
|
||
@Component({ | ||
templateUrl: './create.component.html' | ||
}) | ||
export class CreateLoanComponent implements OnInit { | ||
|
||
loan: Action = null; | ||
users: User[]; | ||
resources: Resource[]; | ||
|
||
userSelect: User = null; | ||
resourceSelect: Resource = null; | ||
|
||
errorMessage: boolean; | ||
message: String; | ||
|
||
constructor(private router: Router, | ||
private activatedRoute: ActivatedRoute, | ||
private sessionService: SessionService, | ||
private actionService: ActionService, | ||
private userService: UserService, | ||
private resourceService: ResourceService) { | ||
this.errorMessage = false; | ||
|
||
} | ||
|
||
ngOnInit() { | ||
if (!this.sessionService.checkCredentials()) { | ||
this.router.navigate(["/login"]); | ||
} else { | ||
this.userService.getUsers().subscribe( | ||
users => this.users = users, | ||
error => console.log(error) | ||
); | ||
this.resourceService.getAllResources().subscribe( | ||
resources => this.resources = resources, | ||
error => console.log(error) | ||
); | ||
} | ||
} | ||
|
||
createLoan() { | ||
let copy: ResourceCopy; | ||
|
||
if (this.resourceSelect.noReservedCopies.length != 0) { | ||
copy = this.resourceSelect.copies.find(x => x.locationCode == this.resourceSelect.noReservedCopies[0]); | ||
copy.resource = { | ||
id: this.resourceSelect.id, | ||
title: this.resourceSelect.title, | ||
author: this.resourceSelect.author, | ||
editorial: this.resourceSelect.editorial, | ||
avaiblereserve: this.resourceSelect.avaiblereserve, | ||
description: this.resourceSelect.description, | ||
hasPhoto: this.resourceSelect.hasPhoto, | ||
noReservedCopies: this.resourceSelect.noReservedCopies | ||
}; | ||
|
||
this.loan = { copy: copy, user: this.userSelect }; | ||
|
||
this.actionService.postAction(this.loan).subscribe( | ||
response => this.router.navigate(["/admin/loans"]), | ||
error => { | ||
this.errorMessage = true; | ||
this.message = 'No se ha podido realizar la acción.' | ||
} | ||
); | ||
} | ||
} | ||
} |
112 changes: 54 additions & 58 deletions
112
frontend/src/app/component/admin/manage-loans/manage-loans.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,73 +1,69 @@ | ||
<div *ngIf="successMessage" class="alert alert-success"> | ||
<strong>¡Eliminado!</strong> {{message}} | ||
<strong>¡Eliminado!</strong> {{message}} | ||
</div> | ||
<div *ngIf="errorMessage" class="alert alert-danger"> | ||
<strong>Algo ha ido mal...</strong> {{message}} | ||
<strong>Algo ha ido mal...</strong> {{message}} | ||
</div> | ||
|
||
<section class="content-header"> | ||
<h1>Administración de préstamos <small>Administra los préstamos de los recursos</small></h1> | ||
<ol class="breadcrumb"> | ||
<li><a [routerLink]="['/admin']"><i class="fa fa-dashboard"></i> Inicio</a></li> | ||
<li class="active">Prestamos</li> | ||
</ol> | ||
<h1>Administración de préstamos <small>Administra los préstamos de los recursos</small></h1> | ||
<ol class="breadcrumb"> | ||
<li><a [routerLink]="['/admin']"><i class="fa fa-dashboard"></i> Inicio</a></li> | ||
<li class="active">Prestamos</li> | ||
</ol> | ||
</section> | ||
|
||
<section class="content"> | ||
<table class="table table-bordered table-striped"> | ||
<thead> | ||
<tr> | ||
<th width="10%">Identificador</th> | ||
<th width="15%">Usuario</th> | ||
<th>Recurso</th> | ||
<th>Petición</th> | ||
<th>Préstamo</th> | ||
<th>Devolución</th> | ||
<th>Administrar</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let loan of loans"> | ||
<td>{{ loan.copy.locationCode }}</td> | ||
<td>{{ loan.user.name }}</td> | ||
<td>{{ loan.copy.resource.title }}</td> | ||
<td>{{ loan.dateLoanInit }}</td> | ||
<td> | ||
<div *ngIf="loan.dateLoanGiven; else elseBlock">{{ loan.dateLoanGiven }}</div> | ||
<ng-template #elseBlock> | ||
<a> | ||
<button type="button" class="btn btn-primary"><span class="fa fa-bookmark-o"></span> Prestar</button> | ||
</a> | ||
</ng-template> | ||
</td> | ||
<td> | ||
<div *ngIf="loan.dateLoanReturn; else elseBlock">{{ loan.dateLoanReturn }}</div> | ||
<ng-template #elseBlock> | ||
<a> | ||
<button type="button" class="btn btn-primary"><span class="fa fa-bookmark"></span> Devolución</button> | ||
</a> | ||
</ng-template> | ||
</td> | ||
<td> | ||
<button type="button" class="btn btn-warning" (click)="deleteLoan(loan.id)"><span class="fa fa-trash"></span></button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<table class="table table-bordered table-striped"> | ||
<thead> | ||
<tr> | ||
<th width="10%">Identificador</th> | ||
<th width="15%">Usuario</th> | ||
<th>Recurso</th> | ||
<th>Petición</th> | ||
<th>Préstamo</th> | ||
<th>Devolución</th> | ||
<th>Administrar</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let loan of loans"> | ||
<td>{{ loan.copy.locationCode }}</td> | ||
<td>{{ loan.user.name }}</td> | ||
<td>{{ loan.copy.resource.title }}</td> | ||
<td>{{ loan.dateLoanInit }}</td> | ||
<td> | ||
<div *ngIf="loan.dateLoanGiven != '1970-01-01 00:00:00' ; else elseBlockLoanGiven">{{ loan.dateLoanGiven }}</div> | ||
<ng-template #elseBlockLoanGiven> | ||
<button type="button" class="btn btn-primary" (click)="updateLoan(loan.id, 'give')"><span class="fa fa-bookmark-o"></span> Prestar</button> | ||
</ng-template> | ||
</td> | ||
<td> | ||
<div *ngIf="loan.dateLoanReturn != '1970-01-01 00:00:00' ; else elseBlockLoanReturn">{{ loan.dateLoanReturn }}</div> | ||
<ng-template #elseBlockLoanReturn> | ||
<button type="button" class="btn btn-primary" (click)="updateLoan(loan.id, 'return')"><span class="fa fa-bookmark"></span> Devolución</button> | ||
</ng-template> | ||
</td> | ||
<td> | ||
<button type="button" class="btn btn-warning" (click)="deleteLoan(loan.id)"><span class="fa fa-trash"></span></button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<div> | ||
<div class="pull-left"> | ||
<a [routerLink]="['/admin/users/new']"> | ||
<button type="button" class="btn btn-primary"><span class="fa fa-plus-circle"> </span> Añadir préstamo</button> | ||
</a> | ||
</div> | ||
<div class="pull-right"> | ||
<button *ngIf="showPreviousPage" type="button" class="btn btn-primary" (click)="previousPage()"> | ||
<div> | ||
<div class="pull-left"> | ||
<a [routerLink]="['/admin/loans/new']"> | ||
<button type="button" class="btn btn-primary"><span class="fa fa-plus-circle"> </span> Añadir préstamo</button> | ||
</a> | ||
</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()"> | ||
<button *ngIf="showNextPage" type="button" class="btn btn-primary" (click)="nextPage()"> | ||
<i class="fa fa-arrow-right" aria-hidden="true"></i> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
</section> |
Oops, something went wrong.