2025-02-15 23:45:51 -06:00
|
|
|
@using System.Collections
|
2025-11-16 12:31:25 -06:00
|
|
|
@using LANCommander.Server.Settings.Enums
|
2025-02-13 02:11:23 -06:00
|
|
|
@inject UpdateService UpdateService
|
2025-02-15 23:45:51 -06:00
|
|
|
@inject NavigationManager NavigationManager
|
2025-02-13 02:11:23 -06:00
|
|
|
|
2025-02-15 23:45:51 -06:00
|
|
|
<div class="login-download-pane-container">
|
|
|
|
|
<Popover Trigger="new[] { Trigger.Hover }">
|
|
|
|
|
<ContentTemplate>
|
|
|
|
|
<Flex Vertical Gap="FlexGap.Small">
|
2025-04-12 19:53:34 +02:00
|
|
|
@if (IsInitializing)
|
|
|
|
|
{
|
|
|
|
|
<span ita>Fetching Launchers …</span>
|
|
|
|
|
}
|
|
|
|
|
else if (DownloadLinks.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
<span>No Launchers available</span>
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-15 23:45:51 -06:00
|
|
|
@foreach (var downloadLink in DownloadLinks)
|
|
|
|
|
{
|
2025-04-12 22:47:53 +02:00
|
|
|
<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
|
2025-04-12 19:53:34 +02:00
|
|
|
|
2025-04-12 22:47:53 +02:00
|
|
|
@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>
|
2025-02-15 23:45:51 -06:00
|
|
|
</Button>
|
2025-04-12 22:47:53 +02:00
|
|
|
|
2025-02-15 23:45:51 -06:00
|
|
|
}
|
|
|
|
|
</Flex>
|
|
|
|
|
</ContentTemplate>
|
|
|
|
|
<ChildContent>
|
2025-04-12 19:53:34 +02:00
|
|
|
<Button Type="ButtonType.Primary"
|
|
|
|
|
Size="ButtonSize.Large"
|
|
|
|
|
Disabled="@(DownloadLinks.Count() == 0)"
|
|
|
|
|
Loading="@(DownloadLinks.Count() == 0)"
|
|
|
|
|
>
|
2025-02-15 23:45:51 -06:00
|
|
|
Download Launcher
|
|
|
|
|
</Button>
|
|
|
|
|
</ChildContent>
|
|
|
|
|
</Popover>
|
|
|
|
|
</div>
|
2025-02-13 02:11:23 -06:00
|
|
|
|
|
|
|
|
@code {
|
2025-02-15 23:45:51 -06:00
|
|
|
class DownloadLink
|
|
|
|
|
{
|
2025-04-12 22:47:53 +02:00
|
|
|
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; }
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-15 23:45:51 -06:00
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Url { get; set; }
|
|
|
|
|
public string Icon { get; set; }
|
2025-04-12 22:47:53 +02:00
|
|
|
public Tag[] Tags { get; set; }
|
|
|
|
|
public bool IsOnline { get; set; }
|
2025-02-15 23:45:51 -06:00
|
|
|
}
|
|
|
|
|
|
2025-04-12 19:53:34 +02:00
|
|
|
bool IsInitializing = false;
|
|
|
|
|
|
2025-02-15 23:45:51 -06:00
|
|
|
IEnumerable<DownloadLink> DownloadLinks = new List<DownloadLink>();
|
|
|
|
|
|
2025-04-12 22:47:53 +02:00
|
|
|
readonly string DefaultIcon = IconType.Fill.QuestionCircle;
|
2025-02-15 23:45:51 -06:00
|
|
|
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()
|
|
|
|
|
{
|
2025-04-12 19:53:34 +02:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IsInitializing = true;
|
|
|
|
|
var artifacts = await UpdateService.GetLauncherArtifactsAsync();
|
2025-02-28 23:28:10 -06:00
|
|
|
|
2025-04-12 19:53:34 +02:00
|
|
|
DownloadLinks = artifacts
|
|
|
|
|
.OrderBy(a => a.Platform)
|
|
|
|
|
.ThenBy(a => a.Architecture)
|
|
|
|
|
.Select(a =>
|
2025-02-28 23:28:10 -06:00
|
|
|
{
|
2025-04-12 22:47:53 +02:00
|
|
|
var tags = new List<DownloadLink.Tag>();
|
2025-04-12 19:53:34 +02:00
|
|
|
|
|
|
|
|
if (artifacts.Count(art => art.Platform == a.Platform && art.Architecture == a.Architecture) > 1)
|
|
|
|
|
{
|
|
|
|
|
if (a.Url.ToLower().EndsWith(".exe"))
|
2025-04-12 22:47:53 +02:00
|
|
|
tags.Add(new DownloadLink.Tag("exe"));
|
2025-04-12 19:53:34 +02:00
|
|
|
else if (a.Url.ToLower().EndsWith(".zip"))
|
2025-04-12 22:47:53 +02:00
|
|
|
tags.Add(new DownloadLink.Tag("zip"));
|
2025-04-12 19:53:34 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-12 22:47:53 +02:00
|
|
|
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 });
|
|
|
|
|
|
2025-04-12 19:53:34 +02:00
|
|
|
return new DownloadLink
|
|
|
|
|
{
|
|
|
|
|
Name = $"{a.Platform} ({a.Architecture})",
|
2025-04-12 22:47:53 +02:00
|
|
|
Icon = _iconMap[a.Platform]?.ToString() ?? DefaultIcon,
|
2025-04-12 19:53:34 +02:00
|
|
|
Url = a.Url,
|
2025-04-12 22:47:53 +02:00
|
|
|
Tags = tags.ToArray(),
|
|
|
|
|
IsOnline = a.IsOnline,
|
2025-04-12 19:53:34 +02:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
IsInitializing = false;
|
|
|
|
|
}
|
2025-02-15 23:45:51 -06:00
|
|
|
}
|
2025-02-13 02:11:23 -06:00
|
|
|
}
|