From 3b9e359e2154771b545b39e6cda0dedb8280667e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luise=20Quo=C3=9F?= <luise.quoss@idiv.de>
Date: Tue, 1 Mar 2022 11:40:30 +0100
Subject: [PATCH] small changes

---
 ebv_metadata_app.R | 52 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/ebv_metadata_app.R b/ebv_metadata_app.R
index 2823344..b5cb77b 100644
--- a/ebv_metadata_app.R
+++ b/ebv_metadata_app.R
@@ -1,5 +1,27 @@
+#install all packages if not yet installed
+t <- tryCatch(
+  {find.package("shiny")},
+  error = function(e){
+    install.packages('shiny')
+  }
+)
+t <- tryCatch(
+  {find.package("stringr")},
+  error = function(e){
+    install.packages('stringr')
+  }
+)
+t <- tryCatch(
+  {find.package("checkmate")},
+  error = function(e){
+    install.packages('checkmate')
+  }
+)
+
+#load libraries
 library(shiny)
 library(stringr)
+library(checkmate)
 
 ui <- fluidPage(
   #set style
@@ -110,7 +132,7 @@ ui <- fluidPage(
     fluidRow(
       #publisher Name
       column(6,
-             textInput('publisher_name', tags$span(style="font-size: 18px; font-weight: bold", 'Publisher Name*'), width='80%',
+             textInput('publisher_name', tags$span(style="font-size: 18px; font-weight: bold", 'Publisher Name* (responsible PI)'), width='80%',
                        placeholder='The name of the person publishing the data. The publisher is also the contact person.'),
 
       ),
@@ -132,6 +154,7 @@ ui <- fluidPage(
 
     #license
     textAreaInput('license', tags$span(style="font-size: 18px; font-weight: bold", 'License*'), width='90.5%',
+                  value =  "https://creativecommons.org/licenses/by/4.0",
                   placeholder = 'Give the URL of a licence. Prefereble CC-License, e.g. https://creativecommons.org/licenses/by/4.0/'),
     #add a text: link to CC licenses
     tags$a(href="https://creativecommons.org/licenses/", "Link to CC licenses."),
@@ -220,7 +243,7 @@ ui <- fluidPage(
 
              #end 2. tab
              ),
-    tabPanel('Spatial and temportal domain',
+    tabPanel('Spatial and temporal domain',
              #2 cols
              fluidRow(
                #spatial domain
@@ -473,7 +496,7 @@ server <- function(input, output) {
 
 
           #description/long_name
-          ln <- textAreaInput(paste0('scenario_long_name_',i), 'Description*', width='90.5%',
+          ln <- textAreaInput(paste0('scenario_long_name_',i), 'Description', width='90.5%',
                               placeholder = paste0('Description of Scenario ', i))
 
           if(i==1){
@@ -583,16 +606,16 @@ server <- function(input, output) {
 
           #check project_name
           if(!is.null(need(input$project_name != '', TRUE))){
-            project_name <- nodata
+            project_name <- 'TERRANOVA - The European Landscape Learning Initiative'
           }else{
-            project_name <- input$project_name
+            project_name <- 'TERRANOVA - The European Landscape Learning Initiative'
           }
 
           #check project_url
           if(!is.null(need(input$project_url != '', TRUE))){
-            project_url <- nodata
+            project_url <- 'https://www.terranova-itn.eu'
           }else{
-            project_url <- input$project_url
+            project_url <- 'https://www.terranova-itn.eu'
           }
 
           #check creator_name
@@ -751,10 +774,10 @@ server <- function(input, output) {
                 to_do_list <- c(to_do_list, paste0('The name for scenario ',i,' is missing.'))
                 create <- FALSE
               }
-              if(!is.null(need(eval(parse(text = paste0('input$scenario_long_name_', i))) != '', TRUE))){
-                to_do_list <- c(to_do_list, paste0('The description for scenario ',i,' is missing.'))
-                create <- FALSE
-              }
+              # if(!is.null(need(eval(parse(text = paste0('input$scenario_long_name_', i))) != '', TRUE))){
+              #   to_do_list <- c(to_do_list, paste0('The description for scenario ',i,' is missing.'))
+              #   create <- FALSE
+              # }
             }
 
             #scenario_classification_name
@@ -849,9 +872,14 @@ server <- function(input, output) {
                 "ebv_scenario_classification_version": "',scenario_classification_version,'",
                 "ebv_scenario_classification_url": "',scenario_classification_url,'",')
               for(i in 1:input$scenario_no){
+                if(!is.null(need(eval(parse(text = paste0('input$scenario_long_name_', i))) != '', TRUE))){
+                  long_name <- nodata
+                } else{
+                  long_name <- eval(parse(text = paste0('input$scenario_long_name_', i)))
+                }
                 ebv_scenario <- paste0(ebv_scenario, '\n\t\t\t\t"ebv_scenario_',i,'": {
                     ":standard_name": "',eval(parse(text = paste0('input$scenario_standard_name_', i))),'",
-                    ":long_name": "',eval(parse(text = paste0('input$scenario_long_name_', i))),'"
+                    ":long_name": "',long_name,'"
                 }')
                 if(i != input$scenario_no){
                   ebv_scenario <- paste0(ebv_scenario, ',')
-- 
GitLab