<main class="main-container animated fadeIn">
  <app-btn-navigate navigate="/sam/GEPR/SFTR/GSFT" [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('solicitud_ejecuciones_tareas') }} #{{ idExecute }}</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)="getExecuteTask()"
            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_TAREA">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> No </th>
            <td mat-cell *matCellDef="let element"> #{{ element.ID_EJECUCION_TAREA }} </td>
          </ng-container>
          <ng-container matColumnDef="NOMBRE_TAREA">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('nombre_de_la_tarea') }} </th>
            <td mat-cell *matCellDef="let element"> {{ element.NOMBRE_TAREA }} </td>
          </ng-container>
          <ng-container matColumnDef="USUARIO_RESPONSABLE">
            <th mat-header-cell *matHeaderCellDef mat-sort-header> {{ interService.get('nombre_responsable') }} </th>
            <td mat-cell *matCellDef="let element"> {{ element.USUARIO_RESPONSABLE }} </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="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="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="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" 
              [matTooltip]="interService.get('clic_desplegar')" 
              [matMenuTriggerFor]="menu" 
              [disabled]="isLoading || isLoadingForm"
              #menuTrigger>
                <mat-icon>more_vert</mat-icon>
              </button>
              <mat-menu #menu="matMenu">
                <button mat-menu-item (click)="openExecuteTask(element)">
                  <mat-icon>task_alt</mat-icon> {{ interService.get('ver_ejecucion_tareas') }}
                </button>
                <button mat-menu-item (click)="openHistory(element)">
                  <mat-icon>history</mat-icon> {{ interService.get('historial_validaciones') }}
                </button>
              </mat-menu>

            </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>