Compare commits
3 Commits
a0340d78e5
...
d73699a1d1
| Author | SHA1 | Date | |
|---|---|---|---|
| d73699a1d1 | |||
| e6e15392c3 | |||
| 2ececc8029 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,7 +3,6 @@
|
|||||||
/_devel
|
/_devel
|
||||||
/all_bases
|
/all_bases
|
||||||
|
|
||||||
scheme.rds
|
|
||||||
config.yml
|
config.yml
|
||||||
|
|
||||||
.Renviron
|
.Renviron
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(
|
box::use(
|
||||||
modules/utils,
|
R/modules/utils,
|
||||||
)
|
)
|
||||||
|
|
||||||
#' @export
|
#' @export
|
||||||
@@ -5,9 +5,9 @@ box::use(
|
|||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(
|
box::use(
|
||||||
modules/db,
|
R/modules/db,
|
||||||
modules/utils,
|
R/modules/utils,
|
||||||
app/forms
|
R/app/forms
|
||||||
)
|
)
|
||||||
|
|
||||||
#' @export
|
#' @export
|
||||||
@@ -5,9 +5,9 @@ box::use(
|
|||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(
|
box::use(
|
||||||
modules/db,
|
R/modules/db,
|
||||||
modules/utils,
|
R/modules/utils,
|
||||||
app/forms
|
R/app/forms
|
||||||
)
|
)
|
||||||
|
|
||||||
#' @export
|
#' @export
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(modules/data_manipulations[is_this_empty_value])
|
box::use(R/modules/data_manipulations[is_this_empty_value])
|
||||||
|
|
||||||
#' @export
|
#' @export
|
||||||
init_val = function(scheme, ns) {
|
init_val = function(scheme, ns) {
|
||||||
@@ -103,7 +103,7 @@ get_dummy_data = function(type) {
|
|||||||
get_dummy_df = function(forms_id_type_list) {
|
get_dummy_df = function(forms_id_type_list) {
|
||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(modules/utils)
|
box::use(R/modules/utils)
|
||||||
|
|
||||||
purrr::map(
|
purrr::map(
|
||||||
.x = forms_id_type_list,
|
.x = forms_id_type_list,
|
||||||
@@ -136,7 +136,7 @@ compare_existing_table_with_schema = function(
|
|||||||
}
|
}
|
||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(modules/utils)
|
box::use(R/modules/utils)
|
||||||
|
|
||||||
# checking if db structure in form compatible with alrady writed data (in case on changig form)
|
# checking if db structure in form compatible with alrady writed data (in case on changig form)
|
||||||
if (identical(colnames(DBI::dbReadTable(con, table_name)), all_ids_from_schema)) {
|
if (identical(colnames(DBI::dbReadTable(con, table_name)), all_ids_from_schema)) {
|
||||||
@@ -1,10 +1,16 @@
|
|||||||
|
.on_load = function(ns) {
|
||||||
|
|
||||||
|
check_and_init_scheme()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#' @export
|
#' @export
|
||||||
#' @description костыли для упрощения работы себе
|
#' @description костыли для упрощения работы себе
|
||||||
set_global_options = function(
|
set_global_options = function(
|
||||||
SYMBOL_DELIM = "; ",
|
SYMBOL_DELIM = "; ",
|
||||||
APP.DEBUG = FALSE,
|
APP.DEBUG = FALSE,
|
||||||
shiny.host = "127.0.0.1",
|
# shiny.host = "127.0.0.1",
|
||||||
shiny.port = 1338,
|
# shiny.port = 1338,
|
||||||
...
|
...
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@@ -29,9 +35,8 @@ set_global_options = function(
|
|||||||
SYMBOL_DELIM = SYMBOL_DELIM,
|
SYMBOL_DELIM = SYMBOL_DELIM,
|
||||||
# form.db_path = config::get("form_db_path"),
|
# form.db_path = config::get("form_db_path"),
|
||||||
APP.DEBUG = APP.DEBUG,
|
APP.DEBUG = APP.DEBUG,
|
||||||
# APP.FILE_DB = APP.FILE_DB,
|
# shiny.host = shiny.host,
|
||||||
shiny.host = shiny.host,
|
# shiny.port = shiny.port,
|
||||||
shiny.port = shiny.port,
|
|
||||||
...
|
...
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -45,13 +50,15 @@ check_and_init_scheme = function() {
|
|||||||
cli::cli_inform(c("*" = "проверка схемы..."))
|
cli::cli_inform(c("*" = "проверка схемы..."))
|
||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(modules/db[local_db_backup])
|
box::use(
|
||||||
|
R/modules/db[local_db_backup]
|
||||||
|
)
|
||||||
|
|
||||||
# список файлов, изменение которых, приведут к переинициализиации схемы
|
# список файлов, изменение которых, приведут к переинициализиации схемы
|
||||||
files_to_watch <- c(
|
files_to_watch <- c(
|
||||||
"config.yml",
|
"config.yml",
|
||||||
"modules/scheme_generator.R",
|
"R/modules/scheme_generator.R",
|
||||||
"modules/utils.R"
|
"R/modules/utils.R"
|
||||||
)
|
)
|
||||||
|
|
||||||
# проверка существования отслеживаемых файлов
|
# проверка существования отслеживаемых файлов
|
||||||
@@ -75,7 +82,7 @@ check_and_init_scheme = function() {
|
|||||||
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("scheme.rds") | !all(file.exists(db_files))) {
|
if (!file.exists(hash_file) | !file.exists("temp/scheme.rds") | !all(file.exists(db_files))) {
|
||||||
|
|
||||||
init_scheme(scheme_file)
|
init_scheme(scheme_file)
|
||||||
|
|
||||||
@@ -111,8 +118,8 @@ init_scheme = function(scheme_file) {
|
|||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(
|
box::use(
|
||||||
modules/db,
|
R/modules/db,
|
||||||
modules/scheme_generator[scheme_R6]
|
R/modules/scheme_generator[scheme_R6]
|
||||||
)
|
)
|
||||||
|
|
||||||
db_path <- fs::path(config::get("form_app_configure_path"), "db")
|
db_path <- fs::path(config::get("form_app_configure_path"), "db")
|
||||||
@@ -155,5 +162,5 @@ init_scheme = function(scheme_file) {
|
|||||||
cli::cli_abort(c("В одной или нескольких схемах наименования вложенных форм совпадают:", paste("-", names(tab)[tab > 1])))
|
cli::cli_abort(c("В одной или нескольких схемах наименования вложенных форм совпадают:", paste("-", names(tab)[tab > 1])))
|
||||||
}
|
}
|
||||||
|
|
||||||
saveRDS(schms, "scheme.rds")
|
saveRDS(schms, "temp/scheme.rds")
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ scheme_R6 <- R6::R6Class(
|
|||||||
# extract main key
|
# extract main key
|
||||||
private$main_key_id <- self$get_key_id("main")
|
private$main_key_id <- self$get_key_id("main")
|
||||||
|
|
||||||
box::use(modules/utils)
|
box::use(R/modules/utils)
|
||||||
private$bslib_rendered_ui <- bslib::navset_card_underline(
|
private$bslib_rendered_ui <- bslib::navset_card_underline(
|
||||||
id = "main",
|
id = "main",
|
||||||
!!!utils$make_list_of_pages(private$schemes_list[["main"]], private$main_key_id),
|
!!!utils$make_list_of_pages(private$schemes_list[["main"]], private$main_key_id),
|
||||||
@@ -266,7 +266,7 @@ update_forms_with_data = function(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
options(box.path = here::here())
|
options(box.path = here::here())
|
||||||
box::use(modules/data_manipulations[is_this_empty_value])
|
box::use(R/modules/data_manipulations[is_this_empty_value])
|
||||||
|
|
||||||
# print("-----------------")
|
# print("-----------------")
|
||||||
# cli::cli_inform("form_id: {form_id} | form_type: {form_type}")
|
# cli::cli_inform("form_id: {form_id} | form_type: {form_type}")
|
||||||
49
app.R
49
app.R
@@ -1,45 +1,39 @@
|
|||||||
suppressPackageStartupMessages({
|
|
||||||
library(DBI)
|
|
||||||
library(tidyr)
|
|
||||||
library(dplyr)
|
|
||||||
library(purrr)
|
|
||||||
library(magrittr)
|
|
||||||
library(shiny)
|
|
||||||
library(bslib)
|
|
||||||
library(shinymanager)
|
|
||||||
})
|
|
||||||
|
|
||||||
# SOURCE FILES ============================
|
# SOURCE FILES ============================
|
||||||
|
# packages
|
||||||
box::purge_cache()
|
box::purge_cache()
|
||||||
box::use(
|
box::use(
|
||||||
modules/utils,
|
bslib[...],
|
||||||
modules/global_options,
|
shiny[...]
|
||||||
modules/db,
|
)
|
||||||
modules/data_validation,
|
# modules
|
||||||
app/forms,
|
box::use(
|
||||||
app/tasks,
|
R/modules/utils,
|
||||||
app/logs,
|
R/modules/global_options,
|
||||||
modules/data_manipulations[is_this_empty_value]
|
R/modules/db,
|
||||||
|
R/modules/data_validation,
|
||||||
|
R/app/forms,
|
||||||
|
R/app/tasks,
|
||||||
|
R/app/logs,
|
||||||
|
R/modules/data_manipulations[is_this_empty_value]
|
||||||
)
|
)
|
||||||
|
|
||||||
# global settings:
|
# set global settings:
|
||||||
global_options$set_global_options(
|
global_options$set_global_options(
|
||||||
shiny.host = "0.0.0.0",
|
shiny.host = "0.0.0.0",
|
||||||
|
shiny.port = 1338,
|
||||||
APP.DEBUG = FALSE
|
APP.DEBUG = FALSE
|
||||||
)
|
)
|
||||||
|
|
||||||
# init:
|
|
||||||
global_options$check_and_init_scheme()
|
|
||||||
|
|
||||||
# global vars:
|
# global vars:
|
||||||
box::use(
|
box::use(
|
||||||
modules/global_options[AUTH_ENABLED]
|
R/modules/global_options[AUTH_ENABLED]
|
||||||
)
|
)
|
||||||
enabled_schemes <- unlist(config::get()$form_schemes)
|
enabled_schemes <- unlist(config::get()$form_schemes)
|
||||||
enabled_schemes <- setNames(names(enabled_schemes), enabled_schemes)
|
enabled_schemes <- setNames(names(enabled_schemes), enabled_schemes)
|
||||||
|
|
||||||
# load schemes object:
|
# load schemes object:
|
||||||
schms <- readRDS("scheme.rds")
|
schms <- readRDS("temp/scheme.rds")
|
||||||
|
|
||||||
# CHECK FOR PANDOC ----------
|
# CHECK FOR PANDOC ----------
|
||||||
# rmarkdown::find_pandoc(dir = "/opt/homebrew/bin/")
|
# rmarkdown::find_pandoc(dir = "/opt/homebrew/bin/")
|
||||||
@@ -118,7 +112,7 @@ server <- function(input, output, session) {
|
|||||||
res_auth <- if (AUTH_ENABLED) {
|
res_auth <- if (AUTH_ENABLED) {
|
||||||
# check_credentials directly on sqlite db
|
# check_credentials directly on sqlite db
|
||||||
shinymanager::secure_server(
|
shinymanager::secure_server(
|
||||||
check_credentials = check_credentials(
|
check_credentials = shinymanager::check_credentials(
|
||||||
db = "auth.sqlite",
|
db = "auth.sqlite",
|
||||||
passphrase = Sys.getenv("AUTH_DB_KEY")
|
passphrase = Sys.getenv("AUTH_DB_KEY")
|
||||||
),
|
),
|
||||||
@@ -1373,7 +1367,6 @@ server <- function(input, output, session) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app <- shiny::shinyApp(ui = ui, server = server)
|
||||||
|
|
||||||
app <- shinyApp(ui = ui, server = server)
|
shiny::runApp(app, launch.browser = TRUE)
|
||||||
|
|
||||||
runApp(app, launch.browser = TRUE)
|
|
||||||
26
renv.lock
26
renv.lock
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"R": {
|
"R": {
|
||||||
"Version": "4.3.1",
|
"Version": "4.3.2",
|
||||||
"Repositories": [
|
"Repositories": [
|
||||||
{
|
{
|
||||||
"Name": "CRAN",
|
"Name": "CRAN",
|
||||||
@@ -717,6 +717,19 @@
|
|||||||
],
|
],
|
||||||
"Hash": "b8552d117e1b808b09a832f589b79035"
|
"Hash": "b8552d117e1b808b09a832f589b79035"
|
||||||
},
|
},
|
||||||
|
"lubridate": {
|
||||||
|
"Package": "lubridate",
|
||||||
|
"Version": "1.9.5",
|
||||||
|
"Source": "Repository",
|
||||||
|
"Repository": "CRAN",
|
||||||
|
"Requirements": [
|
||||||
|
"R",
|
||||||
|
"generics",
|
||||||
|
"methods",
|
||||||
|
"timechange"
|
||||||
|
],
|
||||||
|
"Hash": "07061b348d057e8ac86771e0eff36b62"
|
||||||
|
},
|
||||||
"magrittr": {
|
"magrittr": {
|
||||||
"Package": "magrittr",
|
"Package": "magrittr",
|
||||||
"Version": "2.0.3",
|
"Version": "2.0.3",
|
||||||
@@ -1203,6 +1216,17 @@
|
|||||||
],
|
],
|
||||||
"Hash": "79540e5fcd9e0435af547d885f184fd5"
|
"Hash": "79540e5fcd9e0435af547d885f184fd5"
|
||||||
},
|
},
|
||||||
|
"timechange": {
|
||||||
|
"Package": "timechange",
|
||||||
|
"Version": "0.4.0",
|
||||||
|
"Source": "Repository",
|
||||||
|
"Repository": "CRAN",
|
||||||
|
"Requirements": [
|
||||||
|
"R",
|
||||||
|
"cpp11"
|
||||||
|
],
|
||||||
|
"Hash": "39c40cb1ad47a4cc384a34a22a29463f"
|
||||||
|
},
|
||||||
"tinytex": {
|
"tinytex": {
|
||||||
"Package": "tinytex",
|
"Package": "tinytex",
|
||||||
"Version": "0.46",
|
"Version": "0.46",
|
||||||
|
|||||||
Reference in New Issue
Block a user