Merge pull request #421 from Moonlight-Panel/v2

Update ImproveForms with latest commits from the main branch
This commit is contained in:
Masu Baumgartner
2024-05-31 11:18:04 +02:00
committed by GitHub
6 changed files with 35 additions and 280 deletions

View File

@@ -1,160 +0,0 @@
@page "/test"
<div class="card card-body mb-5 p-3">
<div class="row">
<div class="col-6 col-md-3">
<div class="input-group">
<span class="input-group-text">
<i class="bx bx-sm bx-search-alt"></i>
</span>
<input placeholder="Search" class="form-control"/>
</div>
</div>
<div class="col-6 col-md-9">
<div class="text-end">
<div class="btn-group dropstart">
<!--!-->
<button class="btn btn-icon btn-secondary rounded" type="button" id="defaultDropdown" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false">
<i class="bx bx-sm bx-filter-alt"></i>
</button>
<div class="dropdown-menu py-1 px-2 fs-5 me-2 bg-secondary" style="min-width: 15rem">
<div class="my-2 text-center">
<!--!-->
<div class="mt-auto">
<input id="Id" type="number" class="form-control ">
</div>
</div>
<div class="my-2 text-center">
<!--!-->
<div class="mt-auto">
<div class="w-100">
<input id="Email" type="text" class="form-control " placeholder="Email" autocomplete="off" spellcheck="false">
</div>
</div>
</div>
<div class="my-2 text-center">
<!--!-->
<div class="mt-auto">
<div class="w-100">
<input id="Username" type="text" class="form-control " placeholder="Username" autocomplete="off" spellcheck="false">
</div>
</div>
</div>
<div class="my-2 text-center">
<!--!-->
<button class="btn btn btn-primary" type="button">
Apply<!--!-->
</button>
</div>
</div>
</div>
<button type="button" class="btn btn-primary ms-3">
<span>Create User</span>
</button>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body pt-3 px-5 pb-4">
<div class="table-responsive mb-3">
<table class="table table-row-bordered table-row-gray-200 align-middle gs-0 gy-3 fs-6 table-rounded">
<!--!--><!--!--><!--!-->
<!--!--><!--!-->
<!--!--><!--!-->
<!--!--><!--!-->
<!--!--><!--!-->
<thead class="fw-bold text-muted">
<tr>
<th class="w-10px align-middle">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="0">
</div>
</th>
<th class="fw-bold">Id</th>
<th class="fw-bold">Email</th>
<th class="fw-bold">Username</th>
<th class="fw-bold">Created at</th>
<th></th>
</tr>
</thead><!--!-->
<tbody>
@for (var i = 1; i <= 10; i++)
{
<tr>
<td class="w-10px align-middle">
<div class="form-check my-1">
<input class="form-check-input" type="checkbox" value="0">
</div>
</td>
<td class="">@(i)</td>
<td class="">admin@masuowo.xyz@(i)</td>
<td class="">masuowo@(i)</td>
<td class="">04/19/2024 12:48:35</td>
<td class="py-1 my-0">
<div class="text-end text-nowrap me-3 fw-semibold">
<a href="#"><i class="bx bx-edit"></i> Edit</a>
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="d-flex justify-content-between align-items-center mx-2">
<div class="d-none d-lg-block">
<span class="text-gray-600 fs-5">Showing 13 of 100 results</span>
</div>
<div>
<div class="input-group input-group-sm">
<span class="input-group-text">Per page</span>
<select class="form-select">
<option selected="selected">10</option>
<option>25</option>
<option>50</option>
<option>100</option>
</select>
</div>
</div>
<div>
<ul class="pagination">
<li class="page-item previous disabled"><a href="#" class="page-link"><i class="previous"></i></a></li>
<li class="page-item "><a href="#" class="page-link">1</a></li>
<li class="page-item active"><a href="#" class="page-link">2</a></li>
<li class="page-item "><a href="#" class="page-link">3</a></li>
<li class="page-item next"><a href="#" class="page-link"><i class="next"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
@*
<div class="my-5"></div>
<div class="input-group mb-5">
<input type="text" class="form-control">
</div>
<div class="input-group has-validation mb-5">
<input type="text" class="form-control is-invalid">
<div class="invalid-feedback">
Please choose a username.
</div>
</div>*@
<WButton Text="Do something" CssClasses="btn-primary" OnClick="Do"></WButton>
@code
{
private async Task Do()
{
await Task.Delay(5000);
}
}

View File

@@ -1,110 +0,0 @@
@page "/testy"
<div class="card card-body mb-8">
<div class="d-flex justify-content-between align-items-center">
<a href="#" class="text-body fs-4">
<i class="bx bx-md bx-chevron-left align-middle"></i>
<span class="align-middle">Back</span>
</a>
<button class="btn btn-primary">Create</button>
</div>
</div>
<div class="card mb-6">
<div class="card-body">
<div class="row g-8">
<div class="col-12 col-md-6">
<label class="form-label">Default input</label>
<input type="text" class="form-control" placeholder="name@example.com"/>
<div class="form-text fs-6 text-gray-600">
dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh
</div>
</div>
<div class="col-12 col-md-3">
<label class="form-label">Default input</label>
<input type="number" class="form-control" value="10324"/>
<div class="form-text fs-6 text-gray-600">
dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh
</div>
</div>
<div class="col-12 col-md-12">
<label class="form-label">Default input</label>
<textarea class="form-control"></textarea>
<div class="form-text fs-6 text-gray-600">
dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh
</div>
</div>
<div class="col-12 col-md-3">
<label class="form-label">Default input</label>
<div class="btn-group w-100">
<label class="btn btn-outline btn-color-muted btn-active-primary">
<input class="btn-check" type="radio" name="method" value="1" />
<i class="bx bx-sm bx-lock-open-alt"></i>
HTTP
</label>
<label class="btn btn-outline btn-color-muted btn-active-primary">
<input class="btn-check" type="radio" name="method" value="1" />
<i class="bx bx-sm bx-lock-alt"></i>
HTTPS
</label>
</div>
<div class="form-text fs-6 text-gray-600">
dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh
</div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="card-title">
<i class="bx bx-md bx-server text-primary me-3 align-middle"></i>
<span class="h3 align-middle">Some Section</span>
</div>
</div>
<div class="card-body">
<div class="row g-8">
<div class="col-12 col-md-6">
<label class="form-label">Default input</label>
<input type="text" class="form-control" placeholder="name@example.com"/>
<div class="form-text fs-6 text-gray-600">
dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh
</div>
</div>
<div class="col-12 col-md-3">
<label class="form-label">Default input</label>
<input type="number" class="form-control" value="10324"/>
<div class="form-text fs-6 text-gray-600">
dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh
</div>
</div>
<div class="col-12 col-md-3">
<label class="form-label">Default input</label>
<div class="btn-group w-100">
<label class="btn btn-outline btn-color-muted btn-active-primary">
<input class="btn-check" type="radio" name="method" value="1"/>
<i class="bx bx-sm bx-lock-open-alt"></i>
HTTP
</label>
<label class="btn btn-outline btn-color-muted btn-active-primary">
<input class="btn-check" type="radio" name="method" value="1"/>
<i class="bx bx-sm bx-lock-alt"></i>
HTTPS
</label>
</div>
<div class="form-text fs-6 text-gray-600">
dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh
</div>
</div>
</div>
</div>
</div>

View File

@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
EXPOSE 443 EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release ARG BUILD_CONFIGURATION=Release
WORKDIR /src WORKDIR /src
COPY ["Moonlight/Moonlight.csproj", "Moonlight/"] COPY ["Moonlight/Moonlight.csproj", "Moonlight/"]

View File

@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
using MoonCore.Abstractions; using MoonCore.Abstractions;
using MoonCore.Attributes; using MoonCore.Attributes;
using MoonCore.Exceptions; using MoonCore.Exceptions;
using MoonCore.Helpers;
using MoonCore.Services; using MoonCore.Services;
using Moonlight.Core.Configuration; using Moonlight.Core.Configuration;
using Moonlight.Core.Database.Entities; using Moonlight.Core.Database.Entities;
@@ -23,6 +24,8 @@ public class ServerService
public ServerBackupService Backup => ServiceProvider.GetRequiredService<ServerBackupService>(); public ServerBackupService Backup => ServiceProvider.GetRequiredService<ServerBackupService>();
public ServerScheduleService Schedule => ServiceProvider.GetRequiredService<ServerScheduleService>(); public ServerScheduleService Schedule => ServiceProvider.GetRequiredService<ServerScheduleService>();
public NodeService NodeService => ServiceProvider.GetRequiredService<NodeService>();
private readonly IServiceProvider ServiceProvider; private readonly IServiceProvider ServiceProvider;
public ServerService(IServiceProvider serviceProvider) public ServerService(IServiceProvider serviceProvider)
@@ -74,6 +77,19 @@ public class ServerService
// Load node // Load node
var node = nodeRepo.Get().First(x => x.Id == form.Node.Id); var node = nodeRepo.Get().First(x => x.Id == form.Node.Id);
// Check if node is available
try
{
await NodeService.GetStatus(node);
}
catch (Exception e)
{
Logger.Warn($"Could not establish to the node with the id {node.Id}");
Logger.Warn(e);
throw new DisplayException($"Could not establish connection to the node: {e.Message}");
}
// Load user // Load user
var user = userRepo.Get().First(x => x.Id == form.Owner.Id); var user = userRepo.Get().First(x => x.Id == form.Owner.Id);

View File

@@ -68,14 +68,23 @@
.Include(x => x.Node); .Include(x => x.Node);
} }
private IEnumerable<ServerAllocation> LoadFreeAllocations(Repository<ServerAllocation> repository, Server currentServer) private IEnumerable<ServerAllocation> LoadFreeAllocations(Repository<ServerAllocation> repository, Server? currentServer)
{ {
return currentServer.Allocations.Concat( if (currentServer == null)
repository {
return repository
.Get() .Get()
.FromSqlRaw($"SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL AND ServerNodeId = {currentServer.Node.Id}") .FromSqlRaw("SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL");
.AsEnumerable() // => executes the sql }
); else
{
return currentServer.Allocations.Concat(
repository
.Get()
.FromSqlRaw($"SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL AND ServerNodeId = {currentServer.Node.Id}")
.AsEnumerable() // => executes the sql
);
}
} }
private async Task CustomAdd(Server form) => await ServerService.Create(form); private async Task CustomAdd(Server form) => await ServerService.Create(form);

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
@@ -92,7 +92,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="MoonCore" Version="1.3.4" /> <PackageReference Include="MoonCore" Version="1.3.4" />
<PackageReference Include="MoonCoreUI" Version="1.1.8" /> <PackageReference Include="MoonCoreUI" Version="1.1.9" />
<PackageReference Include="Otp.NET" Version="1.3.0" /> <PackageReference Include="Otp.NET" Version="1.3.0" />
<PackageReference Include="QRCoder" Version="1.4.3" /> <PackageReference Include="QRCoder" Version="1.4.3" />
<PackageReference Include="XtermBlazor" Version="1.10.2" /> <PackageReference Include="XtermBlazor" Version="1.10.2" />