Skip to content

Commit 233af4d

Browse files
hemanandrclaude
andcommitted
feat: integrate frontend with backend API endpoints
- Add CORS support to backend server for frontend communication - Update API base URL from HTTPS to HTTP (localhost:8080) - Fix TypeScript interface property naming (camelCase vs snake_case) - Update StatusCard and StatusTable components to use correct property names - Enable real-time monitoring dashboard with live data updates - Successfully connect React frontend to ASP.NET Core backend 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c33b462 commit 233af4d

File tree

8 files changed

+41
-26
lines changed

8 files changed

+41
-26
lines changed

ThingConnect.Pulse.Server/Program.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public static void Main(string[] args)
4141
builder.Services.AddScoped<IRollupService, RollupService>();
4242
builder.Services.AddHostedService<RollupBackgroundService>();
4343

44+
// Add CORS
45+
builder.Services.AddCors(options =>
46+
{
47+
options.AddPolicy("AllowFrontend", policy =>
48+
{
49+
policy.WithOrigins("https://localhost:55610", "http://localhost:55610", "https://localhost:5173", "http://localhost:5173")
50+
.AllowAnyHeader()
51+
.AllowAnyMethod()
52+
.AllowCredentials();
53+
});
54+
});
55+
4456
builder.Services.AddControllers(options =>
4557
{
4658
options.InputFormatters.Insert(0, new PlainTextInputFormatter());
@@ -71,6 +83,8 @@ public static void Main(string[] args)
7183

7284
app.UseHttpsRedirection();
7385

86+
app.UseCors("AllowFrontend");
87+
7488
app.UseAuthorization();
7589

7690

ThingConnect.Pulse.Server/obj/Debug/net8.0/ThingConnect.Pulse.Server.AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
1515
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © ThingConnect")]
1616
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
17-
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3a294e086be93bc15b5733ca48ac4615085a8245")]
17+
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c33b462d292456639bcdab9dc1aeb21dc3905be7")]
1818
[assembly: System.Reflection.AssemblyProductAttribute("ThingConnect Pulse")]
1919
[assembly: System.Reflection.AssemblyTitleAttribute("ThingConnect.Pulse.Server")]
2020
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8a1fb2df661e673303a0c0d596ddad65f1dfa609647534d72b076f8c4a02743e
1+
75baa4a277ba113daa8bc7c085331d1e439c901812cbcd2e6d1c0a410954db4b

thingconnect.pulse.client/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Development environment variables for ThingConnect Pulse Frontend
22

33
# Backend API Configuration
4-
VITE_API_BASE_URL=https://localhost:7057
4+
VITE_API_BASE_URL=http://localhost:8080
55
VITE_API_TIMEOUT=30000
66

77
# Development Settings

thingconnect.pulse.client/obj/Debug/package.g.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<PackageJsonDependenciesMonacoEditorReact Condition="$(PackageJsonDependenciesMonacoEditorReact) == ''">^4.7.0</PackageJsonDependenciesMonacoEditorReact>
1818
<PackageJsonDependenciesTanstackReactQuery Condition="$(PackageJsonDependenciesTanstackReactQuery) == ''">^5.84.2</PackageJsonDependenciesTanstackReactQuery>
1919
<PackageJsonDependenciesAxios Condition="$(PackageJsonDependenciesAxios) == ''">^1.11.0</PackageJsonDependenciesAxios>
20+
<PackageJsonDependenciesDateFns Condition="$(PackageJsonDependenciesDateFns) == ''">^4.1.0</PackageJsonDependenciesDateFns>
2021
<PackageJsonDependenciesLodash Condition="$(PackageJsonDependenciesLodash) == ''">^4.17.21</PackageJsonDependenciesLodash>
2122
<PackageJsonDependenciesLucideReact Condition="$(PackageJsonDependenciesLucideReact) == ''">^0.541.0</PackageJsonDependenciesLucideReact>
2223
<PackageJsonDependenciesLuxon Condition="$(PackageJsonDependenciesLuxon) == ''">^3.7.1</PackageJsonDependenciesLuxon>

thingconnect.pulse.client/src/api/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
export interface Group {
55
id: string
66
name: string
7-
parent_id?: string | null
7+
parentId?: string | null
88
color?: string | null
99
}
1010

@@ -15,10 +15,10 @@ export interface Endpoint {
1515
type: 'icmp' | 'tcp' | 'http'
1616
host: string
1717
port?: number | null
18-
http_path?: string | null
19-
http_match?: string | null
20-
interval_seconds: number
21-
timeout_ms: number
18+
httpPath?: string | null
19+
httpMatch?: string | null
20+
intervalSeconds: number
21+
timeoutMs: number
2222
retries: number
2323
enabled: boolean
2424
}
@@ -31,8 +31,8 @@ export interface SparklinePoint {
3131
export interface LiveStatusItem {
3232
endpoint: Endpoint
3333
status: 'up' | 'down' | 'flapping'
34-
rtt_ms?: number | null
35-
last_change_ts: string
34+
rttMs?: number | null
35+
lastChangeTs: string
3636
sparkline: SparklinePoint[]
3737
}
3838

thingconnect.pulse.client/src/components/status/StatusCard.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export function StatusCard({ item }: StatusCardProps) {
2020
}
2121
}
2222

23-
const formatRTT = (rtt?: number | null) => {
24-
if (rtt == null) return '-'
25-
return `${rtt}ms`
23+
const formatRTT = (rttMs?: number | null) => {
24+
if (rttMs == null) return '-'
25+
return `${rttMs}ms`
2626
}
2727

28-
const formatLastChange = (timestamp: string) => {
28+
const formatLastChange = (lastChangeTs: string) => {
2929
try {
30-
return formatDistanceToNow(new Date(timestamp), { addSuffix: true })
30+
return formatDistanceToNow(new Date(lastChangeTs), { addSuffix: true })
3131
} catch {
3232
return 'Unknown'
3333
}
@@ -91,18 +91,18 @@ export function StatusCard({ item }: StatusCardProps) {
9191
<Text
9292
fontFamily="mono"
9393
fontSize="xs"
94-
color={item.rtt_ms ? 'inherit' : 'gray.400'}
94+
color={item.rttMs ? 'inherit' : 'gray.400'}
9595
data-testid="card-endpoint-rtt"
9696
>
97-
{formatRTT(item.rtt_ms)}
97+
{formatRTT(item.rttMs)}
9898
</Text>
9999
</HStack>
100100

101101
{/* Sparkline and last change */}
102102
<HStack justify="space-between" align="center">
103103
<MiniSparkline data={item.sparkline} width={60} height={16} />
104104
<Text fontSize="xs" color="gray.500">
105-
{formatLastChange(item.last_change_ts)}
105+
{formatLastChange(item.lastChangeTs)}
106106
</Text>
107107
</HStack>
108108
</VStack>

thingconnect.pulse.client/src/components/status/StatusTable.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ export function StatusTable({ items, isLoading }: StatusTableProps) {
2222
}
2323
}
2424

25-
const formatRTT = (rtt?: number | null) => {
26-
if (rtt == null) return '-'
27-
return `${rtt}ms`
25+
const formatRTT = (rttMs?: number | null) => {
26+
if (rttMs == null) return '-'
27+
return `${rttMs}ms`
2828
}
2929

30-
const formatLastChange = (timestamp: string) => {
30+
const formatLastChange = (lastChangeTs: string) => {
3131
try {
32-
return formatDistanceToNow(new Date(timestamp), { addSuffix: true })
32+
return formatDistanceToNow(new Date(lastChangeTs), { addSuffix: true })
3333
} catch {
3434
return 'Unknown'
3535
}
@@ -144,16 +144,16 @@ export function StatusTable({ items, isLoading }: StatusTableProps) {
144144
<Text
145145
fontFamily="mono"
146146
fontSize="sm"
147-
color={item.rtt_ms ? 'inherit' : 'gray.400'}
147+
color={item.rttMs ? 'inherit' : 'gray.400'}
148148
data-testid="endpoint-rtt"
149149
>
150-
{formatRTT(item.rtt_ms)}
150+
{formatRTT(item.rttMs)}
151151
</Text>
152152
</Table.Cell>
153153

154154
<Table.Cell>
155155
<Text fontSize="sm" color="gray.600" _dark={{ color: 'gray.400' }}>
156-
{formatLastChange(item.last_change_ts)}
156+
{formatLastChange(item.lastChangeTs)}
157157
</Text>
158158
</Table.Cell>
159159

0 commit comments

Comments
 (0)