I have two selectInputs, one for selecting a device and one for selecting what information they want from that device (temperature, humidity etc). My problem is when I select "Device1" all it's information is shown in the second input, and when I then select "Device2" the second input has the same options even though Device2 might not have that sensor in its database which returns an error.
My code is below:
selectInput("option", "Device",
choices = options()
),
selectInput("dataInput1", "Type",
choices = types()
)
types <- function() {
con <- influxdbr::influx_connection(####)
db_data <- paste0(session$userData$user$username)
results <- show_field_keys(con, db_data, measurement = input$option)
results <- results$fieldKey
return(results)
}
options <- function() {
con <- influxdbr::influx_connection(####)
query_data <- paste0("SHOW MEASUREMENTS")
db_data <- paste0(session$userData$user$username)
results <- show_measurements(con, db_data, where = NULL)
results <- unname(unlist(results))
return(results)
}
My question is how do I have the types from "dataInput1" change depending on what is selected from "option"?