<main class="main-container animated fadeIn">
  <app-btn-navigate navigate="/sam/GEPR" [nameButton]="interService.get('S002V01M03GEPR')" [changeLanguage]="true" />
  <mat-card class="override-card override-elevation-z8">
    @if (isLoadingForm) {
      <mat-progress-bar mode="indeterminate"></mat-progress-bar>
    }
    <section class="override-section">
      <nav class="override-nav">
        <div class="w-100 align-center pv-15">
          <span class="title-card">{{ interService.get('S002V01S03SFTR') }}</span>
        </div>
        <div class="override-actions">
          <app-search-card 
          [dataSource]="dataSource" 
          [disabled]="isLoading || isLoadingForm" 
          [label]="interService.get('buscador')" 
          [placeholder]="interService.get('ingrese_palabra_buscar')" 
          [btnRemoveFilter]="interService.get('eliminar_filtro')" 
          (dataValue)="dataSource = $event" />
          <div class="override-buttons">
            <button 
            mat-mini-fab 
            [matTooltip]="interService.get('actualizar_datos')"
            (click)="getExecuteWorkflow()"
            class="orange_primary_background white_font override_no_shadow ml-8">
              <mat-icon>refresh</mat-icon>
            </button>
          </div>
        </div>
      </nav>

      <app-loading-card [isLoading]="isLoading" [txtLoading]="interService.get('cargando_informacion_solicitudes')" />

      <div class="override-table">
        <table mat-table matSort [dataSource]="dataSource" class="animated fadeIn" [style.display]="isLoading ? 'none' : 'revert'">
          <ng-container matColumnDef="ID_EJECUCION_WORKFLOW">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('numero_ejecucion') }} </th>
            <td mat-cell *matCellDef="let element"> #{{ element.ID_EJECUCION_WORKFLOW }} </td>
          </ng-container>
          <ng-container matColumnDef="NOMBRE_WORKFLOW">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('flujo_trabajo') }} </th>
            <td mat-cell *matCellDef="let element"> {{ element.NOMBRE_WORKFLOW }} </td>
          </ng-container>
          <ng-container matColumnDef="PROGRESO">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('progreso') }} </th>
            <td mat-cell *matCellDef="let element">
              <mat-progress-bar mode="determinate" [value]="element.PROGRESO" [matTooltip]="element.PROGRESO + '%'"></mat-progress-bar>
            </td>
          </ng-container>
          <ng-container matColumnDef="AUTOMATICO">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('fue_automatico') }} </th>
            <td mat-cell *matCellDef="let element"> {{ element.AUTOMATICO }} </td>
          </ng-container>
          <ng-container matColumnDef="USUARIO_MODIFICA">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('usuario_modificacion') }} </th>
            <td mat-cell *matCellDef="let element"> {{ element.USUARIO_MODIFICA }} </td>
          </ng-container>
          <ng-container matColumnDef="FECHA_MODIFICA">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('fecha_actualizacion') }} </th>
            <td mat-cell *matCellDef="let element"> {{ element.FECHA_MODIFICA }} </td>
          </ng-container>
          <ng-container matColumnDef="ESTADO">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('estado') }} </th>
            <td mat-cell *matCellDef="let element"> 
              <button mat-flat-button class="white_font" [class]="resourcesService.setChipList(element.ESTADO)">
                {{ element.ESTADO }}
              </button>
              <!--<mat-chip [class]="resourcesService.setChipList(element.ESTADO)" selected> {{ element.ESTADO }} </mat-chip>-->
            </td>
          </ng-container>
          <ng-container matColumnDef="ACCIONES">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('acciones') }} </th>
            <td mat-cell *matCellDef="let element">
              <button 
              mat-mini-fab 
              color="primary"
              class="override_no_shadow ml-4 white_font pink_primary_background" 
              (click)="getExecuteTask(element)"
              [matTooltip]="interService.get('ver_ejecucion_tareas')"  
              [disabled]="isLoadingForm">
                <mat-icon>task</mat-icon>
              </button>
            </td>
          </ng-container>

          <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
          <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>

          <tr class="mat-row" *matNoDataRow>
            <td class="mat-cell p-20 align-center" colspan="12">
              <object data="assets/img/empty_data.svg" width="150"></object>
              <h2>Sin datos</h2>
            </td>
          </tr>
        </table>
      </div>

    </section>
    <mat-paginator [pageSizeOptions]="[10, 20, 50]" class="override-paginator" showFirstLastButtons></mat-paginator>
  </mat-card>
</main>