From c51ff4e755f009ca0bc8e935a92c04e583c4ee8a Mon Sep 17 00:00:00 2001
From: Jake Mannens
Date: Tue, 17 Mar 2026 03:04:36 +1100
Subject: Initial commit
---
Pages/ViewMedia.razor | 265 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 265 insertions(+)
create mode 100644 Pages/ViewMedia.razor
(limited to 'Pages/ViewMedia.razor')
diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor
new file mode 100644
index 0000000..46cbc45
--- /dev/null
+++ b/Pages/ViewMedia.razor
@@ -0,0 +1,265 @@
+@page "/ViewMedia"
+@using HyperBooru.Util
+@inject IJSRuntime jsRuntime
+@inject IDbContextFactory dbFactory
+@inject ITagService tagService
+@inject IMediaService mediaService
+@inject ISourceService sourceService
+@attribute [Authorize]
+
+@title
+
+
+
+
+
+
+
+
+ } else {
+ @media.OcrData?.Text
+ }
+
+
+
+
+
+
+
+@code {
+ [Parameter]
+ [SupplyParameterFromQuery(Name = "m")]
+ public Guid MediaId { get; set; }
+
+ private Media media;
+
+ private string title;
+
+ private bool infoEditMode = false;
+ private string? shortDescription;
+ private string? longDescription;
+
+ private MediaTagTable mediaTagTable;
+ private Dialog deleteDialog;
+ private Dialog ocrDialog;
+ private TagSelectDialog tagDialog;
+
+ private ElementReference shortDescriptionInput;
+
+ protected override void OnInitialized() =>
+ LoadMedia();
+
+ protected override async void OnAfterRender(bool firstRender) {
+ if(infoEditMode)
+ await shortDescriptionInput.FocusAsync();
+ }
+
+ private void LoadMedia() {
+ using var db = dbFactory.CreateDbContext();
+ media = db.Media
+ .Include(m => m.Tags)
+ .ThenInclude(t => t.TagDefinition)
+ .Include(m => m.CurrentUploadedFile)
+ .Include(m => m.UploadedFiles)
+ .Include(m => m.OcrData)
+ .First(m => m.Guid == MediaId);
+
+ title = media.DisplayName ?? "Media View";
+ }
+
+ private void AddTags(TagDefinition[] tagDefs) {
+ foreach(var tagDef in tagDefs)
+ tagService.AddTag(media, tagDef);
+ mediaTagTable.Refresh();
+ }
+
+ private async void SetIngest(bool ingest) {
+ mediaService.SetIngest(media, ingest);
+ LoadMedia();
+
+ if(ingest)
+ StateHasChanged();
+ else
+ await jsRuntime.InvokeVoidAsync("history.back");
+ }
+
+ private bool InfoEditMode {
+ get => infoEditMode;
+ set {
+ shortDescription = media.ShortDescription;
+ longDescription = media.LongDescription;
+ infoEditMode = value;
+ StateHasChanged();
+ }
+ }
+
+ private void ApplyInfoEdit(bool apply) {
+ if(apply) {
+ mediaService.SetDescription(media, shortDescription, longDescription);
+ LoadMedia();
+ }
+
+ infoEditMode = false;
+ }
+
+ private async void DeleteMedia() {
+ mediaService.Delete(media);
+ await jsRuntime.InvokeVoidAsync("history.back");
+ }
+}
--
cgit v1.3