Skip to content

Commit b2c07b2

Browse files
committed
feat: Started using the paginated endpoint, requires more work
1 parent abe9636 commit b2c07b2

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

shedpi_hub_dashboard/pagination.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
class CreatedAtBasedCursorPagination(CursorPagination):
55
ordering = "-created_at"
66
page_size_query_param = "page_size"
7+
page_size = 100

shedpi_hub_dashboard/static/shedpi_hub_dashboard/js/modules/table.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import {getSchemaDataFields} from "./utils.js";
33

44
/* Table visual */
55

6+
/* TODO: The table needs to have next and prev buttons and auto reload the data,
7+
this is going to require a redesign of the fetch */
8+
69
class dataTable {
710
constructor() {
811
this.dataset = [];

shedpi_hub_dashboard/static/shedpi_hub_dashboard/js/reading.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ let bindFormSubmision = function () {
9999
let loadTableData = function (deviceModuleId, startDate, endDate) {
100100

101101
// const url = section.getAttribute("data-json-feed")
102-
const url = window.location.origin + "/api/v1/device-module-readings/"
102+
const url = window.location.origin + "/api/v1/device-module-readings-paginated/"
103103
const endpoint = new URL(url);
104104
endpoint.searchParams.append("device_module", deviceModuleId);
105105
endpoint.searchParams.append("format", "json");
@@ -122,7 +122,7 @@ let loadTableData = function (deviceModuleId, startDate, endDate) {
122122
.then((response) => {
123123
const schema = deviceModuleSchemaMap[deviceModuleId]
124124

125-
table.draw(response, schema)
126-
chart.draw(response, schema)
125+
table.draw(response["results"], schema)
126+
chart.draw(response["results"], schema)
127127
});
128128
}

shedpi_hub_example_project/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,6 @@
134134
# "DEFAULT_PERMISSION_CLASSES": [
135135
# "rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"
136136
# ]
137-
"PAGE_SIZE": 100,
137+
# "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.CursorPagination",
138+
# "PAGE_SIZE": 100,
138139
}

0 commit comments

Comments
 (0)