EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
page.tsx
Go to the documentation of this file.
1"use client";
2
3import { useEffect, useState } from "react";
4import { apiClient } from "@/lib/client/apiClient";
5import { Icon } from '@/contexts/IconContext';
6
7interface TopologyEntry {
8 f141: string; // Computer Name
9 f110: number; // AppType#
10 f1110: string; // AppType
11 f1111: string; // Rank
12 f113: number; // PLevel
13 f144: number; // Location
14 f114: string; // Database Id
15 f131?: string; // IP Address
16 f151?: number; // IP Port
17}
18
19export default function TopologyPage() {
20 const [topology, setTopology] = useState<TopologyEntry[]>([]);
21 const [loading, setLoading] = useState(true);
22
23 useEffect(() => {
24 loadTopology();
25 }, []);
26
27 const loadTopology = async () => {
28 try {
29 setLoading(true);
30 const result = await apiClient.getTopology();
31
32 if (result.success && result.data?.DATS) {
33 setTopology(result.data.DATS);
34 }
35 } catch (error) {
36 console.error("Error loading topology:", error);
37 } finally {
38 setLoading(false);
39 }
40 };
41
42 if (loading) {
43 return (
44 <div className="p-6 min-h-screen">
45 <div className="animate-pulse space-y-4">
46 <div className="h-8 bg-surface-2 rounded w-1/4"></div>
47 <div className="h-64 bg-surface-2 rounded"></div>
48 </div>
49 </div>
50 );
51 }
52
53 return (
54 <div className="p-6 min-h-screen">
55 {/* Header */}
56 <div className="mb-6">
57 <div className="flex items-center gap-4 mb-4">
58 <a
59 href="/pages/settings/stores"
60 className="text-brand hover:text-brand2 flex items-center gap-2"
61 >
62 <Icon name="arrow_back" size={20} />
63 Back to Stores
64 </a>
65 </div>
66 <h1 className="text-3xl font-bold text-text mb-2 flex items-center gap-3">
67 <Icon name="hub" size={32} />
68 Network Topology
69 </h1>
70 <p className="text-muted">
71 Shows what has been detected running inside your network in recent history
72 </p>
73 </div>
74
75 {/* Topology Table */}
76 <div className="bg-surface rounded-lg shadow overflow-hidden">
77 <div className="overflow-x-auto">
78 <table className="w-full">
79 <thead className="bg-[var(--brand)] text-surface">
80 <tr>
81 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
82 Computer Name
83 </th>
84 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
85 AppType#
86 </th>
87 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
88 AppType
89 </th>
90 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
91 Rank
92 </th>
93 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
94 PLevel
95 </th>
96 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
97 Location
98 </th>
99 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
100 Database Id
101 </th>
102 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
103 IP Address
104 </th>
105 <th className="px-6 py-3 text-left text-xs font-medium text-muted uppercase tracking-wider">
106 IP Port
107 </th>
108 </tr>
109 </thead>
110 <tbody className="bg-surface divide-y divide-gray-200">
111 {topology.length === 0 ? (
112 <tr>
113 <td colSpan={9} className="px-6 py-8 text-center text-muted">
114 No topology data detected
115 </td>
116 </tr>
117 ) : (
118 topology.map((entry, index) => (
119 <tr key={index} className="hover:bg-surface-2">
120 <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-text">
121 {entry.f141}
122 </td>
123 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted">
124 {entry.f110}
125 </td>
126 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted">
127 {entry.f1110 || "—"}
128 </td>
129 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted">
130 {entry.f1111 || "—"}
131 </td>
132 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted">
133 {entry.f113}
134 </td>
135 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted">
136 {entry.f144}
137 </td>
138 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted font-mono text-xs">
139 {entry.f114}
140 </td>
141 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted">
142 {entry.f131 || "—"}
143 </td>
144 <td className="px-6 py-4 whitespace-nowrap text-sm text-muted">
145 {entry.f151 || "—"}
146 </td>
147 </tr>
148 ))
149 )}
150 </tbody>
151 </table>
152 </div>
153
154 {/* Summary */}
155 <div className="bg-surface-2 px-6 py-3 border-t">
156 <p className="text-sm text-muted">
157 Total systems detected: <span className="font-semibold">{topology.length}</span>
158 </p>
159 </div>
160 </div>
161 </div>
162 );
163}