-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.qmd
79 lines (61 loc) · 2.3 KB
/
index.qmd
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
71
72
73
74
75
76
77
78
79
---
title: "Lookup: Posit Connect People and Content"
date: "last-modified"
date-format: D MMM YYYY HH:mm
author: Data Science Team, The Strategy Unit
format:
html:
page-layout: full
execute:
echo: false
resource_files:
- R/api.R
- R/utils.R
---
```{r}
#| label: check-env-vars
#| results: "asis"
list.files("R", "\\.R$", , TRUE) |> purrr::walk(source)
check_env_vars(c("CONNECT_SERVER", "CONNECT_API_KEY"))
```
```{r}
#| label: prepare-variables
#| include: false
server_name <- Sys.getenv("CONNECT_SERVER")
people_path <- glue::glue("{server_name}connect/#/people/")
content_path <- glue::glue("{server_name}connect/#/content/")
client <- get_client()
users_groups <- get_all_users_groups(client)
content <- get_content(client)
n_users <- users_groups |>
dplyr::filter(username != "[none]") |>
dplyr::distinct(username) |>
nrow()
n_groups <- users_groups |>
dplyr::filter(group != "[none]") |>
dplyr::distinct(group) |>
nrow()
n_content <- nrow(content)
```
## Purpose
This page contains tabular lookups of [users](`r people_path`) and [content](`r content_path`) on the server [`r server_name`](`r server_name`). Find [the source on GitHub](https://github.com/The-Strategy-Unit/posit-connect-people/).
## Users and groups
This table shows one row per user and group. There are `r n_users` users and `r n_groups` groups. Note that it's possible for users not to have a group and vice versa. You can search, sort and filter the data and click the 'CSV' button to download the current view.
```{r}
#| label: users-table
users_groups |>
dplyr::mutate(dplyr::across(dplyr::where(is.character), as.factor)) |>
create_dt("users")
```
## Content
This table shows one row per content item. There are `r n_content` content items. You can search, sort and filter the data and click the 'CSV' button to download the current view. Click the links in the `*_url` columns to open the item with or without the Posit Connect dashboard framing the content.
```{r}
#| label: content-table
content |>
dplyr::mutate(
content_url = glue::glue("<a href='{content_url}'>Link</a>"),
dashboard_url = glue::glue("<a href='{dashboard_url}'>Link</a>"),
dplyr::across(dplyr::where(is.character), as.factor)
) |>
create_dt("content")
```