72 lines
3.1 KiB
Plaintext
72 lines
3.1 KiB
Plaintext
@page "/admin/subscriptions/"
|
|
@using Moonlight.App.Services
|
|
@using Moonlight.App.Database.Entities
|
|
@using Moonlight.App.Repositories
|
|
@using BlazorTable
|
|
|
|
@inject SmartTranslateService SmartTranslateService
|
|
@inject SubscriptionRepository SubscriptionRepository
|
|
|
|
<OnlyAdmin>
|
|
<div class="card">
|
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
|
<div class="card-header border-0 pt-5">
|
|
<h3 class="card-title align-items-start flex-column">
|
|
<span class="card-label fw-bold fs-3 mb-1">
|
|
<TL>Subscriptions</TL>
|
|
</span>
|
|
</h3>
|
|
<div class="card-toolbar">
|
|
<a href="/admin/subscriptions/new" class="btn btn-sm btn-light-success">
|
|
<i class="bx bx-credit-card"></i>
|
|
<TL>New subscription</TL>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<Table TableItem="Subscription" Items="Subscriptions" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
|
<Column TableItem="Subscription" Title="@(SmartTranslateService.Translate("Id"))" Field="@(x => x.Id)" Sortable="true" Filterable="true"/>
|
|
<Column TableItem="Subscription" Title="@(SmartTranslateService.Translate("Name"))" Field="@(x => x.Name)" Sortable="true" Filterable="true"/>
|
|
<Column TableItem="Subscription" Title="@(SmartTranslateService.Translate("Description"))" Field="@(x => x.Description)" Sortable="true" Filterable="true"/>
|
|
<Column TableItem="Subscription" Title="@(SmartTranslateService.Translate("Manage"))" Field="@(x => x.Id)" Sortable="false" Filterable="false">
|
|
<Template>
|
|
<a href="/admin/subscriptions/edit/@(context.Id)/">
|
|
<TL>Manage</TL>
|
|
</a>
|
|
</Template>
|
|
</Column>
|
|
<Column TableItem="Subscription" Title="@(SmartTranslateService.Translate("Manage"))" Field="@(x => x.Id)" Sortable="false" Filterable="false">
|
|
<Template>
|
|
<DeleteButton Confirm="true" OnClick="() => Delete(context)" />
|
|
</Template>
|
|
</Column>
|
|
<Pager ShowPageNumber="true" ShowTotalCount="true"/>
|
|
</Table>
|
|
</div>
|
|
</div>
|
|
</LazyLoader>
|
|
</div>
|
|
</OnlyAdmin>
|
|
|
|
@code
|
|
{
|
|
private Subscription[] Subscriptions;
|
|
private LazyLoader LazyLoader;
|
|
|
|
private Task Load(LazyLoader arg)
|
|
{
|
|
Subscriptions = SubscriptionRepository
|
|
.Get()
|
|
.ToArray();
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private async Task Delete(Subscription subscription)
|
|
{
|
|
SubscriptionRepository.Delete(subscription);
|
|
|
|
await LazyLoader.Reload();
|
|
}
|
|
} |