Add ByteSize component
This commit is contained in:
parent
baf4ec15b2
commit
dfce85371d
16 changed files with 45 additions and 28 deletions
|
|
@ -38,10 +38,10 @@
|
|||
</div>
|
||||
<div class="downloader-current-lower">
|
||||
<div class="downloader-current-lower-data">
|
||||
@ByteSizeLib.ByteSize.FromBytes(Progress.BytesDownloaded).ToString() / @ByteSizeLib.ByteSize.FromBytes(Progress.TotalBytes).ToString()
|
||||
<ByteSize Value="Progress.BytesDownloaded" /> / <ByteSize Value="Progress.BytesDownloaded" />
|
||||
</div>
|
||||
<div class="downloader-current-lower-speed">
|
||||
@ByteSizeLib.ByteSize.FromBytes(Progress.TransferSpeed).ToString()/s
|
||||
<ByteSize Value="Progress.TransferSpeed" />/s
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
<div class="queue-item-info">
|
||||
<div>
|
||||
<h3>@queueItem.Title</h3>
|
||||
<span>@ByteSizeLib.ByteSize.FromBytes(queueItem.TotalBytes)</span>
|
||||
<span><ByteSize Value="queueItem.TotalBytes" /></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="queue-item-actions">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<div style="padding: 16px;">
|
||||
<Row Gutter="16">
|
||||
<Col Span="12">
|
||||
<Statistic Title="Download Size" Value="@ByteSizeLib.ByteSize.FromBytes(GetDownloadSize()).ToString()" Style="text-align: center;" />
|
||||
<Statistic Title="Download Size" Value="@ByteSizeLib.ByteSize.FromBytes(GetDownloadSize()).ToString()" Style="text-align: center;"/>
|
||||
</Col>
|
||||
<Col Span="12">
|
||||
<Statistic Title="Space Required" Value="@ByteSizeLib.ByteSize.FromBytes(GetSpaceRequired()).ToString()" Style="text-align: center;"/>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
@directory
|
||||
</GridCol>
|
||||
<GridCol>
|
||||
@ByteSizeLib.ByteSize.FromBytes(GetFreeSpace(directory))
|
||||
<ByteSize Value="GetFreeSpace(directory)" />
|
||||
</GridCol>
|
||||
</GridRow>
|
||||
</Radio>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<Table DataSource="Saves" Size="TableSize.Small" PageIndex="@CurrentPage" PageSize="@PageSize" PaginationPosition="none">
|
||||
<PropertyColumn Property="s => s.CreatedOn" Title="Created On" />
|
||||
<PropertyColumn Property="s => s.Size">
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.Size)
|
||||
<ByteSize Value="context.Size" />
|
||||
</PropertyColumn>
|
||||
<ActionColumn>
|
||||
<Flex Justify="FlexJustify.End">
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
<Column TData="string" Title="Local Size">
|
||||
@if (context.LocalFileInfo?.Length > 0)
|
||||
{
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.LocalFileInfo.Length)
|
||||
<ByteSize Value="context.LocalFileInfo.Length" />
|
||||
}
|
||||
</Column>
|
||||
<PropertyColumn Property="c => c.Length" Title="Original Size">
|
||||
@if (context.Length > 0)
|
||||
{
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.Length)
|
||||
<ByteSize Value="context.Length" />
|
||||
}
|
||||
</PropertyColumn>
|
||||
</Table>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class FileTransferMonitor : IDisposable
|
|||
}
|
||||
|
||||
public long GetBytesTransferred() => _lastBytesTransferred;
|
||||
public double GetSpeed() => _smoothedTransferRate;
|
||||
public long GetSpeed() => (long)_smoothedTransferRate;
|
||||
|
||||
public TimeSpan GetTimeRemaining()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace LANCommander.SDK.Services
|
|||
}
|
||||
set { }
|
||||
}
|
||||
public double TransferSpeed { get; set; }
|
||||
public long TransferSpeed { get; set; }
|
||||
public long BytesDownloaded { get; set; }
|
||||
public long TotalBytes { get; set; }
|
||||
public TimeSpan TimeRemaining { get; set; }
|
||||
|
|
@ -763,7 +763,7 @@ namespace LANCommander.SDK.Services
|
|||
|
||||
GameInstallProgress.BytesDownloaded = pos;
|
||||
GameInstallProgress.TotalBytes = len;
|
||||
GameInstallProgress.TransferSpeed = (double)(bytesThisInterval / (stopwatch.ElapsedMilliseconds / 1000d));
|
||||
GameInstallProgress.TransferSpeed = (long)(bytesThisInterval / (stopwatch.ElapsedMilliseconds / 1000d));
|
||||
|
||||
OnGameInstallProgressUpdate?.Invoke(GameInstallProgress);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@
|
|||
<Input Type="InputType.Text" Bordered="false" @bind-Value="context.Version" OnBlur="() => Update(context)"/>
|
||||
</BoundDataColumn>
|
||||
<BoundDataColumn Property="a => a.CompressedSize">
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.CompressedSize)
|
||||
<ByteSize Value="context.CompressedSize" />
|
||||
</BoundDataColumn>
|
||||
<BoundDataColumn Property="a => a.UncompressedSize">
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.UncompressedSize)
|
||||
<ByteSize Value="context.UncompressedSize" />
|
||||
</BoundDataColumn>
|
||||
<BoundDataColumn Property="a => a.CreatedBy != null ? a.CreatedBy.UserName : String.Empty" Include="CreatedBy"/>
|
||||
<BoundDataColumn Property="a => a.CreatedOn" Format="MM/dd/yyyy hh:mm tt" DefaultSortOrder="SortDirection.Descending"/>
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@
|
|||
@FileSource.GetEntryName(context)
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="e => e.Size" Sortable Title="Size">
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.Size)
|
||||
<ByteSize Value="context.Size" />
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="e => e.ModifiedOn" Format="MM/dd/yyyy hh:mm tt" Sortable Title="Modified" />
|
||||
</Table>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<BoundDataColumn Property="g => g.User.UserName" Include="User" />
|
||||
<BoundDataColumn Property="g => g.CreatedOn" Format="MM/dd/yyyy hh:mm tt" DefaultSortOrder="SortDirection.Descending" />
|
||||
<BoundDataColumn Property="g => g.Size">
|
||||
@ByteSizeLib.ByteSize.FromBytes(save.Size)
|
||||
<ByteSize Value="save.Size" />
|
||||
</BoundDataColumn>
|
||||
<DataActions>
|
||||
<a href="/Download/Save/@(save.Id)" target="_blank" class="ant-btn ant-btn-text ant-btn-icon-only">
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
<BoundDataColumn Property="s => s.Game.Title" Sortable Title="Game" Include="Game" />
|
||||
<BoundDataColumn Property="s => s.CreatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable Title="Created On" DefaultSortOrder="SortDirection.Descending" />
|
||||
<BoundDataColumn Property="s => s.Size" Sortable Title="Size">
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.Size)
|
||||
<ByteSize Value="context.Size" />
|
||||
</BoundDataColumn>
|
||||
<DataActions>
|
||||
<a href="/Download/Save/@(context.Id)" target="_blank" class="ant-btn ant-btn-text ant-btn-icon-only">
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
@inject UpdateService UpdateService
|
||||
@inject IMessageService MessageService
|
||||
@inject IFusionCache FusionCache
|
||||
@inject ILogger<Index> Logger
|
||||
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
||||
|
||||
<PageHeader Title="Tools" />
|
||||
|
|
@ -64,23 +65,31 @@
|
|||
async Task RecalculateFileSizes()
|
||||
{
|
||||
RecalculatingFileSizes = true;
|
||||
|
||||
|
||||
await Task.Yield();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
using (var archiveService = DatabaseServiceFactory.Create<ArchiveService>())
|
||||
{
|
||||
var archives = await archiveService.GetAsync();
|
||||
var archives = await archiveService.AsNoTracking().GetAsync();
|
||||
|
||||
foreach (var archive in archives)
|
||||
{
|
||||
var path = await archiveService.GetArchiveFileLocationAsync(archive);
|
||||
|
||||
if (File.Exists(path))
|
||||
try
|
||||
{
|
||||
archive.CompressedSize = await archiveService.GetCompressedSizeAsync(archive);
|
||||
archive.UncompressedSize = await archiveService.GetUncompressedSizeAsync(archive);
|
||||
var path = await archiveService.GetArchiveFileLocationAsync(archive);
|
||||
|
||||
await archiveService.UpdateAsync(archive);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
archive.CompressedSize = await archiveService.GetCompressedSizeAsync(archive);
|
||||
archive.UncompressedSize = await archiveService.GetUncompressedSizeAsync(archive);
|
||||
|
||||
await archiveService.UpdateAsync(archive);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogError(ex, "Could not recalculate file size for archive {ArchiveId}", archive.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -88,11 +97,14 @@
|
|||
MessageService.Success("File sizes recalculated!");
|
||||
|
||||
RecalculatingFileSizes = false;
|
||||
|
||||
await Task.Yield();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
async Task ClearCache()
|
||||
{
|
||||
await FusionCache.ExpireAsync("MappedGames");
|
||||
await FusionCache.ExpireAsync("Games");
|
||||
|
||||
MessageService.Success("Cache cleared!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<Table TItem="OrphanedFile" DataSource="@Orphans" Loading="@Loading" PageSize="25" Responsive>
|
||||
<PropertyColumn Property="f => f.Path" />
|
||||
<PropertyColumn Property="f => f.Size" Sortable>
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.Size).ToString()
|
||||
<ByteSize Value="context.Size" />
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="f => f.CreatedOn" Format="MM/dd/yyyy hh:mm tt" Sortable />
|
||||
<ActionColumn Title="" Style="text-align: right">
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
@String.Join(", ", context.Roles)
|
||||
</PropertyColumn>
|
||||
<PropertyColumn Property="u => u.SavesSize" Title="Saves">
|
||||
@ByteSizeLib.ByteSize.FromBytes(context.SavesSize)
|
||||
<ByteSize Value="context.SavesSize" />
|
||||
</PropertyColumn>
|
||||
<ActionColumn>
|
||||
<Space Style="display: flex; justify-content: end">
|
||||
|
|
|
|||
5
LANCommander.UI/Components/ByteSize.razor
Normal file
5
LANCommander.UI/Components/ByteSize.razor
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
@ByteSizeLib.ByteSize.FromBytes(Value).ToString()
|
||||
|
||||
@code {
|
||||
[Parameter] public long Value { get; set; }
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
<Icon Type="@IconType.Outline.FileZip" />
|
||||
</div>
|
||||
<span target="_blank" rel="noopener noreferrer" class="ant-upload-list-item-name" title="@File.Name (@ByteSizeLib.ByteSize.FromBytes(File.Size))">
|
||||
@File.Name (@ByteSizeLib.ByteSize.FromBytes(File.Size))
|
||||
@File.Name (<ByteSize Value="File.Size" />)
|
||||
</span>
|
||||
<span class="ant-upload-list-item-card-actions picture">
|
||||
<Button Type="ButtonType.Text" Size="ButtonSize.Small" Icon="@IconType.Outline.Delete" OnClick="Clear" Disabled="@(CurrentProgressStatus != ProgressStatus.Normal)" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue