Skip to content

Commit 290ee02

Browse files
committed
Buscadores
1 parent eefd1da commit 290ee02

9 files changed

Lines changed: 171 additions & 13 deletions

File tree

src/app/components/classes/classes.component.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@
77
<a class="material-icons" style="color: white;">school</a>
88
</div>
99
<div class="card-body">
10+
<div class="row justify-content-start" style="padding-left: 20px;" width="95%">
11+
<div *ngIf="!isFilter" class="row">
12+
<mat-form-field width="200px" style="padding-left: 20px;">
13+
<input matInput type="string"
14+
[(ngModel)]="filter"
15+
placeholder="Filtrar por nombre"
16+
(keyup.enter)="putFilter()">
17+
</mat-form-field>
18+
<button (click)="putFilter()"
19+
style="border: 0; background: transparent;">
20+
<a class="material-icons" style="color: #00bcd4;">filter_alt</a>
21+
</button>
22+
</div>
23+
<div *ngIf="isFilter" style="padding-right: 10px;">
24+
<mat-chip-list #chipList>
25+
<mat-chip>
26+
Nombre '{{filter}}'
27+
<mat-icon class="tal" (click)="quitFilter()">cancel</mat-icon>
28+
</mat-chip>
29+
</mat-chip-list>
30+
</div>
31+
</div>
1032
<div class="table-responsive" *ngIf="true">
1133
<mat-table class="lessons-table mat-elevation-z8" [dataSource]="classRooms" #classRoomTable>
1234
<ng-container matColumnDef="id">
@@ -72,4 +94,12 @@
7294
.mat-row:hover {
7395
background-color: #00bbd442;
7496
}
97+
.tal {
98+
padding: 4px 4px 3px 4px;
99+
font-size: 17px;
100+
color: gray;
101+
}
102+
.tal:hover{
103+
color: rgb(56, 53, 53)!important;
104+
}
75105
</style>

src/app/components/classes/classes.component.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export class ClassesComponent implements OnInit {
3636
levelId: number = null;
3737
userId:number = null;
3838
teacherId:number = null;
39-
39+
filter = "";
40+
isFilter = false;
4041
ngOnInit(): void {
4142
const p: PageEvent =new PageEvent();
4243
p.pageIndex = 0;
@@ -59,7 +60,7 @@ export class ClassesComponent implements OnInit {
5960

6061
public getServerData(event?:PageEvent){
6162
this.subRefs$.push(
62-
this.serverService.getClassRooms(event.pageIndex, event.pageSize, this.levelId, this.userId, this.teacherId)
63+
this.serverService.getClassRooms(event.pageIndex, event.pageSize, this.levelId, this.userId, this.teacherId, this.filter != ''? this.filter : null)
6364
.subscribe(
6465
res => {
6566
if (res.status === 200) {
@@ -114,6 +115,25 @@ export class ClassesComponent implements OnInit {
114115
});
115116
}
116117

118+
119+
putFilter() {
120+
this.isFilter = true;
121+
this.pageIndex = 0;
122+
const p: PageEvent =new PageEvent();
123+
p.pageIndex = 0;
124+
p.pageSize = this.pageSize;
125+
this.getServerData(p);
126+
}
127+
128+
quitFilter() {
129+
this.isFilter = false;
130+
this.filter = '';
131+
this.pageIndex = 0;
132+
const p: PageEvent =new PageEvent();
133+
p.pageIndex = 0;
134+
p.pageSize = this.pageSize;
135+
this.getServerData(p);
136+
}
117137

118138
ngOnDestroy(): void {
119139
this.subRefs$.forEach(r => {if(r){ r.unsubscribe();} })

src/app/components/levels/levels.component.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
<div class="col-md-12">
55
<div class="card">
66
<div class="card-body">
7+
<div class="row justify-content-start" style="padding-left: 20px;" width="95%">
8+
<div *ngIf="!isFilter" class="row">
9+
<mat-form-field width="200px" style="padding-left: 20px;">
10+
<input matInput type="string"
11+
[(ngModel)]="filter"
12+
placeholder="Filtrar por nombre"
13+
(keyup.enter)="putFilter()">
14+
</mat-form-field>
15+
<button (click)="putFilter()"
16+
style="border: 0; background: transparent;">
17+
<a class="material-icons" style="color: #00bcd4;">filter_alt</a>
18+
</button>
19+
</div>
20+
<div *ngIf="isFilter" style="padding-right: 10px;">
21+
<mat-chip-list #chipList>
22+
<mat-chip>
23+
Nombre '{{filter}}'
24+
<mat-icon class="tal" (click)="quitFilter()">cancel</mat-icon>
25+
</mat-chip>
26+
</mat-chip-list>
27+
</div>
28+
</div>
729
<div class="table-responsive" *ngIf="true">
830
<mat-table class="lessons-table mat-elevation-z8" [dataSource]="levels" #levelTable>
931
<ng-container matColumnDef="id">
@@ -76,4 +98,13 @@
7698
.mat-row:hover {
7799
background-color: #00bbd442;
78100
}
101+
102+
.tal {
103+
padding: 4px 4px 3px 4px;
104+
font-size: 17px;
105+
color: gray;
106+
}
107+
.tal:hover{
108+
color: rgb(56, 53, 53)!important;
109+
}
79110
</style>

src/app/components/levels/levels.component.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export class LevelsComponent implements OnInit {
3636
displayedColumns: string[] = ['id','title', 'description','active','publicLevel', 'classRooms','owner'];
3737
classId: number = null;
3838
userId:number = null;
39+
filter = "";
40+
isFilter = false;
3941

4042
ngOnInit(): void {
4143
const p: PageEvent =new PageEvent();
@@ -54,8 +56,9 @@ export class LevelsComponent implements OnInit {
5456
}
5557

5658
public getServerData(event?:PageEvent){
59+
debugger
5760
this.subRefs$.push(
58-
this.serverService.getLevels(event.pageIndex, event.pageSize, this.classId, this.userId)
61+
this.serverService.getLevels(event.pageIndex, event.pageSize, this.classId, this.userId, this.filter != ''? this.filter : null)
5962
.subscribe(
6063
res => {
6164
if (res.status === 200) {
@@ -101,6 +104,24 @@ export class LevelsComponent implements OnInit {
101104
});
102105
}
103106

107+
putFilter() {
108+
this.isFilter = true;
109+
this.pageIndex = 0;
110+
const p: PageEvent =new PageEvent();
111+
p.pageIndex = 0;
112+
p.pageSize = this.pageSize;
113+
this.getServerData(p);
114+
}
115+
116+
quitFilter() {
117+
this.isFilter = false;
118+
this.filter = '';
119+
this.pageIndex = 0;
120+
const p: PageEvent =new PageEvent();
121+
p.pageIndex = 0;
122+
p.pageSize = this.pageSize;
123+
this.getServerData(p);
124+
}
104125
ngOnDestroy(): void {
105126
this.subRefs$.forEach(r => {if(r){ r.unsubscribe();} })
106127
}

src/app/components/users/users.component.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@
77
<a class="material-icons" style="color: white;" >person_add</a>
88
</div>
99
<div class="card-body">
10+
<div class="row justify-content-start" style="padding-left: 20px;" width="95%">
11+
<div *ngIf="!isFilter" class="row">
12+
<mat-form-field width="200px" style="padding-left: 20px;">
13+
<input matInput type="string"
14+
[(ngModel)]="filter"
15+
placeholder="Filtrar por nombre"
16+
(keyup.enter)="putFilter()">
17+
</mat-form-field>
18+
<button (click)="putFilter()"
19+
style="border: 0; background: transparent;">
20+
<a class="material-icons" style="color: #00bcd4;">filter_alt</a>
21+
</button>
22+
</div>
23+
<div *ngIf="isFilter" style="padding-right: 10px;">
24+
<mat-chip-list #chipList>
25+
<mat-chip>
26+
Nombre '{{filter}}'
27+
<mat-icon class="tal" (click)="quitFilter()">cancel</mat-icon>
28+
</mat-chip>
29+
</mat-chip-list>
30+
</div>
31+
</div>
1032
<div class="table-responsive" *ngIf="true">
1133
<mat-table class="lessons-table mat-elevation-z8" [dataSource]="users" #userTable>
1234
<ng-container matColumnDef="id">
@@ -57,5 +79,13 @@
5779
.mat-row:hover {
5880
background-color: #00bbd442;
5981
}
82+
.tal {
83+
padding: 4px 4px 3px 4px;
84+
font-size: 17px;
85+
color: gray;
86+
}
87+
.tal:hover{
88+
color: rgb(56, 53, 53)!important;
89+
}
6090
</style>
6191

src/app/components/users/users.component.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export class UsersComponent implements OnInit, OnDestroy {
3636
displayedColumns: string[] = ['id', 'username', 'enabled', 'role'];
3737
classId: number = null;
3838
teacher:boolean = null;
39-
39+
filter = "";
40+
isFilter = false;
4041

4142
ngOnInit(): void {
4243
const p: PageEvent =new PageEvent();
@@ -54,7 +55,7 @@ export class UsersComponent implements OnInit, OnDestroy {
5455
public getServerData(event?:PageEvent){
5556

5657
this.subRefs$.push(
57-
this.serverService.getUsers(event.pageIndex, event.pageSize, this.classId, this.teacher)
58+
this.serverService.getUsers(event.pageIndex, event.pageSize, this.classId, this.teacher, this.filter != ''? this.filter : null)
5859
.subscribe(
5960
res => {
6061

@@ -90,6 +91,24 @@ export class UsersComponent implements OnInit, OnDestroy {
9091
});
9192
}
9293

94+
putFilter() {
95+
this.isFilter = true;
96+
this.pageIndex = 0;
97+
const p: PageEvent =new PageEvent();
98+
p.pageIndex = 0;
99+
p.pageSize = this.pageSize;
100+
this.getServerData(p);
101+
}
102+
103+
quitFilter() {
104+
this.isFilter = false;
105+
this.filter = '';
106+
this.pageIndex = 0;
107+
const p: PageEvent =new PageEvent();
108+
p.pageIndex = 0;
109+
p.pageSize = this.pageSize;
110+
this.getServerData(p);
111+
}
93112
ngOnDestroy(): void {
94113
this.subRefs$.forEach(r => {if(r){ r.unsubscribe();} })
95114
}

src/app/layouts/admin-layout/admin-layout.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {MatSlideToggleModule} from '@angular/material/slide-toggle';
2828
import { MatDividerModule } from '@angular/material/divider';
2929
import { MatCardModule } from '@angular/material/card';
3030
import { MatIconModule } from '@angular/material/icon';
31+
import { MatChipsModule } from '@angular/material/chips';
3132
import { UserDetailComponent } from 'app/components/users/user-detail/user-detail.component';
3233
import {MatAccordion, MatExpansionModule} from '@angular/material/expansion';
3334
import { ConfirmDialogComponent } from 'app/components/confirm-dialog/confirm-dialog.component';
@@ -63,7 +64,8 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
6364
MatExpansionModule,
6465
MatProgressSpinnerModule,
6566
MatIconModule,
66-
MatDividerModule
67+
MatDividerModule,
68+
MatChipsModule
6769
],
6870
declarations: [
6971
UsersComponent,

src/app/server.service.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ export class ServerService {
3434

3535
/** USERS */
3636

37-
getUsers(page:number, size:number, classId: number, teacher: boolean):Observable<HttpResponse<IPage<IUser>>> {
38-
var url = this.host + 'users?page=' + page + '&size=' + size;
37+
getUsers(page:number, size:number, classId: number, teacher: boolean, filter:string = null):Observable<HttpResponse<IPage<IUser>>> {
38+
var url = this.host + 'users?page=' + page + '&size=' + size +
39+
(filter?"&title=" + filter:"");
3940
if (classId) {
4041
url = url + '&class=' + classId + '&teacher=' + teacher;
4142
}
@@ -68,8 +69,9 @@ export class ServerService {
6869

6970
/** CLASS ROOMS */
7071

71-
getClassRooms(page: number, size: number,levelId: number, userId: number, teacherId: number):Observable<HttpResponse<IPage<IClassRoom>>> {
72-
var url = this.host + 'classes?page=' + page + '&size=' + size;
72+
getClassRooms(page: number, size: number,levelId: number, userId: number, teacherId: number,filter:string = null):Observable<HttpResponse<IPage<IClassRoom>>> {
73+
var url = this.host + 'classes?page=' + page + '&size=' + size +
74+
(filter?"&title=" + filter:"");
7375
if(levelId) {
7476
url = url + '&level=' + levelId;
7577
} else if(userId){
@@ -129,14 +131,16 @@ export class ServerService {
129131
}
130132
/** LEVELS */
131133

132-
getLevels(page: number, size: number,classId: number, userId: number):Observable<HttpResponse<IPage<ILevel>>> {
133-
var url = this.host + 'levels?page=' + page + '&size=' + size;
134+
getLevels(page: number, size: number,classId: number, userId: number, filter:string = null):Observable<HttpResponse<IPage<ILevel>>> {
135+
debugger
136+
var url = this.host + 'levels?page=' + page + '&size=' + size +
137+
(filter?"&title=" + filter:"");
138+
134139
if(classId) {
135140
url = url + '&class=' + classId;
136141
} else if(userId){
137142
url = url + '&user=' + userId;
138143
}
139-
140144
return this.http.get<IPage<ILevel>>(url,
141145
{ observe: 'response' });
142146
}

src/environments/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
export const environment = {
77
production: false,
88
host:"http://13.48.149.249:8080/"
9+
// host: "http://localhost:8080/"
910
};

0 commit comments

Comments
 (0)