Skip to content

Commit 4673713

Browse files
Graph of recommendations in control panel (#867)
* add vis-network dependency * feat: add visualizer route and implement reference graph functionality with mock data * connect to db + seed + clean mock ups * fix graph physics * feat: enhance visualizer with node detail display and interaction * feat: add key block for selected node detail panel to optimize rendering * Minor fixes * feat: enhance reference fetching with API key validation and add missing headers * feat: add pagination support to getAllReferences method * feat: enhance getAllReferences method with pagination and API key validation * feat: enhance graph visualization with filter and detail panels * feat: improve focus handling in FilterPanel with event prevention * chore: remove auto-generated next-env.d.ts * chore: lockfile --------- Co-authored-by: Ananya Rana <ananyarana2920@gmail.com>
1 parent 6162859 commit 4673713

14 files changed

Lines changed: 1129 additions & 40303 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
engine-strict=true
1+
# vis-network required node < 22
2+
engine-strict=false

infrastructure/control-panel/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"lucide-svelte": "^0.561.0",
5757
"qrcode": "^1.5.4",
5858
"signature-validator": "workspace:*",
59-
"tailwind-merge": "^3.0.2"
59+
"tailwind-merge": "^3.0.2",
60+
"vis-network": "^10.0.2"
6061
}
6162
}

infrastructure/control-panel/src/routes/+layout.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
{ label: 'Dashboard', href: '/' },
1515
{ label: 'Monitoring', href: '/monitoring' },
1616
{ label: 'Actions', href: '/actions' },
17-
{ label: 'Notifications', href: '/notifications' }
17+
{ label: 'Notifications', href: '/notifications' },
18+
{ label: 'Visualizer', href: '/visualizer' }
1819
];
1920
2021
const isActive = (href: string) => (href === '/' ? pageUrl === '/' : pageUrl.startsWith(href));
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { json } from '@sveltejs/kit';
2+
import type { RequestHandler } from '@sveltejs/kit';
3+
import { env } from '$env/dynamic/private';
4+
5+
export const GET: RequestHandler = async () => {
6+
const baseUrl = env.EREPUTATION_BASE_URL || 'http://localhost:8765';
7+
8+
try {
9+
const controller = new AbortController();
10+
const timeout = setTimeout(() => controller.abort(), 5000);
11+
const response = await fetch(`${baseUrl}/api/references/all`, {
12+
headers: env.VISUALIZER_API_KEY ? { 'x-visualizer-key': env.VISUALIZER_API_KEY } : {},
13+
signal: controller.signal,
14+
});
15+
clearTimeout(timeout);
16+
17+
18+
if (!response.ok) {
19+
console.error('eReputation API error:', response.status, response.statusText);
20+
return json({ error: 'Failed to fetch references', references: [] }, { status: 500 });
21+
}
22+
23+
const data = await response.json();
24+
return json(data);
25+
} catch (error) {
26+
console.error('Error fetching references from eReputation:', error);
27+
return json({ error: 'Failed to connect to eReputation API', references: [] }, { status: 500 });
28+
}
29+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { PageServerLoad } from './$types';
2+
3+
export interface ReferenceEdge {
4+
id: string;
5+
content: string;
6+
numericScore: number | null;
7+
referenceType: string;
8+
status: string;
9+
targetType: string; // "user" | "group" | "platform"
10+
targetId: string;
11+
targetName: string;
12+
author: {
13+
id: string;
14+
ename: string;
15+
name: string;
16+
};
17+
createdAt: string;
18+
}
19+
20+
21+
export const load: PageServerLoad = async ({ fetch }) => {
22+
try {
23+
const response = await fetch('/api/references');
24+
const data = await response.json();
25+
return { references: (data.references ?? []) as ReferenceEdge[] };
26+
} catch (error) {
27+
console.error('Error loading references for visualizer:', error);
28+
return { references: [] as ReferenceEdge[] };
29+
}
30+
};

0 commit comments

Comments
 (0)