Skip to content

Commit 14645a3

Browse files
committed
Added Connector Metrics
1 parent 5f86ece commit 14645a3

13 files changed

Lines changed: 2367 additions & 26 deletions

File tree

src/lib/components/Navigation.svelte

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,26 @@
3333
{ href: "/", label: "Home", icon: "🏠", available: true },
3434
3535
{
36-
href: "/metrics",
3736
label: "Metrics",
3837
icon: "📊",
3938
available: true,
39+
subItems: [
40+
{
41+
href: "/metrics",
42+
label: "API Metrics",
43+
icon: "📈",
44+
},
45+
{
46+
href: "/aggregate-metrics",
47+
label: "Aggregate Metrics",
48+
icon: "📊",
49+
},
50+
{
51+
href: "/connector-metrics",
52+
label: "Connector Metrics",
53+
icon: "🔗",
54+
},
55+
],
4056
},
4157
{
4258
label: "Dynamic Entities",
@@ -77,6 +93,23 @@
7793
},
7894
],
7995
},
96+
{
97+
label: "Products",
98+
icon: "📦",
99+
available: true,
100+
subItems: [
101+
{
102+
href: "/products",
103+
label: "Products",
104+
icon: "📋",
105+
},
106+
{
107+
href: "/products/collections",
108+
label: "Product Collections",
109+
icon: "🗂️",
110+
},
111+
],
112+
},
80113
].filter((item) => item.available)
81114
: [],
82115
);

src/lib/config/navigation.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,32 +153,37 @@ export function getActiveIntegrationMenuItem(pathname: string) {
153153
return found || integrationItems[0]; // fallback to first item
154154
}
155155

156-
// API Metrics navigation items
157-
function buildApiMetricsItems(): NavigationItem[] {
156+
// Metrics navigation items
157+
function buildMetricsItems(): NavigationItem[] {
158158
const items: NavigationItem[] = [
159-
{ href: "/metrics", label: "Metrics", iconComponent: BarChart3 },
159+
{ href: "/metrics", label: "API Metrics", iconComponent: BarChart3 },
160160
{
161161
href: "/aggregate-metrics",
162162
label: "Aggregate Metrics",
163163
iconComponent: BarChart3,
164164
},
165+
{
166+
href: "/connector-metrics",
167+
label: "Connector Metrics",
168+
iconComponent: Plug,
169+
},
165170
];
166171

167172
return items;
168173
}
169174

170-
export const apiMetricsItems = buildApiMetricsItems();
175+
export const metricsItems = buildMetricsItems();
171176

172-
export function getActiveApiMetricsMenuItem(pathname: string) {
173-
const found = apiMetricsItems.find((item) => {
177+
export function getActiveMetricsMenuItem(pathname: string) {
178+
const found = metricsItems.find((item) => {
174179
// Skip external links for active menu detection
175180
if (item.external) {
176181
return false;
177182
}
178183
return pathname.startsWith(item.href);
179184
});
180185

181-
return found || apiMetricsItems[0]; // fallback to first item
186+
return found || metricsItems[0]; // fallback to first item
182187
}
183188

184189
// RBAC navigation items

src/routes/(protected)/aggregate-metrics/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@
622622
</div>
623623
<button
624624
class="refresh-btn"
625-
on:click={refreshMetrics}
625+
onclick={refreshMetrics}
626626
style="display: block; margin: 0 auto;"
627627
>
628628
🔄 Refresh Data
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { createLogger } from "$lib/utils/logger";
2+
import { error } from "@sveltejs/kit";
3+
import type { PageServerLoad } from "./$types";
4+
5+
const logger = createLogger("ConnectorMetricsPageServer");
6+
7+
export const load: PageServerLoad = async ({ locals }) => {
8+
const session = locals.session;
9+
10+
if (!session?.data?.user) {
11+
throw error(401, "Unauthorized");
12+
}
13+
14+
// Get user entitlements from session for role checking
15+
const userEntitlements = (session.data.user as any)?.entitlements?.list || [];
16+
const requiredRoles = [{ role: "CanGetConnectorMetrics" }];
17+
18+
return {
19+
userEntitlements,
20+
requiredRoles,
21+
};
22+
};

0 commit comments

Comments
 (0)