login issue fix

This commit is contained in:
surendar.m@watermelon.us 2023-03-08 13:28:29 +05:30
parent ac1402df52
commit 40fb087f98
10 changed files with 87 additions and 37 deletions

View File

@ -18,12 +18,17 @@ export class TokenInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// 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);
}

View File

@ -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

View File

@ -27,6 +27,9 @@ import { ConsultantsModule } from './consultants/consultants.module';
ServiceListModule,
ConsultantsModule
],
providers:[
]
})
export class AppoinmentModule { }

View File

@ -12,7 +12,7 @@
<mat-expansion-panel>
<mat-expansion-panel-header >
<div class="example-container mat-elevation-z8 ">
<table mat-table [dataSource]="dataSource" #mytable class="my-table mat-elevation-z8 len-table">
<table mat-table [dataSource]="businessList" #mytable class="my-table mat-elevation-z8 len-table">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef class="font-color"> S.NO </th>
@ -26,7 +26,7 @@
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef class="font-color"> Name </th>
<td mat-cell *matCellDef="let element" class="element-spc"> {{element.name}} </td>
<td mat-cell *matCellDef="let element" class="element-spc"> {{element.busName}} </td>
</ng-container>
<ng-container matColumnDef="email">
@ -36,7 +36,7 @@
<ng-container matColumnDef="phone">
<th mat-header-cell *matHeaderCellDef class="font-color"> Phone </th>
<td mat-cell *matCellDef="let element"> {{element.phone}} </td>
<td mat-cell *matCellDef="let element"> {{element.contactNo}} </td>
</ng-container>
<ng-container matColumnDef="address">
@ -44,7 +44,7 @@
<td mat-cell *matCellDef="let element"> {{element.address}} <br> {{element.city}} <br> {{element.state}} </td>
</ng-container>
<ng-container matColumnDef="state">
<!-- <ng-container matColumnDef="state">
<th mat-header-cell *matHeaderCellDef class="font-color"> State </th>
<td mat-cell *matCellDef="let element"> {{element.state}} </td>
</ng-container>
@ -52,7 +52,7 @@
<ng-container matColumnDef="city">
<th mat-header-cell *matHeaderCellDef class="font-color"> City </th>
<td mat-cell *matCellDef="let element"> {{element.city}} </td>
</ng-container>
</ng-container> -->
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef class="font-color"> Action </th>

View File

@ -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<any>;
@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 = <any> 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)
}
}

View File

@ -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<any>{
return this._http.get<any[]>(this.apiUrl + "businessDetailList")
.pipe(
catchError(this.handleError('role', []))
)
}
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);
}
}
constructor() { }
}

View File

@ -1,5 +1,5 @@
<ng-scrollbar class="scrollHV">
<div fxLayout="row wrap" >
<div fxLayout="row wrap mt-2 mb-2">
<div fxFlex.xs="100" fxFlex.sm="50" fxFlex.md="50" fxFlex.lg="33.33" fxFlex.xl="33.33" class="m-gap p-gap" *ngFor="let consultant of consultants">
<div class="consultant-list-card">
<div class="consultant-content">

View File

@ -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;

View File

@ -44,16 +44,16 @@ export class CustomersListComponent implements OnInit {
@ViewChild(MatTable,{static:true}) table: MatTable<any>;
@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 = <any> 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.!');

View File

@ -13,14 +13,9 @@ export class SessionService {
getLoginToken(params): Observable<any> {
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<any>(this.apiUrl + "login",{'email':params.email,'password':params.password})
// return this._http.post(this.apiUrl + 'login', {'email':params.email,'password':params.password})
}
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);
}
}
}