Skip to content

Commit 5288100

Browse files
committed
[all] show warnings (read-mode, data not avail.)
1 parent 4c12c60 commit 5288100

File tree

2 files changed

+88
-49
lines changed

2 files changed

+88
-49
lines changed

R_scripts/functions/fun_graphics.R

+5-2
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,6 @@ add.group.mean = function(data, y.col){
677677

678678
plot.sf.helper = function(data, ui.input, radial.profile = FALSE){
679679
data$SFI = data$dTSym
680-
681680
if (ui.input$sf_y_axis %in% colnames(data)){
682681
p = plot.sf.function(data = data,
683682
ui.input = ui.input,
@@ -690,7 +689,11 @@ plot.sf.helper = function(data, ui.input, radial.profile = FALSE){
690689
}
691690

692691
} else {
693-
p = plot.emptyMessage(message = "Sapwood depth is missing (see 'Settings')")
692+
if (ui.input$inputType == "HFD_processed_read"){
693+
p = plot.emptyMessage(message = "Metric not available for uploaded file.")
694+
} else {
695+
p = plot.emptyMessage(message = "Sapwood depth is missing (see 'Settings')")
696+
}
694697
}
695698
return(p)
696699
}

server.R

+83-47
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ shinyServer(function(input, output, session) {
195195
swd = sapWoodDepth())
196196
}
197197
)
198+
198199
if (is.character(out)){
199200
return(NULL)
200201
} else {
@@ -326,6 +327,7 @@ shinyServer(function(input, output, session) {
326327
data = rawData()
327328
positions = get.positionsFromRawData(dataSource = data,
328329
input = input)
330+
329331
if (input$inputType == "HFD_raw"){
330332
d = get.delta.from.temp(data, positions)
331333
}
@@ -376,16 +378,26 @@ shinyServer(function(input, output, session) {
376378
#' Button to load filter options
377379
#' Assigns unfiltered, long-format data as reactive
378380
#' value 'deltaTempLong'
379-
observeEvent(input$LoadFilter, {
380-
values$deltaTempLong <- deltaTempLongNoFilter()
381+
observeEvent(input$LoadFilter, {
382+
if (input$inputType == "HFD_processed_read"){
383+
showNotification("Read-only modus. Filter can't be applied.",
384+
type = "warning")
385+
} else {
386+
values$deltaTempLong <- deltaTempLongNoFilter()
387+
}
381388
})
382389

383390
#' Button to apply filter
384391
#' Assigns filterd, long-format data as reactive
385392
#' value 'deltaTempLong'
386393
observeEvent(input$FilterApply, {
387-
values$deltaTempLong <- get.filteredData(data = values$deltaTempLong,
388-
ui.input = input)
394+
if (input$inputType == "HFD_processed_read"){
395+
showNotification("Read-only modus. Filter can't be applied.",
396+
type = "warning")
397+
} else {
398+
values$deltaTempLong <- get.filteredData(data = values$deltaTempLong,
399+
ui.input = input)
400+
}
389401
})
390402

391403
#' Button to delete filter
@@ -719,14 +731,19 @@ shinyServer(function(input, output, session) {
719731
if (click == 1){
720732
emptyKvalues()
721733
}
722-
if (input$kMethod == "regression"){
723-
method_name = method_name_reg(ui.input = input)
734+
if (input$inputType == "HFD_processed_read"){
735+
showNotification("Read-only modus. K can't be modified.",
736+
type = "warning")
724737
} else {
725-
method_name = gsub(".", "-", input$kMethod, fixed = TRUE)
738+
if (input$kMethod == "regression"){
739+
method_name = method_name_reg(ui.input = input)
740+
} else {
741+
method_name = gsub(".", "-", input$kMethod, fixed = TRUE)
742+
}
743+
values$kvalues[values$kvalues$position == input$kPositionSelect, 2:3] <- cbind(
744+
method = as.character(method_name),
745+
k = kValue())
726746
}
727-
values$kvalues[values$kvalues$position == input$kPositionSelect, 2:3] <- cbind(
728-
method = as.character(method_name),
729-
k = kValue())
730747
})
731748

732749
#' Eventlistener to store k-values from csv upload
@@ -959,14 +976,18 @@ shinyServer(function(input, output, session) {
959976
#' Reactive variable holding daily tree water
960977
#' use in kg per h and kg per day
961978
#' for selected method
962-
treeWaterUse <- reactive({
963-
if (all(is.na(values$kvalues$k))){
964-
return(tab.with.message(message.no.k))
965-
} else if (get.sapFlowSum() == 0){
966-
tab.with.message(message.no.sapflow)
967-
} else {
968-
get.treeWaterUseByMethod(data = sapFlow(),
969-
ui.input = input)
979+
treeWaterUse <- reactive({
980+
if (all(is.na(values$kvalues$k))) {
981+
return(tab.with.message(message.no.k))
982+
} else if (get.sapFlowSum() == 0) {
983+
if (input$inputType == "HFD_processed_read") {
984+
tab.with.message("Metric not available for uploaded file.")
985+
} else {
986+
tab.with.message(message.no.sapflow)
987+
}
988+
} else {
989+
get.treeWaterUseByMethod(data = sapFlow(),
990+
ui.input = input)
970991
}
971992
})
972993

@@ -1113,13 +1134,26 @@ shinyServer(function(input, output, session) {
11131134

11141135

11151136
##### Sap Flow Rate #####
1137+
1138+
get.sfplot.empty = reactive({
1139+
if (input$inputType == "HFD_processed_read" ){
1140+
return(plot.emptyMessage(message = "Metric not available for uploaded file."))
1141+
} else {
1142+
return(plot.emptyMessage(message = message.no.sapflow))
1143+
}
1144+
})
1145+
11161146
###### Diurnal Pattern ######
11171147

11181148
get.sapFlowSum = reactive({
11191149
if (click() > 0){
11201150
groups = get.selectedMethods(input)
11211151
sapFlow = sapFlow()
1122-
return(sum(sapFlow[, groups], na.rm = T))
1152+
if (any(groups %in% colnames(sapFlow))) {
1153+
return(sum(sapFlow[, groups], na.rm = T))
1154+
} else {
1155+
return(0)
1156+
}
11231157
} else {
11241158
return(0)
11251159
}
@@ -1129,16 +1163,16 @@ shinyServer(function(input, output, session) {
11291163
#' Reactive variable holding figure of sap flow rate
11301164
#' for selected methods
11311165
sapFlowTreePlot <- reactive({
1132-
if (all(is.na(values$kvalues$k))){
1133-
plot.emptyMessage(message = message.no.k)
1134-
} else {
1135-
if (get.sapFlowSum() == 0){
1136-
plot.emptyMessage(message = message.no.sapflow)
1137-
} else {
1138-
plot.sapFlowRate(data = sapFlow(),
1139-
ui.input = input)
1140-
}
1141-
}
1166+
if (all(is.na(values$kvalues$k))) {
1167+
plot.emptyMessage(message = message.no.k)
1168+
} else {
1169+
if (get.sapFlowSum() == 0) {
1170+
get.sfplot.empty()
1171+
} else {
1172+
plot.sapFlowRate(data = sapFlow(),
1173+
ui.input = input)
1174+
}
1175+
}
11421176
})
11431177

11441178
#' Eventlistener to show figure of sap flow rate
@@ -1170,15 +1204,15 @@ shinyServer(function(input, output, session) {
11701204
#' Reactive variable holding figure of daily water balance
11711205
#' for selected methods
11721206
TWUbarplot <- reactive({
1173-
if (all(is.na(values$kvalues$k))){
1174-
plot.emptyMessage(message = message.no.k)
1175-
} else {
1176-
if (get.sapFlowSum() == 0){
1177-
plot.emptyMessage(message = message.no.sapflow)
1178-
} else {
1179-
plot.sapFlowDay(data = sapFlow(),
1180-
ui.input = input)
1181-
}
1207+
if (all(is.na(values$kvalues$k))) {
1208+
plot.emptyMessage(message = message.no.k)
1209+
} else {
1210+
if (get.sapFlowSum() == 0) {
1211+
get.sfplot.empty()
1212+
} else {
1213+
plot.sapFlowDay(data = sapFlow(),
1214+
ui.input = input)
1215+
}
11821216
}
11831217
})
11841218

@@ -1202,15 +1236,17 @@ shinyServer(function(input, output, session) {
12021236
#' Reactive variable holding figure of daily water balance
12031237
#' for selected methods
12041238
TWUradialprofilePlot <- reactive({
1205-
if (all(is.na(values$kvalues$k))){
1206-
plot.emptyMessage(message = message.no.k)
1207-
} else {
1208-
if (get.sapFlowSum() == 0){
1209-
plot.emptyMessage(message = message.no.sapflow)
1210-
} else {
1211-
plot.twu.radialprofile(data = sapFlow(),
1212-
ui.input = input)
1213-
}
1239+
if (all(is.na(values$kvalues$k))) {
1240+
plot.emptyMessage(message = message.no.k)
1241+
} else {
1242+
if (get.sapFlowSum() == 0) {
1243+
get.sfplot.empty()
1244+
} else if (input$treeScaleSimple1 | input$treeScaleSimple3) {
1245+
plot.twu.radialprofile(data = sapFlow(),
1246+
ui.input = input)
1247+
} else {
1248+
plot.emptyMessage(message = "Radial profile not available for method 2.")
1249+
}
12141250
}
12151251
})
12161252

0 commit comments

Comments
 (0)