import { IPermissionsModel } from '@fleio-api/base-model/IPermissionsModel';
import { ITitle } from '@objects-view/interfaces/card-data/card-title';
import { IObjectStatus } from '@objects-view/interfaces/object-status';
import { ObjectUIServiceBase } from '@objects-view/object-ui-service-base';
import { IAction } from '@objects-view/interfaces/actions/action';
import { Router } from '@angular/router';
import { ConfigService } from '@shared/config/config.service';
import { IDataField } from '@objects-view/interfaces/card-data/data-field';
import { IDetailsTab } from '@objects-view/interfaces/details/details-tab';
import { IHeatResourceTypeModel } from '@fleio-api/openstack/orchestration/model/heat-resource-type.model';
import { HeatResourceTypesApiService } from '@fleio-api/openstack/orchestration/heat-resource-types/heat-resource-types-api.service';
import { HeatResourceTypeDetailsOverviewComponent } from './tabs/heat-resource-type-details-overview/heat-resource-type-details-overview.component';
import { IIcon } from '@shared/ui/common/interfaces/icon';

export class HeatResourceTypeUiService extends ObjectUIServiceBase<IHeatResourceTypeModel> {
  private readonly router: Router;
  private readonly config: ConfigService;
  private readonly heatResourceTypesApiService: HeatResourceTypesApiService;

  constructor(
    iHeatResourceTypeModel: IHeatResourceTypeModel, permissions: IPermissionsModel, state: string,
    router: Router, config: ConfigService, heatResourceTypesApiService: HeatResourceTypesApiService
  ) {
    super(iHeatResourceTypeModel, permissions, state);
    this.router = router;
    this.config = config;
    this.heatResourceTypesApiService = heatResourceTypesApiService;
  }

  getIcon(): IIcon {
    return null;
  }

  getStatus(): IObjectStatus {
    return null;
  }

  getTitle(): ITitle {
    switch (this.state) {
      case 'details':
      default:
        return {
          text: `${this.object.name}`,
        };
    }
  }

  getActions(): IAction[] {
    const actions: IAction[] = [];
    return actions;
  }

  getDetailsActions(): IAction[] {
    const actions = [];
    return actions;
  }

  getDetailsLink(): string {
    return this.config.getPanelUrl(`openstack/heat-resource-types/${this.object.name}`);
  }

  getCardFields(): IDataField[] {
    const fields = [];

    fields.push({
      name: $localize`Name`,
      value: this.object.name,
    });

    return fields;
  }

  getTabs(): IDetailsTab[] {
    switch (this.state) {
      case 'details':
        return [
          {
            tabName: $localize`Overview`,
            tabIdentifier: 'overview',
            component: HeatResourceTypeDetailsOverviewComponent,
          },
        ];
    }
  }

  getCardTags(): string[] {
    return [];
  }

  getObjectDetailsRefreshInterval(): number {
    return null;
  }
}
