From b1e2988e9d02fad63c745c3c9bda78bbb6ded998 Mon Sep 17 00:00:00 2001 From: Arnfinn Hykkerud Steindal Date: Tue, 19 Dec 2023 12:58:02 +0100 Subject: [PATCH] Fjernet advarsler (#28) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fjernet særnorske bokstaver. Fikset linting. Eksplisitt bruk av shiny. --- .Rbuildignore | 21 +- .lintr | 3 +- DESCRIPTION | 2 - R/app_server.R | 604 ++++++++++++++++++++++++------------------------- R/app_ui.R | 244 ++++++++++---------- 5 files changed, 436 insertions(+), 438 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 8b46705..65c9386 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,10 +1,11 @@ -^.*\.Rproj$ -^\.Rproj\.user$ -^_pkgdown\.yml$ -^docs$ -^pkgdown$ -^LICENSE\.md$ -^Rprofile.site$ -^Dockerfile$ -^\.lintr$ -^\.github$ +^.*\.Rproj$ +^\.Rproj\.user$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ +^LICENSE\.md$ +^Rprofile.site$ +^Dockerfile$ +^\.lintr$ +^\.github$ +^renovate.json$ diff --git a/.lintr b/.lintr index 8f728ce..25ad471 100644 --- a/.lintr +++ b/.lintr @@ -1,4 +1,3 @@ linters: linters_with_defaults( object_name_linter(c("camelCase", "snake_case")), - cyclocomp_linter(complexity_limit = 25), - line_length_linter(80)) + line_length_linter(120)) diff --git a/DESCRIPTION b/DESCRIPTION index a710ba6..a267592 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,10 +16,8 @@ Depends: R (>= 3.5.0) Imports: DT, - kableExtra, magrittr, rapbase, - rmarkdown, shiny, shinyalert Remotes: diff --git a/R/app_server.R b/R/app_server.R index 25f6ef3..6b42a88 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -1,302 +1,302 @@ -#' Server logic for the rapRegTemplate app -#' -#' @param input shiny input object -#' @param output shiny output object -#' @param session shiny session object -#' -#' @return A shiny app server object -#' @export - -app_server <- function(input, output, session) { - - # Last inn data - regData <- getFakeRegData() - - # Brukerinformasjon i menylinja (navbar) - output$appUserName <- - shiny::renderText( - paste(rapbase::getUserFullName(session), - rapbase::getUserRole(session), sep = ", ")) - 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", - closeOnEsc = TRUE, closeOnClickOutside = TRUE, - 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 <- renderPlot({ - makeHist(df = regData, var = input$var, bins = input$bins) - }) - - # Tabell - output$distTable <- 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 - shiny::observeEvent(input$subscribe, { - package <- "rapRegTemplate" - type <- "subscription" - owner <- rapbase::getUserName(session) - interval <- strsplit(input$subscriptionFreq, "-")[[1]][2] - intervalName <- strsplit(input$subscriptionFreq, "-")[[1]][1] - runDayOfYear <- rapbase::makeRunDayOfYearSequence( - interval = interval) - - email <- rapbase::getUserEmail(session) - organization <- rapbase::getUserReshId(session) - - if (input$subscriptionRep == "Samlerapport1") { - synopsis <- "Automatisk samlerapport1" - fun <- "samlerapport1Fun" - paramNames <- c("p1", "p2") - paramValues <- c("Alder", 1) - - } - if (input$subscriptionRep == "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, - email = email, organization = organization, - runDayOfYear = runDayOfYear, - interval = interval, intervalName = intervalName) - subscription$tab <- - rapbase::makeAutoReportTab(session, type = "subscription") - }) - - - # 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") - }) - -} +#' Server logic for the rapRegTemplate app +#' +#' @param input shiny input object +#' @param output shiny output object +#' @param session shiny session object +#' +#' @return A shiny app server object +#' @export + +app_server <- function(input, output, session) { + + # Last inn data + regData <- getFakeRegData() + + # Brukerinformasjon i menylinja (navbar) + output$appUserName <- + shiny::renderText( + paste(rapbase::getUserFullName(session), + rapbase::getUserRole(session), sep = ", ")) + 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", + closeOnEsc = TRUE, closeOnClickOutside = TRUE, + 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 + shiny::observeEvent(input$subscribe, { + package <- "rapRegTemplate" + type <- "subscription" + owner <- rapbase::getUserName(session) + interval <- strsplit(input$subscriptionFreq, "-")[[1]][2] + intervalName <- strsplit(input$subscriptionFreq, "-")[[1]][1] + runDayOfYear <- rapbase::makeRunDayOfYearSequence( + interval = interval) + + email <- rapbase::getUserEmail(session) + organization <- rapbase::getUserReshId(session) + + if (input$subscriptionRep == "Samlerapport1") { + synopsis <- "Automatisk samlerapport1" + fun <- "samlerapport1Fun" + paramNames <- c("p1", "p2") + paramValues <- c("Alder", 1) + + } + if (input$subscriptionRep == "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, + email = email, organization = organization, + runDayOfYear = runDayOfYear, + interval = interval, intervalName = intervalName) + subscription$tab <- + rapbase::makeAutoReportTab(session, type = "subscription") + }) + + + # 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") + }) + +} diff --git a/R/app_ui.R b/R/app_ui.R index f01d661..2b5157e 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -1,122 +1,122 @@ -#' Client (ui) for the rapRegTemplate app -#' -#' @return An shiny app ui object -#' @export - -app_ui <- function() { - - shiny::addResourcePath("rap", system.file("www", package = "rapbase")) - regTitle <- "rapRegTemplate" - - ui <- shiny::tagList( - shiny::navbarPage( - title = div(a(includeHTML(system.file("www/logo.svg", - package = "rapbase"))), - regTitle), - windowTitle = regTitle, - theme = "rap/bootstrap.css", - id = "tabs", - - shiny::tabPanel("Veiledning", - shiny::mainPanel(width = 12, - shiny::htmlOutput("veiledning", inline = TRUE), - rapbase::appNavbarUserWidget( - user = uiOutput("appUserName"), - organization = uiOutput("appOrgName"), - addUserInfo = TRUE) - ) - ), - 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( - tabPanel("Figur", plotOutput("distPlot")), - tabPanel("Tabell", tableOutput("distTable")) - ) - ) - ) - ), - 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(Årlig = "Årlig-year", - Kvartalsvis = "Kvartalsvis-quarter", - Månedlig = "Månedlig-month", - Ukentlig = "Ukentlig-week", - Daglig = "Daglig-DSTday"), - selected = "Månedlig-month"), - shiny::actionButton("subscribe", "Bestill", - icon = shiny::icon("paper-plane")) - ), - shiny::mainPanel( - shiny::uiOutput("subscriptionContent") - ) - ) - ), - 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") - ) - ) - ) - - ) # navbarPage - ) # tagList -} +#' Client (ui) for the rapRegTemplate app +#' +#' @return An shiny app ui object +#' @export + +app_ui <- function() { + + shiny::addResourcePath("rap", system.file("www", package = "rapbase")) + regTitle <- "rapRegTemplate" + + shiny::tagList( + shiny::navbarPage( + title = shiny::div(shiny::a(shiny::includeHTML(system.file("www/logo.svg", + package = "rapbase"))), + regTitle), + 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) + ) + ), + 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")) + ) + ) + ) + ), + 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") + ) + ) + ), + 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") + ) + ) + ) + + ) # navbarPage + ) # tagList +}