Settings for the server are now combined with the settings from the SDK. This introduces a large breaking change and a migration should be created. This refactor utilizes .NET Configuration and the Options pattern. This will allow for the overriding of any setting using envionment variables. It also means that Settings.yml can be used to override any .NET configuration. A SettingsProvider implementation was created, and any updating of settings was changed from SettingsService.SaveSettings() to SettingsProvider.Update(s => { ... })
137 lines
No EOL
4.9 KiB
Text
137 lines
No EOL
4.9 KiB
Text
@using System.Collections
|
|
@using LANCommander.Server.Settings.Enums
|
|
@inject UpdateService UpdateService
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<div class="login-download-pane-container">
|
|
<Popover Trigger="new[] { Trigger.Hover }">
|
|
<ContentTemplate>
|
|
<Flex Vertical Gap="FlexGap.Small">
|
|
@if (IsInitializing)
|
|
{
|
|
<span ita>Fetching Launchers …</span>
|
|
}
|
|
else if (DownloadLinks.Count() == 0)
|
|
{
|
|
<span>No Launchers available</span>
|
|
}
|
|
|
|
@foreach (var downloadLink in DownloadLinks)
|
|
{
|
|
<Button Type="ButtonType.Text"
|
|
Block
|
|
Icon="@downloadLink.Icon"
|
|
OnClick="() => NavigationManager.NavigateTo(downloadLink.Url, true)"
|
|
Style="text-align: left">
|
|
<GridRow Wrap="false" Align="@RowAlign.Middle" Justify="@RowJustify.SpaceBetween">
|
|
<GridCol Flex=@("auto")>
|
|
@downloadLink.Name
|
|
|
|
@foreach (var tag in downloadLink.Tags)
|
|
{
|
|
<Tag Icon="@tag.Icon" Color="@(tag.ColorOverride ?? TagColor.Green)">@tag.Name</Tag>
|
|
}
|
|
</GridCol>
|
|
<GridCol Flex=@("none")>
|
|
<div style="padding-left: 8px;">
|
|
@if (downloadLink.IsOnline)
|
|
{
|
|
<Icon Type="@IconType.Outline.Cloud" />
|
|
}
|
|
</div>
|
|
</GridCol>
|
|
</GridRow>
|
|
</Button>
|
|
|
|
}
|
|
</Flex>
|
|
</ContentTemplate>
|
|
<ChildContent>
|
|
<Button Type="ButtonType.Primary"
|
|
Size="ButtonSize.Large"
|
|
Disabled="@(DownloadLinks.Count() == 0)"
|
|
Loading="@(DownloadLinks.Count() == 0)"
|
|
>
|
|
Download Launcher
|
|
</Button>
|
|
</ChildContent>
|
|
</Popover>
|
|
</div>
|
|
|
|
@code {
|
|
class DownloadLink
|
|
{
|
|
public class Tag
|
|
{
|
|
public Tag(string name)
|
|
{
|
|
Name = name;
|
|
Icon = string.Empty;
|
|
}
|
|
public string Name { get; set; }
|
|
public string Icon { get; set; }
|
|
public TagColor? ColorOverride { get; set; }
|
|
}
|
|
|
|
public string Name { get; set; }
|
|
public string Url { get; set; }
|
|
public string Icon { get; set; }
|
|
public Tag[] Tags { get; set; }
|
|
public bool IsOnline { get; set; }
|
|
}
|
|
|
|
bool IsInitializing = false;
|
|
|
|
IEnumerable<DownloadLink> DownloadLinks = new List<DownloadLink>();
|
|
|
|
readonly string DefaultIcon = IconType.Fill.QuestionCircle;
|
|
readonly Hashtable _iconMap = new()
|
|
{
|
|
[LauncherPlatform.Windows] = IconType.Fill.Windows,
|
|
[LauncherPlatform.Linux] = IconType.Outline.Qq, // Not Linux, but QQ penguin
|
|
[LauncherPlatform.macOS] = IconType.Fill.Apple,
|
|
};
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
IsInitializing = true;
|
|
var artifacts = await UpdateService.GetLauncherArtifactsAsync();
|
|
|
|
DownloadLinks = artifacts
|
|
.OrderBy(a => a.Platform)
|
|
.ThenBy(a => a.Architecture)
|
|
.Select(a =>
|
|
{
|
|
var tags = new List<DownloadLink.Tag>();
|
|
|
|
if (artifacts.Count(art => art.Platform == a.Platform && art.Architecture == a.Architecture) > 1)
|
|
{
|
|
if (a.Url.ToLower().EndsWith(".exe"))
|
|
tags.Add(new DownloadLink.Tag("exe"));
|
|
else if (a.Url.ToLower().EndsWith(".zip"))
|
|
tags.Add(new DownloadLink.Tag("zip"));
|
|
}
|
|
|
|
if (a.IsNightly)
|
|
tags.Add(new DownloadLink.Tag("nightly") { Icon = IconType.Fill.Fire, ColorOverride = TagColor.Volcano });
|
|
else if (a.IsPrerelease)
|
|
tags.Add(new DownloadLink.Tag("pre") { ColorOverride = TagColor.Gold });
|
|
|
|
return new DownloadLink
|
|
{
|
|
Name = $"{a.Platform} ({a.Architecture})",
|
|
Icon = _iconMap[a.Platform]?.ToString() ?? DefaultIcon,
|
|
Url = a.Url,
|
|
Tags = tags.ToArray(),
|
|
IsOnline = a.IsOnline,
|
|
};
|
|
});
|
|
}
|
|
finally
|
|
{
|
|
IsInitializing = false;
|
|
}
|
|
}
|
|
} |