<!--

    Copyright © 2016-2023 The Thingsboard Authors

    Licensed 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.

-->
<table mat-table [dataSource]="dataSource">
  <ng-container matColumnDef="order">
    <mat-header-cell *matHeaderCellDef style="min-width: 40px; max-width: 40px; width: 40px"></mat-header-cell>
    <mat-cell *matCellDef="let column; let i = index">
      {{ (i+1) }}
    </mat-cell>
  </ng-container>
  <ng-container matColumnDef="sampleData">
    <mat-header-cell *matHeaderCellDef class="mat-column-sampleData"> {{ 'import.column-example' | translate }} </mat-header-cell>
    <mat-cell *matCellDef="let column">
      {{column.sampleData}}
    </mat-cell>
  </ng-container>
  <ng-container matColumnDef="type">
    <mat-header-cell *matHeaderCellDef class="mat-column-type"> {{ 'import.column-type.column-type' | translate }} </mat-header-cell>
    <mat-cell *matCellDef="let column">
      <mat-select [(ngModel)]="column.type" (ngModelChange)="columnsUpdated()">
        <mat-option *ngFor="let type of columnTypes" [value]="type.value" [disabled]="type.disabled">
          {{ columnTypesTranslations.get(type.value) | translate }}
        </mat-option>
        <mat-optgroup label="{{ 'import.credentials' | translate }}" *ngIf="entityType === entityTypeDevice">
          <mat-option *ngFor="let credential of columnDeviceCredentials" [value]="credential.value" [disabled]="credential.disabled">
            {{ columnTypesTranslations.get(credential.value) | translate }}
          </mat-option>
        </mat-optgroup>
      </mat-select>
    </mat-cell>
  </ng-container>
  <ng-container matColumnDef="key">
    <mat-header-cell *matHeaderCellDef class="mat-column-key"> {{ 'import.column-key' | translate }} </mat-header-cell>
    <mat-cell *matCellDef="let column">
      <mat-form-field *ngIf="isColumnTypeDiffers(column.type)">
        <input matInput [required]="isColumnTypeDiffers(column.type)"
               [(ngModel)]="column.key" (ngModelChange)="columnsUpdated()"
               placeholder="{{ 'import.column-value' | translate }}"/>
      </mat-form-field>
    </mat-cell>
  </ng-container>
  <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
  <mat-row *matRowDef="let column; columns: displayedColumns;"></mat-row>
</table>
<mat-divider></mat-divider>
