Updated the usage of mooncore components
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Extended.Helpers;
|
using MoonCore.Extended.Helpers;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System.Diagnostics;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Helpers;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonlightServers.ApiServer.Database.Entities;
|
using MoonlightServers.ApiServer.Database.Entities;
|
||||||
using MoonlightServers.ApiServer.Services;
|
using MoonlightServers.ApiServer.Services;
|
||||||
using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Sys;
|
using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Sys;
|
||||||
@@ -11,18 +11,19 @@ namespace MoonlightServers.ApiServer.Http.Controllers.Admin.Nodes;
|
|||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/admin/servers/nodes")]
|
[Route("api/admin/servers/nodes")]
|
||||||
public class NodeSystemController : Controller
|
public class NodeStatusController : Controller
|
||||||
{
|
{
|
||||||
private readonly DatabaseRepository<Node> NodeRepository;
|
private readonly DatabaseRepository<Node> NodeRepository;
|
||||||
private readonly NodeService NodeService;
|
private readonly NodeService NodeService;
|
||||||
|
|
||||||
public NodeSystemController(DatabaseRepository<Node> nodeRepository, NodeService nodeService)
|
public NodeStatusController(DatabaseRepository<Node> nodeRepository, NodeService nodeService)
|
||||||
{
|
{
|
||||||
NodeRepository = nodeRepository;
|
NodeRepository = nodeRepository;
|
||||||
NodeService = nodeService;
|
NodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{nodeId}/system/status")]
|
[HttpGet("{nodeId}/system/status")]
|
||||||
|
[RequirePermission("admin.servers.nodes.status")]
|
||||||
public async Task<NodeSystemStatusResponse> GetStatus([FromRoute] int nodeId)
|
public async Task<NodeSystemStatusResponse> GetStatus([FromRoute] int nodeId)
|
||||||
{
|
{
|
||||||
var node = GetNode(nodeId);
|
var node = GetNode(nodeId);
|
||||||
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Extended.Helpers;
|
using MoonCore.Extended.Helpers;
|
||||||
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Helpers;
|
using MoonCore.Helpers;
|
||||||
using MoonCore.Models;
|
using MoonCore.Models;
|
||||||
using MoonlightServers.ApiServer.Database.Entities;
|
using MoonlightServers.ApiServer.Database.Entities;
|
||||||
@@ -28,18 +29,21 @@ public class NodesController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
[RequirePermission("admin.servers.nodes.get")]
|
||||||
public async Task<IPagedData<NodeDetailResponse>> Get([FromQuery] int page, [FromQuery] int pageSize)
|
public async Task<IPagedData<NodeDetailResponse>> Get([FromQuery] int page, [FromQuery] int pageSize)
|
||||||
{
|
{
|
||||||
return await CrudHelper.Get(page, pageSize);
|
return await CrudHelper.Get(page, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("{id:int}")]
|
||||||
|
[RequirePermission("admin.servers.nodes.get")]
|
||||||
public async Task<NodeDetailResponse> GetSingle([FromRoute] int id)
|
public async Task<NodeDetailResponse> GetSingle([FromRoute] int id)
|
||||||
{
|
{
|
||||||
return await CrudHelper.GetSingle(id);
|
return await CrudHelper.GetSingle(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
[RequirePermission("admin.servers.nodes.create")]
|
||||||
public async Task<NodeDetailResponse> Create([FromBody] CreateNodeRequest request)
|
public async Task<NodeDetailResponse> Create([FromBody] CreateNodeRequest request)
|
||||||
{
|
{
|
||||||
var node = Mapper.Map<Node>(request);
|
var node = Mapper.Map<Node>(request);
|
||||||
@@ -52,12 +56,14 @@ public class NodesController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch("{id:int}")]
|
[HttpPatch("{id:int}")]
|
||||||
|
[RequirePermission("admin.servers.nodes.update")]
|
||||||
public async Task<NodeDetailResponse> Update([FromRoute] int id, [FromBody] UpdateNodeRequest request)
|
public async Task<NodeDetailResponse> Update([FromRoute] int id, [FromBody] UpdateNodeRequest request)
|
||||||
{
|
{
|
||||||
return await CrudHelper.Update(id, request);
|
return await CrudHelper.Update(id, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{id:int}")]
|
[HttpDelete("{id:int}")]
|
||||||
|
[RequirePermission("admin.servers.nodes.delete")]
|
||||||
public async Task Delete([FromRoute] int id)
|
public async Task Delete([FromRoute] int id)
|
||||||
{
|
{
|
||||||
await CrudHelper.Delete(id);
|
await CrudHelper.Delete(id);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Helpers;
|
using MoonCore.Helpers;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Extended.Helpers;
|
using MoonCore.Extended.Helpers;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Extended.Helpers;
|
using MoonCore.Extended.Helpers;
|
||||||
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Helpers;
|
using MoonCore.Helpers;
|
||||||
using MoonCore.Models;
|
using MoonCore.Models;
|
||||||
using MoonlightServers.ApiServer.Database.Entities;
|
using MoonlightServers.ApiServer.Database.Entities;
|
||||||
@@ -48,6 +49,7 @@ public class StarDockerImagesController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{starId:int}/dockerImages")]
|
[HttpGet("{starId:int}/dockerImages")]
|
||||||
|
[RequirePermission("admin.servers.stars.get")]
|
||||||
public async Task<IPagedData<StarDockerImageDetailResponse>> Get([FromRoute] int starId, [FromQuery] int page, [FromQuery] int pageSize)
|
public async Task<IPagedData<StarDockerImageDetailResponse>> Get([FromRoute] int starId, [FromQuery] int page, [FromQuery] int pageSize)
|
||||||
{
|
{
|
||||||
await ApplyStar(starId);
|
await ApplyStar(starId);
|
||||||
@@ -56,6 +58,7 @@ public class StarDockerImagesController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{starId:int}/dockerImages/{id:int}")]
|
[HttpGet("{starId:int}/dockerImages/{id:int}")]
|
||||||
|
[RequirePermission("admin.servers.stars.get")]
|
||||||
public async Task<StarDockerImageDetailResponse> GetSingle([FromRoute] int starId, [FromRoute] int id)
|
public async Task<StarDockerImageDetailResponse> GetSingle([FromRoute] int starId, [FromRoute] int id)
|
||||||
{
|
{
|
||||||
await ApplyStar(starId);
|
await ApplyStar(starId);
|
||||||
@@ -64,6 +67,7 @@ public class StarDockerImagesController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{starId:int}/dockerImages")]
|
[HttpPost("{starId:int}/dockerImages")]
|
||||||
|
[RequirePermission("admin.servers.stars.create")]
|
||||||
public async Task<StarDockerImageDetailResponse> Create([FromRoute] int starId, [FromBody] CreateStarDockerImageRequest request)
|
public async Task<StarDockerImageDetailResponse> Create([FromRoute] int starId, [FromBody] CreateStarDockerImageRequest request)
|
||||||
{
|
{
|
||||||
await ApplyStar(starId);
|
await ApplyStar(starId);
|
||||||
@@ -77,6 +81,7 @@ public class StarDockerImagesController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch("{starId:int}/dockerImages/{id:int}")]
|
[HttpPatch("{starId:int}/dockerImages/{id:int}")]
|
||||||
|
[RequirePermission("admin.servers.stars.update")]
|
||||||
public async Task<StarDockerImageDetailResponse> Update([FromRoute] int starId, [FromRoute] int id,
|
public async Task<StarDockerImageDetailResponse> Update([FromRoute] int starId, [FromRoute] int id,
|
||||||
[FromBody] UpdateStarDockerImageRequest request)
|
[FromBody] UpdateStarDockerImageRequest request)
|
||||||
{
|
{
|
||||||
@@ -86,6 +91,7 @@ public class StarDockerImagesController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{starId:int}/dockerImages/{id:int}")]
|
[HttpDelete("{starId:int}/dockerImages/{id:int}")]
|
||||||
|
[RequirePermission("admin.servers.stars.delete")]
|
||||||
public async Task Delete([FromRoute] int starId, [FromRoute] int id)
|
public async Task Delete([FromRoute] int starId, [FromRoute] int id)
|
||||||
{
|
{
|
||||||
await ApplyStar(starId);
|
await ApplyStar(starId);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Helpers;
|
using MoonCore.Helpers;
|
||||||
using MoonlightServers.ApiServer.Services;
|
using MoonlightServers.ApiServer.Services;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Extended.Helpers;
|
using MoonCore.Extended.Helpers;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Extended.Helpers;
|
using MoonCore.Extended.Helpers;
|
||||||
using MoonCore.Helpers;
|
using MoonCore.Helpers;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Extended.PermFilter;
|
||||||
using MoonCore.Exceptions;
|
using MoonCore.Exceptions;
|
||||||
using MoonCore.Extended.Abstractions;
|
using MoonCore.Extended.Abstractions;
|
||||||
using MoonCore.Extensions;
|
using MoonCore.Extensions;
|
||||||
@@ -31,14 +31,15 @@ public class ServersController : Controller
|
|||||||
[RequirePermission("meta.authenticated")]
|
[RequirePermission("meta.authenticated")]
|
||||||
public async Task<PagedData<ServerDetailResponse>> GetAll([FromQuery] int page, [FromQuery] int pageSize)
|
public async Task<PagedData<ServerDetailResponse>> GetAll([FromQuery] int page, [FromQuery] int pageSize)
|
||||||
{
|
{
|
||||||
var user = User.AsIdentity<User>();
|
var userIdClaim = User.Claims.First(x => x.Type == "userId");
|
||||||
|
var userId = int.Parse(userIdClaim.Value);
|
||||||
|
|
||||||
var query = ServerRepository
|
var query = ServerRepository
|
||||||
.Get()
|
.Get()
|
||||||
.Include(x => x.Allocations)
|
.Include(x => x.Allocations)
|
||||||
.Include(x => x.Star)
|
.Include(x => x.Star)
|
||||||
.Include(x => x.Node)
|
.Include(x => x.Node)
|
||||||
.Where(x => x.OwnerId == user.Id);
|
.Where(x => x.OwnerId == userId);
|
||||||
|
|
||||||
var count = await query.CountAsync();
|
var count = await query.CountAsync();
|
||||||
var items = await query.Skip(page * pageSize).Take(pageSize).ToArrayAsync();
|
var items = await query.Skip(page * pageSize).Take(pageSize).ToArrayAsync();
|
||||||
@@ -177,7 +178,8 @@ public class ServersController : Controller
|
|||||||
private async Task<Server> GetServerWithPermCheck(int serverId,
|
private async Task<Server> GetServerWithPermCheck(int serverId,
|
||||||
Func<IQueryable<Server>, IQueryable<Server>>? queryModifier = null)
|
Func<IQueryable<Server>, IQueryable<Server>>? queryModifier = null)
|
||||||
{
|
{
|
||||||
var user = User.AsIdentity<User>();
|
var userIdClaim = User.Claims.First(x => x.Type == "userId");
|
||||||
|
var userId = int.Parse(userIdClaim.Value);
|
||||||
|
|
||||||
var query = ServerRepository
|
var query = ServerRepository
|
||||||
.Get()
|
.Get()
|
||||||
@@ -192,7 +194,7 @@ public class ServersController : Controller
|
|||||||
if (server == null)
|
if (server == null)
|
||||||
throw new HttpApiException("No server with this id found", 404);
|
throw new HttpApiException("No server with this id found", 404);
|
||||||
|
|
||||||
if (server.OwnerId == user.Id) // The current user is the owner
|
if (server.OwnerId == userId) // The current user is the owner
|
||||||
return server;
|
return server;
|
||||||
|
|
||||||
if (User.HasPermission("admin.servers.get")) // The current user is an admin
|
if (User.HasPermission("admin.servers.get")) // The current user is an admin
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
"applicationUrl": "http://localhost:5269",
|
"applicationUrl": "http://localhost:5269",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
"MOONLIGHT_APP_PUBLICURL": "http://localhost:5269"
|
"MOONLIGHT_APP_PUBLICURL": "http://localhost:5269",
|
||||||
|
"HTTP_PROXY": "",
|
||||||
|
"HTTPS_PROXY": ""
|
||||||
},
|
},
|
||||||
"commandLineArgs": "--frontend-asset js/XtermBlazor.min.js --frontend-asset js/moonlightServers.js --frontend-asset js/addon-fit.js"
|
"commandLineArgs": "--frontend-asset js/XtermBlazor.min.js --frontend-asset js/moonlightServers.js --frontend-asset js/addon-fit.js"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
using MoonCore.Blazor.Tailwind.Forms;
|
|
||||||
using MoonCore.Blazor.Tailwind.Forms.Components;
|
|
||||||
using Moonlight.Client;
|
using Moonlight.Client;
|
||||||
|
|
||||||
FormComponentRepository.Set<bool, SwitchComponent>();
|
|
||||||
|
|
||||||
var startup = new Startup();
|
var startup = new Startup();
|
||||||
|
|
||||||
await startup.Run(args, [
|
await startup.Run(args, [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@using MoonCore.Blazor.Tailwind.Alerts
|
@using MoonCore.Blazor.Tailwind.Alerts
|
||||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||||
@using MoonCore.Blazor.Tailwind.DataTable
|
@using MoonCore.Blazor.Tailwind.Dt
|
||||||
@using MoonCore.Blazor.Tailwind.Modals
|
@using MoonCore.Blazor.Tailwind.Modals
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@@ -31,15 +31,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-1 md:col-span-2 -mb-3">
|
<div class="col-span-1 md:col-span-2 -mb-3">
|
||||||
<ItemDataTable @ref="Table"
|
<DataTable @ref="Table" TItem="NodeAllocationDetailResponse" LoadItemsPaginatedAsync="LoadData">
|
||||||
TItem="NodeAllocationDetailResponse"
|
<Configuration>
|
||||||
Title=""
|
<DataTableColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.IpAddress)" Name="IP Address"/>
|
||||||
ItemLoader="Load">
|
<DataTableColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.Port)" Name="Port"/>
|
||||||
<ChildContent>
|
<DataTableColumn TItem="NodeAllocationDetailResponse">
|
||||||
<DataColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.IpAddress)" Title="IP Address"/>
|
<ColumnTemplate>
|
||||||
<DataColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.Port)" Title="Port"/>
|
|
||||||
<DataColumn TItem="NodeAllocationDetailResponse" Title="">
|
|
||||||
<Template>
|
|
||||||
<div class="flex justify-end items-center">
|
<div class="flex justify-end items-center">
|
||||||
<a @onclick="() => UpdateAllocation(context)" @onclick:preventDefault href="#"
|
<a @onclick="() => UpdateAllocation(context)" @onclick:preventDefault href="#"
|
||||||
class="text-primary-500 mr-2 sm:mr-3">
|
class="text-primary-500 mr-2 sm:mr-3">
|
||||||
@@ -50,10 +47,10 @@
|
|||||||
<i class="icon-trash text-base"></i>
|
<i class="icon-trash text-base"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</Template>
|
</ColumnTemplate>
|
||||||
</DataColumn>
|
</DataTableColumn>
|
||||||
</ChildContent>
|
</Configuration>
|
||||||
</ItemDataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -61,12 +58,12 @@
|
|||||||
{
|
{
|
||||||
[Parameter] public NodeDetailResponse Node { get; set; }
|
[Parameter] public NodeDetailResponse Node { get; set; }
|
||||||
|
|
||||||
private ItemDataTable<NodeAllocationDetailResponse> Table;
|
private DataTable<NodeAllocationDetailResponse> Table;
|
||||||
|
|
||||||
private async Task<IPagedData<NodeAllocationDetailResponse>> Load(int page, int pageSize)
|
private async Task<IPagedData<NodeAllocationDetailResponse>> LoadData(PaginationOptions options)
|
||||||
{
|
{
|
||||||
return await ApiClient.GetJson<PagedData<NodeAllocationDetailResponse>>(
|
return await ApiClient.GetJson<PagedData<NodeAllocationDetailResponse>>(
|
||||||
$"api/admin/servers/nodes/{Node.Id}/allocations?page={page}&pageSize={pageSize}"
|
$"api/admin/servers/nodes/{Node.Id}/allocations?page={options.Page}&pageSize={options.PerPage}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +74,7 @@
|
|||||||
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations/range", request);
|
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations/range", request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully created allocations");
|
await ToastService.Success("Successfully created allocations");
|
||||||
await Table.Refresh(isSilent: false, bypassCache: true);
|
await Table.Refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
await ModalService.Launch<CreateMultipleAllocationModal>(parameters =>
|
await ModalService.Launch<CreateMultipleAllocationModal>(parameters =>
|
||||||
@@ -93,7 +90,7 @@
|
|||||||
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations", request);
|
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations", request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully created allocation");
|
await ToastService.Success("Successfully created allocation");
|
||||||
await Table.Refresh(isSilent: false, bypassCache: true);
|
await Table.Refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
await ModalService.Launch<CreateAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
|
await ModalService.Launch<CreateAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
|
||||||
@@ -106,7 +103,7 @@
|
|||||||
await ApiClient.Patch($"api/admin/servers/nodes/{Node.Id}/allocations/{allocation.Id}", request);
|
await ApiClient.Patch($"api/admin/servers/nodes/{Node.Id}/allocations/{allocation.Id}", request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully updated allocation");
|
await ToastService.Success("Successfully updated allocation");
|
||||||
await Table.Refresh(isSilent: false, bypassCache: true);
|
await Table.Refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
await ModalService.Launch<UpdateAllocationModal>(parameters =>
|
await ModalService.Launch<UpdateAllocationModal>(parameters =>
|
||||||
@@ -126,7 +123,7 @@
|
|||||||
await ApiClient.Delete($"api/admin/servers/nodes/{Node.Id}/allocations/{allocation.Id}");
|
await ApiClient.Delete($"api/admin/servers/nodes/{Node.Id}/allocations/{allocation.Id}");
|
||||||
|
|
||||||
await ToastService.Success("Successfully deleted allocation");
|
await ToastService.Success("Successfully deleted allocation");
|
||||||
await Table.Refresh(isSilent: false, bypassCache: true);
|
await Table.Refresh();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -141,7 +138,7 @@
|
|||||||
await ApiClient.Delete($"api/admin/servers/nodes/{Node.Id}/allocations/all");
|
await ApiClient.Delete($"api/admin/servers/nodes/{Node.Id}/allocations/all");
|
||||||
|
|
||||||
await ToastService.Success("Successfully deleted allocations");
|
await ToastService.Success("Successfully deleted allocations");
|
||||||
await Table.Refresh(isSilent: false, bypassCache: true);
|
await Table.Refresh();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
||||||
|
@using MoonCore.Blazor.Tailwind.Ace
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||||
@@ -16,8 +17,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="sm:col-span-6">
|
<div class="sm:col-span-6">
|
||||||
<label class="block text-sm font-medium leading-6 text-white">Script</label>
|
<label class="block text-sm font-medium leading-6 text-white">Script</label>
|
||||||
<div class="mt-2">
|
<div class="mt-2" @onfocusout="OnFocusOut">
|
||||||
<textarea @bind="Request.InstallScript" class="form-textarea w-full"></textarea>
|
<CodeEditor @ref="CodeEditor" InitialContent="@Request.InstallScript" OnConfigure="OnConfigure" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -26,4 +27,16 @@
|
|||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
[Parameter] public UpdateStarRequest Request { get; set; }
|
[Parameter] public UpdateStarRequest Request { get; set; }
|
||||||
|
|
||||||
|
private CodeEditor CodeEditor;
|
||||||
|
|
||||||
|
private void OnConfigure(CodeEditorOptions options)
|
||||||
|
{
|
||||||
|
options.Mode = "ace/mode/sh";
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnFocusOut()
|
||||||
|
{
|
||||||
|
Request.InstallScript = await CodeEditor.GetValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
@page "/admin/servers/all/create"
|
@page "/admin/servers/all/create"
|
||||||
|
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
@using MoonCore.Blazor.Tailwind.Forms
|
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
||||||
@@ -12,10 +11,10 @@
|
|||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
|
|
||||||
<PageHeader Title="Create Server">
|
<PageHeader Title="Create Server">
|
||||||
<button @onclick="GoBack" type="button" class="btn btn-secondary">
|
<a href="/admin/servers/all" class="btn btn-secondary">
|
||||||
<i class="icon-chevron-left mr-1"></i>
|
<i class="icon-chevron-left mr-1"></i>
|
||||||
Back
|
Back
|
||||||
</button>
|
</a>
|
||||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||||
<i class="icon-check mr-1"></i>
|
<i class="icon-check mr-1"></i>
|
||||||
Create
|
Create
|
||||||
@@ -56,9 +55,6 @@
|
|||||||
await ApiClient.Post("api/admin/servers", Request);
|
await ApiClient.Post("api/admin/servers", Request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully created Server");
|
await ToastService.Success("Successfully created Server");
|
||||||
GoBack();
|
Navigation.NavigateTo("/admin/servers/all");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GoBack()
|
|
||||||
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
||||||
}
|
}
|
||||||
@@ -1,78 +1,85 @@
|
|||||||
@page "/admin/servers/all"
|
@page "/admin/servers/all"
|
||||||
|
|
||||||
@using MoonCore.Blazor.Tailwind.MinimalCrud
|
@using MoonCore.Blazor.Tailwind.Alerts
|
||||||
@using MoonCore.Blazor.Tailwind.DataTable
|
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonCore.Models
|
@using MoonCore.Models
|
||||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||||
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
|
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
|
||||||
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
|
@using MoonCore.Blazor.Tailwind.Dt
|
||||||
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
|
|
||||||
@inject HttpApiClient ApiClient
|
@inject HttpApiClient ApiClient
|
||||||
|
@inject AlertService AlertService
|
||||||
|
@inject ToastService ToastService
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<NavTabs Index="1" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
|
<NavTabs Index="1" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MinimalCrud TItem="ServerDetailResponse" OnConfigure="OnConfigure">
|
<div class="mb-5">
|
||||||
<ChildContent>
|
<PageHeader Title="Servers">
|
||||||
<DataColumn TItem="ServerDetailResponse" Field="@(x => x.Id)" Title="Id" IsSortable="true"/>
|
<a href="/admin/servers/all/create" class="btn btn-primary">
|
||||||
<DataColumn TItem="ServerDetailResponse" Field="@(x => x.Name)" Title="Name"/>
|
Create
|
||||||
<DataColumn TItem="ServerDetailResponse" Field="@(x => x.NodeId)" Title="Node">
|
</a>
|
||||||
<Template>
|
</PageHeader>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DataTable @ref="Table" TItem="ServerDetailResponse" PageSize="15" LoadItemsPaginatedAsync="LoadData">
|
||||||
|
<Configuration>
|
||||||
|
<DataTableColumn TItem="ServerDetailResponse" Field="@(x => x.Id)" Name="Id"/>
|
||||||
|
<DataTableColumn TItem="ServerDetailResponse" Field="@(x => x.Name)" Name="Name"/>
|
||||||
|
<DataTableColumn TItem="ServerDetailResponse" Field="@(x => x.NodeId)">
|
||||||
|
<ColumnTemplate>
|
||||||
@{
|
@{
|
||||||
var node = Nodes.FirstOrDefault(x => x.Id == context.NodeId);
|
var node = Nodes.FirstOrDefault(x => x.Id == context.NodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (node != null)
|
<span>
|
||||||
{
|
@(node?.Name ?? "N/A")
|
||||||
<span>@node.Name</span>
|
</span>
|
||||||
}
|
</ColumnTemplate>
|
||||||
else
|
</DataTableColumn>
|
||||||
{
|
<DataTableColumn TItem="ServerDetailResponse" Field="@(x => x.StarId)">
|
||||||
<span>N/A</span>
|
<ColumnTemplate>
|
||||||
}
|
|
||||||
</Template>
|
|
||||||
</DataColumn>
|
|
||||||
<DataColumn TItem="ServerDetailResponse" Field="@(x => x.StarId)" Title="Star">
|
|
||||||
<Template>
|
|
||||||
@{
|
@{
|
||||||
var star = Stars.FirstOrDefault(x => x.Id == context.StarId);
|
var star = Stars.FirstOrDefault(x => x.Id == context.StarId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (star != null)
|
<span>
|
||||||
{
|
@(star?.Name ?? "N/A")
|
||||||
<span>@star.Name</span>
|
</span>
|
||||||
}
|
</ColumnTemplate>
|
||||||
else
|
</DataTableColumn>
|
||||||
{
|
<DataTableColumn TItem="ServerDetailResponse">
|
||||||
<span>N/A</span>
|
<ColumnTemplate>
|
||||||
}
|
<div class="flex justify-end">
|
||||||
</Template>
|
<a href="/admin/servers/all/update/@(context.Id)" class="text-primary-500 mr-2 sm:mr-3">
|
||||||
</DataColumn>
|
<i class="icon-pencil text-base"></i>
|
||||||
</ChildContent>
|
</a>
|
||||||
</MinimalCrud>
|
|
||||||
|
<a href="#" @onclick="() => Delete(context)" @onclick:preventDefault
|
||||||
|
class="text-danger-500">
|
||||||
|
<i class="icon-trash text-base"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</ColumnTemplate>
|
||||||
|
</DataTableColumn>
|
||||||
|
</Configuration>
|
||||||
|
</DataTable>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
private DataTable<ServerDetailResponse> Table;
|
||||||
|
|
||||||
private List<StarDetailResponse> Stars = new();
|
private List<StarDetailResponse> Stars = new();
|
||||||
private List<NodeDetailResponse> Nodes = new();
|
private List<NodeDetailResponse> Nodes = new();
|
||||||
|
|
||||||
private void OnConfigure(MinimalCrudOptions<ServerDetailResponse> options)
|
private async Task<IPagedData<ServerDetailResponse>> LoadData(PaginationOptions options)
|
||||||
{
|
|
||||||
options.Title = "Servers";
|
|
||||||
options.ItemLoader = LoadItems;
|
|
||||||
|
|
||||||
options.CreateUrl = ComponentHelper.GetRouteOfComponent<Create>();
|
|
||||||
options.UpdateUrl = item => ComponentHelper.GetRouteOfComponent<Update>(item.Id)!;
|
|
||||||
options.DeleteFunction = async item => await ApiClient.Delete($"api/admin/servers/{item.Id}");
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<IPagedData<ServerDetailResponse>> LoadItems(int page, int pageSize)
|
|
||||||
{
|
{
|
||||||
// Clear potential previous data
|
// Clear potential previous data
|
||||||
var data = await ApiClient.GetJson<PagedData<ServerDetailResponse>>($"api/admin/servers?page={page}&pageSize={pageSize}");
|
var data = await ApiClient.GetJson<PagedData<ServerDetailResponse>>($"api/admin/servers?page={options.Page}&pageSize={options.PerPage}");
|
||||||
|
|
||||||
foreach (var item in data.Items)
|
foreach (var item in data.Items)
|
||||||
{
|
{
|
||||||
@@ -91,4 +98,19 @@
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task Delete(ServerDetailResponse detailResponse)
|
||||||
|
{
|
||||||
|
await AlertService.ConfirmDanger(
|
||||||
|
"Server deletion",
|
||||||
|
$"Do you really want to delete the server '{detailResponse.Name}'",
|
||||||
|
async () =>
|
||||||
|
{
|
||||||
|
await ApiClient.Delete($"api/admin/servers/{detailResponse.Id}");
|
||||||
|
await ToastService.Success("Successfully deleted server");
|
||||||
|
|
||||||
|
await Table.Refresh();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
@page "/admin/servers/all/update/{Id:int}"
|
@page "/admin/servers/all/update/{Id:int}"
|
||||||
|
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
@using MoonCore.Blazor.Tailwind.Forms
|
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
||||||
@@ -14,10 +13,10 @@
|
|||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<PageHeader Title="Update Server">
|
<PageHeader Title="Update Server">
|
||||||
<button @onclick="GoBack" type="button" class="btn btn-secondary">
|
<a href="/admin/servers/all" class="btn btn-secondary">
|
||||||
<i class="icon-chevron-left mr-1"></i>
|
<i class="icon-chevron-left mr-1"></i>
|
||||||
Back
|
Back
|
||||||
</button>
|
</a>
|
||||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||||
<i class="icon-check mr-1"></i>
|
<i class="icon-check mr-1"></i>
|
||||||
Update
|
Update
|
||||||
@@ -62,10 +61,7 @@
|
|||||||
{
|
{
|
||||||
await ApiClient.Patch($"api/admin/servers/{Id}", Request);
|
await ApiClient.Patch($"api/admin/servers/{Id}", Request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully updated Server");
|
await ToastService.Success("Successfully updated server");
|
||||||
GoBack();
|
Navigation.NavigateTo("/admin/servers/all");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GoBack()
|
|
||||||
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
@page "/admin/servers/nodes/create"
|
@page "/admin/servers/nodes/create"
|
||||||
|
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
@using MoonCore.Blazor.Tailwind.Forms
|
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
||||||
@@ -11,10 +10,10 @@
|
|||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
|
|
||||||
<PageHeader Title="Create Node">
|
<PageHeader Title="Create Node">
|
||||||
<button @onclick="GoBack" type="button" class="btn btn-secondary">
|
<a href="/admin/servers/nodes" class="btn btn-secondary">
|
||||||
<i class="icon-chevron-left mr-1"></i>
|
<i class="icon-chevron-left mr-1"></i>
|
||||||
Back
|
Back
|
||||||
</button>
|
</a>
|
||||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||||
<i class="icon-check mr-1"></i>
|
<i class="icon-check mr-1"></i>
|
||||||
Create
|
Create
|
||||||
@@ -23,12 +22,40 @@
|
|||||||
|
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
||||||
<GeneratedForm TForm="CreateNodeRequest" Model="Request" OnConfigure="OnConfigure"/>
|
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-medium leading-6 text-white">Name</label>
|
||||||
|
<div class="mt-2">
|
||||||
|
<input @bind="Request.Name" type="text" autocomplete="off" class="form-input w-full">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-medium leading-6 text-white">Fqdn</label>
|
||||||
|
<div class="mt-2">
|
||||||
|
<input @bind="Request.Fqdn" type="text" autocomplete="off" class="form-input w-full">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-medium leading-6 text-white">HttpPort</label>
|
||||||
|
<div class="mt-2">
|
||||||
|
<input @bind="Request.HttpPort" type="number" autocomplete="off" class="form-input w-full">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-medium leading-6 text-white">FtpPort</label>
|
||||||
|
<div class="mt-2">
|
||||||
|
<input @bind="Request.FtpPort" type="number" autocomplete="off" class="form-input w-full">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</HandleForm>
|
</HandleForm>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code
|
@*
|
||||||
|
TODO: EnableTransparentMode, EnableDynamicFirewall
|
||||||
|
*@
|
||||||
|
|
||||||
|
@code
|
||||||
{
|
{
|
||||||
private HandleForm Form;
|
private HandleForm Form;
|
||||||
private CreateNodeRequest Request;
|
private CreateNodeRequest Request;
|
||||||
@@ -38,35 +65,11 @@
|
|||||||
Request = new();
|
Request = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnConfigure(FormConfiguration<CreateNodeRequest> configuration)
|
|
||||||
{
|
|
||||||
configuration.WithField(x => x.Name);
|
|
||||||
configuration.WithField(x => x.Fqdn);
|
|
||||||
|
|
||||||
configuration.WithField(x => x.HttpPort, fieldConfiguration =>
|
|
||||||
{
|
|
||||||
fieldConfiguration.DefaultValue = 8080;
|
|
||||||
});
|
|
||||||
|
|
||||||
configuration.WithField(x => x.FtpPort, fieldConfiguration =>
|
|
||||||
{
|
|
||||||
fieldConfiguration.DefaultValue = 2021;
|
|
||||||
});
|
|
||||||
|
|
||||||
var advancedPage = configuration.WithPage("Advanced");
|
|
||||||
|
|
||||||
advancedPage.WithField(x => x.EnableTransparentMode);
|
|
||||||
advancedPage.WithField(x => x.EnableDynamicFirewall);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnSubmit()
|
private async Task OnSubmit()
|
||||||
{
|
{
|
||||||
await ApiClient.Post("api/admin/servers/nodes", Request);
|
await ApiClient.Post("api/admin/servers/nodes", Request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully created Node");
|
await ToastService.Success("Successfully created node");
|
||||||
GoBack();
|
Navigation.NavigateTo("/admin/servers/nodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GoBack()
|
|
||||||
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
||||||
}
|
}
|
||||||
@@ -1,39 +1,45 @@
|
|||||||
@page "/admin/servers/nodes"
|
@page "/admin/servers/nodes"
|
||||||
|
|
||||||
@using System.Diagnostics
|
|
||||||
@using MoonCore.Blazor.Tailwind.Alerts
|
@using MoonCore.Blazor.Tailwind.Alerts
|
||||||
@using MoonCore.Blazor.Tailwind.MinimalCrud
|
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonCore.Models
|
@using MoonCore.Models
|
||||||
@using MoonCore.Blazor.Tailwind.DataTable
|
|
||||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
|
@using MoonCore.Blazor.Tailwind.Dt
|
||||||
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonlightServers.Frontend.Services
|
@using MoonlightServers.Frontend.Services
|
||||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Sys
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Sys
|
||||||
|
|
||||||
@inject HttpApiClient ApiClient
|
@inject HttpApiClient ApiClient
|
||||||
@inject NodeService NodeService
|
@inject NodeService NodeService
|
||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
|
@inject ToastService ToastService
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<NavTabs Index="2" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
|
<NavTabs Index="2" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MinimalCrud TItem="NodeDetailResponse" OnConfigure="OnConfigure">
|
<div class="mb-5">
|
||||||
<ChildContent>
|
<PageHeader Title="Nodes">
|
||||||
<DataColumn TItem="NodeDetailResponse" Field="@(x => x.Id)" Title="Id" IsSortable="true"/>
|
<a href="/admin/servers/nodes/create" class="btn btn-primary">
|
||||||
<DataColumn TItem="NodeDetailResponse" Field="@(x => x.Name)" Title="Name" IsSortable="true">
|
Create
|
||||||
<Template>
|
</a>
|
||||||
@{
|
</PageHeader>
|
||||||
var url = ComponentHelper.GetRouteOfComponent<Update>(context.Id)!;
|
</div>
|
||||||
}
|
|
||||||
|
|
||||||
<a class="text-primary-500" href="@url">@context.Name</a>
|
<DataTable TItem="NodeDetailResponse" PageSize="15" LoadItemsPaginatedAsync="LoadData">
|
||||||
</Template>
|
<Configuration>
|
||||||
</DataColumn>
|
<DataTableColumn TItem="NodeDetailResponse" Field="@(x => x.Id)" Name="Id"/>
|
||||||
<DataColumn TItem="NodeDetailResponse" Field="@(x => x.Fqdn)" Title="Fqdn"/>
|
<DataTableColumn TItem="NodeDetailResponse" Field="@(x => x.Name)" Name="Name">
|
||||||
<DataColumn TItem="NodeDetailResponse" Field="@(x => x.Fqdn)" Title="Status">
|
<ColumnTemplate>
|
||||||
<Template>
|
<a class="text-primary-500" href="/admin/servers/nodes/update/@(context.Id)">
|
||||||
|
@context.Name
|
||||||
|
</a>
|
||||||
|
</ColumnTemplate>
|
||||||
|
</DataTableColumn>
|
||||||
|
<DataTableColumn TItem="NodeDetailResponse" Field="@(x => x.Fqdn)" Name="Fqdn"/>
|
||||||
|
<DataTableColumn TItem="NodeDetailResponse" Field="@(x => x.Fqdn)" Name="Status">
|
||||||
|
<ColumnTemplate>
|
||||||
<LazyLoader Load="_ => LoadNodeStatus(context.Id)">
|
<LazyLoader Load="_ => LoadNodeStatus(context.Id)">
|
||||||
@{
|
@{
|
||||||
bool isFetched;
|
bool isFetched;
|
||||||
@@ -84,48 +90,79 @@
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</Template>
|
</ColumnTemplate>
|
||||||
</DataColumn>
|
</DataTableColumn>
|
||||||
<DataColumn TItem="NodeDetailResponse"
|
<DataTableColumn TItem="NodeDetailResponse"
|
||||||
Title=""
|
HeaderCss="p-2 font-semibold text-left hidden xl:table-cell"
|
||||||
HeadCssClasses="p-2 font-semibold text-left hidden xl:table-cell"
|
ColumnCss="p-2 text-left font-normal hidden xl:table-cell">
|
||||||
CssClasses="p-2 text-left font-normal hidden xl:table-cell">
|
<ColumnTemplate>
|
||||||
<Template>
|
|
||||||
<div>
|
<div>
|
||||||
<i class="icon-cpu text-lg me-1 align-middle text-primary-500"></i>
|
<i class="icon-cpu text-lg me-1 align-middle text-primary-500"></i>
|
||||||
<span class="align-middle">33% of 6 Cores</span>
|
<span class="align-middle">33% of 6 Cores</span>
|
||||||
</div>
|
</div>
|
||||||
</Template>
|
</ColumnTemplate>
|
||||||
</DataColumn>
|
</DataTableColumn>
|
||||||
<DataColumn TItem="NodeDetailResponse"
|
<DataTableColumn TItem="NodeDetailResponse"
|
||||||
Title=""
|
HeaderCss="p-2 font-semibold text-left hidden xl:table-cell"
|
||||||
HeadCssClasses="p-2 font-semibold text-left hidden xl:table-cell"
|
ColumnCss="p-2 text-left font-normal hidden xl:table-cell">
|
||||||
CssClasses="p-2 text-left font-normal hidden xl:table-cell">
|
<ColumnTemplate>
|
||||||
<Template>
|
|
||||||
<div>
|
<div>
|
||||||
<i class="icon-memory-stick text-lg me-1 align-middle text-primary-500"></i>
|
<i class="icon-memory-stick text-lg me-1 align-middle text-primary-500"></i>
|
||||||
<span class="align-middle">1.56GB / 64GB</span>
|
<span class="align-middle">1.56GB / 64GB</span>
|
||||||
</div>
|
</div>
|
||||||
</Template>
|
</ColumnTemplate>
|
||||||
</DataColumn>
|
</DataTableColumn>
|
||||||
<DataColumn TItem="NodeDetailResponse"
|
<DataTableColumn TItem="NodeDetailResponse"
|
||||||
Title=""
|
HeaderCss="p-2 font-semibold text-left hidden xl:table-cell"
|
||||||
HeadCssClasses="p-2 font-semibold text-left hidden xl:table-cell"
|
ColumnCss="p-2 text-left font-normal hidden xl:table-cell">
|
||||||
CssClasses="p-2 text-left font-normal hidden xl:table-cell">
|
<ColumnTemplate>
|
||||||
<Template>
|
|
||||||
<div>
|
<div>
|
||||||
<i class="icon-hard-drive text-lg me-1 align-middle text-primary-500"></i>
|
<i class="icon-hard-drive text-lg me-1 align-middle text-primary-500"></i>
|
||||||
<span class="align-middle">78.68GB / 1TB</span>
|
<span class="align-middle">78.68GB / 1TB</span>
|
||||||
</div>
|
</div>
|
||||||
</Template>
|
</ColumnTemplate>
|
||||||
</DataColumn>
|
</DataTableColumn>
|
||||||
</ChildContent>
|
<DataTableColumn TItem="NodeDetailResponse">
|
||||||
</MinimalCrud>
|
<ColumnTemplate>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<a href="/admin/servers/nodes/update/@(context.Id)" class="text-primary-500 mr-2 sm:mr-3">
|
||||||
|
<i class="icon-pencil text-base"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="#" @onclick="() => Delete(context)" @onclick:preventDefault
|
||||||
|
class="text-danger-500">
|
||||||
|
<i class="icon-trash text-base"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</ColumnTemplate>
|
||||||
|
</DataTableColumn>
|
||||||
|
</Configuration>
|
||||||
|
</DataTable>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
private DataTable<NodeDetailResponse> Table;
|
||||||
|
|
||||||
private Dictionary<int, NodeSystemStatusResponse?> Responses = new();
|
private Dictionary<int, NodeSystemStatusResponse?> Responses = new();
|
||||||
|
|
||||||
|
private async Task<IPagedData<NodeDetailResponse>> LoadData(PaginationOptions options)
|
||||||
|
=> await ApiClient.GetJson<PagedData<NodeDetailResponse>>($"api/admin/servers/nodes?page={options.Page}&pageSize={options.PerPage}");
|
||||||
|
|
||||||
|
private async Task Delete(NodeDetailResponse detailResponse)
|
||||||
|
{
|
||||||
|
await AlertService.ConfirmDanger(
|
||||||
|
"Node deletion",
|
||||||
|
$"Do you really want to delete the node '{detailResponse.Name}'",
|
||||||
|
async () =>
|
||||||
|
{
|
||||||
|
await ApiClient.Delete($"api/admin/servers/nodes/{detailResponse.Id}");
|
||||||
|
await ToastService.Success("Successfully deleted node");
|
||||||
|
|
||||||
|
await Table.Refresh();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private Task LoadNodeStatus(int node)
|
private Task LoadNodeStatus(int node)
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
@@ -165,15 +202,4 @@
|
|||||||
|
|
||||||
await AlertService.Danger("Node error details", message);
|
await AlertService.Danger("Node error details", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnConfigure(MinimalCrudOptions<NodeDetailResponse> options)
|
|
||||||
{
|
|
||||||
options.Title = "Nodes";
|
|
||||||
options.ItemLoader = async (page, pageSize) =>
|
|
||||||
await ApiClient.GetJson<PagedData<NodeDetailResponse>>($"api/admin/servers/nodes?page={page}&pageSize={pageSize}");
|
|
||||||
|
|
||||||
options.CreateUrl = ComponentHelper.GetRouteOfComponent<Create>();
|
|
||||||
options.UpdateUrl = item => ComponentHelper.GetRouteOfComponent<Update>(item.Id)!;
|
|
||||||
options.DeleteFunction = async item => await ApiClient.Delete($"api/admin/servers/nodes/{item.Id}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
@page "/admin/servers/nodes/update/{Id:int}"
|
@page "/admin/servers/nodes/update/{Id:int}"
|
||||||
|
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
@using MoonCore.Blazor.Tailwind.Forms
|
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
||||||
@@ -14,10 +13,10 @@
|
|||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<PageHeader Title="Update Node">
|
<PageHeader Title="Update Node">
|
||||||
<button @onclick="GoBack" type="button" class="btn btn-secondary">
|
<a href="/admin/servers/nodes" class="btn btn-secondary">
|
||||||
<i class="icon-chevron-left mr-1"></i>
|
<i class="icon-chevron-left mr-1"></i>
|
||||||
Back
|
Back
|
||||||
</button>
|
</a>
|
||||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||||
<i class="icon-check mr-1"></i>
|
<i class="icon-check mr-1"></i>
|
||||||
Update
|
Update
|
||||||
@@ -59,27 +58,11 @@
|
|||||||
Request = Mapper.Map<UpdateNodeRequest>(Node);
|
Request = Mapper.Map<UpdateNodeRequest>(Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnConfigure(FormConfiguration<UpdateNodeRequest> configuration)
|
|
||||||
{
|
|
||||||
configuration.WithField(x => x.Name);
|
|
||||||
configuration.WithField(x => x.Fqdn);
|
|
||||||
configuration.WithField(x => x.HttpPort);
|
|
||||||
configuration.WithField(x => x.FtpPort);
|
|
||||||
|
|
||||||
var advancedPage = configuration.WithPage("Advanced");
|
|
||||||
|
|
||||||
advancedPage.WithField(x => x.EnableTransparentMode);
|
|
||||||
advancedPage.WithField(x => x.EnableDynamicFirewall);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnSubmit()
|
private async Task OnSubmit()
|
||||||
{
|
{
|
||||||
await ApiClient.Patch($"api/admin/servers/nodes/{Id}", Request);
|
await ApiClient.Patch($"api/admin/servers/nodes/{Id}", Request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully updated Node");
|
await ToastService.Success("Successfully updated Node");
|
||||||
GoBack();
|
Navigation.NavigateTo("/admin/servers/nodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GoBack()
|
|
||||||
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,20 @@
|
|||||||
@page "/admin/servers/stars/create"
|
@page "/admin/servers/stars/create"
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
@using MoonCore.Blazor.Tailwind.Forms
|
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using Moonlight.Client.Services
|
|
||||||
@using MoonlightServers.Frontend.UI.Components.Forms
|
|
||||||
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
||||||
@using MoonlightServers.Shared.Http.Requests.Admin.StarVariables
|
|
||||||
|
|
||||||
@inject HttpApiClient ApiClient
|
@inject HttpApiClient ApiClient
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
@inject IdentityService IdentityService
|
|
||||||
|
|
||||||
<PageHeader Title="Create Star">
|
<PageHeader Title="Create Star">
|
||||||
<button @onclick="GoBack" class="btn btn-secondary">
|
<a href="/admin/servers/stars" class="btn btn-secondary">
|
||||||
<i class="icon-chevron-left mr-1"></i>
|
<i class="icon-chevron-left mr-1"></i>
|
||||||
Back
|
Back
|
||||||
</button>
|
</a>
|
||||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||||
<i class="icon-check mr-1"></i>
|
<i class="icon-check mr-1"></i>
|
||||||
Create
|
Create
|
||||||
@@ -27,42 +23,43 @@
|
|||||||
|
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
||||||
<GeneratedForm TForm="CreateStarRequest" Model="Request" OnConfigure="OnConfigure"/>
|
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-medium leading-6 text-white">Name</label>
|
||||||
|
<div class="mt-2">
|
||||||
|
<input @bind="Request.Name" type="text" autocomplete="off" class="form-input w-full">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label class="block text-sm font-medium leading-6 text-white">Author</label>
|
||||||
|
<div class="mt-2">
|
||||||
|
<input @bind="Request.Author" type="text" autocomplete="off" class="form-input w-full">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</HandleForm>
|
</HandleForm>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
{
|
{
|
||||||
|
[CascadingParameter] public Task<AuthenticationState> AuthState { get; set; }
|
||||||
|
|
||||||
private HandleForm Form;
|
private HandleForm Form;
|
||||||
private CreateStarRequest Request;
|
private CreateStarRequest Request;
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Request = new();
|
Request = new();
|
||||||
}
|
|
||||||
|
|
||||||
private void OnConfigure(FormConfiguration<CreateStarRequest> configuration)
|
var authState = await AuthState;
|
||||||
{
|
Request.Author = authState.User.Claims.First(x => x.Type == "email").Value;
|
||||||
configuration.WithField(x => x.Name);
|
|
||||||
|
|
||||||
configuration.WithField(x => x.Author, fieldConfiguration =>
|
|
||||||
{
|
|
||||||
fieldConfiguration.DefaultValue = IdentityService.Email;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnSubmit()
|
private async Task OnSubmit()
|
||||||
{
|
{
|
||||||
await ApiClient.Post("api/admin/servers/stars", Request);
|
await ApiClient.Post("api/admin/servers/stars", Request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully created Star");
|
await ToastService.Success("Successfully created star");
|
||||||
await GoBack();
|
Navigation.NavigateTo("/admin/servers/stars");
|
||||||
}
|
|
||||||
|
|
||||||
private Task GoBack()
|
|
||||||
{
|
|
||||||
Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,82 +1,108 @@
|
|||||||
@page "/admin/servers/stars"
|
@page "/admin/servers/stars"
|
||||||
|
|
||||||
@using MoonCore.Blazor.Tailwind.MinimalCrud
|
@using MoonCore.Blazor.Tailwind.Alerts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonCore.Models
|
@using MoonCore.Models
|
||||||
@using MoonCore.Blazor.Tailwind.DataTable
|
|
||||||
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
|
@using MoonCore.Blazor.Tailwind.Dt
|
||||||
|
@using MoonCore.Blazor.Tailwind.Services
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Exceptions
|
@using MoonCore.Exceptions
|
||||||
@using Moonlight.Client.Services
|
|
||||||
|
|
||||||
@inject HttpApiClient ApiClient
|
@inject HttpApiClient ApiClient
|
||||||
@inject DownloadService DownloadService
|
@inject DownloadService DownloadService
|
||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
|
@inject AlertService AlertService
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<NavTabs Index="3" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
|
<NavTabs Index="3" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MinimalCrud @ref="Crud" TItem="StarDetailResponse" OnConfigure="OnConfigure">
|
<div class="mb-5">
|
||||||
<ChildContent>
|
<PageHeader Title="Nodes">
|
||||||
<DataColumn TItem="StarDetailResponse" Field="@(x => x.Id)" Title="Id" IsSortable="true" />
|
|
||||||
<DataColumn TItem="StarDetailResponse" Field="@(x => x.Name)" Title="Name" IsSortable="true">
|
|
||||||
<Template>
|
|
||||||
@{
|
|
||||||
var url = ComponentHelper.GetRouteOfComponent<Update>(context.Id)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
<a class="text-primary-500" href="@url">@context.Name</a>
|
|
||||||
</Template>
|
|
||||||
</DataColumn>
|
|
||||||
<DataColumn TItem="StarDetailResponse" Field="@(x => x.Version)" Title="Version" IsSortable="true"/>
|
|
||||||
<DataColumn TItem="StarDetailResponse" Field="@(x => x.Author)" Title="Author"/>
|
|
||||||
</ChildContent>
|
|
||||||
<Actions>
|
|
||||||
<InputFile id="import-file" hidden="" multiple OnChange="OnImportFiles"/>
|
<InputFile id="import-file" hidden="" multiple OnChange="OnImportFiles"/>
|
||||||
<label for="import-file" class="btn btn-tertiary cursor-pointer">
|
<label for="import-file" class="btn btn-tertiary cursor-pointer">
|
||||||
<i class="icon-file-up mr-2"></i>
|
<i class="icon-file-up mr-2"></i>
|
||||||
Import
|
Import
|
||||||
</label>
|
</label>
|
||||||
</Actions>
|
|
||||||
<ItemActions>
|
|
||||||
@if (!string.IsNullOrEmpty(context.DonateUrl))
|
|
||||||
{
|
|
||||||
<a href="@context.DonateUrl" target="_blank" class="text-red-500 mr-3">
|
|
||||||
<i class="icon-heart align-middle"></i>
|
|
||||||
<span class="align-middle">Donate</span>
|
|
||||||
</a>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (!string.IsNullOrEmpty(context.UpdateUrl))
|
<a href="/admin/servers/nodes/create" class="btn btn-primary">
|
||||||
{
|
Create
|
||||||
<a href="#" @onclick:preventDefault class="text-tertiary-500 mr-3">
|
|
||||||
<i class="icon-refresh-cw align-middle"></i>
|
|
||||||
<span class="align-middle">Update</span>
|
|
||||||
</a>
|
|
||||||
}
|
|
||||||
|
|
||||||
<a href="#" @onclick="() => Export(context)" @onclick:preventDefault class="text-success-500 mr-3">
|
|
||||||
<i class="icon-download align-middle"></i>
|
|
||||||
<span class="align-middle">Export</span>
|
|
||||||
</a>
|
</a>
|
||||||
</ItemActions>
|
</PageHeader>
|
||||||
</MinimalCrud>
|
</div>
|
||||||
|
|
||||||
|
<DataTable @ref="Table" TItem="StarDetailResponse" LoadItemsPaginatedAsync="LoadData">
|
||||||
|
<Configuration>
|
||||||
|
<DataTableColumn TItem="StarDetailResponse" Field="@(x => x.Id)" Name="Id" />
|
||||||
|
<DataTableColumn TItem="StarDetailResponse" Field="@(x => x.Name)" Name="Name">
|
||||||
|
<ColumnTemplate>
|
||||||
|
<a class="text-primary-500" href="/admin/servers/stars/update/@(context.Id)">
|
||||||
|
@context.Name
|
||||||
|
</a>
|
||||||
|
</ColumnTemplate>
|
||||||
|
</DataTableColumn>
|
||||||
|
<DataTableColumn TItem="StarDetailResponse" Field="@(x => x.Version)" Name="Version" />
|
||||||
|
<DataTableColumn TItem="StarDetailResponse" Field="@(x => x.Author)" Name="Author" />
|
||||||
|
<DataTableColumn TItem="StarDetailResponse">
|
||||||
|
<ColumnTemplate>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
@if (!string.IsNullOrEmpty(context.DonateUrl))
|
||||||
|
{
|
||||||
|
<a href="@context.DonateUrl" target="_blank" class="text-red-500 mr-3">
|
||||||
|
<i class="icon-heart align-middle"></i>
|
||||||
|
<span class="align-middle">Donate</span>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (!string.IsNullOrEmpty(context.UpdateUrl))
|
||||||
|
{
|
||||||
|
<a href="#" @onclick:preventDefault class="text-tertiary-500 mr-3">
|
||||||
|
<i class="icon-refresh-cw align-middle"></i>
|
||||||
|
<span class="align-middle">Update</span>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
|
||||||
|
<a href="#" @onclick="() => Export(context)" @onclick:preventDefault class="text-success-500 mr-3">
|
||||||
|
<i class="icon-download align-middle"></i>
|
||||||
|
<span class="align-middle">Export</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="/admin/servers/stars/update/@(context.Id)" class="text-primary-500 mr-2 sm:mr-3">
|
||||||
|
<i class="icon-pencil text-base"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="#" @onclick="() => Delete(context)" @onclick:preventDefault
|
||||||
|
class="text-danger-500">
|
||||||
|
<i class="icon-trash text-base"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</ColumnTemplate>
|
||||||
|
</DataTableColumn>
|
||||||
|
</Configuration>
|
||||||
|
</DataTable>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
private MinimalCrud<StarDetailResponse> Crud;
|
private DataTable<StarDetailResponse> Table;
|
||||||
|
|
||||||
private void OnConfigure(MinimalCrudOptions<StarDetailResponse> options)
|
private async Task<IPagedData<StarDetailResponse>> LoadData(PaginationOptions options)
|
||||||
|
=> await ApiClient.GetJson<PagedData<StarDetailResponse>>($"api/admin/servers/stars?page={options.Page}&pageSize={options.PerPage}");
|
||||||
|
|
||||||
|
private async Task Delete(StarDetailResponse detailResponse)
|
||||||
{
|
{
|
||||||
options.Title = "Stars";
|
await AlertService.ConfirmDanger(
|
||||||
options.ItemLoader = async (page, pageSize) =>
|
"Star deletion",
|
||||||
await ApiClient.GetJson<PagedData<StarDetailResponse>>($"api/admin/servers/stars?page={page}&pageSize={pageSize}");
|
$"Do you really want to delete the star '{detailResponse.Name}'",
|
||||||
|
async () =>
|
||||||
|
{
|
||||||
|
await ApiClient.Delete($"api/admin/servers/stars/{detailResponse.Id}");
|
||||||
|
await ToastService.Success("Successfully deleted star");
|
||||||
|
|
||||||
options.CreateUrl = ComponentHelper.GetRouteOfComponent<Create>();
|
await Table.Refresh();
|
||||||
options.UpdateUrl = item => ComponentHelper.GetRouteOfComponent<Update>(item.Id)!;
|
}
|
||||||
options.DeleteFunction = async item => await ApiClient.Delete($"api/admin/servers/stars/{item.Id}");
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Export(StarDetailResponse star)
|
private async Task Export(StarDetailResponse star)
|
||||||
@@ -125,6 +151,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Crud.Refresh(isSilent: false, bypassCache: true);
|
await Table.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
@page "/admin/servers/stars/update/{Id:int}"
|
@page "/admin/servers/stars/update/{Id:int}"
|
||||||
|
|
||||||
@using MoonCore.Blazor.Tailwind.Components
|
@using MoonCore.Blazor.Tailwind.Components
|
||||||
@using MoonCore.Blazor.Tailwind.Forms
|
|
||||||
@using MoonCore.Blazor.Tailwind.Toasts
|
@using MoonCore.Blazor.Tailwind.Toasts
|
||||||
@using MoonCore.Helpers
|
@using MoonCore.Helpers
|
||||||
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
||||||
@@ -14,10 +13,10 @@
|
|||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<PageHeader Title="Update Star">
|
<PageHeader Title="Update Star">
|
||||||
<button @onclick="GoBack" type="button" class="btn btn-secondary">
|
<a href="/admin/servers/stars" class="btn btn-secondary">
|
||||||
<i class="icon-chevron-left mr-1"></i>
|
<i class="icon-chevron-left mr-1"></i>
|
||||||
Back
|
Back
|
||||||
</button>
|
</a>
|
||||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||||
<i class="icon-check mr-1"></i>
|
<i class="icon-check mr-1"></i>
|
||||||
Update
|
Update
|
||||||
@@ -75,52 +74,11 @@
|
|||||||
Request = Mapper.Map<UpdateStarRequest>(Detail);
|
Request = Mapper.Map<UpdateStarRequest>(Detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnConfigure(FormConfiguration<UpdateStarRequest> configuration)
|
|
||||||
{
|
|
||||||
var generalPage = configuration.WithPage("General");
|
|
||||||
|
|
||||||
generalPage.WithField(x => x.Name);
|
|
||||||
generalPage.WithField(x => x.Version);
|
|
||||||
generalPage.WithField(x => x.Author);
|
|
||||||
generalPage.WithField(x => x.DonateUrl);
|
|
||||||
generalPage.WithField(x => x.UpdateUrl);
|
|
||||||
|
|
||||||
var startStopStatusPage = configuration.WithPage("Start, Stop & Status");
|
|
||||||
|
|
||||||
startStopStatusPage.WithField(x => x.StartupCommand);
|
|
||||||
startStopStatusPage.WithField(x => x.StopCommand);
|
|
||||||
startStopStatusPage.WithField(x => x.OnlineDetection);
|
|
||||||
|
|
||||||
var installationPage = configuration.WithPage("Installation");
|
|
||||||
|
|
||||||
installationPage.WithField(x => x.InstallShell);
|
|
||||||
installationPage.WithField(x => x.InstallDockerImage);
|
|
||||||
|
|
||||||
installationPage.WithField(x => x.InstallScript, fieldConfiguration =>
|
|
||||||
{
|
|
||||||
fieldConfiguration.Columns = 6;
|
|
||||||
});
|
|
||||||
|
|
||||||
var parseConfigurationPage = configuration.WithPage("Parse configuration");
|
|
||||||
|
|
||||||
parseConfigurationPage.WithField(x => x.ParseConfiguration);
|
|
||||||
|
|
||||||
var variablesPage = configuration.WithPage("Variables");
|
|
||||||
|
|
||||||
var miscPage = configuration.WithPage("Miscellaneous");
|
|
||||||
|
|
||||||
miscPage.WithField(x => x.AllowDockerImageChange);
|
|
||||||
miscPage.WithField(x => x.RequiredAllocations);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnSubmit()
|
private async Task OnSubmit()
|
||||||
{
|
{
|
||||||
await ApiClient.Patch($"api/admin/servers/stars/{Id}", Request);
|
await ApiClient.Patch($"api/admin/servers/stars/{Id}", Request);
|
||||||
|
|
||||||
await ToastService.Success("Successfully updated Star");
|
await ToastService.Success("Successfully updated Star");
|
||||||
GoBack();
|
Navigation.NavigateTo("/admin/servers/stars");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GoBack()
|
|
||||||
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
||||||
}
|
}
|
||||||
@@ -12,11 +12,11 @@ public class CreateNodeRequest
|
|||||||
|
|
||||||
[Required(ErrorMessage = "You need to provide a http port")]
|
[Required(ErrorMessage = "You need to provide a http port")]
|
||||||
[Range(1, 65535, ErrorMessage = "You need to provide a valid http port")]
|
[Range(1, 65535, ErrorMessage = "You need to provide a valid http port")]
|
||||||
public int HttpPort { get; set; }
|
public int HttpPort { get; set; } = 8080;
|
||||||
|
|
||||||
[Required(ErrorMessage = "You need to provide a ftp port")]
|
[Required(ErrorMessage = "You need to provide a ftp port")]
|
||||||
[Range(1, 65535, ErrorMessage = "You need to provide a valid ftp port")]
|
[Range(1, 65535, ErrorMessage = "You need to provide a valid ftp port")]
|
||||||
public int FtpPort { get; set; }
|
public int FtpPort { get; set; } = 2021;
|
||||||
|
|
||||||
public bool EnableTransparentMode { get; set; }
|
public bool EnableTransparentMode { get; set; }
|
||||||
public bool EnableDynamicFirewall { get; set; }
|
public bool EnableDynamicFirewall { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user