Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e903cd975d | |||
| e07d6f70e3 | |||
| ab949ee9c2 | |||
| fc2e518d7e | |||
| 14839dee5f | |||
| 915f3e9810 | |||
| fcd19fb09e | |||
| 989cc9b219 | |||
| b428c976d5 | |||
| fb4335006d | |||
| 12c17d3766 | |||
| dc51156490 |
@@ -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
|
#' @export
|
||||||
#' @description костыли для упрощения работы себе
|
#' @description костыли для упрощения работы себе
|
||||||
@@ -17,23 +5,6 @@ set_global_options = function(
|
|||||||
SYMBOL_DELIM = "; ",
|
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(
|
options(
|
||||||
SYMBOL_DELIM = SYMBOL_DELIM,
|
SYMBOL_DELIM = SYMBOL_DELIM,
|
||||||
@@ -55,6 +26,27 @@ ENABLED_SCHEMES <- stats::setNames(names(ENABLED_SCHEMES), ENABLED_SCHEMES)
|
|||||||
#' @export
|
#' @export
|
||||||
check_and_init_scheme = function() {
|
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("*" = "проверка схемы..."))
|
cli::cli_inform(c("*" = "проверка схемы..."))
|
||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
@@ -81,16 +73,17 @@ check_and_init_scheme = function() {
|
|||||||
if (!all(file.exists(scheme_file))) {
|
if (!all(file.exists(scheme_file))) {
|
||||||
cli::cli_abort(c("Отсутствуют файлы схем для следующих наименований:", paste("-", names(scheme_file)[!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")
|
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"
|
hash_file <- "temp/schema_hash.rds"
|
||||||
|
|
||||||
#
|
#
|
||||||
exist_hash <- tools::md5sum(c(scheme_file, files_to_watch))
|
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)
|
init_scheme(scheme_file)
|
||||||
|
|
||||||
|
|||||||
@@ -168,16 +168,3 @@ scheme_R6 <- R6::R6Class(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# object.size(schm)
|
|
||||||
# schm$get_key_id("main")
|
|
||||||
# schm$get_forms_ids("main")
|
|
||||||
# schm$get_all_ids("main")
|
|
||||||
|
|
||||||
# schm$get_scheme("main")
|
|
||||||
|
|
||||||
# schm$get_id_type_list("allergo_anamnesis")
|
|
||||||
|
|
||||||
# # active
|
|
||||||
# schm$get_main_key_id
|
|
||||||
# schm$all_tables_names
|
|
||||||
@@ -108,7 +108,11 @@ render_forms = function(
|
|||||||
} else {
|
} else {
|
||||||
shiny::tagList(
|
shiny::tagList(
|
||||||
if (!is.na(form_label)) {
|
if (!is.na(form_label)) {
|
||||||
shiny::span(form_label, style = "color: #444444; font-weight: 550; line-height: 1.4;")
|
if (form_type == "description_header") {
|
||||||
|
shiny::span(form_label, class = "description-header", style = "color: #444444; font-weight: 550; line-height: 1.4;")
|
||||||
|
} else {
|
||||||
|
shiny::span(form_label, style = "color: #444444; font-weight: 550; line-height: 1.4;")
|
||||||
|
}
|
||||||
# если в схеме есть поле с описанием - добавляем его следующей строчкой
|
# если в схеме есть поле с описанием - добавляем его следующей строчкой
|
||||||
},
|
},
|
||||||
if (!is.na(description) && !is.na(form_label)) shiny::br(),
|
if (!is.na(description) && !is.na(form_label)) shiny::br(),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ credentials <- data.frame(
|
|||||||
# Init the database
|
# Init the database
|
||||||
shinymanager::create_db(
|
shinymanager::create_db(
|
||||||
credentials_data = credentials,
|
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 = Sys.getenv("AUTH_DB_KEY")
|
||||||
# passphrase = "passphrase_wihtout_keyring"
|
# passphrase = "passphrase_wihtout_keyring"
|
||||||
)
|
)
|
||||||
|
|||||||
BIN
all_bases/schemas/orphans_and_amyloidosis.xlsx
Normal file
BIN
all_bases/schemas/orphans_and_amyloidosis.xlsx
Normal file
Binary file not shown.
21
app.R
21
app.R
@@ -19,9 +19,19 @@ box::use(
|
|||||||
|
|
||||||
# глобальные переменные и проверка/инициация схемы:
|
# глобальные переменные и проверка/инициация схемы:
|
||||||
box::use(
|
box::use(
|
||||||
|
R/modules/global_options[set_global_options, check_and_init_scheme],
|
||||||
R/modules/global_options[AUTH_ENABLED, ENABLED_SCHEMES],
|
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")
|
SCHMS <- readRDS("temp/scheme.rds")
|
||||||
|
|
||||||
# CHECK FOR PANDOC ----------
|
# CHECK FOR PANDOC ----------
|
||||||
@@ -32,15 +42,18 @@ if (!rmarkdown::pandoc_available()) warning("Can't find pandoc!")
|
|||||||
|
|
||||||
# web resources ------
|
# web resources ------
|
||||||
shiny::addResourcePath("www", "www")
|
shiny::addResourcePath("www", "www")
|
||||||
|
shiny::resourcePaths()
|
||||||
|
|
||||||
# UI =======================
|
# UI =======================
|
||||||
ui <- page_sidebar(
|
ui <- page_sidebar(
|
||||||
title = config::get("form_name"),
|
title = config::get("form_name"),
|
||||||
theme = bs_theme(version = 5, preset = "bootstrap"),
|
theme = bs_theme(version = 5, preset = "bootstrap"),
|
||||||
header = tags$head(
|
|
||||||
|
tags$head(
|
||||||
|
tags$link(rel = "stylesheet", type = "text/css", href = "www/styles.css"),
|
||||||
tags$link(rel = "icon", href = "www/favicon.ico")
|
tags$link(rel = "icon", href = "www/favicon.ico")
|
||||||
),
|
),
|
||||||
|
|
||||||
sidebar = sidebar(
|
sidebar = sidebar(
|
||||||
actionButton("add_new_main_key_button", "Добавить новую запись", icon("plus", lib = "font-awesome")),
|
actionButton("add_new_main_key_button", "Добавить новую запись", icon("plus", lib = "font-awesome")),
|
||||||
actionButton("save_data_button", "Сохранить данные", icon("floppy-disk", lib = "font-awesome")),
|
actionButton("save_data_button", "Сохранить данные", icon("floppy-disk", lib = "font-awesome")),
|
||||||
@@ -102,7 +115,7 @@ server <- function(input, output, session) {
|
|||||||
# check_credentials directly on sqlite db
|
# check_credentials directly on sqlite db
|
||||||
shinymanager::secure_server(
|
shinymanager::secure_server(
|
||||||
check_credentials = shinymanager::check_credentials(
|
check_credentials = shinymanager::check_credentials(
|
||||||
db = "config/auth.sqlite",
|
db = "temp/auth.sqlite",
|
||||||
passphrase = Sys.getenv("AUTH_DB_KEY")
|
passphrase = Sys.getenv("AUTH_DB_KEY")
|
||||||
),
|
),
|
||||||
keep_token = TRUE
|
keep_token = TRUE
|
||||||
@@ -1139,7 +1152,7 @@ server <- function(input, output, session) {
|
|||||||
# write vector to temp .Rmd file
|
# write vector to temp .Rmd file
|
||||||
writeLines(empty_vec, temp_report, sep = "\n")
|
writeLines(empty_vec, temp_report, sep = "\n")
|
||||||
# copy template .docx file
|
# 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
|
# render file via pandoc
|
||||||
rmarkdown::render(
|
rmarkdown::render(
|
||||||
|
|||||||
5
appinfo.json
Normal file
5
appinfo.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"app_id": "formy",
|
||||||
|
"app_title": "FORMY",
|
||||||
|
"formy_version": "0.18.4"
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
default:
|
default:
|
||||||
form_app_version: !expr config::get("form_app_version", file = "config/descr.yml")
|
form_app_version: !expr jsonlite::read_json("appinfo.json")$formy_version
|
||||||
form_id: !expr config::get("form_id", file = "config/descr.yml")
|
form_id: !expr jsonlite::read_json("appinfo.json")$app_id
|
||||||
form_name: !expr config::get("form_name", file = "config/descr.yml")
|
form_name: !expr jsonlite::read_json("appinfo.json")$app_title
|
||||||
|
|
||||||
prod:
|
prod:
|
||||||
form_app_configure_path: "example_scheme"
|
form_app_configure_path: "example_scheme"
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
default:
|
|
||||||
form_app_version: 0.18.3
|
|
||||||
form_id: formy
|
|
||||||
form_name: FORMY
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"R": {
|
"R": {
|
||||||
"Version": "4.3.2",
|
"Version": "4.3.3",
|
||||||
"Repositories": [
|
"Repositories": [
|
||||||
{
|
{
|
||||||
"Name": "CRAN",
|
"Name": "CRAN",
|
||||||
|
|||||||
BIN
www/favicon.ico
BIN
www/favicon.ico
Binary file not shown.
|
Before Width: | Height: | Size: 295 KiB After Width: | Height: | Size: 2.1 KiB |
10
www/styles.css
Normal file
10
www/styles.css
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.description-header {
|
||||||
|
/* 1. Add the border around the whole box */
|
||||||
|
border-bottom: 2px solid #777777;
|
||||||
|
|
||||||
|
/* 2. Forces border inside the total width/height (prevents breaking layouts) */
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
/* 3. Ensures the div encloses any internal floated elements */
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user