Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI host application #245

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c67e200
GUI - Initial Larvel Setup
felipecastagnarodecarvalho Jul 16, 2023
f018a8b
GUI - Adding basic login/logout/register routes
felipecastagnarodecarvalho Jul 16, 2023
0521404
GUI - minmal breeze implementations
felipecastagnarodecarvalho Jul 16, 2023
037b55f
GUI - basic authorization
felipecastagnarodecarvalho Jul 16, 2023
7feda79
GUI - adding admin-one-vue-tailwind
felipecastagnarodecarvalho Jul 17, 2023
e902c8d
GUI - updating password checking
felipecastagnarodecarvalho Jul 17, 2023
25c0860
Setting up global account object (state oriented with vuex)
felipecastagnarodecarvalho Jul 17, 2023
d61d9b3
GUI - added dark/light options
felipecastagnarodecarvalho Jul 17, 2023
a2e376b
GUI - Minor adjustments to the AdminDashboard
felipecastagnarodecarvalho Jul 17, 2023
43f1ef4
Merge remote-tracking branch 'upstream/master' into GUIHostApplication
felipecastagnarodecarvalho Jul 17, 2023
b402d7e
GUI - Added WebServer Comunications + Profile Page
felipecastagnarodecarvalho Jul 18, 2023
28ffc40
GUI - password reset updated
felipecastagnarodecarvalho Jul 18, 2023
b9731b8
GUI - Added basic process information gathering through API
felipecastagnarodecarvalho Jul 18, 2023
9097dda
Merge remote-tracking branch 'upstream/master' into GUIHostApplication
felipecastagnarodecarvalho Jul 18, 2023
e02a18c
GUI - fixing merge issues
felipecastagnarodecarvalho Jul 18, 2023
f19b1ac
GUI - Minor miss configuration adjustments
felipecastagnarodecarvalho Jul 18, 2023
dd291d5
GUI - Added login page
felipecastagnarodecarvalho Jul 18, 2023
eab1f4d
GUI - Adding kick all feature
felipecastagnarodecarvalho Jul 18, 2023
a2f29c0
GUI - AdminDashboard route secure + Register Page Added
felipecastagnarodecarvalho Jul 19, 2023
92f75f3
GUI - Attempt to do database backups
felipecastagnarodecarvalho Jul 20, 2023
75e166f
GUI - backups added.
felipecastagnarodecarvalho Jul 20, 2023
ee2ea56
GUI - Updating backups and Adding Settings page
felipecastagnarodecarvalho Jul 20, 2023
40144b5
GUI - [WIP] Change configuration on the fly - 1
felipecastagnarodecarvalho Jul 21, 2023
dcbe16e
GUI - [WIP] Change configuration on the fly - 2
felipecastagnarodecarvalho Jul 21, 2023
8c91141
GUI - Cange configutarions on the fly - 3
felipecastagnarodecarvalho Jul 21, 2023
2bfea87
GUI - Backups restauration fixed + warning modal added
felipecastagnarodecarvalho Jul 22, 2023
e99655c
Merge remote-tracking branch 'upstream/master' into GUIHostApplication
felipecastagnarodecarvalho Jul 22, 2023
9945d74
GUI - Added notifications
felipecastagnarodecarvalho Jul 22, 2023
ad9e7ad
GUI - Minor UI adjustment
felipecastagnarodecarvalho Jul 22, 2023
a048eef
GUI - Top silver holders chart added
felipecastagnarodecarvalho Jul 23, 2023
2d6bb1a
GUI - added used jobs chart
felipecastagnarodecarvalho Jul 23, 2023
737727e
GUI - Fixing formatting (prettier)
felipecastagnarodecarvalho Jul 24, 2023
c8f6700
GUI - Added zone management (create/close)
felipecastagnarodecarvalho Jul 25, 2023
e6c3af5
GUI - fixing minor issues
felipecastagnarodecarvalho Jul 25, 2023
3809602
GUI - Attempt to remove storage db from gitIgnore
felipecastagnarodecarvalho Jul 25, 2023
3027e78
GUI - Adding jobs.json and items.json to the repo
felipecastagnarodecarvalho Jul 25, 2023
d85d16e
GUI - Adding basic homepage
felipecastagnarodecarvalho Jul 26, 2023
0516c1c
Merge branch 'master' into GUIHostApplication
felipecastagnarodecarvalho Jul 26, 2023
90ec9a0
GUI - home page redirect to login page
felipecastagnarodecarvalho Jul 26, 2023
55fb578
Merge remote-tracking branch 'origin/GUIHostApplication' into GUIHost…
felipecastagnarodecarvalho Jul 26, 2023
b033bfc
GUI - Inventory inspections (WIP)
felipecastagnarodecarvalho Jul 26, 2023
d81dd75
GUI - Inventory item removal (WIP)
felipecastagnarodecarvalho Jul 27, 2023
7b75099
GUI - Reworking inventory removal system
felipecastagnarodecarvalho Jul 27, 2023
179d499
GUI - adding a guzzleclient service and preventing backup when server on
felipecastagnarodecarvalho Jul 28, 2023
7c09182
GUI - API authentication (WIP)
felipecastagnarodecarvalho Jul 29, 2023
7328ab3
GUI - API Authentication (2) (WIP)
felipecastagnarodecarvalho Jul 30, 2023
b93decc
Merge branch 'master' into GUIHostApplication
felipecastagnarodecarvalho Dec 18, 2023
1f63bb2
Small Adjustment before Refactoring
felipecastagnarodecarvalho Dec 18, 2023
bde84bc
Fixing issues before resolving conflicts
felipecastagnarodecarvalho Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,24 @@ $RECYCLE.BIN/
# Mac crap
.DS_Store
*.lnk

# Melia GUI WebApp
/system/web-optional/MeliaGUI/.phpunit.cache
/system/web-optional/MeliaGUI/node_modules
/system/web-optional/MeliaGUI/public/build
/system/web-optional/MeliaGUI/public/hot
/system/web-optional/MeliaGUI/public/storage
/system/web-optional/MeliaGUI/storage/*.key
/system/web-optional/MeliaGUI/vendor
/system/web-optional/MeliaGUI/.env
/system/web-optional/MeliaGUI/.env.backup
/system/web-optional/MeliaGUI/.env.production
/system/web-optional/MeliaGUI/.phpunit.result.cache
/system/web-optional/MeliaGUI/Homestead.json
/system/web-optional/MeliaGUI/Homestead.yaml
/system/web-optional/MeliaGUI/auth.json
/system/web-optional/MeliaGUI/npm-debug.log
/system/web-optional/MeliaGUI/yarn-error.log
/system/web-optional/MeliaGUI/.fleet
/system/web-optional/MeliaGUI/.idea
/system/web-optional/MeliaGUI/.vscode
Empty file added dump.sql
Empty file.
44 changes: 42 additions & 2 deletions src/BarracksServer/BarracksServer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using Melia.Barracks.Database;
using Melia.Barracks.Network;
using Melia.Barracks.Util;
Expand All @@ -10,6 +13,7 @@
using Melia.Shared.IES;
using Melia.Shared.Network;
using Melia.Shared.Network.Inter.Messages;
using Microsoft.VisualBasic.Devices;
using Yggdrasil.Logging;
using Yggdrasil.Network.Communication;
using Yggdrasil.Network.Communication.Messages;
Expand Down Expand Up @@ -77,6 +81,7 @@ public override void Run(string[] args)

this.StartCommunicator();
this.StartAcceptor();
this.SendProcessInformation();

ConsoleUtil.RunningTitle();
new BarracksConsoleCommands().Wait();
Expand Down Expand Up @@ -144,7 +149,7 @@ private void Communicator_OnClientDisconnected(string commName)
private void Communicator_OnMessageReceived(string sender, ICommMessage message)
{
//Log.Debug("Message received from '{0}': {1}", sender, message);

switch (message)
{
case ServerUpdateMessage serverUpdateMessage:
Expand Down Expand Up @@ -185,6 +190,11 @@ private void Communicator_OnRequestReceived(string sender, RequestMessage reques
this.Communicator.Send(sender, responseMessage);
break;
}
case ResServerInformationMessage resServerInformationMessage:
{
this.Communicator.Send("Web", resServerInformationMessage);
break;
}
}
}

Expand Down Expand Up @@ -259,5 +269,35 @@ public void Broadcast(Packet packet)
conn.Send(packet);
}
}

/// <summary>
/// Send the information about the process to the coordinator.
/// </summary>
private async void SendProcessInformation()
{
var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
cpuCounter.NextValue();
Thread.Sleep(1000);
var cpuUsage = cpuCounter.NextValue();

var processRamCounter = new PerformanceCounter("Process", "Working Set", Process.GetCurrentProcess().ProcessName);

var totalRam = new ComputerInfo().TotalPhysicalMemory;
var processRamUsage = processRamCounter.NextValue();

var serverInformationMessage = new ResServerInformationMessage(
this.ServerInfo.Type, Process.GetCurrentProcess().Id, this.ServerInfo.Id,
Process.GetCurrentProcess().ProcessName, this.ServerInfo.Status,
cpuUsage, processRamUsage, totalRam, this.ServerInfo.Ip
);

try {
this.Communicator.Send("Web", serverInformationMessage);
} catch (Exception)
{
}

await Task.Delay(TimeSpan.FromMinutes(5));
}
}
}
1 change: 1 addition & 0 deletions src/BarracksServer/BarracksServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="MySql.Data, Version=8.0.32.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\MySql.Data.dll</HintPath>
Expand Down
8 changes: 7 additions & 1 deletion src/Shared/Configuration/Files/Barracks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Melia.Shared.World;
using System.Collections.Generic;
using Melia.Shared.World;
using Yggdrasil.Configuration;
using Yggdrasil.Logging;

Expand Down Expand Up @@ -70,5 +71,10 @@ private Position GetPosition(string option, Position defaultValue)

return new Position(x, y, z);
}

public Dictionary<string, string> GetOptions()
{
return _options;
}
}
}
5 changes: 5 additions & 0 deletions src/Shared/Configuration/Files/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public CommandAuthLevels GetLevelsOrDefault(string command)

return result;
}

public Dictionary<string, string> GetOptions()
{
return _options;
}
}

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion src/Shared/Configuration/Files/Database.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Yggdrasil.Configuration;
using System.Collections.Generic;
using Yggdrasil.Configuration;

namespace Melia.Shared.Configuration.Files
{
Expand All @@ -25,5 +26,10 @@ public void Load(string filePath)
this.Pass = this.GetString("pass", "");
this.Db = this.GetString("database", "melia");
}

public Dictionary<string, string> GetOptions()
{
return _options;
}
}
}
8 changes: 7 additions & 1 deletion src/Shared/Configuration/Files/Localization.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Yggdrasil.Configuration;
using System.Collections.Generic;
using Yggdrasil.Configuration;

namespace Melia.Shared.Configuration.Files
{
Expand All @@ -23,5 +24,10 @@ public void Load(string filePath)
this.Culture = this.GetString("culture", "en-US");
this.CultureUi = this.GetString("culture_ui", "en-US");
}

public Dictionary<string, string> GetOptions()
{
return _options;
}
}
}
8 changes: 7 additions & 1 deletion src/Shared/Configuration/Files/Log.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Yggdrasil.Configuration;
using System.Collections.Generic;
using Yggdrasil.Configuration;
using Yggdrasil.Logging;

namespace Melia.Shared.Configuration.Files
Expand All @@ -20,5 +21,10 @@ public void Load(string filePath)

this.Filter = (LogLevel)this.GetInt("log_filter", 0);
}

public Dictionary<string, string> GetOptions()
{
return _options;
}
}
}
8 changes: 7 additions & 1 deletion src/Shared/Configuration/Files/Web.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Collections.Generic;
using System.IO;
using Yggdrasil.Configuration;

namespace Melia.Shared.Configuration.Files
Expand All @@ -22,5 +23,10 @@ public void Load(string filePath)
this.PhpCgiFilePath = this.GetString("php_cgi_bin", Path.Combine("user", "tools", "php", "php-cgi.exe"));
this.PhpDownloadUrl = this.GetString("php_download", "https://windows.php.net/downloads/releases/php-8.2.7-nts-Win32-vs16-x86.zip");
}

public Dictionary<string, string> GetOptions()
{
return _options;
}
}
}
8 changes: 7 additions & 1 deletion src/Shared/Configuration/Files/World.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Yggdrasil.Configuration;
using System.Collections.Generic;
using Yggdrasil.Configuration;

namespace Melia.Shared.Configuration.Files
{
Expand Down Expand Up @@ -113,5 +114,10 @@ public void Load(string filePath)
this.RedOrbJackpotRate = this.GetFloat("red_orb_jackpot_rate", 10000);
this.RedOrbEliteRate = this.GetFloat("red_orb_elite_rate", 1000);
}

public Dictionary<string, string> GetOptions()
{
return _options;
}
}
}
13 changes: 13 additions & 0 deletions src/Shared/Network/Inter/Messages/ReqKickAllMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using Yggdrasil.Network.Communication;

namespace Melia.Shared.Network.Inter.Messages
{
/// <summary>
/// Instruction to kick all players.
/// </summary>
[Serializable]
public class ReqKickAllMessage : ICommMessage
{
}
}
83 changes: 83 additions & 0 deletions src/Shared/Network/Inter/Messages/ResServerInformationMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using Melia.Shared.Data.Database;
using Yggdrasil.Network.Communication;

namespace Melia.Shared.Network.Inter.Messages
{
/// <summary>
/// Contains updated information about a server.
/// </summary>
[Serializable]
public class ResServerInformationMessage : ICommMessage
{
/// <summary>
/// Returns the type of the server.
/// </summary>
public ServerType ServerType { get; set; }

/// <summary>
/// Returns the server's processId
/// </summary>
public int ProcessId { get; set; }

/// <summary>
/// Returns the server's id.
/// </summary>
public int ServerId { get; set; }

/// <summary>
/// Returns the server's processName
/// </summary>
public string ProcessName { get; set; }

/// <summary>
/// Returns the server's status.
/// </summary>
public ServerStatus Status { get; set; }

/// <summary>
/// Returns the server's CPU usage percentage
/// </summary>
public float CpuUsagePercentage { get; set; }

/// <summary>
/// Returns the server's memory usage
/// </summary>
public float ProcessRamUsage { get; set; }

/// <summary>
/// Returns the server's total memory
/// </summary>
public ulong TotalRAM { get; set; }

/// <summary>
/// Returns the server's ip address
/// </summary>
public string ServerIp { get; set; }

/// <summary>
/// Creates a new message.
/// </summary>
/// <param name="serverType"></param>
/// <param name="processId"></param>
/// <param name="serverId"></param>
/// <param name="processName"></param>
/// <param name="status"></param>
/// <param name="cpuUsagePercentage"></param>
/// <param name="processRamUsage"></param>
/// <param name="totalRAM"></param>
/// <param name="serverIp"></param>
public ResServerInformationMessage(ServerType serverType, int processId, int serverId, string processName, ServerStatus status, float cpuUsagePercentage, float processRamUsage, ulong totalRAM, string serverIp)
{
this.ServerType = serverType;
this.ProcessId = processId;
this.ServerId = serverId;
this.ProcessName = processName;
this.Status = status;
this.CpuUsagePercentage = cpuUsagePercentage;
this.ProcessRamUsage = processRamUsage;
this.TotalRAM = totalRAM;
this.ServerIp = serverIp;
}
}
}
8 changes: 4 additions & 4 deletions src/Shared/Network/Inter/Messages/ServerUpdateMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ public class ServerUpdateMessage : ICommMessage
/// <summary>
/// Returns the server's status.
/// </summary>
public ServerStatus Status { get; set; }
public ServerStatus ServerStatus { get; set; }

/// <summary>
/// Creates a new message.
/// </summary>
/// <param name="serverType"></param>
/// <param name="serverId"></param>
/// <param name="playerCount"></param>
/// <param name="status"></param>
public ServerUpdateMessage(ServerType serverType, int serverId, int playerCount, ServerStatus status)
/// <param name="serverStatus"></param>
public ServerUpdateMessage(ServerType serverType, int serverId, int playerCount, ServerStatus serverStatus)
{
this.ServerType = serverType;
this.ServerId = serverId;
this.PlayerCount = playerCount;
this.Status = status;
this.ServerStatus = serverStatus;
}
}
}
13 changes: 13 additions & 0 deletions src/Shared/Network/Inter/Messages/UpdateConfigsMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using Yggdrasil.Network.Communication;

namespace Melia.Shared.Network.Inter.Messages
{
/// <summary>
/// Instruction to kick all players.
/// </summary>
[Serializable]
public class ReqReloadConfigsMessage : ICommMessage
{
}
}
2 changes: 1 addition & 1 deletion src/Shared/Network/ServerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void Update(ServerUpdateMessage serverUpdateMessage)
return;

serverInfo.CurrentPlayers = serverUpdateMessage.PlayerCount;
serverInfo.Status = serverUpdateMessage.Status;
serverInfo.Status = serverUpdateMessage.ServerStatus;
}
}

Expand Down
Loading