inst/ModelBuild/ui.R

### ####################################################################
## UI code for the ModelBuild tool in FloodForT
### ####################################################################
library(shiny)
###########################
## uncomment the following if running without library for dbugging
## library(dygraphs)
## library(rhandsontable)
###########################

## set up the UI
shinyUI(
    navbarPage("FloodForT: Model Build",id="Main",
               
               ## Welcome tab
               tabPanel("Welcome",
                        source('uiWelcome.R',local=TRUE)$value
                       ,
               tags$script("Shiny.addCustomMessageHandler('messageBox', function(msg){window.alert(msg);})")),
               #######################################################
               ## Load Data tab
               tabPanel("Import Data",
                        source('uiImport.R',local=TRUE)$value
                        ),
               #######################################################
               ## Manipulate Data tab
               tabPanel("Combine Data",
                        source('uiCombine.R',local=TRUE)$value
                        ),
               #######################################################
               ## Select data tab
               tabPanel("Select Data",
                        source('uiSelectData.R',local=TRUE)$value
                        ),
               #######################################################
               ## Estimate Model tab
               tabPanel("Estimate Model",
                        source('uiEstimateModel.R',local=TRUE)$value
                        ),
               #######################################################
               ## Data Assimilation tab
               tabPanel("Data Assimilation",
                        source('uiEstimateDA.R',local=TRUE)$value
                        ),
               #######################################################
               ## Save tab
               tabPanel("Save",
                        source('uiSave.R',local=TRUE)$value
                        ),
               #######################################################
               ## help tab
               tabPanel("Help",
                        source('uiHelp.R',local=TRUE)$value
                        )
               )    
    )



## # Define UI for random distribution application 
## shinyUI(
##   fluidPage(
    
##     # Application title
##     titlePanel("Flood Forecasting Toolbox - Model Build",windowTitle = "FloodForT"),
    
##     # set to a sidebar layout
##     sidebarLayout(
##       # Sidebar with text to inform the user about the steps
##       sidebarPanel(
##         # set up the message handler
##         tags$script("Shiny.addCustomMessageHandler('messageBox', function(msg){window.alert(msg);})"),
        
##         # Sidebar for welcome and information
##         conditionalPanel(
##           condition = "input.tabset == 1",
##           h3("Welcome",a(href="#",
##                          onclick = "window.open('FloodForT_User_Manual.pdf#page=14', 'ManualWindow').focus();",
##                          tags$i(class="icon-question-sign")
##           )
##           ),
##           img(src = "dhm.jpg",width=200),
##           br(),
##           br(),
##           img(src = "pac.gif",width=200),
##           br(),
##           br(),
##           img(src = "ulanc.png",width=200),
##           br(),
##           br(),
##           img(src = "Logo_ZURICHrgb4.jpg",width=200)          
##         ),
        
##         # Sidebar for loading the data
##         conditionalPanel(
##           condition = "input.tabset == 2 & output.flgData == false",
##           # execute when no data is loaded
##           h3("Read Data",a(href="#",
##                            onclick = "window.open('FloodForT_User_Manual.pdf#page=15', 'ManualWindow').focus();",
##                            tags$i(class="icon-question-sign")
##           )),
##           p("Please load the data used to generate the flood forecasting model"),
##           wellPanel(
##             fileInput("fileData", 'Choose Data File',
##                       accept=c('text/csv', 
##                                'text/comma-separated-values,text/plain', '.csv')
##             ),
##             radioButtons('radSepData', 'Separator',
##                          c(Comma=',',
##                            Semicolon=';',
##                            Tab='\t'),
##                          ','
##             ),
##             radioButtons('radQuoteData', 'Quote',
##                          c(None='',
##                            'Double Quote'='"',
##                            'Single Quote'="'"),
##                          '"'
##             )
##           )
##         ),
        
##         # Sidebar after the data is loaded
##         conditionalPanel(
##           condition = "input.tabset == 2 & output.flgData==true",
##           h3("Read Data",a(href="#",
##                            onclick = "window.open('FloodForT_User_Manual.pdf#page=15', 'ManualWindow').focus();",
##                            tags$i(class="icon-question-sign")
##           )),
##           p("Select the variables and range of the data to display"),
##           wellPanel(
##             uiOutput("sliderDateData"),
            
##             selectInput("selData",
##                         "Select variables:",
##                         "",
##                         selected = "",
##                         multiple=TRUE),
##             checkboxInput('ckScaleData', 'Scale Data?', FALSE)
##           )
##         ),
        
##         # sidebar for selecting the calibration data
##         conditionalPanel(
##           condition = "input.tabset == 3",    
          
##           h3("Select Data",a(href="#",
##                              onclick = "window.open('FloodForT_User_Manual.pdf#page=17', 'ManualWindow').focus();",
##                              tags$i(class="icon-question-sign")
##           )),
##           helpText("Specify the calibration data"),
##           wellPanel(
##             selectInput("selInputVar", "Select the input variable:",
##                         ""),
##             selectInput("selOutputVar", "Select the output variable:",
##                         ""),
##             selectInput("selWeightVar", "Select the series of weights:",
##                         ""),
##             uiOutput("sliderCalibData"),
##             uiOutput("sliderValidData"),
##             checkboxInput("ckMinima",
##                           "Remove Minima of onput and output series before fitting?",
##                           TRUE
##             ),
##             actionButton("bttnData","Set Calibration Data")   
##           )
##         ),
        
##         # sidebar for the simulation model estimation ####
##         conditionalPanel(
##           condition = "input.tabset == 4",  
          
##           h3("Model Estimation",a(href="#",
##                                   onclick = "window.open('FloodForT_User_Manual.pdf#page=18', 'ManualWindow').focus();",
##                                   tags$i(class="icon-question-sign")
##           )),
##           helpText("Select the limits of the model search"),
##           wellPanel(
##             sliderInput("sliderNumPath",
##                         "Select the number of parrallel pathways of response:",
##                         min=1,
##                         max=4,
##                         value=c(1,2)
##             ),
##             sliderInput("sliderTimeDelay", 
##                         "Select the ranage of time delays to search", 
##                         min = 1,
##                         max = 15,
##                         value = c(1,5)
##             ),
##             checkboxGroupInput("ckNonLin",
##                                "Select Non-linearities to use",
##                                c("None" = "none","Power Law" = "plaw","Negative exponential" = "nexp"),
##                                selected = "none"),
##             actionButton("bttnEstSim","Estimate Models")
##           )
##         ),
        
##         # sidebar for  data assimilation ####
##         conditionalPanel(
##           condition = "input.tabset == 5",
##           h3("Data Assimilation",a(href="#",
##                                    onclick = "window.open('FloodForT_User_Manual.pdf#page=20', 'ManualWindow').focus();",
##                                    tags$i(class="icon-question-sign")
##           )),
##           helpText("Estimate the data assimilation parameters and representation of the forecast uncertainty"),
##           wellPanel(
##             selectInput("selMdlDA", "Select Model to use (Non-linearity, Number of paths, Time delay)",
##                         "",
##                         selected = NULL, multiple = FALSE
##             ),
##             actionButton("bttnDA","Estimate Data Assimilation")
##           )
##         ),
        
##         # The rest of the siderbar containing button and version number ####
##         conditionalPanel(
##           condition = "output.flgData==true",    
##           wellPanel(
##             fluidRow(
##               textInput("downloadFileName","Name of file to Save:",value="")
##             ),
##             fluidRow(
##               downloadButton('bttnDownloadAll', 'Save Analysis')
##             ),
##             conditionalPanel(
##               condition = "output.flgDA == true & input.tabset == 5",
##               br(),
##               fluidRow(
##                 downloadButton('bttnDownloadForecast', 'Save Forecasts')
##               ),
##               br(),
##               fluidRow(
##                 downloadButton('bttnDownloadModel', 'Save Model')                
##               )
##             )
##           )
##         ),
##         tags$div(style='font-size:11px;', "v0.8 2014.06.06")
##       ),
      
##       # main panel with tabset options
##       mainPanel(
##         # to enable progress bar output
##         #includeCSS("progress.css"),
##         bsProgressBar("progBar", value = 0, visible = FALSE, color = "standard", 
##                       striped = FALSE, animate = FALSE),
##         bsAlert("alert"),
##         #progressInit(),
##         # set up waiting indicator
##         #         conditionalPanel(condition="$('html').hasClass('shiny-busy') & 
##         #                                  input.selPlotSS != 'movie'",
##         #                          tags$img(src="loader.gif")
##         #         ),
        
##         # Start of main tab set
##         tabsetPanel(
##           # Welcome tab panel
##           tabPanel("Welcome", 
##                    #                 h2("Welcome"),
##                    p('This is a prototype version to the interface for the guided building of', 
##                      'Data Based Mechanistic flood forcasting models.',
##                      ' It has been developed in partnership with the Nepalese',
##                      ' Dept. of Hydrology & Meteorology and Practical Action Consulting.'),
##                    p('Please contact Practical Action Consulting if you intend to use',
##                      ' this software for commercial or other gain.'),
##                    p('As a prototype reasonable performance can be expected. However ',
##                      'if you encounter bugs, or want to suggest (or impliment) new features',
##                      ' please contact p.j.smith at lancaster.ac.uk'),
##                    p('A ',
##                      a('manual',href="#",onclick = "window.open('FloodForT_User_Manual.pdf#page=1', 'ManualWindow').focus();"),
##                      'is available and other supporting documentation can be found at the ',
##                      a('software website',href="http://flood.lancs.ac.uk/FloodForT.html")
##                      ),
##                    value = 1
##           ),
          
##           # read Data tab panel
##           tabPanel("Read Data",
##                    conditionalPanel(
##                      condition = "input.tabset == 2 & output.flgData==true",
                     
##                      tabsetPanel(
##                        tabPanel("Data Table",
##                                 dataTableOutput('tblData')
##                        ),
##                        tabPanel("Data Plot",
##                                 plotOutput("plotData")
##                        ),
##                        tabPanel("Combine Data",
##                                 fluidRow(
##                                   column(width=4,
##                                          selectInput("selComb1", "Select the variables to combine:",
##                                               "")
##                                          ),
##                                   column(width=2,
##                                          numericInput("numCombW1", "Weight", 0.1, min = 0, max = 1,
##                                                step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,
##                                          selectInput("selComb2", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW2", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb3", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW3", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb4", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW4", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb5", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW5", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb6", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW6", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb7", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW7", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb8", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW8", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb9", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW9", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 fluidRow(
##                                   column(width=4,         
##                                          selectInput("selComb10", "Select the variables to combine:",
##                                                      "")
##                                   ),
##                                   column(width=2,
##                                          numericInput("numCombW10", "Weight", 0.1, min = 0, max = 1,
##                                                       step = 0.01)
##                                   )
##                                 ),
##                                 br(),
##                                 fluidRow(
##                                   column(width=4,
##                                          textInput("txtNameComb", "Enter name for new variablelabe:", value = "")
##                                   ),
##                                   column(width=4,
##                                          actionButton("bttnComb","Make new variable")
##                                   )
##                                 )        
                                
                                
##                        )
##                      )
##                    ),
##                    value = 2
##           ),
          
##           # data select tab panel
##           tabPanel("Select Data",
##                    plotOutput("plotCalibData"),
##                    value = 3
##           ),
          
##           # Model estimation tab panel
##           tabPanel("Model Estimation",
##                   conditionalPanel(
##                     condition = "output.flgMdl == true",
##                      tabsetPanel(
##                        tabPanel("Results Table",
##                                 dataTableOutput('tblRes')
##                        ),
##                        tabPanel("Result Plots",
##                                 fluidRow(
##                                   column(width=5,
##                                          selectInput(
##                                            inputId = "selPlotRes",
##                                            label = "Select type of plot",
##                                            choices = c(
##                                              "Hydrograph"= "hyd",
##                                              "Thresholded RMSE"= "trmse"),
##                                            selected = "trmse")
##                                   ),
##                                   column(width=7,
##                                          selectInput("selMdlRes", "Select models to plot (Non-linearity, Number of paths, Time delay)",
##                                                      "",
##                                                      selected = "", multiple = TRUE)
                                                                         
##                                   )
##                                 ),
##                                 checkboxInput("ckMdlRes", "Show Validation results", value = FALSE),
##                                 conditionalPanel(condition = "input.selPlotRes=='hyd'",
##                                                  uiOutput("sliderDateRes")),
##                                 plotOutput("plotRes")
##                        ),
##                        tabPanel("Model Parameters",
##                                 selectInput("selParRes", "Select model (Non-linearity, Number of paths, Time delay)",
##                                             "",
##                                             selected = "", multiple = FALSE
##                                 ),
##                                 uiOutput("htmlParRes")                              
##                        )
##                     )
##                    ),
##                    value = 4
##           ),
          
##           # data assimilation tab panel
##           tabPanel("Data Assimilation",
##                    conditionalPanel(
##                      condition = "output.flgDA == false &
##                      output.flgForData == false",
##                      wellPanel(
##                        h3("Forecast Inputs"),
##                        fileInput('fileForecast', 'Choose CSV File of forecast inputs',multiple = TRUE,
##                                  accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')
##                        ),
##                        radioButtons('radSepFor', 'Separator',
##                                     c(Comma=',',
##                                       Semicolon=';',
##                                       Tab='\t'),
##                                     ','
##                        ),
##                        radioButtons('radQuoteFor', 'Quote',
##                                     c(None='',
##                                       'Double Quote'='"',
##                                       'Single Quote'="'"),
##                                     '"'
##                        )
##                      )
##                    ),
##                    conditionalPanel(
##                        condition = "output.flgDA == true",
##                        fluidRow(
##                          column(width=4,
##                                 selectInput(
##                                   inputId = "selPlotSS",
##                                   "Select Plot Type:",
##                                   choices = c(
##                                     "Hydrograph"= "hyd",
##                                     "Thresholded RMSE"= "trmse",
##                                     "Movie" = "movie",
##                                     "Uncertainty" = "uncert"),
##                                   selected = "trmse")
##                          ),
##                          column(width=4,
##                                 conditionalPanel(
##                                   condition = "!(input.selPlotSS == 'movie')",
##                                   selectInput("selLeadSS", "Select lead time:",
##                                               "",
##                                               selected = NULL, multiple = TRUE)
##                                 )
##                          )
##                        ),
##                        checkboxInput("ckPlotSS","Show validation Data"),
## #                       fluidRow(
##                          conditionalPanel(
##                            condition = "input.selPlotSS == 'hyd'",
##                            uiOutput("sliderDateSS")),
##                          conditionalPanel(
##                            condition = "input.selPlotSS == 'movie'",
##                            uiOutput("sliderDateMovSS"),
##                            sliderInput("sliderMovSS",
##                                        label = "Select starting date of animation:",
##                                        min = -100,
##                                        max = 0,
##                                        value = 0,
##                                        step = 1,
##                                        animate = list(loop=TRUE,interval = 1000,pauseButton=NULL))
##                          ),
## #                       ),
##                        #                    uiOutput("ssMovDate"),
##                        plotOutput("plotSS")
##                    ),
##                    value = 5
##           ),
##           id = "tabset"
##         )
##       )
##     )
##   )
## )
waternumbers/FloodForT documentation built on Nov. 5, 2019, 12:07 p.m.