login
This commit is contained in:
parent
9a162b1940
commit
9c51abf8ac
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class AppointmentsService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
16
ng-seed/src/app/appoinment/appointment.service.spec.ts
Normal file
16
ng-seed/src/app/appoinment/appointment.service.spec.ts
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
9
ng-seed/src/app/appoinment/appointment.service.ts
Normal file
9
ng-seed/src/app/appoinment/appointment.service.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class AppointmentService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BusinessService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CustomersService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ApiServiceService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
16
ng-seed/src/app/session-services/session.service.spec.ts
Normal file
16
ng-seed/src/app/session-services/session.service.spec.ts
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
25
ng-seed/src/app/session-services/session.service.ts
Normal file
25
ng-seed/src/app/session-services/session.service.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ import { Component, OnInit ,ViewEncapsulation } from '@angular/core';
|
|||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||||
import {Router} from "@angular/router";
|
import {Router} from "@angular/router";
|
||||||
|
import { SessionService } from 'app/session-services/session.service';
|
||||||
import { OtpComponent } from '../otp/otp.component';
|
import { OtpComponent } from '../otp/otp.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -19,7 +20,7 @@ export class LoginComponent {
|
|||||||
dialogRef: MatDialogRef<OtpComponent, any>;
|
dialogRef: MatDialogRef<OtpComponent, any>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router:Router, public dialog: MatDialog) {
|
private router:Router, public dialog: MatDialog,public _ser:SessionService) {
|
||||||
this.loginForm = new FormGroup({
|
this.loginForm = new FormGroup({
|
||||||
email: new FormControl('', [Validators.required, Validators.email,Validators.pattern(
|
email: new FormControl('', [Validators.required, Validators.email,Validators.pattern(
|
||||||
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$',
|
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$',
|
||||||
@ -36,16 +37,21 @@ export class LoginComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(){
|
onSubmit(){
|
||||||
//08/02/2023
|
|
||||||
console.log(this.loginForm.value);
|
console.log(this.loginForm.value);
|
||||||
localStorage.setItem('email',JSON.stringify(this.loginForm.value))
|
const mailid = this.loginForm['value'].email.split(/\s/).join('');
|
||||||
//
|
let auth = { 'email': mailid, 'password': this.loginForm['value'].password};
|
||||||
if(!this.loginForm.valid){
|
localStorage.setItem('email',JSON.stringify(auth))
|
||||||
return;
|
this._ser.getLoginToken(auth).subscribe(res => {
|
||||||
}
|
if (res !== undefined) {
|
||||||
localStorage.setItem('user',this.loginForm.value)
|
localStorage.setItem('user',this.loginForm.value)
|
||||||
this.router.navigate(['/home'])
|
this.router.navigate(['/home'])
|
||||||
}
|
}
|
||||||
|
}, err => {
|
||||||
|
|
||||||
|
//alert(err.message);
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
openDialog(): void {
|
openDialog(): void {
|
||||||
const dialogRef = this.dialog.open(OtpComponent, {
|
const dialogRef = this.dialog.open(OtpComponent, {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: true
|
production: true,
|
||||||
|
environmentName: 'Production Environment',//Localhost Environment.
|
||||||
|
apiEndpoint:'http://venbainfotech.com:5000/',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,5 +4,7 @@
|
|||||||
// The list of which env maps to which file can be found in `angular-cli.json`.
|
// The list of which env maps to which file can be found in `angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false
|
production: false,
|
||||||
|
environmentName: 'Testing Environment',//Localhost Environment.
|
||||||
|
apiEndpoint:'http://venbainfotech.com:5000/',
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user