Skip to content

Commit

Permalink
Info pages (#48)
Browse files Browse the repository at this point in the history
* Feat: Setting up info_pages dev folder and user_guide dev app

* Feat: Adding context, an accordian to display each View and the content for the All LA page (with image)

* Feat: Added LA view to user guide

* Feat: Added rest of the user guide

* Feat: Adding information page and creating a dev app for it

* Feat: Order by alphabet fn

* Chore: Improving styling of indicator info table module

* Feat: Latest data update notification

* Feat: Adding development update log (xlsx)

* Feat: Added development update notification banner

* Feat: Improving the search method for info pages

* Feat: New update banner sheet

* Feat: Adding intro spiel for each heading

* Chore: New useful links data, also lowercasing all data file names

* Feat: Jazzing up the latest dev updates

* Feat: Useful links now into info-pages

* Feat: Adding info page to main app, removing some of the spiel

* Feat: Turning dev updates into more of a bslib card and adding collapsible functionality

* Chore: Removed the default gap that appears fro bslibs page_fillable between elements (like beta banner)

* Feat: Added news banner to dev info app and main app

* Feat: News banner added to top of the app (included with beta banner - now capitalised)

* Feat: Spinners on info page tables, rewritten noti banner for latest data updates as card rather than shinyGovstyle

* Feat: Adding owner title for useful links

* Chore: Linting fixes

* Rename Development_update_log.xlsx to development_update_log.xlsx

* Update and rename Banner_update.csv to banner_update.csv
  • Loading branch information
JT-39 authored Dec 9, 2024
1 parent c53b17a commit c35a878
Show file tree
Hide file tree
Showing 40 changed files with 1,674 additions and 396 deletions.
2 changes: 2 additions & 0 deletions 01_data/02_prod/banner_update.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"Data update"
"Welcome to the first release of the new Local Authority Interactive Tool (LAIT), we hope you find this easy to use but any feedback would be greatly appreciated."
Binary file added 01_data/02_prod/development_update_log.xlsx
Binary file not shown.
File renamed without changes.

Large diffs are not rendered by default.

File renamed without changes.
10 changes: 10 additions & 0 deletions 01_data/02_prod/useful_links.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"Tool_Name","Type","Owner","Link"
"Child Health Profiles","Web Tool","OHID","https://fingertips.phe.org.uk/profile/child-health-profiles"
"Early Years Outcome Dashboard","Rshiny Tool","DfE","https://department-for-education.shinyapps.io/smapey-dashboard/"
"Five-Year Ofsted Inspection Data","ODS","Ofsted","https://www.gov.uk/government/publications/five-year-ofsted-inspection-data"
"High Needs Dashboard","Excel Tool","DfE","https://www.gov.uk/government/publications/high-needs-benchmarking-tool"
"Level 2 and 3 Attainment by 19 Dashboard","Rshiny Tool","DfE","https://department-for-education.shinyapps.io/attainment-age-19/"
"Local Authority School Places Scorecards","Rshiny Tool","DfE","https://department-for-education.shinyapps.io/la-school-places-scorecards/?_inputs_&navlistPanel=%22Homepage%22&tabs=%22quantity%22&tabs_tech_notes=%22Quantity%22&cookies-cookie_accept=0&cookies-cookie_reject=0&cookies-cookie_link=0&linklascorecardsTab=0&linkQuantityTab=0&linkForecastTab=0&linkPreferenceTab=0&linkQualityTab=0&linkCostTab=0&linkTechnicalnotesTab=0&cookie_consent_clear=0&LA_choice=%22England%22&phase_choice=%22Primary%22&selectBenchLAs=null&selectBenchLAspref=null&chart_choice=%22Ofsted%20Rating%22&selectBenchLAsquality=null"
"NEET and Participation LA Scorecards","Rshiny Tool","DfE","https://department-for-education.shinyapps.io/neet-comparative-la-scorecard/"
"Public Health Outcomes Framework","Web Tool","OHID","https://fingertips.phe.org.uk/profile/public-health-outcomes-framework"
"School Performance Tables","Web Tool","DfE","https://www.gov.uk/school-performance-tables"
42 changes: 31 additions & 11 deletions 02_dev/bds_wide_to_long.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,40 @@ Load the latest Data Dictionary

```{r write-data_dict}
# Load raw Data Dict from shared folder
data_dict <- readxl::read_xlsx(
path = paste0(shared_folder, "/../Information for App Development/LAIT Data Dictionary (To QA!).xlsx"),
sheet = "Data_prod",
# Replace multi-space with single-space
.name_repair = clean_spaces
) |>
data_dict <- read_data_dict_shared_folder(shared_folder, "Data_prod") |>
dplyr::filter(!grepl("DISCONTINUE", Table_status))
# Write .csv version
write.csv(
data_dict,
here::here("01_data/02_prod/LAIT Data Dictionary.csv"),
here::here("01_data/02_prod/lait_data_dictionary.csv"),
row.names = FALSE
)
```

Load latest update banner

```{r write-banner}
# Load raw Data Dict from shared folder
banner_update <- read_data_dict_shared_folder(shared_folder, "Banner_updates") |>
# Write .csv version
write.csv(
banner_update,
here::here("01_data/02_prod/banner_update.csv"),
row.names = FALSE
)
```

Load latest update banner

```{r write-banner}
# Load raw Data Dict from shared folder
useful_links <- read_data_dict_shared_folder(shared_folder, "Other Tools")
# Write .csv version
write.csv(
useful_links,
here::here("01_data/02_prod/useful_links.csv"),
row.names = FALSE
)
```
Expand All @@ -55,8 +77,6 @@ bds_wide_raw_sf <- readxl::read_xlsx(
col_types = "text"
)
# Save to data folder
write.csv(
bds_wide_raw_sf,
Expand Down Expand Up @@ -130,7 +150,7 @@ bds_long_clean <- bds_long |>
```{r bds-la_codes}
# Load LA codes
la_codes <- readxl::read_xlsx(
path = here::here("01_data/02_prod/LA code list.xlsx")
path = here::here("01_data/02_prod/la_code_list.xlsx")
)
# Join to bds and create combined codes var
Expand All @@ -145,7 +165,7 @@ bds_long_la <- bds_long_clean |>
# only public-safe/in-use measures)
# NOTE: Children_away changed to Children_Away to match BDS
data_dict <- read.csv(
file = paste0("01_data/02_prod/LAIT Data Dictionary.csv"),
file = paste0("01_data/02_prod/lait_data_dictionary.csv"),
check.names = FALSE
) |>
dplyr::mutate(Measure_short = trimws(Measure_short)) |>
Expand Down
147 changes: 147 additions & 0 deletions 02_dev/info_pages/dev_info_page.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
source(here::here("global.R"))

# Load functions
list.files("R/", full.names = TRUE) |>
(\(x) {
x[grepl("fn_", x)]
})() |>
purrr::walk(source)

# Load modules
list.files("R/lait_modules/", full.names = TRUE) |>
purrr::walk(source)

# Load ui panels
list.files("R/ui_panels/", full.names = TRUE) |>
purrr::walk(source)

ui_dev <- function(input, output, session) {
bslib::page_fillable(

# Set application metadata ------------------------------------------------
tags$head(HTML("<title>Local Authority Interactive Tool (LAIT)</title>")),
tags$head(tags$link(rel = "shortcut icon", href = here::here("www/dfefavicon.png"))),
tags$head(includeHTML(here::here("google-analytics.html"))),
shinytitle::use_shiny_title(),
tags$html(lang = "en"),
# Add meta description for search engines
metathis::meta() |>
metathis::meta_general(
application_name = "Local Authority Interactive Tool (LAIT)",
description = "Local Authority Interactive Tool (LAIT)",
robots = "index,follow",
generator = "R-Shiny",
subject = "data tool",
rating = "General",
referrer = "no-referrer"
),

# Custom disconnect function ----------------------------------------------
# Variables used here are set in the global.R file
dfeshiny::custom_disconnect_message(
links = sites_list,
publication_name = parent_pub_name,
publication_link = parent_publication
),

# Styling with CSS
shiny::includeCSS(here::here("www/dfe_shiny_gov_style.css")),
# Remove any gaps between elements
gap = 0,

# Load javascript dependencies --------------------------------------------
shinyWidgets::useShinydashboard(),
shinyjs::useShinyjs(),
tags$head(htmltools::includeScript(here::here("www/custom_js.js"))),
reactable.extras::reactable_extras_dependency(),
shinyToastify::useShinyToastify(),

# Cookies -----------------------------------------------------------------
# Setting up cookie consent based on a cookie recording the consent:
# https://book.javascript-for-r.com/shiny-cookies.html
dfeshiny::dfe_cookies_script(),
dfeshiny::cookies_banner_ui(
"cookie-banner",
"Local Authority Interactive Tool (LAIT)"
),

# Header ------------------------------------------------------------------
shinyGovstyle::header(
main_text = "",
main_link = "https://www.gov.uk/government/organisations/department-for-education",
secondary_text = "Local Authority Interactive Tool (LAIT)",
logo = "www/images/DfE_logo_landscape.png",
logo_width = 150,
logo_height = 32
),

# Beta banner -------------------------------------------------------------
shiny::tagList(
shinyGovstyle::banner(
ifelse(banner_update_msg == "", "beta-banner", "beta-banner-no-border"),
"Beta",
"This Dashboard is in beta phase and we are still reviewing performance and reliability."
)
),
# News banner --------------------------------------------------------------
if (banner_update_msg != "") {
shinyGovstyle::banner(
inputId = "update-msg-banner",
type = "News",
label = banner_update_msg
)
},

# Start of app ============================================================

# Nav panels --------------------------------------------------------------
bslib::navset_pill_list(
"",
id = "navsetpillslist",
widths = c(2, 10),
well = FALSE,

# =======================================================================
# User guide
# =======================================================================
info_page_panel()
)
)
}


# Define the `server` function
server_dev <- function(input, output, session) {
# Call the banner module server
bannerModuleServer(
"banner_module",
banner_update_msg
)

# Indicator information table
IndicatorInfoTableServer(
"indicator_info_table",
metrics_clean
)

# Latest indicator update notification
LatestDataUpdateServer(
"latest_indicator_update",
metrics_clean
)

# Latest development update
LatestDevUpdateServer(
"latest_dev_update",
development_update_log
)

# Useful links
UsefulLinksServer(
"useful_links",
useful_links
)
}

# Launch the Shiny app
shinyApp(ui_dev, server_dev)
115 changes: 115 additions & 0 deletions 02_dev/info_pages/dev_user_guide.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
source(here::here("global.R"))

# Load functions
list.files("R/", full.names = TRUE) |>
(\(x) {
x[grepl("fn_", x)]
})() |>
purrr::walk(source)

# Load modules
list.files("R/lait_modules/", full.names = TRUE) |>
purrr::walk(source)

# Load ui panels
list.files("R/ui_panels/", full.names = TRUE) |>
purrr::walk(source)

ui_dev <- function(input, output, session) {
bslib::page_fillable(

# Set application metadata ------------------------------------------------
tags$head(HTML("<title>Local Authority Interactive Tool (LAIT)</title>")),
tags$head(tags$link(rel = "shortcut icon", href = here::here("www/dfefavicon.png"))),
tags$head(includeHTML(here::here("google-analytics.html"))),
shinytitle::use_shiny_title(),
tags$html(lang = "en"),
# Add meta description for search engines
metathis::meta() |>
metathis::meta_general(
application_name = "Local Authority Interactive Tool (LAIT)",
description = "Local Authority Interactive Tool (LAIT)",
robots = "index,follow",
generator = "R-Shiny",
subject = "data tool",
rating = "General",
referrer = "no-referrer"
),

# Custom disconnect function ----------------------------------------------
# Variables used here are set in the global.R file
dfeshiny::custom_disconnect_message(
links = sites_list,
publication_name = parent_pub_name,
publication_link = parent_publication
),

# Styling with CSS
shiny::includeCSS(here::here("www/dfe_shiny_gov_style.css")),

# Load javascript dependencies --------------------------------------------
shinyWidgets::useShinydashboard(),
shinyjs::useShinyjs(),
tags$head(htmltools::includeScript(here::here("www/custom_js.js"))),
reactable.extras::reactable_extras_dependency(),
shinyToastify::useShinyToastify(),

# Cookies -----------------------------------------------------------------
# Setting up cookie consent based on a cookie recording the consent:
# https://book.javascript-for-r.com/shiny-cookies.html
dfeshiny::dfe_cookies_script(),
dfeshiny::cookies_banner_ui(
"cookie-banner",
"Local Authority Interactive Tool (LAIT)"
),

# Header ------------------------------------------------------------------
shinyGovstyle::header(
main_text = "",
main_link = "https://www.gov.uk/government/organisations/department-for-education",
secondary_text = "Local Authority Interactive Tool (LAIT)",
logo = "www/images/DfE_logo_landscape.png",
logo_width = 150,
logo_height = 32
),

# Beta banner -------------------------------------------------------------
shinyGovstyle::banner(
"beta banner",
"beta",
paste0(
"This Dashboard is in beta phase and we are still reviewing performance
and reliability. ",
"In case of slowdown or connection issues due to high demand, we have
produced two instances of this site which can be accessed at the
following links: ",
"<a href=", site_primary, " id='link_site_1'>Site 1</a> and ",
"<a href=", site_overflow, " id='link_site_2'>Site 2</a>."
)
),

# Start of app ============================================================

# Nav panels --------------------------------------------------------------
bslib::navset_pill_list(
"",
id = "navsetpillslist",
widths = c(2, 10),
well = FALSE,

# =======================================================================
# User guide
# =======================================================================
user_guide_panel()
)
)
}


# Define the `server` function
server_dev <- function(input, output, session) {
# Add server logic here as needed
}

# Launch the Shiny app
shinyApp(ui_dev, server_dev)
5 changes: 1 addition & 4 deletions R/fn_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,7 @@ filter_by_topic <- function(data, topic_column, selected_topics) {
if (is.null(selected_topics) || any(selected_topics %in% c("All Topics", ""))) {
# Return data ordered alphabetically by "Measure", with letters first
alphabet_ordered <- data |>
dplyr::arrange(
!grepl("^[A-Za-z]", .data$Measure),
.data$Measure
)
order_alphabetically(.data$Measure)
return(alphabet_ordered)
}

Expand Down
31 changes: 31 additions & 0 deletions R/fn_helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -760,3 +760,34 @@ update_topic_label <- function(
shinyjs::html(topic_label_id, label)
})
}


#' Order data alphabetically with non-alphabetical entries at the top
#'
#' This function orders a dataset based on the values of a specified column.
#' Entries that do not start with a letter (A-Z, a-z) are placed at the top,
#' followed by the remaining entries sorted alphabetically.
#'
#' @param data A data frame or tibble to be sorted.
#' @param column The column to be used for sorting. This should be provided
#' as an unquoted column name.
#'
#' @return A data frame or tibble sorted by the specified column.
#'
#' @examples
#' \dontrun{
#' # Example dataset
#' df <- data.frame(Measure = c("Zebra", "1234", "Apple", "Cat"))
#'
#' # Order by the 'Measure' column
#' ordered_df <- order_alphabetically(df, Measure)
#' print(ordered_df)
#' }
#'
order_alphabetically <- function(data, column) {
data |>
dplyr::arrange(
!grepl("^[A-Za-z]", {{ column }}),
{{ column }}
)
}
Loading

0 comments on commit c35a878

Please sign in to comment.