Skip to content

Commit 46f2578

Browse files
authored
Usage Metrics Dashboard: Add loading spinners to outputs (#136)
* add loading spinners to the app * update snapshot * update manifest
1 parent d3abaf3 commit 46f2578

File tree

5 files changed

+486
-586
lines changed

5 files changed

+486
-586
lines changed

extensions/usage-metrics-dashboard/app.R

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ library(lubridate)
99
library(reactable)
1010
library(ggplot2)
1111
library(plotly)
12+
library(shinycssloaders)
1213

1314
shinyOptions(
1415
cache = cachem::cache_disk("./app_cache/cache/", max_age = 60 * 60)
1516
)
1617

18+
options(
19+
spinner.type = 1,
20+
spinner.color = "#7494b1"
21+
)
22+
1723
source("get_usage.R")
1824
source("integrations.R")
1925

@@ -38,7 +44,7 @@ bar_chart <- function(
3844
value,
3945
max_val,
4046
height = "1rem",
41-
fill = "#00bfc4",
47+
fill = "#7494b1",
4248
background = NULL
4349
) {
4450
width <- paste0(value * 100 / max_val, "%")
@@ -201,7 +207,7 @@ ui <- function(request) {
201207
div(
202208
id = "multi_content_table",
203209
textOutput("summary_text"),
204-
reactableOutput("content_usage_table")
210+
withSpinner(reactableOutput("content_usage_table"))
205211
),
206212

207213
# The single-content detail view is displayed when an item is selected,
@@ -229,7 +235,11 @@ ui <- function(request) {
229235
"Daily Visits",
230236
div(
231237
style = "height: 300px",
232-
plotlyOutput("daily_visits_plot", height = "100%", width = "100%")
238+
withSpinner(plotlyOutput(
239+
"daily_visits_plot",
240+
height = "100%",
241+
width = "100%"
242+
))
233243
)
234244
),
235245
tabPanel(
@@ -250,11 +260,11 @@ ui <- function(request) {
250260
"Click a row to show only that user's visits."
251261
)
252262
),
253-
reactableOutput("aggregated_visits")
263+
withSpinner(reactableOutput("aggregated_visits"))
254264
),
255265
tabPanel(
256266
"List of Visits",
257-
reactableOutput("all_visits")
267+
withSpinner(reactableOutput("all_visits"))
258268
)
259269
)
260270
)
@@ -1145,7 +1155,10 @@ server <- function(input, output, session) {
11451155

11461156
height_px <- n_users * row_height + label_buffer + toolbar_buffer
11471157

1148-
plotlyOutput("visit_timeline_plot", height = paste0(height_px, "px"))
1158+
withSpinner(plotlyOutput(
1159+
"visit_timeline_plot",
1160+
height = paste0(height_px, "px")
1161+
))
11491162
})
11501163

11511164
# Global UI elements ----

extensions/usage-metrics-dashboard/get_usage.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
library(connectapi)
2-
library(pins)
32

43
NA_datetime_ <- vctrs::new_datetime(NA_real_, tzone = "UTC")
54
NA_list_ <- list(list())

0 commit comments

Comments
 (0)