File

src/app/modules/user/home/home.ts

Description

Компонент для просмотра информации о пользователе и его профилях

Implements

OnInit

Metadata

selector user-home
styleUrls home.scss
templateUrl ./home.html

Index

Properties
Methods

Constructor

constructor(userService: UserService, route: ActivatedRoute, router: Router)

Конструктор

Parameters :
Name Type Description
userService UserService
route ActivatedRoute
router Router

Methods

getProfile
getProfile(id: number|)

Получение профиля пользователя

Parameters :
Name Type Description
id number
Returns : void
ngOnInit
ngOnInit()

Получение информации о пользователе

Returns : void

Properties

defaultImage
defaultImage: string
Type : string
Default value : assets/images/default_image.svg

Изображение по-умолчанию

header
header: string
Type : string

Заголовок

user
user: any
Type : any

Данные пользователя

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { UserService } from 'glx.ui/components/kernel/services/user.service';
import 'rxjs/add/operator/switchMap';

/**
 * Компонент для просмотра информации о пользователе и его профилях
 */
@Component({
  selector: 'user-home',
  templateUrl: './home.html',
  styleUrls: ['./home.scss']
})
export class UserHomeComponent implements OnInit {
  /**
   * Данные пользователя
   */
  user: any;
  /**
   * Изображение по-умолчанию
   * @type {string}
   */
  defaultImage: string = 'assets/images/default_image.svg';
  /**
   * Заголовок
   * @type {string}
   */
  header: string = '';

  /**
   * Конструктор
   * @param {UserService} userService
   * @param {ActivatedRoute} route
   * @param {Router} router
   */
  constructor(private userService: UserService, private route: ActivatedRoute, private router: Router) {
  }

  /**
   * Получение информации о пользователе
   */
  ngOnInit() {
    this.route.parent.params.subscribe(params => {
      const id = +params['id'];
      this.getProfile(id);
    });
  }

  /**
   * Получение профиля пользователя
   * @param {number} id
   */
  getProfile(id: number | undefined) {
    this.user = {
      'id': 12750,
      'sync_id': '14268',
      'external_id': '14268',
      'sync_source': 'persons',
      'login': 'gretsova.mv',
      'bitrix_id': 39827,
      'deletion_mark': 0,
      'fullname': '\u0413\u0440\u0435\u0446\u043e\u0432\u0430 \u041c\u0430\u0440\u0438\u044f \u0412\u0430\u0434\u0438\u043c\u043e\u0432\u043d\u0430',
      'lastname': '\u0413\u0440\u0435\u0446\u043e\u0432\u0430',
      'name': '\u041c\u0430\u0440\u0438\u044f',
      'surname': '\u0412\u0430\u0434\u0438\u043c\u043e\u0432\u043d\u0430',
      'email': 'mary_grecova@mail.ru',
      'sex': null,
      'birthdate': '1995-01-16',
      'inn': null,
      'country': null,
      'state': null,
      'city': null,
      'zip': null,
      'address': null,
      'phone': null,
      'notes': null,
      'created_at': null,
      'updated_at': null,
      'domain': 'EDU',
      'profiles': [
        {
          'id': 12853,
          'sync_id': '127854',
          'sync_source': 'profiles',
          'external_id': '127854',
          'user_id': 12750,
          'bitrix_id': 39827,
          'type': 'student',
          'deletion_mark': 0,
          'country': null,
          'state': null,
          'city': null,
          'zip': null,
          'address': null,
          'company': null,
          'web': null,
          'department_id': null,
          'job_title': null,
          'job_type': null,
          'job_activity': null,
          'phone': null,
          'internal_phone': null,
          'fax': null,
          'edu_dep_id': 1494,
          'degree': null,
          'rank': null,
          'qual_level': null,
          'manager_id': null,
          'edu_form': '\u041e\u0447\u043d\u0430\u044f',
          'edu_mark_book_num': '16366012',
          'edu_student_link_code': null,
          'edu_status': '\u0423\u0447\u0438\u0442\u0441\u044f',
          'faculty_id': 7,
          'cathedra': '\u043c\u041f\u041c\u0418',
          'edu_direction_id': 1695,
          'edu_specialization_id': 244,
          'edu_qualification_id': 2,
          'edu_group_id': 1494,
          'edu_subgroup': null,
          'edu_course': 1,
          'edu_semester': 2,
          'edu_year': 2016,
          'notes': null,
          'extra': null,
          'created_at': null,
          'updated_at': '',
          'role': 'student',
          'type_name': '\u0421\u0442\u0443\u0434\u0435\u043d\u0442',
          'photo_url': '',
          'faculty': {
            'id': 7,
            'title': '\u0418\u043d\u0441\u0442\u0438\u0442\u0443\u0442 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0438'
          },
          'edu_direction': {
            'id': 1695,
            'title': '01.04.02 \u041f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0430'
          },
          'edu_group': {'id': 1494, 'title': '13641\/1'}
        },
        {
          'id': 12855,
          'sync_id': '127855',
          'sync_source': 'profiles',
          'external_id': '127854',
          'user_id': 12750,
          'bitrix_id': 39827,
          'type': 'employee',
          'deletion_mark': 0,
          'country': null,
          'state': null,
          'city': null,
          'zip': null,
          'address': null,
          'company': null,
          'web': null,
          'department_id': null,
          'job_title': 'Лаборант',
          'job_type': 'По совместительству',
          'job_activity': null,
          'phone': null,
          'internal_phone': null,
          'fax': null,
          'edu_dep_id': 1494,
          'degree': null,
          'rank': null,
          'qual_level': null,
          'manager_id': null,
          'edu_form': '',
          'edu_mark_book_num': '16366012',
          'edu_student_link_code': null,
          'edu_status': '',
          'faculty_id': 7,
          'cathedra': '',
          'edu_direction_id': 1695,
          'edu_specialization_id': 244,
          'edu_qualification_id': 2,
          'edu_group_id': 1494,
          'edu_subgroup': null,
          'edu_course': 1,
          'edu_semester': 2,
          'edu_year': 2016,
          'notes': null,
          'extra': null,
          'created_at': null,
          'updated_at': '',
          'role': 'employee',
          'type_name': 'Сотрудник',
          'photo_url': '',
          'faculty': {
            'id': 7,
            'title': '\u0418\u043d\u0441\u0442\u0438\u0442\u0443\u0442 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0438'
          },
          'edu_direction': {
            'id': 1695,
            'title': '01.04.02 \u041f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0430'
          },
          'edu_group': {'id': 1494, 'title': '13641\/1'}
        }
      ]
    };
    this.header = this.user.fullname;
  }
}
<glx-page-title-bx [header]="header"></glx-page-title-bx>
<div class="user-viewer-wrapper">
  <glx-user-viewer [user]="user" [defaultImage]="defaultImage"></glx-user-viewer>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""