Skip to content

Commit c9f31d3

Browse files
committed
vault backup: 2025-07-29 10:16:45
1 parent 877c9d3 commit c9f31d3

File tree

2 files changed

+107
-5
lines changed

2 files changed

+107
-5
lines changed

source/content/.obsidian/workspace.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"state": {
1414
"type": "markdown",
1515
"state": {
16-
"file": "BSGOU-System/RNA-seq Tool Kits/BRAP.md",
16+
"file": "BSGOU-System/RNA-seq Tool Kits/DeVlog/20250729-fenA-processx_convert-theme.md",
1717
"mode": "source",
1818
"source": false
1919
},
2020
"icon": "lucide-file",
21-
"title": "BRAP"
21+
"title": "20250729-fenA-processx_convert-theme"
2222
}
2323
}
2424
]
@@ -142,13 +142,13 @@
142142
"state": {
143143
"type": "outline",
144144
"state": {
145-
"file": "BSGOU-System/RNA-seq Tool Kits/BRAP.md",
145+
"file": "BSGOU-System/RNA-seq Tool Kits/DeVlog/20250729-fenA-processx_convert-theme.md",
146146
"followCursor": false,
147147
"showSearch": false,
148148
"searchQuery": ""
149149
},
150150
"icon": "lucide-list",
151-
"title": "Outline of BRAP"
151+
"title": "Outline of 20250729-fenA-processx_convert-theme"
152152
}
153153
}
154154
],
@@ -171,8 +171,8 @@
171171
},
172172
"active": "438080deb723bad3",
173173
"lastOpenFiles": [
174-
"conflict-files-obsidian-git.md",
175174
"BSGOU-System/RNA-seq Tool Kits/BRAP.md",
175+
"conflict-files-obsidian-git.md",
176176
"BSGOU-System/Journal Club/index.md",
177177
"BSGOU-System/Journal Club/The One Mutation That Let Us Speak?.md",
178178
"BSGOU-System/Journal Club/PTSD Brain Fog Is Real—and It’s Complicated.md",
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: "20250729:fenA processx_convert & theme"
3+
draft: false
4+
tags:
5+
- Dry
6+
- Linux
7+
- ShinyApp
8+
- Functional-Enrichment-Analysis
9+
---
10+
# Today's task
11+
12+
1. Make fenA fit with our [loc](https://github.com/LabOnoM/ShinyAppsManager) platform
13+
2. Convert the main loop of fenA ShinyApp into Subprocesses of R session by using [processx](https://github.com/r-lib/processx)
14+
3. Change the theme of fenA ShinyApp into the uniformed format
15+
4. If possible, draw software scheme for the main logic in fenA ShinyApp
16+
17+
# 1. Add code blocks for [loc](https://github.com/LabOnoM/ShinyAppsManager)
18+
19+
## Basic functions
20+
1. Handle crash
21+
2. Email notification
22+
3. Communications with [loc](https://github.com/LabOnoM/ShinyAppsManager) based on [jwt](https://en.wikipedia.org/wiki/JSON_Web_Token)
23+
24+
Example codes:
25+
```R
26+
# Fetch information if running on BSGOU loc (local allocation controller) system.
27+
observe({
28+
req(values$is_on_shiny_server)
29+
req(values$server_connected)
30+
req(is.null(session$userData$email))
31+
invalidateLater(10000, session)
32+
msg <- "Checking email"
33+
isolate(values$console_log <-c(values$console_log, print_to_console(msg)))
34+
isolate({values$console_log <- c(values$console_log, msg)})
35+
session$userData$email <- get_user_email(session$userData$token)
36+
isolate(UserEmail <- session$userData$email)
37+
msg <- paste0("Your email is: ", UserEmail)
38+
isolate(values$console_log <-c(values$console_log, print_to_console(msg)))
39+
isolate({values$console_log <- c(values$console_log, msg)})
40+
msg <- "Welcome to BSGOU!"
41+
isolate(values$console_log <-c(values$console_log, print_to_console(msg)))
42+
isolate({values$console_log <- c(values$console_log, msg)})
43+
isolate(values$user_email_checked <- TRUE)
44+
})
45+
output$EmailNotif_ui <- renderUI({
46+
req(values$user_email_checked )
47+
req(!is.null(session$userData$email))
48+
req(values$is_on_shiny_server)
49+
label <- paste0("Enable Email Notification to: ", session$userData$email)
50+
checkboxInput("EmailNotif", label = label, value = TRUE)
51+
})
52+
observe({
53+
msg <- "The console is working"
54+
isolate(values$console_log <-c(values$console_log, print_to_console(msg)))
55+
req(isolate(values$is_on_shiny_server))
56+
## start-3嵌入代码开始,作用:进入/退出HTTP请求记录
57+
query <- parseQueryString(session$clientData$url_search)
58+
session$userData$id <- query$id
59+
session$userData$appName <- query$appName
60+
session$userData$token <- query$token
61+
headers <- httr::add_headers(`Token`=session$userData$token, `Content-Type`="application/json")
62+
connect_req = list(`appName`=session$userData$appName, `action`="connect", `id`=session$userData$id)
63+
connect_data <- try(
64+
url_execute(
65+
2, 'http://10.2.26.152/sqx_fast/app/workstation/shiny-connect-action',
66+
toJSON(connect_req, pretty = FALSE,auto_unbox = TRUE), headers), silent = TRUE
67+
)
68+
values$server_connected<-TRUE
69+
if (connect_data$code!=0) {session$close()}
70+
## end-3嵌入代码开始,作用:进入/退出HTTP请求记录
71+
})
72+
output$conditional_head <- renderUI({
73+
if(isolate(values$is_on_shiny_server)){
74+
## start-1嵌入代码开始,作用:异常跳转到预约系统首页
75+
tags$head(
76+
tags$script(HTML("
77+
$(document).on('shiny:disconnected', function(event) {
78+
window.location.href = 'http://10.2.26.152/';
79+
});
80+
"))
81+
)
82+
## end-1嵌入代码结束,作用:异常跳转到预约系统首页
83+
}else{
84+
NULL
85+
}
86+
})
87+
## Handle crash info ----
88+
# Pop up dialog to show error message
89+
observeEvent(values$error_state, {
90+
if(!is.null(values$error_state)){
91+
SoftwareCrashInfo(error_state = values$error_state, input = input, output = output, main_session=session)
92+
values$error_state<-NULL
93+
}
94+
})
95+
# Observe button click to close modal
96+
observeEvent(input$Crash_modal_ok, {
97+
shiny::removeModal()
98+
})
99+
```
100+
101+
# 2. Convert Main loop with [processx](https://github.com/r-lib/processx)
102+

0 commit comments

Comments
 (0)