Compare commits

...

2 Commits

Author SHA1 Message Date
max
0ab0a029c4 [CHANGE] Working on client manager 2025-08-31 21:36:53 +02:00
max
2f018d131e [CHANGE] Small changes, renamed app title 2025-08-31 21:08:14 +02:00
4 changed files with 44 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ public partial class ApplicationLayout
[CascadingParameter]
public BaseLayout? BaseLayout { get; set; }
public bool DrawerOpen { get; set; } = true;
public string AppText { get; set; } = "YouTube Import";
public string AppText { get; set; } = "YouTube Manager";
private void ToggleDrawerOpen()
{

View File

@@ -24,7 +24,7 @@
</tr>
<tr>
<td>Library size:</td>
<td>@Suffix.BytesToSizeSuffix(_libraryInformation.TotalSizeBytes)</td>
<td>@($"{Suffix.BytesToSizeSuffix(_libraryInformation.TotalSizeBytes)} ({_libraryInformation.TotalSizeBytes} bytes)")</td>
</tr>
<tr>

View File

@@ -2,6 +2,7 @@ using DotBased.Monads;
using Manager.App.Models.Library;
using Manager.App.Models.Settings;
using Manager.Data.Contexts;
using Manager.Data.Entities.LibraryContext;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
@@ -45,13 +46,21 @@ public class LibraryService : ILibraryService
}
catch (Exception e)
{
if (e is OperationCanceledException)
{
return ResultError.Fail("Library service operation cancelled");
}
return HandleException(e);
}
}
_logger.LogError(e, "Failed to get library information");
return ResultError.Fail("Failed to get library information");
public async Task<Result<List<ClientAccountEntity>>> GetAccountsAsync(int total = 20, int offset = 0, CancellationToken cancellationToken = default)
{
try
{
await using var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
var orderedAccounts = context.Accounts.OrderBy(x => x.Id).Skip(offset).Take(total);
return orderedAccounts.ToList();
}
catch (Exception e)
{
return HandleException(e);
}
}
@@ -59,7 +68,7 @@ public class LibraryService : ILibraryService
{
try
{
var size = dir.EnumerateFiles("", SearchOption.AllDirectories).Select(f => f.Length).Sum();
var size = dir.EnumerateFiles("*", SearchOption.AllDirectories).Select(f => f.Length).Sum();
return size;
}
catch (Exception e)
@@ -68,4 +77,15 @@ public class LibraryService : ILibraryService
throw;
}
}
private ResultError HandleException(Exception exception)
{
if (exception is OperationCanceledException)
{
return ResultError.Fail("Library service operation cancelled");
}
_logger.LogError(exception, "Failed to get library information");
return ResultError.Fail("Failed to get library information");
}
}

View File

@@ -0,0 +1,15 @@
using Manager.YouTube;
namespace Manager.App.Services.System;
public class ClientManager : BackgroundService
{
private readonly List<YouTubeClient> _clients = [];
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
throw new NotImplementedException();
}
}