import { Component, OnInit, AfterViewInit,ViewChild } from '@angular/core'; import { UserService } from './user.service'; import { Router } from '@angular/router'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { User } from '../UserEntity/datamodel'; import { Http, Response } from '@angular/http'; //import { Global } from '../../Shared/global'; //import { DBOperation } from 'S'; import { Observable } from 'rxjs/Observable'; import { ConfirmService } from '../../Shared/Confirm/confirm.service'; import 'rxjs/Rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; @Component({ templateUrl:'./users.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' }) export class UsersList implements OnInit { modalTitle: string; Users: FormGroup; alerts: string; public UserTypeList: any; public AccountTypeList: any; public UserList: any; error; //@ViewChild("profileModal") //profileModal: ModalComponent; //errorMessage: any; constructor(private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, private _confirmService: ConfirmService ) { } ngOnInit(): void { this.alerts = ''; //this.userservice.GetUserById(this.UserId); this.Users = this.fb.group({ FirstName:[''], LastName: [''], EmailId: [''], AccountNumber: [''], UserTypeId: [''], AccountTypeId:[''] // Gender: ['', Validators.required], // Email: [''] }); this.GetUserType(); this.GetAccountType(); //this.GetUserList(); } redirect() { this.router.navigate(['/']); } GetUserType() { this.userservice.GetUserType().subscribe(x => { this.UserTypeList = x; }, error => this.error = error); } GetAccountType() { this.userservice.GetAccountType().subscribe(x => { this.AccountTypeList = x; }, error => this.error = error); } GetUserList() { //this.userservice.GetUserList().subscribe(x => { this.UserList = x; }, error => this.error = error); } SearchUserList(this) { var UserFilterControl = this.Users.value; this.userservice.GetUserList( { FirstName: this.Users.controls['FirstName'].value, LastName: this.Users.controls['LastName'].value, EmailId: this.Users.controls['EmailId'].value, AccountNumber: this.Users.controls['AccountNumber'].value, UserTypeId: (this.Users.controls['UserTypeId'].value != null && this.Users.controls['UserTypeId'].value !='' ? this.Users.controls['UserTypeId'].value:0), AccountTypeId: (this.Users.controls['AccountTypeId'].value != null && this.Users.controls['AccountTypeId'].value != ''? this.Users.controls['AccountTypeId'].value : 0), }) .subscribe(x => { this.UserList = x; }, error => this.error = error); } AfterInsertData(data) { if (data == "success") { this._confirmService.activate("Userid Updated Successfully.", "alertMsg"); } else { this.alerts += '' + data+''; return false; } //if (this.closeflag) { // this.close.emit(null); //} //else { //} } ResetFormFields() { //this.ChangeUserIdFrm.reset() //this.ChangeUserIdFrm.controls['id'].setValue(this.user.Id) //this.ChangeUserIdFrm.controls['loginid'].setValue(this.user.LoginId) //this.ChangeUserIdFrm.controls['newloginid'].setValue('') //this.ChangeUserIdFrm.controls['confirmloginid'].setValue('') this.alerts = ''; } }