-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
118 lines (104 loc) · 3.83 KB
/
Copy pathserver.R
File metadata and controls
118 lines (104 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#server.R
options(bitmapType="cairo")
LOCAL = TRUE
server <- function(input, output, session) {
if (LOCAL){
credentials <- read_delim("credentials.csv", delim = ";", escape_double = FALSE, trim_ws = TRUE)
} else {
drv <- DBI::dbDriver("PostgreSQL")
con <- dbConnect(drv , dbname = "dbname", host="127.0.0.1", port="5432", user="XXXX", password="XXXXXXXX")
credentials <- dbGetQuery(con, "select * from moduleappuser")
names(credentials)[names(credentials) == "username"] <- "user"
}
auth <<- FALSE
display <<- NULL
res_auth <- secure_server(
check_credentials = check_credentials(credentials)
)
# Create reactive values including all credentials
creds_reactive <- reactive({
reactiveValuesToList(res_auth)
})
observe({
req(creds_reactive()$display)
cat(file=stderr(), paste0("user :", creds_reactive()$user," ",Sys.Date(), Sys.time(), "\n"))
if (!is.null(creds_reactive()$display)){
display <- creds_reactive()$display
var_display <<- display
qid <<- creds_reactive()$portal_id
auth <<- TRUE
}
})
observeEvent(res_auth,{
if(auth == TRUE){
# Read display according to user
ui_json <- rjson::fromJSON(file = var_display)
session$userData$ui_json <- ui_json
# initialize the id for module UI et module server connexion.
id_list <<- c()
id_list_routine <<- list()
data_list <<- list()
if(ui_json$mode == "nav"){
theme <- bs_theme(
# Controls the default grayscale palette
bg = "#FFF", fg = "#21759b",
# Controls the accent (e.g., hyperlink, button, etc) colors
primary = "#f1c31c", secondary = "#21759b",
base_font = c("Grandstander", "sans-serif"),
code_sfont = c("Courier", "monospace"),
heading_font = "'Helvetica Neue', Helvetica, sans-serif",
# Can also add lower-level customization
"input-border-color" = "#f1c31c",
"navbar-bg" ="#21759b",
"nav-link-hover-color" = "#f1c31c !important",
"nav-link-active-color" = "#f1c31c !important"
)
ui_app <- makeNavUi(ui_json,session,theme)
}
if(ui_json$mode == "dash"){
ui_app <- MakeDashUi(ui_json,session)
}
output$MainUI <- renderUI({
tagList(
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "styles.css"),
tags$script(src = "custom.js"),
),
ui_app
)
})
# Call modules accordind to UI modules
for (item in id_list_routine){
# extract method
method <- item$type
id <- item$id
# call the module
switch(method,
"updatedata" = {updateDataServer(id)},
"hist" = {histogramServer(id)},
"text" = {TextServer(id)},
"qfreq2" = {qfreq2Server(id)},
"varfreq" = {varfreqServer(id)},
"varfreqGraph" = {varfreqGraphServer(id)},
"varfreqTable" = {varfreqServer(id)},
"crossvargraph" = {CrossVarGraphServer(id)},
"crossvartable" = {CrossVarTableServer(id)},
"downloadFile" = {DownloadFileServer(id)},
"showdata" = {ShowDataServer(id)},
"showquota" = {ShowQuotaServer(id)},
"apishowdata" = {ApiShowDataServer(id)},
"selectquota" = {SelectQuotaServer(id)},
"pivotdata" = {pivotDataServer(id)},
"gwalkr" = {gwalkrServer(id)},
"filters" = {filtersServer(id)},
"advent" = {adventServer(id)},
"appcreator"= {ui_json_creator_server(id)},
"runcode" = {runcodeServer()}
# Add others modules server :
# "newtype" = {newTypeServer(id)}
)
}
}
}
)
}