diff --git a/DESCRIPTION b/DESCRIPTION
index 7dd68f4..bb5b503 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -21,7 +21,7 @@ Imports:
shiny,
shinyalert
Remotes:
- Rapporteket/rapbase
+ Rapporteket/rapbase@main
License: GPL-3
Encoding: UTF-8
LazyData: true
diff --git a/R/app_server.R b/R/app_server.R
index 539d955..26c007a 100644
--- a/R/app_server.R
+++ b/R/app_server.R
@@ -9,9 +9,6 @@
app_server <- function(input, output, session) {
- # Last inn data
- regData <- getFakeRegData()
-
# Brukerinformasjon i menylinja (navbar)
output$appUserName <- shiny::renderText(
paste(rapbase::getUserFullName(session),
@@ -20,6 +17,7 @@ app_server <- function(input, output, session) {
output$appOrgName <- shiny::renderText(rapbase::getUserReshId(session))
userInfo <-
rapbase::howWeDealWithPersonalData(session, callerPkg = "rapRegTemplate")
+
shiny::observeEvent(input$userInfo, {
shinyalert::shinyalert("Dette vet Rapporteket om deg:", userInfo,
type = "", imageUrl = "rap/logo.svg",
@@ -27,268 +25,9 @@ app_server <- function(input, output, session) {
html = TRUE, confirmButtonText = rapbase::noOptOutOk())
})
- # Veiledning
- output$veiledning <- shiny::renderUI({
- rapbase::renderRmd(
- system.file("veiledning.Rmd", package = "rapRegTemplate"),
- outputType = "html_fragment"
- )
- })
-
-
- # Figur og tabell
- # Figur
- output$distPlot <- shiny::renderPlot({
- makeHist(df = regData, var = input$var, bins = input$bins)
- })
-
- # Tabell
- output$distTable <- shiny::renderTable({
- makeHist(df = regData, var = input$var, bins = input$bins,
- makeTable = TRUE)
- })
-
-
- # Samlerapport
- ## vis
- output$samlerapport <- shiny::renderUI({
- rapbase::renderRmd(
- system.file("samlerapport.Rmd", package = "rapRegTemplate"),
- outputType = "html_fragment",
- params = list(type = "html",
- var = input$varS,
- bins = input$binsS)
- )
- })
-
- ## last ned
- output$downloadSamlerapport <- shiny::downloadHandler(
- filename = function() {
- basename(tempfile(pattern = "rapRegTemplateSamlerapport",
- fileext = paste0(".", input$formatS)))
- },
- content = function(file) {
- srcFile <-
- normalizePath(system.file("samlerapport.Rmd", package = "rapRegTemplate"))
- fn <- rapbase::renderRmd(srcFile, outputType = input$formatS,
- params = list(type = input$formatS,
- var = input$varS,
- bins = input$binsS))
- file.rename(fn, file)
- }
- )
-
-
- # Abonnement
- ## rekative verdier for aa holde rede paa endringer som skjer mens
- ## applikasjonen kjorer
- subscription <- shiny::reactiveValues(
- tab = rapbase::makeAutoReportTab(session, type = "subscription")
- )
-
- ## lag tabell over gjeldende status for abonnement
- output$activeSubscriptions <- DT::renderDataTable(
- subscription$tab, server = FALSE, escape = FALSE, selection = "none",
- options = list(dom = "tp", ordning = FALSE,
- columnDefs = list(list(visible = FALSE, targets = 6))),
- rownames = FALSE
- )
-
- ## lag side som viser status for abonnement, ogsaa naar det ikke finnes noen
- output$subscriptionContent <- shiny::renderUI({
- userFullName <- rapbase::getUserFullName(session)
- if (length(subscription$tab) == 0) {
- shiny::p(paste("Ingen aktive abonnement for", userFullName))
- } else {
- shiny::tagList(
- shiny::p(paste0("Aktive abonnement som sendes per epost til ",
- userFullName, ":")),
- DT::dataTableOutput("activeSubscriptions")
- )
- }
- })
-
- ## nye abonnement
- ## Objects currently shared among subscription and dispathcment
- orgs <- list(Sykehus1 = 1234,
- Sykehus2 = 4321)
- reports <- list(
- Samlerapport1 = list(
- synopsis = "Automatisk samlerapport1",
- fun = "samlerapport1Fun",
- paramNames = c("p1", "p2"),
- paramValues = c("Alder", 1)
- ),
- Samlerapport2 = list(
- synopsis = "Automatisk samlerapport2",
- fun = "samlerapport2Fun",
- paramNames = c("p1", "p2"),
- paramValues = c("BMI", 1)
- )
- )
-
- ## Subscription
- rapbase::autoReportServer(
- id = "testSubscription", registryName = "rapRegTemplate",
- type = "subscription", reports = reports, orgs = orgs, freq = "quarter"
- )
-
- # Utsending
- ## reaktive verdier for aa holde rede paa endringer som skjer mens
- ## applikasjonen kjorer
- dispatchment <- shiny::reactiveValues(
- tab = rapbase::makeAutoReportTab(session = session, type = "dispatchment"),
- report = "Automatisk samlerapport1",
- freq = "M\u00E5nedlig-month",
- email = vector()
- )
-
- ## observer og foreta endringer mens applikasjonen kjorer
- shiny::observeEvent(input$addEmail, {
- dispatchment$email <- c(dispatchment$email, input$email)
- })
- shiny::observeEvent(input$delEmail, {
- dispatchment$email <-
- dispatchment$email[!dispatchment$email == input$email]
- })
- shiny::observeEvent(input$dispatch, {
- package <- "rapRegTemplate"
- type <- "dispatchment"
- owner <- rapbase::getUserName(session)
- ownerName <- rapbase::getUserFullName(session)
- interval <- strsplit(input$dispatchmentFreq, "-")[[1]][2]
- intervalName <- strsplit(input$dispatchmentFreq, "-")[[1]][1]
- runDayOfYear <- rapbase::makeRunDayOfYearSequence(
- interval = interval
- )
-
- email <- dispatchment$email
- organization <- rapbase::getUserReshId(session)
-
- if (input$dispatchmentRep == "Automatisk samlerapport1") {
- synopsis <- "Automatisk samlerapport1"
- fun <- "samlerapport1Fun"
- paramNames <- c("p1", "p2")
- paramValues <- c("Alder", 1)
-
- }
- if (input$dispatchmentRep == "Automatisk samlerapport2") {
- synopsis <- "Automatisk samlerapport2"
- fun <- "samlerapport2Fun"
- paramNames <- c("p1", "p2")
- paramValues <- c("BMI", 2)
- }
- rapbase::createAutoReport(synopsis = synopsis, package = package,
- type = type, fun = fun, paramNames = paramNames,
- paramValues = paramValues, owner = owner,
- ownerName = ownerName,
- email = email, organization = organization,
- runDayOfYear = runDayOfYear,
- interval = interval, intervalName = intervalName)
- dispatchment$tab <-
- rapbase::makeAutoReportTab(session, type = "dispatchment")
- dispatchment$email <- vector()
- })
-
- ## ui: velg rapport
- output$report <- shiny::renderUI({
- shiny::selectInput(
- "dispatchmentRep", "Rapport:",
- c("Automatisk samlerapport1", "Automatisk samlerapport2"),
- selected = dispatchment$report
- )
- })
-
- ## ui: velg frekvens
- output$freq <- shiny::renderUI({
- shiny::selectInput(
- "dispatchmentFreq", "Frekvens:",
- list("\u00C5rlig" = "\u00C5rlig-year",
- Kvartalsvis = "Kvartalsvis-quarter",
- Maanedlig = "M\u00E5nedlig-month",
- Ukentlig = "Ukentlig-week",
- Daglig = "Daglig-DSTday"),
- selected = dispatchment$freq
- )
- })
-
- ## ui: legg til gyldig- og slett epost
- output$editEmail <- shiny::renderUI({
- if (!grepl("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$",
- input$email)) {
- shiny::tags$p("Angi mottaker over")
- } else {
- if (input$email %in% dispatchment$email) {
- shiny::actionButton("delEmail", "Slett epostmottaker",
- icon = shiny::icon("trash"))
- } else {
- shiny::actionButton("addEmail", "Legg til epostmottaker",
- icon = shiny::icon("pencil"))
- }
- }
- })
-
- ## ui: vis valgte mottakere
- output$recipients <- shiny::renderText(paste(dispatchment$email,
- sep = "
"))
-
- ## ui: lag ny utsending
- output$makeDispatchment <- shiny::renderUI({
- if (length(dispatchment$email) == 0) {
- NULL
- } else {
- shiny::actionButton("dispatch", "Lag utsending",
- icon = shiny::icon("save"))
- }
- })
-
- ## lag tabell over gjeldende status for utsending
- output$activeDispatchments <- DT::renderDataTable(
- dispatchment$tab, server = FALSE, escape = FALSE, selection = "none",
- options = list(dom = "tp", ordering = FALSE), rownames = FALSE
- )
-
-
- ## ui: lag side som viser status for utsending, ogsaa naar det ikke finnes noen
- output$dispatchmentContent <- shiny::renderUI({
- if (length(dispatchment$tab) == 0) {
- shiny::p("Det finnes ingen utendinger")
- } else {
- shiny::tagList(
- shiny::p("Aktive utsendinger:"),
- DT::dataTableOutput("activeDispatchments")
- )
- }
- })
-
- # Rediger eksisterende auto rapport (alle typer)
- shiny::observeEvent(input$edit_button, {
- repId <- strsplit(input$edit_button, "_")[[1]][2]
- rep <- rapbase::readAutoReportData()[[repId]]
- if (rep$type == "subscription") {
-
- }
- if (rep$type == "dispatchment") {
- dispatchment$freq <- paste0(rep$intervalName, "-", rep$interval)
- dispatchment$email <- rep$email
- rapbase::deleteAutoReport(repId)
- dispatchment$tab <-
- rapbase::makeAutoReportTab(session, type = "dispatchment")
- dispatchment$report <- rep$synopsis
- }
- if (rep$type == "bulletin") {
-
- }
- })
-
- # Slett eksisterende auto rapport (alle typer)
- shiny::observeEvent(input$del_button, {
- repId <- strsplit(input$del_button, "_")[[1]][2]
- rapbase::deleteAutoReport(repId)
- subscription$tab <-
- rapbase::makeAutoReportTab(session, type = "subscription")
- dispatchment$tab <-
- rapbase::makeAutoReportTab(session, type = "dispatchment")
- })
-
+ veiledning_server("veiledning")
+ plots_server("plots")
+ samlerapport_server("samlerapport")
+ abonnement_server("abonnement")
+ utsending_server("utsending")
}
diff --git a/R/app_ui.R b/R/app_ui.R
index 8826354..2290aca 100644
--- a/R/app_ui.R
+++ b/R/app_ui.R
@@ -20,139 +20,27 @@ app_ui <- function() {
windowTitle = regTitle,
theme = "rap/bootstrap.css",
id = "tabs",
-
shiny::tabPanel(
"Veiledning",
- shiny::mainPanel(
- width = 12,
- shiny::htmlOutput("veiledning", inline = TRUE),
- rapbase::appNavbarUserWidget(
- user = shiny::uiOutput("appUserName"),
- organization = shiny::uiOutput("appOrgName"),
- addUserInfo = TRUE
- )
- )
+ veiledning_ui("veiledning")
),
shiny::tabPanel(
"Figur og tabell",
- shiny::sidebarLayout(
- shiny::sidebarPanel(
- width = 3,
- shiny::selectInput(
- inputId = "var",
- label = "Variabel:",
- c("mpg", "disp", "hp", "drat", "wt", "qsec")
- ),
- shiny::sliderInput(
- inputId = "bins",
- label = "Antall grupper:",
- min = 1,
- max = 10,
- value = 5
- )
- ),
- shiny::mainPanel(
- shiny::tabsetPanel(
- shiny::tabPanel("Figur", shiny::plotOutput("distPlot")),
- shiny::tabPanel("Tabell", shiny::tableOutput("distTable"))
- )
- )
- )
+ plots_ui("plots")
),
shiny::tabPanel(
"Samlerapport",
- shiny::tabPanel(
- "Fordeling av mpg",
- shiny::sidebarLayout(
- shiny::sidebarPanel(
- width = 3,
- shiny::selectInput(
- inputId = "varS",
- label = "Variabel:",
- c("mpg", "disp", "hp", "drat", "wt", "qsec")
- ),
- shiny::sliderInput(
- inputId = "binsS",
- label = "Antall grupper:",
- min = 1,
- max = 10,
- value = 5
- ),
- shiny::selectInput(
- inputId = "formatS",
- label = "Velg format for nedlasting:",
- choices = list(PDF = "pdf", HTML = "html")
- ),
- shiny::downloadButton(
- outputId = "downloadSamlerapport",
- label = "Last ned!"
- )
- ),
- shiny::mainPanel(
- shiny::uiOutput("samlerapport")
- )
- )
- )
- ),
- shiny::tabPanel(
- "Abonnement",
- shiny::sidebarLayout(
- shiny::sidebarPanel(
- width = 3,
- shiny::selectInput(
- "subscriptionRep", "Rapport:",
- c("Samlerapport1", "Samlerapport2")
- ),
- shiny::selectInput(
- "subscriptionFreq", "Frekvens:",
- list("\u212brlig" = "\u212brlig-year",
- Kvartalsvis = "Kvartalsvis-quarter",
- "M\u00e5nedlig" = "M\u00e5nedlig-month",
- Ukentlig = "Ukentlig-week",
- Daglig = "Daglig-DSTday"),
- selected = "M\u00e5nedlig-month"
- ),
- shiny::actionButton(
- "subscribe", "Bestill",
- icon = shiny::icon("paper-plane")
- )
- ),
- shiny::mainPanel(
- shiny::uiOutput("subscriptionContent")
- )
- )
+ samlerapport_ui("samlerapport")
),
shiny::tabPanel(
- shiny::span("Abonnement v2",
+ shiny::span("Abonnement",
title = "Bestill tilsending av rapporter p\u00e5 e-post"),
- shiny::sidebarLayout(
- shiny::sidebarPanel(
- rapbase::autoReportInput("testSubscription")
- ),
- shiny::mainPanel(
- rapbase::autoReportUI("testSubscription")
- )
- )
+ abonnement_ui("abonnement")
),
shiny::tabPanel(
"Utsending",
- shiny::sidebarLayout(
- shiny::sidebarPanel(
- width = 3,
- shiny::uiOutput("report"),
- shiny::uiOutput("freq"),
- shiny::textInput("email", "Epostmottakere:"),
- shiny::uiOutput("editEmail"),
- shiny::htmlOutput("recipients"),
- shiny::tags$hr(),
- shiny::uiOutput("makeDispatchment")
- ),
- shiny::mainPanel(
- shiny::uiOutput("dispatchmentContent")
- )
- )
+ utsending_ui("utsending")
)
-
) # navbarPage
) # tagList
}
diff --git a/R/mod_abonnement.R b/R/mod_abonnement.R
new file mode 100644
index 0000000..2105bbb
--- /dev/null
+++ b/R/mod_abonnement.R
@@ -0,0 +1,44 @@
+#' Shiny module providing GUI and server logic for the subscription v2 tab
+#'
+#' @param id Character string module namespace
+NULL
+
+abonnement_ui <- function(id) {
+
+ shiny::sidebarLayout(
+ shiny::sidebarPanel(
+ rapbase::autoReportInput(id)
+ ),
+ shiny::mainPanel(
+ rapbase::autoReportUI(id)
+ )
+ )
+}
+
+abonnement_server <- function(id) {
+
+ ## nye abonnement
+ ## Objects currently shared among subscription and dispathcment
+ orgs <- list(Sykehus1 = 1234,
+ Sykehus2 = 4321)
+ reports <- list(
+ Samlerapport1 = list(
+ synopsis = "Automatisk samlerapport1",
+ fun = "samlerapport1Fun",
+ paramNames = c("p1", "p2"),
+ paramValues = c("Alder", 1)
+ ),
+ Samlerapport2 = list(
+ synopsis = "Automatisk samlerapport2",
+ fun = "samlerapport2Fun",
+ paramNames = c("p1", "p2"),
+ paramValues = c("BMI", 1)
+ )
+ )
+
+ ## Subscription
+ rapbase::autoReportServer(
+ id = id, registryName = "rapRegTemplate",
+ type = "subscription", reports = reports, orgs = orgs, freq = "quarter"
+ )
+}
diff --git a/R/mod_plots.R b/R/mod_plots.R
new file mode 100644
index 0000000..b3ab065
--- /dev/null
+++ b/R/mod_plots.R
@@ -0,0 +1,55 @@
+#' Shiny module providing GUI and server logic for the plot tab
+#'
+#' @param id Character string module namespace
+NULL
+
+plots_ui <- function(id) {
+ ns <- shiny::NS(id)
+
+ shiny::sidebarLayout(
+ shiny::sidebarPanel(
+ width = 3,
+ shiny::selectInput(
+ inputId = ns("var"),
+ label = "Variabel:",
+ c("mpg", "disp", "hp", "drat", "wt", "qsec")
+ ),
+ shiny::sliderInput(
+ inputId = ns("bins"),
+ label = "Antall grupper:",
+ min = 1,
+ max = 10,
+ value = 5
+ )
+ ),
+ shiny::mainPanel(
+ shiny::tabsetPanel(
+ shiny::tabPanel(ns("Figur"), shiny::plotOutput(ns("distPlot"))),
+ shiny::tabPanel(ns("Tabell"), shiny::tableOutput(ns("distTable")))
+ )
+ )
+ )
+}
+
+plots_server <- function(id) {
+ shiny::moduleServer(
+ id,
+ function(input, output, session) {
+
+ # Last inn data
+ regData <- getFakeRegData()
+
+ # Figur og tabell
+ # Figur
+ output$distPlot <- shiny::renderPlot({
+ makeHist(df = regData, var = input$var, bins = input$bins)
+ })
+
+ # Tabell
+ output$distTable <- shiny::renderTable({
+ makeHist(df = regData, var = input$var, bins = input$bins,
+ makeTable = TRUE)
+ })
+ }
+ )
+}
diff --git a/R/mod_samlerapport.R b/R/mod_samlerapport.R
new file mode 100644
index 0000000..6efec03
--- /dev/null
+++ b/R/mod_samlerapport.R
@@ -0,0 +1,78 @@
+#' Shiny module providing GUI and server logic for the report tab
+#'
+#' @param id Character string module namespace
+NULL
+
+samlerapport_ui <- function(id) {
+ ns <- shiny::NS(id)
+
+ shiny::tabPanel(
+ "Fordeling av mpg",
+ shiny::sidebarLayout(
+ shiny::sidebarPanel(
+ width = 3,
+ shiny::selectInput(
+ inputId = ns("varS"),
+ label = "Variabel:",
+ c("mpg", "disp", "hp", "drat", "wt", "qsec")
+ ),
+ shiny::sliderInput(
+ inputId = ns("binsS"),
+ label = "Antall grupper:",
+ min = 1,
+ max = 10,
+ value = 5
+ ),
+ shiny::selectInput(
+ inputId = ns("formatS"),
+ label = "Velg format for nedlasting:",
+ choices = list(PDF = "pdf", HTML = "html")
+ ),
+ shiny::downloadButton(
+ outputId = ns("downloadSamlerapport"),
+ label = "Last ned!"
+ )
+ ),
+ shiny::mainPanel(
+ shiny::uiOutput(ns("samlerapport"))
+ )
+ )
+ )
+}
+
+samlerapport_server <- function(id) {
+ shiny::moduleServer(
+ id,
+ function(input, output, session) {
+
+ # Samlerapport
+ ## vis
+ output$samlerapport <- shiny::renderUI({
+ rapbase::renderRmd(
+ system.file("samlerapport.Rmd", package = "rapRegTemplate"),
+ outputType = "html_fragment",
+ params = list(type = "html",
+ var = input$varS,
+ bins = input$binsS)
+ )
+ })
+
+ ## last ned
+ output$downloadSamlerapport <- shiny::downloadHandler(
+ filename = function() {
+ basename(tempfile(pattern = "rapRegTemplateSamlerapport",
+ fileext = paste0(".", input$formatS)))
+ },
+ content = function(file) {
+ srcFile <-
+ normalizePath(system.file("samlerapport.Rmd", package = "rapRegTemplate"))
+ fn <- rapbase::renderRmd(srcFile, outputType = input$formatS,
+ params = list(type = input$formatS,
+ var = input$varS,
+ bins = input$binsS))
+ file.rename(fn, file)
+ }
+ )
+ }
+ )
+}
diff --git a/R/mod_utsending.R b/R/mod_utsending.R
new file mode 100644
index 0000000..78bfdf6
--- /dev/null
+++ b/R/mod_utsending.R
@@ -0,0 +1,191 @@
+#' Shiny module providing GUI and server logic for the dispatch tab
+#'
+#' @param id Character string module namespace
+NULL
+
+utsending_ui <- function(id) {
+ ns <- shiny::NS(id)
+
+ shiny::sidebarLayout(
+ shiny::sidebarPanel(
+ width = 3,
+ shiny::uiOutput(ns("report")),
+ shiny::uiOutput(ns("freq")),
+ shiny::textInput(ns("email"), "Epostmottakere:"),
+ shiny::uiOutput(ns("editEmail")),
+ shiny::htmlOutput(ns("recipients")),
+ shiny::tags$hr(),
+ shiny::uiOutput(ns("makeDispatchment"))
+ ),
+ shiny::mainPanel(
+ shiny::uiOutput(ns("dispatchmentContent"))
+ )
+ )
+}
+
+utsending_server <- function(id) {
+ shiny::moduleServer(
+ id,
+ function(input, output, session) {
+ ns <- session$ns
+
+ # Utsending
+ ## reaktive verdier for aa holde rede paa endringer som skjer mens
+ ## applikasjonen kjorer
+ dispatchment <- shiny::reactiveValues(
+ tab = rapbase::makeAutoReportTab(session = session, type = "dispatchment"),
+ report = "Automatisk samlerapport1",
+ freq = "M\u00E5nedlig-month",
+ email = vector()
+ )
+
+ ## observer og foreta endringer mens applikasjonen kjorer
+ shiny::observeEvent(input$addEmail, {
+ dispatchment$email <- c(dispatchment$email, input$email)
+ })
+ shiny::observeEvent(input$delEmail, {
+ dispatchment$email <-
+ dispatchment$email[!dispatchment$email == input$email]
+ })
+ shiny::observeEvent(input$dispatch, {
+ package <- "rapRegTemplate"
+ type <- "dispatchment"
+ owner <- rapbase::getUserName(session)
+ ownerName <- rapbase::getUserFullName(session)
+ interval <- strsplit(input$dispatchmentFreq, "-")[[1]][2]
+ intervalName <- strsplit(input$dispatchmentFreq, "-")[[1]][1]
+ runDayOfYear <- rapbase::makeRunDayOfYearSequence(
+ interval = interval
+ )
+
+ email <- dispatchment$email
+ organization <- rapbase::getUserReshId(session)
+
+ if (input$dispatchmentRep == "Automatisk samlerapport1") {
+ synopsis <- "Automatisk samlerapport1"
+ fun <- "samlerapport1Fun"
+ paramNames <- c("p1", "p2")
+ paramValues <- c("Alder", 1)
+
+ }
+ if (input$dispatchmentRep == "Automatisk samlerapport2") {
+ synopsis <- "Automatisk samlerapport2"
+ fun <- "samlerapport2Fun"
+ paramNames <- c("p1", "p2")
+ paramValues <- c("BMI", 2)
+ }
+ rapbase::createAutoReport(synopsis = synopsis, package = package,
+ type = type, fun = fun, paramNames = paramNames,
+ paramValues = paramValues, owner = owner,
+ ownerName = ownerName,
+ email = email, organization = organization,
+ runDayOfYear = runDayOfYear,
+ interval = interval, intervalName = intervalName)
+ dispatchment$tab <-
+ rapbase::makeAutoReportTab(session, type = "dispatchment")
+ dispatchment$email <- vector()
+ })
+
+ ## ui: velg rapport
+ output$report <- shiny::renderUI({
+ shiny::selectInput(
+ ns("dispatchmentRep"), "Rapport:",
+ c("Automatisk samlerapport1", "Automatisk samlerapport2"),
+ selected = dispatchment$report
+ )
+ })
+
+ ## ui: velg frekvens
+ output$freq <- shiny::renderUI({
+ shiny::selectInput(
+ ns("dispatchmentFreq"), "Frekvens:",
+ list("\u00C5rlig" = "\u00C5rlig-year",
+ Kvartalsvis = "Kvartalsvis-quarter",
+ Maanedlig = "M\u00E5nedlig-month",
+ Ukentlig = "Ukentlig-week",
+ Daglig = "Daglig-DSTday"),
+ selected = dispatchment$freq
+ )
+ })
+
+ ## ui: legg til gyldig- og slett epost
+ output$editEmail <- shiny::renderUI({
+ if (!grepl("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$",
+ input$email)) {
+ shiny::tags$p("Angi mottaker over")
+ } else {
+ if (input$email %in% dispatchment$email) {
+ shiny::actionButton("delEmail", "Slett epostmottaker",
+ icon = shiny::icon("trash"))
+ } else {
+ shiny::actionButton("addEmail", "Legg til epostmottaker",
+ icon = shiny::icon("pencil"))
+ }
+ }
+ })
+
+ ## ui: vis valgte mottakere
+ output$recipients <- shiny::renderText(paste(dispatchment$email,
+ sep = "
"))
+
+ ## ui: lag ny utsending
+ output$makeDispatchment <- shiny::renderUI({
+ if (length(dispatchment$email) == 0) {
+ NULL
+ } else {
+ shiny::actionButton("dispatch", "Lag utsending",
+ icon = shiny::icon("save"))
+ }
+ })
+
+ ## lag tabell over gjeldende status for utsending
+ output$activeDispatchments <- DT::renderDataTable(
+ dispatchment$tab, server = FALSE, escape = FALSE, selection = "none",
+ options = list(dom = "tp", ordering = FALSE), rownames = FALSE
+ )
+
+
+ ## ui: lag side som viser status for utsending, ogsaa naar det ikke finnes noen
+ output$dispatchmentContent <- shiny::renderUI({
+ if (length(dispatchment$tab) == 0) {
+ shiny::p("Det finnes ingen utendinger")
+ } else {
+ shiny::tagList(
+ shiny::p("Aktive utsendinger:"),
+ DT::dataTableOutput("activeDispatchments")
+ )
+ }
+ })
+
+ # Rediger eksisterende auto rapport (alle typer)
+ shiny::observeEvent(input$edit_button, {
+ repId <- strsplit(input$edit_button, "_")[[1]][2]
+ rep <- rapbase::readAutoReportData()[[repId]]
+ if (rep$type == "subscription") {
+
+ }
+ if (rep$type == "dispatchment") {
+ dispatchment$freq <- paste0(rep$intervalName, "-", rep$interval)
+ dispatchment$email <- rep$email
+ rapbase::deleteAutoReport(repId)
+ dispatchment$tab <-
+ rapbase::makeAutoReportTab(session, type = "dispatchment")
+ dispatchment$report <- rep$synopsis
+ }
+ if (rep$type == "bulletin") {
+
+ }
+ })
+
+ # Slett eksisterende auto rapport (alle typer)
+ shiny::observeEvent(input$del_button, {
+ repId <- strsplit(input$del_button, "_")[[1]][2]
+ rapbase::deleteAutoReport(repId)
+ subscription$tab <-
+ rapbase::makeAutoReportTab(session, type = "subscription")
+ dispatchment$tab <-
+ rapbase::makeAutoReportTab(session, type = "dispatchment")
+ })
+ }
+ )
+}
diff --git a/R/mod_veiledning.R b/R/mod_veiledning.R
new file mode 100644
index 0000000..c58d8d5
--- /dev/null
+++ b/R/mod_veiledning.R
@@ -0,0 +1,34 @@
+#' Shiny module providing GUI and server logic for the intro tab
+#'
+#' @param id Character string module namespace
+NULL
+
+veiledning_ui <- function(id) {
+ ns <- shiny::NS(id)
+
+ shiny::mainPanel(
+ width = 12,
+ shiny::htmlOutput(ns("veiledning"), inline = TRUE),
+ rapbase::appNavbarUserWidget(
+ user = shiny::uiOutput(ns("appUserName")),
+ organization = shiny::uiOutput(ns("appOrgName")),
+ addUserInfo = TRUE
+ )
+ )
+}
+
+veiledning_server <- function(id) {
+ shiny::moduleServer(
+ id,
+ function(input, output, session) {
+
+ # Veiledning
+ output$veiledning <- shiny::renderUI({
+ rapbase::renderRmd(
+ system.file("veiledning.Rmd", package = "rapRegTemplate"),
+ outputType = "html_fragment"
+ )
+ })
+ }
+ )
+}