import { Component, OnInit } from '@angular/core';
import { UserInfo } from '../../models/userInfo.model';
import { LocalStorageService } from 'angular-2-local-storage';
import { EmployeeNavBarService } from '../employee-dashboard/employee-nav-bar.service';
import { Subject } from 'rxjs/Rx';


const dashboardPages = [
  { title: '' },
  { title: 'bny-dashboard' },
];


@Component({
  selector: 'app-bny-employee-dashboard',
  templateUrl: './bny-employee-dashboard.component.html',
  styleUrls: ['./bny-employee-dashboard.component.scss'],
  providers: [EmployeeNavBarService]
})
export class BnyEmployeeDashboardComponent implements OnInit {
  initials = '';
  backLink = '/employee/dashboard';
  empData: UserInfo;
  currentPageNumber: number;
  private $destroyed = new Subject();
  currentPageData: { title: string };
  roleStatus: boolean = false;
  showVideos: any;
  vidName: string;
  frmCandD:boolean = false;
  
  public menuItemsArray: any[] = [
    {
      'title': 'Help', 'link': '#', 'id': 'help',
      'subItems': [
        {'title': 'Employee', 'link': '#', 'embed': 'Employee+intro+and+capability+assessment.mov', 'id': 'employeeV', 'name': 'Employee Help Video'},
      ]
    },
  ];

  constructor(protected localStorageService: LocalStorageService,
    private employeeNavBarService: EmployeeNavBarService,
  ) { 
    this.empData = this.localStorageService.get('userInfo') as UserInfo;
    if (this.empData['fullName']) {
      this.initials = this.empData['fullName'].replace(/\W*(\w)\w*/g, '$1').toUpperCase();
    }   

    employeeNavBarService.currentPage$.takeUntil(this.$destroyed).subscribe((val: number) => {
      this.currentPageNumber = val;
      this.currentPageData = dashboardPages[this.currentPageNumber];
      // this.showButtonPlus = !currentPageNotShowButtonPlus.some(c => c === this.currentPageNumber);
    });     
  }

  ngOnInit() {
  }
  changeRole(evnt){
    this.roleStatus = !this.roleStatus;
  }
  closeNavDetails(event){
    this.roleStatus = event;
  }
  public onMenuOpen() {
    console.log('menu Opened');
  }  
  public onMenuClose() {
    console.log('menu closed');
  }  
  public onItemSelect(item: any) {
    console.log(item);
    this.vidName = item.name;
    this.showVideos = item.embed;
    document.getElementById('openVideoModalButton').click();
  }  

  openFeedModal(e){
    console.log(e);
    if(e == true){
      this.frmCandD = e
    }
  }

  closeFdModal(e){
    if(e == false){
      this.frmCandD = e;
    }
  }
}
