3
3
server <- function (input , output , session ) {
4
4
5
5
waiting_screen <- tagList(
6
- h3(" Initialisation of Application " ),
6
+ h3(" Initializing " ),
7
7
spin_flower()
8
8
)
9
9
@@ -46,67 +46,15 @@ server <- function(input, output, session) {
46
46
)
47
47
)
48
48
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
- )
60
49
}
61
50
62
51
# 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 )
110
58
111
59
# TODO current config from file, next to get from Workspace URL inherited from ICPROXY
112
60
# ---------------------------------------------------------------------------------------
@@ -117,12 +65,17 @@ server <- function(input, output, session) {
117
65
# If you are an R developer, you need to create a .REnviron file (no file extension) in /dcf-shiny dir
118
66
# The file should include the local path for your shiny config file in that way:
119
67
# 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
+ ))
120
73
local_config_file <- Sys.getenv(" DCF_SHINY_CONFIG" )
121
74
if (nzchar(local_config_file )) config_file <- local_config_file
122
75
CONFIG <- read_dcf_config(file = config_file )
123
76
print(" STEP CONFIG" )
124
77
waiter_update(html = tagList(
125
- h3(paste0(" Welcome to " ,CONFIG $ dcf $ name , " Application " )),
78
+ h3(paste0(" Welcome to " ,CONFIG $ dcf $ name )),
126
79
spin_flower()
127
80
))
128
81
@@ -135,31 +88,29 @@ server <- function(input, output, session) {
135
88
136
89
# DBI component to add
137
90
# ---------------------------------------------------------------------------------------
91
+ waiter_update(html = tagList(
92
+ h3(paste0(" Welcome to " ,CONFIG $ dcf $ name )),
93
+ spin_flower(),
94
+ div(" Connecting to database ..." )
95
+ ))
138
96
pool <- loadDBI(config = CONFIG )
139
97
COMPONENTS $ POOL <- pool
140
98
print(" STEP POOL" )
99
+ # User full profile (roles) initialization
100
+ # ---------------------------------------------------------------------------------------
141
101
waiter_update(html = tagList(
142
- h3(paste0(" Welcome to " ,CONFIG $ dcf $ name , " application " )),
102
+ h3(paste0(" Welcome to " ,CONFIG $ dcf $ name )),
143
103
spin_flower(),
144
104
div(" User identification ..." )
145
105
))
146
106
print(" STEP PROFILE" )
147
107
PROFILE <- fetchProfileRoles(pool = COMPONENTS $ POOL , profile = PROFILE )
148
108
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 )
158
110
COMPONENTS $ POOL <- pool
159
111
}
160
-
161
112
waiter_update(html = tagList(
162
- h3(paste0(" Welcome to " ,CONFIG $ dcf $ name , " application " )),
113
+ h3(paste0(" Welcome to " ,CONFIG $ dcf $ name )),
163
114
spin_flower(),
164
115
h4(paste0(" Welcome " ,PROFILE $ name ," !" )),
165
116
))
0 commit comments