Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 4d1df66

Browse files
jvalkealcppwfs
authored andcommitted
Fix app list paging and filtering
- Remove caching from page in favour of doing server side filtering with paging. Filter on server side is only with name as address doesn't play nice search(makes it impossible to filter names). - Initially tried to add better tests for apps but that was a failure. Will get done with #336. - Fixes #296 Resolves issue with search field being disabled on empty result
1 parent b4fd432 commit 4d1df66

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

ui/src/app/apps/apps.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h1 [ngBusy]="busy">Apps</h1>
2424
<span class="hidden-xs">Bulk Import Applications</span>
2525
</button>
2626
<label *ngIf="appRegistrations" class="control">
27-
<input type="text" class="input" placeholder="Filter items" [(ngModel)]="appRegistrations.filter" [disabled]="!appRegistrations || appRegistrations.items.length === 0">
27+
<input type="text" class="input" placeholder="Filter items" [(ngModel)]="appRegistrations.filter" >
2828
</label>
2929
<button id="refreshAppRegistrationsButton" type="button" (click)="loadAppRegistrations(true)"
3030
class="btn btn-default"
@@ -44,7 +44,7 @@ <h1 [ngBusy]="busy">Apps</h1>
4444
</tr>
4545
</thead>
4646
<tbody>
47-
<tr *ngFor="let item of appRegistrations.items | searchFilter: appRegistrations.filter | paginate: appRegistrations.getPaginationInstance(); index as i">
47+
<tr *ngFor="let item of appRegistrations.items | paginate: appRegistrations.getPaginationInstance(); index as i">
4848
<td><input type="checkbox" [(ngModel)]="item.isSelected" /></td>
4949
<td>{{item.name}}</td>
5050
<td>{{item.type}}</td>

ui/src/app/apps/apps.component.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class AppsComponent implements OnInit {
5656
* @param reload
5757
*/
5858
public loadAppRegistrations(reload: boolean) {
59-
this.busy = this.appsService.getApps(reload).subscribe(
59+
this.busy = this.appsService.getApps(reload, this.getFilter()).subscribe(
6060
data => {
6161
if (!this.appRegistrations) {
6262
this.appRegistrations = data;
@@ -128,7 +128,7 @@ export class AppsComponent implements OnInit {
128128
if (this.appsService.appRegistrations.items.length === 0 && this.appsService.appRegistrations.pageNumber > 0) {
129129
this.appRegistrations.pageNumber = this.appRegistrations.pageNumber - 1;
130130
}
131-
this.busy = this.appsService.getApps(true).subscribe(
131+
this.busy = this.appsService.getApps(true, this.getFilter()).subscribe(
132132
appRegistrations => {}
133133
);
134134
},
@@ -154,7 +154,7 @@ export class AppsComponent implements OnInit {
154154
if (this.appsService.appRegistrations.items.length === 0 && this.appsService.appRegistrations.pageNumber > 0) {
155155
this.appRegistrations.pageNumber = this.appRegistrations.pageNumber - 1;
156156
}
157-
this.busy = this.appsService.getApps(true).subscribe(
157+
this.busy = this.appsService.getApps(true, this.getFilter()).subscribe(
158158
appRegistrationsResult => {}
159159
);
160160
}
@@ -202,4 +202,12 @@ export class AppsComponent implements OnInit {
202202
this.appsService.appRegistrations.pageNumber = page - 1;
203203
this.loadAppRegistrations(true);
204204
}
205+
206+
private getFilter(): string {
207+
let search: string;
208+
if (this.appRegistrations) {
209+
search = this.appRegistrations.filter;
210+
}
211+
return search;
212+
}
205213
}

ui/src/app/apps/apps.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class AppsService {
3232
console.log('constructing');
3333
}
3434

35-
getApps(reload?: boolean): Observable<Page<AppRegistration>> {
35+
getApps(reload?: boolean, search?: string): Observable<Page<AppRegistration>> {
3636
console.log(`Get apps - reload ${reload}`, this.appRegistrations);
3737
if (!this.appRegistrations || reload) {
3838
if (!this.appRegistrations) {
@@ -42,7 +42,7 @@ export class AppsService {
4242
this.remotelyLoaded = true;
4343

4444
return this.sharedAppsService.getApps(
45-
new PageRequest(this.appRegistrations.pageNumber, this.appRegistrations.pageSize))
45+
new PageRequest(this.appRegistrations.pageNumber, this.appRegistrations.pageSize), undefined, search)
4646
.map(page => {
4747
this.appRegistrations.update(page);
4848
return this.appRegistrations;

ui/src/app/shared/services/shared-apps.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ export class SharedAppsService {
2323
/**
2424
* Returns a paged list of {@link AppRegistrations}s.
2525
*/
26-
getApps(pageRequest: PageRequest, type?: ApplicationType): Observable<Page<AppRegistration>> {
26+
getApps(pageRequest: PageRequest, type?: ApplicationType, search?: string): Observable<Page<AppRegistration>> {
2727
const params = HttpUtils.getPaginationParams(pageRequest.page, pageRequest.size);
2828
const requestOptionsArgs: RequestOptionsArgs = HttpUtils.getDefaultRequestOptions();
2929

3030
if (type) {
3131
params.append('type', ApplicationType[type]);
3232
}
33+
if (search) {
34+
params.append('search', search);
35+
}
3336
requestOptionsArgs.search = params;
3437
return this.http.get(SharedAppsService.appsUrl, requestOptionsArgs)
3538
.map(this.extractData.bind(this))

0 commit comments

Comments
 (0)