<!-- GUIPropertiesViewAndSortCustomizer -->
<div class="d-flex justify-content-center">
  <div class="col-8">
    @if (inputDataUpload()) {
      <div>
        <h2 data-cy="inputDataUploadDetailsHeading">
          <span jhiTranslate="resilientApp.inputDataUpload.detail.title">Input Data Upload</span>
        </h2>

        <hr />

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

        <jhi-alert></jhi-alert>

        <jhi-activity-progress [activityDomain]="inputDataUpload()"></jhi-activity-progress>
		
        <dl class="row-md jh-entity-details">
          <dt><span jhiTranslate="resilientApp.inputDataUpload.period">Period</span></dt>
          <dd>
            @if (inputDataUpload()!.period) {
              <div>
                <a [routerLink]="['/period', inputDataUpload()!.period?.id, 'view']">{{ inputDataUpload()!.period?.name }}</a>
              </div>
            }
          </dd>
          <dt><span jhiTranslate="resilientApp.inputDataUpload.owner">Owner</span></dt>
          <dd>
            @if (inputDataUpload()!.owner) {
              <div>
                <a [routerLink]="['/organization', inputDataUpload()!.owner?.id, 'view']">{{ inputDataUpload()!.owner?.name }}</a>
              </div>
            }
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputDataUpload.help.title' | translate" jhiTranslate="resilientApp.inputDataUpload.title"
              >Title</span
            >
          </dt>
          <dd>
            <span>{{ inputDataUpload()!.title }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputDataUpload.help.type' | translate" jhiTranslate="resilientApp.inputDataUpload.type"
              >Type</span
            >
          </dt>
          <dd>
            <span [jhiTranslate]="'resilientApp.UploadType.' + (inputDataUpload()!.type ?? 'null')">{{
              { null: '', INVENTORY: 'INVENTORY', ENERGY: 'ENERGY', GAS: 'GAS', GLOBAL: 'GLOBAL', ACCOUNTING: 'ACCOUNTING' }[inputDataUpload()!.type ?? 'null']
            }}</span>
          </dd>
          <dt>
            <span
              [ngbTooltip]="'resilientApp.inputDataUpload.help.dataFile' | translate"
              jhiTranslate="resilientApp.inputDataUpload.dataFile"
              >Data File</span
            >
          </dt>
          <dd>
            @if (inputDataUpload()!.dataFile) {
              <div>
                <a
                  (click)="openFile(inputDataUpload()!.dataFile ?? '', inputDataUpload()!.dataFileContentType)"
                  jhiTranslate="entity.action.open"
                  >Abrir</a
                >
                {{ inputDataUpload()!.dataFileContentType }}, {{ byteSize(inputDataUpload()!.dataFile ?? '') }}
              </div>
            }
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputDataUpload.help.state' | translate" jhiTranslate="resilientApp.inputDataUpload.state"
              >State</span
            >
          </dt>
          <dd>
            <span [jhiTranslate]="'resilientApp.UploadStatus.' + (inputDataUpload()!.state ?? 'null')">{{
              { null: '', UPLOADED: 'UPLOADED', PROCESSING: 'PROCESSING', PROCESSED: 'PROCESSED', ERROR: 'ERROR' }[
                inputDataUpload()!.state ?? 'null'
              ]
            }}</span>
          </dd>
          <dt>
            <span
              [ngbTooltip]="'resilientApp.inputDataUpload.help.comments' | translate"
              jhiTranslate="resilientApp.inputDataUpload.comments"
              >Comments</span
            >
          </dt>
      </dl>

        <button type="submit" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
          <fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Voltar</span>
        </button>

        <button 
          *ngIf="canUpdate(inputDataUpload())"
          type="button" 
          [routerLink]="!canUpdate(inputDataUpload()) ? null : ['/input-data-upload', inputDataUpload()!.id, 'edit']" 
          class="btn btn-primary" 
          [class.disabled]="!canUpdate(inputDataUpload())"
        >
          <fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span jhiTranslate="entity.action.edit">Editar</span>
        </button>
		
        <button type="button" (click)="showLogs()" class="btn btn-danger" *ngIf="inputDataUpload()!.state === UploadStatus.ERROR">
          <fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span jhiTranslate="resilientApp.inputDataUpload.action.showLogs">Logs</span>
        </button>
        
        <!-- ACTIVITY Actions -->
        <resilient-activity-actions-button [activityDomain]="inputDataUpload()" (activityInvoked)="handleActivityInvoked($event)"></resilient-activity-actions-button>
      </div>
    }
  </div>
</div>
