From 0a86178d21c9a2de3bc705f3592afeafc314563d Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Tue, 3 Mar 2020 19:18:27 +0530 Subject: [PATCH] Fairoj : Sales PD Advanced Filter option, Loader for every HTTP Request and PD List Limit note in all list screen --- ng6-seed/src/app/_guard/token.interceptor.ts | 29 ++++- ng6-seed/src/app/app.module.ts | 6 +- .../layouts/admin/admin-layout.component.html | 2 + .../http-loader/http-loader.component.html | 6 + .../http-loader/http-loader.component.scss | 34 +++++ .../http-loader/http-loader.component.spec.ts | 25 ++++ .../http-loader/http-loader.component.ts | 29 +++++ .../list-pd/all-pd/all-pd.component.html | 13 +- .../list-pd/all-pd/all-pd.component.scss | 9 +- .../list-pd/all-pd/all-pd.component.ts | 3 + .../completed-pd/completed-pd.component.html | 15 ++- .../completed-pd/completed-pd.component.ts | 5 +- .../inprogress-pd.component.html | 13 +- .../inprogress-pd/inprogress-pd.component.ts | 5 +- .../qc-completed-pd.component.html | 13 +- .../qc-completed-pd.component.ts | 5 +- .../scheduled-pd/scheduled-pd.component.html | 11 +- .../scheduled-pd/scheduled-pd.component.ts | 5 +- .../material_modules/material.module.ts | 4 +- .../advance-filter.component.html | 78 ++++++++++++ .../advance-filter.component.scss | 0 .../advance-filter.component.spec.ts | 25 ++++ .../advance-filter.component.ts | 119 ++++++++++++++++++ .../sales-pd-list/sales-pd.component.html | 83 ++---------- .../sales-pd-list/sales-pd.component.scss | 7 ++ .../sales-pd-list/sales-pd.component.ts | 50 ++++++++ ng6-seed/src/app/sales-pd/sales-pd.module.ts | 3 +- .../app/sales-pd/services/sales-pd.service.ts | 3 + .../loaderService/loader.service.spec.ts | 12 ++ .../shared/loaderService/loader.service.ts | 19 +++ ng6-seed/src/environments/environment.ts | 3 +- 31 files changed, 526 insertions(+), 108 deletions(-) create mode 100644 ng6-seed/src/app/layouts/http-loader/http-loader.component.html create mode 100644 ng6-seed/src/app/layouts/http-loader/http-loader.component.scss create mode 100644 ng6-seed/src/app/layouts/http-loader/http-loader.component.spec.ts create mode 100644 ng6-seed/src/app/layouts/http-loader/http-loader.component.ts create mode 100644 ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.html create mode 100644 ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.scss create mode 100644 ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.spec.ts create mode 100644 ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.ts create mode 100644 ng6-seed/src/app/shared/loaderService/loader.service.spec.ts create mode 100644 ng6-seed/src/app/shared/loaderService/loader.service.ts diff --git a/ng6-seed/src/app/_guard/token.interceptor.ts b/ng6-seed/src/app/_guard/token.interceptor.ts index 1767891e3..7b4534355 100755 --- a/ng6-seed/src/app/_guard/token.interceptor.ts +++ b/ng6-seed/src/app/_guard/token.interceptor.ts @@ -4,7 +4,8 @@ import { HttpHandler, HttpEvent, HttpInterceptor, - HttpHeaders + HttpHeaders, + HttpResponse } from '@angular/common/http'; // import { AuthGuard } from './auth.guard'; import { Observable, of, throwError } from 'rxjs'; @@ -14,16 +15,18 @@ import { HttpErrorResponse } from "@angular/common/http"; import { CognitoService } from '../AwsService/cognito.service'; //environment import { environment } from '../../environments/environment'; +import { LoaderService } from 'app/shared/loaderService/loader.service'; @Injectable() export class TokenInterceptor implements HttpInterceptor{ - constructor( private router: Router,public shared:CognitoService) {} + constructor( private router: Router,public shared:CognitoService,private loaderService:LoaderService) {} intercept(request: HttpRequest, next: HttpHandler): Observable> { // request = request.clone({ // setHeaders: { // Authorization: `${this.auth.getToken()}` // } // }); + this.showLoader(); let token:any = this.shared.getAccessToken() ||""; //console.log(token); let requests = request.clone({ @@ -32,9 +35,15 @@ export class TokenInterceptor implements HttpInterceptor{ 'Token': token.getIdToken().getJwtToken() }) }); - return next.handle(requests).pipe( - catchError(this.handleError('role', [])) - ) + return next.handle(requests).pipe(tap((event:HttpEvent)=>{ + if (event instanceof HttpResponse) { + this.onEnd(); + } + }, + (err: any) => { + this.handleError('role',err); + this.onEnd(); + })); } // private handleError (operation = 'operation', result?: T) { @@ -54,6 +63,7 @@ export class TokenInterceptor implements HttpInterceptor{ private handleError (operation = 'operation', result?: T) { return (error: any): Observable => { if(error instanceof HttpErrorResponse){ + // this.onEnd(); console.log("Error from interceptor >>>",error) console.error("Error: " + error.status); if(error.status == 401){ @@ -91,4 +101,13 @@ export class TokenInterceptor implements HttpInterceptor{ } }; } + private onEnd(): void { + this.hideLoader(); + } + private showLoader(): void { + this.loaderService.show(); + } + private hideLoader(): void { + this.loaderService.hide(); + } } \ No newline at end of file diff --git a/ng6-seed/src/app/app.module.ts b/ng6-seed/src/app/app.module.ts index d626e5b9c..ff95f18ec 100755 --- a/ng6-seed/src/app/app.module.ts +++ b/ng6-seed/src/app/app.module.ts @@ -56,6 +56,8 @@ import { environment } from '../environments/environment'; import { AsyncPipe } from '../../node_modules/@angular/common'; // import { SalesPdComponent } from './sales-pd/sales-pd.component'; import { PdTrigerService } from './personal-discussion/pd-service/pd-triger.service'; +import { HttpLoaderComponent } from './layouts/http-loader/http-loader.component'; +import { LoaderService } from './shared/loaderService/loader.service'; export function HttpLoaderFactory(http: HttpClient) { @@ -75,7 +77,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { AppComponent, AdminLayoutComponent, AuthLayoutComponent, - NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe + NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe, HttpLoaderComponent ], imports: [ BrowserModule, @@ -130,7 +132,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { useClass: TokenInterceptor, multi: true }, - MessagingService, AsyncPipe + MessagingService, AsyncPipe,LoaderService ], entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog], bootstrap: [AppComponent] diff --git a/ng6-seed/src/app/layouts/admin/admin-layout.component.html b/ng6-seed/src/app/layouts/admin/admin-layout.component.html index ffbfd6e50..a285abdbc 100755 --- a/ng6-seed/src/app/layouts/admin/admin-layout.component.html +++ b/ng6-seed/src/app/layouts/admin/admin-layout.component.html @@ -347,6 +347,7 @@ +
+
diff --git a/ng6-seed/src/app/layouts/http-loader/http-loader.component.html b/ng6-seed/src/app/layouts/http-loader/http-loader.component.html new file mode 100644 index 000000000..f1e8f5499 --- /dev/null +++ b/ng6-seed/src/app/layouts/http-loader/http-loader.component.html @@ -0,0 +1,6 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/ng6-seed/src/app/layouts/http-loader/http-loader.component.scss b/ng6-seed/src/app/layouts/http-loader/http-loader.component.scss new file mode 100644 index 000000000..9eb5f1b15 --- /dev/null +++ b/ng6-seed/src/app/layouts/http-loader/http-loader.component.scss @@ -0,0 +1,34 @@ +.hidden { + visibility: hidden; + } + .loader-overlay { + position: absolute; + width: 100%; + z-index: 500000; + top: 0; + } + .loader { + height: 4px; + width: 100%; + position: relative; + overflow: hidden; + background-color: #FFF; + } + .loader:before { + display: block; + position: absolute; + content: ""; + left: -200px; + width: 200px; + height: 4px; + background-color: red; + animation: loading 2s linear infinite; + } + @keyframes loading { + from {left: -200px; width: 30%;} + 50% {width: 30%;} + 70% {width: 70%;} + 80% {left: 50%;} + 95% {left: 120%;} + to {left: 100%;} + } \ No newline at end of file diff --git a/ng6-seed/src/app/layouts/http-loader/http-loader.component.spec.ts b/ng6-seed/src/app/layouts/http-loader/http-loader.component.spec.ts new file mode 100644 index 000000000..1aead06d8 --- /dev/null +++ b/ng6-seed/src/app/layouts/http-loader/http-loader.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HttpLoaderComponent } from './http-loader.component'; + +describe('HttpLoaderComponent', () => { + let component: HttpLoaderComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ HttpLoaderComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(HttpLoaderComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/layouts/http-loader/http-loader.component.ts b/ng6-seed/src/app/layouts/http-loader/http-loader.component.ts new file mode 100644 index 000000000..0e4be33ea --- /dev/null +++ b/ng6-seed/src/app/layouts/http-loader/http-loader.component.ts @@ -0,0 +1,29 @@ +import { Component, OnInit } from '@angular/core'; +import { LoaderService } from 'app/shared/loaderService/loader.service'; +import { Subscription } from 'rxjs'; +export interface LoaderState { + show: boolean; +} +@Component({ + selector: 'app-http-loader', + templateUrl: './http-loader.component.html', + styleUrls: ['./http-loader.component.scss'] +}) +export class HttpLoaderComponent implements OnInit { + show = false; + private subscription: Subscription; + + constructor( private loaderService: LoaderService) { } + + ngOnInit() { + this.subscription = this.loaderService.loaderState + .subscribe((state: LoaderState) => { + this.show = state.show; + }); + } + ngOnDestroy() { + this.subscription.unsubscribe(); + } + + +} diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html index 96f03bcc5..43e1cf60b 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.html @@ -5,7 +5,7 @@ filter_list - Advance Filter + Advanced Filter @@ -78,7 +78,7 @@ -
+

Showing data for last 10 days. Showing data for last 10 days. To see older records, please use advanced filter

@@ -156,8 +156,13 @@ --> - - + + + +
Showing data for last 10 days. To see older records, please use advanced filter
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.scss index 4043f5c5d..c24aaeb0a 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.scss @@ -18,4 +18,11 @@ .toolbar-space { flex: 0.01 0 auto; } - \ No newline at end of file + +p.note { + // float: right; + text-align: right; + font-size: 12px; + color: grey; + font-weight: bold; +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts index 74eba2c9c..715e0ddb6 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/all-pd/all-pd.component.ts @@ -91,6 +91,7 @@ export class AllPdComponent implements OnInit, OnChanges { this.PdListData = data.records; this.dataLengthTab1 = data.records.length; this.dataSourceTab1.data = this.PdListData; + this.recordStatus=false; } else{ this.PdListData=[]; @@ -201,11 +202,13 @@ export class AllPdComponent implements OnInit, OnChanges { this.dataSourceTab1.data = res['records']; // console.log('records',res['records']); this.dataSourceTab1.paginator = this.paginator; + this.recordStatus=false; }else{ this.notifier.notify('warning', 'No Records Found !'); this.dataSourceTab1.paginator['length'] = 0; this.dataSourceTab1.paginator['pageIndex'] = 0; this.dataSourceTab1.data = []; + this.recordStatus=true; // console.log('records-records',res['records']); } },error => { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html index e2f8ed4c1..fd6ee6e54 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.html @@ -7,7 +7,7 @@ filter_list - Advance Filter + Advanced Filter @@ -73,7 +73,7 @@ -
+

Showing data for last 10 days. Showing data for last 10 days. To see older records, please use advanced filter

@@ -125,9 +125,14 @@ - + - - + + + +
Showing data for last 10 days. To see older records, please use advanced filter
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts index 08049caa7..2f9d3b525 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/completed-pd/completed-pd.component.ts @@ -93,6 +93,7 @@ export class CompletedPdComponent implements OnInit, OnChanges { this.completedPdListData = data.records; this.dataLengthTab4 = data.records.length; this.dataSourceTab4.data = this.completedPdListData; + this.recordStatus=false; } else{ this.completedPdListData=[]; @@ -215,12 +216,14 @@ export class CompletedPdComponent implements OnInit, OnChanges { { this.dataSourceTab4 = res['records']; this.dataSourceTab4.paginator = this.paginator; + this.recordStatus=false; }else{ this.notifier.notify('warning', 'No Records Found !'); this.dataSourceTab4.paginator['length'] = 0; this.dataSourceTab4.paginator['pageIndex'] = 0; - this.dataSourceTab4.data = []; + this.dataSourceTab4.data = []; + this.recordStatus=true; } },error => { this.errorMessage.push(error); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html index a71f2de87..c8d1a21ab 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.html @@ -6,7 +6,7 @@ filter_list - Advance Filter + Advanced Filter @@ -72,7 +72,7 @@ -
+

Showing data for last 10 days. Showing data for last 10 days. To see older records, please use advanced filter

@@ -121,7 +121,12 @@ - - + + + +
Showing data for last 10 days. To see older records, please use advanced filter
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts index a2b486e73..44b6cbb25 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/inprogress-pd/inprogress-pd.component.ts @@ -88,6 +88,7 @@ export class InprogressPdComponent implements OnInit, OnChanges { this.progressPdListData = data.records; this.dataLengthTab2 = data.records.length; this.dataSourceTab2.data = this.progressPdListData; + this.recordStatus=false; }else{ this.progressPdListData =[]; this.dataSourceTab2 = null; @@ -206,11 +207,13 @@ export class InprogressPdComponent implements OnInit, OnChanges { { this.dataSourceTab2 = res['records']; this.dataSourceTab2.paginator = this.paginator; + this.recordStatus=false; }else{ this.notifier.notify('warning', 'No Records Found !'); this.dataSourceTab2.paginator['length'] = 0; this.dataSourceTab2.paginator['pageIndex'] = 0; - this.dataSourceTab2.data = []; + this.dataSourceTab2.data = []; + this.recordStatus=true; } },error => { this.errorMessage.push(error); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html index 9dc13bc53..ae6db3c34 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.html @@ -6,7 +6,7 @@ filter_list - Advance Filter + Advanced Filter @@ -74,7 +74,7 @@ -
+

Showing data for last 10 days. Showing data for last 10 days. To see older records, please use advanced filter

@@ -124,7 +124,12 @@ - - + + + +
Showing data for last 10 days. To see older records, please use advanced filter
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts index 0ad028e3f..ed11546c1 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/qc-completed-pd/qc-completed-pd.component.ts @@ -94,6 +94,7 @@ export class QcCompletedPdComponent implements OnInit, OnChanges { this.qcCompletedPdListData = data.records; this.dataLengthTab5 = data.records.length; this.dataSourceTab5.data = this.qcCompletedPdListData; + this.recordStatus = false } else { this.qcCompletedPdListData = []; @@ -193,11 +194,13 @@ export class QcCompletedPdComponent implements OnInit, OnChanges { if (res['dataStatus'] == true) { this.dataSourceTab5 = res['records']; this.dataSourceTab5.paginator = this.paginator; + this.recordStatus = false }else{ this.notifier.notify('warning', 'No Records Found !'); this.dataSourceTab5.paginator['length'] = 0; this.dataSourceTab5.paginator['pageIndex'] = 0; - this.dataSourceTab5.data = []; + this.dataSourceTab5.data = []; + this.recordStatus = true } },error => { this.errorMessage.push(error); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html index d45bb0319..811be580f 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.html @@ -6,7 +6,7 @@ filter_list - Advance Filter + Advanced Filter @@ -72,7 +72,7 @@ -
+

Showing data for last 10 days. Showing data for last 10 days. To see older records, please use advanced filter

@@ -124,8 +124,13 @@ - +
+
+ +
Showing data for last 10 days. To see older records, please use advanced filter
+
\ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts index e17970ad1..872c0545d 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/scheduled-pd/scheduled-pd.component.ts @@ -93,6 +93,7 @@ export class ScheduledPdComponent implements OnInit, OnChanges { this.scheduledPdListData = data.records; this.dataLengthTab3 = data.records.length; this.dataSourceTab3.data = this.scheduledPdListData; + this.recordStatus = false } else{ this.scheduledPdListData=[]; @@ -206,11 +207,13 @@ export class ScheduledPdComponent implements OnInit, OnChanges { { this.dataSourceTab3 = res['records']; this.dataSourceTab3.paginator = this.paginator; + this.recordStatus = false }else{ this.notifier.notify('warning', 'No Records Found !'); this.dataSourceTab3.paginator['length'] = 0; this.dataSourceTab3.paginator['pageIndex'] = 0; - this.dataSourceTab3.data = []; + this.dataSourceTab3.data = []; + this.recordStatus = true } },error => { this.errorMessage.push(error); diff --git a/ng6-seed/src/app/sales-pd/material_modules/material.module.ts b/ng6-seed/src/app/sales-pd/material_modules/material.module.ts index 94d954350..3529e40ca 100644 --- a/ng6-seed/src/app/sales-pd/material_modules/material.module.ts +++ b/ng6-seed/src/app/sales-pd/material_modules/material.module.ts @@ -1,6 +1,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { MatIconModule, MatInputModule, MatTableModule, MatListModule, MatToolbarModule, MatFormFieldModule, MatTabsModule, MatCardModule, MatPaginatorModule, MatButtonModule, MatExpansionModule, MatProgressBarModule, MatProgressSpinnerModule, MatDatepickerModule } from '@angular/material'; +import { MatIconModule, MatInputModule, MatTableModule, MatListModule, MatToolbarModule, MatFormFieldModule, MatTabsModule, MatCardModule, MatPaginatorModule, MatButtonModule, MatExpansionModule, MatProgressBarModule, MatProgressSpinnerModule, MatDatepickerModule, MatSelectModule } from '@angular/material'; import { FlexLayoutModule } from '@angular/flex-layout'; import { MatTableExporterModule } from 'mat-table-exporter'; import { ReactiveFormsModule, FormsModule } from '@angular/forms'; @@ -51,6 +51,7 @@ const pdCustomNotifierOptions: NotifierOptions = { imports: [ CommonModule, MatInputModule, + MatSelectModule, MatIconModule, MatTableModule, MatListModule, @@ -72,6 +73,7 @@ const pdCustomNotifierOptions: NotifierOptions = { exports:[ CommonModule, MatInputModule, + MatSelectModule, MatIconModule, MatTableModule, MatListModule, diff --git a/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.html b/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.html new file mode 100644 index 000000000..3afdcd863 --- /dev/null +++ b/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.html @@ -0,0 +1,78 @@ + + + + + + filter_list + + Advanced Filter + + + + + +
+ + + {{status}} + + + + + + + + + + + + + + + + {{pro.abbr}} + + + + + + {{ent.full_name}} + + + + + + + + +
+
+
+ + + + + + +
+ + +
\ No newline at end of file diff --git a/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.scss b/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.spec.ts b/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.spec.ts new file mode 100644 index 000000000..748a0b61a --- /dev/null +++ b/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AdvanceFilterComponent } from './advance-filter.component'; + +describe('AdvanceFilterComponent', () => { + let component: AdvanceFilterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AdvanceFilterComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AdvanceFilterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.ts b/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.ts new file mode 100644 index 000000000..28de34f3f --- /dev/null +++ b/ng6-seed/src/app/sales-pd/sales-pd-list/advance-filter/advance-filter.component.ts @@ -0,0 +1,119 @@ +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { FormGroup, FormBuilder } from '@angular/forms'; +import { PdTrigerService } from 'app/personal-discussion/pd-service/pd-triger.service'; +import { DatePipe } from '@angular/common'; +import { SalesPdService } from 'app/sales-pd/services/sales-pd.service'; + + +@Component({ + selector: 'app-advance-filter', + templateUrl: './advance-filter.component.html', + styleUrls: ['./advance-filter.component.scss'] +}) +export class AdvanceFilterComponent implements OnInit { + searchForm:FormGroup; + todaydate: any; + pdStatus: any=[]; + // pdStatus_all: any=[]; + ENTITY: any =[]; + @Input()drop_down_datas + @Output() filteredlistData = new EventEmitter(); + @Output() resetFilter = new EventEmitter(); + PRODUCTS: any =[]; + xpandStatus:boolean=false; + pipe=new DatePipe('en-US'); + constructor(private _fb:FormBuilder,private _pd:PdTrigerService,private salesPDService:SalesPdService) { + this.todaydate = new Date(); + this.getDropdown(); + } + + ngOnInit() { + this.searchForm=this._fb.group({ + pd_status:[''], + pd_from_date:[''], + pd_to_date:[''], + pd_products:[''], + pd_lender:[''], + pd_applicant_name:[''], + pd_officer:[''], + }) + console.log(this.drop_down_datas) + } + getDropdown(){ + // this._pd.getAllMasterDatas('PDSTATUS').subscribe(res=> + // { + // if(res.dataStatus==true) + // { + // this.pdStatus_all = res.records.filter(status=>status.isactive==1); + // } + // }); + this._pd.getAllMasterDatas('ENTITY').subscribe(res=> + { + if(res.dataStatus==true) + { + this.ENTITY = res.records.filter(ent=>ent.isactive==1); + } + }); + this._pd.getAllMasterDatas('PRODUCTS').subscribe(res=> + { + if(res.dataStatus==true) + { + this.PRODUCTS = res.records.filter(pro=>pro.isactive==1); + } + }); + + } + ngOnChanges(){ + console.log(this.drop_down_datas) + if(this.drop_down_datas != undefined){ + this.pdStatus=this.drop_down_datas.pd_status + if(this.ENTITY.length != 0) { + this.entityCheck() + } + else{ + setTimeout(()=>{this.entityCheck()},500) + } + if(this.PRODUCTS.length != 0) { + this.productCheck() + } + else{ + setTimeout(()=>{this.productCheck()},500) + } + } + } + productCheck(){ + this.PRODUCTS=this.PRODUCTS.filter(val=>{ + if(this.drop_down_datas.product_ids.filter(dp=>dp == val.product_id).length > 0){ + return val + } + }) + } + entityCheck(){ + this.ENTITY=this.ENTITY.filter(val=>{ + if(this.drop_down_datas.lender_ids.filter(dp=>dp == val.entity_id).length > 0){ + return val + } + }) + } + searchItem(){ + this.searchForm.value.pd_from_date = this.pipe.transform(this.searchForm.value.pd_from_date,'yyyy-MM-dd'); + this.searchForm.value.pd_to_date = this.pipe.transform(this.searchForm.value.pd_to_date,'yyyy-MM-dd'); + // console.log(JSON.stringifythis.searchForm.value); + this.xpandStatus=true; + this.salesPDService.advancedFilter(this.searchForm.value).subscribe(res=>{ + if(res.dataStatus){ + console.log(res); + this.filteredlistData.emit(res); + this.xpandStatus=false + } + else{ + this.filteredlistData.emit(res) + } + }) + } + onReset(){ + this.searchForm.reset(); + this.xpandStatus=false + this.resetFilter.emit(true); + } +} diff --git a/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.html b/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.html index 4af6211e4..c592ee3bf 100644 --- a/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.html +++ b/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.html @@ -13,80 +13,14 @@ - + - - - - - - - + + +

Showing data for last 10 days. Showing data for last 10 days. To see older records, please use advanced filter

@@ -152,9 +86,12 @@ - +
- + +
Showing data for last 10 days. To see older records, please use advanced filter
+