commit 4cbdb545277502552ed23d6b601543ab10033347
parent 5eaf61f779f6a465f9d39c47d7e2a2bb304c0a3d
Author: William Lindholm <a22willi@student.his.se>
Date: Thu, 9 Nov 2023 17:43:32 +0100
Improved ajaxtable functions.
Diffstat:
3 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/WebInterface/routes.py b/WebInterface/routes.py
@@ -2,6 +2,8 @@ import json
from pathlib import Path
from flask import request, redirect, url_for, render_template, session
+from jinja2 import TemplateNotFound
+
from dbrepository import DatabaseRepository
from . import web_interface
from .tableFactory import TableFactory
@@ -15,12 +17,7 @@ def home():
if not session.get('logged_in'):
return redirect(url_for('web_interface.login'))
- page_number = request.args.get('page', 1, type=int)
-
- tables = TableFactory()
- message_table = tables.get_message_table(page_number)
-
- return render_template('home.html', page_title="home", table=message_table)
+ return render_template('home.html', page_title='Messages', api_endpoint='messages')
@web_interface.route('/integrations')
diff --git a/templates/ajaxtable.html b/templates/ajaxtable.html
@@ -1,6 +1,6 @@
<div class="row">
<div class="input-field col s10">
- <input type="text" id="search-bar" placeholder="Search Messages...">
+ <input type="text" id="search-bar" placeholder="Search {{ api_endpoint }}...">
</div>
<div class="input-field col s2">
<select id="page-size" onchange="searchData()">
@@ -32,7 +32,7 @@
<script>
- const API_ENDPOINT = '/api/messages/';
+ const API_ENDPOINT = '/api/{{ api_endpoint }}/';
document.addEventListener('DOMContentLoaded', function() {
M.AutoInit();
@@ -41,7 +41,6 @@
sortTableByHeader('id');
fetchData(API_ENDPOINT, { page: 1, page_size: 10 });
- sortTableByHeader('id');
});
function debounce(func, delay) {
@@ -54,4 +53,4 @@
};
}
-</script>
-\ No newline at end of file
+</script>
diff --git a/templates/home.html b/templates/home.html
@@ -1,5 +1,5 @@
{% extends 'base.html' %}
{% block content %}
-{% include 'ajaxtable.html' %}
-{% endblock %}
-\ No newline at end of file
+ {% include 'ajaxtable.html' %}
+{% endblock %}