Compare commits
4 Commits
dd30d57838
...
f07ad58655
| Author | SHA1 | Date | |
|---|---|---|---|
| f07ad58655 | |||
| 2f7f8dbdf8 | |||
| 528b904d72 | |||
| 0448711082 |
+4
-1
@@ -314,4 +314,7 @@ Database/Vaults/*
|
|||||||
**/wwwroot/js/*
|
**/wwwroot/js/*
|
||||||
# ...except hand-authored client JS modules (not TS compile output).
|
# ...except hand-authored client JS modules (not TS compile output).
|
||||||
!DeepDrftPublic.Client/wwwroot/js/
|
!DeepDrftPublic.Client/wwwroot/js/
|
||||||
!DeepDrftPublic.Client/wwwroot/js/*.js
|
!DeepDrftPublic.Client/wwwroot/js/*.js
|
||||||
|
# RCL compiled JS must be committed — MapStaticAssets serves from build-time manifest;
|
||||||
|
# gitignored TS output is absent when manifest is generated, so absent from publish output.
|
||||||
|
!DeepDrftShared.Client/wwwroot/js/parallax/
|
||||||
@@ -59,9 +59,12 @@ public class ReleaseConfiguration : BaseEntityConfiguration<ReleaseEntity>
|
|||||||
|
|
||||||
// Unique constraint on the natural key (title + artist). Prevents duplicate release rows
|
// Unique constraint on the natural key (title + artist). Prevents duplicate release rows
|
||||||
// from concurrent uploads of the same album. The FindOrCreateRelease path catches the
|
// from concurrent uploads of the same album. The FindOrCreateRelease path catches the
|
||||||
// resulting ClassifiedDbException (UniqueViolation) and re-queries for the winning row.
|
// resulting UniqueViolation and re-queries for the winning row.
|
||||||
|
// Partial filter excludes soft-deleted rows so re-uploading a deleted release does not
|
||||||
|
// hit a uniqueness conflict when FindOrCreateRelease creates a fresh row.
|
||||||
builder.HasIndex(e => new { e.Title, e.Artist })
|
builder.HasIndex(e => new { e.Title, e.Artist })
|
||||||
.IsUnique()
|
.IsUnique()
|
||||||
.HasDatabaseName("IX_release_title_artist");
|
.HasDatabaseName("IX_release_title_artist")
|
||||||
|
.HasFilter("\"is_deleted\" = false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+179
@@ -0,0 +1,179 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DeepDrftData.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DeepDrftData.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DeepDrftContext))]
|
||||||
|
[Migration("20260612102604_MakeReleaseTitleArtistUniquePartial")]
|
||||||
|
partial class MakeReleaseTitleArtistUniquePartial
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "10.0.7")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DeepDrftModels.Entities.ReleaseEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Artist")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)")
|
||||||
|
.HasColumnName("artist");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created_at");
|
||||||
|
|
||||||
|
b.Property<long?>("CreatedByUserId")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasColumnName("created_by_user_id");
|
||||||
|
|
||||||
|
b.Property<string>("Genre")
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("genre");
|
||||||
|
|
||||||
|
b.Property<string>("ImagePath")
|
||||||
|
.HasMaxLength(500)
|
||||||
|
.HasColumnType("character varying(500)")
|
||||||
|
.HasColumnName("image_path");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false)
|
||||||
|
.HasColumnName("is_deleted");
|
||||||
|
|
||||||
|
b.Property<DateOnly?>("ReleaseDate")
|
||||||
|
.HasColumnType("date")
|
||||||
|
.HasColumnName("release_date");
|
||||||
|
|
||||||
|
b.Property<string>("ReleaseType")
|
||||||
|
.IsRequired()
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)")
|
||||||
|
.HasDefaultValue("Single")
|
||||||
|
.HasColumnName("release_type");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)")
|
||||||
|
.HasColumnName("title");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated_at");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IsDeleted")
|
||||||
|
.HasDatabaseName("IX_release_is_deleted");
|
||||||
|
|
||||||
|
b.HasIndex("Title", "Artist")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("IX_release_title_artist")
|
||||||
|
.HasFilter("\"is_deleted\" = false");
|
||||||
|
|
||||||
|
b.ToTable("release", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DeepDrftModels.Entities.TrackEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created_at");
|
||||||
|
|
||||||
|
b.Property<string>("EntryKey")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("entry_key");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false)
|
||||||
|
.HasColumnName("is_deleted");
|
||||||
|
|
||||||
|
b.Property<string>("OriginalFileName")
|
||||||
|
.HasMaxLength(500)
|
||||||
|
.HasColumnType("character varying(500)")
|
||||||
|
.HasColumnName("original_file_name");
|
||||||
|
|
||||||
|
b.Property<long?>("ReleaseId")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasColumnName("release_id");
|
||||||
|
|
||||||
|
b.Property<string>("TrackName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)")
|
||||||
|
.HasColumnName("track_name");
|
||||||
|
|
||||||
|
b.Property<int>("TrackNumber")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasDefaultValue(1)
|
||||||
|
.HasColumnName("track_number");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated_at");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IsDeleted")
|
||||||
|
.HasDatabaseName("IX_track_is_deleted");
|
||||||
|
|
||||||
|
b.HasIndex("ReleaseId");
|
||||||
|
|
||||||
|
b.ToTable("track", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DeepDrftModels.Entities.TrackEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DeepDrftModels.Entities.ReleaseEntity", "Release")
|
||||||
|
.WithMany("Tracks")
|
||||||
|
.HasForeignKey("ReleaseId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.Navigation("Release");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DeepDrftModels.Entities.ReleaseEntity", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Tracks");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DeepDrftData.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class MakeReleaseTitleArtistUniquePartial : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_release_title_artist",
|
||||||
|
table: "release");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_release_title_artist",
|
||||||
|
table: "release",
|
||||||
|
columns: new[] { "title", "artist" },
|
||||||
|
unique: true,
|
||||||
|
filter: "\"is_deleted\" = false");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_release_title_artist",
|
||||||
|
table: "release");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_release_title_artist",
|
||||||
|
table: "release",
|
||||||
|
columns: new[] { "title", "artist" },
|
||||||
|
unique: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -90,7 +90,8 @@ namespace DeepDrftData.Migrations
|
|||||||
|
|
||||||
b.HasIndex("Title", "Artist")
|
b.HasIndex("Title", "Artist")
|
||||||
.IsUnique()
|
.IsUnique()
|
||||||
.HasDatabaseName("IX_release_title_artist");
|
.HasDatabaseName("IX_release_title_artist")
|
||||||
|
.HasFilter("\"is_deleted\" = false");
|
||||||
|
|
||||||
b.ToTable("release", (string)null);
|
b.ToTable("release", (string)null);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
@using DeepDrftModels.Enums
|
@using DeepDrftModels.Enums
|
||||||
@using Microsoft.AspNetCore.Components.Forms
|
@using Microsoft.AspNetCore.Components.Forms
|
||||||
@inject IHttpClientFactory HttpClientFactory
|
|
||||||
|
|
||||||
<MudPaper Class="pa-6 mb-4" Elevation="2">
|
<MudPaper Class="pa-6 mb-4" Elevation="2">
|
||||||
<MudGrid>
|
<MudGrid>
|
||||||
@@ -93,19 +92,11 @@
|
|||||||
|
|
||||||
[Parameter] public bool Disabled { get; set; }
|
[Parameter] public bool Disabled { get; set; }
|
||||||
|
|
||||||
// The image endpoint (GET api/image/{entryKey}) is unauthenticated, so the browser hits
|
// Relative path — resolves against the Manager's own origin, proxied by ImageProxyController.
|
||||||
// DeepDrftAPI directly. Base address comes from the same named client the CMS uses.
|
private string? ExistingImagePreviewUrl =>
|
||||||
private string? ExistingImagePreviewUrl
|
string.IsNullOrEmpty(ExistingImagePath)
|
||||||
{
|
? null
|
||||||
get
|
: $"/api/image/{Uri.EscapeDataString(ExistingImagePath)}";
|
||||||
{
|
|
||||||
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) =>
|
private Task HandleImageFileSelected(InputFileChangeEventArgs e) =>
|
||||||
SelectedImageFileChanged.InvokeAsync(e.File);
|
SelectedImageFileChanged.InvokeAsync(e.File);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
@using DeepDrftManager.Services
|
@using DeepDrftManager.Services
|
||||||
@using DeepDrftModels.DTOs
|
@using DeepDrftModels.DTOs
|
||||||
@inject ICmsTrackService CmsTrackService
|
@inject ICmsTrackService CmsTrackService
|
||||||
@inject IHttpClientFactory HttpClientFactory
|
|
||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
@inject ISnackbar Snackbar
|
@inject ISnackbar Snackbar
|
||||||
@inject ILogger<CmsAlbumBrowser> Logger
|
@inject ILogger<CmsAlbumBrowser> Logger
|
||||||
@@ -126,13 +125,6 @@ else
|
|||||||
// back. We only re-project when the parent hands us a genuinely new list.
|
// back. We only re-project when the parent hands us a genuinely new list.
|
||||||
private IReadOnlyList<ReleaseDto>? _projectedReleases;
|
private IReadOnlyList<ReleaseDto>? _projectedReleases;
|
||||||
|
|
||||||
// The cover-art endpoint (GET api/image/{entryKey}) lives on DeepDrftAPI and is unauthenticated,
|
|
||||||
// so the browser hits it directly. Base address comes from the same named client the CMS uses.
|
|
||||||
private Uri? _contentApiBase;
|
|
||||||
|
|
||||||
protected override void OnInitialized() =>
|
|
||||||
_contentApiBase = HttpClientFactory.CreateClient("DeepDrft.Content.Cms").BaseAddress;
|
|
||||||
|
|
||||||
// Re-project rows only when the parent supplies a genuinely new release list (reference change).
|
// Re-project rows only when the parent supplies a genuinely new release list (reference change).
|
||||||
// Local edits to _rows (a removed row after delete) must survive re-renders triggered by the
|
// Local edits to _rows (a removed row after delete) must survive re-renders triggered by the
|
||||||
// same cached VM.Albums instance.
|
// same cached VM.Albums instance.
|
||||||
@@ -145,10 +137,9 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string? ThumbUrl(string imagePath) =>
|
// Relative path — resolves against the Manager's own origin, proxied by ImageProxyController.
|
||||||
_contentApiBase is null
|
private static string ThumbUrl(string imagePath) =>
|
||||||
? null
|
$"/api/image/{Uri.EscapeDataString(imagePath)}";
|
||||||
: new Uri(_contentApiBase, $"api/image/{Uri.EscapeDataString(imagePath)}").ToString();
|
|
||||||
|
|
||||||
private async Task ToggleExpand(AlbumRow row)
|
private async Task ToggleExpand(AlbumRow row)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
@using DeepDrftManager.Services
|
@using DeepDrftManager.Services
|
||||||
@using DeepDrftModels.DTOs
|
@using DeepDrftModels.DTOs
|
||||||
@inject ICmsTrackService CmsTrackService
|
@inject ICmsTrackService CmsTrackService
|
||||||
@inject IHttpClientFactory HttpClientFactory
|
|
||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
@inject ISnackbar Snackbar
|
@inject ISnackbar Snackbar
|
||||||
@inject ILogger<CmsTrackGrid> Logger
|
@inject ILogger<CmsTrackGrid> Logger
|
||||||
@@ -133,23 +132,17 @@
|
|||||||
// The parent owns "Generate All Missing"; while it runs it disables this grid's per-row buttons.
|
// The parent owns "Generate All Missing"; while it runs it disables this grid's per-row buttons.
|
||||||
private bool _bulkRunning;
|
private bool _bulkRunning;
|
||||||
|
|
||||||
// The image endpoint (GET api/image/{entryKey}) lives on DeepDrftAPI and is unauthenticated, so
|
|
||||||
// the browser hits it directly. Base address comes from the same named client the CMS uses.
|
|
||||||
private Uri? _contentApiBase;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_contentApiBase = HttpClientFactory.CreateClient("DeepDrft.Content.Cms").BaseAddress;
|
|
||||||
await RefreshWaveformStatusAsync();
|
await RefreshWaveformStatusAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasProfile(string entryKey) =>
|
private bool HasProfile(string entryKey) =>
|
||||||
_waveformStatus.TryGetValue(entryKey, out var hasProfile) && hasProfile;
|
_waveformStatus.TryGetValue(entryKey, out var hasProfile) && hasProfile;
|
||||||
|
|
||||||
private string? ThumbUrl(string imagePath) =>
|
// Relative path — resolves against the Manager's own origin, proxied by ImageProxyController.
|
||||||
_contentApiBase is null
|
private static string ThumbUrl(string imagePath) =>
|
||||||
? null
|
$"/api/image/{Uri.EscapeDataString(imagePath)}";
|
||||||
: new Uri(_contentApiBase, $"api/image/{Uri.EscapeDataString(imagePath)}").ToString();
|
|
||||||
|
|
||||||
/// <summary>Number of tracks with a missing waveform profile — drives the parent's bulk button label.</summary>
|
/// <summary>Number of tracks with a missing waveform profile — drives the parent's bulk button label.</summary>
|
||||||
public int GetMissingCount() => _waveformStatus.Count(kv => !kv.Value);
|
public int GetMissingCount() => _waveformStatus.Count(kv => !kv.Value);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@inject ICmsTrackService CmsTrackService
|
@inject ICmsTrackService CmsTrackService
|
||||||
@inject CmsTrackBrowserViewModel VM
|
@inject CmsTrackBrowserViewModel VM
|
||||||
@inject IHttpClientFactory HttpClientFactory
|
|
||||||
@inject ISnackbar Snackbar
|
@inject ISnackbar Snackbar
|
||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
@inject NavigationManager Nav
|
@inject NavigationManager Nav
|
||||||
@@ -160,18 +159,11 @@
|
|||||||
!string.IsNullOrWhiteSpace(_form.TrackName)
|
!string.IsNullOrWhiteSpace(_form.TrackName)
|
||||||
&& !string.IsNullOrWhiteSpace(_form.Artist);
|
&& !string.IsNullOrWhiteSpace(_form.Artist);
|
||||||
|
|
||||||
// The image endpoint (GET api/image/{entryKey}) is unauthenticated, so the browser can hit
|
// Relative path — resolves against the Manager's own origin, proxied by ImageProxyController.
|
||||||
// DeepDrftAPI directly. Base address comes from the same named client the CMS uses for writes.
|
private string? ImagePreviewUrl =>
|
||||||
private string? ImagePreviewUrl
|
string.IsNullOrEmpty(_form.ImagePath)
|
||||||
{
|
? null
|
||||||
get
|
: $"/api/image/{Uri.EscapeDataString(_form.ImagePath)}";
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_form.ImagePath)) return null;
|
|
||||||
var baseAddress = HttpClientFactory.CreateClient("DeepDrft.Content.Cms").BaseAddress;
|
|
||||||
if (baseAddress is null) return null;
|
|
||||||
return new Uri(baseAddress, $"api/image/{Uri.EscapeDataString(_form.ImagePath)}").ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace DeepDrftManager.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Proxies image API calls to DeepDrftAPI so the browser never makes cross-origin requests.
|
||||||
|
/// The CMS host runs server-side only, so rendered image URLs must resolve against the Manager's
|
||||||
|
/// own origin, not the internal API address. This controller forwards unauthenticated
|
||||||
|
/// <c>api/image/{entryKey}</c> requests upstream using the "DeepDrft.Content" named client
|
||||||
|
/// (no API key — the image endpoint is public).
|
||||||
|
/// </summary>
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/image")]
|
||||||
|
public class ImageProxyController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly HttpClient _upstream;
|
||||||
|
private readonly ILogger<ImageProxyController> _logger;
|
||||||
|
|
||||||
|
public ImageProxyController(IHttpClientFactory httpClientFactory, ILogger<ImageProxyController> logger)
|
||||||
|
{
|
||||||
|
_upstream = httpClientFactory.CreateClient("DeepDrft.Content");
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Proxies image binary streaming by vault entry key from DeepDrftAPI.</summary>
|
||||||
|
[HttpGet("{entryKey}")]
|
||||||
|
public async Task<ActionResult> GetImage(string entryKey, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Proxying image {EntryKey}", entryKey);
|
||||||
|
|
||||||
|
var path = $"api/image/{Uri.EscapeDataString(entryKey)}";
|
||||||
|
|
||||||
|
HttpResponseMessage upstream;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
upstream = await _upstream.GetAsync(path, HttpCompletionOption.ResponseHeadersRead, ct);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Upstream call to DeepDrftAPI image/{EntryKey} failed", entryKey);
|
||||||
|
return StatusCode(502, "Upstream unavailable");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!upstream.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
upstream.Dispose();
|
||||||
|
_logger.LogWarning("DeepDrftAPI image/{EntryKey} returned {Status}", entryKey, (int)upstream.StatusCode);
|
||||||
|
return StatusCode((int)upstream.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do NOT dispose upstream here — File() takes ownership of the response stream
|
||||||
|
// and disposes it after the body is sent.
|
||||||
|
var contentType = upstream.Content.Headers.ContentType?.ToString() ?? "application/octet-stream";
|
||||||
|
var contentLength = upstream.Content.Headers.ContentLength;
|
||||||
|
|
||||||
|
if (contentLength.HasValue)
|
||||||
|
Response.ContentLength = contentLength.Value;
|
||||||
|
|
||||||
|
var stream = await upstream.Content.ReadAsStreamAsync(ct);
|
||||||
|
HttpContext.Response.RegisterForDispose(upstream);
|
||||||
|
return File(stream, contentType, enableRangeProcessing: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,6 +61,11 @@ builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
|||||||
options.KnownProxies.Clear();
|
options.KnownProxies.Clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// MVC controllers — required for the ImageProxyController that forwards browser image requests
|
||||||
|
// to DeepDrftAPI so rendered URLs resolve against the Manager's own origin, not the internal
|
||||||
|
// API address.
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
// InteractiveServer only — no WASM render mode on the CMS host.
|
// InteractiveServer only — no WASM render mode on the CMS host.
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
.AddInteractiveServerComponents();
|
.AddInteractiveServerComponents();
|
||||||
@@ -98,6 +103,7 @@ app.UseAntiforgery();
|
|||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapStaticAssets();
|
app.MapStaticAssets();
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
// The AuthBlocks API surface (/api/auth/*, /api/users/*, etc.) now lives on DeepDrftAPI; this host
|
// The AuthBlocks API surface (/api/auth/*, /api/users/*, etc.) now lives on DeepDrftAPI; this host
|
||||||
// only renders the AuthBlocksWeb Razor pages (/account/login, /account/logout), which call that API.
|
// only renders the AuthBlocksWeb Razor pages (/account/login, /account/logout), which call that API.
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* parallax - scroll-driven background-position panning for ParallaxImage.
|
||||||
|
*
|
||||||
|
* Single Responsibility: own the parallax math and scroll/observer lifecycle.
|
||||||
|
* Blazor owns the component lifecycle and calls register/unregister. When the
|
||||||
|
* IntersectionObserver fires and JS attaches the scroll listener, this module
|
||||||
|
* sets data-parallax-active and immediately primes background-position-y —
|
||||||
|
* atomically cancelling the pre-WASM CSS animation and writing the correct
|
||||||
|
* position in the same turn, so there is no flash at the handoff.
|
||||||
|
*/
|
||||||
|
const handles = new Map();
|
||||||
|
let _handleCounter = 0;
|
||||||
|
const reducedMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||||
|
function clamp(value, min, max) {
|
||||||
|
return Math.max(min, Math.min(max, value));
|
||||||
|
}
|
||||||
|
function applyParallax(handle) {
|
||||||
|
const { element, options } = handle;
|
||||||
|
const rect = element.getBoundingClientRect();
|
||||||
|
const viewportH = window.innerHeight;
|
||||||
|
let progress = options.invertDirection
|
||||||
|
? rect.top / viewportH
|
||||||
|
: 1 - rect.top / viewportH;
|
||||||
|
progress = clamp(progress, 0, 1);
|
||||||
|
const pos = progress * clamp(options.speed, 0, 1) * 100;
|
||||||
|
// Write background-position-y on each layer directly — the same property the
|
||||||
|
// pre-WASM CSS animation drives (now cancelled via data-parallax-active).
|
||||||
|
const layers = element.querySelectorAll(':scope > .layer');
|
||||||
|
for (const layer of layers) {
|
||||||
|
layer.style.backgroundPositionY = `${pos}%`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function attachScrollListener(handle) {
|
||||||
|
if (handle.scrollListener || reducedMotion())
|
||||||
|
return;
|
||||||
|
const listener = () => {
|
||||||
|
if (handle.rafId !== null)
|
||||||
|
return;
|
||||||
|
handle.rafId = requestAnimationFrame(() => {
|
||||||
|
handle.rafId = null;
|
||||||
|
applyParallax(handle);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
handle.scrollListener = listener;
|
||||||
|
window.addEventListener('scroll', listener, { passive: true });
|
||||||
|
// Cancel CSS animation and prime position atomically — no gap where neither drives.
|
||||||
|
handle.element.setAttribute('data-parallax-active', '');
|
||||||
|
applyParallax(handle);
|
||||||
|
}
|
||||||
|
function detachScrollListener(handle) {
|
||||||
|
if (handle.scrollListener) {
|
||||||
|
window.removeEventListener('scroll', handle.scrollListener);
|
||||||
|
handle.scrollListener = null;
|
||||||
|
}
|
||||||
|
if (handle.rafId !== null) {
|
||||||
|
cancelAnimationFrame(handle.rafId);
|
||||||
|
handle.rafId = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function setupAutoHeight(handle) {
|
||||||
|
if (!handle.options.heightFraction || !handle.options.image1)
|
||||||
|
return;
|
||||||
|
const fraction = handle.options.heightFraction;
|
||||||
|
const element = handle.element;
|
||||||
|
const applyHeight = (naturalW, naturalH) => {
|
||||||
|
const containerW = element.offsetWidth;
|
||||||
|
if (containerW === 0 || naturalW === 0)
|
||||||
|
return;
|
||||||
|
const h = Math.round(containerW * (naturalH / naturalW) * fraction);
|
||||||
|
element.style.setProperty('--window-height', `${h}px`);
|
||||||
|
};
|
||||||
|
const probe = new Image();
|
||||||
|
probe.onload = () => {
|
||||||
|
const nw = probe.naturalWidth;
|
||||||
|
const nh = probe.naturalHeight;
|
||||||
|
applyHeight(nw, nh);
|
||||||
|
// Watch container width changes (orientation, responsive layout, etc.)
|
||||||
|
handle.resizeObserver = new ResizeObserver(() => {
|
||||||
|
applyHeight(nw, nh);
|
||||||
|
});
|
||||||
|
handle.resizeObserver.observe(element);
|
||||||
|
};
|
||||||
|
probe.src = handle.options.image1;
|
||||||
|
}
|
||||||
|
export function register(element, options) {
|
||||||
|
const id = `parallax-${++_handleCounter}`;
|
||||||
|
const realObserver = new IntersectionObserver((entries) => {
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (entry.isIntersecting) {
|
||||||
|
attachScrollListener(handle);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
detachScrollListener(handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const handle = {
|
||||||
|
element,
|
||||||
|
options: { ...options, speed: clamp(options.speed, 0, 1) },
|
||||||
|
observer: realObserver,
|
||||||
|
resizeObserver: null,
|
||||||
|
scrollListener: null,
|
||||||
|
rafId: null,
|
||||||
|
};
|
||||||
|
handle.observer.observe(element);
|
||||||
|
handles.set(id, handle);
|
||||||
|
setupAutoHeight(handle);
|
||||||
|
// Prime position synchronously so enhanced navigation and WASM handoff have
|
||||||
|
// zero-frame gap. The init script covers cold page load; this covers nav.
|
||||||
|
// Skip under reduced motion — parallax.ts never drives position then.
|
||||||
|
if (!reducedMotion()) {
|
||||||
|
element.setAttribute('data-parallax-active', '');
|
||||||
|
applyParallax(handle);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
export function unregister(handleId) {
|
||||||
|
const handle = handles.get(handleId);
|
||||||
|
if (!handle)
|
||||||
|
return;
|
||||||
|
detachScrollListener(handle);
|
||||||
|
handle.element.removeAttribute('data-parallax-active');
|
||||||
|
handle.observer.disconnect();
|
||||||
|
handle.resizeObserver?.disconnect();
|
||||||
|
handles.delete(handleId);
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=/js/parallax/parallax.js.map
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"parallax.js","sourceRoot":"/Interop/","sources":["parallax/parallax.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkBH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE1C,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB,MAAM,aAAa,GAAG,GAAY,EAAE,CAChC,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AAElE,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAClD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACjC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,IAAI,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAC7C,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;IAErC,IAAI,QAAQ,GAAG,OAAO,CAAC,eAAe;QAClC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,SAAS;QACtB,CAAC,C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