import { Component, OnInit } from '@angular/core';
import { DetailsComponentBase } from '@objects-view/details-component-base';
import { FormatHelper } from '@shared/ui-api/helpers/format-helper';
import { ConfigService } from '@shared/config/config.service';
import { ILBMemberModel } from '@fleio-api/openstack/load-balancing/model/lb-member.model';

@Component({
  selector: 'app-member-details-overview',
  templateUrl: './member-details-overview.component.html',
  styleUrls: ['./member-details-overview.component.scss']
})
export class MemberDetailsOverviewComponent extends DetailsComponentBase<ILBMemberModel> implements OnInit {
  formatHelper = new FormatHelper();

  constructor(
    public config: ConfigService,
  ) {
    super();
  }

  ngOnInit() {
    super.ngOnInit();
    if (this.object?.id) {
      this.object.name = this.object.name || $localize`(none)`;
      this.object.operating_status = this.object.operating_status || $localize`n/a`;
      this.object.provisioning_status = this.object.provisioning_status || $localize`n/a`;
      this.object.monitor = this.object.monitor || $localize`n/a`;
      this.object.admin_state_up_display = this.object.admin_state_up ? $localize`Yes`: $localize`No`;
      this.object.backup_display = this.object.backup ? $localize`Yes`: $localize`No`;
    }
  }
}
