Merge branch 'dev' into feature/US-11

This commit is contained in:
Pablo Bonilla 2021-07-09 00:45:18 -06:00
commit de543365d9
No known key found for this signature in database
GPG Key ID: 46877262B8DE47E2
13 changed files with 100 additions and 87 deletions

2
.gitignore vendored
View File

@ -157,3 +157,5 @@ Desktop.ini
###################### ######################
/coverage/ /coverage/
/.nyc_output/ /.nyc_output/
.mvn/wrapper/maven-wrapper.jar

0
mvnw vendored Normal file → Executable file
View File

0
npmw Normal file → Executable file
View File

View File

@ -1,10 +1,21 @@
export interface IUser { export interface IUser {
id?: number; id?: number;
login?: string; login?: string;
firstName?: string | null;
lastName?: string | null;
email?: string;
authorities?: string[];
} }
export class User implements IUser { export class User implements IUser {
constructor(public id: number, public login: string) {} constructor(
public id: number,
public login: string,
public firstName?: string,
public lastName?: string,
public email?: string,
public authorities?: string[]
) {}
} }
export function getUserIdentifier(user: IUser): number | undefined { export function getUserIdentifier(user: IUser): number | undefined {

View File

@ -32,8 +32,10 @@ describe('Service Tests', () => {
}); });
const req = httpMock.expectOne({ method: 'GET' }); const req = httpMock.expectOne({ method: 'GET' });
req.flush([new User(123, 'user')]); req.flush([new User(123, 'user', 'fist name', 'last name', 'email@gmail.com', ['ROLE_USER'])]);
expect(expectedResult).toEqual([{ id: 123, login: 'user' }]); expect(expectedResult).toEqual([
{ id: 123, login: 'user', firstName: 'fist name', lastName: 'last name', email: 'email@gmail.com', authorities: ['ROLE_USER'] },
]);
}); });
it('should propagate not found response', () => { it('should propagate not found response', () => {

View File

@ -7,6 +7,9 @@ import { createRequestOption } from 'app/core/request/request-util';
import { isPresent } from 'app/core/util/operators'; import { isPresent } from 'app/core/util/operators';
import { Pagination } from 'app/core/request/request.model'; import { Pagination } from 'app/core/request/request.model';
import { IUser, getUserIdentifier } from './user.model'; import { IUser, getUserIdentifier } from './user.model';
import { map } from 'rxjs/operators';
export type EntityResponseType = HttpResponse<IUser>;
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class UserService { export class UserService {

View File

@ -32,34 +32,38 @@
<table class="table table-striped" aria-describedby="page-heading"> <table class="table table-striped" aria-describedby="page-heading">
<thead> <thead>
<tr> <tr>
<th scope="col"><span jhiTranslate="global.field.id">ID</span></th> <th scope="col"><span>Rol de usuario</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.nombre">Nombre</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.iconoPerfil">Icono Perfil</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.iconoPerfil">Icono Perfil</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.fechaNacimiento">Fecha Nacimiento</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.nombre">Nombre Usuario</span></th>
<th scope="col"><span>Nombre Completo</span></th>
<th scope="col"><span>Correo electrónico</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.estado">Estado</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.estado">Estado</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.user">User</span></th> <!--<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.plantilla">Plantilla</span></th>-->
<th scope="col"><span jhiTranslate="dataSurveyApp.usuarioExtra.plantilla">Plantilla</span></th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let usuarioExtra of usuarioExtras; trackBy: trackId" data-cy="entityTable"> <tr *ngFor="let usuarioExtra of usuarioExtras; trackBy: trackId" data-cy="entityTable">
<td *ngIf="usuarioExtra.user">
<ul class="listRoles">
<li *ngFor="let userRole of usuarioExtra.user.authorities">
<p>{{ userRole }}</p>
</li>
</ul>
</td>
<td> <td>
<a [routerLink]="['/usuario-extra', usuarioExtra.id, 'view']">{{ usuarioExtra.id }}</a> <div class="photo mb-2"><img src="../../../../content/profile_icons/C{{ usuarioExtra.iconoPerfil }}.png" /></div>
</td> </td>
<td>{{ usuarioExtra.nombre }}</td> <td>{{ usuarioExtra.nombre }}</td>
<td>{{ usuarioExtra.iconoPerfil }}</td> <td *ngIf="usuarioExtra.user">{{ usuarioExtra.user.firstName }} {{ usuarioExtra.user.lastName }}</td>
<td>{{ usuarioExtra.fechaNacimiento | formatMediumDatetime }}</td> <td *ngIf="usuarioExtra.user">{{ usuarioExtra.user.email }}</td>
<td jhiTranslate="{{ 'dataSurveyApp.EstadoUsuario.' + usuarioExtra.estado }}">{{ usuarioExtra.estado }}</td> <td jhiTranslate="{{ 'dataSurveyApp.EstadoUsuario.' + usuarioExtra.estado }}">{{ usuarioExtra.estado }}</td>
<td> <!--<td>
{{ usuarioExtra.user?.id }}
</td>
<td>
<span *ngFor="let plantilla of usuarioExtra.plantillas; let last = last"> <span *ngFor="let plantilla of usuarioExtra.plantillas; let last = last">
<a class="form-control-static" [routerLink]="['/plantilla', plantilla.id, 'view']">{{ plantilla.id }}</a <a class="form-control-static" [routerLink]="['/plantilla', plantilla.id, 'view']">{{ plantilla.id }}</a
>{{ last ? '' : ', ' }} >{{ last ? '' : ', ' }}
</span> </span>
</td> </td>-->
<td class="text-right"> <td class="text-right">
<div class="btn-group"> <div class="btn-group">
<button <button
@ -72,16 +76,6 @@
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</button> </button>
<button
type="submit"
[routerLink]="['/usuario-extra', usuarioExtra.id, 'edit']"
class="btn btn-primary btn-sm"
data-cy="entityEditButton"
>
<fa-icon icon="pencil-alt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="submit" (click)="delete(usuarioExtra)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton"> <button type="submit" (click)="delete(usuarioExtra)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton">
<fa-icon icon="times"></fa-icon> <fa-icon icon="times"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>

View File

@ -0,0 +1,12 @@
.photo {
width: 80px;
height: 80px;
overflow: hidden;
z-index: 5;
border-radius: 50%;
}
.listRoles {
list-style: none;
padding-left: 10px;
}

View File

@ -1,48 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { of } from 'rxjs';
import { UsuarioExtraService } from '../service/usuario-extra.service';
import { UsuarioExtraComponent } from './usuario-extra.component';
describe('Component Tests', () => {
describe('UsuarioExtra Management Component', () => {
let comp: UsuarioExtraComponent;
let fixture: ComponentFixture<UsuarioExtraComponent>;
let service: UsuarioExtraService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
declarations: [UsuarioExtraComponent],
})
.overrideTemplate(UsuarioExtraComponent, '')
.compileComponents();
fixture = TestBed.createComponent(UsuarioExtraComponent);
comp = fixture.componentInstance;
service = TestBed.inject(UsuarioExtraService);
const headers = new HttpHeaders().append('link', 'link;link');
jest.spyOn(service, 'query').mockReturnValue(
of(
new HttpResponse({
body: [{ id: 123 }],
headers,
})
)
);
});
it('Should call load all on init', () => {
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.usuarioExtras?.[0]).toEqual(expect.objectContaining({ id: 123 }));
});
});
});

View File

@ -5,24 +5,48 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { IUsuarioExtra } from '../usuario-extra.model'; import { IUsuarioExtra } from '../usuario-extra.model';
import { UsuarioExtraService } from '../service/usuario-extra.service'; import { UsuarioExtraService } from '../service/usuario-extra.service';
import { UsuarioExtraDeleteDialogComponent } from '../delete/usuario-extra-delete-dialog.component'; import { UsuarioExtraDeleteDialogComponent } from '../delete/usuario-extra-delete-dialog.component';
import { IUser } from '../../user/user.model';
import { finalize } from 'rxjs/operators';
@Component({ @Component({
selector: 'jhi-usuario-extra', selector: 'jhi-usuario-extra',
templateUrl: './usuario-extra.component.html', templateUrl: './usuario-extra.component.html',
styleUrls: ['./usuario-extra.component.scss'],
}) })
export class UsuarioExtraComponent implements OnInit { export class UsuarioExtraComponent implements OnInit {
usuarioExtras?: IUsuarioExtra[]; usuarioExtras?: IUsuarioExtra[];
publicUsers?: IUser[];
isLoading = false; isLoading = false;
constructor(protected usuarioExtraService: UsuarioExtraService, protected modalService: NgbModal) {} constructor(protected usuarioExtraService: UsuarioExtraService, protected modalService: NgbModal) {}
loadAll(): void { loadPublicUser(): void {
this.isLoading = true; this.usuarioExtraService
.retrieveAllPublicUsers()
.pipe(finalize(() => this.loadUserExtras()))
.subscribe(res => {
res.forEach(user => {
let rolList: string[] | undefined;
rolList = user.authorities;
let a = rolList?.pop();
if (a == 'ROLE_ADMIN') {
user.authorities = ['ADMIN'];
} else if (a == 'ROLE_USER') {
user.authorities = ['USUARIO'];
}
});
this.publicUsers = res;
});
}
loadUserExtras() {
this.usuarioExtraService.query().subscribe( this.usuarioExtraService.query().subscribe(
(res: HttpResponse<IUsuarioExtra[]>) => { (res: HttpResponse<IUsuarioExtra[]>) => {
this.isLoading = false; this.isLoading = false;
this.usuarioExtras = res.body ?? []; this.usuarioExtras = res.body ?? [];
this.usuarioExtras.forEach(uE => {
uE.user = this.publicUsers?.find(pU => pU.id == uE.user?.id);
});
}, },
() => { () => {
this.isLoading = false; this.isLoading = false;
@ -30,6 +54,11 @@ export class UsuarioExtraComponent implements OnInit {
); );
} }
loadAll(): void {
this.isLoading = true;
this.loadPublicUser();
}
ngOnInit(): void { ngOnInit(): void {
this.loadAll(); this.loadAll();
} }

View File

@ -8,13 +8,17 @@ import { isPresent } from 'app/core/util/operators';
import { ApplicationConfigService } from 'app/core/config/application-config.service'; import { ApplicationConfigService } from 'app/core/config/application-config.service';
import { createRequestOption } from 'app/core/request/request-util'; import { createRequestOption } from 'app/core/request/request-util';
import { IUsuarioExtra, getUsuarioExtraIdentifier } from '../usuario-extra.model'; import { IUsuarioExtra, getUsuarioExtraIdentifier } from '../usuario-extra.model';
import { IUser } from '../../user/user.model';
export type EntityResponseType = HttpResponse<IUsuarioExtra>; export type EntityResponseType = HttpResponse<IUsuarioExtra>;
export type EntityArrayResponseType = HttpResponse<IUsuarioExtra[]>; export type EntityArrayResponseType = HttpResponse<IUsuarioExtra[]>;
export type EntityArrayUserPublicResponseType = HttpResponse<IUser[]>;
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class UsuarioExtraService { export class UsuarioExtraService {
protected resourceUrl = this.applicationConfigService.getEndpointFor('api/usuario-extras'); protected resourceUrl = this.applicationConfigService.getEndpointFor('api/usuario-extras');
protected resourceUrlPublicUser = this.applicationConfigService.getEndpointFor('api');
constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {}
@ -45,6 +49,10 @@ export class UsuarioExtraService {
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
} }
retrieveAllPublicUsers(): Observable<IUser[]> {
return this.http.get<IUser[]>(this.resourceUrlPublicUser + '/admin/users');
}
query(req?: any): Observable<EntityArrayResponseType> { query(req?: any): Observable<EntityArrayResponseType> {
const options = createRequestOption(req); const options = createRequestOption(req);
return this.http return this.http

View File

@ -2,20 +2,20 @@
"dataSurveyApp": { "dataSurveyApp": {
"categoria": { "categoria": {
"home": { "home": {
"title": "Categorias", "title": "Categorías",
"refreshListLabel": "Refrescar lista", "refreshListLabel": "Refrescar lista",
"createLabel": "Crear nuevo Categoria", "createLabel": "Crear nueva Categoría",
"createOrEditLabel": "Crear o editar Categoria", "createOrEditLabel": "Crear o editar Categoría",
"notFound": "Ningún Categorias encontrado" "notFound": "Ninguna Categoría encontrada"
}, },
"created": "Un nuevo Categoria ha sido creado con el identificador {{ param }}", "created": "Una nueva Categoría ha sido creada con el identificador {{ param }}",
"updated": "Un Categoria ha sido actualizado con el identificador {{ param }}", "updated": "Una Categoría ha sido actualizado con el identificador {{ param }}",
"deleted": "Un Categoria ha sido eliminado con el identificador {{ param }}", "deleted": "Una Categoría ha sido eliminado con el identificador {{ param }}",
"delete": { "delete": {
"question": "¿Seguro que quiere eliminar Categoria {{ id }}?" "question": "¿Seguro que quiere eliminar Categoría {{ id }}?"
}, },
"detail": { "detail": {
"title": "Categoria" "title": "Categoría"
}, },
"id": "ID", "id": "ID",
"nombre": "Nombre", "nombre": "Nombre",

View File

@ -2,8 +2,8 @@
"dataSurveyApp": { "dataSurveyApp": {
"EstadoCategoria": { "EstadoCategoria": {
"null": "", "null": "",
"ACTIVE": "ACTIVE", "ACTIVE": "ACTIVA",
"INACTIVE": "INACTIVE" "INACTIVE": "INACTIVA"
} }
} }
} }