updateuserprofile.component.js
6.97 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var user_service_1 = require("../UserEntity/user.service");
var router_1 = require("@angular/router");
var forms_1 = require("@angular/forms");
var datamodel_1 = require("../UserEntity/datamodel");
var http_1 = require("@angular/http");
var confirm_service_1 = require("../../Shared/Confirm/confirm.service");
require("rxjs/Rx");
require("rxjs/add/operator/map");
require("rxjs/add/operator/filter");
var UpdateUserProfile = /** @class */ (function () {
//@ViewChild("profileModal")
//profileModal: ModalComponent;
//errorMessage: any;
function UpdateUserProfile(userservice, router, fb, http, _confirmService) {
this.userservice = userservice;
this.router = router;
this.fb = fb;
this.http = http;
this._confirmService = _confirmService;
this.UserId = 1;
this.indLoading = false;
this.baseUrl = "User";
this.emailPattern = "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$";
//extractData(res: Response) {
// //debugger;
// let body = res.json();
// return body;
//}
//handleError(error: any) {
// // In a real world app, we might use a remote logging infrastructure
// // We'd also dig deeper into the error to get a better message
// let errMsg = (error.message) ? error.message :
// error.status ? `${error.status} - ${error.statusText}` : 'Server error';
// console.error(errMsg); // log to console instead
// return Observable.throw(errMsg);
//}
this.validationMessages = {
'firstName': {
'required': 'First name is required.'
},
'lastName': {
'required': 'Last name is required.'
},
'email': {
'required': 'Email is required.',
'pattern': 'Email pattern is not valid.'
}
};
}
UpdateUserProfile.prototype.ngOnInit = function () {
this.user = new datamodel_1.User();
this.alerts = '';
//this.userservice.GetUserById(this.UserId);
this.userFrm = this.fb.group({
id: [''],
firstName: ['', forms_1.Validators.required],
lastName: ['', forms_1.Validators.required],
emailId: ['', forms_1.Validators.required]
// LastName: [''],
// Gender: ['', Validators.required],
// Email: ['']
});
this.GetUserById();
};
//ngAfterviewint() {
// this.LoadUsers();
//}
//getCustomerById(UserId) {
// return this.userservice.GetUserById(UserId)
// .map((response: Response) => response.json())
// .catch(this._errorHandler)
//}
//formErrors = {
// 'firstName': '',
// 'lastName': '',
// 'email': ''
//};
UpdateUserProfile.prototype.GetUserById = function () {
var _this = this;
this.userservice.GetUserById()
.subscribe(function (x) { console.log(x); _this.bindUsers(x); }, function (error) { return _this.error = error; });
};
UpdateUserProfile.prototype.UpdateUserProfile = function () {
var _this = this;
// debugger;
this.user = this.userFrm.value;
//if(this.user.)
//console.log(this.user);
var obj = this.user;
if (this.userFrm.valid) {
return this.userservice.UpdateUserProfileById(obj)
.subscribe(function (n) { return (_this.AfterInsertData(n)); }, function (error) { return _this.error = error; });
}
};
UpdateUserProfile.prototype.AfterInsertData = function (data) {
//debugger;
if (data.Status == "False") {
// this._confirmService.activate(data.ResponseMessage, "alertMsg");
//setTimeout(() => this.amCode.nativeElement.focus(), 0);
// this.closeflag = false;
return false;
}
else {
this.status = true;
this._confirmService.activate("User Profile Updated Successfully.", "alertMsg");
//this.profileModal.open();
// this.submitted = false;
// this.GetAllAcctMgr();
// this.DisableAllControls();
// this.AccountManagerID.enable();
// let accountManagerID: string = data.Id == null ? "" : data.Id.toString();
// console.log(accountManagerID);
// this.GetAcctMgr(Number(accountManagerID));
//this.GetAccountManagerListOptions(false);
// this.defautValue = data.id;
// this.BtnReset = true;
// this.BtnSave = true;
// this.BtnEdit = false;
// this.BtnNew = false;
// this.BtnDelete = false;
// this.Abbrevtion = this.Abbrev.value;
// setTimeout(() => this.AMform.controls["AccountManagerID"].setValue(accountManagerID.toString()), 1000);
// setTimeout(() => this.AMform.markAsPristine(), 2000);
}
//if (this.closeflag) {
// this.close.emit(null);
//}
//else {
//}
};
UpdateUserProfile.prototype.bindUsers = function (data) {
//console.log(data);
//alert(JSON.stringify(data));
this.user = data[0];
console.log(this.user);
this.userFrm.controls['id'].setValue(this.user.Id);
this.userFrm.controls['firstName'].setValue(this.user.FirstName);
this.userFrm.controls['lastName'].setValue(this.user.LastName);
this.userFrm.controls['emailId'].setValue(this.user.EmailId);
// this.GetClientListOptions(false);
// this.GetCrossRefClientListOptions(false);
};
UpdateUserProfile = __decorate([
core_1.Component({
templateUrl: './updateuserprofile.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html'
}),
__metadata("design:paramtypes", [user_service_1.UserService, router_1.Router, forms_1.FormBuilder, http_1.Http,
confirm_service_1.ConfirmService])
], UpdateUserProfile);
return UpdateUserProfile;
}());
exports.UpdateUserProfile = UpdateUserProfile;
//# sourceMappingURL=updateuserprofile.component.js.map