forked from OWRC/sHydrology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
70 lines (55 loc) · 2.84 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
##########################################################
################### sHydrologyMap ########################
#### A Shiny-Leaflet interface to the HYDAT database. ####
##########################################################
# Leaflet map
#
# By M. Marchildon
# v.1.6.2
# Nov, 2021
##########################################################
source("pkg/pkg.R", local=TRUE)
source("pkg/shiny_leaflet_functions.R", local=TRUE)
source("pkg/sources.R", local=TRUE)
source("pkg/mobile.R", local=TRUE)
shinyApp(
ui <- bootstrapPage(
useShinyjs(),
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
tags$head(includeCSS("pkg/styles.css")),
div(
id = "app-content",
list(tags$head(HTML('<link rel="icon", href="favicon.png",type="image/png" />'))),
div(style="padding: 1px 0px; height: 0px", titlePanel(title="", windowTitle="sHydrology"))
),
leafletOutput("map", width = "100%", height = "100%"),
windowTitle="sHydrology",
# modified from superZip (http://shiny.rstudio.com/gallery/superzip-example.html)
absolutePanel(id = "panl", class = "panel panel-default", fixed = TRUE,
draggable = FALSE, top = 10, left = "auto", right = 10, bottom = "auto",
width = 330, height = "auto",
h2("Hydrograph explorer"),
sliderInput("YRrng", "Select date envelope", min(tblSta$YRb), max(tblSta$YRe),
value = c(max(tblSta$YRe)-30,max(tblSta$YRe)), sep=""),
selectInput("POR", "minimum period of length/count of data", c("no limit" = 0, "5yr" = 5, "10yr" = 10, "30yr" = 30, "50yr" = 50, "75yr" = 75, "100yr" = 100)),
checkboxInput("chkCluster", "apply marker clustering", FALSE), br(),
checkboxInput("chkSW", "show streamflow stations", TRUE),
checkboxInput("chkMet", "show climate stations", FALSE),
checkboxInput("chkGW", "deep (>20m) groundwater monitoring", FALSE),
checkboxInput("chkGWshal", "shallow groundwater monitoring", FALSE),
h4("Hydrograph preview:"),
dygraphOutput("hydgrph", height = 200), br(),
div(style="display:inline-block",actionButton("expnd", "Analyze")),
div(style="display:inline-block",downloadButton('dnld', 'Download CSV'))
),
mobileDetect('isMobile') ## from: https://g3rv4.com/2017/08/shiny-detect-mobile-browsers
),
server <- function(input, output, session) {
shinyjs::disable("dnld")
shinyjs::disable("expnd")
### load external code:
source("pkg/server.R", local = TRUE)$value
source("pkg/mobile_srv.R", local = TRUE)$value
session$onSessionEnded(stopApp)
}
)