Skip to content

Commit

Permalink
som eprogress made on dropdown selection, now needs a dat aendpoint c…
Browse files Browse the repository at this point in the history
…onnecting
  • Loading branch information
Aiky30 committed Feb 13, 2024
1 parent 98690d7 commit e776487
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 17 additions & 5 deletions shedpi_hub_dashboard/static/shedpi_hub_dashboard/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ let drawDropdown = function (data) {
emptySelector.textContent = "Please Select"
dropdown.append(emptySelector)


dropdown.addEventListener('change', function (e) {
optionId = this.selectedOptions[0].id

if (optionId) {
loadTableData(optionId)
}
});

for (let deviceModuleIndex in data) {
const deviceModule = data[deviceModuleIndex]

let optionElement = document.createElement("option");
optionElement.textContent = deviceModule.device + " - " + deviceModule.name

optionElement.addEventListener('select', function (e) {
console.log("Draw data")
});
optionElement.id = deviceModule.device

dropdown.append(optionElement);
}
Expand All @@ -44,7 +50,13 @@ let drawDropdown = function (data) {

/* Table visual */

let loadTableData = function () {
let loadTableData = function (deviceModuleId) {


// TODO: Get data based on deviceModuleId
// Endpoint: http://127.0.0.1:8000/api/v1/device-module-readings/
// device_module = deviceModuleId

const urlDeviceModuleReading = section.getAttribute("data-json-feed")
let endpointDeviceModuleReading = new Request(urlDeviceModuleReading);
response = fetch(endpointDeviceModuleReading)
Expand Down
6 changes: 6 additions & 0 deletions shedpi_hub_dashboard/tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def test_device_module_list(client):
assert len(response.data) == 2


# TODO: device_module_readings_list
@pytest.mark.django_db
def device_module_readings_list(client):
assert False


@pytest.mark.django_db
def test_device_module_reading_submission(client):
schema = {
Expand Down

0 comments on commit e776487

Please sign in to comment.