From 1856552f4bed33a521e63b0d0117ca0c108fee05 Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 14:53:20 +0200
Subject: [PATCH 1/9] import for module DT
import for missing module DT
---
app.R | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app.R b/app.R
index 65fd238..338bed4 100644
--- a/app.R
+++ b/app.R
@@ -33,7 +33,7 @@ library(magrittr)
library(rjson) # write JSON files
library(jsonlite) # read JSON files
-
+library(DT) # interactive Tables in shiny
library(igraph)
From b46d2ae0dc107c20bc43669e9d5c48c121c2e4b3 Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 15:32:15 +0200
Subject: [PATCH 2/9] bugfix: correct zip download in preprocessing
zip download of preprocessed data was faulty; fixed by using zipr instead of zip function.
Additionally small cosmetics to the code.
---
app.R | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/app.R b/app.R
index 338bed4..285a754 100644
--- a/app.R
+++ b/app.R
@@ -736,7 +736,7 @@ fluidPage(clusteringCAMs_overallLevelUI("clusteringCAMs_overallLevel"))
)
}
- if ("approximateMatching" %in% globals$condition ||
+ if ("approximateMatching" %in% globals$condition ||
"searchTerms" %in% globals$condition ||
"findSynonyms" %in% globals$condition ||
"word2vec" %in% globals$condition) {
@@ -810,7 +810,7 @@ fluidPage(clusteringCAMs_overallLevelUI("clusteringCAMs_overallLevel"))
)
}
- if ("networkIndicators" %in% globals$condition) {
+ if ("networkIndicators" %in% globals$condition) {
write(
"\nnetworkIndicators: .txt file of all computed network indicators",
path,
@@ -836,7 +836,7 @@ fluidPage(clusteringCAMs_overallLevelUI("clusteringCAMs_overallLevel"))
)
}
- if ("networkNeighborhoodIndicators" %in% globals$condition) {
+ if ("networkNeighborhoodIndicators" %in% globals$condition) {
write(
"\nnetworkNeighborhoodIndicators: .txt file of all computed neighborhood indicators",
path,
@@ -861,31 +861,31 @@ fluidPage(clusteringCAMs_overallLevelUI("clusteringCAMs_overallLevel"))
path,
append = TRUE
)
- }
+ }
- if ("wordlistOverallCreated" %in% globals$condition) {
- write(
+ if ("wordlistOverallCreated" %in% globals$condition) {
+ write(
"\nwordlistOverall: .txt file of overall wordlist",
path,
append = TRUE
)
- write(
+ write(
"wordlistOverall: .xlsx (Excel) file of overall wordlist",
path,
append = TRUE
)
}
- if ("singleConceptsTable" %in% globals$condition) {
- write(
+ if ("singleConceptsTable" %in% globals$condition) {
+ write(
"\nsingleConceptsTable: .txt file of all drawn single concepts seperated by CAMs",
path,
append = TRUE
)
- write(
+ write(
"singleConceptsTable: .xlsx (Excel) file of all drawn single concepts seperated by CAMs",
path,
append = TRUE
@@ -893,14 +893,14 @@ fluidPage(clusteringCAMs_overallLevelUI("clusteringCAMs_overallLevel"))
}
- if ("CAMsSlicedCreated" %in% globals$condition) {
- write(
+ if ("CAMsSlicedCreated" %in% globals$condition) {
+ write(
paste0("\nCAMs sliced datasets: .txt files (nodes, connectors, merged) created for central concept: ", globals$namingSlicedCAMs[1]),
path,
append = TRUE
)
- write(
+ write(
paste0("CAMs sliced datasets: .txt files (nodes, connectors, merged) created for central concept: ", globals$namingSlicedCAMs[2]),
path,
append = TRUE
@@ -925,9 +925,7 @@ fluidPage(clusteringCAMs_overallLevelUI("clusteringCAMs_overallLevel"))
# write(rjson::toJSON(globals$protocol), path)
#jsonlite::write_json(x = globals$protocol, path = path)
-
-
- zip(zipfile = fname, files = fs)
+ zip::zipr(zipfile = fname, files = fs)
},
contentType = "application/zip"
)
From 08f72becfcc226a8897e23c9833d286f6191373f Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 16:03:41 +0200
Subject: [PATCH 3/9] bugfix: upload of protocol on local machine
Now reads the text only once in correct encoding.
---
www/modules/uploadServer.R | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/www/modules/uploadServer.R b/www/modules/uploadServer.R
index 844427c..c00b5d4 100644
--- a/www/modules/uploadServer.R
+++ b/www/modules/uploadServer.R
@@ -292,16 +292,17 @@ uploadServer <- function(id, parent, globals) {
### upload protocol dataset
protocol <- reactive({
## to test validity of JSON file
- text <- readLines(input$uploadProtocol$datapath, warn = FALSE)
- text <- readLines(textConnection(text, encoding="UTF-8"), encoding="UTF-8")
- if (testIfJson(file = text)) {
+ protocol <- reactive({
+ req(input$uploadProtocol)
+ if (testIfJson(file = readLines(input$uploadProtocol$datapath, warn = FALSE, encoding="UTF-8"))) {
protocol <- rjson::fromJSON(file = input$uploadProtocol$datapath)
-
return(protocol)
- } else{
+ } else {
print("Invalid protocol uploaded")
return(NULL)
}
+ })
+
# ## alternative
From 69dfa13204dda2f81d278bbf13b7f35ee35c8f48 Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 16:20:24 +0200
Subject: [PATCH 4/9] TEMP bugfix: accessing analysis part on local machine
Was prohibited because of closure-error. Has to be fixed correctly by not using a list for "cleanValence" in the protocoll.
---
www/modules/uploadServer.R | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/modules/uploadServer.R b/www/modules/uploadServer.R
index c00b5d4..58e8e53 100644
--- a/www/modules/uploadServer.R
+++ b/www/modules/uploadServer.R
@@ -1079,7 +1079,7 @@ uploadServer <- function(id, parent, globals) {
verbose = FALSE)
## set protocol to true
- globals$protocol$cleanValence <- TRUE
+ globals$protocol()$cleanValence <- TRUE
v$dfClean <- clean_ValenceData
v$df <- clean_ValenceData
From cf1d94515401a02c7b7a3ef9877f214b723e4a54 Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 16:48:52 +0200
Subject: [PATCH 5/9] Revert "TEMP bugfix: accessing analysis part on local
machine"
This reverts commit 69dfa13204dda2f81d278bbf13b7f35ee35c8f48.
---
www/modules/uploadServer.R | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/modules/uploadServer.R b/www/modules/uploadServer.R
index 58e8e53..c00b5d4 100644
--- a/www/modules/uploadServer.R
+++ b/www/modules/uploadServer.R
@@ -1079,7 +1079,7 @@ uploadServer <- function(id, parent, globals) {
verbose = FALSE)
## set protocol to true
- globals$protocol()$cleanValence <- TRUE
+ globals$protocol$cleanValence <- TRUE
v$dfClean <- clean_ValenceData
v$df <- clean_ValenceData
From e1c1d5333c0853348728e1e042e40ed1c7250be0 Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 20:42:35 +0200
Subject: [PATCH 6/9] import for module stringdist
---
app.R | 1 +
1 file changed, 1 insertion(+)
diff --git a/app.R b/app.R
index 285a754..d3417de 100644
--- a/app.R
+++ b/app.R
@@ -38,6 +38,7 @@ library(DT) # interactive Tables in shiny
library(igraph)
library(sortable)
+library(stringdist)
library(vroom)
library(xlsx)
From c9ef3b148879bdc89c39c29860c32d5c9ea05cbf Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 20:48:10 +0200
Subject: [PATCH 7/9] bugfix and code-cleaning
Fixed my own bug (had protocol <- reactive nested in itself) and also cleaned up the code a bit.
---
www/modules/uploadServer.R | 303 ++++++++++++++++++++-----------------
1 file changed, 162 insertions(+), 141 deletions(-)
diff --git a/www/modules/uploadServer.R b/www/modules/uploadServer.R
index c00b5d4..5581972 100644
--- a/www/modules/uploadServer.R
+++ b/www/modules/uploadServer.R
@@ -290,45 +290,26 @@ uploadServer <- function(id, parent, globals) {
#> Server
### upload protocol dataset
+
+ ## to test validity of JSON file
protocol <- reactive({
- ## to test validity of JSON file
- protocol <- reactive({
- req(input$uploadProtocol)
- if (testIfJson(file = readLines(input$uploadProtocol$datapath, warn = FALSE, encoding="UTF-8"))) {
- protocol <- rjson::fromJSON(file = input$uploadProtocol$datapath)
- return(protocol)
- } else {
- print("Invalid protocol uploaded")
- return(NULL)
- }
- })
-
-
-
- # ## alternative
- # text <- readLines(input$uploadProtocol$datapath)
- # text <- readLines(textConnection(text, encoding="UTF-8"), encoding="UTF-8")
- # if (testIfJson(file = text)) {
- # protocol <- jsonlite::fromJSON(txt = text)
- # # jsonlite::read_json(path = input$uploadProtocol$datapath)
- # # rjson::fromJSON(file = input$uploadProtocol$datapath)
- # return(protocol)
- # } else{
- # print("ERROR")
- # return(NULL)
- # }
- #
- # ## right encoding
- # for(i in 1:length(protocol$approximateMatching)){
- # Encoding(x = protocol$approximateMatching[[i]]$wordsFound) <- "latin1"
- # Encoding(x = protocol$approximateMatching[[i]]$supordinateWord) <- "latin1"
- # }
+ req(input$uploadProtocol)
+ if (testIfJson(file = readLines(input$uploadProtocol$datapath, warn = FALSE, encoding="UTF-8"))) {
+ protocol <- rjson::fromJSON(file = input$uploadProtocol$datapath)
+ return(protocol)
+ } else {
+ print("Invalid protocol uploaded")
+ return(NULL)
+ }
})
+
observeEvent(input$uploadProtocol, {
+ print("observer for uploadProtocol is triggered")
if (!is.null(protocol())) {
message("successfully uploaded protocol!")
v$protocol = TRUE
+ print(v$protocol)
} else{
v$protocol = FALSE
showModal(
@@ -366,9 +347,10 @@ uploadServer <- function(id, parent, globals) {
### create three data sets with nodes / connectors / merged
- data <- reactive({
- # wait for upload
+ uploadedData <- reactive({
req(ext())
+ print("uploadedData ist being read")
+ print(ext())
## if CAMEL data (checked by .txt ending)
if (all(stringr::str_detect(string = ext(), pattern = "txt"))) {
@@ -397,6 +379,7 @@ uploadServer <- function(id, parent, globals) {
)
)
v$dataUploaded <- "no"
+ print("Uploaded raw_CAM Datei doesn't seem to be a valid Data Collection Tool dataset..")
return(NULL)
}
}
@@ -417,6 +400,7 @@ uploadServer <- function(id, parent, globals) {
)
)
v$dataUploaded <- "no"
+ print("CAMs are not valid Data Collection Tool datasets or a empty")
return(NULL)
}
@@ -428,13 +412,24 @@ uploadServer <- function(id, parent, globals) {
## if JSON file
} else if (all(stringr::str_detect(string = ext(), pattern = "json"))) {
+ print("Starting JSON-Branch")
+ print(input$upload$datapath)
+ print(ext())
+ print("testIfJson:")
+ print(testIfJson(input$upload$datapath))
+
if(testIfJson(input$upload$datapath)) {
raw <- jsonlite::fromJSON(input$upload$datapath, simplifyVector = FALSE)
-
+
+ #print("raw nach fromJSON:")
+ #str(raw, max.level=2)
+
# Then apply fromJSON again per CAM - this allows proper simplification
dat <- lapply(raw, function(cam) {
jsonlite::fromJSON(jsonlite::toJSON(cam, auto_unbox = TRUE))
})
+ #print("dat nach lapply:")
+ #str(dat, max.level=2)
} else {
showModal(
modalDialog(
@@ -447,12 +442,15 @@ uploadServer <- function(id, parent, globals) {
)
)
v$dataUploaded <- "no"
+ print("CAMs scheinen fehlerhaft zu sein. (TestifJson)")
return(NULL)
}
CAMfiles <-
create_CAMfiles(datCAM = dat, reDeleted = TRUE, verbose = FALSE)
+ #print("CAMfiles nach create_CAMfiles:")
+ #str(CAMfiles, max.level=2)
# check if parsing CAMs was successful
if(is.null(CAMfiles)) {
@@ -467,6 +465,7 @@ uploadServer <- function(id, parent, globals) {
)
)
v$dataUploaded <- "no"
+ print("CAM doesn't have a valid Data Collection Tool dataset or it contains only empty CAMS")
return(NULL)
}
@@ -474,6 +473,9 @@ uploadServer <- function(id, parent, globals) {
CAMfiles[[1]]$text <-
stringr::str_trim(string = CAMfiles[[1]]$text, side = "both")
v$dataUploaded <- "yes"
+
+ #print("CAMfiles nach trim:")
+ #str(CAMfiles, max.level=2)
## if Valence data (checked by .csv ending)
} else if (all(stringr::str_detect(string = ext(), pattern = "csv"))) {
@@ -491,6 +493,7 @@ uploadServer <- function(id, parent, globals) {
)
)
v$dataUploaded <- "no"
+ print("Not enough csv files")
return(NULL)
}
@@ -498,10 +501,10 @@ uploadServer <- function(id, parent, globals) {
## names for blocks and links files
files_blocks <-
sort(stringr::str_subset(string = input$upload[, "name"],
- pattern = "blocks"))
+ pattern = "blocks"))
files_links <-
sort(stringr::str_subset(string = input$upload[, "name"],
- pattern = "links"))
+ pattern = "links"))
## check: equal numbers of blocks and links dataset
if (v$boolContinue) {
@@ -518,6 +521,7 @@ uploadServer <- function(id, parent, globals) {
)
)
v$dataUploaded <- "no"
+ print("csv files do not have the same number of blocks and links")
return(NULL)
}
}
@@ -548,6 +552,7 @@ uploadServer <- function(id, parent, globals) {
)
)
v$dataUploaded <- "no"
+ print("CSV Files do not have identical IDs in the format ID_CAMnumber_links/blocks")
return(NULL)
}
}
@@ -611,7 +616,7 @@ uploadServer <- function(id, parent, globals) {
CAMfiles <- NULL
}
- } else{
+ }else{
## if no CAMEL or Valence files have been upload
showModal(modalDialog(
title = "Wrong files",
@@ -631,13 +636,14 @@ uploadServer <- function(id, parent, globals) {
# print(head(CAMfiles[[3]]))
if(v$protocol){
- # print(globals$protocol)
+ #Possible error, if protocol()$software is NULL!
globals$protocol$software <- protocol()$software
-
globals$protocol$cleanValence <- protocol()$cleanValence
+
## keep only CAMs which have not been deleted
if(length(protocol()$currentCAMs) > 0){
+ print("tries to ony keep CAMs which have not been deleted?")
# if participants IDs have been used in the draw CAM step
if(all(unlist(protocol()$currentCAMs) %in% CAMfiles[[1]]$CAM)){
CAMfiles[[1]] <- CAMfiles[[1]][CAMfiles[[1]]$CAM %in% unlist(protocol()$currentCAMs), ]
@@ -660,9 +666,10 @@ uploadServer <- function(id, parent, globals) {
}
if(length(protocol()$approximateMatching) > 0
- || length(protocol()$searchTerms) > 0
- || length(protocol()$findSynonyms) > 0
- || length(protocol()$modelwordVec) > 0){
+ || length(protocol()$searchTerms) > 0
+ || length(protocol()$findSynonyms) > 0
+ || length(protocol()$modelwordVec) > 0){
+ print("tries to overwrite protocol, if apporximate Matching has been done")
CAMfiles[[1]]$text_summarized <- CAMfiles[[1]]$text
tmp_out <- overwriteTextNodes(protocolDat = protocol(), nodesDat = CAMfiles[[1]])
CAMfiles[[1]] <- tmp_out[[1]]
@@ -679,9 +686,9 @@ uploadServer <- function(id, parent, globals) {
# print("globals$protocol:")
# print(globals$protocol)
}
- ## save as global variable - else triggered to early
+ ## save as global variable - else triggered to early
- # print(globals$protocol$cleanValence)
+ # print(globals$protocol$cleanValence)
if(!globals$protocol$cleanValence[[1]]){
v$df <- CAMfiles
@@ -691,21 +698,37 @@ uploadServer <- function(id, parent, globals) {
dat_merged = CAMfiles[[3]],
verbose = FALSE)
message("successfully cleaned Valence data!")
-
}
# nodes_raw$text_summarized <- nodes_raw$text
-
+ print("End of uploadedData, v$df:")
+ print(str(v$df, max.level=1))
return(v$df) ### ??? CAMfiles
})
-
+
## SAVE to globals ##
observeEvent(input$upload, {
+ print("Input upload:")
+ print(input$upload)
+ print("ext:")
+ print(ext())
+ if (!exists("uploadedData") || is.null(uploadedData)){
+ print("uploadedData ist NULL!")
+ return(NULL)
+ }
+
+ dat <- tryCatch(uploadedData(), error = function(e) NULL)
+ if (is.null(dat)) {
+ print("uploadedData() ist NULL!")
+ return(NULL)
+ }
+ req(dat)
+
req(ext())
- req(data())
+ req(uploadedData())
message("uploaded file(s) - extensions:", ext())
- if (!is.null(v$df)) {
+ if (v$dataUploaded == "yes" && !is.null(v$df)) {
message("successfully uploaded data!")
#> change condition
globals$condition <-
@@ -727,6 +750,7 @@ uploadServer <- function(id, parent, globals) {
tmp_list
}
} else{
+ print("Fehler beim Data-Upload")
#> avoid error in download function
globals$condition <-
str_replace_all(
@@ -738,7 +762,7 @@ uploadServer <- function(id, parent, globals) {
globals$protocol$software[[length(globals$protocol$software) + 1]] <-
c("unknown", as.character(as.POSIXct(Sys.time())))
}
- })
+ }, ignoreNULL = TRUE)
####
@@ -940,6 +964,7 @@ uploadServer <- function(id, parent, globals) {
if(length(list_summarizeTerms) == 0){
+ print("Länge der list_summarizeTerms ist Null)")
return(NULL)
}
@@ -1193,105 +1218,101 @@ uploadServer <- function(id, parent, globals) {
)
})
-#> Server
-split_data <- reactive({
-
- tmp_extensions <- tools::file_ext(input$split_uploadCAMfiles$name)
- print(tmp_extensions)
-
- ## if CAMEL data (checked by .txt ending)
-
- if (all(stringr::str_detect(string = tmp_extensions, pattern = "txt")) && length(tmp_extensions) == 3 && all(stringr::str_detect(string = input$split_uploadCAMfiles$name, pattern = "nodes|connectors|merged"))){
-
-
-tmp_names <- input$split_uploadCAMfiles$name
-tmp_datapat <- input$split_uploadCAMfiles$datapath
-
-CAMfiles <- list()
-CAMfiles[[1]] <- vroom::vroom(
- file = tmp_datapat[stringr::str_detect(string = tmp_names, pattern = "nodes")],
- delim = "\t",
- show_col_types = FALSE,
- col_names = TRUE
-)
-## trim whitespace
-CAMfiles[[1]]$text <-
- stringr::str_trim(string = CAMfiles[[1]]$text, side = "both")
+ #> Server
+ split_data <- reactive({
+
+ tmp_extensions <- tools::file_ext(input$split_uploadCAMfiles$name)
+ print(tmp_extensions)
+
+ ## if CAMEL data (checked by .txt ending)
- if(any(colnames(CAMfiles[[1]]) == "text_summarized")){
-## trim whitespace
-CAMfiles[[1]]$text_summarized <-
- stringr::str_trim(string = CAMfiles[[1]]$text_summarized, side = "both")
+ if (all(stringr::str_detect(string = tmp_extensions, pattern = "txt")) && length(tmp_extensions) == 3 && all(stringr::str_detect(string = input$split_uploadCAMfiles$name, pattern = "nodes|connectors|merged"))){
- ## remove white spaces before suffixes
- CAMfiles[[1]]$text_summarized <- str_remove_all(string = CAMfiles[[1]]$text_summarized, pattern = "\\s(?=(_neutral$|_positive$|_negative$|_ambivalent$))")
- }
-
+ tmp_names <- input$split_uploadCAMfiles$name
+ tmp_datapat <- input$split_uploadCAMfiles$datapath
+ CAMfiles <- list()
+ CAMfiles[[1]] <- vroom::vroom(
+ file = tmp_datapat[stringr::str_detect(string = tmp_names, pattern = "nodes")],
+ delim = "\t",
+ show_col_types = FALSE,
+ col_names = TRUE
+ )
+ ## trim whitespace
+ CAMfiles[[1]]$text <-
+ stringr::str_trim(string = CAMfiles[[1]]$text, side = "both")
-CAMfiles[[2]] <- vroom::vroom(
- file = tmp_datapat[stringr::str_detect(string = tmp_names, pattern = "connectors")],
- delim = "\t",
- show_col_types = FALSE,
- col_names = TRUE
-)
+ if(any(colnames(CAMfiles[[1]]) == "text_summarized")){
+ ## trim whitespace
+ CAMfiles[[1]]$text_summarized <-
+ stringr::str_trim(string = CAMfiles[[1]]$text_summarized, side = "both")
-CAMfiles[[3]] <- vroom::vroom(
- file = tmp_datapat[stringr::str_detect(string = tmp_names, pattern = "merged")],
- delim = "\t",
- show_col_types = FALSE,
- col_names = TRUE
-)
+ ## remove white spaces before suffixes
+ CAMfiles[[1]]$text_summarized <- str_remove_all(string = CAMfiles[[1]]$text_summarized, pattern = "\\s(?=(_neutral$|_positive$|_negative$|_ambivalent$))")
+ }
+
+ CAMfiles[[2]] <- vroom::vroom(
+ file = tmp_datapat[stringr::str_detect(string = tmp_names, pattern = "connectors")],
+ delim = "\t",
+ show_col_types = FALSE,
+ col_names = TRUE
+ )
+ CAMfiles[[3]] <- vroom::vroom(
+ file = tmp_datapat[stringr::str_detect(string = tmp_names, pattern = "merged")],
+ delim = "\t",
+ show_col_types = FALSE,
+ col_names = TRUE
+ )
- ## continue analysis
- v$df <- CAMfiles
- v$dataUploaded <- "yes"
+ ## continue analysis
+ v$df <- CAMfiles
+ v$dataUploaded <- "yes"
- } else {
- if(!all(stringr::str_detect(string = tmp_extensions, pattern = "txt")) || length(tmp_extensions) != 3){
- showModal(
- modalDialog(
- title = "Invalid raw data",
- paste0(
- "You have uploaded ", length(tmp_extensions), " files. Please upload exactly three files .txt files."
- ),
- easyClose = TRUE,
- footer = tagList(modalButton("Ok"))
- )
- )
- }else if(!all(stringr::str_detect(string = input$split_uploadCAMfiles$name, pattern = "nodes|connectors|merged"))){
- showModal(
- modalDialog(
- title = "Invalid raw data",
- paste0(
- "You have uploaded files with the following names: ", paste0(input$split_uploadCAMfiles$name, collapse = ", ")," files. Please upload exactly three .txt files containing the names nodes, connectors, merged."
- ),
- easyClose = TRUE,
- footer = tagList(modalButton("Ok"))
- )
- )
- }
- }
- })
+ } else {
+ if(!all(stringr::str_detect(string = tmp_extensions, pattern = "txt")) || length(tmp_extensions) != 3){
+ showModal(
+ modalDialog(
+ title = "Invalid raw data",
+ paste0(
+ "You have uploaded ", length(tmp_extensions), " files. Please upload exactly three files .txt files."
+ ),
+ easyClose = TRUE,
+ footer = tagList(modalButton("Ok"))
+ )
+ )
+ }else if(!all(stringr::str_detect(string = input$split_uploadCAMfiles$name, pattern = "nodes|connectors|merged"))){
+ showModal(
+ modalDialog(
+ title = "Invalid raw data",
+ paste0(
+ "You have uploaded files with the following names: ", paste0(input$split_uploadCAMfiles$name, collapse = ", ")," files. Please upload exactly three .txt files containing the names nodes, connectors, merged."
+ ),
+ easyClose = TRUE,
+ footer = tagList(modalButton("Ok"))
+ )
+ )
+ }
+ }
+ })
-observeEvent(input$split_uploadExcel, {
- showModal(
- modalDialog(
- title = "Will be implemented soon",
- paste0(
- "Just wait for it."
- ),
- easyClose = TRUE,
- footer = tagList(modalButton("Ok"))
- )
- )
-})
+ observeEvent(input$split_uploadExcel, {
+ showModal(
+ modalDialog(
+ title = "Will be implemented soon",
+ paste0(
+ "Just wait for it."
+ ),
+ easyClose = TRUE,
+ footer = tagList(modalButton("Ok"))
+ )
+ )
+ })
## wait for uploaded files ##
observeEvent(input$split_uploadCAMfiles, {
@@ -1320,11 +1341,11 @@ observeEvent(input$split_uploadExcel, {
tags$br(),
HTML(
'The tool is a shiny-App programmed in the R environment. Every time you have finished the central step of
- the module (here the Upload step) you can click "continue" in the bottom right to jump to the next
- module. This is just a recommended procedure, whereby the first two steps - uploading your data and draw your CAMs - is mandatory. Feel free to skip every other module.
- The central step within each module is depicted in bold.
-
- The application is divided in two central parts, whereby for the first part a protocol is generated, which should be uploaded together with the raw dataset(s).'
+ the module (here the Upload step) you can click "continue" in the bottom right to jump to the next
+ module. This is just a recommended procedure, whereby the first two steps - uploading your data and draw your CAMs - is mandatory. Feel free to skip every other module.
+ The central step within each module is depicted in bold.
+
+ The application is divided in two central parts, whereby for the first part a protocol is generated, which should be uploaded together with the raw dataset(s).'
),
tags$ol(tags$li(
HTML('Prep-rocessing Part: using multiple modules it is possible to summarize the CAM data semi-automatically')
From 1cf64f712021346ed677c4dd8705d6ca3a5694f5 Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Tue, 30 Sep 2025 20:56:18 +0200
Subject: [PATCH 8/9] small error catch
---
www/modules/uploadServer.R | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/www/modules/uploadServer.R b/www/modules/uploadServer.R
index 5581972..9c9b897 100644
--- a/www/modules/uploadServer.R
+++ b/www/modules/uploadServer.R
@@ -635,8 +635,11 @@ uploadServer <- function(id, parent, globals) {
# print(head(CAMfiles[[2]]))
# print(head(CAMfiles[[3]]))
- if(v$protocol){
+ print("Starting protocol-section")
+ tryCatch({
+ if(v$protocol){
#Possible error, if protocol()$software is NULL!
+ req(protocol())
globals$protocol$software <- protocol()$software
globals$protocol$cleanValence <- protocol()$cleanValence
@@ -685,7 +688,8 @@ uploadServer <- function(id, parent, globals) {
# print("globals$protocol:")
# print(globals$protocol)
- }
+ }}, error = function(e) {
+ print(paste("error in protocol section:", e$message))})
## save as global variable - else triggered to early
# print(globals$protocol$cleanValence)
From e07c776f0dcc4568f5c083e398ecd33482ac69ce Mon Sep 17 00:00:00 2001
From: moritzoc <93144026+moritzoc@users.noreply.github.com>
Date: Wed, 1 Oct 2025 09:47:16 +0200
Subject: [PATCH 9/9] typo: comment
---
www/modules/uploadServer.R | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/modules/uploadServer.R b/www/modules/uploadServer.R
index 9c9b897..8f16f2c 100644
--- a/www/modules/uploadServer.R
+++ b/www/modules/uploadServer.R
@@ -646,7 +646,7 @@ uploadServer <- function(id, parent, globals) {
## keep only CAMs which have not been deleted
if(length(protocol()$currentCAMs) > 0){
- print("tries to ony keep CAMs which have not been deleted?")
+ print("tries to only keep CAMs which have not been deleted")
# if participants IDs have been used in the draw CAM step
if(all(unlist(protocol()$currentCAMs) %in% CAMfiles[[1]]$CAM)){
CAMfiles[[1]] <- CAMfiles[[1]][CAMfiles[[1]]$CAM %in% unlist(protocol()$currentCAMs), ]