Implemented service admin view
This commit is contained in:
parent
e8706cad1c
commit
0f989a38c3
4 changed files with 166 additions and 4 deletions
|
@ -84,6 +84,17 @@
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<div class="menu-item">
|
||||
<a class="menu-link " href="/admin/services">
|
||||
<span class="menu-icon">
|
||||
<i class="bx bx-sm bx-cube"></i>
|
||||
</span>
|
||||
<span class="menu-title">
|
||||
Services
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="menu-item">
|
||||
<a class="menu-link " href="/admin/store">
|
||||
<span class="menu-icon">
|
||||
|
|
71
Moonlight/Shared/Views/Admin/Services/Index.razor
Normal file
71
Moonlight/Shared/Views/Admin/Services/Index.razor
Normal file
|
@ -0,0 +1,71 @@
|
|||
@page "/admin/services"
|
||||
|
||||
@using Moonlight.App.Extensions.Attributes
|
||||
@using Moonlight.App.Models.Enums
|
||||
@using Moonlight.App.Repositories
|
||||
@using Moonlight.App.Database.Entities.Store
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using BlazorTable
|
||||
|
||||
@attribute [RequirePermission(Permission.AdminServices)]
|
||||
|
||||
@inject Repository<Service> ServiceRepository
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Services</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<LazyLoader Load="Load">
|
||||
<Table TableItem="Service"
|
||||
Items="Services"
|
||||
PageSize="50"
|
||||
TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3 fs-6"
|
||||
TableHeadClass="fw-bold text-muted">
|
||||
<Column TableItem="Service" Field="@(x => x.Id)" Title="Id" Filterable="true" Sortable="true"/>
|
||||
<Column TableItem="Service" Field="@(x => x.Nickname)" Title="Name" Filterable="true" Sortable="false">
|
||||
<Template>
|
||||
<a href="/admin/services/view/@(context.Id)">@(context.Nickname ?? $"Service {context.Id}")</a>
|
||||
</Template>
|
||||
</Column>
|
||||
<Column TableItem="Service" Field="@(x => x.Owner)" Title="Owner" Filterable="false" Sortable="false">
|
||||
<Template>
|
||||
<span>@(context.Owner.Username)</span>
|
||||
</Template>
|
||||
</Column>
|
||||
<Column TableItem="Service" Field="@(x => x.Product)" Title="Type" Filterable="false" Sortable="false">
|
||||
<Template>
|
||||
<span>@(context.Product.Type)</span>
|
||||
</Template>
|
||||
</Column>
|
||||
<Column TableItem="Service" Field="@(x => x.Product)" Title="Product" Filterable="false" Sortable="false">
|
||||
<Template>
|
||||
<span>@(context.Product.Name)</span>
|
||||
</Template>
|
||||
</Column>
|
||||
<Column TableItem="Service" Field="@(x => x.CreatedAt)" Title="Created at" Filterable="true" Sortable="true"/>
|
||||
<Column TableItem="Service" Field="@(x => x.Id)" Title="" Filterable="false" Sortable="false">
|
||||
<Template>
|
||||
<a href="/service/@(context.Id)">View as user</a>
|
||||
</Template>
|
||||
</Column>
|
||||
</Table>
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
private Service[] Services;
|
||||
|
||||
private Task Load(LazyLoader lazyLoader)
|
||||
{
|
||||
Services = ServiceRepository
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Include(x => x.Product)
|
||||
.ToArray();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
81
Moonlight/Shared/Views/Admin/Services/View.razor
Normal file
81
Moonlight/Shared/Views/Admin/Services/View.razor
Normal file
|
@ -0,0 +1,81 @@
|
|||
@page "/admin/services/view/{Id:int}/{Route?}"
|
||||
|
||||
@using Moonlight.App.Repositories
|
||||
@using Moonlight.App.Database.Entities.Store
|
||||
@using Moonlight.App.Services.ServiceManage
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Moonlight.App.Extensions.Attributes
|
||||
@using Moonlight.App.Models.Abstractions.Services
|
||||
@using Moonlight.App.Models.Enums
|
||||
@using Moonlight.App.Services
|
||||
|
||||
@attribute [RequirePermission(Permission.AdminServices)]
|
||||
|
||||
@inject Repository<Service> ServiceRepository
|
||||
@inject ServiceService ServiceService
|
||||
@inject IdentityService IdentityService
|
||||
@inject PluginService PluginService
|
||||
|
||||
<LazyLoader Load="Load" ShowAsCard="true">
|
||||
@if (Service == null)
|
||||
{
|
||||
<NotFoundAlert />
|
||||
}
|
||||
else
|
||||
{
|
||||
<CascadingValue Name="Service" Value="Service">
|
||||
<CascadingValue Name="Implementation" Value="Definition">
|
||||
<CascadingValue Name="Route" Value="Route">
|
||||
<CascadingValue Name="ViewContext" Value="ViewContext">
|
||||
@ViewContext.Layout
|
||||
</CascadingValue>
|
||||
</CascadingValue>
|
||||
</CascadingValue>
|
||||
</CascadingValue>
|
||||
}
|
||||
</LazyLoader>
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string? Route { get; set; }
|
||||
|
||||
private Service? Service;
|
||||
private ServiceDefinition Definition;
|
||||
private ServiceViewContext ViewContext;
|
||||
|
||||
private async Task Load(LazyLoader lazyLoader)
|
||||
{
|
||||
await lazyLoader.SetText("Requesting service");
|
||||
|
||||
// Load service with relational data
|
||||
Service = ServiceRepository
|
||||
.Get()
|
||||
.Include(x => x.Product)
|
||||
.Include(x => x.Owner)
|
||||
.FirstOrDefault(x => x.Id == Id);
|
||||
|
||||
if(Service == null)
|
||||
return;
|
||||
|
||||
// Load implementation
|
||||
await lazyLoader.SetText("Loading implementation");
|
||||
Definition = ServiceService.Definition.Get(Service.Product.Type);
|
||||
|
||||
// Build dynamic user interface
|
||||
await lazyLoader.SetText("Building dynamic user interface");
|
||||
|
||||
ViewContext = new ServiceViewContext()
|
||||
{
|
||||
Service = Service,
|
||||
Product = Service.Product,
|
||||
User = IdentityService.CurrentUser
|
||||
};
|
||||
|
||||
await Definition.BuildAdminView(ViewContext);
|
||||
await PluginService.BuildAdminServiceView(ViewContext);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
@using Moonlight.App.Database.Entities.Store
|
||||
@using Moonlight.App.Services.ServiceManage
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Moonlight.App.Models.Abstractions
|
||||
@using Moonlight.App.Models.Abstractions.Services
|
||||
@using Moonlight.App.Services
|
||||
|
||||
|
|
Loading…
Reference in a new issue