diff --git a/Plugins/LiveRadar/Controllers/RadarController.cs b/Plugins/LiveRadar/Controllers/RadarController.cs index 8920091b0..5a98f764c 100644 --- a/Plugins/LiveRadar/Controllers/RadarController.cs +++ b/Plugins/LiveRadar/Controllers/RadarController.cs @@ -1,9 +1,7 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using SharedLibraryCore.Dtos; using System.Linq; -using System.Text; using WebfrontCore.Controllers; namespace LiveRadar.Web.Controllers @@ -17,32 +15,50 @@ namespace LiveRadar.Web.Controllers }; [HttpGet] - public IActionResult Index() + [Route("Radar/{serverId}")] + public IActionResult Index(long? serverId = null) { ViewBag.IsFluid = true; + ViewBag.Title = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"]; + ViewBag.ActiveServerId = serverId ?? Manager.GetServers().FirstOrDefault()?.EndPoint; + ViewBag.Servers = Manager.GetServers().Select(_server => new ServerInfo() + { + Name = _server.Hostname, + ID = _server.EndPoint + }); + return View(); } + [HttpGet] + [Route("Radar/{serverId}/Map")] public IActionResult Map(long? serverId = null) { - var server = Manager.GetServers().FirstOrDefault(); - + var server = serverId == null ? Manager.GetServers().FirstOrDefault() : Manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId); var map = Plugin.Config.Configuration().Maps.FirstOrDefault(_map => _map.Name == server.CurrentMap.Name); - map.Alias = server.CurrentMap.Alias; - return Json(map); + if (map != null) + { + map.Alias = server.CurrentMap.Alias; + return Json(map); + } + + // occurs if we don't recognize the map + return StatusCode(500); } [HttpGet] + [Route("Radar/{serverId}/Data")] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Data(long? serverId = null) { - var server = serverId == null ? Manager.GetServers()[0] : Manager.GetServers().First(_server => _server.GetHashCode() == serverId); + var server = serverId == null ? Manager.GetServers()[0] : Manager.GetServers().First(_server => _server.EndPoint == serverId); var radarInfo = server.GetClientsAsList().Select(_client => _client.GetAdditionalProperty("LiveRadar")).ToList(); return Json(radarInfo); } [HttpGet] + [Route("Radar/Update")] public IActionResult Update(string payload) { var radarUpdate = RadarEvent.Parse(payload); diff --git a/Plugins/LiveRadar/LiveRadar.csproj b/Plugins/LiveRadar/LiveRadar.csproj index 48fd16d2d..ba5349765 100644 --- a/Plugins/LiveRadar/LiveRadar.csproj +++ b/Plugins/LiveRadar/LiveRadar.csproj @@ -20,6 +20,12 @@ + + + Never + + + diff --git a/Plugins/LiveRadar/Plugin.cs b/Plugins/LiveRadar/Plugin.cs index b1e8266d5..99c3d73eb 100644 --- a/Plugins/LiveRadar/Plugin.cs +++ b/Plugins/LiveRadar/Plugin.cs @@ -47,6 +47,8 @@ namespace LiveRadar Config.Set((LiveRadarConfiguration)new LiveRadarConfiguration().Generate()); await Config.Save(); } + + manager.GetPageList().Pages.Add(Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"], "/Radar/All"); } public Task OnTickAsync(Server S) diff --git a/Plugins/LiveRadar/Views/Radar/Index.cshtml b/Plugins/LiveRadar/Views/Radar/Index.cshtml index c819e3fae..da9f784d2 100644 --- a/Plugins/LiveRadar/Views/Radar/Index.cshtml +++ b/Plugins/LiveRadar/Views/Radar/Index.cshtml @@ -11,8 +11,21 @@ background-size: 1.5rem 1.5rem; } +
+
+ +
+
+
-
+
@@ -21,12 +34,12 @@
-
+
- + @section scripts { @@ -263,7 +276,7 @@
${player.kills}
-
+
${player.deaths}
${player.deaths == 0 ? player.kills.toFixed(2) : (player.kills / player.deaths).toFixed(2)}
diff --git a/Plugins/LiveRadar/Views/_ViewImports.cshtml b/Plugins/LiveRadar/Views/_ViewImports.cshtml new file mode 100644 index 000000000..a757b413b --- /dev/null +++ b/Plugins/LiveRadar/Views/_ViewImports.cshtml @@ -0,0 +1 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/Plugins/LiveRadar/wwwroot/images/compass_map_mp_rust@2x.png b/Plugins/LiveRadar/wwwroot/images/compass_map_mp_rust@2x.png deleted file mode 100644 index c5f0d0713..000000000 Binary files a/Plugins/LiveRadar/wwwroot/images/compass_map_mp_rust@2x.png and /dev/null differ diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index 75ddea2df..aa1575f9c 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -39,8 +39,6 @@ - - diff --git a/WebfrontCore/wwwroot/js/action.js b/WebfrontCore/wwwroot/js/action.js index d456674dc..3450d9438 100644 --- a/WebfrontCore/wwwroot/js/action.js +++ b/WebfrontCore/wwwroot/js/action.js @@ -95,7 +95,9 @@ $(document).ready(function () { $.each(ipAddresses, function (index, address) { $.get('https://ip2c.org/' + $(address).data('ip'), function (result) { const countryCode = result.split(';')[1].toLowerCase(); - $(address).css('background-image', `url(https://www.countryflags.io/${countryCode}/flat/64.png)`); + if (countryCode != 'zz') { + $(address).css('background-image', `url(https://www.countryflags.io/${countryCode}/flat/64.png)`); + } }); }); }