"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("../UpdateProfile/user.service"); var router_1 = require("@angular/router"); var forms_1 = require("@angular/forms"); var datamodel_1 = require("../UpdateProfile/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; debugger; 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) { debugger; //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