From 5247aa5a136fcf48d80c8e75625ae773a14fbd26 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Wed, 9 Aug 2023 09:21:36 +1000 Subject: Added the ability to delete media items --- HyperBooru.cs | 3 +- Pages/Shared/_Layout.cshtml | 2 +- Pages/TagDefinitions.cshtml | 104 ++++++++++++++++++++++++++++++++++++++++ Pages/TagDefinitions.cshtml.cs | 16 +++++++ Pages/TagDefinitions.cshtml.css | 16 +++++++ Pages/ViewMedia.cshtml | 30 +++++++++--- Pages/ViewMedia.cshtml.css | 5 ++ Server.csproj | 10 ++-- TagController.cs | 2 +- wwwroot/styles/global.css | 75 ++++++++++++++++++++++------- 10 files changed, 233 insertions(+), 30 deletions(-) create mode 100644 Pages/TagDefinitions.cshtml create mode 100644 Pages/TagDefinitions.cshtml.cs create mode 100644 Pages/TagDefinitions.cshtml.css diff --git a/HyperBooru.cs b/HyperBooru.cs index 9ccd323..e0e1b2d 100644 --- a/HyperBooru.cs +++ b/HyperBooru.cs @@ -1,3 +1,4 @@ +using Microsoft.EntityFrameworkCore; using System.Text.Json.Serialization; namespace HyperBooru; @@ -20,7 +21,7 @@ public class HyperBooru { using var scope = app.Services.CreateScope(); using var db = scope.ServiceProvider.GetRequiredService(); - db.Database.EnsureCreated(); + db.Database.Migrate(); #if DEBUG app.UseSwagger(); diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml index be445cc..9cdb952 100644 --- a/Pages/Shared/_Layout.cshtml +++ b/Pages/Shared/_Layout.cshtml @@ -16,7 +16,7 @@
@RenderBody() diff --git a/Pages/TagDefinitions.cshtml b/Pages/TagDefinitions.cshtml new file mode 100644 index 0000000..a05f5d5 --- /dev/null +++ b/Pages/TagDefinitions.cshtml @@ -0,0 +1,104 @@ +@page +@model HyperBooru.Pages.TagDefinitionsModel +@{ + ViewBag.Title = "Tag Definitions"; +} + + + + + + + + + + + + + + @foreach(var tagDef in Model.TagDefinitions) { + + + + + + + + } +
GuidSourceNamespaceName
@tagDef.Guid@tagDef.Source@tagDef.Namespace@tagDef.Name
+ +
+ +
+ +
+

Create a new tag definition

+
+
+ + + + +
+ + +
+
+
+ +
+

Are you sure you want to delete this tag definition?

+
+
+ + +
+
diff --git a/Pages/TagDefinitions.cshtml.cs b/Pages/TagDefinitions.cshtml.cs new file mode 100644 index 0000000..e2253d6 --- /dev/null +++ b/Pages/TagDefinitions.cshtml.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace HyperBooru.Pages; + +public class TagDefinitionsModel : PageModel { + public IEnumerable TagDefinitions => + db.TagDefinitions; + + private HyperBooruDbContext db; + + public TagDefinitionsModel(HyperBooruDbContext db) => + this.db = db; + + public void OnGet() {} +} diff --git a/Pages/TagDefinitions.cshtml.css b/Pages/TagDefinitions.cshtml.css new file mode 100644 index 0000000..0a9e226 --- /dev/null +++ b/Pages/TagDefinitions.cshtml.css @@ -0,0 +1,16 @@ +form > input { + width: 100%; +} + +div.button-container { + display: flex; + justify-content: flex-end; +} + +table#tag-definitions td:first-child { + font-family: 'Lucida Console'; +} + +table#tag-definitions td > button { + margin-top: 0; +} \ No newline at end of file diff --git a/Pages/ViewMedia.cshtml b/Pages/ViewMedia.cshtml index 967759b..3d0ce4a 100644 --- a/Pages/ViewMedia.cshtml +++ b/Pages/ViewMedia.cshtml @@ -17,6 +17,10 @@ } } + function showDeleteDialog(visible) { + document.getElementById('delete-dialog').classList.toggle('visible', visible); + } + function selectPane(tab) { var tabs = Array.from(document.querySelectorAll('div#metadata-header > a')); @@ -44,8 +48,8 @@
@*
@@ -54,7 +58,7 @@
*@ -
+

Upload history


@@ -75,14 +79,28 @@ }
+
+ +
-
+
Tag Name
- +
+ +
-
\ No newline at end of file +
+ +
+

Delete this media?

+
+
+ + +
+
diff --git a/Pages/ViewMedia.cshtml.css b/Pages/ViewMedia.cshtml.css index ff8a1cd..4041fa8 100644 --- a/Pages/ViewMedia.cshtml.css +++ b/Pages/ViewMedia.cshtml.css @@ -49,4 +49,9 @@ div#metadata-fileinfo > table th { div#metadata-fileinfo > table td { font-family: 'Lucida Console'; font-size: 8pt; +} + +div.button-container { + display: flex; + justify-content: flex-end; } \ No newline at end of file diff --git a/Server.csproj b/Server.csproj index 7917674..f7bf989 100644 --- a/Server.csproj +++ b/Server.csproj @@ -10,9 +10,13 @@ - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/TagController.cs b/TagController.cs index b97b066..5c9fa39 100644 --- a/TagController.cs +++ b/TagController.cs @@ -3,7 +3,7 @@ namespace HyperBooru; [ApiController] -[Route("tag")] +[Route("/api/tag")] public class TagController : Controller { private HyperBooruDbContext db; diff --git a/wwwroot/styles/global.css b/wwwroot/styles/global.css index 4a76f87..2b007f8 100644 --- a/wwwroot/styles/global.css +++ b/wwwroot/styles/global.css @@ -1,6 +1,10 @@ :root { - --col-bg: #222; - --col-navbar-bg: magenta; + --col-accent-pri: #0aa; + --col-bg: #222; + --col-dialog-bg: #333; + --col-navbar-bg: var(--col-accent-pri); + --col-button-pri: var(--col-accent-pri); + --col-button-sec: #555; } body { @@ -15,29 +19,42 @@ a { text-decoration: none; } -input { +button, input[type=submit] { color: white; - box-sizing: border-box; - border: 1px solid #aaa; - background: rgba(0, 0, 0, 0.3); - border-radius: 5px; -} - -button { - background: #f0f; + background: var(--col-button-pri); border-radius: 10px; border: none; box-sizing: border-box; height: 30px; - padding: 0 7px 0 7px; + margin: 10px 5px 0 5px; + padding: 0 9px 0 9px; +} + +button.secondary { + background: var(--col-button-sec); +} + +button:hover, input[type=submit]:hover { + filter: grayscale(0.9) brightness(2.5); +} + +button:active, input[type=submit]:active { + filter: grayscale(0.9) brightness(3.5); } -button:hover { - background: #f8f; +input { + background: rgba(0, 0, 0, 0); + border-radius: 5px; + border: 1px solid #aaa; + box-sizing: border-box; + color: white; + height: 25px !important; + margin-bottom: 10px; } -button:active { - background: #fff; +/* necessary for use inside flex containers */ +hr { + width: 100%; } table.data-table { @@ -54,10 +71,32 @@ table.data-table > tbody > tr > td { padding: 4px; } -table.data-table > tbody > tr:nth-child(2n):not(:last-child) { +table.data-table > tbody > tr:nth-child(2n) { background: rgba(255, 255, 255, 0.2); } table.data-table > tbody > tr > td:not(:last-child) { border-right: 1px solid white; -} \ No newline at end of file +} + +div.dialog { + background: var(--col-dialog-bg); + border-radius: 20px; + box-shadow: 0px 5px 10px 10px rgb(0 0 0 / 25%); + display: flex; + flex-direction: column; + left: 50%; + opacity: 0; + padding: 20px; + position: absolute; + top: 50%; + transform: translate(-50%, -50%); + transition: visibility 0.1s, opacity 0.1s linear; + visibility: hidden; + width: 450px; +} + +div.dialog.visible { + opacity: 1; + visibility: visible; +} -- cgit v1.3