@using System.Linq.Expressions;
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.Extensions.Logging
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Extension
@using ThingsGateway.Gateway.Application
@using BootstrapBlazor.Components
@using ThingsGateway.Plugin.DB
@namespace ThingsGateway.Plugin.TDengineDB


<AdminTable TItem="TDengineDBHistoryValue" AutoGenerateColumns="false" ShowDefaultButtons=false
                AllowResizing="true" IsFixedHeader=true IsMultipleSelect=false
                ShowExtendEditButton=false ShowExtendDeleteButton=false ShowExtendButtons=false
            ShowExportButton="true" IsAutoQueryFirstRender=false
                OnQueryAsync="OnQueryAsync" IsPagination=true CustomerSearchModel="@CustomerSearchModel">
        <CustomerSearchTemplate>
        @if (context is SqlDBPageInput model)
            {
                @Render(model)
            }
        </CustomerSearchTemplate>
    <TableColumns>
        <TableColumn @bind-Field="@context.DeviceName" ShowTips=true Filterable=true Sortable=true Visible=true />
        <TableColumn @bind-Field="@context.Name" ShowTips=true Filterable=true Sortable=true Visible=true />
        <TableColumn @bind-Field="@context.Value" ShowTips=true Filterable=true Sortable=true Visible=true />
        <TableColumn Field="@context.CollectTime" ShowTips=true FieldExpression=@(()=>context.CollectTime) Filterable=true Sortable=true Visible=true />
        <TableColumn Field="@context.IsOnline" FieldExpression=@(()=>context.IsOnline) Filterable=true Sortable=true Visible=true />
        <TableColumn @bind-Field="@context.Id" Visible="false" DefaultSort=true DefaultSortOrder="SortOrder.Asc" />

    </TableColumns>
    </AdminTable>

@code {
    RenderFragment Render(SqlDBPageInput model) =>
    @<div class="row form-inline g-2">
        <div class="col-12 ">
            <BootstrapInput @bind-Value="model.VariableName" ShowLabel="true" />
        </div>
        <div class="col-12 ">
            <DateTimeRange @bind-Value="model.SearchDate" ShowLabel="true" />
        </div>
    </div>;

}
