refactor: инициация схемы - при загрузке модуля, вместо загрузки пакетов через library: box and namespacing
This commit is contained in:
@@ -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,7 +50,9 @@ 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(R/modules/db[local_db_backup])
|
box::use(
|
||||||
|
R/modules/db[local_db_backup]
|
||||||
|
)
|
||||||
|
|
||||||
# список файлов, изменение которых, приведут к переинициализиации схемы
|
# список файлов, изменение которых, приведут к переинициализиации схемы
|
||||||
files_to_watch <- c(
|
files_to_watch <- c(
|
||||||
|
|||||||
29
app.R
29
app.R
@@ -1,16 +1,12 @@
|
|||||||
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(
|
||||||
|
bslib[...],
|
||||||
|
shiny[...]
|
||||||
|
)
|
||||||
|
# modules
|
||||||
box::use(
|
box::use(
|
||||||
R/modules/utils,
|
R/modules/utils,
|
||||||
R/modules/global_options,
|
R/modules/global_options,
|
||||||
@@ -22,15 +18,13 @@ box::use(
|
|||||||
R/modules/data_manipulations[is_this_empty_value]
|
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(
|
||||||
R/modules/global_options[AUTH_ENABLED]
|
R/modules/global_options[AUTH_ENABLED]
|
||||||
@@ -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)
|
|
||||||
Reference in New Issue
Block a user