che-server/dashboard/src/app/profile/profile.controller.ts

49 lines
1.5 KiB
TypeScript

/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {CheKeycloak} from '../../components/api/che-keycloak.factory';
import {CheProfile} from '../../components/api/che-profile.factory';
/**
* This class is handling the controller for the profile page.
*
* @author Anna Shumilova
*/
export class ProfileController {
private profileUrl: string;
private firstName: string;
private lastName: string;
private email: string;
private userName: string;
private $window: ng.IWindowService;
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor(cheKeycloak: CheKeycloak, cheProfile: CheProfile, $window: ng.IWindowService) {
this.$window = $window;
this.profileUrl = cheKeycloak.getProfileUrl();
let profile = cheProfile.getProfile();
this.firstName = <string>profile.attributes['firstName'];
this.lastName = <string>profile.attributes['lastName'];
this.email = profile.email;
this.userName = <string>profile.attributes['preferred_username'];
}
/**
* Edit profile - redirects to proper page.
*/
editProfile(): void {
this.$window.open(this.profileUrl);
}
}