diff --git a/angular.json b/angular.json
index 7e42e0f27..7ed1ac13d 100644
--- a/angular.json
+++ b/angular.json
@@ -102,7 +102,7 @@
"vendorChunk": false
},
"development": {
- "optimization": true,
+ "optimization": false,
"sourceMap": true,
"namedChunks": true,
"outputHashing": "all",
diff --git a/package.json b/package.json
index e20c7f439..0be609879 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"build": "npm run env -s && ng build --prod --output-hashing=none",
"build:prod": "node --max-old-space-size=16384 ./node_modules/@angular/cli/bin/ng build --prod --output-hashing=none --base-href=/web-app/",
"start": "npm run env -s && ng serve --aot --proxy-config proxy.conf.js",
+ "serve:dev": "npm run env -s && ng serve",
"serve:sw": "npm run build -s && npx http-server ./dist -p 4200",
"lint": "ng lint && stylelint \"src/**/*.scss\" --syntax scss && htmlhint \"src\" --config .htmlhintrc",
"test": "npm run env -s && ng test",
diff --git a/src/app/clients/clients.component.html b/src/app/clients/clients.component.html
index fb93c6ccd..c22844eff 100644
--- a/src/app/clients/clients.component.html
+++ b/src/app/clients/clients.component.html
@@ -6,9 +6,6 @@
-
-
-
Show Closed Accounts
@@ -23,25 +20,26 @@
-
+
+
-
+
| Name |
- {{row.entityName}} |
+ {{row.displayName}} |
-
+
Account No. |
- {{row.entityAccountNo}} |
+ {{row.accountNumber}} |
-
+
External Id |
-
+
|
@@ -49,33 +47,27 @@
Status |
-
+
- {{ row.entityStatus.value | translate }}
+ {{ row.status.value | translate }}
|
-
- Office Name |
- {{row.parentName}} |
-
-
-
-
- Staff Name |
- {{row.staffName}} |
+
+ Office Name |
+ {{row.officeName}} |
-
-
+
+
-
diff --git a/src/app/clients/clients.component.ts b/src/app/clients/clients.component.ts
index 36dbeb25c..663f6b37a 100644
--- a/src/app/clients/clients.component.ts
+++ b/src/app/clients/clients.component.ts
@@ -1,13 +1,13 @@
/** Angular Imports. */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatCheckbox } from '@angular/material/checkbox';
-import { MatPaginator } from '@angular/material/paginator';
-import { MatSort } from '@angular/material/sort';
+import { MatPaginator, PageEvent } from '@angular/material/paginator';
+import { MatSort, Sort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
/** Custom Services */
-import { SearchService } from 'app/search/search.service';
import { environment } from 'environments/environment';
+import { ClientsService } from './clients.service';
@Component({
selector: 'mifosx-clients',
@@ -15,51 +15,75 @@ import { environment } from 'environments/environment';
styleUrls: ['./clients.component.scss'],
})
export class ClientsComponent implements OnInit {
- @ViewChild('showClosedAccounts', { static: true }) showClosedAccounts: MatCheckbox;
+ @ViewChild('showClosedAccounts') showClosedAccounts: MatCheckbox;
- displayedColumns = ['entityName', 'entityAccountNo', 'entityExternalId', 'status', 'parentName', 'staffName'];
- dataSource: MatTableDataSource;
+ displayedColumns = ['displayName', 'accountNumber', 'externalId', 'status', 'officeName'];
+ dataSource: MatTableDataSource = new MatTableDataSource();
existsClientsToFilter = false;
notExistsClientsToFilter = false;
- moreClientsToFilter = false;
- @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
- @ViewChild(MatSort, { static: true }) sort: MatSort;
+ totalRows: number;
+ isLoading = false;
+
+ pageSize = 50;
+ currentPage = 0;
+ filterText = '';
- constructor(private searchService: SearchService) { }
+ sortAttribute = '';
+ sortDirection = '';
+
+ @ViewChild(MatPaginator) paginator: MatPaginator;
+ @ViewChild(MatSort) sort: MatSort;
+
+ constructor(private clientService: ClientsService) { }
ngOnInit() {
if (environment.preloadClients) {
- this.getClients('');
+ this.getClients();
}
}
- /**
- * Filter Client Data
- * @param {string} filterValue Value to filter data.
- */
- applyFilter(filterValue: string = '') {
- this.dataSource.filter = filterValue.trim().toLowerCase();
- }
-
/**
* Searches server for query and resource.
*/
search(value: string) {
- if (value !== '') {
- this.getClients(value);
- }
+ this.filterText = value;
+ this.getClients();
}
- private getClients(value: string) {
- this.searchService.getSearchResults(value, 'clients').subscribe((data: any) => {
- this.dataSource = new MatTableDataSource(data);
- this.dataSource.paginator = this.paginator;
- this.dataSource.sort = this.sort;
- this.existsClientsToFilter = (data.length > 0);
+ private getClients() {
+ this.isLoading = true;
+ this.clientService.searchByText(this.filterText, this.currentPage, this.pageSize, this.sortAttribute, this.sortDirection)
+ .subscribe((data: any) => {
+ this.dataSource.data = data.content;
+
+ this.totalRows = data.totalElements;
+
+ this.existsClientsToFilter = (data.numberOfElements > 0);
this.notExistsClientsToFilter = !this.existsClientsToFilter;
- this.moreClientsToFilter = (data.length > 50);
+ this.isLoading = false;
+ }, (error: any) => {
+ this.isLoading = false;
});
}
+
+ pageChanged(event: PageEvent) {
+ this.pageSize = event.pageSize;
+ this.currentPage = event.pageIndex;
+ this.getClients();
+ }
+
+ sortChanged(event: Sort) {
+ if (event.direction === '') {
+ this.sortDirection = '';
+ this.sortAttribute = '';
+ } else {
+ this.sortAttribute = event.active;
+ this.sortDirection = event.direction;
+ }
+ this.currentPage = 0;
+ this.paginator.firstPage();
+ this.getClients();
+ }
}
diff --git a/src/app/clients/clients.service.ts b/src/app/clients/clients.service.ts
index 6abd9fd99..28963ab69 100644
--- a/src/app/clients/clients.service.ts
+++ b/src/app/clients/clients.service.ts
@@ -381,4 +381,26 @@ export class ClientsService {
getCollateralTemplate(clientId: any) {
return this.http.get(`/clients/${clientId}/collaterals/template`);
}
+
+ searchByText(text: string, page: number, pageSize: number, sortAttribute: string = '', sortDirection: string = '') {
+ let request: any = {
+ request: {
+ text
+ },
+ page,
+ size: pageSize
+ }
+ if (sortAttribute !== '' && sortDirection !== '') {
+ request = {
+ ...request,
+ sorts: [
+ {
+ direction: sortDirection,
+ property: sortAttribute
+ }
+ ]
+ }
+ }
+ return this.http.post(`/v2/clients/search`, request);
+ }
}
diff --git a/src/app/core/http/api-prefix.interceptor.ts b/src/app/core/http/api-prefix.interceptor.ts
index 86d33a13c..c21b851c8 100644
--- a/src/app/core/http/api-prefix.interceptor.ts
+++ b/src/app/core/http/api-prefix.interceptor.ts
@@ -22,13 +22,18 @@ export class ApiPrefixInterceptor implements HttpInterceptor {
* Intercepts a Http request and prefixes it with `serverUrl`.
*/
intercept(request: HttpRequest, next: HttpHandler): Observable> {
+ let baseUrl = this.settingsService.serverUrl;
+
+ const versionRegex = /^\/(v[1-9][0-9]*\/).*$/;
+ if (versionRegex.test(request.url)) {
+ baseUrl = this.settingsService.baseServerUrl;
+ }
/**
* Ignore URLs that are complete for i18n
*/
if (!request.url.includes('http:') && !request.url.includes('https:')) {
- request = request.clone({ url: this.settingsService.serverUrl + request.url });
+ request = request.clone({ url: baseUrl + request.url });
}
-
return next.handle(request);
}
diff --git a/src/app/settings/settings.service.ts b/src/app/settings/settings.service.ts
index a95089f28..34d49b76c 100644
--- a/src/app/settings/settings.service.ts
+++ b/src/app/settings/settings.service.ts
@@ -148,6 +148,13 @@ export class SettingsService {
return environment.baseApiUrl;
}
+ /**
+ * Returns server url with api path without version
+ */
+ get baseServerUrl() {
+ return this.server + environment.apiProvider;
+ }
+
/**
* Returns server url with api path and version
*/