This commit is contained in:
erri120 2022-01-21 16:11:44 +01:00
parent 9187fa2307
commit f1b17df03a
No known key found for this signature in database
GPG Key ID: 7FA9556C936B847C
4 changed files with 19 additions and 18 deletions

View File

@ -35,8 +35,12 @@ public partial class App
var consoleTarget = new ConsoleTarget("console");
var uiTarget = new MemoryTarget("ui");
var blackholeTarget = new NullTarget("blackhole");
if (!string.Equals("TRUE", Environment.GetEnvironmentVariable("DEBUG_BLAZOR", EnvironmentVariableTarget.Process), StringComparison.OrdinalIgnoreCase))
{
config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Debug, blackholeTarget, "Microsoft.AspNetCore.Components.*", true);
}
config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Debug, blackholeTarget, "Microsoft.AspNetCore.Components.*", true);
config.AddRuleForAllLevels(fileTarget);
config.AddRuleForAllLevels(consoleTarget);
config.AddRuleForAllLevels(uiTarget);

View File

@ -1,6 +1,5 @@
@page "/gallery"
@using Wabbajack.RateLimiter
@using System.Globalization
@namespace Wabbajack.App.Blazor.Pages
@ -36,11 +35,11 @@
}
}
@if (_downloadProgress != Percent.Zero && _downloadingMetaData is not null)
@if (DownloadingMetaData is not null)
{
<BottomBar Image="@_downloadingMetaData.Links.ImageUri" Title="Downloading..." Subtitle="@_downloadingMetaData.Title">
<BottomBar Image="@DownloadingMetaData.Links.ImageUri" Title="Downloading..." Subtitle="@DownloadingMetaData.Title">
<div style="height:1.5rem;">
<ProgressBar Percentage="@_downloadProgress" Text="@_downloadProgress.Value.ToString(CultureInfo.InvariantCulture)"/>
<ProgressBar Percentage="@DownloadProgress" Text="@DownloadProgress.Value.ToString(CultureInfo.InvariantCulture)"/>
</div>
</BottomBar>
}

View File

@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Shell;
using Microsoft.AspNetCore.Components;
@ -11,8 +9,6 @@ using Microsoft.Extensions.Logging;
using Wabbajack.App.Blazor.State;
using Wabbajack.Common;
using Wabbajack.DTOs;
using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
using Wabbajack.RateLimiter;
using Wabbajack.Services.OSIntegrated.Services;
@ -26,8 +22,8 @@ public partial class Gallery
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
[Inject] private ModListDownloadMaintainer Maintainer { get; set; } = default!;
private Percent _downloadProgress = Percent.Zero;
private ModlistMetadata? _downloadingMetaData;
private Percent DownloadProgress { get; set; } = Percent.Zero;
private ModlistMetadata? DownloadingMetaData { get; set; }
private IEnumerable<ModlistMetadata> Modlists => StateContainer.Modlists;
@ -52,13 +48,13 @@ public partial class Gallery
_shouldRender = true;
}
private async void OnClickDownload(ModlistMetadata metadata)
private async Task OnClickDownload(ModlistMetadata metadata)
{
// GlobalState.NavigationAllowed = !GlobalState.NavigationAllowed;
await Download(metadata);
}
private async void OnClickInformation(ModlistMetadata metadata)
private async Task OnClickInformation(ModlistMetadata metadata)
{
// TODO: [High] Implement information modal.
}
@ -66,8 +62,10 @@ public partial class Gallery
private async Task Download(ModlistMetadata metadata)
{
StateContainer.NavigationAllowed = false;
_downloadingMetaData = metadata;
DownloadingMetaData = metadata;
// TODO: download progress should be in ProgressBar component so it can refresh independently
try
{
var (progress, task) = Maintainer.DownloadModlist(metadata);
@ -77,13 +75,16 @@ public partial class Gallery
.Throttle(TimeSpan.FromMilliseconds(100))
.Subscribe(p =>
{
_downloadProgress = p;
DownloadProgress = p;
StateContainer.TaskBarState = new TaskBarState
{
Description = $"Downloading {metadata.Title}",
State = TaskbarItemProgressState.Indeterminate,
ProgressValue = p.Value
};
InvokeAsync(StateHasChanged);
// Dispatcher.CreateDefault().InvokeAsync(StateHasChanged);
}, () => { StateContainer.TaskBarState = new TaskBarState(); });
await task;

View File

@ -1,16 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Extensions.Logging;
using PInvoke;
using Silk.NET.Core.Native;
using Silk.NET.DXGI;
using Wabbajack.Common;
using Wabbajack.Installer;
using Wabbajack;
using Wabbajack.Paths.IO;
using static PInvoke.User32;
using UnmanagedType = System.Runtime.InteropServices.UnmanagedType;