<!--
  ~  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 class="flex flex-col h-full gap-y-2">
    <div class="flex-1">
        <ng-container>
            <div class="cluster-version-table h-full flex flex-col">
                <!-- allow filtering of the table -->
                <cluster-table-filter
                    [filteredCount]="filteredCount"
                    [totalCount]="totalCount"
                    [filterableColumns]="filterableColumns"
                    filterColumn="address"
                    (filterChanged)="applyFilter($event)"></cluster-table-filter>

                <div class="flex-1 relative">
                    <div class="listing-table overflow-y-auto absolute inset-0">
                        <table
                            mat-table
                            [dataSource]="dataSource"
                            matSort
                            matSortDisableClear
                            (matSortChange)="sortData($event)"
                            [matSortActive]="initialSortColumn"
                            [matSortDirection]="initialSortDirection">
                            <!-- Node Address -->
                            <ng-container matColumnDef="address">
                                <th mat-header-cell *matHeaderCellDef mat-sort-header title="Node Address">
                                    <div class="overflow-ellipsis overflow-hidden whitespace-nowrap">Node Address</div>
                                </th>
                                <td mat-cell *matCellDef="let item" [title]="formatNodeAddress(item)">
                                    {{ formatNodeAddress(item) }}
                                </td>
                            </ng-container>

                            <!-- NiFi Version -->
                            <ng-container matColumnDef="nifiVersion">
                                <th mat-header-cell *matHeaderCellDef mat-sort-header title="NiFi Version">
                                    <div class="overflow-ellipsis overflow-hidden whitespace-nowrap">NiFi Version</div>
                                </th>
                                <td mat-cell *matCellDef="let item" [title]="item.snapshot.versionInfo.niFiVersion">
                                    {{ item.snapshot.versionInfo.niFiVersion }}
                                </td>
                            </ng-container>

                            <!-- Java Vendor -->
                            <ng-container matColumnDef="javaVendor">
                                <th mat-header-cell *matHeaderCellDef mat-sort-header title="Java Vendor">
                                    <div class="overflow-ellipsis overflow-hidden whitespace-nowrap">Java Vendor</div>
                                </th>
                                <td mat-cell *matCellDef="let item" [title]="item.snapshot.versionInfo.javaVendor">
                                    {{ item.snapshot.versionInfo.javaVendor }}
                                </td>
                            </ng-container>

                            <!-- Java Version -->
                            <ng-container matColumnDef="javaVersion">
                                <th mat-header-cell *matHeaderCellDef mat-sort-header title="Java Version">
                                    <div class="overflow-ellipsis overflow-hidden whitespace-nowrap">Java Version</div>
                                </th>
                                <td mat-cell *matCellDef="let item" [title]="item.snapshot.versionInfo.javaVersion">
                                    {{ item.snapshot.versionInfo.javaVersion }}
                                </td>
                            </ng-container>

                            <!-- OS Name -->
                            <ng-container matColumnDef="osName">
                                <th mat-header-cell *matHeaderCellDef mat-sort-header title="OS Name">
                                    <div class="overflow-ellipsis overflow-hidden whitespace-nowrap">OS Name</div>
                                </th>
                                <td mat-cell *matCellDef="let item" [title]="item.snapshot.versionInfo.osName">
                                    {{ item.snapshot.versionInfo.osName }}
                                </td>
                            </ng-container>

                            <!-- OS Version -->
                            <ng-container matColumnDef="osVersion">
                                <th mat-header-cell *matHeaderCellDef mat-sort-header title="OS Version">
                                    <div class="overflow-ellipsis overflow-hidden whitespace-nowrap">OS Version</div>
                                </th>
                                <td mat-cell *matCellDef="let item" [title]="item.snapshot.versionInfo.osVersion">
                                    {{ item.snapshot.versionInfo.osVersion }}
                                </td>
                            </ng-container>

                            <!-- OS Architecture -->
                            <ng-container matColumnDef="osArchitecture">
                                <th mat-header-cell *matHeaderCellDef mat-sort-header title="OS Architecture">
                                    <div class="overflow-ellipsis overflow-hidden whitespace-nowrap">
                                        OS Architecture
                                    </div>
                                </th>
                                <td mat-cell *matCellDef="let item" [title]="item.snapshot.versionInfo.osArchitecture">
                                    {{ item.snapshot.versionInfo.osArchitecture }}
                                </td>
                            </ng-container>

                            <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
                            <tr
                                mat-row
                                *matRowDef="let row; let even = even; columns: displayedColumns"
                                [class.even]="even"
                                (click)="select(row)"
                                [class.selected]="isSelected(row)"></tr>
                        </table>
                    </div>
                </div>
            </div>
        </ng-container>
    </div>
</div>
