Skip to content

Commit

Permalink
Filtragem por vinculo
Browse files Browse the repository at this point in the history
  • Loading branch information
nYCSTs committed Nov 2, 2023
1 parent 8a4d39f commit 217f143
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/app/pages/update-role/update-role.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ tr:hover {
background-color: #e0e0e0;
}

select {
border: 1px solid black;
border-radius: 6px;
padding: 2px 4px;
.filter-container {
display: flex;
align-items: flex-start;
column-gap: 6px;
}
35 changes: 28 additions & 7 deletions src/app/pages/update-role/update-role.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
<div class="mx-5">
<input
[(ngModel)]="filterInputValue"
(change)="filterUser()"
placeholder="Filtrar pelo nome do usuário"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-100 p-2.5 outline-none" />
<div class="filter-container">
<div>
<label>Nome ou Email:</label>
<input
[(ngModel)]="filterInputValue"
(change)="filterUser()"
placeholder="Filtrar pelo nome do usuário"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-100 p-2.5 outline-none"
/>
</div>
<div>
<label>Vínculo:</label>
<select
(change)="filterUser()"
[(ngModel)]="filterConnectionValue"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-100 p-2.5 outline-none"
>
<option disabled hidden value="">Selecione um vínculo</option>
<option value="ALUNO">Aluno</option>
<option value="PROFESSOR">Professor</option>
<option value="COMUNIDADE">Comunidade</option>
<option value="EXTERNO">Externo</option>
</select>
</div>
</div>
<table class="table-auto mt-3" style="border-collapse: collapse !important;" >
<thead>
<tr>
Expand All @@ -21,9 +41,10 @@
<td>{{ user.connection }}</td>
<td>
<select
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 outline-none"
class="bg-gray-100 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 outline-none"
[(ngModel)]="user.role"
(change)="updateUserRole(user.id)" *ngIf="user.id !== userId; else readOnly">
(change)="updateUserRole(user.id)" *ngIf="user.id !== userId; else readOnly"
>
<option value="USER">Usuário</option>
<option value="ADMIN">Administrador</option>
</select>
Expand Down
11 changes: 9 additions & 2 deletions src/app/pages/update-role/update-role.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import jwt_decode from 'jwt-decode';
export class UpdateRoleComponent {
users: any = [];
userId: number = 0;

filterInputValue: string = "";
total: number = 0;
filterConnectionValue: string = ""

total: number = 0;
pageSize: number = 10;
pageIndex: number = 0;

Expand Down Expand Up @@ -54,7 +56,12 @@ export class UpdateRoleComponent {
};

getAllUsers() {
this.userService.getAllUsers({ nameEmail: this.filterInputValue, limit: this.pageSize, offset: (this.pageIndex * this.pageSize) }).subscribe({
this.userService.getAllUsers({
nameEmail: this.filterInputValue,
connection: this.filterConnectionValue,
limit: this.pageSize,
offset: (this.pageIndex * this.pageSize)
}).subscribe({
next: (data: Response) => {
this.users = data.body;
if (data.headers.has("x-total-count")) {
Expand Down

0 comments on commit 217f143

Please sign in to comment.