Skip to content

Commit 35e2558

Browse files
committed
consolidate waiter messages
1 parent a840a82 commit 35e2558

File tree

2 files changed

+24
-73
lines changed

2 files changed

+24
-73
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "dcf-shiny",
3-
"version": "0.4.1-6",
3+
"version": "0.4.2",
44
"date": "2024-04-11",
55
"dependencies": [
66
{"package": "R6", "version": "2.5.1", "repos": "https://cran.r-project.org"},

server.R

Lines changed: 23 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
server <- function(input, output, session) {
44

55
waiting_screen<-tagList(
6-
h3("Initialisation of Application"),
6+
h3("Initializing"),
77
spin_flower()
88
)
99

@@ -46,67 +46,15 @@ server <- function(input, output, session) {
4646
)
4747
)
4848
stop("Application has stopped!")
49-
}else{
50-
waiter_hide()
51-
shiny::showModal(
52-
shiny::modalDialog(
53-
title = "Warning",
54-
shiny::tagList(
55-
br(),
56-
sprintf("Access Token: %s", PROFILE$access$access_token)
57-
)
58-
)
59-
)
6049
}
6150

6251
#COMPONENTS
63-
64-
#STORAGEHUB
65-
STORAGEHUB <- try(d4storagehub4R::StoragehubManager$new(token = PROFILE$access$access_token, token_type = "jwt"))
66-
attr(STORAGEHUB, "description") <- "Workspace (StorageHub)"
67-
if(is(STORAGEHUB, "try-error")){
68-
shiny::showModal(
69-
shiny::modalDialog(
70-
title = "Error",
71-
"Access token doesn't work on STORAGEHUB"
72-
)
73-
)
74-
}
75-
76-
icproxy_req <- try(httr::GET(sprintf("https://registry.d4science.org/icproxy/gcube/service/ServiceEndpoint/DataAnalysis/DataMiner"),
77-
httr::add_headers("Authorization" = paste("Bearer", PROFILE$access$access_token))))
78-
if(httr::status_code(icproxy_req)!=200){
79-
shiny::showModal(
80-
shiny::modalDialog(
81-
title = "Error",
82-
"Access token doesn't work on ICPROXY"
83-
)
84-
)
85-
}
86-
87-
sdi_req <- try(httr::GET(sprintf("https://sdi.d4science.org/sdi-service/gcube/service/SDI"),
88-
httr::add_headers(
89-
"Authorization" = paste("Bearer", PROFILE$access$access_token)
90-
)))
91-
if(httr::status_code(sdi_req)!=200){
92-
shiny::showModal(
93-
shiny::modalDialog(
94-
title = "Error",
95-
"Access token doesn't work on SDI-service"
96-
)
97-
)
98-
}
99-
100-
COMPONENTS <- try(loadComponents(profile = PROFILE, sdi = FALSE))
101-
if(is(COMPONENTS, "try-error")){
102-
shiny::showModal(
103-
shiny::modalDialog(
104-
title = "Error",
105-
paste0("Error while loading components with sdi = TRUE:", COMPONENTS[1])
106-
)
107-
)
108-
}
109-
52+
waiter_update(html = tagList(
53+
h3(paste0("Welcome to ",CONFIG$dcf$name)),
54+
spin_flower(),
55+
h4("Loading components..."),
56+
))
57+
COMPONENTS <- loadComponents(profile = PROFILE, sdi = FALSE)
11058

11159
#TODO current config from file, next to get from Workspace URL inherited from ICPROXY
11260
#---------------------------------------------------------------------------------------
@@ -117,12 +65,17 @@ server <- function(input, output, session) {
11765
#If you are an R developer, you need to create a .REnviron file (no file extension) in /dcf-shiny dir
11866
#The file should include the local path for your shiny config file in that way:
11967
#DCF_SHINY_CONFIG=<your config path>
68+
waiter_update(html = tagList(
69+
h3(paste0("Welcome to ",CONFIG$dcf$name)),
70+
spin_flower(),
71+
h4("Configuring..."),
72+
))
12073
local_config_file <- Sys.getenv("DCF_SHINY_CONFIG")
12174
if(nzchar(local_config_file)) config_file <- local_config_file
12275
CONFIG <- read_dcf_config(file = config_file)
12376
print("STEP CONFIG")
12477
waiter_update(html = tagList(
125-
h3(paste0("Welcome to ",CONFIG$dcf$name," Application")),
78+
h3(paste0("Welcome to ",CONFIG$dcf$name)),
12679
spin_flower()
12780
))
12881

@@ -135,31 +88,29 @@ server <- function(input, output, session) {
13588

13689
#DBI component to add
13790
#---------------------------------------------------------------------------------------
91+
waiter_update(html = tagList(
92+
h3(paste0("Welcome to ",CONFIG$dcf$name)),
93+
spin_flower(),
94+
div("Connecting to database ...")
95+
))
13896
pool <- loadDBI(config = CONFIG)
13997
COMPONENTS$POOL <- pool
14098
print("STEP POOL")
99+
#User full profile (roles) initialization
100+
#---------------------------------------------------------------------------------------
141101
waiter_update(html = tagList(
142-
h3(paste0("Welcome to ",CONFIG$dcf$name," application")),
102+
h3(paste0("Welcome to ",CONFIG$dcf$name)),
143103
spin_flower(),
144104
div("User identification ...")
145105
))
146106
print("STEP PROFILE")
147107
PROFILE <- fetchProfileRoles(pool = COMPONENTS$POOL, profile = PROFILE)
148108
if("admin" %in% PROFILE$shiny_app_roles){
149-
COMPONENTS <- try(loadComponents(profile = PROFILE, sdi = TRUE))
150-
if(is(COMPONENTS, "try-error")){
151-
shiny::showModal(
152-
shiny::modalDialog(
153-
title = "Error",
154-
paste0("Error while loading components with sdi = TRUE:", COMPONENTS[1])
155-
)
156-
)
157-
}
109+
COMPONENTS <- loadComponents(profile = PROFILE, sdi = TRUE)
158110
COMPONENTS$POOL <- pool
159111
}
160-
161112
waiter_update(html = tagList(
162-
h3(paste0("Welcome to ",CONFIG$dcf$name," application")),
113+
h3(paste0("Welcome to ",CONFIG$dcf$name)),
163114
spin_flower(),
164115
h4(paste0("Welcome ",PROFILE$name," !")),
165116
))

0 commit comments

Comments
 (0)