Skip to content

Commit

Permalink
wip creds
Browse files Browse the repository at this point in the history
  • Loading branch information
bergalli committed Feb 27, 2024
1 parent 0306b25 commit c958222
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 44 deletions.
94 changes: 50 additions & 44 deletions app/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ui <- function(id) {
}
"))
),

Check warning on line 72 in app/main.R

View workflow job for this annotation

GitHub Actions / Run linters and tests

file=app/main.R,line=72,col=8,[indentation_linter] Indentation should be 10 spaces but is 8 spaces.

Check warning on line 72 in app/main.R

View workflow job for this annotation

GitHub Actions / Run linters and tests

file=app/main.R,line=72,col=8,[indentation_linter] Indentation should be 10 spaces but is 8 spaces.
div(id = "loading-overlay", "Initializing...")
# div(id = "loading-overlay", "Initializing...")

Check warning on line 73 in app/main.R

View workflow job for this annotation

GitHub Actions / Run linters and tests

file=app/main.R,line=73,col=11,[commented_code_linter] Commented code should be removed.

Check warning on line 73 in app/main.R

View workflow job for this annotation

GitHub Actions / Run linters and tests

file=app/main.R,line=73,col=11,[commented_code_linter] Commented code should be removed.
),
dashboardPage(
title = "Homepage",
Expand Down Expand Up @@ -191,60 +191,66 @@ ui <- function(id) {
#' @export
server <- function(id) {
moduleServer(id, function(input, output, session) {
authorized_access_r <- shiny::reactiveVal(FALSE)
if (Sys.getenv("CRISPY_APP_ENV") == "prod"){
conn <- DBI::dbConnect(RPostgres::Postgres(),
dbname = Sys.getenv("ST_POSTGRES_DB"),
host = Sys.getenv("ST_POSTGRES_HOST"),
port = Sys.getenv("ST_POSTGRES_PORT"),
user = Sys.getenv("ST_POSTGRES_USERNAME"),
password = Sys.getenv("ST_POSTGRES_PASSWORD")
)

conn <- DBI::dbConnect(RPostgres::Postgres(),
dbname = Sys.getenv("ST_POSTGRES_DB"),
host = Sys.getenv("ST_POSTGRES_HOST"),
port = Sys.getenv("ST_POSTGRES_PORT"),
user = Sys.getenv("ST_POSTGRES_USERNAME"),
password = Sys.getenv("ST_POSTGRES_PASSWORD")
)
observeEvent(input$loginBtn, {
authorized_access <- check_credentials(input=input, conn=conn)
if (authorized_access) {
shinyjs::hide("login")
shinyjs::show("app_content")
} else {
shinyjs::alert("Incorrect username or password!")
authorized_access <- check_credentials(input=input, conn=conn)
if (authorized_access) {
shinyjs::hide("login")
} else {
shinyjs::alert("Incorrect username or password!")
}
authorized_access_r(authorized_access)
}
}
)} else{
shinyjs::hide("login")
observe({authorized_access_r(TRUE)})

}

possible_trisk_combinations <- r2dii.climate.stress.test::get_scenario_geography_x_ald_sector(trisk_input_path)

# the TRISK runs are generated In the sidebar module
perimeter <- sidebar_parameters$server(
"sidebar_parameters",
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
available_vars = available_vars, # constant
hide_vars = hide_vars, # constant
use_ald_sector = use_ald_sector # constant
)
shiny::observeEvent(c(authorized_access_r()), ignoreInit=TRUE, {
possible_trisk_combinations <- r2dii.climate.stress.test::get_scenario_geography_x_ald_sector(trisk_input_path)

# the TRISK runs are generated In the sidebar module
perimeter <- sidebar_parameters$server(
"sidebar_parameters",
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
available_vars = available_vars, # constant
hide_vars = hide_vars, # constant
use_ald_sector = use_ald_sector # constant
)

homepage$server("homepage")
homepage$server("homepage")

crispy_equities$server(
"crispy_equities",
backend_trisk_run_folder = backend_trisk_run_folder, # constant
max_trisk_granularity = max_trisk_granularity, # constant
perimeter = perimeter
)
crispy_equities$server(
"crispy_equities",
backend_trisk_run_folder = backend_trisk_run_folder, # constant
max_trisk_granularity = max_trisk_granularity, # constant
perimeter = perimeter
)

crispy_loans$server(
"crispy_loans",
backend_trisk_run_folder = backend_trisk_run_folder, # constant
possible_trisk_combinations = possible_trisk_combinations, # computed constant
max_trisk_granularity = max_trisk_granularity, # constant
perimeter = perimeter
)
})
# shinyjs::runjs('$("#loading-overlay").hide();')

crispy_loans$server(
"crispy_loans",
backend_trisk_run_folder = backend_trisk_run_folder, # constant
possible_trisk_combinations = possible_trisk_combinations, # computed constant
max_trisk_granularity = max_trisk_granularity, # constant
perimeter = perimeter
)
})
shinyjs::runjs('$("#loading-overlay").hide();')
}


Expand Down
24 changes: 24 additions & 0 deletions application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
proxy:
title: ShinyProxy with Rhino
logo-url: https://www.example.com/logo.png
landing-page: /
heartbeat-rate: 10000
heartbeat-timeout: 60000
port: 8080
authentication: simple
users:
- name: user
password: password
docker:
internal-networking: true
specs:
- id: rhino-app
display-name: Rhino Shiny App
description: App developed with Rhino framework
container-cmd: ["R", "-e", "rhino::run_app('/srv/shiny-server/app')"]
container-image: rhino-shiny-app
access-groups: scientists

logging:
file:
shinyproxy.log

0 comments on commit c958222

Please sign in to comment.