import {
  Component,
  OnInit,
  ViewEncapsulation,
  AfterContentInit,
  AfterViewInit,
  DoCheck
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { fuseAnimations } from 'src/@fuse/animations';
import { FuseConfigService } from 'src/@fuse/services/config.service';
import { Dashboard } from 'src/modules/dashboard/model/Dashboard';

@Component({
  selector: 'app-pages-settings-dashboard',
  templateUrl: './main.component.html',
  styleUrls: ['./main.component.scss'],
  animations: fuseAnimations
})
export class MainComponent implements OnInit {
  widgets: any;
  dashboards: Dashboard[];
  currentDashboard: Dashboard;

  /**
   * Constructor
   */
  constructor(
    private fuseConfigService: FuseConfigService,
    private activatedRoute: ActivatedRoute
  ) {}

  // -----------------------------------------------------------------------------------------------------
  // @ Lifecycle hooks
  // -----------------------------------------------------------------------------------------------------

  /**
   * On init
   */
  ngOnInit(): void {
    // Get the widgets from the service
    this.dashboards = this.activatedRoute.snapshot.data.dashboards || [];

    console.log(this.dashboards);
  }

  // -----------------------------------------------------------------------------------------------------
  // @ Private methods
  // -----------------------------------------------------------------------------------------------------

  // -----------------------------------------------------------------------------------------------------
  // @ Public methods
  // -----------------------------------------------------------------------------------------------------

  /**
   * Deselect current todo
   */
  deselectCurrentDashboard(): void {
    this.currentDashboard = null;
  }

  onSelectedDashboard(dashboard: Dashboard): void {
    console.log(dashboard);
    this.currentDashboard = dashboard;
  }
}
