Skip to content

Commit

Permalink
add manage actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jherel committed Apr 17, 2017
1 parent 8e0c0fb commit dc34410
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 106 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spring.h2.console.enabled=true

spring.datasource.url = jdbc:mysql://localhost/brems?verifyServerCertificate=false&useSSL=true
spring.datasource.username = root
spring.datasource.password = 1234
spring.datasource.password = root
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto = create-drop

Expand Down
2 changes: 1 addition & 1 deletion backend/target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Implementation-Title: appSpring
Implementation-Version: 0.0.1
Built-By: c.vazquezlos
Built-By: jherel
Implementation-Vendor-Id: es.urjc.daw
Build-Jdk: 1.8.0_121
Implementation-URL: http://projects.spring.io/spring-boot/appSpring/
Expand Down
2 changes: 1 addition & 1 deletion backend/target/classes/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spring.h2.console.enabled=true

spring.datasource.url = jdbc:mysql://localhost/brems?verifyServerCertificate=false&useSSL=true
spring.datasource.username = root
spring.datasource.password = 1234
spring.datasource.password = root
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto = create-drop

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/app/component/admin/admin.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';

import { AdminComponent } from './admin.component';
Expand All @@ -16,7 +17,9 @@ import { DashboardComponent } from './dashboard/dashboard.component';
@NgModule({
imports: [
CommonModule,
AdminRoutingModule
AdminRoutingModule,
FormsModule,
ReactiveFormsModule
],
declarations: [
AdminComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
<p>
manage-loans works!
</p>
<section class="content-header">
<h1>Administración de préstamos <small>Administra los préstamos de los recursos</small></h1>
</section>

<section class="content">
<table class="table table-bordered table-striped" style="background-color: white !important;">
<thead>
<tr>
<th width="20%">Identificador</th>
<th width="20%">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></td>
<td></td>
<td></td>
<td></td>
<td>
<a>
<button type="button" class="btn btn-primary"><span class="fa fa-bookmark-o"></span> &nbsp; Prestar</button>
</a>
</td>
<td>
<a>
<button type="button" class="btn btn-primary"><span class="fa fa-bookmark"></span> &nbsp; Devolución</button>
</a>
</td>
<td>
<a>
<button type="button" class="btn btn-warning"><span class="fa fa-trash"></span></button>
</a>
</td>
</tr>
</tbody>
</table>
<a>
<button type="button" class="btn btn-primary"><span class="fa fa-plus-circle"> </span> &nbsp; Añadir préstamo</button>
</a>
</section>
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Component, OnInit } from '@angular/core';

import { ActionService } from 'app/service/action.service'

@Component({
selector: 'app-manage-loans',
templateUrl: './manage-loans.component.html',
styleUrls: ['./manage-loans.component.css']
})
export class ManageLoansComponent implements OnInit {

constructor() { }
private loans: Object[] = [];

ngOnInit() {
constructor(private service: ActionService) {
}

ngOnInit() {
this.service.getAllActions().subscribe(
loans => {
this.loans = loans;
console.log(this.loans);
},
error => console.log(error)
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
<section class="content-header">
<h1>Administraión de recursos<small>Administra los libros o las revistas</small></h1>
</section>

<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Editar {{resource?.title}}</h3>
</div>
<div class="box-body">
<div class="row">
<form>
<div class="col-md-5 col-lg-3">
<div class="form-group">
<!--
<img src="/img/books/{{ resource.picture }}" alt="" class="img-responsive">
<img src="/img/noPicture.png" alt="" class="img-responsive">
<label for="exampleInputFile">Imagen</label>
<input for="exampleInputFile" type="file" name="picture">
-->
</div>
</div>

<div class="col-lg-8">
<div class="form-group">
<label>Sumario del recurso</label>
<textarea rows="3" cols="50" class="form-control" [(ngModel)]="resource.description">
</textarea>
</div>
<div class="form-group">
<label>Autor o compañía</label>
<input type="text" class="form-control" [(ngModel)]="resource.author">
</div>
<div class="form-group">
<label>Género literario</label>
<input type="text" class="form-control" [(ngModel)]="resource.genre.name">
</div>
<div class="form-group">
<label>Editorial</label>
<input type="text" class="form-control" [(ngModel)]="resource.editorial">
</div>
<div class="form-group">
<label>Tipo de recurso</label>
<input type="text" class="form-control" [(ngModel)]="resource.resourceType.name">
</div>
<div class="form-group">
<label>Número de copias</label>
<input type="number" class="form-control" [(ngModel)]="resource.copies.length">
</div>

<div class="pull-right">
<button (click)="saveResource()" class="btn btn-success">Guardar</button>
</div>
</div>-->
</form>
</div>
</div>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';

import { Resource } from 'app/model/resource.model';

import { ResourceService } from 'app/service/resource.service';

@Component({
Expand All @@ -14,21 +13,22 @@ export class EditResourceComponent implements OnInit {
private resource: Resource;

constructor(private router: Router,
activatedRoute: ActivatedRoute, service: ResourceService) {
let id = activatedRoute.snapshot.params['id'];
private activatedRoute: ActivatedRoute,
private service: ResourceService) {
}

service.getResource(id).subscribe(
resource => this.resource = resource,
error => console.error(error)
ngOnInit() {
let id = this.activatedRoute.snapshot.params['id'];
this.service.getResource(id).subscribe(
resource => {
this.resource = resource;
},
error => console.log(error)
);
console.log(this.resource);
}

ngOnInit() { }

gotoResources() { this.router.navigate(['/resources']); }

saveResource() { }


}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>Administración de recursos <small>Administra los libros o las revistas</sma
<td>{{ resource.genre.name }}</td>
<td>{{ resource.resourceType.name }}</td>
<td>
<a [routerLink]="['/resource', resource.id]">
<a [routerLink]="['../resource', resource.id]">
<button type="button" class="btn btn-success"><span class="fa fa-pencil"></span></button>
</a>
<a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';

import { ResourceService } from 'app/service/resource.service';

@Component({
selector: 'app-manage-resources',
templateUrl: './manage-resources.component.html',
styleUrls: ['./manage-resources.component.css']
})
export class ManageResourcesComponent implements OnInit {

private resources: Object[] = [];

constructor(private http: Http) {
constructor(private service: ResourceService) {
}

ngOnInit() {
this.getResources();
}

getResources() {
this.resources = [];
let url = "https://localhost:8443/api/resources";

this.http.get(url).subscribe(
response => {
let data = response.json().content;
data.forEach(element => {
this.resources.push(element);
});
this.service.getAllResources().subscribe(
resources => {
this.resources = resources;
},
error => console.error(error)
error => console.log(error)
);
}

}
7 changes: 4 additions & 3 deletions frontend/src/app/service/action.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export class ActionService {
this.authCreds = authCreds;
}

getAllActions(page: number, finished: boolean) {

getAllActions(page?: number, finished?: boolean) {
let headers: Headers = new Headers();
headers.append('Authorization', 'Basic ' + this.authCreds);
return this.http.get(ACTION_URL + '?page=' + page + '&finished=' + finished, {headers: headers})

let url = (page && finished) ? ACTION_URL + '?page=' + page + '&finished=' + finished : ACTION_URL;
return this.http.get(url, {headers: headers})
.map(response => response.json().content)
.catch(error => Observable.throw('Server error'));
}
Expand Down
15 changes: 8 additions & 7 deletions frontend/src/app/service/resource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ export class ResourceService {
.catch(error => Observable.throw('Server error'))
}

getAllResources(type: string, page: number) {
return this.http.get(RESOURCES_URL + '?type=' + type + '&page=' + page)
getAllResources(type?: string, page?: number) {
let url = (type && page) ? RESOURCES_URL + '?type=' + type + '&page=' + page : RESOURCES_URL;
return this.http.get(url)
.map(response => response.json().content)
.catch(error => Observable.throw('Server error'));
}

searchResources(name: string, page: number){
return this.http.get(RESOURCES_URL + '?name=' + name + '&page=' + page)
.map(response => response.json().content)
.catch(error => Observable.throw('Server error'));
}
searchResources(name: string, page: number) {
return this.http.get(RESOURCES_URL + '?name=' + name + '&page=' + page)
.map(response => response.json().content)
.catch(error => Observable.throw('Server error'));
}
}

0 comments on commit dc34410

Please sign in to comment.