import { Component, OnInit } from '@angular/core';
import { UiModule } from '@shared/ui/ui.module';
import { DetailsComponentBase } from '@objects-view/details-component-base';
import { ConfigService } from '@shared/config/config.service';
import { IRBACPolicyModel } from '@fleio-api/openstack/model/rbac-policy.model';
import { NgIf } from '@angular/common';

@Component({
  selector: 'app-rbac-policy-details-overview',
  standalone: true,
  imports: [
    UiModule,
    NgIf
  ],
  templateUrl: './rbac-policy-details-overview.component.html',
  styleUrl: './rbac-policy-details-overview.component.scss'
})
export class RbacPolicyDetailsOverviewComponent extends DetailsComponentBase<IRBACPolicyModel> implements OnInit {
  objectUrl: string = null;

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

  ngOnInit(refreshTimerInterval?: number) {
    super.ngOnInit(refreshTimerInterval);
    switch (this.object.object_type) {
      case 'network':
        this.objectUrl = this.config.getPanelUrl(`openstack/networks/${this.object.object_id}`);
        break;
      case 'subnetpool':
        this.objectUrl = this.config.getPanelUrl(`openstack/subnet-pools/${this.object.object_id}`);
        break;
    }
  }

}
