From 40fb087f98d2001ccf517dd853d10a87a92545ea Mon Sep 17 00:00:00 2001 From: "surendar.m@watermelon.us" Date: Wed, 8 Mar 2023 13:28:29 +0530 Subject: [PATCH] login issue fix --- ng-seed/src/app/_guard/token.interceptor.ts | 17 +++++--- ng-seed/src/app/app.module.ts | 4 ++ .../src/app/appoinment/appoinment.module.ts | 3 ++ .../business-list.component.html | 10 ++--- .../business-list/business-list.component.ts | 40 +++++++++++++++---- .../business-service/business.service.ts | 22 +++++++++- .../consultants-list.component.html | 2 +- .../consultants-list.component.scss | 2 +- .../customers-list.component.ts | 11 +++-- .../app/session-services/session.service.ts | 13 ++---- 10 files changed, 87 insertions(+), 37 deletions(-) diff --git a/ng-seed/src/app/_guard/token.interceptor.ts b/ng-seed/src/app/_guard/token.interceptor.ts index a24cb01..aa16438 100644 --- a/ng-seed/src/app/_guard/token.interceptor.ts +++ b/ng-seed/src/app/_guard/token.interceptor.ts @@ -18,12 +18,17 @@ export class TokenInterceptor implements HttpInterceptor { intercept(req: HttpRequest, next: HttpHandler): Observable> { // const tokenUrl = 'http://example.com/token'; // replace with your token url - const token = localStorage.getItem('user_token'); // get the token from local storage - const authReq = req.clone({ - headers: req.headers.set('x-access-token', token).set('Content-Type', 'application/json') - }); - - + const token = localStorage.getItem('user_token'); + let authReq:any; // get the token from local storage + if(token != '' && token != undefined && token != null){ + authReq = req.clone({ + headers: req.headers.set('x-access-token', token).set('Content-Type', 'application/json') + }); + }else{ + authReq = req; + } + + return next.handle(authReq); } diff --git a/ng-seed/src/app/app.module.ts b/ng-seed/src/app/app.module.ts index ca70440..1564658 100644 --- a/ng-seed/src/app/app.module.ts +++ b/ng-seed/src/app/app.module.ts @@ -35,6 +35,8 @@ import { ProgressSpineerDialogComponent } from './shared/progress-spineer-dialog import { AppoinmentModule } from './appoinment/appoinment.module'; import { MatFormFieldModule } from '@angular/material/form-field'; import { TokenInterceptor } from './_guard/token.interceptor'; +import { SessionService } from './session-services/session.service'; +import { AppointmentService } from './appoinment/appointment.service'; export function HttpLoaderFactory(http: HttpClient) { @@ -87,6 +89,8 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { ], providers: [ TranslateService, + SessionService, + AppointmentService, { provide: PERFECT_SCROLLBAR_CONFIG, useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG diff --git a/ng-seed/src/app/appoinment/appoinment.module.ts b/ng-seed/src/app/appoinment/appoinment.module.ts index d4d5af0..6dcbaaf 100644 --- a/ng-seed/src/app/appoinment/appoinment.module.ts +++ b/ng-seed/src/app/appoinment/appoinment.module.ts @@ -27,6 +27,9 @@ import { ConsultantsModule } from './consultants/consultants.module'; ServiceListModule, ConsultantsModule ], + providers:[ + + ] }) export class AppoinmentModule { } diff --git a/ng-seed/src/app/appoinment/business/business-list/business-list.component.html b/ng-seed/src/app/appoinment/business/business-list/business-list.component.html index c6a7b2d..00adb1d 100644 --- a/ng-seed/src/app/appoinment/business/business-list/business-list.component.html +++ b/ng-seed/src/app/appoinment/business/business-list/business-list.component.html @@ -12,7 +12,7 @@
- +
@@ -26,7 +26,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts b/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts index f0d9ec2..c309a98 100644 --- a/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts +++ b/ng-seed/src/app/appoinment/business/business-list/business-list.component.ts @@ -4,6 +4,7 @@ import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { MatTable, MatTableDataSource } from '@angular/material/table'; import Swal from 'sweetalert2/dist/sweetalert2.js'; +import { BusinessService } from '../business-service/business.service'; import { DialogBoxComponent } from '../dialog-box/dialog-box.component'; export interface UsersData { @@ -41,18 +42,44 @@ export class BusinessListComponent implements OnInit { // dataSource: any = new MatTableDataSource(ELEMENT_DATA); @ViewChild(MatTable,{static:true}) table: MatTable; @ViewChild(MatPaginator) paginator: MatPaginator; + businessList: any; + + + constructor(public dialog: MatDialog,public _bus:BusinessService) {} + + ngOnInit(): void { + this.dataSource = new MatTableDataSource(ELEMENT_DATA) + this.getBusinessList() + } + + getBusinessList() { + //this._pd.getTabStatusPdDetails(this.tabStatus) + this._bus.getBusinessListDetails().subscribe(res => { + if (res.status == 200) { + this.businessList = res.data; + } + else{ + + } + } + // , error => {this.errorMessage = error}); + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); + }) + } ngAfterViewInit() { - this.dataSource.paginator = this.paginator; + this.businessList.paginator = this.paginator; } applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; - this.dataSource.filter = filterValue.trim().toLowerCase(); - if (this.dataSource.paginator) { - this.dataSource.paginator.firstPage(); + this.businessList.filter = filterValue.trim().toLowerCase(); + if (this.businessList.paginator) { + this.businessList.paginator.firstPage(); } } - constructor(public dialog: MatDialog) { } confirmBox(name,element){ console.log(name,element) @@ -140,8 +167,5 @@ export class BusinessListComponent implements OnInit { }); console.log(this.dataSource) } - ngOnInit(): void { - this.dataSource = new MatTableDataSource(ELEMENT_DATA) - } } diff --git a/ng-seed/src/app/appoinment/business/business-service/business.service.ts b/ng-seed/src/app/appoinment/business/business-service/business.service.ts index fb6c36e..a3b70d8 100644 --- a/ng-seed/src/app/appoinment/business/business-service/business.service.ts +++ b/ng-seed/src/app/appoinment/business/business-service/business.service.ts @@ -1,9 +1,29 @@ +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; +import { Observable, of } from 'rxjs'; +import { catchError } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class BusinessService { + private apiUrl = environment.apiEndpoint; + + constructor(private _http: HttpClient) { } + + getBusinessListDetails(): Observable{ + return this._http.get(this.apiUrl + "businessDetailList") + .pipe( + catchError(this.handleError('role', [])) + ) + } + + private handleError(operation = 'operation', result?: T) { + return (error: any): Observable => { + return of(result as T); + } + } + - constructor() { } } diff --git a/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.html b/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.html index 30d616e..51d21e5 100644 --- a/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.html +++ b/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.html @@ -1,5 +1,5 @@ -
+
diff --git a/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.scss b/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.scss index d8bd382..b053d91 100644 --- a/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.scss +++ b/ng-seed/src/app/appoinment/consultants/consultants-list/consultants-list.component.scss @@ -10,7 +10,7 @@ $black_60: rgba(0, 0, 0, 0.6); padding-bottom: 4rem; } .scrollHV { - height: calc(100vh - 410px); + height: calc(100vh - 105px); } .consultant-list-card { background: $white; diff --git a/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts b/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts index 9d2c3ea..e836fc7 100644 --- a/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts +++ b/ng-seed/src/app/appoinment/customers/customers-list/customers-list.component.ts @@ -44,16 +44,16 @@ export class CustomersListComponent implements OnInit { @ViewChild(MatTable,{static:true}) table: MatTable; @ViewChild(MatPaginator) paginator: MatPaginator; recordStatus: boolean; - length = 5; - pageIndex = 0; - pageSize = 10; - pageEvent: PageEvent; + // length = 5; + // pageIndex = 0; + // pageSize = 10; + // pageEvent: PageEvent; addFormData: any; constructor(public dialog: MatDialog,public _cus:CustomersService) { } ngOnInit(): void { - console.log('IN') + // console.log('IN') // this.dataSource = new MatTableDataSource(ELEMENT_DATA) this.getCustomersList() } @@ -76,7 +76,6 @@ export class CustomersListComponent implements OnInit { // this.recordStatus=true; } } - // , error => {this.errorMessage = error}); ,error => { // this.errorMessage.push(error); // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); diff --git a/ng-seed/src/app/session-services/session.service.ts b/ng-seed/src/app/session-services/session.service.ts index 53d8d0b..931fece 100644 --- a/ng-seed/src/app/session-services/session.service.ts +++ b/ng-seed/src/app/session-services/session.service.ts @@ -13,14 +13,9 @@ export class SessionService { getLoginToken(params): Observable { console.log(params.email) - return this._http.post(this.apiUrl + 'login', {'email':params.email,'password':params.password}) - .pipe( - catchError(this.handleError('role', [])) - ) + return this._http.post(this.apiUrl + "login",{'email':params.email,'password':params.password}) + // return this._http.post(this.apiUrl + 'login', {'email':params.email,'password':params.password}) + } - private handleError(operation = 'operation', result?: T) { - return (error: any): Observable => { - return of(result as T); - } - } + }
S.NO Name {{element.name}} {{element.busName}} Phone {{element.phone}} {{element.contactNo}} {{element.address}}
{{element.city}}
{{element.state}}
Action