-
-
Save marcionicolau/4437023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
# load a very small projects file | |
# Eventually the idea is to have a database link to SQLite or access | |
projects=data.frame(pid=c(1,2,3,4,5),project=c("proj1","proj2","proj3","proj4","proj5")) | |
# Define server logic | |
shinyServer(function(input, output) { | |
# if Projects -> View Projects is selected, this outputs the lists in dataframe projects | |
output$projlist=reactivePrint(function(){ | |
if(!(input$menuproj == "View Projects")) return(NULL) | |
projects | |
}) | |
# if Projects -> Add New Project is selected and | |
# a new project is entered in the text box and | |
# Update choice is selected in dropdown this this adds the new project to the dataframe projects | |
output$newprojout=reactivePrint(function(){ | |
if(input$projupdt == "Update") { | |
pidnew=nrow(projects)+1 | |
projects <<- rbind(projects,data.frame(pid=pidnew,project=input$newproj)) | |
} | |
projects[nrow(projects),] | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
# Objective: Test app to see if I can input data into a database | |
# Currently no database connection is set up and this app just starts with uploading a simple dataframe | |
# The data gets added to a temporary dataframe | |
shinyUI(pageWithSidebar( | |
# Application title | |
headerPanel("Test Form Input to Database"), | |
sidebarPanel( | |
# main type of view to select | |
selectInput("menutype","Choose View Type", | |
choices=c("ChooseOne","Projects","Project-Steps","Tasks")), | |
# selection if Projects view is selected | |
conditionalPanel( | |
condition = "input.menutype == 'Projects'", | |
selectInput("menuproj","Choose an Option", | |
choices=c("ChooseOne","View Projects","Add Project")) | |
) | |
), | |
mainPanel( | |
# view if Projects -> View Projects is selected | |
conditionalPanel( | |
condition = "input.menuproj == 'View Projects'", | |
HTML("<h3> Project List </h3>"), | |
verbatimTextOutput("projlist") | |
), | |
# view if Projects -> Add Project is selected | |
conditionalPanel( | |
condition = "input.menuproj == 'Add Project'", | |
HTML("<h3> Add or Modify a Project </h3>"), | |
selectInput("projupdt","Choose option Update to Add/Modify Project", | |
choices=c("Choose","Update")), | |
textInput("newproj","Add New Project"), | |
verbatimTextOutput("newprojout") | |
), | |
# view if Project-Steps is selected (to Do) | |
conditionalPanel( | |
condition="input.menutype == 'Project-Steps'", | |
HTML("<h3> To be Done </h3>")), | |
# view if Tasks is selected (to Do) | |
conditionalPanel( | |
condition="input.menutype == 'Tasks'", | |
HTML("<h3> To be Done </h3>")) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment