import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';

import { AppComponent } from "../../app.component";
import { AppConstants } from "../../app.constants";
import { ApiService } from "@shared/services/api.service";
import { HeaderService } from "@shared/services/header.service";
import { SideMenuService } from "@shared/services/side-menu.service";
import { FooterService } from "@shared/services/footer.service";
import { UtilityService } from "@shared/services/utility.service";

@Component({
  selector: 'app-dashboard-page',
  templateUrl: './dashboard-page.component.html',
  styleUrls: ['./dashboard-page.component.sass']
})
export class DashboardPageComponent implements OnInit {

  public userCount: any;
  public graphData: any;
  public claimDetails: any;
  public productOverviewDetails: any;
  public userData: any;
  public riskData: any;
  public view;
  public showLoader: boolean;
  public osData: any;
  public statusDetails: any;
  public loaderArr: any = [];
  constructor(public util: UtilityService,
    private _apiCallService: ApiService,
    public sideMenu: SideMenuService,
    public footer: FooterService,
    public header:HeaderService,
    private Router: Router ) {
      this.view = AppConstants.VIEW_DASH;
  }

  setViews(val) {
      this.view = val;
      if(this.view == 'welcome') {
          this.sideMenu.hide();
          this.footer.show();
          this.header.setCommonHead();
          this.util.setLiteBg();
      }
      else if(this.view == 'dashboard') {
          this.footer.hide();
          this.header.setDashHead();
          this.util.setDarkBg();
          this.sideMenu.show();
          this.sideMenu.setActiveClass("/dashboard");
          this.sideMenu.dashIcon = true;
          this.sideMenu.hideSelectionIcon = false;
      }
  }

  ngOnInit() {
      this.setViews('dashboard');
      this.showLoader = true;
  }

  checkLoader(e: any) {
      this.loaderArr.push(e);
      console.log(this.loaderArr);
      // Checks to no of api's called. Since there are 8 components, 8 respective api calls initiated
      if(this.loaderArr.length === 7){
          this.showLoader = false;
      }
  }
}