a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[frontend/pages] Add status button to Drive page

pancakes c5165f4b 926a1d9c

+37 -1
+3
Iceshrimp.Frontend/Core/ControllerModels/DriveControllerModel.cs
··· 39 39 40 40 public Task<DriveFolderResponse?> UpdateFolderParentAsync(string id, string? folderId) => 41 41 api.CallNullableAsync<DriveFolderResponse>(HttpMethod.Post, $"/drive/folder/{id}/move", data: new DriveMoveRequest { FolderId = folderId }); 42 + 43 + public Task<DriveStatusResponse> GetDriveStatusAsync() => 44 + api.CallAsync<DriveStatusResponse>(HttpMethod.Get, "/drive/status"); 42 45 }
+18
Iceshrimp.Frontend/Core/Miscellaneous/MeasurementHelper.cs
··· 1 + namespace Iceshrimp.Frontend.Core.Miscellaneous; 2 + 3 + public static class MeasurementHelper 4 + { 5 + private static readonly string[] ByteOrders = ["B", "kB", "MB", "GB"]; 6 + 7 + public static string BytesToHumanReadableSize(long value) 8 + { 9 + var order = 0; 10 + while (value >= 1000 && order < ByteOrders.Length - 1) 11 + { 12 + value /= 1000; 13 + order++; 14 + } 15 + 16 + return $"{value:N0} {ByteOrders[order]}"; 17 + } 18 + }
+16 -1
Iceshrimp.Frontend/Pages/DrivePage.razor
··· 33 33 @Loc["Drive"] 34 34 @if (State == State.Loaded && Folder is not null) 35 35 { 36 + @if (Status != null) 37 + { 38 + <span class="action btn" @onclick="ShowStatus" title="@Loc["Status"]"> 39 + <Icon Name="Icons.Info"/> 40 + <span>@Loc["Status"]</span> 41 + </span> 42 + } 36 43 <span class="action btn" @onclick="CreateFolder" title="@Loc["Create folder"]"> 37 44 <Icon Name="Icons.FolderPlus"/> 45 + <span>@Loc["Create folder"]</span> 38 46 </span> 39 47 <span class="action btn" @onclick="OpenUpload" title="@Loc["Upload file"]"> 40 48 <Icon Name="Icons.Upload"/> 49 + <span>@Loc["Upload file"]</span> 41 50 </span> 42 51 @if (Folder is { Id: not null, Files: [], Folders: [] }) 43 52 { 44 53 <span class="action btn" @onclick="DeleteFolder" title="@Loc["Delete folder"]"> 45 54 <Icon Name="Icons.FolderMinus"/> 55 + <span>@Loc["Delete folder"]</span> 46 56 </span> 47 57 } 48 58 } ··· 107 117 @code { 108 118 [Parameter] public string? Id { get; set; } 109 119 private DriveFolderResponse? Folder { get; set; } 110 - private State State { get; set; } 120 + private DriveStatusResponse? Status { get; set; } 121 + private State State { get; set; } 111 122 private InputFile UploadInput { get; set; } = null!; 112 123 private IJSObjectReference _module = null!; 113 124 ··· 119 130 try 120 131 { 121 132 Folder = await Api.Drive.GetFolderAsync(Id); 133 + Status = await Api.Drive.GetDriveStatusAsync(); 122 134 } 123 135 catch (Exception e) 124 136 { ··· 147 159 { 148 160 await Load(); 149 161 } 162 + 163 + private async Task ShowStatus() => 164 + await Global.NoticeDialog?.Display(Loc["Drive Status"] + "\n" + Loc["Total files: {0}", Status?.FileCount ?? 0] + "\n" + Loc["Storage usage: {0}", MeasurementHelper.BytesToHumanReadableSize(Status?.UsedSize ?? 0)])!; 150 165 151 166 private void NavigateToParent() 152 167 {