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 { IHeatTemplateVersionModel } from '@fleio-api/openstack/orchestration/model/heat-template-version.model';
import { HeatTemplateVersionsApiService } from '@fleio-api/openstack/orchestration/heat-template-versions/heat-template-versions-api.service';
import { HeatTemplateVersionDetailsOverviewComponent } from './tabs/heat-template-version-details-overview/heat-template-version-details-overview.component';

export class HeatTemplateVersionUiService extends ObjectUIServiceBase<IHeatTemplateVersionModel> {
  private readonly router: Router;
  private readonly config: ConfigService;
  private readonly heatTemplateVersionsApiService: HeatTemplateVersionsApiService;

  constructor(
    iHeatTemplateVersionModel: IHeatTemplateVersionModel, permissions: IPermissionsModel, state: string,
    router: Router, config: ConfigService, heatTemplateVersionsApiService: HeatTemplateVersionsApiService
  ) {
    super(iHeatTemplateVersionModel, permissions, state);
    this.router = router;
    this.config = config;
    this.heatTemplateVersionsApiService = heatTemplateVersionsApiService;
  }

  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-template-versions/${this.object.name}`);
  }

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

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

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

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

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

  getObjectDetailsRefreshInterval(): number {
    return null;
  }
}
