Skip to content

Commit

Permalink
button in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
bergalli committed Feb 23, 2024
1 parent ac6e98b commit 905f360
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 42 deletions.
3 changes: 1 addition & 2 deletions app/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ server <- function(id) {
max_trisk_granularity = max_trisk_granularity, # constant
possible_trisk_combinations = possible_trisk_combinations, # computed constant
backend_trisk_run_folder = backend_trisk_run_folder, # constant
trisk_input_path=trisk_input_path, # constant

Check warning on line 170 in app/main.R

View workflow job for this annotation

GitHub Actions / Run linters and tests

file=app/main.R,line=170,col=23,[infix_spaces_linter] Put spaces around all infix operators.
available_vars = available_vars, # constant
hide_vars = hide_vars, # constant
use_ald_sector = use_ald_sector # constant
Expand All @@ -176,7 +177,6 @@ server <- function(id) {

crispy_equities$server(
"crispy_equities",
trisk_input_path = trisk_input_path, # constant
backend_trisk_run_folder = backend_trisk_run_folder, # constant
max_trisk_granularity = max_trisk_granularity, # constant
perimeter = perimeter
Expand All @@ -185,7 +185,6 @@ server <- function(id) {

crispy_loans$server(
"crispy_loans",
trisk_input_path = trisk_input_path, # constant
backend_trisk_run_folder = backend_trisk_run_folder, # constant
possible_trisk_combinations = possible_trisk_combinations, # computed constant
max_trisk_granularity = max_trisk_granularity, # constant
Expand Down
19 changes: 3 additions & 16 deletions app/view/crispy_equities.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ box::use(
)

box::use(
app / view / modules / trisk_button,
app / view / portfolio / portfolio_analysis,
app / view / modules / plots_equity_change,
app / view / modules / plots_trajectories,
Expand All @@ -26,7 +25,6 @@ ui <- function(id, max_trisk_granularity, available_vars) {
class = "ui segment", style = "min-height: 100vh;",
shiny::tags$div(
class = "ui stackable grid",
trisk_button$ui(ns("trisk_button")),
portfolio_analysis$ui(ns("portfolio_analysis"), title = "Equities portfolio"),
plots_equity_change$ui(ns("plots_equity_change")),
plots_trajectories$ui(ns("plots_trajectories"))
Expand All @@ -37,10 +35,12 @@ ui <- function(id, max_trisk_granularity, available_vars) {

####### Server

server <- function(id, perimeter, backend_trisk_run_folder, trisk_input_path, max_trisk_granularity) {
server <- function(id, perimeter, backend_trisk_run_folder, max_trisk_granularity) {
moduleServer(id, function(input, output, session) {
trisk_granularity_r <- perimeter$trisk_granularity_r
trisk_run_params_r <- perimeter$trisk_run_params_r
crispy_data_r <- perimeter$crispy_data_r
trajectories_data_r <- perimeter$trajectories_data_r

# GET RESULTS FROM CONFIG =========================

Expand All @@ -53,19 +53,6 @@ server <- function(id, perimeter, backend_trisk_run_folder, trisk_input_path, ma
editable_columns_names_equities <- c("exposure_value_usd")
colored_columns_names_equities <- c("crispy_perc_value_change", "crispy_value_loss")

results <- trisk_button$server(
"trisk_button",
crispy_data_r = crispy_data_r,
trisk_granularity_r = trisk_granularity_r,
trisk_run_params_r = trisk_run_params_r,
backend_trisk_run_folder = backend_trisk_run_folder,
trisk_input_path = trisk_input_path,
max_trisk_granularity = max_trisk_granularity
)

crispy_data_r <- results$crispy_data_r
trajectories_data_r <- results$trajectories_data_r

# MANAGE PORTFOLIO =========================

# Manages the porfolio creator module
Expand Down
20 changes: 3 additions & 17 deletions app/view/crispy_loans.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ box::use(
)

box::use(
app / view / modules / trisk_button,
app / view / portfolio / portfolio_analysis
)

Expand All @@ -22,33 +21,20 @@ ui <- function(id, max_trisk_granularity, available_vars) {
class = "pusher container", style = "min-height: 100vh;",
shiny::div(
class = "ui segment", style = "min-height: 100vh;",
trisk_button$ui(ns("trisk_button")),
portfolio_analysis$ui(ns("portfolio_analysis"), "Loans Portfolio")
)
)
}

####### Server

server <- function(id, perimeter, backend_trisk_run_folder, trisk_input_path, possible_trisk_combinations, max_trisk_granularity) {
server <- function(id, perimeter, backend_trisk_run_folder, possible_trisk_combinations, max_trisk_granularity) {
moduleServer(id, function(input, output, session) {
# SELECT PARAMETERS =========================
trisk_granularity_r <- perimeter$trisk_granularity_r
trisk_run_params_r <- perimeter$trisk_run_params_r

results <- trisk_button$server(
"trisk_button",
crispy_data_r = crispy_data_r,
trisk_granularity_r = trisk_granularity_r,
trisk_run_params_r = trisk_run_params_r,
backend_trisk_run_folder = backend_trisk_run_folder,
trisk_input_path = trisk_input_path,
max_trisk_granularity = max_trisk_granularity
)

crispy_data_r <- results$crispy_data_r
trajectories_data_r <- results$trajectories_data_r

crispy_data_r <- perimeter$crispy_data_r
trajectories_data_r <- perimeter$trajectories_data_r

# INIT PORTFOLIO ===============

Expand Down
3 changes: 1 addition & 2 deletions app/view/modules/trisk_button.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ ui <- function(id) {

server <- function(
id,
crispy_data_r,
trisk_granularity_r,
trisk_run_params_r,
trisk_granularity_r,
backend_trisk_run_folder,
trisk_input_path,
max_trisk_granularity) {
Expand Down
28 changes: 23 additions & 5 deletions app/view/sidebar_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ box::use(
app/view/params/params_scenarios,
app/view/params/params_dimensions,
app/view/params/params_trisk,
app / view / modules / trisk_button,
app/logic/renamings[rename_string_vector]
)

Expand All @@ -23,10 +24,12 @@ ui <- function(id, max_trisk_granularity, available_vars) {

list(
params_dimensions$ui(ns("params_dimensions"), max_trisk_granularity),
# Second segment in the left half // Scenario Choice
# Scenario Choice
params_scenarios$ui(ns("params_scenarios")),
# Third segment in the left half // TRISK params
params_trisk$ui(ns("params_trisk"), available_vars)
# TRISK params
params_trisk$ui(ns("params_trisk"), available_vars),
# Run TRISK button
trisk_button$ui(ns("trisk_button"))
)
}

Expand All @@ -35,7 +38,7 @@ ui <- function(id, max_trisk_granularity, available_vars) {



server <- function(id, backend_trisk_run_folder,
server <- function(id, backend_trisk_run_folder, trisk_input_path,
possible_trisk_combinations,
available_vars,
hide_vars,
Expand Down Expand Up @@ -77,9 +80,24 @@ server <- function(id, backend_trisk_run_folder,
)
})

results <- trisk_button$server(
"trisk_button",
trisk_run_params_r = trisk_run_params_r,
trisk_granularity_r = trisk_granularity_r,
backend_trisk_run_folder = backend_trisk_run_folder,
trisk_input_path = trisk_input_path,
max_trisk_granularity = max_trisk_granularity
)

crispy_data_r <- results$crispy_data_r
trajectories_data_r <- results$trajectories_data_r


perimeter <- list(
"trisk_granularity_r" = trisk_granularity_r,
"trisk_run_params_r" = trisk_run_params_r
"trisk_run_params_r" = trisk_run_params_r,
"crispy_data_r" = crispy_data_r,
"trajectories_data_r" = trajectories_data_r
)

return(
Expand Down

0 comments on commit 905f360

Please sign in to comment.