import { Component, OnInit } from '@angular/core';
import { LineCap } from '@progress/kendo-angular-gauges';
import { DashboardSale, SaleSupervisor } from 'src/app/models/dashboard.model';
import { DashboardService } from 'src/app/services/dashboard.service';

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

  constructor(private readonly dashboardService: DashboardService) { }

  public gridData: any[] = [];
  dataTodaySale: any;
  public showLabels = true;
  public showTicks = true;
  public reverse = false;
  public autoCorrect = true;
  public listItems: Array<string> = ["round", "butt"];

  public startAngle = 0;
  public endAngle = 180;
  public rangeSize = 20;

  public rangeLineCap: LineCap = "round";

  public rangePlaceholderColor = "rgba(228, 228, 228, 1)";
  public ticksColor = "rgba(0, 128,0, 1)";
  public labelsColor = "rgba(0, 0, 255, 1)";

  public colors = [
    {
      to: 25,
      color: "#f31700",
    },
    {
      from: 25,
      to: 80,
      color: "#f31700", //"#37b400"
    },
    {
      from: 80,
      to: 99,
      color: "#ffc000",
    },
    {
      from: 100,
      color: "#0aac25af",
    },
  ];

  public colorsProfit = [
    {
      to: 0,
      color: "#f31700",
    },
    {
      from: 0,
      to: 20,
      color: "#f31700", //"#37b400"
    },
    {
      from: 20,
      to: 27,
      color: "#ffc000",
    },
    {
      from: 27,
      color: "#0aac25af",
    },
  ];

  public colorsObjetive = [
    {
      to: 0,
      color: "#f31700",
    },
    {
      from: 0,
      to: 80,
      color: "#f31700", //"#37b400"
    },
    {
      from: 80,
      to: 99,
      color: "#ffc000",
    },
    {
      from: 99,
      color: "#0aac25af",
    },
  ];

  public rangeSize2 = 12;

  public lineColor2 = "rgba(107, 107, 111, 1)";
  public rangeColor2 = "rgba(186, 186, 191, 1)";
  public rangePlaceholderColor2 = "rgba(228, 228, 228, 1)";
  public ticksColor2 = "rgba(0, 128,0, 1)";
  public labelsColor2 = "rgba(0, 0, 255, 1)";
  public showLabels2 = false;
  public showTicks2 = false;
  public reverse2 = false;
  public vertical2 = false;
  public autoCorrect2 = true;
  public lineWidth2: number;
  public value2 = 30;
  public listItems2: Array<string> = ["round", "butt"];

  reloadPagina(tempo: number): void {
    setTimeout(() => {
      window.location.reload();
    }, tempo);
  }

  ngOnInit(): void {
    this.dashboardService.getSaleCompany()
      .subscribe(data => {
        this.dataTodaySale = data;
        this.gridData = this.dataTodaySale.saleSupervisor;
      });
    this.reloadPagina(60000)
  }

}
