From e119bc55ea82cefcbcc0571650107dfd5d73f570 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 3 Nov 2020 19:17:22 +0000 Subject: [PATCH] feat: shared folder file listing --- frontend/public/themes/dark.css | 6 ++-- frontend/src/css/_share.css | 57 +++++++++++++++++++++++++-------- frontend/src/views/Share.vue | 40 +++++++++++++++++++---- http/public.go | 12 +++++-- 4 files changed, 89 insertions(+), 26 deletions(-) diff --git a/frontend/public/themes/dark.css b/frontend/public/themes/dark.css index 1ee5f1ac..0ff15578 100644 --- a/frontend/public/themes/dark.css +++ b/frontend/public/themes/dark.css @@ -191,10 +191,10 @@ table th { } } -.share__box, .share__box__download { - background: var(--surfaceSecondary) !important; +.share__box, .share__box__header { + background: var(--surfacePrimary) !important; color: var(--textPrimary); } -.share__box__download { +.share__box__header { border-bottom-color: var(--divider); } \ No newline at end of file diff --git a/frontend/src/css/_share.css b/frontend/src/css/_share.css index a0e21153..28d10214 100644 --- a/frontend/src/css/_share.css +++ b/frontend/src/css/_share.css @@ -1,29 +1,58 @@ -.share__box { - text-align: center; - box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px; - background: #fff; - display: block; - border-radius: 0.2em; - width: 90%; - max-width: 25em; - margin: 6em auto; +.share { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: flex-start; } -.share__box__download { +@media (max-width: 736px) { + .share { + display: block; + } +} + +.share__box { + box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px; + background: #fff; + border-radius: 0.2em; + margin: 5px; + overflow: hidden; +} + +.share__box__header { width: 100%; padding: 1em; cursor: pointer; background: #ffffff; - color: rgba(0, 0, 0, 0.5); - border-bottom: 1px solid rgba(0, 0, 0, 0.05); + border-bottom: 1px solid rgba(0, 0, 0, 0.1); } -.share__box__info { +.share__box__body { padding: 2em 3em; } .share__box__title { - margin-top: .2em; + margin: 0 0 2em; overflow: hidden; text-overflow: ellipsis; } + +.share__box__info { + text-align: center; + flex: 1 1 auto; +} + +.share__box__items { + text-align: left; + flex: 10 0 15em; +} + +.share__box__items #listing.list .item { + cursor: auto; + border-left: 0; + border-right: 0; +} + +.share__box__items #listing.list .item .name { + width: auto; +} \ No newline at end of file diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue index bbc15d75..ae42a271 100644 --- a/frontend/src/views/Share.vue +++ b/frontend/src/views/Share.vue @@ -1,10 +1,10 @@ @@ -34,7 +56,8 @@ export default { data: () => ({ loaded: false, notFound: false, - file: null + file: null, + showLimit: 500 }), watch: { '$route': 'fetchData' @@ -54,6 +77,9 @@ export default { }, }, methods: { + base64: function (name) { + return window.btoa(unescape(encodeURIComponent(name))) + }, fetchData: async function () { try { this.file = await api.getHash(this.hash) diff --git a/http/public.go b/http/public.go index 4467613d..269c5bdd 100644 --- a/http/public.go +++ b/http/public.go @@ -28,7 +28,7 @@ var withHashFile = func(fn handleFunc) handleFunc { Fs: d.user.Fs, Path: link.Path, Modify: d.user.Perm.Modify, - Expand: false, + Expand: true, Checker: d, }) if err != nil { @@ -54,7 +54,15 @@ func ifPathWithName(r *http.Request) string { } var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { - return renderJSON(w, r, d.raw) + file := d.raw.(*files.FileInfo) + + if file.IsDir { + file.Listing.Sorting = files.Sorting{By: "name", Asc: false} + file.Listing.ApplySort() + return renderJSON(w, r, file) + } + + return renderJSON(w, r, file) }) var publicDlHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {