From 3ed594ab880faa7016abd10d5e7764b4b86043e7 Mon Sep 17 00:00:00 2001 From: Damillora Date: Fri, 15 Apr 2022 00:12:07 +0700 Subject: [PATCH] feat: redesign of some pages --- pkg/app/post_routes.go | 5 +- pkg/models/item.go | 7 +- pkg/models/responses.go | 1 + web/app/src/AuthCheck.svelte | 12 ++ web/app/src/EditPostPanel.svelte | 90 ++++++++++++++ web/app/src/TagLink.svelte | 2 +- web/app/src/TagLinkNumbered.svelte | 13 ++ web/app/src/ViewPostPanel.svelte | 78 ++++++++++++ web/app/src/main.scss | 4 +- web/app/src/routes/Post.svelte | 116 +++++++----------- web/app/src/routes/Posts.svelte | 186 +++++++++++++++++++---------- web/app/src/routes/Tags.svelte | 6 - web/app/src/routes/Upload.svelte | 6 - web/app/src/simple-pagination.js | 64 ++++++++++ 14 files changed, 431 insertions(+), 159 deletions(-) create mode 100644 web/app/src/AuthCheck.svelte create mode 100644 web/app/src/EditPostPanel.svelte create mode 100644 web/app/src/TagLinkNumbered.svelte create mode 100644 web/app/src/ViewPostPanel.svelte create mode 100644 web/app/src/simple-pagination.js diff --git a/pkg/app/post_routes.go b/pkg/app/post_routes.go index 112be82..e77cf2a 100644 --- a/pkg/app/post_routes.go +++ b/pkg/app/post_routes.go @@ -57,8 +57,9 @@ func postGet(c *gin.Context) { } var postResult []models.PostListItem + var tagStrings []string for _, post := range posts { - var tagStrings []string + for _, tag := range post.Tags { tagStrings = append(tagStrings, tag.TagType.Name+":"+tag.Name) } @@ -67,7 +68,6 @@ func postGet(c *gin.Context) { ID: post.ID, ImageThumbnailPath: "/data/" + post.Blob.ThumbnailFilePath, ImagePath: "/data/" + post.Blob.FilePath, - Tags: tagStrings, }) } c.JSON(http.StatusOK, models.PostPaginationResponse{ @@ -75,6 +75,7 @@ func postGet(c *gin.Context) { TotalPage: totalPage, PostCount: postPages, Posts: postResult, + Tags: tagStrings, }) } diff --git a/pkg/models/item.go b/pkg/models/item.go index 784dcb6..e44939e 100644 --- a/pkg/models/item.go +++ b/pkg/models/item.go @@ -17,10 +17,9 @@ type TagAutocompleteListItem struct { } type PostListItem struct { - ID string `json:"id"` - ImagePath string `json:"image_path"` - ImageThumbnailPath string `json:"thumbnail_path"` - Tags []string `json:"tags"` + ID string `json:"id"` + ImagePath string `json:"image_path"` + ImageThumbnailPath string `json:"thumbnail_path"` } type PostSimilarityListItem struct { diff --git a/pkg/models/responses.go b/pkg/models/responses.go index 268af3c..e0b8eb9 100644 --- a/pkg/models/responses.go +++ b/pkg/models/responses.go @@ -31,4 +31,5 @@ type PostPaginationResponse struct { TotalPage int `json:"totalPage"` PostCount int `json:"postCount"` Posts []PostListItem `json:"posts"` + Tags []string `json:"tags"` } diff --git a/web/app/src/AuthCheck.svelte b/web/app/src/AuthCheck.svelte new file mode 100644 index 0000000..f7c8e6f --- /dev/null +++ b/web/app/src/AuthCheck.svelte @@ -0,0 +1,12 @@ + + +{#if loggedIn == true} + +{/if} diff --git a/web/app/src/EditPostPanel.svelte b/web/app/src/EditPostPanel.svelte new file mode 100644 index 0000000..b4b5bb8 --- /dev/null +++ b/web/app/src/EditPostPanel.svelte @@ -0,0 +1,90 @@ + + +
+
+

Edit Post

+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+
diff --git a/web/app/src/TagLink.svelte b/web/app/src/TagLink.svelte index 09e858a..87e0fc3 100644 --- a/web/app/src/TagLink.svelte +++ b/web/app/src/TagLink.svelte @@ -8,4 +8,4 @@ let tagDisplay = tagName.split("_").join(" "); -{tagDisplay} +{tagDisplay} diff --git a/web/app/src/TagLinkNumbered.svelte b/web/app/src/TagLinkNumbered.svelte new file mode 100644 index 0000000..5aef594 --- /dev/null +++ b/web/app/src/TagLinkNumbered.svelte @@ -0,0 +1,13 @@ + + +{tagDisplay} {num} diff --git a/web/app/src/ViewPostPanel.svelte b/web/app/src/ViewPostPanel.svelte new file mode 100644 index 0000000..49e2abc --- /dev/null +++ b/web/app/src/ViewPostPanel.svelte @@ -0,0 +1,78 @@ + + +
+

Post

+
+
+ Uploader: +
+
{post.uploader}
+
+
+
+ Source URL: +
+ +
+
+
+ Original: +
+
+ Image +
+
+
+
+ Dimensions: +
+
+ {post.width}x{post.height} +
+
+
+
+

Tags:

+
+
+ +
+
+ +

+ + +

+
+
diff --git a/web/app/src/main.scss b/web/app/src/main.scss index 2bf86c0..bf5c924 100644 --- a/web/app/src/main.scss +++ b/web/app/src/main.scss @@ -12,5 +12,5 @@ } .svelte-tags-input-matchs-parent { - z-index: 200; -} \ No newline at end of file + z-index: 2000; +} diff --git a/web/app/src/routes/Post.svelte b/web/app/src/routes/Post.svelte index f87f12f..f079cdc 100644 --- a/web/app/src/routes/Post.svelte +++ b/web/app/src/routes/Post.svelte @@ -3,6 +3,8 @@ import TagLink from "../TagLink.svelte"; import { getPost, postCreate, postDelete } from "../api.js"; import { Link, navigate } from "svelte-routing"; + import EditPostPanel from "../EditPostPanel.svelte"; + import ViewPostPanel from "../ViewPostPanel.svelte"; export let id; let post; const getData = async () => { @@ -21,70 +23,62 @@ getData(); }); - let modal_shown = false; + let deleteMenuShown = false; const deletePost = async () => { - toggleModal(); + toggleDeleteMenu(); const success = await postDelete({ id }); if (success) { navigate("/posts"); } }; - const toggleModal = () => { - modal_shown = !modal_shown; + const toggleDeleteMenu = () => { + deleteMenuShown = !deleteMenuShown; + }; + + let editMenuShown = false; + + const toggleEditMenu = () => { + editMenuShown = !editMenuShown; }; -
-
- {#if post} -

- Post ID: {post.id} -

- {/if} -
-
{#if post}
-
-
-

- Edit - -

-

- Uploader: {post.uploader} -

-

- Source URL: {trimUrl(post.source_url)} -

-

- Original: Image -

-

- Dimensions: {post.width}x{post.height} -

-

- Tags:
-

-

- {#if post.tags} - {#each post.tags as tag (tag)} - - {/each} - {/if} -

-
+
+ {#if editMenuShown == false && deleteMenuShown == false} + + {:else if editMenuShown == true} + + {:else if deleteMenuShown == true} +
+

Delete Post

+
+ Are you sure to delete post {post.id}? +
+
+ + +
+
+ {/if}
{#if post.width > 1000} @@ -105,26 +99,4 @@
-