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

@ -36,7 +36,11 @@ public partial class App
var uiTarget = new MemoryTarget("ui"); var uiTarget = new MemoryTarget("ui");
var blackholeTarget = new NullTarget("blackhole"); 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(fileTarget);
config.AddRuleForAllLevels(consoleTarget); config.AddRuleForAllLevels(consoleTarget);
config.AddRuleForAllLevels(uiTarget); config.AddRuleForAllLevels(uiTarget);

View File

@ -1,6 +1,5 @@
@page "/gallery" @page "/gallery"
@using Wabbajack.RateLimiter
@using System.Globalization @using System.Globalization
@namespace Wabbajack.App.Blazor.Pages @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;"> <div style="height:1.5rem;">
<ProgressBar Percentage="@_downloadProgress" Text="@_downloadProgress.Value.ToString(CultureInfo.InvariantCulture)"/> <ProgressBar Percentage="@DownloadProgress" Text="@DownloadProgress.Value.ToString(CultureInfo.InvariantCulture)"/>
</div> </div>
</BottomBar> </BottomBar>
} }

View File

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

View File

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