Skip to content

Commit 84e20d8

Browse files
committed
Add checks
1 parent 0dd35f8 commit 84e20d8

File tree

12 files changed

+247
-21
lines changed

12 files changed

+247
-21
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export(get_dc_groups)
44
export(get_dc_ids)
55
export(mod_configure_checks_server)
66
export(mod_configure_checks_ui)
7+
export(mod_perform_checks_server)
8+
export(mod_perform_checks_ui)
79
export(run_app)
810
import(bdchecks)
911
import(bddwc.app)

R/app_server.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ app_server <- function(input, output,session) {
2121
id = "bdChecksConfigure"
2222
)
2323

24+
callModule(
25+
mod_perform_checks_server,
26+
id = "bdChecksPerform"
27+
)
28+
29+
callModule(
30+
bddwc.app::mod_citation_server,
31+
id = "bdcite"
32+
)
33+
2434
#------------- Modules --------------
2535

2636

@@ -36,5 +46,15 @@ app_server <- function(input, output,session) {
3646
}
3747
})
3848

49+
observeEvent(input$sideBar, {
50+
if(input$sideBar == "configure"){
51+
shinyjs::runjs("$grid.isotope('shuffle');")
52+
}
53+
54+
55+
56+
})
57+
58+
3959
#------------- Events --------------
4060
}

R/app_ui.R

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#' @import shiny shinydashboard mod_add_data_ui
22
app_ui <- function() {
3+
dbHeader <- dashboardHeader()
4+
dbHeader$children[[2]]$children <- tags$img(src='www/bdchecks-logo.png',height='50',width='50')
5+
36
tagList(
47
dashboardPage(
5-
dashboardHeader(title = "bdchecks"),
8+
dbHeader,
69

710
dashboardSidebar(sidebarMenu(
811
id = "sideBar",
@@ -15,10 +18,17 @@ app_ui <- function() {
1518
"Configure Cleaning",
1619
tabName = "configure",
1720
icon = icon("wrench")
21+
),
22+
menuItem(
23+
"Perform Cleaning",
24+
tabName = "clean",
25+
icon = icon("broom")
26+
),
27+
menuItem(
28+
"Cite Us",
29+
tabName = "cite",
30+
icon = icon("copyright")
1831
)
19-
# menuItem("Darwinize",
20-
# tabName = "darwinize",
21-
# icon = icon("blocks"))
2232
)),
2333

2434
dashboardBody(
@@ -41,8 +51,22 @@ app_ui <- function() {
4151

4252
tabItem("configure",
4353
fluidRow(
44-
div(mod_configure_checks_ui("bdChecksConfigure"))
45-
))
54+
column(12,
55+
h1("Select Checks to Perform"),
56+
br(),
57+
div(mod_configure_checks_ui("bdChecksConfigure"))
58+
)
59+
)),
60+
61+
tabItem("clean",
62+
fluidRow(
63+
div(mod_perform_checks_ui("bdChecksPerform"))
64+
)),
65+
66+
tabItem("cite",
67+
fluidRow(
68+
div(bddwc.app:: mod_citation_ui("bdcite"))
69+
))
4670
)
4771
)
4872
),

R/mod_configure_checks.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ mod_configure_checks_ui <- function(id) {
6868
),
6969

7070
fluidRow(
71-
div(class = "checksListTopic col-sm-4", p("Category of Quality Check: ")),
71+
div(class = "checksListTopic col-sm-4", p("Category of Check: ")),
7272
div(class = "checksListTitle col-sm-8",
7373
p(check@description$DarwinCoreClass))
7474
),
7575

7676
fluidRow(
77-
div(class = "checksListTopic col-sm-4", p("DWC Field Targetted by Check: ")),
77+
div(class = "checksListTopic col-sm-4", p("DWC Field Targetted: ")),
7878
div(class = "checksListTitle col-sm-8",
7979
p(check@input$Target))
8080
),
@@ -96,7 +96,7 @@ mod_configure_checks_ui <- function(id) {
9696
12,
9797

9898
fluidRow(column(
99-
6,
99+
5,
100100
div(
101101
p("Sort Checks By: "),
102102
class = "btn-group btn-group-justified",
@@ -148,11 +148,18 @@ mod_configure_checks_ui <- function(id) {
148148
)
149149
,
150150
column(
151-
3,
151+
2,
152152
p("Select None: "),
153153
checkboxInput(ns("showDetailed"), label = "", value = FALSE)
154+
),
155+
column(
156+
4,
157+
p("Next:"),
158+
actionButton("configureToPerform", "Perform Cleaning")
154159
)
155160

161+
162+
156163
)),
157164

158165
div(class = "grid", components)

R/mod_perform_checks.R

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Module UI
2+
3+
#' @title mod_perform_checks_ui and mod_perform_checks_server
4+
#' @description A shiny Module.
5+
#'
6+
#' @param id shiny id
7+
#' @param input internal
8+
#' @param output internal
9+
#' @param session internal
10+
#'
11+
#' @rdname mod_perform_checks
12+
#'
13+
#' @keywords internal
14+
#' @export
15+
#' @importFrom shiny NS tagList
16+
mod_perform_checks_ui <- function(id) {
17+
ns <- NS(id)
18+
tagList(column(12,
19+
div(
20+
h1("Perform Cleaning"),
21+
22+
column(
23+
12,
24+
fluidRow(column(4,
25+
h4("Records Submitted", class = "control-header"),
26+
div(class = "control-header stats-green", textOutput(ns("total")))),
27+
column(4,
28+
h4("Data Checks Performed", class = "control-header"),
29+
div(class = "control-header stats-green", textOutput(ns("checks")))),
30+
column(4,
31+
h4("Records After Filtering", class = "control-header"),
32+
div(class = "control-header stats-green", textOutput(ns("filtered"))))),
33+
34+
fluidRow(
35+
column(
36+
12,
37+
actionButton(ns("perform"), "Perform Data Checks", width = "14%"),
38+
actionButton("a", "Select All Passed Records", width = "14%"),
39+
actionButton("b", "Select All Failed Records", width = "14%"),
40+
actionButton("c", "Select All Missing Records", width = "14%"),
41+
actionButton("d", "Clear Selections", width = "14%"),
42+
actionButton("e", "Accept Selections", width = "14%"),
43+
actionButton("f", "Download Final Data", width = "14%")
44+
)
45+
46+
),
47+
48+
br(),
49+
50+
column(
51+
12,
52+
DT::dataTableOutput(ns("summaryTable"))
53+
)
54+
)
55+
56+
)))
57+
}
58+
59+
# Module Server
60+
61+
#' @rdname mod_perform_checks
62+
#' @export
63+
#' @keywords internal
64+
65+
mod_perform_checks_server <- function(input, output, session) {
66+
ns <- session$ns
67+
68+
summary <- data.frame()
69+
70+
observeEvent(input$perform, {
71+
checks <-
72+
bdchecks::perform_dc(
73+
bdchecks::data_bats,
74+
c(
75+
"elevationOutOfRange",
76+
"eventDateInFuture",
77+
"monthInvalid",
78+
"occurrenceIdNotGuid",
79+
"dateIdentifiedInFuture",
80+
"dataGeneralised",
81+
"countryMismatch",
82+
"dateNull",
83+
"coordinatesZero"
84+
)
85+
)
86+
87+
summary <<-
88+
bdchecks::summary_dc(checks, fancy = FALSE, filtering_dt = TRUE)
89+
})
90+
91+
output$summaryTable <- DT::renderDataTable(
92+
DT::datatable({
93+
input$perform
94+
summary
95+
},
96+
rownames = FALSE,
97+
options = list(pageLength = 100,
98+
columnDefs = list(
99+
list(className = "no_select",
100+
targets = 0:1)
101+
)),
102+
selection = list(target = "cell"),
103+
callback = DT::JS(
104+
"table.on('click', 'td.no_select', function() {
105+
var td = $(this), row = table.row(td.closest('tr'));
106+
if ($(td.node()).hasClass('selected')) {
107+
$(td.node()).removeClass('selected');
108+
}});"
109+
))
110+
)
111+
112+
output$filtered <-
113+
renderText({
114+
69
115+
})
116+
117+
output$total <-
118+
renderText({
119+
128
120+
})
121+
122+
output$checks <-
123+
renderText({
124+
14
125+
})
126+
}
127+
128+
## To be copied in the UI
129+
# mod_perform_checks_ui("perform_checks_ui_1")
130+
131+
## To be copied in the server
132+
# callModule(mod_perform_checks_server, "perform_checks_ui_1")

dev/02_dev.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## 2.1 Add modules
99
##
10-
golem::add_module( name = "configure_checks" ) # Name of the module
10+
golem::add_module( name = "perform_checks" ) # Name of the module
1111
golem::add_module( name = "my_other_module" ) # Name of the module
1212

1313
## 2.2 Add dependencies

inst/app/www/bdchecks-logo.png

215 KB
Loading

inst/app/www/favicon.ico

225 KB
Binary file not shown.

inst/app/www/input.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
left: 0; top: 0;
6363
width: 1.8em; height: 1.8em;
6464
border: 2px solid #ccc;
65-
background: #fff;
66-
border-radius: 4px;
65+
background: transparent;
6766
box-shadow: inset 0 1px 3px rgba(0,0,0,.1);
6867
}
6968

@@ -73,7 +72,7 @@
7372
position: absolute;
7473
font-size: 2.5em;
7574
line-height: 0.8;
76-
color: #09ad7e;
75+
color: orange;
7776
transition: all .2s;
7877
font-family: Helvetica, Arial, sans-serif;
7978
}

inst/app/www/script.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ $('.btn-group').each( function( i, buttonGroup ) {
2727
});
2828
});
2929

30-
$(window).load(function() {
31-
setTimeout(
32-
function() {
33-
$grid.isotope('shuffle');
34-
}, 2000);
30+
$grid.on( 'click', '.element-item', function() {
31+
var checkbox = $("input:checkbox[value=" + this.getElementsByTagName("h4")[0].innerHTML + "]");
32+
checkbox.prop("checked", !checkbox.prop("checked"));
3533
});

0 commit comments

Comments
 (0)