Compare commits

...

9 Commits

6 changed files with 38 additions and 35 deletions

View File

@@ -1,15 +1,3 @@
.on_load = function(ns) {
check_and_init_scheme()
# set global settings:
set_global_options(
shiny.host = "0.0.0.0",
shiny.port = 1338,
APP.DEBUG = FALSE
)
}
#' @export
#' @description костыли для упрощения работы себе
@@ -17,23 +5,6 @@ set_global_options = function(
SYMBOL_DELIM = "; ",
...
) {
config_params_to_check <- c(
"form_app_version",
"form_id",
"form_name",
"form_app_configure_path",
"form_auth_enabled",
"form_schemes"
)
expected_params_in_config <- config_params_to_check %in% names(config::get())
if (!all(expected_params_in_config)) {
cli::cli_abort(c(
"Необходимо добавить в файл конфига {.file config.yml} следующие параметры:",
paste0(config_params_to_check[!expected_params_in_config], ":")
))
}
options(
SYMBOL_DELIM = SYMBOL_DELIM,
@@ -55,6 +26,27 @@ ENABLED_SCHEMES <- stats::setNames(names(ENABLED_SCHEMES), ENABLED_SCHEMES)
#' @export
check_and_init_scheme = function() {
cli::cli_inform(c("*" = "проверка файла конфигурации..."))
config_params_to_check <- c(
"form_app_version",
"form_id",
"form_name",
"form_app_configure_path",
"form_auth_enabled",
"form_schemes"
)
expected_params_in_config <- config_params_to_check %in% names(config::get())
if (!all(expected_params_in_config)) {
cli::cli_abort(c(
"Необходимо добавить в файл конфига {.file config.yml} следующие параметры:",
paste0(config_params_to_check[!expected_params_in_config], ":")
))
}
# -------------------
cli::cli_inform(c("*" = "проверка схемы..."))
options(box.path = here::here())
@@ -81,16 +73,17 @@ check_and_init_scheme = function() {
if (!all(file.exists(scheme_file))) {
cli::cli_abort(c("Отсутствуют файлы схем для следующих наименований:", paste("-", names(scheme_file)[!file.exists(scheme_file)])))
}
db_files <- paste0(config::get("form_app_configure_path"), "/db/", scheme_names, ".sqlite")
if (!dir.exists("temp")) dir.create("temp")
hash_file <- "temp/schema_hash.rds"
#
exist_hash <- tools::md5sum(c(scheme_file, files_to_watch))
# если первый запуск (нет файла с кешем) инициализация схемы
if (!file.exists(hash_file) | !file.exists("temp/scheme.rds") | !all(file.exists(db_files))) {
if (!file.exists(hash_file) | !file.exists("temp/scheme.rds")) {
init_scheme(scheme_file)

View File

@@ -14,7 +14,7 @@ credentials <- data.frame(
# Init the database
shinymanager::create_db(
credentials_data = credentials,
sqlite_path = "config/auth.sqlite", # will be created
sqlite_path = "temp/auth.sqlite", # will be created
passphrase = Sys.getenv("AUTH_DB_KEY")
# passphrase = "passphrase_wihtout_keyring"
)

Binary file not shown.

14
app.R
View File

@@ -19,9 +19,19 @@ box::use(
# глобальные переменные и проверка/инициация схемы:
box::use(
R/modules/global_options[set_global_options, check_and_init_scheme],
R/modules/global_options[AUTH_ENABLED, ENABLED_SCHEMES],
)
# set global settings:
set_global_options(
shiny.host = "0.0.0.0",
shiny.port = 1338,
APP.DEBUG = FALSE
)
check_and_init_scheme()
SCHMS <- readRDS("temp/scheme.rds")
# CHECK FOR PANDOC ----------
@@ -102,7 +112,7 @@ server <- function(input, output, session) {
# check_credentials directly on sqlite db
shinymanager::secure_server(
check_credentials = shinymanager::check_credentials(
db = "config/auth.sqlite",
db = "temp/auth.sqlite",
passphrase = Sys.getenv("AUTH_DB_KEY")
),
keep_token = TRUE
@@ -1139,7 +1149,7 @@ server <- function(input, output, session) {
# write vector to temp .Rmd file
writeLines(empty_vec, temp_report, sep = "\n")
# copy template .docx file
file.copy("references/reference.docx", temp_template, overwrite = TRUE)
file.copy("resources/references/reference.docx", temp_template, overwrite = TRUE)
# render file via pandoc
rmarkdown::render(

View File

@@ -1,6 +1,6 @@
{
"R": {
"Version": "4.3.2",
"Version": "4.3.3",
"Repositories": [
{
"Name": "CRAN",