@using DeepDrftModels.Enums @using Microsoft.AspNetCore.Components.Forms @inject IHttpClientFactory HttpClientFactory @foreach (var rt in Enum.GetValues()) { @rt } @if (SelectedImageFile is { } selectedImage) { Selected: @selectedImage.Name } else if (ExistingImagePreviewUrl is { } previewUrl) { Current cover art. } else { No cover art — optional. } @if (SelectedImageFile is not null) { Will upload on submit. } @code { [Parameter] public string AlbumName { get; set; } = string.Empty; [Parameter] public EventCallback AlbumNameChanged { get; set; } [Parameter] public string Artist { get; set; } = string.Empty; [Parameter] public EventCallback ArtistChanged { get; set; } [Parameter] public string Genre { get; set; } = string.Empty; [Parameter] public EventCallback GenreChanged { get; set; } [Parameter] public string ReleaseDate { get; set; } = string.Empty; [Parameter] public EventCallback ReleaseDateChanged { get; set; } [Parameter] public ReleaseType ReleaseType { get; set; } = ReleaseType.Single; [Parameter] public EventCallback ReleaseTypeChanged { get; set; } [Parameter] public IBrowserFile? SelectedImageFile { get; set; } [Parameter] public EventCallback SelectedImageFileChanged { get; set; } // BatchEdit only: when set (and no new file picked), preview the release's current cover. // The parent nulls this to drop the preview when the admin clears the existing cover. [Parameter] public string? ExistingImagePath { get; set; } [Parameter] public bool Disabled { get; set; } // The image endpoint (GET api/image/{entryKey}) is unauthenticated, so the browser hits // DeepDrftAPI directly. Base address comes from the same named client the CMS uses. private string? ExistingImagePreviewUrl { get { if (string.IsNullOrEmpty(ExistingImagePath)) return null; var baseAddress = HttpClientFactory.CreateClient("DeepDrft.Content.Cms").BaseAddress; return baseAddress is null ? null : new Uri(baseAddress, $"api/image/{Uri.EscapeDataString(ExistingImagePath)}").ToString(); } } private Task HandleImageFileSelected(InputFileChangeEventArgs e) => SelectedImageFileChanged.InvokeAsync(e.File); private Task ClearSelectedFile() => SelectedImageFileChanged.InvokeAsync(null); }