Commit dde1388e authored by Conor Anderson's avatar Conor Anderson

Crop check-in

parent 55c65ee3
......@@ -6,4 +6,5 @@ Some notes:
You should _not_ provide both a Shapefile _and_ manual input. However, if in doubt, keep the following guidelines in mind:
- Uploading a Shapefile will reset the manual input to the default (invalid) coordinates. The Shapefile will be used.
- If you set coordiantes manually _after_ uploading a Shapefile, we will remove the Shapefile and prefer the manual input.
- If you change your mind again, re-upload the Shapefile, and it will again clear the manual input.
- If you change your mind again, click the map once more. When the box disappears, the Shapefile will be used.
- If you want to use a different Shapefile, uploading it will replace any previously uploaded Shapefiles.
......@@ -481,7 +481,7 @@ shinyServer(function(input, output, session) {
### Resample Data (WIP)
crop_model_in <- callModule(singleModelSelect, "crop_model_in",
choices = reactive({get_choices(file_dir, input$var_filter_crop, lim = TRUE)}),
coords = NULL,
coords = reactive(return(NULL)),
projection = reactive({input$crop_year_in[1]:input$crop_year_in[2]}))
output$resample_map <- renderLeaflet({
......@@ -490,9 +490,7 @@ shinyServer(function(input, output, session) {
setView(lng = 0, lat = 0, zoom = 3)
})
# Show Shapefile on map
observeEvent(input$shapefile, {
map_shapefile <- function() {
# Clear the manual inputs
updateNumericInput(session, "Lat1", value = -999)
updateNumericInput(session, "Lat2", value = -999)
......@@ -510,6 +508,11 @@ shinyServer(function(input, output, session) {
proxy %>% addPolygons(data = shp) %>%
flyToBounds(attr(ext, "xmin"), attr(ext, "ymin"),
attr(ext, "xmax"), attr(ext, "ymax"))
}
# Show Shapefile on map
observeEvent(input$shapefile, {
map_shapefile()
})
#Show popup on click
......@@ -542,17 +545,40 @@ shinyServer(function(input, output, session) {
updateNumericInput(session, "Lon1", value = -999)
updateNumericInput(session, "Lon2", value = -999)
proxy %>% clearMarkers() %>% clearShapes()
if (!is.null(input$shapefile)) {
map_shapefile()
}
}
})
output$crop_action <- renderUI({
validate(
need(crop_model_in(), "Choose a model to crop.")
)
actionButton("crop_go",
"Process!")
#need(!(any(c(input$Lon1, input$Lon2) %in% -999)) || input$shapefile, "We need some lat/lon data.")
output$latlon_checkbox <- renderUI({
model <- try(req(crop_model_in()))
shp <- try(req(input$shapefile))
inherits(shp, "try-error")
print(input$shapefile)
content <- '<b>To do:</b>'
if (all(c(input$Lat1, input$Lat2, input$Lon1, input$Lon2) %in% -999) &&
is.null(input$shapefile)) {
content <- c(content, '<i class="far fa-square"></i> Select at least one point or upload a .shp')
} else {
content <- c(content, '<i class="far fa-check-square"></i> Select at least one point or upload a .shp')
}
if (inherits(model, "try-error")) {
content <- c(content, '<i class="far fa-square"></i> Choose a mod/var/scen to process.')
} else {
content <- c(content, '<i class="far fa-check-square"></i> Choose a mod/var/scen to process.</i>')
}
HTML(paste(content, collapse = "<br>"))
})
output$crop_action <- renderUI({
if ((!all(c(input$Lat1, input$Lat2, input$Lon1, input$Lon2) %in% -999) ||
!is.null(input$shapefile)) &
!is.null(crop_model_in())) {
actionButton("crop_go", "Process!")
} else {
NULL
}
})
output$source <- renderUI({
......
......@@ -20,8 +20,13 @@ dashboardPage(
menuItem("Source Code", tabName = "source", icon = icon("git"))
)
),
dashboardBody(
dashboardBody( tags$head(
tags$style(HTML("
.shiny-output-error-validation {
color: gray;
}
"))
),
tabItems(
## README
tabItem(tabName = "README",
......@@ -157,6 +162,7 @@ dashboardPage(
includeMarkdown("include/crop.md")
),
box(width = 2,
uiOutput("latlon_checkbox"),
uiOutput("crop_action")
)
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment