Guest User

Untitled

a guest
Jan 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.28 KB | None | 0 0
  1. eval("/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return UserProfileComponent; });n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_forms__ = __webpack_require__("../../../forms/esm5/forms.js");n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__angular_material__ = __webpack_require__("../../../material/esm5/material.es5.js");n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__service_user_service__ = __webpack_require__("../../../../../src/app/service/user.service.ts");nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {rn var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;rn if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);rn 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;rn return c > 3 && r && Object.defineProperty(target, key, r), r;rn};rnvar __metadata = (this && this.__metadata) || function (k, v) {rn if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);rn};rnvar __param = (this && this.__param) || function (paramIndex, decorator) {rn return function (target, key) { decorator(target, key, paramIndex); }rn};rnrnrnrnrnvar UserProfileComponent = (function () {rn function UserProfileComponent(data, fb, userService) {rn this.data = data;rn this.fb = fb;rn this.userService = userService;rn this.submitted = false;rn this.editMode = false;rn this.submitDisabled = true;rn }rn UserProfileComponent.prototype.ngOnInit = function () {rn var _this = this;rn this.user = this.data;rn this.buildForm();rn this.userProfileChanges = this.userProfile.valueChanges.subscribe(function (form) {rn _this.submitDisabled = !_this.userProfileForm.form.valid;rn });rn };rn UserProfileComponent.prototype.buildForm = function () {rn this.userProfile = this.fb.group({rn login: this.fb.group({rn id: [this.user.id],rn alias: [this.user.alias, [rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].required,rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].minLength(3),rn this.nosSpaceValidatorrn ]],rn passwords: this.fb.group({rn password: ['test123AAA', [rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].required,rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].minLength(10),rn this.passwordValidator()rn ]],rn passwordrepeat: ['test123AAA', [rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].requiredrn ]],rn }, { validator: this.matchPassword }),rn emailsList: [false],rn email: [this.user.email, [rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].required,rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].emailrn ]]rn }),rn personal: this.fb.group({rn title: [this.user.title],rn name: [this.user.name, [rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].required,rn this.nosSpaceValidatorrn ]],rn forename: [this.user.forename, [rn __WEBPACK_IMPORTED_MODULE_1__angular_forms__["l" /* Validators */].required,rn this.nosSpaceValidatorrn ]],rn company: [this.user.company],rn department: [this.user.department],rn street: [this.user.street],rn zipCode: [this.user.zipCode],rn city: [this.user.city],rn deleted: [this.user.deleted]rn }),rn accounting: this.fb.group({rn personalnumber: [this.user.personalnumber],rn costPerHour: [this.user.costPerHour]rn })rn });rn };rn UserProfileComponent.prototype.nosSpaceValidator = function (control) {rn return control.value && control.value.replace(/ /g, '').length === 0 ? { 'noSpace': true } : null;rn };rn UserProfileComponent.prototype.matchPassword = function (groupControl) {rn var password = groupControl.get('password').value;rn var passwordrepeat = groupControl.get('passwordrepeat').value;rn return password !== passwordrepeat ? { 'notMatches': { passwordrepeat: passwordrepeat } } : null;rn };rn /**rn * cancel changesrn */rn UserProfileComponent.prototype.resetUserProfileForm = function () {rn // this.user = this.userService.getUser(1);rn this.userProfile.reset({rn login: {rn alias: this.user.alias,rn passwords: {rn password: this.user.password,rn passwordrepeat: this.user.password,rn },rn email: this.user.emailrn },rn personal: {rn title: this.user.title,rn name: this.user.name,rn forename: this.user.forename,rn company: this.user.company,rn department: this.user.department,rn street: this.user.street,rn zipCode: this.user.zipCode,rn city: this.user.city,rn deleted: this.user.deletedrn },rn accounting: {rn personalnumber: this.user.personalnumber,rn costPerHour: this.user.costPerHourrn }rn });rn this.changeEditMode();rn this.submitDisabled = true;rn };rn UserProfileComponent.prototype.changeEditMode = function () {rn this.editMode = !this.editMode;rn };rn UserProfileComponent.prototype.passwordValidator = function () {rn var _this = this;rn return function (control) {rn var password = typeof control.value === 'string' ? control.value : control.value[0];rn var containName = false;rn var criteria = 0;rn if (password.toUpperCase() != password) {rn // has lower case lettersrn criteria++;rn }rn if (password.toLowerCase() != password) {rn // has upper case lettersrn criteria++;rn }rn if (/^[a-zA-Z0-9]*$/.test(password) === false) {rn // has special charactersrn criteria++;rn }rn if (/\d/.test(password) === true) {rn // has numbersrn criteria++;rn }rn if (_this.userProfileForm.value && (password.includes(_this.userProfileForm.value.login.alias) ||rn password.includes(_this.userProfileForm.value.personal.name) ||rn password.includes(_this.userProfileForm.value.personal.forename))) {rn // can’t contain the user name or parts of the user’s full namern containName = true;rn }rn return (criteria >= 3 && password.length >= 10 && !containName) ? null : { 'passwordRules': { password: password } };rn };rn };rn UserProfileComponent.prototype.onSubmit = function (_a) {rn var value = _a.value, valid = _a.valid;rn this.submitted = true;rn for (var formKey in value) {rn if (value[formKey]) {rn for (var key in value[formKey]) {rn if (key === 'passwords') {rn // this.user['password'] = sha256(value[formKey][key]['password']);rn }rn else {rn this.user[key] = value[formKey][key];rn }rn }rn }rn }rn // this.userService.updateUserData(this.user).then(function () {rn this.editMode = !this.editMode;rn // }.bind(this));rn };rn UserProfileComponent.prototype.updateUserProfilePhoto = function ($event) {rn var files = $event.target.files || $event.srcElement.files;rn var file = files[0];rn var formData = new FormData();rn formData.append('file', file);rn // this.userService.updateUserPhoto(formData);rn };rn // unsubscribe from listenersrn UserProfileComponent.prototype.ngOnDestroy = function () {rn if (this.userProfileChanges) {rn this.userProfileChanges.unsubscribe();rn }rn };rn __decorate([rn Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewChild"])('userProfileForm'),rn __metadata("design:type", Object)rn ], UserProfileComponent.prototype, "userProfileForm", void 0);rn UserProfileComponent = __decorate([rn Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({rn selector: 'app-user-profile',rn template: 'passed in {{ data }}',rn template: __webpack_require__("../../../../../src/app/component/header/user-profile/user-profile.component.html"),rn styles: [__webpack_require__("../../../../../src/app/component/header/user-profile/user-profile.component.scss")],rn encapsulation: __WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewEncapsulation"].None,rn }),rn __param(0, Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Inject"])(__WEBPACK_IMPORTED_MODULE_2__angular_material__["a" /* MAT_DIALOG_DATA */])),rn __metadata("design:paramtypes", [Object, __WEBPACK_IMPORTED_MODULE_1__angular_forms__["b" /* FormBuilder */],rn __WEBPACK_IMPORTED_MODULE_3__service_user_service__["a" /* UserService */]])rn ], UserProfileComponent);rn return UserProfileComponent;rn}());rnrn//# sourceURL=[module]n//# sourceMappingURL=data:application/json;charset=utf-8;base64,
Add Comment
Please, Sign In to add comment