refactoring page buttons and front page time loads

levin
lza_menace 4 years ago
parent 69262619fe
commit 2315989b1e

@ -27,7 +27,7 @@ app.secret_key = app.config["SECRET_KEY"]
@app.route("/", methods=["GET", "POST"]) @app.route("/", methods=["GET", "POST"])
def index(): def index():
form = SubmitNode() form = SubmitNode()
itp = 20 itp = 10
page = request.args.get("page", 1) page = request.args.get("page", 1)
try: try:
page = int(page) page = int(page)
@ -52,7 +52,7 @@ def index():
nodes = nodes.where(Node.is_tor==True) nodes = nodes.where(Node.is_tor==True)
paginated = nodes.paginate(page, itp) paginated = nodes.paginate(page, itp)
total_pages = nodes.count() / itp total_pages = int(nodes.count() / itp) + 1
return render_template( return render_template(
"index.html", "index.html",
nodes=paginated, nodes=paginated,

@ -61,3 +61,11 @@ input[type="text"] {
.container2 { .container2 {
padding: 4em; padding: 4em;
} }
.page-btn {
text-align: center;
}
.current-page-btn {
background-color: #b8b8b8;
}

@ -57,7 +57,7 @@
<td>{{ node.last_height }}</td> <td>{{ node.last_height }}</td>
<td>{{ node.datetime_checked | humanize }}</td> <td>{{ node.datetime_checked | humanize }}</td>
<td>{% for hc in node.healthchecks %} <td>{% for hc in node.healthchecks %}
{% if loop.index > loop.length - 11 %} {% if loop.index > loop.length - 6 %}
<span class="dot glowing-{% if hc.health %}green{% else %}red{% endif %}"></span> <span class="dot glowing-{% if hc.health %}green{% else %}red{% endif %}"></span>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
@ -66,12 +66,11 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% if page > 1 %} <div class="page-btn">
<a href="/?page={{ page - 1 }}" class="pure-button btn">Back</a> {% for p in range(1, total_pages + 1) %}
{% endif %} <a href="/?page={{ p }}" class="pure-button btn {% if p == page %}current-page-btn{% endif %}">{{ p }}</a>
{% if page < total_pages and total_pages > 0 %} {% endfor %}
<a href="/?page={{ page + 1 }}" class="pure-button btn">Next</a> </div>
{% endif %}
{% else %} {% else %}
<p>No nodes in the database yet...</p> <p>No nodes in the database yet...</p>
{% endif %} {% endif %}

Loading…
Cancel
Save