This commit is contained in:
surendar.m@watermelon.us 2023-03-04 17:40:58 +05:30
parent 9a162b1940
commit 9c51abf8ac
15 changed files with 189 additions and 13 deletions

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AppointmentsService } from './appointments.service';
describe('AppointmentsService', () => {
let service: AppointmentsService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AppointmentsService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class AppointmentsService {
constructor() { }
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AppointmentService } from './appointment.service';
describe('AppointmentService', () => {
let service: AppointmentService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AppointmentService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class AppointmentService {
constructor() { }
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { BusinessService } from './business.service';
describe('BusinessService', () => {
let service: BusinessService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(BusinessService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class BusinessService {
constructor() { }
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { CustomersService } from './customers.service';
describe('CustomersService', () => {
let service: CustomersService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(CustomersService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class CustomersService {
constructor() { }
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ApiServiceService } from './api-service.service';
describe('ApiServiceService', () => {
let service: ApiServiceService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ApiServiceService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ApiServiceService {
constructor() { }
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { SessionService } from './session.service';
describe('SessionService', () => {
let service: SessionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SessionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,25 @@
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 SessionService {
private apiUrl = environment.apiEndpoint;
constructor(private _http: HttpClient) { }
getLoginToken(params): Observable<any> {
return this._http.post(this.apiUrl + 'login', {params})
.pipe(
catchError(this.handleError('role', []))
)
}
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);
}
}
}

View File

@ -2,6 +2,7 @@ import { Component, OnInit ,ViewEncapsulation } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import {Router} from "@angular/router";
import { SessionService } from 'app/session-services/session.service';
import { OtpComponent } from '../otp/otp.component';
@Component({
@ -19,7 +20,7 @@ export class LoginComponent {
dialogRef: MatDialogRef<OtpComponent, any>;
constructor(
private router:Router, public dialog: MatDialog) {
private router:Router, public dialog: MatDialog,public _ser:SessionService) {
this.loginForm = new FormGroup({
email: new FormControl('', [Validators.required, Validators.email,Validators.pattern(
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$',
@ -35,16 +36,21 @@ export class LoginComponent {
this.hide = true;
}
onSubmit(){
//08/02/2023
console.log(this.loginForm.value);
localStorage.setItem('email',JSON.stringify(this.loginForm.value))
//
if(!this.loginForm.valid){
return;
}
localStorage.setItem('user',this.loginForm.value)
this.router.navigate(['/home'])
onSubmit(){
console.log(this.loginForm.value);
const mailid = this.loginForm['value'].email.split(/\s/).join('');
let auth = { 'email': mailid, 'password': this.loginForm['value'].password};
localStorage.setItem('email',JSON.stringify(auth))
this._ser.getLoginToken(auth).subscribe(res => {
if (res !== undefined) {
localStorage.setItem('user',this.loginForm.value)
this.router.navigate(['/home'])
}
}, err => {
//alert(err.message);
})
}
openDialog(): void {

View File

@ -1,3 +1,5 @@
export const environment = {
production: true
production: true,
environmentName: 'Production Environment',//Localhost Environment.
apiEndpoint:'http://venbainfotech.com:5000/',
};

View File

@ -4,5 +4,7 @@
// The list of which env maps to which file can be found in `angular-cli.json`.
export const environment = {
production: false
production: false,
environmentName: 'Testing Environment',//Localhost Environment.
apiEndpoint:'http://venbainfotech.com:5000/',
};