Skip to content

Commit

Permalink
addeda unique error/warning/message system with specified colors for …
Browse files Browse the repository at this point in the history
…each case red/orange/blue
  • Loading branch information
Konrad1991 committed Dec 12, 2024
1 parent 915f2a7 commit dc209c0
Show file tree
Hide file tree
Showing 19 changed files with 584 additions and 514 deletions.
4 changes: 2 additions & 2 deletions app/DoseResponse.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ DoseResponseServer <- function(id, data, listResults) {
neg <- input$negIdentifier
req(input$posIdentifier)
pos <- input$posIdentifier
print_noti(!is.null(data$formula), "You have to set a formula")
print_req(!is.null(data$formula), "You have to set a formula")
req(!is.null(data$formula))
r_vals$plots <- NULL # reset
r_vals$names <- NULL # reset
Expand Down Expand Up @@ -258,7 +258,7 @@ DoseResponseServer <- function(id, data, listResults) {
})
if (inherits(e, "try-error")) {
err <- conditionMessage(attr(e, "condition"))
print_noti(FALSE, err)
print_req(FALSE, err)
} else {
listResults$curr_data <- new("doseResponse", df = resDF, p = resPlot)
listResults$curr_name <- paste("Test Nr", length(listResults$all_names) + 1, "Conducted dose response analysis")
Expand Down
8 changes: 4 additions & 4 deletions app/MainApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,15 @@ app <- function() {
})

observeEvent(input$download, {
print_noti(is_valid_filename(input$user_filename), "Defined filename is not valid")
print_noti(length(listResults$all_data) > 0, "No results to save")
print_req(is_valid_filename(input$user_filename), "Defined filename is not valid")
print_req(length(listResults$all_data) > 0, "No results to save")
l <- listResults$all_data
if (Sys.getenv("RUN_MODE") == "SERVER") {
print_noti(check_filename_for_server(input$user_filename), "Defined filename does not have xlsx as extension")
print_req(check_filename_for_server(input$user_filename), "Defined filename does not have xlsx as extension")
excelFile <- createExcelFile(l)
upload(session, excelFile, new_name = input$user_filename)
} else {
print_noti(check_filename_for_serverless(input$user_filename), "Defined filename does not have zip as extension")
print_req(check_filename_for_serverless(input$user_filename), "Defined filename does not have zip as extension")
jsString <- createJSString(l)
session$sendCustomMessage(
type = "downloadZip",
Expand Down
8 changes: 4 additions & 4 deletions app/assumption.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ assServer <- function(id, data, listResults) {
output$curr_error <- renderText(err)
} else {
err <- conditionMessage(attr(e, "condition"))
print_noti(FALSE, err)
print_req(FALSE, err)
}
}
}
Expand Down Expand Up @@ -207,7 +207,7 @@ assServer <- function(id, data, listResults) {
output$curr_error <- renderText(err)
} else {
err <- conditionMessage(attr(e, "condition"))
print_noti(FALSE, err)
print_req(FALSE, err)
}
}
observeEvent(input$shapiroResiduals, {
Expand All @@ -227,7 +227,7 @@ assServer <- function(id, data, listResults) {
}, silent = TRUE)
if (inherits(e, "try-error")) {
err <- conditionMessage(attr(e, "condition"))
print_noti(FALSE, err)
print_req(FALSE, err)
} else {
exportTestValues(
assumption_res = fit
Expand Down Expand Up @@ -256,7 +256,7 @@ assServer <- function(id, data, listResults) {
}, silent = TRUE)
if (inherits(e, "try-error")) {
err <- conditionMessage(attr(e, "condition"))
print_noti(FALSE, err)
print_req(FALSE, err)
} else {
exportTestValues(
assumption_res = p
Expand Down
10 changes: 7 additions & 3 deletions app/correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ corrServer <- function(id, data, listResults) {
})

corr_fct <- function(method) {
req(is.data.frame(data$df))
req(!is.null(data$formula))
print(is.data.frame(data$df))
str(data$formula)
print_req(is.data.frame(data$df), "The dataset is missing")
# req(is.data.frame(data$df))
# req(!is.null(data$formula))
print_req(!is.null(data$formula), "The formula is missing")
f <- as.character(data$formula)
dep <- f[2]
indep <- f[3]
Expand Down Expand Up @@ -158,7 +162,7 @@ corrServer <- function(id, data, listResults) {
error = function(err) {
err <- err$message
showNotification(err)
print_noti(FALSE, err)
print_req(FALSE, err)
}
)
}
Expand Down
6 changes: 3 additions & 3 deletions app/statisticalTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ testsServer <- function(id, data, listResults) {
})
if (inherits(e, "try-error")) {
err <- conditionMessage(attr(e, "condition"))
print_noti(FALSE, err)
print_req(FALSE, err)
} else {
listResults$counter <- listResults$counter + 1
new_name <- paste0(
Expand Down Expand Up @@ -300,10 +300,10 @@ testsServer <- function(id, data, listResults) {
if (inherits(e, "try-error")) {
err <- conditionMessage(attr(e, "condition"))
err <- paste0(err, "\n", "Test did not run successfully")
print_noti(FALSE, err)
print_req(FALSE, err)
} else if (is.null(fit)) {
err <- paste0(err, "\n", "Test did not run successfully")
print_noti(FALSE, err)
print_req(FALSE, err)
} else {
fit <- cbind(fit, row.names(fit))
names(fit)[ncol(fit)] <- paste0(indep, collapse = ".")
Expand Down
2 changes: 1 addition & 1 deletion app/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ split <- function(df, cols, levels) {
}

# check and print notifications
print_noti <- function(expr, message) {
print_req <- function(expr, message) {
if (!expr) {
showNotification(message)
}
Expand Down
12 changes: 6 additions & 6 deletions app/visualisation.R
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,18 @@ visServer <- function(id, data, listResults) {
x <- input$xVar
y <- input$yVar
colNames <- names(df)
print_noti(x %in% colNames, "X variable not found")
print_noti(y %in% colNames, "Y variable not found")
print_req(x %in% colNames, "X variable not found")
print_req(y %in% colNames, "Y variable not found")
width <- input$widthPlot
height <- input$heightPlot
resolution <- input$resPlot
print_noti(width > 0, "width has to be a positive number; It is changed to 10 cm")
print_req(width > 0, "width has to be a positive number; It is changed to 10 cm")
if (width <= 0) width <- 10
print_noti(height > 0, "height has to be a positive number; It is changed to 10 cm")
print_req(height > 0, "height has to be a positive number; It is changed to 10 cm")
if (height <= 0) height <- 10
print_noti(width < 100, "width exceeds max value of 100; It is changed to 100 cm")
print_req(width < 100, "width exceeds max value of 100; It is changed to 100 cm")
if (width > 100) width <- 100
print_noti(height < 100, "height exceeds max value of 100; It is changed to 100 cm")
print_req(height < 100, "height exceeds max value of 100; It is changed to 100 cm")
if (height > 100) height <- 100
col <- input$col
fill <- input$fill
Expand Down
Loading

0 comments on commit dc209c0

Please sign in to comment.