moduleConfig.R 53 KB
Newer Older
1
2
# DQAgui - A graphical user interface (GUI) to the functions implemented in the
# R package 'DQAstats'.
Jonathan Mang's avatar
Jonathan Mang committed
3
# Copyright (C) 2019-2020 Universitätsklinikum Erlangen
Lorenz Kapsner's avatar
Lorenz Kapsner committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

18

19
#' @title module_config_server
kapsner's avatar
kapsner committed
20
21
22
23
24
#'
#' @param input Shiny server input object
#' @param output Shiny server output object
#' @param session Shiny session object
#' @param rv The global 'reactiveValues()' object, defined in server.R
25
26
#' @param input_re The Shiny server input object, wrapped into a reactive
#'   expression: input_re = reactive({input})
kapsner's avatar
kapsner committed
27
28
29
#'
#' @export
#'
30
# module_config_server
31
32
33
module_config_server <-
  function(input, output, session, rv, input_re) {
    # filepath roots dir
34
    roots <- c(home = "/home/")
35
36
37
38
39

    # If source-csv-path-button is clicked, read the path and save it:
    # root-folder of shinyFiles::shinyDirChoose
    shinyFiles::shinyDirChoose(
      input = input,
40
41
42
      id = "config_sourcedir_in",
      roots = roots,
      session = session
43
    )
44
45
46

    shinyFiles::shinyDirChoose(
      input = input,
47
48
49
      id = "config_targetdir_in",
      roots = roots,
      session = session
50
    )
51
52

    # observe click button event
53
    observeEvent(
54
      eventExpr = input$config_sourcedir_in,
55
      handlerExpr = {
56
        rv$csv_dir_src_clicked <- FALSE
Lorenz Kapsner's avatar
Lorenz Kapsner committed
57
        rv$csv_dir_src <- as.character(
Jonathan Mang's avatar
Jonathan Mang committed
58
          DIZutils::clean_path_name(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
59
60
61
62
            shinyFiles::parseDirPath(
              roots = roots,
              selection = input$config_sourcedir_in
            )))
63

64
        rv$source$settings$path <- rv$csv_dir_src
65

66
67
68
        if (!identical(rv$source$settings$path, character(0)) &&
            !is.null(rv$source$settings$path) &&
            rv$source$settings$path != "") {
69
70
          # workaround to tell ui, that it is there
          output$source_csv_dir <- reactive({
Jonathan Mang's avatar
Jonathan Mang committed
71
            DIZutils::feedback(
72
              paste0("Source file dir: ",
73
                     rv$source$settings$path),
74
75
76
77
              findme = "ad440c9fcb",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
78
            paste(rv$source$settings$path)
79
80
          })
          outputOptions(output, "source_csv_dir", suspendWhenHidden = FALSE)
81
82
          rv$source$system_name <-
            input_re()[["moduleConfig-source_csv_presettings_list"]]
83
          rv$source$system_type <- "csv"
84
85
86
87
          DIZutils::feedback(
            paste0("rv$source$system_type = ",
                   rv$source$system_type),
            findme = "91ebdd5a1d")
88
89
90
91
92
          output$source_system_feedback_txt <-
            renderText({
              feedback_txt(system = "CSV", type = "source")
            })
        }
93
        check_load_data_button(rv, session)
94
      }
95
96
97
98
    )
    observeEvent(
      eventExpr = input$config_targetdir_in,
      handlerExpr = {
99
        rv$csv_dir_tar_clicked <- FALSE
Lorenz Kapsner's avatar
Lorenz Kapsner committed
100
        rv$csv_dir_tar <- as.character(
Jonathan Mang's avatar
Jonathan Mang committed
101
          DIZutils::clean_path_name(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
102
103
104
105
            shinyFiles::parseDirPath(
              roots = roots,
              selection = input$config_targetdir_in
            )))
106
        rv$target$settings$path <- rv$csv_dir_tar
107

108
109
110
        if (!identical(rv$target$settings$path, character(0)) &&
            !is.null(rv$target$settings$path) &&
            rv$target$settings$path != "") {
111
112
          # workaround to tell ui, that it is there
          output$target_csv_dir <- reactive({
Jonathan Mang's avatar
Jonathan Mang committed
113
            DIZutils::feedback(
114
              paste0("Target file dir: ",
115
                     rv$target$settings$path),
116
117
118
119
              findme = "6f18c181e5",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
120
            paste(rv$target$settings$path)
121
122
          })
          outputOptions(output, "target_csv_dir", suspendWhenHidden = FALSE)
123
124
          rv$target$system_name <-
            input_re()[["moduleConfig-target_csv_presettings_list"]]
125
          rv$target$system_type <- "csv"
126
127
128
129
          DIZutils::feedback(
            paste0("rv$target$system_type = ",
                   rv$target$system_type),
            findme = "4690c52739")
130
131
132
133
134
          output$target_system_feedback_txt <-
            renderText({
              feedback_txt(system = "CSV", type = "target")
            })
        }
135
        check_load_data_button(rv, session)
136
      }
137
    )
138

139
140
141
142
143
    # load mdr
    observeEvent(
      eventExpr = input_re()[["moduleConfig-config_load_mdr"]],
      handlerExpr = {
        if (is.null(rv$mdr)) {
Jonathan Mang's avatar
Jonathan Mang committed
144
          DIZutils::feedback(
145
146
147
148
149
            print_this = "Reading MDR ...",
            findme = "f877fee7d2",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
Jonathan Mang's avatar
Jonathan Mang committed
150
          DIZutils::feedback(
151
152
            print_this = paste0("MDR-Filename:",
                                rv$mdr_filename),
153
154
155
156
            findme = "582d6a39c6",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
Jonathan Mang's avatar
Jonathan Mang committed
157
          DIZutils::feedback(
158
159
            print_this = paste0("rv$utilspath:",
                                rv$utilspath),
160
161
162
163
            findme = "b5c71849f9",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
164

Lorenz Kapsner's avatar
Lorenz Kapsner committed
165
166
167
168
169
170
          rv$mdr <- button_mdr(
            utils_path = rv$utilspath,
            mdr_filename = rv$mdr_filename,
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
171
172
          stopifnot(data.table::is.data.table(rv$mdr))

173
174
175
          ## Read in the settings
          # - Determine the different systems from mdr:
          vec <-
176
            c("source_system_name",
177
178
              "source_system_type")
          rv$systems <- unique(rv$mdr[, vec, with = F])
Jonathan Mang's avatar
Jonathan Mang committed
179
          DIZutils::feedback(
180
181
182
183
184
            print_this = "Different systems found in MDR:",
            findme = "4451da82ad",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
185

186
187
188
189
          # - Read the settings for all these systems:
          unique_systems <-
            rv$systems[!is.na(get("source_system_name")),
                       unique(get("source_system_name"))]
190

191
          # FIXME remove settings reading in the future
192
          rv$settings <-
193
            sapply(unique_systems, function(x) {
194
195
              DIZutils::get_config_env(
                system_name = x,
196
197
198
                logfile_dir = rv$log$logfile_dir,
                headless = rv$headless
              )
199
            }, USE.NAMES = T, simplify = F)
200

201
202
203
204
          # - Different system-types:
          rv$system_types <-
            rv$systems[!is.na(get("source_system_type")),
                       unique(get("source_system_type"))]
205

Jonathan Mang's avatar
Jonathan Mang committed
206
          DIZutils::feedback(
207
208
209
210
211
212
            print_this = rv$system_types,
            prefix = "System type ",
            findme = "9aec84fcca",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
213

214
215
          if (!("csv" %in% tolower(rv$system_types))) {
            # Remove CSV-Tabs:
Jonathan Mang's avatar
Jonathan Mang committed
216
            DIZutils::feedback(
217
              "Removing csv-tab from source ...",
218
219
220
221
              findme = "3c2f368001",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
222
223
            removeTab(inputId = "source_tabs", target = "CSV")

Jonathan Mang's avatar
Jonathan Mang committed
224
            DIZutils::feedback(
225
              "Removing csv-tab from target ...",
226
227
228
229
              findme = "337b20a126",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
230
231
232
233
234
235
            removeTab(inputId = "target_tabs", target = "CSV")
          } else {
            csv_system_names <-
              rv$systems[get("source_system_type") == "csv" &
                           !is.na(get("source_system_name")),
                         unique(get("source_system_name"))]
Jonathan Mang's avatar
Jonathan Mang committed
236
            DIZutils::feedback(
237
238
239
240
241
242
              csv_system_names,
              prefix = "csv_system_names: ",
              findme = "5a083a3d53",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
243
244
245
246

            if (length(csv_system_names) > 0) {
              # Show buttons to prefill diff. systems presettings:
              # - Add a button/choice/etc. for each system:
247
248
249
250
251
252
              updateSelectInput(session = session,
                                inputId = "source_csv_presettings_list",
                                choices = csv_system_names)
              updateSelectInput(session = session,
                                inputId = "target_csv_presettings_list",
                                choices = csv_system_names)
253
254
255
256
            }
          }
          if (!("postgres" %in% tolower(rv$system_types))) {
            # Remove Postgres-Tabs:
Jonathan Mang's avatar
Jonathan Mang committed
257
            DIZutils::feedback(
258
259
260
261
              "Removing postgres-tab from source ...",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
262
263
            removeTab(inputId = "source_tabs", target = "PostgreSQL")

Jonathan Mang's avatar
Jonathan Mang committed
264
            DIZutils::feedback(
265
266
267
268
              "Removing postgres-tab from target ...",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
269
270
271
272
273
274
275
276
277
278
279
280
            removeTab(inputId = "target_tabs", target = "PostgreSQL")
          } else{
            # Fill the tab with presettings
            # - filter for all system_names with
            #% system_type == postgres
            #% select source_system_name from
            #% rv$systems where source_system_type == postgres
            #% GROUP BY source_system_name
            postgres_system_names <-
              rv$systems[get("source_system_type") == "postgres" &
                           !is.na(get("source_system_name")),
                         unique(get("source_system_name"))]
Jonathan Mang's avatar
Jonathan Mang committed
281
            DIZutils::feedback(
282
283
284
285
286
287
              postgres_system_names,
              prefix = "postgres_system_names: ",
              findme = "be136f5ab6",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )
288
289
290
291

            if (length(postgres_system_names) > 0) {
              # Show buttons to prefill diff. systems presettings:
              # - Add a button/choice/etc. for each system:
292
              updateSelectInput(session = session,
293
                                inputId = "source_postgres_presettings_list",
294
295
                                choices = postgres_system_names)
              updateSelectInput(session = session,
296
                                inputId = "target_postgres_presettings_list",
297
                                choices = postgres_system_names)
298
299
            }
          }
Jonathan Mang's avatar
Jonathan Mang committed
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
          if (!("oracle" %in% tolower(rv$system_types))) {
            # Remove Oracle-Tabs:
            DIZutils::feedback(
              "Removing oracle-tab from source ...",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless,
              findme = "8e93367dec"
            )
            removeTab(inputId = "source_tabs", target = "Oracle")

            DIZutils::feedback(
              "Removing oracle-tab from target ...",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless,
              findme = "1c2023da56"
            )
            removeTab(inputId = "target_tabs", target = "Oracle")
          } else{
            # Fill the tab with presettings
            # - filter for all system_names with
            #% system_type == oracle
            #% select source_system_name from
            #% rv$systems where source_system_type == oracle
            #% GROUP BY source_system_name
            oracle_system_names <-
              rv$systems[get("source_system_type") == "oracle" &
                           !is.na(get("source_system_name")),
                         unique(get("source_system_name"))]
            DIZutils::feedback(
              oracle_system_names,
              prefix = "oracle_system_names: ",
              findme = "bea2cd91a1",
              logfile_dir = rv$log$logfile_dir,
              headless = rv$headless
            )

            if (length(oracle_system_names) > 0) {
              # Show buttons to prefill diff. systems presettings:
              # - Add a button/choice/etc. for each system:
              updateSelectInput(session = session,
                                inputId = "source_oracle_presettings_list",
                                choices = oracle_system_names)
              updateSelectInput(session = session,
                                inputId = "target_oracle_presettings_list",
                                choices = oracle_system_names)
            }
          }

348
349
350
351
352
353
354
355
356

          # Store the system-types in output-variable to only
          # show these tabs on the config page:
          output$system_types <- reactive({
            rv$system_types
          })
          outputOptions(output,
                        "system_types",
                        suspendWhenHidden = FALSE)
357
358

          # workaround to tell ui, that mdr is there
359
360
361
          output$mdr_present <- reactive({
            return(TRUE)
          })
362
363
364
365
366
367
368
369
370
371
372
373
          outputOptions(output,
                        "mdr_present",
                        suspendWhenHidden = FALSE)

          # workaround to tell ui, that mdr is there
          output$source_system_type <- reactive({
            return(input_re()
                   [["moduleConfig-config_source_system_type"]])
          })
          outputOptions(output,
                        "source_system_type",
                        suspendWhenHidden = FALSE)
374
375
376
377
          output$source_system_feedback_txt <-
            renderText({
              "\U26A0 Please select a source system to load the data."
            })
378
        }
379
        check_load_data_button(rv, session)
380
      })
kapsner's avatar
kapsner committed
381
382


383
384
    # If the "load presets"-button was pressed, startload & show the presets:
    # observeEvent(input$source_pg_presettings_btn, {
385
    observeEvent(input$source_postgres_presettings_list, {
Jonathan Mang's avatar
Jonathan Mang committed
386
      DIZutils::feedback(
387
388
389
        print_this =
          paste0(
            "Input-preset ",
390
            input$source_postgres_presettings_list,
391
392
393
            " was chosen as SOURCE.",
            " Loading presets ..."
          ),
394
395
396
        findme = "e9832b3092",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
kapsner's avatar
kapsner committed
397
      )
398
      config_stuff <- rv$settings[[tolower(input$source_postgres_presettings_list)]]
399

Jonathan Mang's avatar
Jonathan Mang committed
400
      DIZutils::feedback(
401
402
403
404
        print_this = paste(
          "Loaded successfully.",
          "Filling presets to global rv-object and UI ..."
        ),
405
406
407
        findme = "3c9136d49f",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
408
      )
409
410
      if (length(config_stuff) != 0) {
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
                        inputId = "config_source_postgres_dbname",
                        value = config_stuff[["dbname"]])
        updateTextInput(session = session,
                        inputId = "config_source_postgres_host",
                        value = config_stuff[["host"]])
        updateTextInput(session = session,
                        inputId = "config_source_postgres_port",
                        value = config_stuff[["port"]])
        updateTextInput(session = session,
                        inputId = "config_source_postgres_user",
                        value = config_stuff[["user"]])
        updateTextInput(session = session,
                        inputId = "config_source_postgres_password",
                        value = config_stuff[["password"]])
      } else{
        updateTextInput(session = session,
                        inputId = "config_source_postgres_dbname",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_source_postgres_host",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_source_postgres_port",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_source_postgres_user",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_source_postgres_password",
                        value = "")
      }
      updateActionButton(
        session = session,
        inputId = "source_postgres_test_connection",
        label = "Test & Save connection",
        icon = icon("database")
      )
      shinyjs::enable("source_postgres_test_connection")
    })

    observeEvent(input$source_oracle_presettings_list, {
      DIZutils::feedback(
        print_this =
          paste0(
            "Input-preset ",
            input$source_oracle_presettings_list,
            " was chosen as SOURCE.",
            " Loading presets ..."
          ),
        findme = "44179e7b1f",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
      )
      config_stuff <- rv$settings[[tolower(input$source_oracle_presettings_list)]]

      DIZutils::feedback(
        print_this = paste(
          "Loaded successfully.",
          "Filling presets to global rv-object and UI ..."
        ),
        findme = "ff874cb58d",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
      )
      if (length(config_stuff) != 0) {
        updateTextInput(session = session,
                        inputId = "config_source_oracle_dbname",
478
479
                        value = config_stuff[["dbname"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
480
                        inputId = "config_source_oracle_host",
481
482
                        value = config_stuff[["host"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
483
                        inputId = "config_source_oracle_port",
484
485
                        value = config_stuff[["port"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
486
                        inputId = "config_source_oracle_user",
487
488
                        value = config_stuff[["user"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
489
                        inputId = "config_source_oracle_password",
490
                        value = config_stuff[["password"]])
Jonathan Mang's avatar
Jonathan Mang committed
491
492
493
        updateTextInput(session = session,
                        inputId = "config_source_oracle_sid",
                        value = config_stuff[["sid"]])
494
495
      } else{
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
496
497
498
499
                        inputId = "config_source_oracle_dbname",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_source_oracle_host",
500
501
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
502
                        inputId = "config_source_oracle_port",
503
504
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
505
                        inputId = "config_source_oracle_user",
506
507
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
508
                        inputId = "config_source_oracle_password",
509
510
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
511
                        inputId = "config_source_oracle_sid",
512
513
                        value = "")
      }
514
515
      updateActionButton(
        session = session,
Jonathan Mang's avatar
Jonathan Mang committed
516
        inputId = "source_oracle_test_connection",
517
518
519
        label = "Test & Save connection",
        icon = icon("database")
      )
Jonathan Mang's avatar
Jonathan Mang committed
520
      shinyjs::enable("source_oracle_test_connection")
521
522
    })

Jonathan Mang's avatar
Jonathan Mang committed
523

524
    #observeEvent(input$target_pg_presettings_btn, {
525
    observeEvent(input$target_postgres_presettings_list, {
Jonathan Mang's avatar
Jonathan Mang committed
526
      DIZutils::feedback(
527
528
        paste0(
          "Input-preset ",
529
          input$target_postgres_presettings_list,
Jonathan Mang's avatar
Jonathan Mang committed
530
          " was chosen as TARGET.",
531
          " Loading presets ..."
532
533
534
535
        ),
        findme = "d603f8127a",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
536
      )
537
      config_stuff <- rv$settings[[tolower(input$target_postgres_presettings_list)]]
538

Jonathan Mang's avatar
Jonathan Mang committed
539
      DIZutils::feedback(
540
541
542
543
544
545
546
547
        paste(
          "Loaded successfully.",
          "Filling presets to global rv-object and UI ..."
        ),
        findme = "fa908f0035",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
      )
548
549
      if (length(config_stuff) != 0) {
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
550
                        inputId = "config_target_postgres_dbname",
551
552
                        value = config_stuff[["dbname"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
553
                        inputId = "config_target_postgres_host",
554
555
                        value = config_stuff[["host"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
556
                        inputId = "config_target_postgres_port",
557
558
                        value = config_stuff[["port"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
559
                        inputId = "config_target_postgres_user",
560
561
                        value = config_stuff[["user"]])
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
562
                        inputId = "config_target_postgres_password",
563
564
565
                        value = config_stuff[["password"]])
      } else{
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
566
                        inputId = "config_target_postgres_dbname",
567
568
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
569
                        inputId = "config_target_postgres_host",
570
571
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
572
                        inputId = "config_target_postgres_port",
573
574
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
575
                        inputId = "config_target_postgres_user",
576
577
                        value = "")
        updateTextInput(session = session,
Jonathan Mang's avatar
Jonathan Mang committed
578
                        inputId = "config_target_postgres_password",
579
580
                        value = "")
      }
581
582
      updateActionButton(
        session = session,
Jonathan Mang's avatar
Jonathan Mang committed
583
        inputId = "target_postgres_test_connection",
584
585
586
        label = "Test & Save connection",
        icon = icon("database")
      )
Jonathan Mang's avatar
Jonathan Mang committed
587
      shinyjs::enable("target_postgres_test_connection")
588
    })
kapsner's avatar
kapsner committed
589

Jonathan Mang's avatar
Jonathan Mang committed
590
591
592
593
594
595
596
597
598
599
600
601
602
    observeEvent(input$target_oracle_presettings_list, {
      DIZutils::feedback(
        paste0(
          "Input-preset ",
          input$target_oracle_presettings_list,
          " was chosen as TARGET.",
          " Loading presets ..."
        ),
        findme = "1156504e13",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
      )
      config_stuff <- rv$settings[[tolower(input$target_oracle_presettings_list)]]
kapsner's avatar
kapsner committed
603

Jonathan Mang's avatar
Jonathan Mang committed
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
      DIZutils::feedback(
        paste(
          "Loaded successfully.",
          "Filling presets to global rv-object and UI ..."
        ),
        findme = "3d39553c3c",
        logfile_dir = rv$log$logfile_dir,
        headless = rv$headless
      )
      if (length(config_stuff) != 0) {
        updateTextInput(session = session,
                        inputId = "config_target_oracle_dbname",
                        value = config_stuff[["dbname"]])
        updateTextInput(session = session,
                        inputId = "config_target_oracle_host",
                        value = config_stuff[["host"]])
        updateTextInput(session = session,
                        inputId = "config_target_oracle_port",
                        value = config_stuff[["port"]])
        updateTextInput(session = session,
                        inputId = "config_target_oracle_user",
                        value = config_stuff[["user"]])
        updateTextInput(session = session,
                        inputId = "config_target_oracle_password",
                        value = config_stuff[["password"]])
        updateTextInput(session = session,
                        inputId = "config_target_oracle_sid",
                        value = config_stuff[["sid"]])
      } else{
        updateTextInput(session = session,
                        inputId = "config_target_oracle_dbname",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_target_oracle_host",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_target_oracle_port",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_target_oracle_user",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_target_oracle_password",
                        value = "")
        updateTextInput(session = session,
                        inputId = "config_target_oracle_sid",
                        value = "")
651
      }
Jonathan Mang's avatar
Jonathan Mang committed
652
653
654
655
656
657
658
      updateActionButton(
        session = session,
        inputId = "target_oracle_test_connection",
        label = "Test & Save connection",
        icon = icon("database")
      )
      shinyjs::enable("target_oracle_test_connection")
659
    })
kapsner's avatar
kapsner committed
660

661

Jonathan Mang's avatar
Jonathan Mang committed
662
663
664
665
666
667
668
669
670
671
    observeEvent(input$source_postgres_test_connection, {
      test_connection_button_clicked(
        rv = rv,
        source_target = "source",
        db_type = "postgres",
        input = input,
        output = output,
        session = session
      )
    })
672

Jonathan Mang's avatar
Jonathan Mang committed
673
674
675
676
677
678
679
680
681
    observeEvent(input$source_oracle_test_connection, {
      test_connection_button_clicked(
        rv = rv,
        source_target = "source",
        db_type = "oracle",
        input = input,
        output = output,
        session = session
      )
682
683
    })

Jonathan Mang's avatar
Jonathan Mang committed
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
    observeEvent(input$target_postgres_test_connection, {
      test_connection_button_clicked(
        rv = rv,
        source_target = "target",
        db_type = "postgres",
        input = input,
        output = output,
        session = session
      )
    })

    observeEvent(input$target_oracle_test_connection, {
      test_connection_button_clicked(
        rv = rv,
        source_target = "target",
        db_type = "oracle",
        input = input,
        output = output,
        session = session
      )
    })


707
    observeEvent(input$target_system_to_source_system_btn, {
Jonathan Mang's avatar
Jonathan Mang committed
708
709
      if (isTRUE(input$target_system_to_source_system_btn)) {
        ## Target was != source and should become equal:
710
711
712
        # Hide target-setting-tabs:
        hideTab(inputId = "target_tabs", target = "CSV")
        hideTab(inputId = "target_tabs", target = "PostgreSQL")
Jonathan Mang's avatar
Jonathan Mang committed
713
        hideTab(inputId = "target_tabs", target = "Oracle")
714
715
716
717
718
719
720
721
722
723
        # Assign source-values to target:
        rv <- set_target_equal_to_source(rv)
        # Set internal flag that target == source:
        rv$target_is_source <- T
        # Show feedback-box in the UI:
        output$target_system_feedback_txt <-
          renderText({
            feedback_txt(system = "The source system", type = "target")
          })
        # Feedback to the console:
Jonathan Mang's avatar
Jonathan Mang committed
724
        DIZutils::feedback(
725
726
727
728
729
          "Target == source now.",
          findme = "94d3a2090c",
          logfile_dir = rv$log$logfile_dir,
          headless = rv$headless
        )
Jonathan Mang's avatar
Jonathan Mang committed
730
731
732
733
734
735
736
737
      } else if (isFALSE(input$target_system_to_source_system_btn)) {
        ## Target was == source but should become different now:
        rv$target_is_source <- F
        rv$target <- NULL
        output$target_system_feedback_txt <- NULL
        # Show target-settings-tabs again:
        showTab(inputId = "target_tabs", target = "CSV")
        showTab(inputId = "target_tabs", target = "PostgreSQL")
Jonathan Mang's avatar
Jonathan Mang committed
738
        showTab(inputId = "target_tabs", target = "Oracle")
Jonathan Mang's avatar
Jonathan Mang committed
739
740
741
742
743
744
745
        # Feedback to the console:
        DIZutils::feedback(
          "Target != source now.",
          findme = "ec51b122ee",
          logfile_dir = rv$log$logfile_dir,
          headless = rv$headless
        )
746
      }
747
      check_load_data_button(rv, session)
748
    })
749
750
751
752
753
754

    observe({
      if (is.null(rv$sitenames)) {
        # check, if user has provided custom site names
        rv$sitenames <- tryCatch({
          outlist <- jsonlite::fromJSON(
755
            paste0(rv$utilspath, "/MISC/sitenames.JSON")
756
757
758
          )
          outlist
        }, error = function(e) {
759
          outlist <- list("undefined" = "undefined")
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
          outlist
          # TODO instead of dropdown menu, render text input field in the
          # case, users have not provided sitenames. This allows them
          # to specify a name of the DQA session (which will be included
          # into the report's title)
        }, finally = function(f) {
          return(outlist)
        })

        updateSelectInput(
          session,
          "config_sitename",
          choices = rv$sitenames,
          selected = ifelse(!is.null(rv$sitename),
                            rv$sitename,
                            character(0))
        )
      }
    })
779

780
781
782
783
    observeEvent(input_re()[["moduleConfig-dash_load_btn"]], {
      tryCatch({
        ## For runtime calculation:
        start_time <- Sys.time()
784

785
786
787
788
789
790
791
792
793
794
        # The button is on "moduleConfig".
        # This tab here will be set active below if all inputs are valid.

        # Error flag: If an error occurs, the flag will be set to true
        # and the main calculation won't start:
        error_tmp <- F

        # check, if mdr is present. without mdr, we cannot perform any
        # further operations
        if (is.null(rv$mdr)) {
Jonathan Mang's avatar
Jonathan Mang committed
795
          DIZutils::feedback(
796
797
            "No MDR found. Please provide a metadata repository (MDR).",
            type = "Warning",
798
799
800
            findme = "1dc68937b8",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
801
802
803
804
805
806
807
808
          )
          error_tmp <- T
          # mdr is present:
        } else {
          # check if sitename is present
          if (nchar(input_re()[["moduleConfig-config_sitename"]]) < 2 ||
              any(grepl("\\s", input_re()[["moduleConfig-config_sitename"]]))) {
            # site name is missing:
809
810
811
812
813
814
815
816
            shiny::showModal(shiny::modalDialog(
              title = "The sitename is missing",
              paste0(
                "There are no empty strings or spaces allowed in",
                " the site name configuration.",
                " Please select your site name."
              )
            ))
817
818
819
            error_tmp <- T
          } else {
            # site name is present:
820
821
            rv$sitename <-
              input_re()[["moduleConfig-config_sitename"]]
822
823
          }

824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
          # Check if at least one data element was selected for analyzation:
          if (length(input_re()[[paste0("moduleConfig-select_dqa_assessment",
                                        "_variables")]]) <= 0) {
            DIZutils::feedback(
              print_this = paste0(
                "You didn't specify a data element to",
                " analyze. Please select at least one data element",
                " and try again."
              ),
              type = "UI",
              ui = T,
              findme = "57562a3092"
            )
            error_tmp <- T
          }

840
841
842
843
844
          # If target should be identical to source, set it here again:
          if (isTRUE(rv$target_is_source)) {
            rv <- set_target_equal_to_source(rv)
          }

Jonathan Mang's avatar
Jonathan Mang committed
845
          DIZutils::feedback(
846
847
848
849
850
            paste0("Source system is ", rv$source$system_name),
            findme = "1d61685355",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
Jonathan Mang's avatar
Jonathan Mang committed
851
          DIZutils::feedback(
852
853
854
855
856
            paste0("Target system is ", rv$target$system_name),
            findme = "eaf72ed747",
            logfile_dir = rv$log$logfile_dir,
            headless = rv$headless
          )
857
858
        }

859
860
861
862
863
        if (validate_inputs(rv,
                            input = input,
                            output = output,
                            session = session) &&
            !error_tmp) {
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
          # set flags to inactivate config-widgets and start loading of
          # data
          rv$getdata_target <- TRUE
          rv$getdata_source <- TRUE

          if (!dir.exists(paste0(tempdir(), "/_settings/"))) {
            dir.create(paste0(tempdir(), "/_settings/"))
          }

          # save user settings
          writeLines(
            jsonlite::toJSON(
              list(
                "source_system" = rv$source$settings,
                "target_system" = rv$target$settings,
                "site_name" = rv$sitename
              ),
              pretty = T,
              auto_unbox = F
            ),
            paste0(tempdir(), "/_settings/global_settings.JSON")
          )
        }
887
888
889
890
891
      }, error = function(cond) {
        DIZutils::feedback(
          print_this = paste0(cond),
          findme = "05c96798f8",
          type = "Error",
892
893
          logfile_dir = rv$log$logfile_dir
        )
894
895
896
897
898
899
900
901
902
        ## Trigger the modal for the user/UI:
        rv$error <- T
        show_failure_alert(
          paste0(
            "Executing the script to pre-check the",
            " input parameters before data-loading failed"
          )
        )
        # stop()
903
      })
904
905
906
907
908
909
      print_runtime(
        start_time = start_time,
        name = "moduleConfig-dash_load_btn",
        logfile_dir = rv$log$logfile_dir
      )
    })
910

Jonathan Mang's avatar
Jonathan Mang committed
911
    observeEvent(input$select_all_assessment_variables, {
912
913
      updateCheckboxGroupInput(
        session = session,
Jonathan Mang's avatar
Jonathan Mang committed
914
        inputId = "select_dqa_assessment_variables",
915
        choices = sort(rv$dqa_assessment[["designation"]]),
916
917
918
919
        selected = rv$dqa_assessment[["designation"]]
      )
    })

Jonathan Mang's avatar
Jonathan Mang committed
920
    observeEvent(input$select_no_assessment_variables, {
921
922
      updateCheckboxGroupInput(
        session = session,
Jonathan Mang's avatar
Jonathan Mang committed
923
        inputId = "select_dqa_assessment_variables",
924
        choices = sort(rv$dqa_assessment[["designation"]]),
925
926
927
        selected = NULL
      )
    })
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951

    ## Date-time picker for date restriction:
    shiny::observeEvent(eventExpr = input$datetime_picker,
                        handlerExpr = {
                          # shiny::showModal(shiny::modalDialog(
                          #   title = "Date selected",
                          #   paste0(
                          #     "Start date and time: ",
                          #     input$datetime_picker[[1]],
                          #     "\nEnd date and time: ",
                          #     input$datetime_picker[[2]]
                          #   ),
                          #   easyClose = TRUE
                          # ))
                          output$datetime_picker_info <-
                            shiny::renderText({
                              paste0(
                                "Start date and time: ",
                                input$datetime_picker[[1]],
                                "\n\nEnd date and time: ",
                                input$datetime_picker[[2]]
                              )
                            })
                        })
952
  }
kapsner's avatar
kapsner committed
953

954
#' @title module_config_ui
kapsner's avatar
kapsner committed
955
956
957
958
959
#'
#' @param id A character. The identifier of the shiny object
#'
#' @export
#'
960
961
# module_config_ui
module_config_ui <- function(id) {
kapsner's avatar
kapsner committed
962
963
  ns <- NS(id)

964
965
  tagList(
    fluidRow(
966
      shinyalert::useShinyalert(),
967
968
969
970
971
972
      column(
        9,
        ## This will be displayed after the MDR is loaded successfully:
        conditionalPanel(
          condition =
            "typeof output['moduleConfig-system_types'] !== 'undefined'",
973
          box(
974
975
            title =  "SOURCE settings",
            width = 6,
976
            #solidHeader = TRUE,
Jonathan Mang's avatar
Jonathan Mang committed
977
            tabsetPanel(
978
979
980
              # The id lets us use input$source_tabs
              # on the server to find the current tab
              id = ns("source_tabs"),
981
              # selected = "PostgreSQL",
982
              tabPanel(
983
984
985
986
987
                # ATTENTION: If you change the title, you also have to change
                # the
                # corresponding part above for the "source == source" button
                # reaction. Otherwise the tabs won't hide/show up anymore.
                # >> ATTENTION <<
988
                title = "CSV",
989
990
                # >> ATTENTION << for title. See above.
                id = ns("source_tab_csv"),
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
                h4("Source CSV Upload"),
                box(
                  title = "Available CSV-Systems",
                  # background = "blue",
                  # solidHeader = TRUE,
                  width = 12,
                  selectInput(
                    # This will be filled in the server part.
                    inputId = ns("source_csv_presettings_list"),
                    label = NULL,
                    choices = NULL,
                    selected = NULL
                  ),
                  style = "text-align:center;"
1005
                ),
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
                div(
                  paste(
                    "Please choose the directory of your",
                    "\u00A7",
                    "21 source data in csv format (default: '/home/input')."
                  )
                ),
                br(),
                # If the path is already set, display it
                conditionalPanel(
                  condition = paste0(
                    "typeof ",
                    "output['moduleConfig-source_csv_dir']",
                    " !== 'undefined'"
                  ),
                  verbatimTextOutput(ns("source_csv_dir")),
1022
                  style = "text-align:center;"
1023
                ),
1024
1025
1026
                br(),

                # If there is no path set yet: Display the button to choose it
1027
1028
1029
1030
1031
1032
1033
                shinyFiles::shinyDirButton(
                  id = ns("config_sourcedir_in"),
                  label = "Source Dir",
                  title = "Please select the source directory",
                  buttonType = "default",
                  icon = icon("folder"),
                  class = NULL,
1034
1035
                  style = "text-align:center;"
                )
1036
              ),
1037
              tabPanel(
1038
1039
1040
1041
1042
                # ATTENTION: If you change the title, you also have to change
                # the
                # corresponding part above for the "source == source" button
                # reaction. Otherwise the tabs won't hide/show up anymore.
                # >> ATTENTION <<
1043
                title = "PostgreSQL",
1044
1045
                # >> ATTENTION << for title. See above.
                id = ns("source_tab_pg"),
1046
1047
1048
1049
1050
1051
1052
1053
                h4("Source Database Connection"),
                box(
                  title = "Preloadings",
                  # background = "blue",
                  #solidHeader = TRUE,
                  width = 12,
                  selectInput(
                    # This will be filled in the server part.
1054
                    inputId = ns("source_postgres_presettings_list"),
1055
1056
1057
1058
                    label = NULL,
                    choices = NULL,
                    selected = NULL
                  ),
1059
1060
                  style = "text-align:center;"
                ),
1061
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1062
                  inputId = ns("config_source_postgres_dbname"),
1063
1064
                  label = "DB Name",
                  placeholder = "Enter the name of the database ..."
1065
                ),
1066
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1067
                  inputId = ns("config_source_postgres_host"),
1068
1069
1070
1071
                  label = "IP",
                  placeholder = "Enter the IP here in format '192.168.1.1' ..."
                ),
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1072
                  inputId = ns("config_source_postgres_port"),
1073
1074
1075
1076
                  label = "Port",
                  placeholder = "Enter the Port of the database connection ..."
                ),
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1077
                  inputId = ns("config_source_postgres_user"),
1078
1079
1080
1081
1082
                  label = "Username",
                  placeholder =
                    "Enter the Username for the database connection ..."
                ),
                passwordInput(
Jonathan Mang's avatar
Jonathan Mang committed
1083
                  inputId = ns("config_source_postgres_password"),
1084
1085
1086
1087
1088
                  label = "Password",
                  placeholder = "Enter the database password ..."
                ),
                br(),
                actionButton(
Jonathan Mang's avatar
Jonathan Mang committed
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
                  inputId = ns("source_postgres_test_connection"),
                  label = "Test & Save connection",
                  icon = icon("database"),
                  style = "text-align:center;"
                )
              ),
              tabPanel(
                # ATTENTION: If you change the title, you also have to change
                # the
                # corresponding part above for the "target == source" button
                # reaction. Otherwise the tabs won't hide/show up anymore.
                # >> ATTENTION <<
                title = "Oracle",
                # >> ATTENTION << for title. See above.
                id = ns("source_tab_oracle"),
                h4("Source Database Connection"),
                box(
                  title = "Preloadings",
                  # background = "blue",
                  #solidHeader = TRUE,
                  width = 12,
                  selectInput(
                    # This will be filled in the server part.
                    inputId = ns("source_oracle_presettings_list"),
                    label = NULL,
                    choices = NULL,
                    selected = NULL
                  ),
                  style = "text-align:center;"
                ),
                textInput(
                  inputId = ns("config_source_oracle_dbname"),
                  label = "DB Name",
                  placeholder = "Enter the name of the database ..."
                ),
                textInput(
                  inputId = ns("config_source_oracle_host"),
                  label = "IP",
                  placeholder = "Enter the IP here in format '192.168.1.1' ..."
                ),
                textInput(
                  inputId = ns("config_source_oracle_port"),
                  label = "Port",
                  placeholder = "Enter the Port of the database connection ..."
                ),
                textInput(
                  inputId = ns("config_source_oracle_user"),
                  label = "Username",
                  placeholder =
                    "Enter the Username for the database connection ..."
                ),
                passwordInput(
                  inputId = ns("config_source_oracle_password"),
                  label = "Password",
                  placeholder = "Enter the database password ..."
                ),
                textInput(
                  inputId = ns("config_source_oracle_sid"),
                  label = "SID",
                  placeholder =
                    "Enter the SID for the database connection ..."
                ),
                br(),
                actionButton(
                  inputId = ns("source_oracle_test_connection"),
1154
1155
1156
1157
                  label = "Test & Save connection",
                  icon = icon("database"),
                  style = "text-align:center;"
                )
1158
              )
1159
1160
            )
          ),
1161
1162
1163
          box(
            title =  "TARGET settings",
            width = 6,
1164
            #solidHeader = TRUE,
Jonathan Mang's avatar
Jonathan Mang committed
1165
            tabsetPanel(
1166
1167
1168
1169
1170
              # The id lets us use input$target_tabs
              # on the server to find the current tab
              id = ns("target_tabs"),
              # selected = "PostgreSQL",
              tabPanel(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1171
1172
                # ATTENTION: If you change the title, you also have to change
                # the
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
                # corresponding part above for the "target == source" button
                # reaction. Otherwise the tabs won't hide/show up anymore.
                # >> ATTENTION <<
                title = "CSV",
                # >> ATTENTION << for title. See above.
                id = ns("target_tab_csv"),
                h4("Target CSV Upload"),
                box(
                  title = "Available CSV-Systems",
                  # background = "blue",
                  # solidHeader = TRUE,
                  width = 12,
                  selectInput(
                    # This will be filled in the server part.
                    inputId = ns("target_csv_presettings_list"),
                    label = NULL,
                    choices = NULL,
                    selected = NULL
                  ),
                  style = "text-align:center;"
1193
                ),
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
                div(
                  paste(
                    "Please choose the directory of your",
                    "\u00A7",
                    "21 target data in csv format (default: '/home/input')."
                  )
                ),
                br(),
                # If the path is already set, display it
                conditionalPanel(
                  condition = paste0(
                    "typeof ",
                    "output['moduleConfig-target_csv_dir']",
                    " !== 'undefined'"
                  ),
                  verbatimTextOutput(ns("target_csv_dir")),
1210
                  style = "text-align:center;"
1211
                ),
1212
1213
1214
                br(),

                # If there is no path set yet: Display the button to choose it
1215
1216
1217
1218
1219
1220
1221
                shinyFiles::shinyDirButton(
                  id = ns("config_targetdir_in"),
                  label = "Target Dir",
                  title = "Please select the target directory",
                  buttonType = "default",
                  icon = icon("folder"),
                  class = NULL,
1222
1223
                  style = "text-align:center;"
                )
1224
              ),
1225
              tabPanel(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1226
1227
                # ATTENTION: If you change the title, you also have to change
                # the
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
                # corresponding part above for the "target == source" button
                # reaction. Otherwise the tabs won't hide/show up anymore.
                # >> ATTENTION <<
                title = "PostgreSQL",
                # >> ATTENTION << for title. See above.
                id = ns("target_tab_pg"),
                h4("Target Database Connection"),
                box(
                  title = "Preloadings",
                  # background = "blue",
                  #solidHeader = TRUE,
                  width = 12,
                  selectInput(
                    # This will be filled in the server part.
1242
                    inputId = ns("target_postgres_presettings_list"),
1243
1244
1245
1246
                    label = NULL,
                    choices = NULL,
                    selected = NULL
                  ),
1247
1248
                  style = "text-align:center;"
                ),
1249
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
                  inputId = ns("config_target_postgres_dbname"),
                  label = "DB Name",
                  placeholder = "Enter the name of the database ..."
                ),
                textInput(
                  inputId = ns("config_target_postgres_host"),
                  label = "IP",
                  placeholder = "Enter the IP here in format '192.168.1.1' ..."
                ),
                textInput(
                  inputId = ns("config_target_postgres_port"),
                  label = "Port",
                  placeholder = "Enter the Port of the database connection ..."
                ),
                textInput(
                  inputId = ns("config_target_postgres_user"),
                  label = "Username",
                  placeholder =
                    "Enter the Username for the database connection ..."
                ),
                passwordInput(
                  inputId = ns("config_target_postgres_password"),
                  label = "Password",
                  placeholder = "Enter the database password ..."
                ),
                br(),
                actionButton(
                  inputId = ns("target_postgres_test_connection"),
                  label = "Test & Save connection",
                  icon = icon("database"),
                  style = "text-align:center;"
                )
              ),
              tabPanel(
                # ATTENTION: If you change the title, you also have to change
                # the
                # corresponding part above for the "target == source" button
                # reaction. Otherwise the tabs won't hide/show up anymore.
                # >> ATTENTION <<
                title = "Oracle",
                # >> ATTENTION << for title. See above.
                id = ns("target_tab_oracle"),
                h4("Target Database Connection"),
                box(
                  title = "Preloadings",
                  # background = "blue",
                  #solidHeader = TRUE,
                  width = 12,
                  selectInput(
                    # This will be filled in the server part.
                    inputId = ns("target_oracle_presettings_list"),
                    label = NULL,
                    choices = NULL,
                    selected = NULL
                  ),
                  style = "text-align:center;"
                ),
                textInput(
                  inputId = ns("config_target_oracle_dbname"),
1309
1310
                  label = "DB Name",
                  placeholder = "Enter the name of the database ..."
1311
                ),
1312
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1313
                  inputId = ns("config_target_oracle_host"),
1314
1315
1316
1317
                  label = "IP",
                  placeholder = "Enter the IP here in format '192.168.1.1' ..."
                ),
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1318
                  inputId = ns("config_target_oracle_port"),
1319
1320
1321
1322
                  label = "Port",
                  placeholder = "Enter the Port of the database connection ..."
                ),
                textInput(
Jonathan Mang's avatar
Jonathan Mang committed
1323
                  inputId = ns("config_target_oracle_user"),
1324
1325
1326
1327
1328
                  label = "Username",
                  placeholder =
                    "Enter the Username for the database connection ..."
                ),
                passwordInput(
Jonathan Mang's avatar
Jonathan Mang committed
1329
                  inputId = ns("config_target_oracle_password"),
1330
1331
1332
                  label = "Password",
                  placeholder = "Enter the database password ..."
                ),
Jonathan Mang's avatar
Jonathan Mang committed
1333
1334
1335
1336
1337
1338
                textInput(
                  inputId = ns("config_target_oracle_sid"),
                  label = "SID",
                  placeholder =
                    "Enter the SID for the database connection ..."
                ),
1339
1340
                br(),
                actionButton(
Jonathan Mang's avatar
Jonathan Mang committed
1341
                  inputId = ns("target_oracle_test_connection"),
1342
1343
1344
1345
                  label = "Test & Save connection",
                  icon = icon("database"),
                  style = "text-align:center;"
                )
1346
              )
Jonathan Mang's avatar
Jonathan Mang committed
1347
            ),
Jonathan Mang's avatar
Jonathan Mang committed
1348
            tags$hr(),
Jonathan Mang's avatar
Jonathan Mang committed
1349
1350
            checkboxInput(
              inputId = ns("target_system_to_source_system_btn"),
Jonathan Mang's avatar
Jonathan Mang committed
1351
              # inputId = ns("randomstringhere"),
Jonathan Mang's avatar
Jonathan Mang committed
1352
1353
1354
1355
              label = paste0(" Use SOURCE also as TARGET",
                             " (Compare source with itself)"),
              value = FALSE
            ),
Jonathan Mang's avatar
Jonathan Mang committed
1356
            tags$hr()
1357
          )
1358
        )
1359
1360
1361
1362
      ),
      column(
        3,
        conditionalPanel(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1363
1364
          condition =
            "typeof output['moduleConfig-mdr_present'] == 'undefined'",
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
          box(
            title = "Load Metadata Repository",
            actionButton(
              inputId = ns("config_load_mdr"),
              label = "Load MDR",
              icon = icon("table")
            ),
            width = 12
          )
        ),
        conditionalPanel(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1376
          condition =
1377
            "typeof output['moduleConfig-mdr_present'] !== 'undefined'",
1378
          box(
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1379
            title = "Load the data",
1380
            h4(htmlOutput(ns("source_system_feedback_txt"))),
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1381
            br(),
1382
            h4(htmlOutput(ns("target_system_feedback_txt"))),
1383
1384
1385
1386
1387
1388
1389
1390
1391
            hr(),
            selectInput(
              ns("config_sitename"),
              "Please enter the name of your site",
              selected = F,
              choices = NULL,
              multiple = F
            ),
            hr(),
1392
1393
            actionButton(ns("dash_load_btn"),
                         "Load data",
1394
1395
1396
1397
1398
                         icon = icon("file-upload"),
                         style = paste0("color: #fff;",
                                        "background-color: #337ab7;",
                                        "border-color: #2e6da4;",
                                        "display:center-align;")),
1399
            width = 12
1400
          ),
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
          box(
            id = ns("config_select_datetime_picker_box"),
            title = "Pick the date and time to be analyzed",
            h4(htmlOutput(ns("datetime_picker_info"))),
            daterangepicker::daterangepicker(
              inputId = ns("datetime_picker"),
              # label = "Please pick a date range ",
              start = Sys.Date() - 30, end = Sys.Date(),
              style = "width:100%; border-radius:4px",
              ranges = datepicker_get_list_of_ranges(),
              options = list(
                showDropdowns = TRUE,
                timePicker = TRUE,
                timePicker24Hour = TRUE,
                autoApply = TRUE
              )
              # icon = shiny::icon("calendar")
            ),
            width = 12
          ),
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1421
          box(
1422
1423
1424
            id = ns("config_select_dqa_assessment_box"),
            title = "Analyse the following data elements",
            hr(),
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1425
            actionButton(
Jonathan Mang's avatar
Jonathan Mang committed
1426
              inputId = ns("select_all_assessment_variables"),
1427
              label = "Select all"
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1428
            ),
1429
            actionButton(
Jonathan Mang's avatar
Jonathan Mang committed
1430
              inputId = ns("select_no_assessment_variables"),
1431
1432
1433
1434
              label = "Unselect all"
            ),
            hr(),
            checkboxGroupInput(
Jonathan Mang's avatar
Jonathan Mang committed
1435
              inputId = ns("select_dqa_assessment_variables"),
1436
1437
              label = NULL,
              choices = NULL),
1438
            width = 12
Lorenz Kapsner's avatar
Lorenz Kapsner committed
1439
          )
1440
        )
1441
1442
1443
      )
    )
  )
kapsner's avatar
kapsner committed
1444
}