@@ -44,6 +44,34 @@ full_url <- function(session) {
44
44
)
45
45
}
46
46
47
+ content_usage_table_search_method = JS("
48
+ function(rows, columnIds, searchValue) {
49
+ if (!searchValue) return rows;
50
+
51
+ const guidPattern = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
52
+ const guidMatch = searchValue.match(guidPattern);
53
+ const matchGuid = guidMatch ? guidMatch[0].toLowerCase() : null;
54
+ const searchLower = searchValue.toLowerCase(); // <-- moved here
55
+
56
+ return rows.filter(function(row) {
57
+ return columnIds.some(function(columnId) {
58
+ const value = String(row.values[columnId] || '').toLowerCase();
59
+
60
+ if (columnId === 'title' && value.includes(searchLower)) {
61
+ return true;
62
+ }
63
+ if (columnId === 'dashboard_url' && value.includes(searchLower)) {
64
+ return true;
65
+ }
66
+ if (columnId === 'content_guid' && matchGuid && value === matchGuid) {
67
+ return true;
68
+ }
69
+ return false;
70
+ });
71
+ });
72
+ }
73
+ " )
74
+
47
75
ui <- function (request ) {
48
76
page_sidebar(
49
77
useShinyjs(),
@@ -507,6 +535,11 @@ server <- function(input, output, session) {
507
535
pagination = TRUE ,
508
536
defaultPageSize = 25 ,
509
537
sortable = TRUE ,
538
+ searchable = TRUE ,
539
+ searchMethod = content_usage_table_search_method ,
540
+ language = reactableLang(
541
+ searchPlaceholder = " Search by title, URL, or GUID" ,
542
+ ),
510
543
highlight = TRUE ,
511
544
defaultSorted = " total_views" ,
512
545
style = list (cursor = " pointer" ),
@@ -771,6 +804,11 @@ server <- function(input, output, session) {
771
804
selected_content_info()$ title
772
805
})
773
806
807
+ output $ content_guid <- renderText({
808
+ req(selected_content_info())
809
+ selected_content_info()$ guid
810
+ })
811
+
774
812
output $ dashboard_link <- renderUI({
775
813
req(selected_content_info())
776
814
url <- selected_content_info()$ dashboard_url
@@ -903,12 +941,17 @@ server <- function(input, output, session) {
903
941
" Usage"
904
942
} else {
905
943
div(
906
- style = " display: flex; justify-content: space-between; gap: 1rem; align-items: center ;" ,
944
+ style = " display: flex; justify-content: space-between; gap: 1rem; align-items: baseline ;" ,
907
945
actionButton(" clear_content_selection" , " Back" , icon(" arrow-left" ), class = " btn btn-sm" , style = " white-space: nowrap;" ),
908
946
span(
909
947
" Usage / " ,
910
948
textOutput(" content_title" , inline = TRUE )
911
949
),
950
+ code(
951
+ class = " text-muted" ,
952
+ style = " font-family: \" Fira Mono\" , Consolas, Monaco, monospace; font-size: 0.875rem;" ,
953
+ textOutput(" content_guid" , inline = TRUE )
954
+ ),
912
955
uiOutput(" dashboard_link" )
913
956
)
914
957
}
0 commit comments