Skip to content

Commit 7e6665c

Browse files
committed
add integration totals
1 parent 9ae3d74 commit 7e6665c

File tree

1 file changed

+64
-3
lines changed
  • extensions/champion-dashboard

1 file changed

+64
-3
lines changed

extensions/champion-dashboard/app.py

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,42 @@
266266
.content-table tbody tr:hover {
267267
background-color: #f7f6f3;
268268
}
269+
.template-header {
270+
position: relative;
271+
cursor: help;
272+
}
273+
.template-header .tooltip-text {
274+
visibility: hidden;
275+
background-color: #37352f;
276+
color: #fff;
277+
text-align: center;
278+
border-radius: 6px;
279+
padding: 8px 12px;
280+
position: absolute;
281+
z-index: 1;
282+
bottom: 125%;
283+
left: 50%;
284+
transform: translateX(-50%);
285+
white-space: nowrap;
286+
font-size: 12px;
287+
font-weight: 400;
288+
opacity: 0;
289+
transition: opacity 0.2s;
290+
}
291+
.template-header .tooltip-text::after {
292+
content: "";
293+
position: absolute;
294+
top: 100%;
295+
left: 50%;
296+
margin-left: -5px;
297+
border-width: 5px;
298+
border-style: solid;
299+
border-color: #37352f transparent transparent transparent;
300+
}
301+
.template-header:hover .tooltip-text {
302+
visibility: visible;
303+
opacity: 1;
304+
}
269305
"""
270306

271307
def fetch_all_prometheus_metrics(url: str) -> Dict[str, List[Tuple[Dict[str, str], float]]]:
@@ -347,14 +383,28 @@ def get_oauth_association_metrics(metrics: Dict) -> Dict:
347383

348384
if template not in matrix:
349385
matrix[template] = {}
350-
matrix[template][auth_type] = int(value)
386+
matrix[template][auth_type] = int(value)
351387

352388
return {
353389
'matrix': matrix,
354390
'templates': sorted(templates),
355391
'auth_types': sorted(auth_types)
356392
}
357393

394+
def get_integration_count_by_template(metrics: Dict) -> Dict[str, int]:
395+
"""Sum integration_count by template."""
396+
integration_count = metrics.get('integrations_count', [])
397+
result = {}
398+
399+
for labels, value in integration_count:
400+
template = labels.get('integration_template')
401+
if template:
402+
if template not in result:
403+
result[template] = 0
404+
result[template] += int(value)
405+
406+
return result
407+
358408
def get_system_info(client):
359409
response = client.get("server_settings")
360410
settings = response.json()
@@ -534,7 +584,7 @@ def get_server_base_url() -> str:
534584
class_="section-grid-4"
535585
),
536586
ui.div(
537-
ui.div("Content items with OAuth integration stats", class_="card-title"),
587+
ui.div("Content items with OAuth integrations", class_="card-title"),
538588
ui.output_ui("oauth_association_metrics_table"),
539589
class_="content-card"
540590
),
@@ -700,10 +750,21 @@ def oauth_association_metrics_table():
700750
matrix = associations_data['matrix']
701751
templates = associations_data['templates']
702752
auth_types = associations_data['auth_types']
753+
integration_counts = get_integration_count_by_template(metrics)
754+
755+
def create_template_header(template):
756+
count = integration_counts.get(template, 0)
757+
return ui.tags.th(
758+
ui.span(
759+
template,
760+
ui.span(f"Unique Integrations: {count}", class_="tooltip-text"),
761+
class_="template-header"
762+
)
763+
)
703764

704765
header_row = ui.tags.tr(
705766
ui.tags.th(""),
706-
*[ui.tags.th(template) for template in templates],
767+
*[create_template_header(template) for template in templates],
707768
ui.tags.th("Total")
708769
)
709770

0 commit comments

Comments
 (0)