ver1.0
This commit is contained in:
3
R/_disable_autoload.R
Executable file
3
R/_disable_autoload.R
Executable file
@@ -0,0 +1,3 @@
|
||||
# Disabling shiny autoload
|
||||
|
||||
# See ?shiny::loadSupport for more information
|
||||
43
R/app_config.R
Executable file
43
R/app_config.R
Executable file
@@ -0,0 +1,43 @@
|
||||
#' Access files in the current app
|
||||
#'
|
||||
#' NOTE: If you manually change your package name in the DESCRIPTION,
|
||||
#' don't forget to change it here too, and in the config file.
|
||||
#' For a safer name change mechanism, use the `golem::set_golem_name()` function.
|
||||
#'
|
||||
#' @param ... character vectors, specifying subdirectory and file(s)
|
||||
#' within your package. The default, none, returns the root of the app.
|
||||
#'
|
||||
#' @noRd
|
||||
app_sys <- function(...){
|
||||
system.file(..., package = "aquacollect")
|
||||
}
|
||||
|
||||
|
||||
#' Read App Config
|
||||
#'
|
||||
#' @param value Value to retrieve from the config file.
|
||||
#' @param config GOLEM_CONFIG_ACTIVE value. If unset, R_CONFIG_ACTIVE.
|
||||
#' If unset, "default".
|
||||
#' @param use_parent Logical, scan the parent directory for config file.
|
||||
#'
|
||||
#' @noRd
|
||||
get_golem_config <- function(
|
||||
value,
|
||||
config = Sys.getenv(
|
||||
"GOLEM_CONFIG_ACTIVE",
|
||||
Sys.getenv(
|
||||
"R_CONFIG_ACTIVE",
|
||||
"default"
|
||||
)
|
||||
),
|
||||
use_parent = TRUE
|
||||
){
|
||||
config::get(
|
||||
value = value,
|
||||
config = config,
|
||||
# Modify this if your config file is somewhere else:
|
||||
file = app_sys("golem-config.yml"),
|
||||
use_parent = use_parent
|
||||
)
|
||||
}
|
||||
|
||||
163
R/app_server.R
Executable file
163
R/app_server.R
Executable file
@@ -0,0 +1,163 @@
|
||||
#' The application server-side
|
||||
#'
|
||||
#' @param input,output,session Internal parameters for {shiny}.
|
||||
#' DO NOT REMOVE.
|
||||
#' @import shiny
|
||||
#' @importFrom fst read.fst
|
||||
#' @noRd
|
||||
app_server <- function( input, output, session ) {
|
||||
# Your application server logic
|
||||
#oi<-fst::read.fst("open_items.fst")
|
||||
oi<-openitems
|
||||
|
||||
# res_auth <- shinymanager::secure_server(
|
||||
# check_credentials = shinymanager::check_credentials(
|
||||
# data.frame(
|
||||
# user = c("aldo", "betza", "tico"), # mandatory
|
||||
# password = c("lanubia", "aqualectra","imthegodfatherofaqualectra"), # mandatory
|
||||
# start = c("2019-04-15"), # optinal (all others)
|
||||
# expire = c(NA, NA, NA),
|
||||
# admin = c(TRUE, FALSE, TRUE),
|
||||
# comment = "Here we go",
|
||||
# stringsAsFactors = FALSE
|
||||
# )
|
||||
# )
|
||||
# )
|
||||
|
||||
# mod_shinyman_server(
|
||||
# "shinyauth",
|
||||
# res_auth
|
||||
# )
|
||||
|
||||
mod_barplot_server("otype",otype(oi), ttl=paste0("Total: ", round(sum(oi$amount/1000000)), " M"))
|
||||
|
||||
observeEvent(input$wadepall,{
|
||||
|
||||
if(input$wadepall=="Waste"){
|
||||
a<- oi %>% filter(o.type=="Waste")
|
||||
}
|
||||
if(input$wadepall=="Deposit"){
|
||||
a<- oi %>% filter(o.type=="Deposit")
|
||||
}
|
||||
if(input$wadepall=="Rest"){
|
||||
a<- oi %>% filter(o.type %in% c("Installments","Real"))
|
||||
}
|
||||
|
||||
mod_dccb_server("all",a)
|
||||
|
||||
mod_tab_server("tab", a)
|
||||
mod_downbutt_server("wadepalldata",dat=a,nm=input$wadepall)
|
||||
|
||||
})
|
||||
|
||||
real<-oi %>% filter(o.type %in% c("Installments","Real"))
|
||||
|
||||
observeEvent(input$delein,{
|
||||
|
||||
if(input$delein=="Open Items"){
|
||||
a<- real %>% filter(e.status=="active")
|
||||
print(nrow(a))
|
||||
print("Open Items Success")
|
||||
}
|
||||
|
||||
# if(input$delein=="Merged"){
|
||||
# a<- real %>% filter(e.status=="Merger")
|
||||
# }
|
||||
if(input$delein=="Passed"){
|
||||
a<- real %>% filter(e.status=="Passed")
|
||||
}
|
||||
|
||||
if(input$delein=="Discontinued"){
|
||||
a <- real %>% filter(e.status=="Discontinued")
|
||||
}
|
||||
if(input$delein=="Left"){
|
||||
a<- real %>% filter(e.status=="Left")
|
||||
}
|
||||
# if(input$delein=="Liquidated"){
|
||||
# a<- real %>% filter(e.status=="Liquidated")
|
||||
# }
|
||||
# if(input$delein=="Dissolved"){
|
||||
# a<- real %>% filter(e.status=="Dissolved")
|
||||
# }
|
||||
# if(input$delein=="Bankrupt"){
|
||||
# a<- real %>% filter(e.status=="Bankrupt")
|
||||
# }
|
||||
if(input$delein=="Government"){
|
||||
a<- real %>% filter(new_contract_type %in% c("Government", "Own")) |>
|
||||
filter(!e.status %in% c("Discontinued","Left","Liquidated","Dissolved","Bankrupt") )
|
||||
}
|
||||
|
||||
if(input$delein=="Own"){
|
||||
a<- real %>% filter(new_contract_type %in% c("Own")) |>
|
||||
filter(!e.status %in% c("Discontinued","Left","Liquidated","Dissolved","Bankrupt") )
|
||||
}
|
||||
|
||||
mod_dccb_server("delei",a)
|
||||
|
||||
mod_tab_server("dele", a)
|
||||
|
||||
mod_barplot_server("del", neg(a),ttl=paste0("Total: ", round(sum(a$amount/1000000)), " M"),ny=1000000)
|
||||
|
||||
mod_downbutt_server("deleindata",dat=a,nm=input$delein)
|
||||
|
||||
})
|
||||
|
||||
realwodead<-real %>% filter(e.status=="active") |> filter(new_contract_type != "Government") |> filter(new_contract_type != "Own")
|
||||
|
||||
observeEvent(c(input$status,input$thresholdsel),{
|
||||
|
||||
|
||||
a<- realwodead %>% filter(status.x==input$status)
|
||||
|
||||
|
||||
# bydun(a)
|
||||
mod_barplot_server("fivepm", fpm(a), paste0("Total: ", round(sum(a$amount/1000000)), " M"),ny=1000000)
|
||||
mod_stackedbarplot_server("fivepmtype", fpmtype(a), paste0("Total: ", round(sum(a$amount/1000000)), " M"),ny=1000000)
|
||||
mod_dccb_server("fivep",a)
|
||||
mod_tab_server("five",a)
|
||||
mod_downbutt_server("fivedata",dat=a,nm=input$status)
|
||||
mod_barplot_server("agew", ab(a), paste0("Total: ", round(sum(a$amount/1000000)), " M"),ny=1000000)
|
||||
mod_stackedbarplot_server("agewwbptype", abs(a), paste0("Total: ", round(sum(a$amount/1000000)), " M"),ny=1000000)
|
||||
|
||||
mod_tab_server("fiv",cont.aggr(a))
|
||||
mod_downbutt_server("fivdata",dat=cont.aggr(a),nm=paste0(input$status,"aggr"))
|
||||
mod_barplot_server("fivedunn",bydun(a), paste0("Total: ", round(sum(a$amount/1000000)), " M"),ny=1000000)
|
||||
mod_stackedbarplot_server("fivedunntype", byduntype(a), paste0("Total: ", round(sum(a$amount/1000000)), " M"),ny=1000000)
|
||||
|
||||
|
||||
l<-a |>
|
||||
filter(!negative) |>
|
||||
group_by(contract_account) |>
|
||||
summarise(amount=sum(amount)) |>
|
||||
filter(amount<input$thresholdsel) |>
|
||||
pull(contract_account)
|
||||
|
||||
b<- a |> filter(contract_account %in% l)
|
||||
|
||||
mod_barplot_server("thrfivepm", fpm(b), paste0("Total: ", round(sum(b$amount/1000000)), " M"),ny=1000000)
|
||||
mod_stackedbarplot_server("thrfivepmtype", fpmtype(b), paste0("Total: ", round(sum(b$amount/1000000)), " M"),ny=1000000)
|
||||
mod_dccb_server("thrfivep",b)
|
||||
mod_tab_server("thrfive",b)
|
||||
mod_downbutt_server("thrfivedata",dat=b,nm=input$status)
|
||||
mod_barplot_server("thragew", ab(b), paste0("Total: ", round(sum(b$amount/1000000)), " M"),ny=1000000)
|
||||
mod_stackedbarplot_server("thragewwbptype", abs(b), paste0("Total: ", round(sum(b$amount/1000000)), " M"),ny=1000000)
|
||||
|
||||
mod_tab_server("thrfiv",cont.aggr(b))
|
||||
mod_downbutt_server("thrfivdata",dat=cont.aggr(b),nm=paste0(input$status,"aggr"))
|
||||
mod_barplot_server("thrfivedunn",bydun(b), paste0("Total: ", round(sum(b$amount/1000000)), " M"),ny=1000000)
|
||||
mod_stackedbarplot_server("thrfivedunntype", byduntype(b), paste0("Total: ", round(sum(b$amount/1000000)), " M"),ny=1000000)
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
mod_tab_server("passedleftaggre",passedleftaggr(real))
|
||||
mod_downbutt_server("passedleftaggredata",dat=passedleftaggr(real),nm=paste0("aggrdesisedeft"))
|
||||
|
||||
mod_tab_server("orgaggre",discaggr(real))
|
||||
mod_downbutt_server("orgaggredata",dat=discaggr(real),nm=paste0("orgagredat"))
|
||||
|
||||
|
||||
}
|
||||
233
R/app_ui.R
Executable file
233
R/app_ui.R
Executable file
@@ -0,0 +1,233 @@
|
||||
#' The application User-Interface
|
||||
#'
|
||||
#' @param request Internal parameter for `{shiny}`.
|
||||
#' DO NOT REMOVE.
|
||||
#' @import shiny
|
||||
#' @import shinydashboard
|
||||
#' @importFrom bslib bs_theme
|
||||
#' @noRd
|
||||
app_ui <- function(request) {
|
||||
tagList(
|
||||
# Leave this function for adding external resources
|
||||
golem_add_external_resources(),
|
||||
# Your application UI logic
|
||||
fluidPage(
|
||||
titlePanel("Aqualectra AR"),
|
||||
theme = bs_theme(version = 4, bootswatch = "lumen"),
|
||||
# mod_shinyman_ui("shinyauth"),
|
||||
fluidRow(
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_barplot_ui("otype")
|
||||
)
|
||||
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
radioButtons("wadepall", label="Select", choices = c("Waste","Deposit","Rest"), selected = "Rest", inline = T),
|
||||
mod_dccb_ui("all")
|
||||
)
|
||||
)
|
||||
|
||||
),
|
||||
fluidRow(
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_tab_ui("tab"),
|
||||
mod_downbutt_ui("wadepalldata")
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
h2(" Waste and Deposits Removed"),
|
||||
|
||||
fluidRow(
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_barplot_ui("del")
|
||||
)
|
||||
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
radioButtons("delein", label="Select", choices = c("Open Items","Discontinued", "Left","Passed","Government","Own"), selected = "Passed", inline = T),
|
||||
mod_dccb_ui("delei")
|
||||
)
|
||||
)
|
||||
|
||||
),
|
||||
fluidRow(
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_tab_ui("dele"),
|
||||
mod_downbutt_ui("deleindata")
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
h2("Inoperative businesses, individuals who passed away or moved, government/own, removed (further)"),
|
||||
h5("Does not contain BPs marked as discontinued in Chamber of Commmerce"),
|
||||
|
||||
fluidRow(
|
||||
column(
|
||||
width = 6,
|
||||
#radioButtons("govtstatus", "Select Govt or not", choices = c("Government","Own","Rest"), selected="Rest", inline=T),
|
||||
radioButtons("status","Select BP Activity", choices = c("Only Active", "Only Inactive", "Both Active and Inactive"),
|
||||
selected = "Only Inactive", inline = T),
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_barplot_ui("fivepm"),
|
||||
mod_stackedbarplot_ui("fivepmtype")
|
||||
)
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_dccb_ui("fivep"),
|
||||
mod_barplot_ui("fivedunn"),
|
||||
mod_stackedbarplot_ui("fivedunntype")
|
||||
)
|
||||
)
|
||||
),
|
||||
fluidRow(
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_barplot_ui("agew"),
|
||||
mod_stackedbarplot_ui("agewwbptype"),
|
||||
h3("Aggregate"),
|
||||
mod_tab_ui("fiv"),
|
||||
mod_downbutt_ui("fivdata")
|
||||
)
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_tab_ui("five"),
|
||||
mod_downbutt_ui("fivedata")
|
||||
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
fluidRow(
|
||||
h4("The threshhold selecter filters based on the sum of all open items per contract account, without considering the credits"),
|
||||
h5("The items above contains contracts whose total open items (excluding the negatives) exceed the selected threshold value"),
|
||||
sliderInput("thresholdsel","Select Threshhold", min=1, max = 20000, step = 5, value = 500, width = "100%"),
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_barplot_ui("thrfivepm"),
|
||||
mod_stackedbarplot_ui("thrfivepmtype")
|
||||
)
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_dccb_ui("thrfivep"),
|
||||
mod_barplot_ui("thrfivedunn"),
|
||||
mod_stackedbarplot_ui("thrfivedunntype")
|
||||
)
|
||||
)
|
||||
),
|
||||
fluidRow(
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_barplot_ui("thragew"),
|
||||
mod_stackedbarplot_ui("thragewwbptype"),
|
||||
h3("Aggregate"),
|
||||
mod_tab_ui("thrfiv"),
|
||||
mod_downbutt_ui("thrfivdata")
|
||||
)
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
mod_tab_ui("thrfive"),
|
||||
mod_downbutt_ui("thrfivedata")
|
||||
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
fluidRow(
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
h3("Aggregated - Passed/Left"),
|
||||
mod_tab_ui("passedleftaggre"),
|
||||
mod_downbutt_ui("passedleftaggredata")
|
||||
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
fluidRow(
|
||||
box(
|
||||
width=12,
|
||||
solidHeader = T,
|
||||
h3("Aggregated - Orgs discontinued, dissolved, bankrupt or liquidated"),
|
||||
mod_tab_ui("orgaggre"),
|
||||
mod_downbutt_ui("orgaggredata")
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' Add external Resources to the Application
|
||||
#'
|
||||
#' This function is internally used to add external
|
||||
#' resources inside the Shiny application.
|
||||
#'
|
||||
#' @import shiny
|
||||
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
|
||||
#' @noRd
|
||||
golem_add_external_resources <- function(){
|
||||
|
||||
add_resource_path(
|
||||
'www', app_sys('app/www')
|
||||
)
|
||||
|
||||
tags$head(
|
||||
favicon(),
|
||||
bundle_resources(
|
||||
path = app_sys('app/www'),
|
||||
app_title = 'aquacollect'
|
||||
)
|
||||
# Add here other external resources
|
||||
# for example, you can add shinyalert::useShinyalert()
|
||||
)
|
||||
}
|
||||
|
||||
106
R/fct_helpers.R
Executable file
106
R/fct_helpers.R
Executable file
@@ -0,0 +1,106 @@
|
||||
#' helpers
|
||||
#'
|
||||
#' @description A fct function
|
||||
#'
|
||||
#' @return The return value, if any, from executing the function.
|
||||
#' @import dplyr
|
||||
#' @noRd
|
||||
#' @importFrom tidyr pivot_wider
|
||||
|
||||
otype<-function(oi){
|
||||
oi %>%
|
||||
group_by(o.type) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=o.type)
|
||||
}
|
||||
|
||||
neg<-function(oi){
|
||||
oi %>%
|
||||
group_by(negative) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=negative)
|
||||
}
|
||||
|
||||
fpm<-function(oi){
|
||||
oi %>%
|
||||
group_by(spread) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=spread)
|
||||
}
|
||||
|
||||
ab<-function(oi){
|
||||
oi %>%
|
||||
group_by(AGE_BUCKET) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=AGE_BUCKET)
|
||||
}
|
||||
|
||||
|
||||
tfrnma<-function(dat){
|
||||
if("TRUE" %in% colnames(dat)){
|
||||
dat<-dat |> rename(credits=`TRUE`)
|
||||
}
|
||||
if("FALSE" %in% colnames(dat)){
|
||||
dat<-dat |> rename(`Open Items`=`FALSE`)
|
||||
}
|
||||
dat
|
||||
}
|
||||
|
||||
cont.aggr<-function(dat){
|
||||
dat %>%
|
||||
group_by(business_partner,contract_account, negative) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
pivot_wider(names_from=negative, values_from=amount) |>
|
||||
tfrnma()
|
||||
}
|
||||
|
||||
bydun<-function(dat){
|
||||
dat %>%
|
||||
group_by(dunn_status) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=dunn_status)
|
||||
}
|
||||
|
||||
abs<-function(oi){
|
||||
oi %>%
|
||||
group_by(AGE_BUCKET, bp_category) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=AGE_BUCKET)
|
||||
}
|
||||
|
||||
|
||||
fpmtype<-function(oi){
|
||||
oi %>%
|
||||
group_by(spread, bp_category) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=spread)
|
||||
}
|
||||
|
||||
|
||||
byduntype<-function(dat){
|
||||
dat %>%
|
||||
group_by(dunn_status, bp_category) %>%
|
||||
summarize(amount=sum(amount)) %>%
|
||||
rename(name=dunn_status)
|
||||
}
|
||||
|
||||
|
||||
passedleftaggr<- function(dat){
|
||||
dat |>
|
||||
filter(e.status %in% c("Passed","Left")) |>
|
||||
mutate(age=ifelse(AGE_BUCKET=="5+ years", "More than 5","Less than 5")) |>
|
||||
mutate(rel.status=ifelse(rel.status=="long past", "More than 60 days","Less than 60 days")) |>
|
||||
group_by(contract_account,rel.status,negative, age, dunn_status) |>
|
||||
summarise(amount=sum(amount))
|
||||
}
|
||||
|
||||
discaggr<- function(dat){
|
||||
dat |>
|
||||
filter(e.status %in% c("Discontinued","Dissolved","Bankrupt","Liquidated")) |>
|
||||
mutate(age=ifelse(AGE_BUCKET=="5+ years", "More than 5","Less than 5")) |>
|
||||
mutate(rel.status=ifelse(rel.status=="long past", "More than 60 days","Less than 60 days")) |>
|
||||
group_by(contract_account,rel.status,negative, age, dunn_status) |>
|
||||
summarise(amount=sum(amount))
|
||||
}
|
||||
|
||||
|
||||
55
R/mod_barplot.R
Executable file
55
R/mod_barplot.R
Executable file
@@ -0,0 +1,55 @@
|
||||
#' barplot UI Function
|
||||
#'
|
||||
#' @description A shiny Module.
|
||||
#'
|
||||
#' @param id,input,output,session Internal parameters for {shiny}.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @importFrom shiny NS tagList
|
||||
#' @importFrom plotly plotlyOutput renderPlotly ggplotly
|
||||
#' @importFrom ggplot2 ggplot aes geom_col geom_text labs theme_classic scale_y_continuous theme position_stack
|
||||
#' @importFrom scales unit_format
|
||||
mod_barplot_ui <- function(id){
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
shinycssloaders::withSpinner(
|
||||
type = 5,
|
||||
hide.ui=F,
|
||||
plotly::plotlyOutput(ns("barplot"))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' barplot Server Functions
|
||||
#'
|
||||
#' @noRd
|
||||
mod_barplot_server <- function(id, dat, ttl, cptn="Source: Download from SAP", ny=3000000){
|
||||
moduleServer( id, function(input, output, session){
|
||||
ns <- session$ns
|
||||
output$barplot<- plotly::renderPlotly({
|
||||
validate(
|
||||
need(nrow(dat)>0, 'Wait. Wrong button. There is nothing here. CLick something else.')
|
||||
)
|
||||
|
||||
pl<-ggplot(dat, aes(x=name, y=amount, label=paste0(round(amount/1000000,1)," M")))+
|
||||
geom_col(fill="blue")+
|
||||
geom_text(col="black", nudge_y = ny)+
|
||||
scale_y_continuous(labels = unit_format(unit = "M", scale = 1e-6))+
|
||||
labs(title=ttl,
|
||||
subtitle = "",
|
||||
y="amount",
|
||||
x="",
|
||||
caption=cptn)+
|
||||
theme_classic()
|
||||
ggplotly(pl)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
## To be copied in the UI
|
||||
# mod_barplot_ui("barplot_ui_1")
|
||||
|
||||
## To be copied in the server
|
||||
# mod_barplot_server("barplot_ui_1")
|
||||
75
R/mod_dccb.R
Executable file
75
R/mod_dccb.R
Executable file
@@ -0,0 +1,75 @@
|
||||
#' dccb UI Function
|
||||
#'
|
||||
#' @description A shiny Module.
|
||||
#'
|
||||
#' @param id,input,output,session Internal parameters for {shiny}.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @importFrom shiny NS tagList
|
||||
mod_dccb_ui <- function(id){
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
fluidRow(
|
||||
column(
|
||||
width = 6,
|
||||
fluidRow(
|
||||
# "Credits",
|
||||
mod_inbox_ui(ns("credit"))
|
||||
)
|
||||
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
fluidRow(
|
||||
# "Open",
|
||||
mod_inbox_ui(ns("debit"))
|
||||
)
|
||||
|
||||
)
|
||||
),
|
||||
fluidRow(
|
||||
column(
|
||||
width = 6,
|
||||
fluidRow(
|
||||
# "Contracts",
|
||||
mod_inbox_ui(ns("contracts"))
|
||||
)
|
||||
|
||||
),
|
||||
column(
|
||||
width = 6,
|
||||
fluidRow(
|
||||
# "Business Partners",
|
||||
mod_inbox_ui(ns("bps"))
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' dccb Server Functions
|
||||
#'
|
||||
#' @noRd
|
||||
mod_dccb_server <- function(id, dat){
|
||||
moduleServer( id, function(input, output, session){
|
||||
ns <- session$ns
|
||||
credit<- sum(dat[dat$negative,]$amount)
|
||||
debit<- sum(dat[!dat$negative,]$amount)
|
||||
contracts<-length(unique(dat$contract_account))
|
||||
bps<-length(unique(dat$business_partner))
|
||||
|
||||
mod_inbox_server("credit", ttl="Credit",val=paste0(round(credit/1000000), "M"))
|
||||
mod_inbox_server("debit",ttl="Open",val=paste0(round(debit/1000000), "M"))
|
||||
mod_inbox_server("contracts",ttl="Contracts",val=contracts)
|
||||
mod_inbox_server("bps",ttl="BPs",val=bps)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
## To be copied in the UI
|
||||
# mod_dccb_ui("dccb_ui_1")
|
||||
|
||||
## To be copied in the server
|
||||
# mod_dccb_server("dccb_ui_1")
|
||||
44
R/mod_downbutt.R
Executable file
44
R/mod_downbutt.R
Executable file
@@ -0,0 +1,44 @@
|
||||
#' downbutt UI Function
|
||||
#'
|
||||
#' @description A shiny Module.
|
||||
#'
|
||||
#' @param id,input,output,session Internal parameters for {shiny}.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @importFrom shiny NS tagList
|
||||
mod_downbutt_ui <- function(id){
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
shinycssloaders::withSpinner(
|
||||
type = 5,
|
||||
hide.ui=F,
|
||||
downloadButton(ns("dbutton"),"Download Full File!")
|
||||
)
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
#' downbutt Server Functions
|
||||
#'
|
||||
#' @noRd
|
||||
mod_downbutt_server <- function(id,dat,nm){
|
||||
moduleServer( id, function(input, output, session){
|
||||
ns <- session$ns
|
||||
|
||||
output$dbutton<-downloadHandler(
|
||||
filename = function() {
|
||||
paste(nm, Sys.Date(), ".csv", sep="")
|
||||
},
|
||||
content = function(file) {
|
||||
write.csv(dat, file)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
## To be copied in the UI
|
||||
# mod_downbutt_ui("downbutt_ui_1")
|
||||
|
||||
## To be copied in the server
|
||||
# mod_downbutt_server("downbutt_ui_1")
|
||||
43
R/mod_inbox.R
Executable file
43
R/mod_inbox.R
Executable file
@@ -0,0 +1,43 @@
|
||||
#' inbox UI Function
|
||||
#'
|
||||
#' @description A shiny Module.
|
||||
#'
|
||||
#' @param id,input,output,session Internal parameters for {shiny}.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @importFrom shiny NS tagList
|
||||
mod_inbox_ui <- function(id){
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
shinycssloaders::withSpinner(
|
||||
type = 5,
|
||||
hide.ui=F,
|
||||
infoBoxOutput(ns("infbox"),width = 12)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' inbox Server Functions
|
||||
#'
|
||||
#' @noRd
|
||||
mod_inbox_server <- function(id,ttl,val="0 %"){
|
||||
moduleServer( id, function(input, output, session){
|
||||
ns <- session$ns
|
||||
output$infbox<-renderInfoBox(
|
||||
infoBox(
|
||||
ttl,
|
||||
val,
|
||||
icon = shiny::icon("chart-bar"),
|
||||
width = 12
|
||||
)
|
||||
)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
## To be copied in the UI
|
||||
# mod_inbox_ui("inbox_ui_1")
|
||||
|
||||
## To be copied in the server
|
||||
# mod_inbox_server("inbox_ui_1")
|
||||
35
R/mod_shinyman.R
Executable file
35
R/mod_shinyman.R
Executable file
@@ -0,0 +1,35 @@
|
||||
#' shinyman UI Function
|
||||
#'
|
||||
#' @description A shiny Module.
|
||||
#'
|
||||
#' @param id,input,output,session Internal parameters for {shiny}.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @importFrom shiny NS tagList
|
||||
mod_shinyman_ui <- function(id){
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
h1("golemshinymanager"),
|
||||
verbatimTextOutput(ns("auth_output"))
|
||||
)
|
||||
}
|
||||
|
||||
#' shinyman Server Functions
|
||||
#'
|
||||
#' @noRd
|
||||
mod_shinyman_server <- function(id,res_auth){
|
||||
moduleServer( id, function(input, output, session){
|
||||
ns <- session$ns
|
||||
output$auth_output <- renderPrint({
|
||||
reactiveValuesToList(res_auth)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
## To be copied in the UI
|
||||
# mod_shinyman_ui("shinyman_ui_1")
|
||||
|
||||
## To be copied in the server
|
||||
# mod_shinyman_server("shinyman_ui_1")
|
||||
51
R/mod_stackedbarplot.R
Executable file
51
R/mod_stackedbarplot.R
Executable file
@@ -0,0 +1,51 @@
|
||||
#' stackedbarplot UI Function
|
||||
#'
|
||||
#' @description A shiny Module.
|
||||
#'
|
||||
#' @param id,input,output,session Internal parameters for {shiny}.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @importFrom shiny NS tagList
|
||||
mod_stackedbarplot_ui <- function(id){
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
shinycssloaders::withSpinner(
|
||||
type = 5,
|
||||
hide.ui=F,
|
||||
plotly::plotlyOutput(ns("stabarplot"))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' stackedbarplot Server Functions
|
||||
#'
|
||||
#' @noRd
|
||||
mod_stackedbarplot_server <- function(id, dat, ttl, cptn="Source: Download from SAP", ny=2000000){
|
||||
moduleServer( id, function(input, output, session){
|
||||
ns <- session$ns
|
||||
output$stabarplot<- plotly::renderPlotly({
|
||||
pl<-ggplot(dat, aes(x=name, y=amount, fill=bp_category, label=paste0(round(amount/1000000,1)," M")))+
|
||||
geom_col(position="stack")+
|
||||
geom_text(col="black", size=3, angle = 45, position = position_stack(vjust = 0.5),check_overlap = TRUE)+
|
||||
scale_y_continuous(labels = unit_format(unit = "M", scale = 1e-6))+
|
||||
labs(title=ttl,
|
||||
subtitle = "",
|
||||
y="amount",
|
||||
x="",
|
||||
caption=cptn)+
|
||||
theme_classic()+
|
||||
theme(
|
||||
legend.position="bottom"
|
||||
)
|
||||
ggplotly(pl)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
## To be copied in the UI
|
||||
# mod_stackedbarplot_ui("stackedbarplot_ui_1")
|
||||
|
||||
## To be copied in the server
|
||||
# mod_stackedbarplot_server("stackedbarplot_ui_1")
|
||||
48
R/mod_tab.R
Executable file
48
R/mod_tab.R
Executable file
@@ -0,0 +1,48 @@
|
||||
#' tab UI Function
|
||||
#'
|
||||
#' @description A shiny Module.
|
||||
#'
|
||||
#' @param id,input,output,session Internal parameters for {shiny}.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @importFrom shiny NS tagList
|
||||
#' @import DT
|
||||
mod_tab_ui <- function(id){
|
||||
ns <- NS(id)
|
||||
tagList(
|
||||
|
||||
DT::dataTableOutput(ns("tab"))
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
#' tab Server Functions
|
||||
#'
|
||||
#' @noRd
|
||||
mod_tab_server <- function(id,dat){
|
||||
moduleServer( id, function(input, output, session){
|
||||
ns <- session$ns
|
||||
output$tab<- DT::renderDataTable({
|
||||
validate(
|
||||
need(nrow(dat)>0, 'Wait. Wrong button. There is nothing here. CLick something else.')
|
||||
)
|
||||
DT::datatable(dat,
|
||||
filter="top",
|
||||
options = list(scrollX=TRUE,
|
||||
scrollY=TRUE,
|
||||
paging = TRUE, searching = TRUE,
|
||||
fixedColumns = FALSE, autoWidth = TRUE
|
||||
))
|
||||
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
## To be copied in the UI
|
||||
# mod_tab_ui("tab_ui_1")
|
||||
|
||||
## To be copied in the server
|
||||
# mod_tab_server("tab_ui_1")
|
||||
BIN
R/open_items.fst
Executable file
BIN
R/open_items.fst
Executable file
Binary file not shown.
28
R/run_app.R
Executable file
28
R/run_app.R
Executable file
@@ -0,0 +1,28 @@
|
||||
#' Run the Shiny Application
|
||||
#'
|
||||
#' @param ... arguments to pass to golem_opts.
|
||||
#' See `?golem::get_golem_options` for more details.
|
||||
#' @inheritParams shiny::shinyApp
|
||||
#'
|
||||
#' @export
|
||||
#' @importFrom shiny shinyApp
|
||||
#' @importFrom golem with_golem_options
|
||||
run_app <- function(
|
||||
onStart = NULL,
|
||||
options = list(),
|
||||
enableBookmarking = NULL,
|
||||
uiPattern = "/",
|
||||
...
|
||||
) {
|
||||
with_golem_options(
|
||||
app = shinyApp(
|
||||
ui = app_ui,
|
||||
server = app_server,
|
||||
onStart = onStart,
|
||||
options = options,
|
||||
enableBookmarking = enableBookmarking,
|
||||
uiPattern = uiPattern
|
||||
),
|
||||
golem_opts = list(...)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user