Skip to content
Permalink
Browse files

update ui with proper pagination path

  • Loading branch information...
tdantas committed Apr 15, 2019
1 parent d77da28 commit 0f85e48b3e3cda7b41582ebfae79ef90501a02f8

This file was deleted.

Oops, something went wrong.
@@ -1,6 +1,6 @@
<nav class="nav justify-content-end">
<a class="nav-link {% if not prev-page %}disabled{% endif %}"
href="{{prefix}}/failed?page={{ prev-page|default:"" }}">Prev</a>
href="{{prefix}}/{{page-name}}?page={{ prev-page|default:"" }}">Prev</a>
<a class="nav-link {% if not next-page %}disabled{% endif %}"
href="{{prefix}}/failed?page={{ next-page|default:"" }}">Next</a>
href="{{prefix}}/{{page-name}}?page={{ next-page|default:"" }}">Next</a>
</nav>
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% block content %}
{% include "components/paging_nav.html" %}

<table class="table">
<tr>
<th>ID</th>
@@ -13,7 +14,7 @@
<tr>
<td>
<a href="{{prefix}}/jobs/{{ item.job.job-id}}">
<span title="{{ item.job.job-id }}">{{ item.job.job-id|farmhand/subs:0:6 }}...</span>
<span title="{{ item.job.job-id }}">{{ item.job.job-id| farmhand/subs:0:6 }}...</span>
</a>
</td>
<td>{{ item.job.queue }}</td>
@@ -7,17 +7,16 @@
[farmhand.registry :as registry]
[farmhand.ui.layout :as layout :refer [error-page]]
[ring.util.anti-forgery :refer [anti-forgery-field]]
[clojure.string :refer [replace]]))
[clojure.string :as string]))

(defn- render-registry-page
[request template registry-name prefix]
[request template registry-name prefix page-name]
(layout/render-200
template
(let [page (as-int (get-in request [:query-params "page"]))]
(assoc (registry/page (:farmhand.ui/context request)
registry-name
{:page page})
(assoc (registry/page (:farmhand.ui/context request) registry-name {:page page})
:prefix prefix
:page-name page-name
:anti-forgery-field (anti-forgery-field)))))

(defn- normalize-prefix [prefix]
@@ -28,7 +27,7 @@

(defn endpoints [prefix]
(let [prefix (normalize-prefix prefix)
redirect #(layout/found (replace (str prefix %) #"//" "/"))]
redirect #(layout/found (string/replace (str prefix %) #"//" "/"))]

(routes
(context prefix []
@@ -48,16 +47,16 @@
(redirect "/queues"))

(GET "/in-flight" request
(render-registry-page request "registries/in_flight.html" queue/in-flight-registry prefix))
(render-registry-page request "registries/in_flight.html" queue/in-flight-registry prefix "in-flight"))

(GET "/scheduled" request
(render-registry-page request "registries/scheduled.html" queue/scheduled-registry prefix))
(render-registry-page request "registries/scheduled.html" queue/scheduled-registry prefix "scheduled"))

(GET "/completed" request
(render-registry-page request "registries/completed.html" queue/completed-registry prefix))
(render-registry-page request "registries/completed.html" queue/completed-registry prefix "completed"))

(GET "/failed" request
(render-registry-page request "registries/failed.html" queue/dead-letter-registry prefix))
(render-registry-page request "registries/failed.html" queue/dead-letter-registry prefix "failed"))

(GET "/jobs/:job-id" [job-id :as request]
(let [job (jobs/fetch (:farmhand.ui/context request) job-id)]
@@ -34,4 +34,4 @@

(testing "returns 404 once prefixed routes not found"
(let [response ((app (farmhand/create-context) "/farmhand") (request :get "/farmhand/invalid"))]
(is (= 404 (:status response))))))
(is (= 404 (:status response))))))

0 comments on commit 0f85e48

Please sign in to comment.
You can’t perform that action at this time.