/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { BciImprintComponent, ModalWindowService, NavigationService, SidebarNavItem } from '@bci-web-core/core';
import { Observable } from 'rxjs';

@Component({
  selector: 'bci-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
  title = 'BCI Maps Demo App';
  sidebarLinks: SidebarNavItem[] = [];
  sidebarFooterLinks: SidebarNavItem[] = [
    {
      id: 'imprint',
      cb: () => this.onAbout(),
      title: 'Imprint',
      icon: 'Bosch-Ic-information',
    },
  ];

  constructor(
    private titleService: Title,
    private navigationService: NavigationService,
    private modalWindowService: ModalWindowService
  ) {}

  ngOnInit() {
    this.titleService.setTitle(this.title);
    this.getSidebarLinks().subscribe((sidebarLinks) => (this.sidebarLinks = sidebarLinks));
  }

  getSidebarLinks(): Observable<SidebarNavItem[]> {
    return this.navigationService.getNavigationItems();
  }

  onAbout() {
    this.modalWindowService.openDialogWithComponent(BciImprintComponent);
  }
}
