diff --git a/build/ControlPanelVersion.props b/build/ControlPanelVersion.props index ba79100b84..98d6fd4bc5 100644 --- a/build/ControlPanelVersion.props +++ b/build/ControlPanelVersion.props @@ -1,6 +1,6 @@ - 2.0.1 + 2.1.2 diff --git a/build/Version.props b/build/Version.props index 1eb3527d2a..f8cbd5f8fc 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,8 +3,8 @@ - 4.8.2 - 2.3.0 + 4.9.0 + 3.0.0 8.3.0 9.2.0 6.0.1 diff --git a/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs b/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs index 13320674dc..3314c4eea5 100644 --- a/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Tgstation.Server.Host.Configuration { @@ -22,6 +22,11 @@ namespace Tgstation.Server.Host.Configuration /// public bool AllowAnyOrigin { get; set; } + /// + /// The channel to retrieve the webpanel from. "local" uses the bundled version. + /// + public string Channel { get; set; } + /// /// Origins allowed for CORS requests /// diff --git a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs index 28f68d21d7..71de870e2c 100644 --- a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs +++ b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs @@ -1,10 +1,14 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.StaticFiles; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; using System; +using System.Globalization; using System.Net.Mime; +using Tgstation.Server.Api; +using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Core; namespace Tgstation.Server.Host.Controllers @@ -20,13 +24,44 @@ namespace Tgstation.Server.Host.Controllers /// readonly IWebHostEnvironment hostEnvironment; + /// + /// The for the . + /// + readonly ControlPanelConfiguration controlPanelConfiguration; + /// /// Initializes a new instance of the . /// /// The value of . - public ControlPanelController(IWebHostEnvironment hostEnvironment) + /// The containing the value of . + public ControlPanelController(IWebHostEnvironment hostEnvironment, IOptions controlPanelConfigurationOptions) { this.hostEnvironment = hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment)); + controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions)); + } + + /// + /// Returns the . + /// + /// A with the . + [Route("channel.json")] + [HttpGet] + public JsonResult GetChannelJson() + { + var controlPanelChannel = controlPanelConfiguration.Channel; + if (controlPanelChannel == "local") + controlPanelChannel = Application.ControlPanelRoute; + + controlPanelChannel = controlPanelChannel + .Replace("${Major}", ApiHeaders.Version.Major.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal) + .Replace("${Minor}", ApiHeaders.Version.Minor.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal) + .Replace("${Patch}", ApiHeaders.Version.Build.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal); + + return Json(new + { + FormatVersion = 1, + Channel = controlPanelChannel, + }); } /// diff --git a/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs index 06d2665cbc..d6552a90d2 100644 --- a/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs +++ b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs @@ -36,6 +36,11 @@ namespace Tgstation.Server.Host.Properties /// public string RawHostWatchdogVersion { get; } + /// + /// The compile time default + /// + public string DefaultControlPanelChannel { get; } + /// /// Initializes a new instance of the . /// diff --git a/src/Tgstation.Server.Host/appsettings.yml b/src/Tgstation.Server.Host/appsettings.yml index b53cd2832a..a8467be26e 100644 --- a/src/Tgstation.Server.Host/appsettings.yml +++ b/src/Tgstation.Server.Host/appsettings.yml @@ -28,6 +28,7 @@ Logging: Microsoft: Warning ControlPanel: Enable: false + Channel: https://tgstation.github.io/tgstation-server-webpanel/api/${Major}.${Minor}.${Patch} AllowAnyOrigin: false AllowedOrigins: [] Updates: