aboutsummaryrefslogtreecommitdiff
path: root/lib/waev_web
diff options
context:
space:
mode:
Diffstat (limited to 'lib/waev_web')
-rw-r--r--lib/waev_web/controllers/exports_controller.ex9
-rw-r--r--lib/waev_web/templates/exports/show.html.eex2
-rw-r--r--lib/waev_web/views/exports_view.ex13
3 files changed, 21 insertions, 3 deletions
diff --git a/lib/waev_web/controllers/exports_controller.ex b/lib/waev_web/controllers/exports_controller.ex
index f2b6fb4..8d16cb5 100644
--- a/lib/waev_web/controllers/exports_controller.ex
+++ b/lib/waev_web/controllers/exports_controller.ex
@@ -1,10 +1,13 @@
defmodule WaevWeb.ExportsController do
use WaevWeb, :controller
- def show(conn, %{"id" => id}) do
- case Waev.Export.get(id) do
+ def show(conn, %{"id" => id} = params) do
+ page = Map.get(params, "page", "1") |> String.to_integer()
+ size = Map.get(params, "size", "100") |> String.to_integer()
+
+ case Waev.Export.get(id, page, size) do
{:ok, export} ->
- render(conn, "show.html", id: id, export: export)
+ render(conn, "show.html", id: id, export: export, page: page, size: size)
:error ->
conn
diff --git a/lib/waev_web/templates/exports/show.html.eex b/lib/waev_web/templates/exports/show.html.eex
index 6356804..15a1360 100644
--- a/lib/waev_web/templates/exports/show.html.eex
+++ b/lib/waev_web/templates/exports/show.html.eex
@@ -35,3 +35,5 @@
</div>
<% end %>
+
+<%= pagination_bar(assigns, @page, @size) %>
diff --git a/lib/waev_web/views/exports_view.ex b/lib/waev_web/views/exports_view.ex
index 680454c..f0cfa0d 100644
--- a/lib/waev_web/views/exports_view.ex
+++ b/lib/waev_web/views/exports_view.ex
@@ -38,4 +38,17 @@ defmodule WaevWeb.ExportsView do
|> raw()
end)
end
+
+ def pagination_bar(assigns, page, size) do
+ prev = if page == 0, do: 0, else: page - 1
+ # TODO max
+ next = page + 1
+
+ ~E"""
+ <div>
+ <a href="<%= Routes.exports_path(@conn, :show, @id, page: prev, size: size) %>">Left</a>
+ <a href="<%= Routes.exports_path(@conn, :show, @id, page: next, size: size) %>">Right</a>
+ </div>
+ """
+ end
end