From 4d4e3ab9e6c82777bd65b81e06d2b3bfdb4b4712 Mon Sep 17 00:00:00 2001 From: Steph1508 Date: Fri, 10 Aug 2018 11:46:51 +0200 Subject: [PATCH] updating Help, inserting title possible, all selectfields work, fixing reuploading issues within one session, downloadbutton not working yet --> causes crash --- dashboard/server.R | 57 +++++++++++++++++++++++----------------------- dashboard/ui.R | 31 ++++++++++++------------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/dashboard/server.R b/dashboard/server.R index 52296e1..01373d5 100644 --- a/dashboard/server.R +++ b/dashboard/server.R @@ -4,7 +4,7 @@ library(jsonlite) library(DT) library(webshot) -server <- function(input, output) { +server <- function(input, output, session) { set.seed(122) #CoConUT Data import and showing into data site @@ -99,13 +99,13 @@ server <- function(input, output) { }) - - output$questTimes <- renderDataTable({ inFile <- input$quest if (is.null(inFile)) return(NULL) + + #loading CoCoQuest data json_data_quest <<- fromJSON(paste(inFile$datapath, sep = ""), flatten = TRUE) @@ -165,8 +165,9 @@ server <- function(input, output) { print(totalStarttime) }) + output$text <- renderText({ input$title }) - #TODO: Getting HEADER out of json to select it + output$check_histogram <- renderPrint({input$checkbox_hist }) #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({ @@ -178,63 +179,64 @@ server <- function(input, output) { output$input_hist_y <- renderUI({ if (is.null(input$nut)) return(NULL) - selectInput("in2", "y-axis:", as.list(coconut.df),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) }) + output$input_time_x <- renderUI({ if (is.null(input$nut)) return(NULL) - selectInput("in3", "x-axis:", as.list(coconut.df),multiple=TRUE, selectize=TRUE) + selectInput("in3", "x-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$input_time_y <- renderUI({ if (is.null(input$nut)) return(NULL) - selectInput("in4", "y-axis:", as.list(coconut.df),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) }) + output$input_map_x <- renderUI({ if (is.null(input$nut)) return(NULL) - selectInput("in5", "x-axis:", as.list(coconut.df),multiple=TRUE, selectize=TRUE) + selectInput("in5", "x-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$input_map_y <- renderUI({ if (is.null(input$nut)) return(NULL) - selectInput("in6", "y-axis:", as.list(coconut.df),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) }) + output$input_line_x <- renderUI({ if (is.null(input$nut)) return(NULL) - selectInput("in7", "x-axis:", as.list(coconut.df),multiple=TRUE, selectize=TRUE) + selectInput("in7", "x-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$input_line_y <- renderUI({ if (is.null(input$nut)) return(NULL) - selectInput("in8", "y-axis:", as.list(coconut.df),multiple=TRUE, selectize=TRUE) + selectInput("in8", "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$download <- downloadHandler({ - filename=function(){ - dashbord.png - paste("dashboard", "png", sep=".") - } - content=function(file){ - #open divice - png(file) - #create image - appshot(cocoVisR, file = "dashboard.png", ..., port = getOption("shiny.port"), envvars = NULL) - #close divice - dev.off() - } + + #download dashboard button + #TODO: MAKE IT WORK! + observeEvent(input$screenshot,{ + cdat <<- session$clientData + #print(cdat) + url <- paste0(cdat$url_protocol,"//",cdat$url_hostname,":", cdat$url_port, cdat$url_pathname,cdat$url_search) + print(url) + webshot::webshot(url, "webshot.png") }) - #output$downButton <- downloadHandler( # filename="dashboard.png", #content=function(file){ @@ -244,10 +246,7 @@ server <- function(input, output) { #}) #} #) - #appshot(cocoVisR, file = "dashboard.png", ..., port = getOption("shiny.port"), - #envvars = NULL) - - + #histdata <- rnorm(500) #output$plot1 <- renderPlot({ diff --git a/dashboard/ui.R b/dashboard/ui.R index 00686a5..5bf6ef9 100644 --- a/dashboard/ui.R +++ b/dashboard/ui.R @@ -66,24 +66,24 @@ ui <- dashboardPage( # Controlls tab content tabItem(tabName = "controlls", h2("Controlls here:"), - - checkboxInput("histogram", "Histogram", FALSE), + textInput("title", "Title", " "), + checkboxInput("checkbox_hist", label = "Histogram", value = FALSE), uiOutput("input_hist_x"), uiOutput("input_hist_y"), - checkboxInput("timeline", "Timeline", FALSE), + uiOutput("check_time"), uiOutput("input_time_x"), uiOutput("input_time_y"), - checkboxInput("map", "Map", FALSE), + uiOutput("check_map"), uiOutput("input_map_x"), uiOutput("input_map_y"), - checkboxInput("lingegraph","Linegraph",FALSE), + uiOutput("check_line"), uiOutput("input_line_x"), uiOutput("input_line_y") ), # Dashboard tab content tabItem(tabName = "dashboard", - h2("This is the Dashboard"), + h2(textOutput("text")), fluidRow( #tabBox( #title = "First tabBox", @@ -93,13 +93,13 @@ ui <- dashboardPage( #tabPanel("Tab2", "Tab content 2") #), - #if(menuitem$controls$histogram ==TRUE){ + #if(verbatimTextOutput("check_histogram")){ box( title="Histogram", status= "warning", solidHeader = TRUE, collapsible = TRUE, plotOutput("plot1", height = 250)), - #}, + # }, box(title="Map", status = "warning", @@ -113,12 +113,11 @@ ui <- dashboardPage( box(title="Linechart", status = "warning", solidHeader = TRUE, - collapsible = TRUE,plotOutput("plot4", height = 250))#, - - #downloadButton("downButton", "Download") + collapsible = TRUE,plotOutput("plot4", height = 250)) ), + actionButton("screenshot","Download") - downloadButton("downButton", "Download") + #downloadButton("downButton", "Download") ), @@ -131,15 +130,15 @@ ui <- dashboardPage( "For uploading you have to click on the 'Browse'-Button and an explorer-window will open.", br(), "Please navigate to the wanted file, select it and click on 'open'. Then the name of the selected file and a loadingbar will apear. 'Upload complete' will show you that the upload worked and is finished.", br(), - "Please make sure, that you upload the right data into the right field. If not please restart the Application and upload the correct file. Reloading within one session is not possible. ", br(), + "Please make sure, that you upload the right data into the right field. If not please upload the correct file in the right fields. ", br(), "First field: CoConUT and second field: CoCoQuest. Otherwise the visualization won't work.", h3("Data"), - "After correctly loading up the right json files, in this vies will apear a table that shows the data that were red from the jsons.", br(), + "After correctly loading up the right json files, in this vies will apear a table that shows the data that were red from the jsons. Also the names of the loaded files will apear, here you can check again, if the uploaded files where the right ones.", br(), h3("Controlls"), - "On this page you are able to select the visualizations you want to use and which data should be in them.", br(), + "On this page you are able to select the visualizations you want to use and which data should be in them.", br(), "Also you can enter the title of your dashboard.", "To show a visualization on the dashboard you have to enable the right checkbox. After that you need to select the x- and y-axis for this visualisation and then it will be added to the dashboard. ", h3("Dashboard"), - "Here you can now find your selected visualizations. ", br() + "Here you can now find your selected visualizations. Also there is a download button which will create a screenshot which you can save on your device.", br() ) -- GitLab