diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 47e9945..d98af8c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,4 +29,4 @@ jobs: run: lintr::lint_package() shell: Rscript {0} env: - LINTR_ERROR_ON_LINT: false + LINTR_ERROR_ON_LINT: true diff --git a/R/MakeHist.R b/R/MakeHist.R index 870b7ac..014d5c6 100644 --- a/R/MakeHist.R +++ b/R/MakeHist.R @@ -18,9 +18,15 @@ makeHist <- function(df, var, bins, makeTable = FALSE) { x <- df[[var]] bins <- seq(min(x), max(x), length.out = bins + 1) - t <- graphics::hist(x, breaks = bins, col = "#154ba2", border = "white", - main = paste("Fordeling av", var), xlab = var, - ylab = "Antall") + t <- graphics::hist( + x, + breaks = bins, + col = "#154ba2", + border = "white", + main = paste("Fordeling av", var), + xlab = var, + ylab = "Antall" + ) if (makeTable) { data.frame(GruppeMin = t$breaks[seq_len(length(t$mids))], GruppeMax = t$breaks[2:(length(t$mids) + 1)], Antall = t$counts) diff --git a/R/app_server.R b/R/app_server.R index 3dfdd67..539d955 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -13,18 +13,18 @@ app_server <- function(input, output, session) { regData <- getFakeRegData() # Brukerinformasjon i menylinja (navbar) - output$appUserName <- - shiny::renderText( - paste(rapbase::getUserFullName(session), - rapbase::getUserRole(session), sep = ", ")) + 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()) + type = "", imageUrl = "rap/logo.svg", + closeOnEsc = TRUE, closeOnClickOutside = TRUE, + html = TRUE, confirmButtonText = rapbase::noOptOutOk()) }) # Veiledning @@ -38,9 +38,9 @@ app_server <- function(input, output, session) { # Figur og tabell # Figur - output$distPlot <- shiny::renderPlot({ + output$distPlot <- shiny::renderPlot({ makeHist(df = regData, var = input$var, bins = input$bins) - }) + }) # Tabell output$distTable <- shiny::renderTable({ @@ -83,7 +83,8 @@ app_server <- function(input, output, session) { ## rekative verdier for aa holde rede paa endringer som skjer mens ## applikasjonen kjorer subscription <- shiny::reactiveValues( - tab = rapbase::makeAutoReportTab(session, type = "subscription")) + tab = rapbase::makeAutoReportTab(session, type = "subscription") + ) ## lag tabell over gjeldende status for abonnement output$activeSubscriptions <- DT::renderDataTable( @@ -158,7 +159,8 @@ app_server <- function(input, output, session) { interval <- strsplit(input$dispatchmentFreq, "-")[[1]][2] intervalName <- strsplit(input$dispatchmentFreq, "-")[[1]][1] runDayOfYear <- rapbase::makeRunDayOfYearSequence( - interval = interval) + interval = interval + ) email <- dispatchment$email organization <- rapbase::getUserReshId(session) @@ -193,7 +195,8 @@ app_server <- function(input, output, session) { shiny::selectInput( "dispatchmentRep", "Rapport:", c("Automatisk samlerapport1", "Automatisk samlerapport2"), - selected = dispatchment$report) + selected = dispatchment$report + ) }) ## ui: velg frekvens @@ -201,11 +204,12 @@ app_server <- function(input, output, session) { shiny::selectInput( "dispatchmentFreq", "Frekvens:", list("\u00C5rlig" = "\u00C5rlig-year", - Kvartalsvis = "Kvartalsvis-quarter", - Maanedlig = "M\u00E5nedlig-month", - Ukentlig = "Ukentlig-week", - Daglig = "Daglig-DSTday"), - selected = dispatchment$freq) + Kvartalsvis = "Kvartalsvis-quarter", + Maanedlig = "M\u00E5nedlig-month", + Ukentlig = "Ukentlig-week", + Daglig = "Daglig-DSTday"), + selected = dispatchment$freq + ) }) ## ui: legg til gyldig- og slett epost @@ -240,8 +244,8 @@ app_server <- function(input, output, session) { ## 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 + dispatchment$tab, server = FALSE, escape = FALSE, selection = "none", + options = list(dom = "tp", ordering = FALSE), rownames = FALSE ) diff --git a/R/app_ui.R b/R/app_ui.R index 8323084..8826354 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -10,98 +10,121 @@ app_ui <- function() { shiny::tagList( shiny::navbarPage( - title = shiny::div(shiny::a(shiny::includeHTML(system.file("www/logo.svg", - package = "rapbase"))), - regTitle), + 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( + "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( + "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( + "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( + "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( shiny::span("Abonnement v2", - title="Bestill tilsending av rapporter p\u00e5 e-post"), + title = "Bestill tilsending av rapporter p\u00e5 e-post"), shiny::sidebarLayout( shiny::sidebarPanel( rapbase::autoReportInput("testSubscription") @@ -111,22 +134,23 @@ app_ui <- function() { ) ) ), - 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") - ) - ) + 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