<commit_before>import { Component, OnInit } from '@angular/core';
import { ToasterService } from 'angular2-toaster';

import { AuthService } from '../core/auth/auth.service';
import { UserService } from '../core/user/user.service';
import { User } from '../core/user/user.model';

@Component({
  selector: 'hip-user-profile',
  templateUrl: './app/userprofile/userprofile.component.html',
  styleUrls: ['./app/userprofile/userprofile.component.css']
})
export class ManageUserComponent implements OnInit {
  errorMessage: string = '';
  loggedIn: boolean;
  user = {
    oldPassword: '',
    newPassword: '',
    confirmPass: '',
  };
  private currentUser: User = User.getEmptyUser();

  constructor(private userService: UserService,
              private authService: AuthService,
              private toasterService: ToasterService) {
  }

  formReset() {
    this.user = {
      oldPassword: '',
      newPassword: '',
      confirmPass: ''
    };
    this.errorMessage = '';
  }

  ngOnInit() {
    this.loggedIn = this.authService.isLoggedIn();
    if (this.loggedIn) {
      this.userService.getCurrent().then(
        (data: any) => this.currentUser = <User> data,
        (error: any) => this.errorMessage = <any> error.error
      );
    }
  }

  passwordValid() {
    return this.user.confirmPass.match(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{6,}$/);
  }

  changePassword() {
    this.authService.changePassword(this.user.oldPassword, this.user.newPassword, this.user.confirmPass)
      .then((response: any) => {
        this.toasterService.pop('success', 'Success', response);
        this.formReset();
      })
      .catch((error: any) => {
        try {
          this.errorMessage = error.json()[''];
        } catch (e) {
        }
      });
  }

  updateUserInfo() {
    this.userService.updateUserInfo(this.currentUser.firstName, this.currentUser.lastName)
      .then(response => {
        this.toasterService.pop('success', 'Success', response);
      })
      .catch(error => {
        this.errorMessage = error.error;
      });
  }
}<commit_msg>iss-hipangular-25: broken translations in User profile<commit_after>import { Component, OnInit } from '@angular/core';
import { ToasterService } from 'angular2-toaster';

import { AuthService } from '../core/auth/auth.service';
import { UserService } from '../core/user/user.service';
import { User } from '../core/user/user.model';
import { TranslateService } from 'ng2-translate';

@Component({
  selector: 'hip-user-profile',
  templateUrl: './app/userprofile/userprofile.component.html',
  styleUrls: ['./app/userprofile/userprofile.component.css']
})
export class ManageUserComponent implements OnInit {
  errorMessage: string = '';
  loggedIn: boolean;
  translatedResponse: any;
  getTranslatedData: any;
  user = {
    oldPassword: '',
    newPassword: '',
    confirmPass: '',
  };
  private currentUser: User = User.getEmptyUser();

  constructor(private userService: UserService,
              private authService: AuthService,
              private toasterService: ToasterService,
              private translateService: TranslateService) {
  }

  formReset() {
    this.user = {
      oldPassword: '',
      newPassword: '',
      confirmPass: ''
    };
    this.errorMessage = '';
  }

  ngOnInit() {
    this.loggedIn = this.authService.isLoggedIn();
    if (this.loggedIn) {
      this.userService.getCurrent().then(
        (data: any) => this.currentUser = <User> data,
        (error: any) => this.errorMessage = <any> error.error
      );
    }
  }

  passwordValid() {
    return this.user.confirmPass.match(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{6,}$/);
  }

  changePassword() {
    this.authService.changePassword(this.user.oldPassword, this.user.newPassword, this.user.confirmPass)
      .then((response: any) => {
        this.getTranslatedData = this.translatedData(response);
        this.toasterService.pop('success', 'Success', this.translatedResponse);
        this.formReset();
      })
      .catch((error: any) => {
        try {
          this.errorMessage = error.json()[''];
        } catch (e) {
        }
      });
  }

  updateUserInfo() {
    this.userService.updateUserInfo(this.currentUser.firstName, this.currentUser.lastName)
      .then(response => {
        this.getTranslatedData = this.translatedData(response);
        this.toasterService.pop('success', 'Success', this.translatedResponse);
      })
      .catch(error => {
        this.errorMessage = error.error;
      });
  }

  translatedData(data: any) {
    this.translateService.get(data).subscribe(
      value => {
        this.translatedResponse = value;
      }
    )
    return this.translatedResponse;
  }
}
{'fraction_non_alphanumeric': 0.16561047739754964, 'fraction_numerical': 0.001478664976763836, 'mean_word_length': 2.897119341563786, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3211397', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1474, 'n_words': 240}