Remove old v2 structure
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
@using Moonlight.Features.Servers.Models.Abstractions
|
||||
@using Moonlight.Features.Servers.Services
|
||||
@using Moonlight.Features.Servers.UI.Components
|
||||
@using Moonlight.Features.Servers.Entities
|
||||
|
||||
@inject ServerService ServerService
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<div class="card card-body bg-black border-0 p-3">
|
||||
<Terminal @ref="Terminal" />
|
||||
<div class="mt-3">
|
||||
<div class="input-group">
|
||||
<input @bind="CommandInput" class="form-control form-control-transparent text-white" placeholder="Enter command"/>
|
||||
<WButton CssClasses="btn btn-secondary rounded-start" Text="Execute" OnClick="SendCommand" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public ServerMeta Meta { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public Server Server { get; set; }
|
||||
|
||||
private Terminal Terminal;
|
||||
private string CommandInput = "";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
string[] messages;
|
||||
|
||||
lock (Meta.ConsoleMessages)
|
||||
messages = Meta.ConsoleMessages.TakeLast(50).ToArray();
|
||||
|
||||
foreach (var message in messages)
|
||||
await Terminal.WriteLine(message);
|
||||
|
||||
Meta.OnConsoleMessage += OnConsoleMessage;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnConsoleMessage(string message)
|
||||
{
|
||||
await Terminal.WriteLine(message);
|
||||
}
|
||||
|
||||
private async Task SendCommand()
|
||||
{
|
||||
await ServerService.Console.SendCommand(Server, CommandInput);
|
||||
CommandInput = "";
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if(Meta != null)
|
||||
Meta.OnConsoleMessage -= OnConsoleMessage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
@using Moonlight.Core.Configuration
|
||||
@using Moonlight.Core.Services.Utils
|
||||
@using Moonlight.Features.FileManager.Models.Abstractions.FileAccess
|
||||
@using Moonlight.Features.Servers.Entities
|
||||
@using Moonlight.Features.ServiceManagement.Entities
|
||||
@using MoonCore.Services
|
||||
@using Moonlight.Features.FileManager.UI.Components
|
||||
@using Moonlight.Features.Servers.Helpers
|
||||
|
||||
@inject JwtService JwtService
|
||||
@inject ConfigService<ConfigV1> ConfigService
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<LazyLoader Load="Load" ShowAsCard="true">
|
||||
<FileManager FileAccess="FileAccess" />
|
||||
</LazyLoader>
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter] public Service Service { get; set; }
|
||||
|
||||
[CascadingParameter] public Server Server { get; set; }
|
||||
|
||||
private IFileAccess FileAccess;
|
||||
|
||||
private async Task Load(LazyLoader lazyLoader)
|
||||
{
|
||||
var ftpLoginJwt = await JwtService.Create(data =>
|
||||
{
|
||||
data.Add("ServerId", Server.Id.ToString());
|
||||
}, "FtpServerLogin", TimeSpan.FromMinutes(5));
|
||||
|
||||
FileAccess = new ServerFtpFileAccess(
|
||||
Server.Node.Fqdn,
|
||||
Server.Node.FtpPort,
|
||||
$"moonlight.{Server.Id}",
|
||||
ftpLoginJwt,
|
||||
ConfigService.Get().FileManager.OperationTimeout
|
||||
);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
FileAccess.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
@using Moonlight.Features.Servers.Entities
|
||||
@using System.Net
|
||||
|
||||
<div class="card card-body mb-8 pb-1 d-none d-md-flex">
|
||||
<div class="row g-3 align-items-center mx-2">
|
||||
<div class="col">
|
||||
<label class="form-label fs-5">FQDN (or dedicated ip address)</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="form-label fs-5">IP Address</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="form-label fs-5">Port</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="form-label fs-5">Notes</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@foreach (var allocation in Server.Allocations)
|
||||
{
|
||||
<div class="card card-body py-2 my-3">
|
||||
<div class="row g-3 align-items-center mx-2">
|
||||
<div class="col">
|
||||
<div class="fs-3">
|
||||
@if (allocation.IpAddress == "0.0.0.0")
|
||||
{
|
||||
@Server.Node.Fqdn
|
||||
}
|
||||
else
|
||||
{
|
||||
@allocation.IpAddress
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
@if (allocation.IpAddress != "0.0.0.0" || IsIpAddress(Server.Node.Fqdn))
|
||||
{
|
||||
<div class="fs-3">
|
||||
-
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: Resolve domains addresses here
|
||||
<div class="fs-3">
|
||||
188.75.252.37
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="fs-3">
|
||||
@allocation.Port
|
||||
</div>
|
||||
</div>
|
||||
<div class="col d-none d-sm-block">
|
||||
<input type="text" class="form-control" placeholder="What is this allocation for?"/>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button class="btn btn-icon btn-danger disabled" type="button" disabled="disabled">
|
||||
<i class="bx bx-sm bx-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter] public Server Server { get; set; }
|
||||
|
||||
private bool IsIpAddress(string input) => IPAddress.TryParse(input, out _);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
@using Moonlight.Features.Servers.Entities
|
||||
@using Moonlight.Features.Servers.Models.Abstractions
|
||||
@using Moonlight.Features.Servers.Models.Enums
|
||||
@using Moonlight.Features.Servers.Services
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
@inject ServerService ServerService
|
||||
|
||||
<div class="card card-body">
|
||||
@if (Meta.State == ServerState.Offline)
|
||||
{
|
||||
<ConfirmButton OnClick="ResetServer" CssClasses="btn btn-danger" Text="Reset server" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-danger disabled" disabled="">Reset server</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public Server Server { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public ServerMeta Meta { get; set; }
|
||||
|
||||
protected override Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
Meta.OnStateChanged += OnStateChanged;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task ResetServer()
|
||||
{
|
||||
await ServerService.Console.SendAction(Server, PowerAction.Install);
|
||||
}
|
||||
|
||||
private async Task OnStateChanged()
|
||||
{
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Meta.OnStateChanged -= OnStateChanged;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
@using Moonlight.Features.Servers.Entities
|
||||
|
||||
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public Server Server { get; set; }
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
@using Moonlight.Features.Servers.Entities
|
||||
@using MoonCore.Abstractions
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using MoonCoreUI.Services
|
||||
|
||||
@inject Repository<Server> ServerRepository
|
||||
@inject Repository<ServerImage> ImageRepository
|
||||
@inject Repository<ServerVariable> ServerVariableRepository
|
||||
@inject ToastService ToastService
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load" ShowAsCard="true">
|
||||
<div class="row mb-5">
|
||||
<div class="col-md-6 col-12">
|
||||
<div class="card card-body p-5">
|
||||
<label class="form-label">Docker image</label>
|
||||
@if (Image.AllowUserToChangeDockerImage)
|
||||
{
|
||||
<SmartSelect @bind-Value="SelectedDockerImage"
|
||||
Items="Image.DockerImages"
|
||||
DisplayField="@(x => x.DisplayName)"
|
||||
OnChange="OnDockerImageChanged"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<select class="form-select disabled" disabled="disabled">
|
||||
<option>@SelectedDockerImage.DisplayName</option>
|
||||
</select>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex row g-5">
|
||||
@foreach (var variable in Server.Variables)
|
||||
{
|
||||
var imageVariable = Image.Variables.FirstOrDefault(x => x.Key == variable.Key);
|
||||
|
||||
if (imageVariable != null && imageVariable.AllowUserToView)
|
||||
{
|
||||
<div class="d-flex flex-column col-md-3 col-12">
|
||||
<div class="card card-body p-5">
|
||||
<label class="form-label">@(imageVariable.DisplayName)</label>
|
||||
<div class="form-text fs-5 mb-2 mt-0">
|
||||
@imageVariable.Description
|
||||
</div>
|
||||
<div class="mt-auto">
|
||||
@if (imageVariable.AllowUserToEdit)
|
||||
{
|
||||
<div class="input-group">
|
||||
<input @bind="variable.Value" type="text" class="form-control" placeholder="@(imageVariable.DefaultValue)"/>
|
||||
<WButton OnClick="() => UpdateVariable(variable)" CssClasses="btn btn-icon btn-primary">
|
||||
<i class="bx bx-sm bx-save"></i>
|
||||
</WButton>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="input-group">
|
||||
<input value="@variable.Value" type="text" class="form-control disabled" disabled=""/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</LazyLoader>
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter] public Server Server { get; set; }
|
||||
|
||||
private ServerImage Image;
|
||||
private LazyLoader LazyLoader;
|
||||
|
||||
private ServerDockerImage SelectedDockerImage;
|
||||
|
||||
private async Task Load(LazyLoader lazyLoader)
|
||||
{
|
||||
await lazyLoader.SetText("Loading server image data");
|
||||
|
||||
Image = ImageRepository
|
||||
.Get()
|
||||
.Include(x => x.Variables)
|
||||
.Include(x => x.DockerImages)
|
||||
.First(x => x.Id == Server.Image.Id);
|
||||
|
||||
if (Server.DockerImageIndex >= Image.DockerImages.Count || Server.DockerImageIndex == -1)
|
||||
SelectedDockerImage = Image.DockerImages.Last();
|
||||
else
|
||||
SelectedDockerImage = Image.DockerImages[Server.DockerImageIndex];
|
||||
}
|
||||
|
||||
private async Task OnDockerImageChanged()
|
||||
{
|
||||
Server.DockerImageIndex = Image.DockerImages.IndexOf(SelectedDockerImage);
|
||||
ServerRepository.Update(Server);
|
||||
|
||||
await ToastService.Success("Successfully changed docker image");
|
||||
await LazyLoader.Reload();
|
||||
}
|
||||
|
||||
private async Task UpdateVariable(ServerVariable variable)
|
||||
{
|
||||
ServerVariableRepository.Update(variable);
|
||||
|
||||
await ToastService.Success("Successfully changed variable");
|
||||
await LazyLoader.Reload();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user