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

import { Component, Inject, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
import {
  BciImprintComponent,
  BciSidebarService,
  CORE_CONFIG,
  CoreConfig,
  ModalWindowService,
  NavigationService,
  SidebarNavItem,
} from '@bci-web-core/core';
import { Observable } from 'rxjs';

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

  constructor(
    private titleService: Title,
    @Inject(CORE_CONFIG) private config: CoreConfig,
    private navigationService: NavigationService,
    private modalWindowService: ModalWindowService,
    private router: Router,
    private dialog: MatDialog,
    private bciSidebarService: BciSidebarService
  ) {}

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

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

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