From 95405e76d13ea25bec5c1f3801817980c91757dd Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Thu, 7 Feb 2019 23:09:54 +0100 Subject: [PATCH] Add pagination on files and lists page --- Makefile | 10 ++--- res/static/style/layout.css | 4 +- res/template/account/login.html | 6 +-- res/template/account/user_files.html | 35 ++++++++++++++++- res/template/account/user_home.html | 3 +- res/template/account/user_lists.html | 56 ++++++++++++++++++++++++++++ res/template/fragments/menu.html | 1 + webcontroller/templateData.go | 7 +++- webcontroller/templateManager.go | 22 ++++++++++- webcontroller/webcontroller.go | 1 + 10 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 res/template/account/user_lists.html diff --git a/Makefile b/Makefile index 0f44be4..647d6b2 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ run: ${MAKE} -j2 backgroundrun backgroundts build: - tsc res/static/res/typescript/lib/*.ts --outFile res/static/res/script/pixellib.js \ - res/static/res/typescript/home/*.ts \ - res/static/res/typescript/lib/*.ts --outFile res/static/res/script/home.js + tsc res/static/typescript/lib/*.ts --outFile res/static/script/pixellib.js \ + res/static/typescript/home/*.ts \ + res/static/typescript/lib/*.ts --outFile res/static/script/home.js go build main.go -o pixeldrain-web deps: @@ -12,8 +12,8 @@ deps: backgroundrun: go run main.go backgroundts: - tsc --watch --project res/static/res/typescript/home - --project res/static/res/typescript/textupload + tsc --watch --project res/static/typescript/home + --project res/static/typescript/textupload docker: go build -o docker/pixeldrain-web docker/main.go diff --git a/res/static/style/layout.css b/res/static/style/layout.css index 0939a09..7f6a9aa 100644 --- a/res/static/style/layout.css +++ b/res/static/style/layout.css @@ -86,7 +86,7 @@ body{ .navigation .icon { display: none; } -@media screen and (max-width: 500px) { +@media screen and (max-width: 35em) { .navigation a:not(:first-child) {display: none;} .navigation a.icon { float: right; @@ -163,7 +163,7 @@ a:hover {color: var(--highlight_color); text-decoration: underline;} table:not(.form) {border-collapse: collapse; width: 100%;} tr:not(.form) {border-bottom: 1px var(--accent_color_medium_border) solid;} tr > td {padding: 0.5em;} -@media(max-width: 28em) { +@media(max-width: 30em) { tr > td { box-sizing: border-box; float: left; diff --git a/res/template/account/login.html b/res/template/account/login.html index 81141b9..e835670 100644 --- a/res/template/account/login.html +++ b/res/template/account/login.html @@ -14,12 +14,12 @@
- - + + - + diff --git a/res/template/account/user_files.html b/res/template/account/user_files.html index d3474ed..011dd85 100644 --- a/res/template/account/user_files.html +++ b/res/template/account/user_files.html @@ -7,14 +7,30 @@ {{template "menu" .}} -
+
These files were uploaded while logged in to your pixeldrain account, click here to view files uploaded anonymously in this browser.
+ {{$limit := 100}} + {{$page := .URLQuery.Get "page" | pageNr}} + {{$files := .PixelAPI.UserFiles $page $limit}} +
+ {{if ne $page 0}} + 🡄 4 Pages + ⬅ 2 Pages + ← Last Page + {{end}} + Page {{$page}} + {{if len $files.Files | eq $limit}} + Next Page → + 2 Pages ⮕ + 4 Pages 🡆 + {{end}} +

- {{$files := .PixelAPI.UserFiles 0 1000}} + {{range $files.Files}} {{.Name}} @@ -24,6 +40,21 @@ {{end}} +
+
+ {{if ne $page 0}} + 🡄 4 Pages + ⬅ 2 Pages + ← Last Page + {{end}} + Page {{$page}} + {{if len $files.Files | eq $limit}} + Next Page → + 2 Pages ⮕ + 4 Pages 🡆 + {{end}} +
+ {{template "analytics"}} diff --git a/res/template/account/user_home.html b/res/template/account/user_home.html index cbd5948..9665a1b 100644 --- a/res/template/account/user_home.html +++ b/res/template/account/user_home.html @@ -22,7 +22,7 @@ {{end}}
- ...All my files + ...All my files

Your most recently created lists:

@@ -38,6 +38,7 @@ {{end}}
+ ...All my lists
diff --git a/res/template/account/user_lists.html b/res/template/account/user_lists.html new file mode 100644 index 0000000..eab4645 --- /dev/null +++ b/res/template/account/user_lists.html @@ -0,0 +1,56 @@ +{{define "user_lists"}} + + + {{template "meta_tags" "Lists"}} + + + + + {{template "menu" .}} + {{$limit := 100}} + {{$page := .URLQuery.Get "page" | pageNr}} + {{$lists := .PixelAPI.UserLists $page $limit}} +
+ {{if ne $page 0}} + 🡄 4 Pages + ⬅ 2 Pages + ← Last Page + {{end}} + Page {{$page}} + {{if len $lists.Lists | eq $limit}} + Next Page → + 2 Pages ⮕ + 4 Pages 🡆 + {{end}} +
+
+ + {{range $lists.Lists}} + + {{.Title}} + {{.Title}} + ({{.FileCount}} Files) +
+ {{.DateCreated.Format "2006-01-02 15:04:05"}} +
+ {{end}} + +
+
+ {{if ne $page 0}} + 🡄 4 Pages + ⬅ 2 Pages + ← Last Page + {{end}} + Page {{$page}} + {{if len $lists.Lists | eq $limit}} + Next Page → + 2 Pages ⮕ + 4 Pages 🡆 + {{end}} +
+ + {{template "analytics"}} + + +{{end}} diff --git a/res/template/fragments/menu.html b/res/template/fragments/menu.html index 86460bc..312ec8d 100644 --- a/res/template/fragments/menu.html +++ b/res/template/fragments/menu.html @@ -2,6 +2,7 @@
UsernameUsername / e-mail
Password