-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.R
78 lines (63 loc) · 1.53 KB
/
global.R
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
library(tidyverse)
library(shiny)
library(shinythemes)
library(DBI)
library(odbc)
library(dbplyr)
library(yaml)
library(config)
library(rlang)
library(DT)
library(waiter)
library(future)
library(promises)
options(shiny.sanitize.errors = FALSE)
options(future.rng.onMisuse = 'ignore')
plan(multisession, workers = 2)
enableBookmarking(store = "url")
# establish to specified connection
est_mysql_conn <- function(db) {
DBI::dbConnect(
drv = RMySQL::MySQL(),
host = db[["host"]],
port = db[["port"]],
user = db[["username"]],
password = db[["password"]],
dbname = db[["dbname"]]
)
}
est_hive_conn <- function(db) {
DBI::dbConnect(
odbc::odbc(),
Driver = db[['driver']],
Host = db[["host"]],
Port = db[["port"]],
UID = db[["username"]],
PWD = db[["passwors"]]
)
}
# customize loading screen
waiting_screen <-
tagList(
spin_dual_circle(),
h4("请稍等片刻,拉比克正在为大人您服务 ٩(◕‿◕。)۶ ")
)
validate_token <- function(input, ref) {
if (input != ref) {
stop("Validation failed. Check token.")
}
}
get_form_name <- function(form) {
name <- config::get(config = form)[['name']]
if (is.null(name)) {
return(form)
}
return(name)
}
get_form_group <- function(form) {
grp <- config::get(config = form)[['group']]
if (is.null(grp)) {
return("blank")
}
return(grp)
}