@using AntDesign.Charts @using LANCommander.SDK.Enums @inject StorageLocationService StorageLocationService @code { object[] Data; bool Loading = true; string JsConfig = @"{ meta: { value: { alias: 'Data Usage', formatter: (v) => Uploader.GetHumanFileSize(v, true, 1) } }, label: { visible: true, type: 'outer-center' } }"; PieConfig Config = new PieConfig { Radius = 0.8, AngleField = "value", ColorField = "type", }; protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { var settings = SettingService.GetSettings(); var drives = DriveInfo.GetDrives(); var root = Path.GetPathRoot(System.Reflection.Assembly.GetExecutingAssembly().Location); long totalAvailableFreeSpace = drives.Where(d => d.IsReady && d.Name == root).Sum(d => d.AvailableFreeSpace); long totalSaveDirectorySize = 0; long totalMediaDirectorySize = 0; long totalUploadDirectorySize = 0; var storageLocations = await StorageLocationService.GetAsync(); foreach (var storageLocation in storageLocations) { switch (storageLocation.Type) { case StorageLocationType.Archive: totalUploadDirectorySize += new DirectoryInfo(storageLocation.Path).EnumerateFiles().Sum(f => f.Length); break; case StorageLocationType.Save: totalSaveDirectorySize += new DirectoryInfo(storageLocation.Path).EnumerateFiles().Sum(f => f.Length); break; case StorageLocationType.Media: totalSaveDirectorySize += new DirectoryInfo(storageLocation.Path).EnumerateFiles().Sum(f => f.Length); break; } } Data = new object[] { new { type = "Free", value = totalAvailableFreeSpace }, new { type = "Games", value = totalUploadDirectorySize }, new { type = "Saves", value = totalSaveDirectorySize }, new { type = "Media", value = totalMediaDirectorySize } }; Loading = false; StateHasChanged(); } } }