diff options
Diffstat (limited to 'Pages')
| -rw-r--r-- | Pages/ViewMedia.razor | 73 | ||||
| -rw-r--r-- | Pages/ViewMedia.razor.css | 36 |
2 files changed, 83 insertions, 26 deletions
diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor index e559460..68e6d70 100644 --- a/Pages/ViewMedia.razor +++ b/Pages/ViewMedia.razor @@ -1,6 +1,7 @@ @page "/ViewMedia" @inject IDbContextFactory<HBContext> dbFactory @inject ITagService tagService +@inject IMediaService mediaService @implements IDisposable <PageTitle>@title</PageTitle> @@ -11,20 +12,26 @@ <img src="/media/@(media.Guid)"/> <div id="metadata"> <div id="metadata-fileinfo"> - @if(true) { - <label> - Title: - <input type="text" style="width:100%;"/> - </label> - <p>Description:</p> - <textarea/> + @if(infoEditMode) { + <form @onsubmit=@(() => ApplyInfoEdit(true))> + <table id="edit-metadata"> + <tr> + <td>Title:</td> + <td><input type="text" @bind=shortDescription/></td> + </tr> + <tr> + <td>Description:</td> + <td><textarea rows="4" @bind=longDescription/></td> + </tr> + </table> + </form> } else { - <p>Title: <i>@(@media.ShortDescription ?? "None")</i></p> - <p>Description: <i>@(media.LongDescription ?? "None")</i></p> + <p>Title: <i>@(media.ShortDescription ?? "None")</i></p> + <p class="newlines">Description:<br/><i>@(media.LongDescription ?? "None")</i></p> } <p class="heading">Upload history</p> <hr/> - <table class="data-table"> + <table id="uploaded-files" class="data-table"> <tr> <th>Created On</th> <th>Last Write</th> @@ -42,22 +49,25 @@ </tr> } </table> - <div class="button-container"> - <button @onclick=@(() => deleteDialog.Show()) class="warning">Delete</button> - <button>Apply</button> - </div> </div> <div id="metadata-tags"> <p class="heading">Tags</p> <hr/> <MediaTagTable Media=media @ref=mediaTagTable/> <div class="button-container"> + <button @onclick=@(() => deleteDialog.Show()) class="warning">Delete</button> <button @onclick=@(() => tagDialog.Show()) class="secondary">Add Tag</button> @if(media.IsIngest) { <button @onclick=@(() => SetIngest(false))>Mark Tagging Complete</button> } else { <button class="secondary" @onclick=@(() => SetIngest(true))>Mark Tagging Incomplete</button> } + @if(infoEditMode) { + <button @onclick=@(() => ApplyInfoEdit(false)) class="secondary">Cancel</button> + <button @onclick=@(() => ApplyInfoEdit(true))>Apply</button> + } else { + <button @onclick=@(() => InfoEditMode = true) class="secondary">Edit Info</button> + } </div> </div> </div> @@ -84,7 +94,9 @@ private string title; - private bool infoEditMode = false; + private bool infoEditMode = false; + private string? shortDescription; + private string? longDescription; private Dialog deleteDialog; private TagSelectDialog tagDialog; @@ -109,17 +121,30 @@ } private void SetIngest(bool ingest) { - var ingestTag = db.TagDefinitions - .First(td => td.Guid == HBContext.IngestTag); + mediaService.SetIngest(media, ingest); + StateHasChanged(); + } - if(!ingest) - media.Tags.RemoveAll(t => t.TagDefinition.Guid == ingestTag.Guid); - else - if(!media.IsIngest) - media.Tags.Add(new(ingestTag)); + private bool InfoEditMode { + get => infoEditMode; + set { + shortDescription = media.ShortDescription; + longDescription = media.LongDescription; + infoEditMode = value; + StateHasChanged(); + } + } - db.SaveChanges(); - StateHasChanged(); + 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); + } + + infoEditMode = false; } public void Dispose() => db.Dispose(); diff --git a/Pages/ViewMedia.razor.css b/Pages/ViewMedia.razor.css index 8a6a95a..2a242f6 100644 --- a/Pages/ViewMedia.razor.css +++ b/Pages/ViewMedia.razor.css @@ -15,11 +15,39 @@ div#metadata { width: 100%; } -div#metadata-fileinfo > table th { +table#edit-metadata { + border-collapse: collapse; + width: 100%; +} + +table#edit-metadata tr:first-child { + vertical-align: middle; +} + +table#edit-metadata tr:last-child { + vertical-align: top; +} + +table#edit-metadata td:last-child { + width: 100%; +} + +table#edit-metadata td > input { + width: 100%; + margin: 0; +} + +table#edit-metadata td > textarea { + margin: 0; + resize: none; + width: 100%; +} + +table#uploaded-files th { font-size: 8pt; } -div#metadata-fileinfo > table td { +table#uploaded-files td { font-family: 'Lucida Console'; font-size: 8pt; } @@ -28,6 +56,10 @@ p.heading { margin-top: 30px; } +p.newlines { + white-space: pre-line; +} + div.button-container { display: flex; justify-content: flex-end; |
