Title: | 'shiny' Cron Expression Input Widget |
---|---|
Description: | A widget for 'shiny' apps to handle schedule expression input, using the 'cron-expression-input' JavaScript component. Note that this does not edit the 'crontab' file, it is just an input element for the schedules. See <https://github.com/DatalabFabriek/shinycroneditor/blob/main/inst/examples/shiny-app.R> for an example implementation. |
Authors: | Harmen van der Veer [aut, cre] |
Maintainer: | Harmen van der Veer <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.0 |
Built: | 2024-11-23 05:33:47 UTC |
Source: | https://github.com/cran/shinycroneditor |
Cron editor, creates a 'htmlwidgets' object, for use in a 'shiny' dashboard
cron(schedule, width = NULL, height = NULL, elementId = NULL)
cron(schedule, width = NULL, height = NULL, elementId = NULL)
schedule |
Any valid cron schedule, for example "0 6 * * *" |
width |
How wide should the editor be? Defaults to NULL, meaning 100% |
height |
How high should the editor be? Defaults to NULL, meaning 32px |
elementId |
Optionally specifiy the ID of the element |
Returns a 'htmlwidgets' object that can be used in a 'shiny' app
# A simple cron editor in a Shiny app if (interactive()) { library(shiny) library(shinycroneditor) ui <- fluidPage( titlePanel("Cron Expression Input Widget"), mainPanel( shinycroneditor::cronOutput("cronschedule1", label = "Choose your first schedule", language = "en-US"), shiny::div( "Your first chosen schedule is: ", verbatimTextOutput("cronExpression1") ), shinycroneditor::cronOutput("cronschedule2", label = "Choose your second schedule", language = "en-US"), shiny::div( "Your chosen second schedule is: ", verbatimTextOutput("cronExpression2") ) ) ) server <- function(input, output, session) { output$cronschedule1 <- shinycroneditor::renderCron({ shinycroneditor::cron("0 6 * * *") }) output$cronExpression1 <- renderPrint({ input$cronschedule1 }) output$cronschedule2 <- shinycroneditor::renderCron({ shinycroneditor::cron("30 1,3,7 * * *") }) output$cronExpression2 <- renderPrint({ input$cronschedule2 }) } shinyApp(ui, server) }
# A simple cron editor in a Shiny app if (interactive()) { library(shiny) library(shinycroneditor) ui <- fluidPage( titlePanel("Cron Expression Input Widget"), mainPanel( shinycroneditor::cronOutput("cronschedule1", label = "Choose your first schedule", language = "en-US"), shiny::div( "Your first chosen schedule is: ", verbatimTextOutput("cronExpression1") ), shinycroneditor::cronOutput("cronschedule2", label = "Choose your second schedule", language = "en-US"), shiny::div( "Your chosen second schedule is: ", verbatimTextOutput("cronExpression2") ) ) ) server <- function(input, output, session) { output$cronschedule1 <- shinycroneditor::renderCron({ shinycroneditor::cron("0 6 * * *") }) output$cronExpression1 <- renderPrint({ input$cronschedule1 }) output$cronschedule2 <- shinycroneditor::renderCron({ shinycroneditor::cron("30 1,3,7 * * *") }) output$cronExpression2 <- renderPrint({ input$cronschedule2 }) } shinyApp(ui, server) }
Output and render functions for using cron editor within 'shiny' applications and interactive 'rmarkdown' documents.
cronOutput( outputId, label = NULL, language = "en-US", width = "100%", height = NULL ) renderCron(expr, env = parent.frame(), quoted = FALSE)
cronOutput( outputId, label = NULL, language = "en-US", width = "100%", height = NULL ) renderCron(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
label |
The label to show, just like in a regular Shiny input element. Set to NULL if you don't want a label. |
language |
The language the cron editor's UI will be in. Choose one of en-US, nl-NL, es-ES, zh-CN. Note that if you have multiple cron editors on one page, the last editor's language will be the one for all editors. |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a test |
env |
The environment in which to evaluate |
quoted |
Is |
An 'htmlwidgets' object for use in a shiny app, containing a placeholder for where the cron input element is rendered.
A 'htmlwidgets' object for use in a 'shiny' app as an input element