Show machine photo thumbnails in machine details.

This commit is contained in:
2025-11-15 20:07:52 +00:00
parent 6a52c1f067
commit 1dcb062c35
6 changed files with 154 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Marechai.App.Helpers;
using Microsoft.Kiota.Abstractions.Serialization;
@@ -205,4 +206,39 @@ public class ComputersService
return null;
}
}
/// <summary>
/// Fetches the list of photo GUIDs for a machine from the API
/// </summary>
public async Task<List<Guid>> GetMachinePhotosAsync(int machineId)
{
try
{
_logger.LogInformation("Fetching photos for machine {MachineId} from API", machineId);
List<Guid?>? photos = await _apiClient.Machines[machineId].Photos.GetAsync();
if(photos == null || photos.Count == 0)
{
_logger.LogInformation("No photos found for machine {MachineId}", machineId);
return [];
}
// Filter out null values
var validPhotos = photos.Where(p => p.HasValue).Select(p => p!.Value).ToList();
_logger.LogInformation("Successfully fetched {Count} photos for machine {MachineId}",
validPhotos.Count,
machineId);
return validPhotos;
}
catch(Exception ex)
{
_logger.LogError(ex, "Error fetching photos for machine {MachineId} from API", machineId);
return [];
}
}
}