<!-- GUIPropertiesViewAndSortCustomizer -->
<div>
  <h2 id="page-heading" data-cy="InputDataUploadHeading">
    <span jhiTranslate="resilientApp.inputDataUpload.home.title">Input Data Uploads</span>

    <div class="d-flex justify-content-end">
      <button class="btn btn-info me-2" (click)="load()" [disabled]="isLoading">
        <fa-icon icon="sync" [spin]="isLoading"></fa-icon>
        <span jhiTranslate="resilientApp.inputDataUpload.home.refreshListLabel">Refresh list</span>
      </button>

      <button
        id="jh-create-entity"
        data-cy="entityCreateButton"
        class="btn btn-primary jh-create-entity create-input-data-upload"
        *ngIf="hasCreatePermission(Resources.INPUT_DATA_UPLOAD)"
        [routerLink]="!canCreate() ? null : ['/input-data-upload/new']"
        [class.disabled]="!canCreate()"
        [disabled]="!canCreate()"
      >
        <fa-icon icon="plus"></fa-icon>
        <span jhiTranslate="resilientApp.inputDataUpload.home.createLabel">Criar novo(a) Input Data Upload</span>
      </button>
    </div>
  </h2>

  <jhi-alert-error></jhi-alert-error>

  <jhi-alert></jhi-alert>

  @if (inputDataUploads?.length === 0) {
    <div class="alert alert-warning" id="no-result">
      <span jhiTranslate="resilientApp.inputDataUpload.home.notFound">Nenhum Input Data Uploads encontrado</span>
    </div>
  }

  @if (inputDataUploads && inputDataUploads.length > 0) {
    <div class="table-responsive table-entities" id="entities">
      <table class="table table-striped" aria-describedby="page-heading">
        <thead>
          <tr jhiSort [sortState]="sortState" (sortChange)="navigateToWithComponentValues($event)">
            <th scope="col" jhiSortBy="title">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.inputDataUpload.title">Title</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="type">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.inputDataUpload.type">Type</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="state">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.inputDataUpload.state">State</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>

            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
          @for (inputDataUpload of inputDataUploads; track trackId) {
            <tr data-cy="entityTable">
              <td>{{ inputDataUpload.title }}</td>
              <td [jhiTranslate]="'resilientApp.UploadType.' + (inputDataUpload.type ?? 'null')">
                {{ { null: '', INVENTORY: 'INVENTORY',ENERGY: 'ENERGY', GAS: 'GAS', GLOBAL: 'GLOBAL', ACCOUNTING: 'ACCOUNTING' }[inputDataUpload.type ?? 'null'] }}
              </td>
              <td [jhiTranslate]="'resilientApp.UploadStatus.' + (inputDataUpload.state ?? 'null')">
                {{
                  { null: '', UPLOADED: 'UPLOADED', PROCESSING: 'PROCESSING', PROCESSED: 'PROCESSED', ERROR: 'ERROR' }[
                    inputDataUpload.state ?? 'null'
                  ]
                }}
              </td>

              <td class="text-end">
                <div class="btn-group">
                  <a
                    [routerLink]="['/input-data-upload', inputDataUpload.id, 'view']"
                    class="btn btn-info btn-sm"
                    data-cy="entityDetailsButton"
                    *ngIf="hasReadPermission(Resources.INPUT_DATA_UPLOAD)"
                  >
                    <fa-icon icon="eye"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.view">Visualizar</span>
                  </a>

                  <a
                    [routerLink]="!canUpdate(inputDataUpload) ? null : ['/input-data-upload', inputDataUpload.id, 'edit']"
                    class="btn btn-primary btn-sm"
                    [class.disabled]="!canUpdate(inputDataUpload)"
                    data-cy="entityEditButton"
                    *ngIf="hasUpdatePermission(Resources.INPUT_DATA_UPLOAD)"
                  >
                    <fa-icon icon="pencil-alt"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Editar</span>
                  </a>

                  <button 
                    type="submit" 
                    class="btn btn-danger btn-sm" 
                    data-cy="entityDeleteButton"
                    *ngIf="hasDeletePermission(Resources.INPUT_DATA_UPLOAD)"
                    (click)="!canDelete(inputDataUpload) ? null : delete(inputDataUpload)" 
                    [class.disabled]="!canDelete(inputDataUpload)"
                    [disabled]="!canDelete(inputDataUpload)"
                  >
                    <fa-icon icon="times"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Eliminar</span>
                  </button>
                </div>
              </td>
            </tr>
          }
        </tbody>
      </table>
    </div>
  }
</div>
