<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  -->

<div fxFlex="100" fxLayout="column" *ngIf="filesAvailable" style="margin:1px;">
    <table fxFlex="100" mat-table [dataSource]="dataSource" style="width: 100%;">
        <ng-container matColumnDef="filename">
            <th mat-header-cell *matHeaderCellDef> Filename</th>
            <td mat-cell *matCellDef="let fileMetadata">
                <h4>{{fileMetadata.originalFilename}}</h4>
            </td>
        </ng-container>
        <ng-container matColumnDef="filetype">
            <th mat-header-cell *matHeaderCellDef> Filetype</th>
            <td mat-cell *matCellDef="let fileMetadata">
                <span class="filetype-container">{{fileMetadata.filetype}}</span>
            </td>
        </ng-container>
        <ng-container matColumnDef="uploaded">
            <th mat-header-cell *matHeaderCellDef> Uploaded</th>
            <td mat-cell *matCellDef="let fileMetadata">
                <h5>{{fileMetadata.createdAt | date:'dd.MM.yyyy HH:mm'}}</h5>
            </td>
        </ng-container>

        <ng-container matColumnDef="action">
            <th mat-header-cell *matHeaderCellDef> Action</th>
            <td mat-cell *matCellDef="let fileMetadata">
                    <button color="accent" mat-button mat-icon-button matTooltip="Delete file" matTooltipPosition="above"
                            (click)="deleteFile(fileMetadata)" data-cy="delete">
                        <i class="material-icons">delete</i>
                    </button>
            </td>
        </ng-container>

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

    </table>
    <div fxFlex="100" fxLayoutAlign="end end">
        <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" [pageSize]="10"></mat-paginator>
    </div>
</div>
<div fxFlex="100" fxLayout="column" fxLayoutAlign="center center" *ngIf="!filesAvailable">
    <h5>(no files available)</h5>
</div>
