import { Component, OnInit } from '@angular/core';
import { IconServiceService } from 'app/service/icon-service.service';

export type Star = 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5;
export const STAR_CLASS_MAP = {
  0: IconServiceService.farStar,
  0.5: IconServiceService.faStarHalfAlt,
  1: IconServiceService.fasStar,
}
export const MAX_STARS = 5;

export interface Link {
  href: string;
  name: string;
}
export interface Skill {
  name: string;
  icon: any;
  starCount?: Star;
  isFaIcon: boolean;
  description?: {
    text?: string;
    links?: Link[];
  };
}
@Component({
  selector: 'app-resume',
  templateUrl: './resume.component.html',
  styleUrls: ['./resume.component.scss']
})
export class ResumeComponent implements OnInit {

  public focus = false;
  public focus1 = false;

  displayedPersonalColumns = [
    'name',
    'birthdate',
    'location'
  ];
  personalData = {
    name: 'Christian Ziermann',
    birthdate: new Date('September 3, 1996'),
    location: 'Aachner Straße 545 Cologne 50933',
  }
  public softSkills: Skill[] = [
    {
      name: 'Teamwork',
      icon: IconServiceService.faUsers,
      isFaIcon: true,
      starCount: 4
    },
    {
      name: 'Communication',
      icon: IconServiceService.faComments,
      isFaIcon: true,
      starCount: 4.5
    },
  ];

  public likeToLearn: Skill[] = [
    {
      name: 'IoT',
      icon: IconServiceService.faMicrochip,
      isFaIcon: true,
    },
    {
      name: 'Deep Learning',
      icon: IconServiceService.faCogs,
      isFaIcon: true,
    },
    {
      name: 'Game Development',
      icon: IconServiceService.faGamepad,
      isFaIcon: true,
    },
    {
      name: 'Vuejs',
      icon: IconServiceService.faVuejs,
      isFaIcon: true,
    },
  ];




  public hobbys: Skill[] = [
    {
      name: 'Gaming',
      icon: IconServiceService.faGamepad,
      isFaIcon: true,
    },
    {
      name: 'Music',
      icon: IconServiceService.faMusic,
      isFaIcon: true,
      description: {
        links: [
          {
            href: '/music',
            name: 'Checkout'
          }
        ]
      }
    },
    {
      name: 'Programming',
      icon: IconServiceService.faCode,
      isFaIcon: true,
    },
    {
      name: 'Cooking',
      icon: IconServiceService.faUtensils,
      isFaIcon: true,
    },
    {
      name: 'Skating',
      icon: IconServiceService.faSnowboarding,
      isFaIcon: true,
    },
    {
      name: 'Pen & Paper',
      icon: IconServiceService.faEdit,
      isFaIcon: true,
    },
  ];

  public languages: Skill[] = [
    {
      name: 'German (native language)',
      icon: '<img height="30" src="/assets/icons/flags/german.png" alt="German">',
      isFaIcon: false,
      starCount: 5
    },
    {
      name: 'English',
      icon: '<img height="30" src="/assets/icons/flags/english.png" alt="English">',
      isFaIcon: false,
      starCount: 3.5
    },
  ];

  public skills: Skill[] = [
    {
      name: 'Unit-testing',
      icon: IconServiceService.faVial,
      isFaIcon: true,
      starCount: 3
    },
    {
      name: 'Jira',
      icon: IconServiceService.faJira,
      isFaIcon: true,
      starCount: 4
    },
    {
      name: 'Apache',
      icon: '<img height="30" src="/assets/icons/apache.svg" alt="Apache">',
      isFaIcon: false,
      starCount: 2.5
    },
    {
      name: 'Nginx',
      icon: '<img height="30" src="/assets/icons/nginx.svg" alt="Nginx">',
      isFaIcon: false,
      starCount: 4.5
    },
    {
      name: 'Jenkins',
      icon: IconServiceService.faJenkins,
      isFaIcon: true,
      starCount: 3
    },
    {
      name: 'SQL',
      icon: IconServiceService.faDatabase,
      isFaIcon: true,
      starCount: 3.5
    },
    {
      name: 'Python',
      icon: IconServiceService.faPython,
      isFaIcon: true,
      starCount: 2
    },
    {
      name: 'PHP',
      icon: IconServiceService.faPhp,
      isFaIcon: true,
      starCount: 4
    },
    {
      name: 'HTML & CSS',
      icon: IconServiceService.faHtml5,
      isFaIcon: true,
      starCount: 4.5
    },
    {
      name: 'Angular 2+ & AngularJS',
      icon: IconServiceService.faAngular,
      isFaIcon: true,
      starCount: 4.5
    },

    {
      name: 'NestJs',
      icon: '<img height="30" src="/assets/icons/nestjs.svg" alt="NestJs">',
      isFaIcon: false,
      starCount: 4
    },
    {
      name: 'Twig',
      icon: '<img height="30" src="/assets/icons/twig.svg" alt="Twig">',
      isFaIcon: false,
      starCount: 4.5
    },
    {
      name: 'Electron',
      icon: IconServiceService.faAtom,
      isFaIcon: true,
      starCount: 4
    },
    {
      name: 'Typescript',
      icon: '<img height="30" color="white" class="skill-logo" src="/assets/icons/typescript.svg" alt="Typescript">',
      isFaIcon: false,
      starCount: 4
    },
    {
      name: 'Ubuntu',
      icon: IconServiceService.faUbuntu,
      isFaIcon: true,
      starCount: 4
    },
    {
      name: 'Docker',
      icon: IconServiceService.faDocker,
      isFaIcon: true,
      starCount: 3
    },
    {
      name: 'Kubernetes',
      icon: '<img height="30" src="/assets/icons/kubernetes.svg" alt="Kubernetes">',
      isFaIcon: false,
      starCount: 2
    },
    {
      name: 'Git',
      icon: IconServiceService.faGit,
      isFaIcon: true,
      starCount: 4.5
    },
    {
      name: 'NPM',
      icon: IconServiceService.faNpm,
      isFaIcon: true,
      starCount: 5
    },

    {
      name: 'Unity',
      icon: IconServiceService.faUnity,
      isFaIcon: true,
      starCount: 2
    },

    {
      name: 'Godot',
      icon: '<img height="30" src="/assets/icons/kubernetes.svg" alt="Kubernetes">',
      isFaIcon: false,
      starCount: 4.5
    },
    {
      name: 'C#',
      icon: '<div height="30">C#</div>',
      isFaIcon: false,
      starCount: 4.5
    },

  ];
  public icons = IconServiceService;
  constructor() { }

  ngOnInit(): void {
  }


  getStarIcon(starCount: Star, starIndex: number) {
    const starSizes: number[] = [];
    let starCountWorker = starCount;
    for (let starIterator = 1; starIterator <= MAX_STARS; starIterator++) {
      if (starCountWorker >= 1) {
        starCountWorker = (starCountWorker - 1) as Star;
        starSizes.push(1);
      } else {
        if (starCountWorker === 0) {
          starSizes.push(starCountWorker);
          continue;
        }
        starSizes.push(starCountWorker);
        starCountWorker = 0;
      }
    }
    return STAR_CLASS_MAP[starSizes[starIndex]];
  }

}
