Created static object provider + added some properties
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
@page "/counter"
|
||||
@using System.Text.Json
|
||||
@using HopFrame.Web
|
||||
@using HopFrame.Web.Admin.Providers
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<PageTitle>Counter</PageTitle>
|
||||
@@ -9,12 +12,20 @@
|
||||
|
||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
||||
|
||||
@inject IAdminPagesProvider Provider
|
||||
|
||||
@code {
|
||||
private int currentCount = 0;
|
||||
private string[] permissions = ["web.counter"];
|
||||
|
||||
private void IncrementCount() {
|
||||
currentCount++;
|
||||
|
||||
string json = JsonSerializer.Serialize(Provider.LoadRegisteredAdminPages(), new JsonSerializerOptions {
|
||||
WriteIndented = true
|
||||
});
|
||||
|
||||
Console.WriteLine(json);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
using HopFrame.Database.Models;
|
||||
using HopFrame.Web.Admin;
|
||||
using HopFrame.Web.Admin.Generators;
|
||||
using HopFrame.Web.Admin.Models;
|
||||
|
||||
namespace RestApiTest;
|
||||
|
||||
public class AdminContext : AdminPagesContext {
|
||||
|
||||
public AdminPage<User> Users { get; set; }
|
||||
public AdminPage<PermissionGroup> Groups { get; set; }
|
||||
|
||||
public override void OnModelCreating(IAdminContextGenerator generator) {
|
||||
|
||||
/*generator.Page<User>()
|
||||
.Title("Users")
|
||||
.Description("On this page you can manage all user accounts.")
|
||||
.UpdatePermission("update")
|
||||
.ViewPermission("view")
|
||||
.DeletePermission("delete")
|
||||
.CreatePermission("create")
|
||||
.DefaultSort(u => u.Id, ListSortDirection.Descending);*/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace RestApiTest.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("test")]
|
||||
public class TestController(ITokenContext userContext, DatabaseContext context, AdminContext adminContext) : ControllerBase {
|
||||
public class TestController(ITokenContext userContext, DatabaseContext context) : ControllerBase {
|
||||
|
||||
[HttpGet("permissions"), Authorized]
|
||||
public ActionResult<IList<Permission>> Permissions() {
|
||||
@@ -50,10 +50,5 @@ public class TestController(ITokenContext userContext, DatabaseContext context,
|
||||
public async Task<ActionResult<IList<Address>>> GetAddresses() {
|
||||
return LogicResult<IList<Address>>.Ok(await context.Addresses.Include(e => e.Employee).ToListAsync());
|
||||
}
|
||||
|
||||
[HttpGet("adminContext")]
|
||||
public ActionResult<AdminContext> GetAdminContext() {
|
||||
return LogicResult<AdminContext>.Ok(adminContext);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using RestApiTest;
|
||||
using HopFrame.Api.Extensions;
|
||||
using HopFrame.Web.Admin;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -14,7 +13,6 @@ builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddDbContext<DatabaseContext>();
|
||||
builder.Services.AddAdminContext<AdminContext>();
|
||||
|
||||
builder.Services.AddSwaggerGen(c => {
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme {
|
||||
|
||||
Reference in New Issue
Block a user