import { Component, OnInit } from '@angular/core';
import { DetailsComponentBase } from '@objects-view/details-component-base';
import { IHypervisorModel } from '@fleio-api/openstack/model/hypervisor.model';

@Component({
  selector: 'app-hypervisor-info-tab',
  templateUrl: './hypervisor-info-tab.component.html',
  styleUrls: ['./hypervisor-info-tab.component.scss']
})
export class HypervisorInfoTabComponent extends DetailsComponentBase<IHypervisorModel> implements OnInit {
  cpuInfo: any;

  constructor() {
    super();
  }

  ngOnInit(): void {
    super.ngOnInit();
    if (this.object.cpu_info) {
      this.cpuInfo = JSON.parse(this.object.cpu_info);
    }
  }

  hasCPUInfo(): boolean {
    if (this.cpuInfo) {
      return Object.keys(this.cpuInfo).length > 0;
    } else {
      return false;
    }
  }

}
