diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-09-08 09:03:58 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2023-09-08 09:06:35 +1000 |
| commit | d3d926875f137b3b25d7a2beee14e5d73ca9aab9 (patch) | |
| tree | 331098f76d451cab792dad4728984f15389fe8f5 /Pages/ViewMedia.razor | |
| parent | a6ae1e33c6c25c364fcea2e0af23578803f5941d (diff) | |
Additional data sanitization in media service and keyboard shortcuts
Diffstat (limited to 'Pages/ViewMedia.razor')
| -rw-r--r-- | Pages/ViewMedia.razor | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor index 26b7988..7823c75 100644 --- a/Pages/ViewMedia.razor +++ b/Pages/ViewMedia.razor @@ -4,7 +4,6 @@ @inject IDbContextFactory<HBContext> dbFactory @inject ITagService tagService @inject IMediaService mediaService -@implements IDisposable <PageTitle>@title</PageTitle> @@ -30,7 +29,7 @@ <table id="edit-metadata"> <tr> <td>Title:</td> - <td><input type="text" @bind=shortDescription/></td> + <td><input type="text" @bind=shortDescription @ref=shortDescriptionInput/></td> </tr> <tr> <td>Description:</td> @@ -83,19 +82,19 @@ </div> <div id="button-container"> <ButtonContainer> - <button @onclick=@(() => deleteDialog.Show()) class="warning" data-keyboard-shortcut="d">Delete</button> - <button @onclick=@(() => tagDialog.Show()) class="secondary" data-keyboard-shortcut="t">Add Tag</button> - <button @onclick=@(() => ocrDialog.Show()) class="secondary" data-keyboard-shortcut="o">View OCR</button> + <button @onclick=@(() => deleteDialog.Show()) class="warning" data-keyboard-shortcut="d"><u>D</u>elete</button> + <button @onclick=@(() => tagDialog.Show()) class="secondary" data-keyboard-shortcut="t">Add <u>T</u>ag</button> + <button @onclick=@(() => ocrDialog.Show()) class="secondary" data-keyboard-shortcut="o">View <u>O</u>CR</button> @if(infoEditMode) { <button @onclick=@(() => ApplyInfoEdit(false)) class="secondary">Cancel</button> <button @onclick=@(() => ApplyInfoEdit(true))>Apply</button> } else { - <button @onclick=@(() => InfoEditMode = true) class="secondary" data-keyboard-shortcut="e">Edit Info</button> + <button @onclick=@(() => InfoEditMode = true) class="secondary" data-keyboard-shortcut="e"><u>E</u>dit Info</button> } @if(media.IsIngest) { - <button @onclick=@(() => SetIngest(false)) data-keyboard-shortcut="c">Mark Tagging Complete</button> + <button @onclick=@(() => SetIngest(false)) data-keyboard-shortcut="c">Mark Tagging <u>C</u>omplete</button> } else { - <button class="secondary" @onclick=@(() => SetIngest(true)) data-keyboard-shortcut="c">Mark Tagging Incomplete</button> + <button class="secondary" @onclick=@(() => SetIngest(true)) data-keyboard-shortcut="c">Mark Tagging In<u>c</u>omplete</button> } </ButtonContainer> </div> @@ -143,14 +142,18 @@ private Dialog ocrDialog; private TagSelectDialog tagDialog; - private HBContext db; + private ElementReference shortDescriptionInput; - protected override void OnInitialized() { - db = dbFactory.CreateDbContext(); + 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) @@ -170,7 +173,6 @@ private async void SetIngest(bool ingest) { mediaService.SetIngest(media, ingest); - db.Entry(media).State = EntityState.Detached; LoadMedia(); if(ingest) @@ -191,11 +193,8 @@ private void ApplyInfoEdit(bool apply) { if(apply) { - if(string.IsNullOrEmpty(shortDescription)) shortDescription = null; - if(string.IsNullOrEmpty(longDescription)) longDescription = null; - media.ShortDescription = shortDescription; - media.LongDescription = longDescription; mediaService.SetDescription(media, shortDescription, longDescription); + LoadMedia(); } infoEditMode = false; @@ -205,6 +204,4 @@ mediaService.Delete(media); await jsRuntime.InvokeVoidAsync("history.back"); } - - public void Dispose() => db.Dispose(); } |
