password.component.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import { Component, OnInit } from '@angular/core';
  2. import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';
  3. import { HttpClient } from '@angular/common/http';
  4. import { CommonFunctionService } from '../services/commonfunctions.service';
  5. import { response } from 'express';
  6. import { Router } from '@angular/router';
  7. @Component({
  8. selector: 'dvr-password',
  9. templateUrl: './password.component.html',
  10. styleUrls: ['./password.component.css']
  11. })
  12. export class PasswordComponent implements OnInit {
  13. public passwordForm !: FormGroup;
  14. loginStatus: any;
  15. loginvalidflag: boolean = false;
  16. loginvalidpassword: boolean = false;
  17. validationmsg: any;
  18. validationmsg1: any;
  19. error_msg: any;
  20. success_msg: any;
  21. status_msg: any;
  22. displayStyle = "none";
  23. checkoperationflag: boolean = false;
  24. entry_successflag: boolean = false;
  25. constructor(private router: Router, private commonservice: CommonFunctionService) {
  26. console.log("in password changes");
  27. }
  28. ngOnInit() {
  29. this.passwordForm = new FormGroup({
  30. email: new FormControl(null, Validators.required),
  31. password: new FormControl(null, [Validators.required, Validators.maxLength(8)])
  32. });
  33. }
  34. ngOnChanges() {
  35. console.log("this.passwordForm------>", this.passwordForm);
  36. }
  37. passwordUser(form: FormGroup) {
  38. console.log('Username', form.value.email);
  39. //console.log('password', form.value.password);
  40. const logindata = {
  41. username: form.value.email,
  42. password: form.value.password
  43. }
  44. //console.log("username and password ", logindata);
  45. this.validationmsg = "";
  46. this.validationmsg1 = "";
  47. this.loginvalidflag = false;
  48. this.loginvalidpassword = false;
  49. this.commonservice.getData(this.commonservice.projectpath + "/changepassword", logindata).subscribe(response => {
  50. // console.log("in response", response);
  51. console.log("in response", response);
  52. if (response.data.length == 0) {
  53. //warning
  54. this.openPopup();
  55. this.status_msg = "Warning";
  56. this.error_msg = response.errors;
  57. this.entry_successflag=true;
  58. } else if (response.data.length > 0) {
  59. console.log("inside if(response.message== '') ")
  60. this.openPopup();
  61. this.status_msg = "Success";
  62. this.error_msg = response.data[0].message;
  63. this.checkoperationflag=true;
  64. console.log("error_msg", this.error_msg);
  65. }
  66. else {
  67. this.status_msg = "";
  68. this.error_msg = "";
  69. }
  70. })
  71. }
  72. onCancle() {
  73. console.log("in cancel");
  74. this.validationmsg = "";
  75. }
  76. onKeypressEvent(event: any) {
  77. // console.log("in onkey press",event.target.value);
  78. this.loginvalidflag = false;
  79. }
  80. openPopup() {
  81. this.displayStyle = "block";
  82. }
  83. onKeypressEvent1(event: any) {
  84. // console.log("in onkey press",event.target.value);
  85. this.loginvalidpassword = false;
  86. }
  87. closePopup() {
  88. this.displayStyle = "none";
  89. if (this.checkoperationflag == true) {
  90. this.router.navigate(['/login'])
  91. } else {
  92. if (this.entry_successflag == true) {
  93. window.location.reload();
  94. }
  95. }
  96. }
  97. }