Merge pull request #33 from Moonlight-Panel/ServerNodeStatusScreen

Added server node status screen check thingy
This commit is contained in:
Marcel Baumgartner 2023-04-04 16:29:22 +02:00 committed by GitHub
commit 317927b12a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 147 additions and 104 deletions

View file

@ -17,6 +17,7 @@
@inject ServerRepository ServerRepository
@inject WingsConsoleHelper WingsConsoleHelper
@inject MessageService MessageService
@inject NodeService NodeService
@inject NavigationManager NavigationManager
@implements IDisposable
@ -26,10 +27,12 @@
{
<div class="d-flex justify-content-center flex-center">
<div class="card">
<img src="/assets/media/svg/nodata.svg" class="card-img-top w-25 mx-auto pt-5" alt="Not found image" />
<img src="/assets/media/svg/nodata.svg" class="card-img-top w-50 mx-auto pt-5" alt="Not found image"/>
<div class="card-body text-center">
<h4 class="card-title"><TL>Server not found</TL></h4>
<p class="card-text">
<h1 class="card-title">
<TL>Server not found</TL>
</h1>
<p class="card-text fs-4">
<TL>A server with that id cannot be found or you have no access for this server</TL>
</p>
</div>
@ -37,6 +40,8 @@
</div>
}
else
{
if (NodeOnline)
{
if (Console.ConnectionState == ConnectionState.Connected)
{
@ -142,6 +147,23 @@
</div>
}
}
else
{
<div class="d-flex justify-content-center flex-center">
<div class="card">
<img src="/assets/media/svg/serverdown.svg" class="card-img-top w-50 mx-auto pt-5" alt="Not found image"/>
<div class="card-body text-center">
<h1 class="card-title">
<TL>Node offline</TL>
</h1>
<p class="card-text fs-4">
<TL>The node the server is running on is currently offline</TL>
</p>
</div>
</div>
</div>
}
}
</LazyLoader>
@code
@ -159,6 +181,7 @@
private PteroConsole? Console;
private Server? CurrentServer;
private Node Node;
private bool NodeOnline = false;
private Image Image;
private NodeAllocation NodeAllocation;
private string[] Tags;
@ -205,7 +228,7 @@
.Include(x => x.Owner)
.First(x => x.Uuid == uuid);
if (CurrentServer.Owner.Id != User!.Id && User.Admin)
if (CurrentServer.Owner.Id != User!.Id && !User.Admin)
CurrentServer = null;
}
catch (Exception)
@ -214,6 +237,23 @@
}
if (CurrentServer != null)
{
await lazyLoader.SetText("Checking node online status");
try
{
//TODO: Implement status caching
var data = await NodeService.GetStatus(CurrentServer.Node);
if (data != null)
NodeOnline = true;
}
catch (Exception)
{
// ignored
}
if (NodeOnline)
{
await lazyLoader.SetText("Requesting tags");
@ -230,14 +270,12 @@
MessageService.Subscribe<Index, Server>($"server.{CurrentServer.Uuid}.installcomplete", this, server =>
{
Task.Run(() =>
{
NavigationManager.NavigateTo(NavigationManager.Uri);
});
Task.Run(() => { NavigationManager.NavigateTo(NavigationManager.Uri); });
return Task.CompletedTask;
});
}
}
else
{
Logger.Debug("Server is null");

View file

@ -478,3 +478,7 @@ Enter your information;Enter your information
You need to enter your full name in order to use moonlight;You need to enter your full name in order to use moonlight
No node found;No node found
No node found to deploy to found;No node found to deploy to found
Node offline;Node offline
The node the server is running on is currently offline;The node the server is running on is currently offline
Server not found;Server not found
A server with that id cannot be found or you have no access for this server;A server with that id cannot be found or you have no access for this server

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.4 KiB