inst/ui-functions.R

ui_hello <- function(){
        shiny::fluidPage(
                h3("Hello"),
                p("Welcome to the time-series labeler."),
                br(),
                p("You can quickly view time series data and tag anomalies interactively."),
                p("You can create your own custom tags."),
                p("Your time series can be in data.table or read from a CSV."),
                br(),
                p("Ask for features or issue bugs here:", .noWS = "after"),
                a("https://github.com/rsangole/tslabeler")
        )
}

ui_from_env_df <- function(){
        shiny::sidebarLayout(
                sidebarPanel = shiny::sidebarPanel(
                        width = 2,
                        shiny::selectInput(
                                inputId = "df_to_load",
                                label = "Select variable",
                                choices = env_tabs$existing_tables,
                                multiple = FALSE
                        ),
                        shiny::uiOutput(outputId = "ui_select_df"),
                        shiny::uiOutput(outputId = "ui_select_btn_after_checkprep")
                ),
                mainPanel = shiny::mainPanel(
                        width = 10,
                        DT::dataTableOutput(outputId = "sample_data"),
                        br(),
                        shiny::verbatimTextOutput(outputId = "ui_check_df")
                )
        )
}

ui_from_env_tsibble <- function(){
        
}

ui_from_disk <- function(){
        shiny::sidebarLayout(
                sidebarPanel = shiny::sidebarPanel(
                        width = 2,
                        tagList(
                                shinyWidgets::awesomeRadio(
                                        inputId = "filein_sep",
                                        label = "Separator",
                                        choices = c(
                                                Comma = ',',
                                                Semicolon = ';',
                                                Tab = '\t'
                                        ),
                                        selected = ',',
                                        inline = T,
                                        status = "danger"
                                ),
                                div(style = "margin-top:-15px"),
                                shinyWidgets::awesomeRadio(
                                        inputId = 'filein_quote',
                                        label = 'Quote',
                                        choices = c(
                                                'Double Quote' = '"',
                                                'Single Quote' = "'",
                                                None = ''
                                        ),
                                        selected = '"',
                                        inline = T,
                                        status = "danger"
                                ),
                                div(style = "margin-top:-15px"),
                                shinyWidgets::awesomeRadio(
                                        inputId = 'filein_header',
                                        label = 'Header',
                                        choices = c(
                                                'Yes' = TRUE,
                                                'No' = FALSE
                                        ),
                                        selected = TRUE,
                                        inline = TRUE,
                                        status = "danger"
                                ),
                                div(style = "margin-top:-15px"),
                                shiny::fileInput(
                                        inputId = 'filein_rawdata',
                                        label = 'Choose CSV',
                                        multiple = FALSE,
                                        placeholder = "...",
                                        accept = c(
                                                'text/csv',
                                                'text/comma-separated-values,text/plain',
                                                '.csv'
                                        )
                                ),
                                shiny::uiOutput(outputId = "ui_select_csv"),
                                shiny::uiOutput(outputId = "ui_select_btn_after_checkprep_csv")
                        )
                ),
                mainPanel = shiny::mainPanel(
                        width = 10,
                        tagList(
                                DT::DTOutput(outputId = "DT_filein_preview"),
                                br(),
                                shiny::verbatimTextOutput(outputId = "ui_check_csv")
                        )
                )
        )
}

ui_label <- function(){
        shiny::sidebarLayout(
                sidebarPanel = shiny::sidebarPanel(
                        width = 2,
                        tagList(
                                shiny::uiOutput(outputId = "ui_labeler_sidemenu"),
                                br(),
                                shiny::tableOutput(outputId = "labeler_metatable")
                        )
                ),
                mainPanel = shiny::mainPanel(
                        width = 10,
                        tagList(
                                shiny::uiOutput("labeler_ui_tsplot", inline = T),
                                # div(style = "margin-top:-50px"),
                                # div(style = ".form-group {margin-bottom: 0 !important;}"),
                                shiny::uiOutput("labeler_ui_tsplot_zoomed", inline = T),
                                DT::dataTableOutput(outputId = "DT_selectionpreview")
                        )
                )
        )
}

ui_features <- function(){
        shiny::sidebarLayout(
                sidebarPanel = shiny::sidebarPanel(
                        width = 2,
                        shinyWidgets::awesomeCheckbox(
                                inputId = "feat_monthnum",
                                label = "Month (Num)",
                                value = FALSE,
                                status = "danger"
                        ),
                        shinyWidgets::awesomeCheckbox(
                                inputId = "feat_monthname",
                                label = "Month (Name)",
                                value = FALSE,
                                status = "danger"
                        ),
                        shinyWidgets::awesomeCheckbox(
                                inputId = "feat_qtr",
                                label = "Quarter",
                                value = FALSE,
                                status = "danger"
                        ),
                        shinyWidgets::awesomeCheckbox(
                                inputId = "feat_wday",
                                label = "Weekday / Weekend",
                                value = FALSE,
                                status = "danger"
                        ),
                        shinyWidgets::awesomeCheckbox(
                                inputId = "feat_daywk",
                                label = "Day of Week",
                                value = FALSE,
                                status = "danger"
                        ),
                        hr(),
                        shinyWidgets::actionBttn(
                                inputId = "btn_dofeat",
                                label = "Add Cols",
                                color = "success",
                                style = "material-flat",
                                size = "xs"
                        )
                        
                ),
                mainPanel = shiny::mainPanel(
                        width = 9,
                        DT::dataTableOutput(outputId = "DT_featpreview")
                )
        )
}

ui_save <- function(){
        shiny::fluidPage(
                shiny::fluidRow(
                        h3("Save to Disk"),
                        br(),
                        DT::DTOutput(outputId = "DT_savetodisk")
                ),
                hr(),
                shiny::fluidRow(
                        h3("Save to Environment"),
                        br(),
                        shinyWidgets::actionBttn(
                                        inputId = "btn_save_to_env",
                                        label = "Save",
                                        style = "material-flat",
                                        size = "s",
                                        color = "primary",
                                        icon = icon("floppy-o")
                                        )
                )
        )
}
rsangole/tslabeler documentation built on April 4, 2020, 8:26 p.m.