mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 14:37:44 +01:00
Merge pull request #1213 from tgstation/1205-ChannelJson
Adds Webpanel Channels
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<!-- This is in it's own file to help incremental building, changing it causes a complete rebuild of the web panel -->
|
||||
<TgsControlPanelVersion>2.0.1</TgsControlPanelVersion>
|
||||
<TgsControlPanelVersion>2.1.2</TgsControlPanelVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
<!-- Integration tests will ensure they match across the board -->
|
||||
<Import Project="ControlPanelVersion.props" />
|
||||
<PropertyGroup>
|
||||
<TgsCoreVersion>4.8.2</TgsCoreVersion>
|
||||
<TgsConfigVersion>2.3.0</TgsConfigVersion>
|
||||
<TgsCoreVersion>4.9.0</TgsCoreVersion>
|
||||
<TgsConfigVersion>3.0.0</TgsConfigVersion>
|
||||
<TgsApiVersion>8.3.0</TgsApiVersion>
|
||||
<TgsClientVersion>9.2.0</TgsClientVersion>
|
||||
<TgsDmapiVersion>6.0.1</TgsDmapiVersion>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public bool AllowAnyOrigin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The channel to retrieve the webpanel from. "local" uses the bundled version.
|
||||
/// </summary>
|
||||
public string Channel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Origins allowed for CORS requests
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
readonly IWebHostEnvironment hostEnvironment;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ControlPanelConfiguration"/> for the <see cref="ControlPanelController"/>.
|
||||
/// </summary>
|
||||
readonly ControlPanelConfiguration controlPanelConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ControlPanelController"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
/// <param name="hostEnvironment">The value of <see cref="hostEnvironment"/>.</param>
|
||||
public ControlPanelController(IWebHostEnvironment hostEnvironment)
|
||||
/// <param name="controlPanelConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="controlPanelConfiguration"/>.</param>
|
||||
public ControlPanelController(IWebHostEnvironment hostEnvironment, IOptions<ControlPanelConfiguration> controlPanelConfigurationOptions)
|
||||
{
|
||||
this.hostEnvironment = hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment));
|
||||
controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="ControlPanelConfiguration.Channel"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="JsonResult"/> with the <see cref="ControlPanelConfiguration.Channel"/>.</returns>
|
||||
[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,
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -36,6 +36,11 @@ namespace Tgstation.Server.Host.Properties
|
||||
/// </summary>
|
||||
public string RawHostWatchdogVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The compile time default
|
||||
/// </summary>
|
||||
public string DefaultControlPanelChannel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MasterVersionsAttribute"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user