Skip to content

Commit

Permalink
Merge pull request #137 from cvazquezlos/carlos
Browse files Browse the repository at this point in the history
Added user management.
  • Loading branch information
cvazquezlos authored Apr 18, 2017
2 parents 9c9a389 + 944892f commit d212615
Show file tree
Hide file tree
Showing 16 changed files with 264 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
public class UserRestController {

public interface UserDetail extends User.Basic, User.Act, User.Fin, Fine.Basic, Action.Basic {}
public interface UserBasic extends User.LoginInt {}

@Autowired
private UserService userService;
Expand Down Expand Up @@ -84,7 +85,7 @@ public ResponseEntity<User> getUser(@PathVariable int id, Authentication authent
}

@CrossOrigin(origins = "http://localhost:4200")
@JsonView(UserDetail.class)
@JsonView(UserBasic.class)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<User> deleteUser(@PathVariable Integer id, HttpSession session,
Authentication authentication) {
Expand Down
Binary file modified backend/target/appSpring-0.0.1.jar
Binary file not shown.
Binary file modified backend/target/appSpring-0.0.1.jar.original
Binary file not shown.
1 change: 0 additions & 1 deletion frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ import { Component } from '@angular/core';
export class AppComponent {

constructor() {
localStorage.clear();
}
}
4 changes: 2 additions & 2 deletions frontend/src/app/component/admin/admin-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const adminRoutes: Routes = [
{path: 'loans', component: ManageLoansComponent},
{path: 'fines', component: ManageFinesComponent},
{path: 'users', component: ManageUsersComponent},
{path: 'user/:id', component: EditUserComponent},
{path: 'user/new', component: CreateUserComponent},
{path: 'users/new', component: CreateUserComponent},
{path: 'users/:id', component: EditUserComponent},
{path: '', component: DashboardComponent}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
<div class="content-wrapper">
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
</div>
<section class="content-header">
<h1>
Administración de usuarios
<small>Administra los usuarios</small>
</h1>
<ol class="breadcrumb">
<li><a href="/admin/"><i class="fa fa-dashboard"></i> Inicio</a></li>
<li><a href="/admin/users">Usuarios</a></li>
<li class="active">Añadir usuario</li>
</ol>
</section>
<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Nuevo usuario</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-lg-8">
<div class="form-group">
<label>Nombre y apellidos</label>
<br>
<input type="text" class="form-control" style='display: inline; width: 38%;' placeholder="Nombre"
#firstName required>
<input type="text" class="form-control" style='display: inline; width: 30%;'
placeholder="Primer apellido" #lastName1 required>
<input type="text" class="form-control" style='display: inline; width: 30%;'
placeholder="Segundo apellido" #lastName2 required>
</div>
<div class="form-group">
<label>Usuario</label>
<input type="text" class="form-control" name="name" placeholder="Usuario" #name required>
</div>
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" name="email" placeholder="Email" #email required>
</div>
<div class="pull-left">
<button class="btn btn-success" (click)="create(firstName.value, lastName1.value, lastName2.value,
name.value, email.value, password.value, dni.value, telephone.value)">Registrar</button>
</div>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
</div>
<section class="content-header">
<h1>
Administración de usuarios
<small>Administra los usuarios</small>
</h1>
<ol class="breadcrumb">
<li><a href="/admin/"><i class="fa fa-dashboard"></i> Inicio</a></li>
<li><a href="/admin/users">Usuarios</a></li>
<li class="active">Añadir usuario</li>
</ol>
</section>
<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Nuevo usuario</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-lg-8">
<div class="form-group">
<label>Nombre y apellidos</label>
<br>
<input type="text" class="form-control" style='display: inline; width: 38%;' placeholder="Nombre"
#firstName required>
<input type="text" class="form-control" style='display: inline; width: 30%;'
placeholder="Primer apellido" #lastName1 required>
<input type="text" class="form-control" style='display: inline; width: 30%;'
placeholder="Segundo apellido" #lastName2 required>
</div>
<div class="form-group">
<label>Usuario</label>
<input type="text" class="form-control" name="name" placeholder="Usuario" #name required>
</div>
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" name="email" placeholder="Email" #email required>
</div>
<div class="col-lg-2">
<div class="form-group">
<label>Contraseña</label>
<input class="form-control" name="password" type="password" placeholder="Contraseña" #password required>
</div>
<div class="form-group">
<label>D.N.I.</label>
<input class="form-control" name="dni" type="text" #dni placeholder="D.N.I.">
</div>
<div class="form-group">
<label>Teléfono</label>
<input class="form-control" name="telephone" type="text" #telephone placeholder="Teléfono">
</div>
</div>
<div class="col-lg-2">
<div class="form-group">
<label>D.N.I.</label>
<input class="form-control" name="dni" type="text" #dni placeholder="D.N.I.">
</div>
<div class="form-group">
<label>Contraseña</label>
<input class="form-control" name="password" type="password" placeholder="Contraseña" #password required>
</div>
<div class="form-group">
<label>Teléfono</label>
<input class="form-control" name="telephone" type="text" #telephone placeholder="Teléfono">
</div>
<div class="pull-left">
<button class="btn btn-success" (click)="create(firstName.value, lastName1.value, lastName2.value,
name.value, email.value, password.value, dni.value, telephone.value)">Registrar
</button>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {SessionService} from '../../../../service/session.service';
import {UserService} from '../../../../service/user.service';

@Component({
templateUrl: './create.component.html'
templateUrl: 'create.component.html'
})
export class CreateUserComponent implements OnInit {

Expand All @@ -23,9 +23,8 @@ export class CreateUserComponent implements OnInit {
create(firstName: string, lastName1: string, lastName2: string, name: string, email: string, password: string,
dni: string, telephone: string) {
let createdUser: User = {
name: name, dni: dni, firstName: firstName, lastName1: lastName1, lastName2: lastName2, email: email,
telephone: telephone, literaryHobby: []
};
name: name, passwordHash: password, dni: dni, firstName: firstName, lastName1: lastName1, lastName2: lastName2, email: email,
telephone: telephone, literaryHobby: [], roles: ["ROLE_USER"]};
this.userService.createUser(createdUser).subscribe(
response => {
console.log(name + " successfully created.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
<div class="content-wrapper">
<section class="content-header">
<h1>
Administración de usuarios
<small>Administra los usuarios</small>
</h1>
<ol class="breadcrumb">
<li><a [routerLink]="['/admin']"><i class="fa fa-dashboard"></i> Inicio</a></li>
<li><a [routerLink]="['/admin/users']">Usuarios</a></li>
<li class="active">Añadir usuario</li>
</ol>
</section>
<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Editar {{user?.name}}</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-lg-8">
<div class="form-group">
<label>Nombre y apellidos</label>
<br>
<input type="text" class="form-control" name="firstName" style='display: inline; width: 38%;'
#firstName value="{{user?.firstName}}">
<input type="text" class="form-control" name="lastName1" style='display: inline; width: 30%;'
#lastName1 value="{{user?.lastName1}}">
<input type="text" class="form-control" name="lastName2" style='display: inline; width: 30%;'
#lastName2 value="{{user?.lastName2}}">
</div>
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" name="email" #email value="{{user?.email}}">
</div>
<div class="form-group">
<label>DNI</label>
<input type="text" class="form-control" name="dni" #dni value="{{user?.dni}}">
</div>
<div class="pull-right">
<button type="submit" class="btn btn-success" (click)="edit(firstName.value, lastName1.value,
lastName2.value, email.value, dni.value)">Modificar</button>
</div>
<section class="content-header">
<h1>
Administración de usuarios
<small>Administra los usuarios</small>
</h1>
<ol class="breadcrumb">
<li><a [routerLink]="['/admin']"><i class="fa fa-dashboard"></i> Inicio</a></li>
<li><a [routerLink]="['/admin/users']">Usuarios</a></li>
<li class="active">Modificar usuario</li>
</ol>
</section>
<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Editar {{user?.name}}</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-lg-8">
<div class="form-group">
<label>Nombre y apellidos</label>
<br>
<input type="text" class="form-control" name="firstName" style='display: inline; width: 38%;'
#firstName value="{{user?.firstName}}">
<input type="text" class="form-control" name="lastName1" style='display: inline; width: 30%;'
#lastName1 value="{{user?.lastName1}}">
<input type="text" class="form-control" name="lastName2" style='display: inline; width: 30%;'
#lastName2 value="{{user?.lastName2}}">
</div>
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" name="email" #email value="{{user?.email}}">
</div>
<div class="form-group">
<label>DNI</label>
<input type="text" class="form-control" name="dni" #dni value="{{user?.dni}}">
</div>
<div class="pull-right">
<button type="submit" class="btn btn-success" (click)="edit(firstName.value, lastName1.value,
lastName2.value, email.value, dni.value)">Modificar
</button>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {SessionService} from '../../../../service/session.service';
import {UserService} from '../../../../service/user.service';

@Component({
templateUrl: './edit.component.html'
templateUrl: 'edit.component.html'
})
export class EditUserComponent implements OnInit {

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,55 +1,60 @@
<div class="content-wrapper">
<div *ngIf="successMessage" class="alert alert-success">
<strong>¡Eliminado!</strong> {{message}}
</div>
<div *ngIf="errorMessage" class="alert alert-danger">
<strong>Algo ha ido mal...</strong> {{message}}
</div>
<section class="content-header">
<h1>
Administración de usuarios
<small>Administra los usuarios</small>
</h1>
<ol class="breadcrumb">
<li><a [routerLink]="['/admin']"><i class="fa fa-dashboard"></i> Inicio</a></li>
<li class="active">Usuarios</li>
</ol>
</section>
<section class="content">
<table class="table table-bordered table-striped" style="background-color: white !important;">
<thead>
<div *ngIf="successMessage" class="alert alert-success">
<strong>¡Eliminado!</strong> {{message}}
</div>
<div *ngIf="errorMessage" class="alert alert-danger">
<strong>Algo ha ido mal...</strong> {{message}}
</div>
<section class="content-header">
<h1>
Administración de usuarios
<small>Administra los usuarios</small>
</h1>
<ol class="breadcrumb">
<li><a [routerLink]="['/admin']"><i class="fa fa-dashboard"></i> Inicio</a></li>
<li class="active">Usuarios</li>
</ol>
</section>
<section class="content">
<table class="table table-bordered table-striped" style="background-color: white !important;">
<thead>
<tr>
<th width="20%">Nombre y apellidos</th>
<th width="20%">Usuario</th>
<th width="5%">Rol(es)</th>
<th width="5%">Multas</th>
<th width="5%">Préstamos</th>
<th width="3%">Administrar</th>
</tr>
</thead>
<tbody>
<ng-template ngFor let-user [ngForOf]="users">
<tr>
<th>Nombre y apellidos</th>
<th>Usuario</th>
<th>Rol(es)</th>
<th>Multas</th>
<th>Préstamos</th>
<th>Administrar</th>
<td>{{user?.firstName}} {{user?.lastName1}} {{user?.lastName2}}</td>
<td>{{user?.name}}</td>
<td>{{user?.roles?.length}}</td>
<td>{{user.penalties?.length}}</td>
<td>{{user.actions?.length}}</td>
<td>
<a [routerLink]="['./',user.id]">
<button type="button" class="btn btn-success"><span class="fa fa-pencil"></span></button>
</a>
&nbsp;&nbsp;
<button type="button" class="btn btn-warning" (click)="delete(user.id)"><span class="fa fa-trash"></span>
</button>
</td>
</tr>
</thead>
<tbody>
<ng-template ngFor let-user [ngForOf]="users">
<tr>
<td>{{user.firstName}} {{user.lastName1}} {{user.lastName2}}</td>
<td>{{user.name}}</td>
<td>{{user.roles?.length}}</td>
<td>{{user.penalties?.length}}</td>
<td>{{user.actions?.length}}</td>
<td>
<a [routerLink]="['/user',user.id]">
<button type="button" class="btn btn-success"><span class="fa fa-pencil"></span></button>
</a>
&nbsp;&nbsp;
<button type="button" class="btn btn-warning" (click)="delete(user.id)"><span class="fa fa-trash"></span>
</button>
</td>
</tr>
</ng-template>
</tbody>
</table>
<a [routerLink]="['/user/new']">
<button type="button" class="btn btn-primary"><span class="fa fa-plus-circle"> </span> &nbsp; Añadir usuario
</button>
</a>
</section>
</div>
</ng-template>
</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>&nbsp;Añadir usuario</button>
</a>
</div>
<div class="pull-right">
<button *ngIf="showPreviousPage" type="button" class="btn btn-primary" (click)="previousPage()">&#8678;</button>
<button *ngIf="showNextPage" type="button" class="btn btn-primary" (click)="nextPage()">&#8680;</button>
</div>
</div>
</section>
Loading

0 comments on commit d212615

Please sign in to comment.