diff options
author | Rachitha Ramappa <rachitha.ramappa@att.com> | 2020-05-14 18:33:19 +0530 |
---|---|---|
committer | Sunder Tattavarada <statta@research.att.com> | 2020-05-19 15:51:20 +0000 |
commit | a942e5cdc2998560a2810d4eec028301339623b5 (patch) | |
tree | a9ea8f7f5248a5a559fdb05e57f56e0bbfc83a3c /portal-FE-os/src/app/pages | |
parent | 8e3d0ff5ce27cd87a257a2a95430add3dd3596ce (diff) |
Change-Id: I7578f95d0e4f91d8499e9c973fc5bfc5a2e45e27
Issue-ID: PORTAL-867
Signed-off-by: rachitha.ramappa@att.com
Diffstat (limited to 'portal-FE-os/src/app/pages')
-rw-r--r-- | portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html | 2 | ||||
-rw-r--r-- | portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts | 22 |
2 files changed, 18 insertions, 6 deletions
diff --git a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html index 7fc35e44..bd9d69b6 100644 --- a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html +++ b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.html @@ -113,6 +113,6 @@ </form> </div> <div class="modal-footer"> - <button type="submit" class="btn btn-primary" (click)="addUser()" [disabled]="addNewUserForm.invalid">Next</button> + <button type="submit" class="btn btn-primary" (click)="addUser()">Next</button> <button type="button" class="btn btn-primary" aria-label="Close" (click)="activeModal.dismiss('Cross')">Close</button> </div> diff --git a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts index bea0fcdb..33d2b331 100644 --- a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts +++ b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.ts @@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MustMatch } from 'src/app/shared/helpers/must-match-validator'; import { UsersService } from 'src/app/shared/services'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; @Component({ selector: 'app-user-details-form', @@ -13,9 +14,10 @@ export class UserDetailsFormComponent implements OnInit { addNewUserForm: FormGroup; submitted = false; - constructor(private formBuilder: FormBuilder, + constructor(private formBuilder: FormBuilder, private usersService: UsersService, - public activeModal: NgbActiveModal) { } + public activeModal: NgbActiveModal, + public ngbModal: NgbModal) { } ngOnInit() { this.addNewUserForm = this.formBuilder.group({ @@ -24,7 +26,7 @@ export class UserDetailsFormComponent implements OnInit { lastName: ['', Validators.required], email: ['', [Validators.required, Validators.email]], loginId: ['', Validators.required], - loginPwd: ['', [Validators.required, Validators.minLength(6)]], + loginPwd: ['', Validators.required], confirmPassword: ['', Validators.required] }, { validator: MustMatch('loginPwd', 'confirmPassword') @@ -44,7 +46,17 @@ export class UserDetailsFormComponent implements OnInit { console.log("New user Json : " + JSON.stringify(this.addNewUserForm.value)); console.log("Get Raw value : " + this.addNewUserForm.getRawValue()); let newUserFormData = JSON.stringify(this.addNewUserForm.getRawValue()); - this.usersService.addNewUser(newUserFormData); + this.usersService.addNewUser(newUserFormData).subscribe(result => { + console.log("Result : ", result); + const modalSuccess = this.ngbModal.open(ConfirmationModalComponent); + modalSuccess.componentInstance.title = "Success"; + modalSuccess.componentInstance.message = 'User added Successfully!'; + }, error => { + console.log("Error : ", error); + const modalErrorRef = this.ngbModal.open(ConfirmationModalComponent); + modalErrorRef.componentInstance.title = "Error"; + modalErrorRef.componentInstance.message = 'Something went wrong. Error Message: ' + error.message; + }) this.activeModal.close(); } |