File

src/app/modules/profile/profile.component.ts

Description

Компонент-оболочка для модуля профиль

Implements

OnInit

Metadata

styleUrls profile.scss
templateUrl ./profile.html

Index

Properties
Methods

Constructor

constructor(route: ActivatedRoute, profileService: ProfileService, settingsService: SettingsService)

Конструктор

Parameters :
Name Type Description
route ActivatedRoute
profileService ProfileService
settingsService SettingsService

Methods

ngOnInit
ngOnInit()

Получени профиля и установка меню

Returns : void

Properties

foreignProfile
foreignProfile: boolean
Type : boolean
Default value : true

Свой или чужой профиль

id
id: number
Type : number

ИД профиля

menu
menu: any
Type : any

Пункты менбю

mode
mode: string
Type : string
Default value : profile

Режим меню

profile
profile: any
Type : any

Профиль

role
role: string
Type : string

Роль профиля

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import 'rxjs/add/operator/switchMap';
import { ProfileService } from 'glx.ui/components/kernel/services/profile.service';
import { SettingsService } from 'glx.ui/components/kernel/services/settings.service';

import { MENU } from './menu';

/**
 * Компонент-оболочка для модуля профиль
 */
@Component({
  templateUrl: './profile.html',
  styleUrls: ['./profile.scss']
})
export class ProfileComponent implements OnInit {
  /**
   * Пункты менбю
   * @type {Array}
   */
  menu: any = [];
  /**
   * ИД профиля
   */
  id: number;
  /**
   * Свой или чужой профиль
   * @type {boolean}
   */
  foreignProfile: boolean = true;
  /**
   * Режим меню
   * @type {string}
   */
  mode: string = 'profile';
  /**
   * Профиль
   */
  profile: any;
  /**
   * Роль профиля
   * @type {string}
   */
  role: string = '';

  /**
   * Конструктор
   * @param {ActivatedRoute} route
   * @param {ProfileService} profileService
   * @param {SettingsService} settingsService
   */
  constructor(private route: ActivatedRoute,
              private profileService: ProfileService,
              private settingsService: SettingsService) {
  }

  /**
   * Получени профиля и установка меню
   */
  ngOnInit() {
    if (this.route.snapshot.paramMap.get('mode')) {
      this.mode = this.route.snapshot.paramMap.get('mode');
    }

    this.profileService.getCurrent()
      .subscribe(
        data => {
          this.profile = data;
          this.role = data.role;

          this.route.params.subscribe(params => {
            const id = +params['id'];
            if (id && id > 0) {
              this.foreignProfile = true;
              this.id = id;
              this.menu = MENU.empty;
            } else {
              this.foreignProfile = false;
              this.settingsService.getSection('common')
                .subscribe(
                  data => {
                    this.menu = data.profileMenu[this.mode + '_' + this.role];
                  },
                  error => {
                    this.menu = MENU.empty;
                    console.error(error);
                  });
            }
          });
        },
        error => {
          console.error(error);
        });
  }

}
<!--<nav *ngIf="menu && menu.length > 0">-->
<!--<a *ngFor="let item of menu"-->
<!--[routerLink]="item.path" routerLinkActive="active">{{item.title}}</a>-->
<!--</nav>-->
<glx-top-menu-bx [items]="menu"></glx-top-menu-bx>
<div class="container-fluid">
  <router-outlet></router-outlet>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""