Commit 5222ef3d authored by Stephanie Wegscheidl's avatar Stephanie Wegscheidl

dashboard only showing boxes if checkbox is checked. and Code cleaned up and

parent 4d4e3ab9
...@@ -4,10 +4,20 @@ library(jsonlite) ...@@ -4,10 +4,20 @@ library(jsonlite)
library(DT) library(DT)
library(webshot) library(webshot)
server <- function(input, output, session) { server <- function(input, output, session) {
set.seed(122) set.seed(122)
#DATA PAGE
#last coconut_name
output$lastLoadedNut<- renderText({
if (is.null(input$nut))
return(NULL)
else lastCoConUT
})
#CoConUT Data import and showing into data site #CoConUT Data import
output$nut <- renderDataTable({ output$nut <- renderDataTable({
inFile <- input$nut inFile <- input$nut
if (is.null(inFile)) if (is.null(inFile))
...@@ -21,7 +31,6 @@ server <- function(input, output, session) { ...@@ -21,7 +31,6 @@ server <- function(input, output, session) {
print("coconut:") print("coconut:")
print(coconut.df) print(coconut.df)
if(is.null(coconut.df$timestamp)){} if(is.null(coconut.df$timestamp)){}
else{unixTime<<-coconut.df$timestamp} else{unixTime<<-coconut.df$timestamp}
...@@ -88,24 +97,23 @@ server <- function(input, output, session) { ...@@ -88,24 +97,23 @@ server <- function(input, output, session) {
class = 'cell-border stripe' class = 'cell-border stripe'
) )
) )
}) })
output$lastLoadedNut<- renderText({ #last cocoquest_name
if (is.null(input$nut)) output$lastLoadedQuest <- renderText({
if (is.null(input$quest))
return(NULL) return(NULL)
else lastCoConUT else lastCoCoQuest
}) })
output$questTimes <- renderDataTable({
#CoCoQuest Data import
output$quest <- renderDataTable({
inFile <- input$quest inFile <- input$quest
if (is.null(inFile)) if (is.null(inFile))
return(NULL) return(NULL)
#loading CoCoQuest data #loading CoCoQuest data
json_data_quest <<- fromJSON(paste(inFile$datapath, sep = ""), flatten = TRUE) json_data_quest <<- fromJSON(paste(inFile$datapath, sep = ""), flatten = TRUE)
...@@ -122,23 +130,11 @@ server <- function(input, output, session) { ...@@ -122,23 +130,11 @@ server <- function(input, output, session) {
endtimes <<- c(anytime(dat$endtime/1000)) endtimes <<- c(anytime(dat$endtime/1000))
tasks <- rep(1:length(json_data_quest$tasks$data), sapply(json_data_quest$tasks$data, nrow)) tasks <- rep(1:length(json_data_quest$tasks$data), sapply(json_data_quest$tasks$data, nrow))
#count<<-0
# y <<-1
# x<<-1
#numOfTasks <<- if(tasks[x]!=y)
# {
# count<<-count+1
# y<<-y+1
# x<<-x+1
#}
#else{x<<-x+1}
together <<- c(tasks, endtimes) together <<- c(tasks, endtimes)
#all <<- matrix(c(tasks,endtimes),byrow=FALSE,nrow=length(tasks))
all <- rbind(together)
all <- rbind(together)
#setting the table style #setting the table style
datatable( datatable(
cbind(tasks, endtimes), cbind(tasks, endtimes),
...@@ -149,15 +145,8 @@ server <- function(input, output, session) { ...@@ -149,15 +145,8 @@ server <- function(input, output, session) {
) )
) )
}) })
#CoCOQuest Data import and showing into data site #cocoQuest Starttime
output$lastLoadedQuest <- renderText({
if (is.null(input$quest))
return(NULL)
else lastCoCoQuest
})
output$totalStarttime <- renderText({ output$totalStarttime <- renderText({
if (is.null(input$quest)) if (is.null(input$quest))
return(NULL) return(NULL)
...@@ -165,11 +154,13 @@ server <- function(input, output, session) { ...@@ -165,11 +154,13 @@ server <- function(input, output, session) {
print(totalStarttime) print(totalStarttime)
}) })
#CONTROLLS PAGE
#Title Input
output$text <- renderText({ input$title }) output$text <- renderText({ input$title })
output$check_histogram <- renderPrint({input$checkbox_hist }) #Histogram
#Not sure if so smart but it should work that way --> mit if schaun welches ausgewählt worden ist und die daten dann für dashboard ausgeben
output$input_hist_x <- renderUI({ output$input_hist_x <- renderUI({
if (is.null(input$nut)) if (is.null(input$nut))
return(NULL) return(NULL)
...@@ -182,8 +173,9 @@ server <- function(input, output, session) { ...@@ -182,8 +173,9 @@ server <- function(input, output, session) {
selectInput("in2", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE) selectInput("in2", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
}) })
output$check_time <- renderUI({checkboxInput("timeline", "Timeline", FALSE) })
#Timeline
output$input_time_x <- renderUI({ output$input_time_x <- renderUI({
if (is.null(input$nut)) if (is.null(input$nut))
return(NULL) return(NULL)
...@@ -196,8 +188,9 @@ server <- function(input, output, session) { ...@@ -196,8 +188,9 @@ server <- function(input, output, session) {
selectInput("in4", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE) selectInput("in4", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
}) })
output$check_map <- renderUI({checkboxInput("map", "Map", FALSE) })
#Map
output$input_map_x <- renderUI({ output$input_map_x <- renderUI({
if (is.null(input$nut)) if (is.null(input$nut))
return(NULL) return(NULL)
...@@ -210,8 +203,9 @@ server <- function(input, output, session) { ...@@ -210,8 +203,9 @@ server <- function(input, output, session) {
selectInput("in6", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE) selectInput("in6", "y-axis:", cbind("unixTime", "longitude", "latitude", "speed", "gps.acc","lux", "light.acc","acc.coordinates", "acc.acc","bluetooth","ble.bpm","ble.bpmlist","ble.hrv","ble.hrvlist","activity.name", "acctivity.confidence","screen.status" ,"touch"),multiple=TRUE, selectize=TRUE)
}) })
output$check_line <- renderUI({checkboxInput("linegraph", "Linegraph", FALSE) })
#Linegraph
output$input_line_x <- renderUI({ output$input_line_x <- renderUI({
if (is.null(input$nut)) if (is.null(input$nut))
return(NULL) return(NULL)
...@@ -226,9 +220,54 @@ server <- function(input, output, session) { ...@@ -226,9 +220,54 @@ server <- function(input, output, session) {
#download dashboard button
#DASHBOARD PAGE
#HISTOGRAM
output$hist_box <- renderUI({
if(input$check_hist)
box( title="Histogram",
status= "warning",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plot1", height = 250))
})
#TIMELINE
output$time_box <- renderUI({
if(input$check_time)
box( title="Timeline",
status= "warning",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plot1", height = 250))
})
#MAP
output$map_box <- renderUI({
if(input$check_map)
box( title="Map",
status= "warning",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plot1", height = 250))
})
#LINEGRAPH
output$line_box <- renderUI({
if(input$check_line)
box( title="Linegraph",
status= "warning",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plot1", height = 250))
})
#DownloadButton
#TODO: MAKE IT WORK! #TODO: MAKE IT WORK!
observeEvent(input$screenshot,{ observeEvent(input$screenshot,{
webshot::install_phantomjs()
cdat <<- session$clientData cdat <<- session$clientData
#print(cdat) #print(cdat)
url <- paste0(cdat$url_protocol,"//",cdat$url_hostname,":", cdat$url_port, cdat$url_pathname,cdat$url_search) url <- paste0(cdat$url_protocol,"//",cdat$url_hostname,":", cdat$url_port, cdat$url_pathname,cdat$url_search)
...@@ -247,6 +286,14 @@ server <- function(input, output, session) { ...@@ -247,6 +286,14 @@ server <- function(input, output, session) {
#} #}
#) #)
#SOME STUFF
#histdata <- rnorm(500) #histdata <- rnorm(500)
#output$plot1 <- renderPlot({ #output$plot1 <- renderPlot({
......
...@@ -58,7 +58,7 @@ ui <- dashboardPage( ...@@ -58,7 +58,7 @@ ui <- dashboardPage(
textOutput("lastLoadedQuest"), textOutput("lastLoadedQuest"),
h4("Starttime: "), h4("Starttime: "),
textOutput("totalStarttime"), textOutput("totalStarttime"),
dataTableOutput("questTimes") dataTableOutput("quest")
), ),
...@@ -67,16 +67,21 @@ ui <- dashboardPage( ...@@ -67,16 +67,21 @@ ui <- dashboardPage(
tabItem(tabName = "controlls", tabItem(tabName = "controlls",
h2("Controlls here:"), h2("Controlls here:"),
textInput("title", "Title", " "), textInput("title", "Title", " "),
checkboxInput("checkbox_hist", label = "Histogram", value = FALSE), #HISTOGRAM
checkboxInput("check_hist", "Histogram", FALSE),
#uiOutput("check_hist"),
uiOutput("input_hist_x"), uiOutput("input_hist_x"),
uiOutput("input_hist_y"), uiOutput("input_hist_y"),
uiOutput("check_time"), #TIMELINE
checkboxInput("check_time", "Timeline", FALSE),
uiOutput("input_time_x"), uiOutput("input_time_x"),
uiOutput("input_time_y"), uiOutput("input_time_y"),
uiOutput("check_map"), #MAP
checkboxInput("check_map", "Map", FALSE),
uiOutput("input_map_x"), uiOutput("input_map_x"),
uiOutput("input_map_y"), uiOutput("input_map_y"),
uiOutput("check_line"), #LINEGRAPH
checkboxInput("check_line", "Linegraph", FALSE),
uiOutput("input_line_x"), uiOutput("input_line_x"),
uiOutput("input_line_y") uiOutput("input_line_y")
), ),
...@@ -93,27 +98,12 @@ ui <- dashboardPage( ...@@ -93,27 +98,12 @@ ui <- dashboardPage(
#tabPanel("Tab2", "Tab content 2") #tabPanel("Tab2", "Tab content 2")
#), #),
#if(verbatimTextOutput("check_histogram")){
box( title="Histogram", uiOutput("hist_box"),
status= "warning", uiOutput("time_box"),
solidHeader = TRUE, uiOutput("map_box"),
collapsible = TRUE, uiOutput("line_box")
plotOutput("plot1", height = 250)),
# },
box(title="Map",
status = "warning",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plot2", height = 250)),
box(title="Timeline",
status = "warning",
solidHeader = TRUE,
collapsible = TRUE,plotOutput("plot3", height = 250)),
box(title="Linechart",
status = "warning",
solidHeader = TRUE,
collapsible = TRUE,plotOutput("plot4", height = 250))
), ),
actionButton("screenshot","Download") actionButton("screenshot","Download")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment