Skip to content

Commit df599c0

Browse files
authored
Merge pull request #23 from aaronlmathis/UI/Endpoint-Details
UI/endpoint details
2 parents bac8a50 + 412a41d commit df599c0

19 files changed

Lines changed: 3029 additions & 1316 deletions

File tree

UI/src/app.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,18 @@ declare global {
2323
}
2424
}
2525

26+
declare module 'svelte-apexcharts' {
27+
import { SvelteComponentTyped } from 'svelte';
28+
29+
export interface ApexChartProps {
30+
options?: any;
31+
series?: any;
32+
type?: string;
33+
width?: string | number;
34+
height?: string | number;
35+
}
36+
37+
export default class ApexChart extends SvelteComponentTyped<ApexChartProps> {}
38+
}
39+
2640
export {};

UI/src/lib/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* API client for GoSight backend
33
*/
4-
import type { AlertRule, AlertRulesResponse, EndpointsResponse, Endpoint } from './types';
4+
import type { AlertRule, AlertRulesResponse, EndpointsResponse, Endpoint, LogResponse } from './types';
55

66
export interface ApiError {
77
message: string;
@@ -223,7 +223,7 @@ export class LogsApi {
223223
container_id?: string;
224224
platform?: string;
225225
[key: string]: any; // for dynamic tag_* and field_* and meta_* parameters
226-
} = {}) {
226+
} = {}): Promise<LogResponse> {
227227
const searchParams = new URLSearchParams();
228228

229229
// Handle array parameters (levels, categories)
@@ -255,7 +255,7 @@ export class LogsApi {
255255
return this.api.request(`/logs${query ? `?${query}` : ''}`);
256256
}
257257

258-
async getRecent(limit = 50) {
258+
async getRecent(limit = 50): Promise<LogResponse> {
259259
return this.api.request(`/logs/latest?limit=${limit}`);
260260
}
261261
}
@@ -633,7 +633,7 @@ async getMetrics(params?: any) {
633633
return this.metrics.getAll(params);
634634
}
635635

636-
async getLogs(params?: any) {
636+
async getLogs(params?: any): Promise<LogResponse> {
637637
return this.logs.getAll(params);
638638
}
639639

UI/src/lib/svelte-apexcharts.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module 'svelte-apexcharts' {
2+
export function chart(node: HTMLElement, options: any): {
3+
update(options: any): void;
4+
};
5+
}

UI/src/lib/types.ts

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,25 @@ export interface EndpointMetric {
246246

247247
// Metric types
248248
export interface Metric {
249-
id: string;
249+
id?: string;
250250
name: string;
251-
type: 'gauge' | 'counter' | 'histogram';
251+
namespace?: string;
252+
subnamespace?: string;
253+
type?: 'gauge' | 'counter' | 'histogram';
252254
value: number;
253-
unit: string;
254-
labels: Record<string, string>;
255+
unit?: string;
256+
labels?: Record<string, string>;
257+
dimensions?: Record<string, string>;
255258
timestamp: string;
256259
endpointId?: string;
257260
endpoint_id?: string;
261+
stats?: {
262+
min: number;
263+
max: number;
264+
count: number;
265+
sum: number;
266+
};
267+
resolution?: number;
258268
}
259269

260270
export interface MetricSeries {
@@ -287,29 +297,39 @@ export interface Event {
287297
}
288298

289299
// Log types
300+
export interface LogMeta {
301+
platform?: string;
302+
app_name?: string;
303+
app_version?: string;
304+
container_id?: string;
305+
container_name?: string;
306+
unit?: string;
307+
service?: string;
308+
event_id?: string;
309+
user?: string;
310+
exe?: string;
311+
path?: string;
312+
extra?: Record<string, string>;
313+
}
314+
290315
export interface LogEntry {
291-
id: string;
292-
timestamp: string;
293-
level: 'debug' | 'info' | 'warning' | 'error' | 'fatal' | 'critical';
316+
id?: string; // Optional client-side ID for deduplication
317+
timestamp: string; // ISO timestamp
318+
level: string;
294319
message: string;
295320
source: string;
296321
category?: string;
297-
endpointId?: string;
298-
endpoint_id?: string;
299-
endpoint_name?: string;
300-
metadata?: Record<string, any>;
301-
meta?: Record<string, any>;
322+
pid?: number;
323+
fields?: Record<string, string>;
302324
tags?: Record<string, string>;
303-
target?: string;
304-
unit?: string;
305-
app_name?: string;
306-
service?: string;
307-
event_id?: string;
308-
user?: string;
309-
container_id?: string;
310-
container_name?: string;
311-
platform?: string;
312-
fields?: Record<string, any>;
325+
meta?: LogMeta;
326+
}
327+
328+
export interface LogResponse {
329+
logs: LogEntry[];
330+
next_cursor?: string;
331+
has_more: boolean;
332+
count: number;
313333
}
314334

315335
// Process types

UI/src/lib/websocket.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,14 @@ export const websocketManager = {
164164
}
165165
});
166166
return unsubscribe;
167+
},
168+
169+
subscribeToProcesses(callback: (data: any) => void) {
170+
const unsubscribe = processesWS.messages.subscribe((messages) => {
171+
if (messages.length > 0) {
172+
callback(messages[0]);
173+
}
174+
});
175+
return unsubscribe;
167176
}
168177
};

0 commit comments

Comments
 (0)