NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


<body style="background-color: #fff;" class="w3-animate-right">
<div class="container" >
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="text-center">,
<h1>Login</h1>
<h6 style="color: #ffffff;">Please enter your details !!</h6>
</div>
<form [formGroup]="loginForm" (ngSubmit)="login()">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<p [ngClass]="{'is-invalid': isSubmitted && formControls['Mail'].errors}">
<input type="email" class="form-control" placeholder="Enter your Email id" formControlName="Mail">
</p>
<div *ngIf="isSubmitted && formControls['Mail'].errors" class="help-block">
<div *ngIf="formControls['Mail'].errors['required']" style="color: red;"> *Email is required</div>
</div>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<p [ngClass]="{'is-invalid': isSubmitted && formControls['Password'].errors}">
<input type="password" class="form-control" placeholder="Enter your Password" formControlName="Password">
</p>
<div *ngIf="isSubmitted && formControls['Password'].errors" class="help-block">
<div *ngIf="formControls['Password'].errors['required']" style="color: red;"> *Password is required</div>
</div>
</div>
<div class="form-group">
<label for="exampleInputRole">Role</label>
<p [ngClass]="{'is-invalid': isSubmitted && formControls['Role'].errors}">
<select class="exampleInputRole form-control" id="exampleInputRole" placeholder="Choose your Role" formControlName="Role">
<option value="admin" type="text">Admin</option>
<option value="employee" type="text">Employee</option>
</select>
</p>
<div *ngIf="isSubmitted && formControls['Role'].errors" class="help-block">
<div *ngIf="formControls['Role'].errors['required']" style="color: red;"> *Role is required</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Login</button>

</form>
<br><a routerLink="/signup">New User ? Click here to register !!</a>
</div>
</div>
</div>
</div>

<div class="text-center p-4" id="XYZ">
© 2022 Copyright :
<a class="text fw-bold" style="color: #ffffff; text-decoration: none;">CTS &nbsp; DX050 &nbsp; Team 4 </a>
</div>
</body>


ts
import { Component, OnInit } from '@angular/core';
import { FormBuilder , FormGroup,Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';

@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {

public loginForm !: FormGroup
isSubmitted = false;
constructor( private formBuilder : FormBuilder , private http : HttpClient , private router : Router) { }

ngOnInit(): void {

this.loginForm = this.formBuilder.group({
Mail:['',Validators.required],
Password:['',Validators.required],
Role:['',Validators.required]

})
}
get formControls()
{
return this.loginForm.controls;
}

login()
{
console.log(this.loginForm.value);
this.isSubmitted = true;
if(this.loginForm.invalid)
{
return;
}
this.http.get<any>("http://localhost:9083/api/User").subscribe(res=>{
const user = res.find((a:any)=>{
return a.Mail === this.loginForm.value.Mail && a.Password === this.loginForm.value.Password && a.Role === this.loginForm.value.Role
});
if(user && this.loginForm.value.Role == 'admin')
{
alert("Login Successfull !!!");
this.loginForm.reset();
this.router.navigate(['admin'])
}
else if(user && this.loginForm.value.Role == 'employee')
{
alert("Login Successfull !!! ");
this.loginForm.reset();
this.router.navigate(['emphome'])
}
else
{
alert("User Not Found !")
}
}, err=>{
alert("Oops.... Something went wrong n"+"Please try again ")
})


}

}

     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.