diff --git a/ebv_metadata_app.R b/ebv_metadata_app.R index 4bd9390bf2783153b9c1f899c4c8d5944717eeb7..db26293e83230930117705be3c6ecdf6bf7b5f72 100644 --- a/ebv_metadata_app.R +++ b/ebv_metadata_app.R @@ -37,7 +37,7 @@ ui <- fluidPage( #create several tabs tabsetPanel( - #1. tab: general information + #1. tab: general information---- tabPanel('General Information', #2 cols fluidRow( @@ -167,7 +167,7 @@ ui <- fluidPage( #end tabPanel 1 ), - #2. tab: ebv attributes + #2. tab: ebv attributes---- tabPanel('EBV Attributes', @@ -251,6 +251,7 @@ ui <- fluidPage( #end 2. tab ), + #3. tab: spat. temp. attributes---- tabPanel('Spatial and temporal domain', #2 cols fluidRow( @@ -288,6 +289,7 @@ ui <- fluidPage( "monthly" = "P0000-01-00", "weekly" = "P0000-00-07", "daily" = "P0000-00-01", + 'one timestep' = "P0000-00-00", "other" = "other"), width='80%'), @@ -295,9 +297,16 @@ ui <- fluidPage( uiOutput('temporal_resoultion_other'), #temporal extent + uiOutput('temporal_extent'), + #tags$b('Temporal Extent'), - dateInput('temp_start', tags$span(style="font-size: 18px; font-weight: bold", 'Start date of the dataset*'), width='80%'), - dateInput('temp_end', tags$span(style="font-size: 18px; font-weight: bold", 'End date of the dataset*'), width='80%') + # dateInput('temp_start', tags$span(style="font-size: 18px; font-weight: bold", + # 'Start date of the dataset*'), width='80%', + # startview ='year'), + # dateInput('temp_end', tags$span(style="font-size: 18px; font-weight: bold", + # 'End date of the dataset*'), width='80%', + # startview ='year') + ) @@ -305,7 +314,7 @@ ui <- fluidPage( #end 3. tab ), - #4. tab: check and output generation + #4. tab: check and output generation---- tabPanel('Save metadata to file', textInput('outputpath', tags$span(style="font-size: 18px; font-weight: bold", 'Outputpath*')), #value='C:\\Users\\lq39quba\\Desktop\\ebv_terranova\\bla.json' @@ -537,12 +546,57 @@ server <- function(input, output) { } }) + #check variables + to_do_list <- c() + create <- TRUE + + #temporal extent---- + output$temporal_extent <- renderUI({ + if(input$temporal_resolution=='other'){ + #user defined temporal resolution + if(grepl('^P{1}\\d{4}-00-00', input$temp_res_txt)){ + dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold", + 'Start and end date of the dataset*'), + format = "yyyy") + } else if(grepl('^P{1}\\d{4}-\\d{2}-00$', input$temp_res_txt)){ + dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold", + 'Start and end date of the dataset*'), + format = "mm-yyyy") + } else if (grepl('^P{1}\\d{4}-\\d{2}-\\d{2}$', input$temp_res_txt)){ + dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold", + 'Start and end date of the dataset*'), + format = "dd-mm-yyyy") + }else{ + create <- FALSE + to_do_list <- c(to_do_list, 'Your temporal resolution does not match the ISO duration format.') + } + + }else if(input$temporal_resolution=='P0000-00-00'){ + #one timestep only + dateInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold", + 'Date of the dataset*'), width='80%', + startview ='year') + + }else if(grepl('^P{1}\\d{4}-00-00$', input$temporal_resolution)){ + dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold", + 'Start and end date of the dataset*'), + format = "yyyy") + } else if(grepl('^P{1}\\d{4}-\\d{2}-00$', input$temporal_resolution)){ + dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold", + 'Start and end date of the dataset*'), + format = "mm-yyyy") + } else { + dateRangeInput('temporal_extent_input', tags$span(style="font-size: 18px; font-weight: bold", + 'Start and end date of the dataset*'), + format = "dd-mm-yyyy") + } + + }) + #submit button clicked ----- observeEvent(input$create_json,{ #start checks---- - to_do_list <- c() - create <- TRUE #check if outputpath is empty if(input$outputpath==''){ @@ -846,11 +900,15 @@ server <- function(input, output) { } #temporal extent - if(input$temp_end < input$temp_start){ - to_do_list <- c(to_do_list, 'The temporal end of the dataset is before the start. Please correct!') - create <- FALSE + if(input$temporal_resolution=='P0000-00-00'){ + t_start <-input$temporal_extent_input + t_end <- input$temporal_extent_input + }else{ + t_start <- input$temporal_extent_input[1] + t_end <- input$temporal_extent_input[2] } + #check terranova type if(!is.null(need(input$terranova_type != '', TRUE))){ to_do_list <- c(to_do_list, 'You need to provide a value for the type of the data.') @@ -958,8 +1016,8 @@ server <- function(input, output) { "geospatial_lon_units": "',input$spatial_units,'", "time_coverage": { "time_coverage_resolution": "',input$temporal_resolution,'", - "time_coverage_start": "',input$temp_start,'", - "time_coverage_end": "',input$temp_end,'" + "time_coverage_start": "',t_start,'", + "time_coverage_end": "',t_end,'" }, "ebv_domain": [\n\t\t\t\t"', paste0(ebv_domain_value, collapse = '",\n\t\t\t\t"'),'"\n\t\t\t], "comment": "',comment,'", @@ -967,6 +1025,8 @@ server <- function(input, output) { } ] }') + + print(input$temporal_extent_input) #write to file write(json, input$outputpath) }