@page "/gateway/plugin"
@attribute [Authorize]
@attribute [RolePermission]

@namespace ThingsGateway.Gateway.Razor
@using BootstrapBlazor.Components
@using ThingsGateway.Admin.Application
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Gateway.Application
@inherits ComponentDefault


<div class="h-100">
    <AdminTable @ref=table TItem="PluginInfo"
                AutoGenerateColumns="true"
                ShowDefaultButtons=false
                EditDialogSize="Size.Large"
                AllowResizing="true"
                IsFixedHeader=true
                ShowSearch="false"
                IsMultipleSelect=false
                ShowExtendEditButton=false
                ShowExtendDeleteButton=false
                ShowExtendButtons=false
                ShowExportButton="true"
                ShowAdvancedSearch=false
                SearchModel=SearchModel
                OnQueryAsync="OnQueryAsync">

        <TableToolbarTemplate>
            <TableToolbarButton TItem="PluginInfo" Color="Color.Info" Icon="fa fa-plus" Text="@RazorLocalizer["Add"]"
                                OnClickCallback="OnAdd" IsShow=@(AuthorizeButton("添加")) />

            <TableToolbarButton TItem="PluginInfo" Color="Color.Warning" Icon="fa-solid fa-rotate" Text="@PluginPageLoaclozer["Reload"]"
                                OnClick="OnReload" IsShow=@(AuthorizeButton("添加")) />

        </TableToolbarTemplate>
        <TableColumns>
            <TableColumn @bind-Field="@context.Name">
                <Template Context="name">
                    @if (name.Row.EducationPlugin)
                    {
                        <span>@name.Value</span>
                        <div style="flex-grow: 1;"></div>
                        <Tag Color="Color.Primary">PRO</Tag>
                    }
                    else
                    {
                        <span>@name.Value</span>
                    }
                </Template>
            </TableColumn>
        </TableColumns>

        <ExportButtonDropdownTemplate Context="ExportContext">
            <div class="dropdown-item" @onclick="() => ExcelExportAsync(ExportContext)" IsDisabled=@(!AuthorizeButton("导出"))>
                <i class="fas fa-file-export"></i>
                <span>@RazorLocalizer["TablesExportButtonExcelText"]</span>
            </div>
        </ExportButtonDropdownTemplate>
    </AdminTable>
</div>
@code {
    AdminTable<PluginInfo> table;
}
