unblockuser.component.ts
4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { Component, OnInit, AfterViewInit, ViewChild, TemplateRef } 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 { GlobalService } 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';
import { LoadingService } from '../../shared/loading.service';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
@Component({
templateUrl:'./unblockuser.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html'
})
export class UnblockUser implements OnInit {
modalTitle: string;
UnBlockedUserFrm: FormGroup;
alerts: string;
public UserTypeList: any;
public AccountTypeList: any;
public UserList: any;
error;
modalRef: BsModalRef;
checkedRecords: Array<number>;
display = 'none';
modalAlerts: string;
//@ViewChild("profileModal")
//profileModal: ModalComponent;
//errorMessage: any;
constructor(private _loadingService: LoadingService,private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http,
private _confirmService: ConfirmService, private modalService: BsModalService, private commonService: GlobalService
) { }
ngOnInit(): void {
this.alerts = '';
//this.userservice.GetUserById(this.UserId);
this.UnBlockedUserFrm = this.fb.group({
//FirstName:[''],
//LastName: [''],
//EmailId: [''],
//AccountNumber: [''],
//UserTypeId: [''],
//AccountTypeId:['']
// Gender: ['', Validators.required],
// Email: ['']
}); this._loadingService.ShowLoading("global-loading");
this.GetBlockUserList();
//this.GetAccountType();
this._loadingService.HideLoading("global-loading");
//this.GetUserList();
}
redirect() {
this.router.navigate(['/']);
}
onChange(Idx: number, Id: number, isChecked: boolean) {
debugger;
if (isChecked) {
this.checkedRecords[Idx] = Id;
}
else {
this.checkedRecords[Idx] = 0;
}
}
openModal(template: TemplateRef<any>) {
debugger;
this.display = 'block';
if (this.checkedRecords.filter(C => C > 0).length == 0) return;
this.modalRef = this.modalService.show(template);
}
UpdateUnBlockedUsers(template: TemplateRef<any>) {
this.modalRef.hide();
console.log(this.checkedRecords);
this.alerts = '';
if (this.alerts == '') {
var obj = this.checkedRecords.filter(C => C > 0);
return this.userservice.UpdateUnBlockedUser(obj)
.subscribe(
data => (this.AfterDeleteData(data, template)),
error => {
this.error = <any>error;
this.alerts = "<span>" + this.error + "</span>";
});
}
}
AfterDeleteData(data, template) {
debugger;
if (data.Status == "false") {
this._confirmService.activate("We have encountered a technical error and same has been notified to our technical team.", "alertMsg");
} else {
//this.modalAlerts = "<p>Selected users has been unblocked now</p>";
//this.modalRef = this.modalService.show(template);
this.GetBlockUserList();
}
}
GetBlockUserList(this)
{
var UserFilterControl = this.UnBlockedUserFrm.value;
this.userservice.GetBlockUserList(
{
UserTypeId: this.commonService.UserType,
LicenseId: 0,
})
.subscribe(x => { this.UserList = x; this.checkedRecords = new Array<number>(this.UserList.length);}, error => this.error = <any>error);
}
AfterInsertData(data) {
if (data == "success") {
this._confirmService.activate("Userid Updated Successfully.", "alertMsg");
} else {
this.alerts += '<span>' + data+'</span>';
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 = '';
}
}