Skip to content

Commit dc03760

Browse files
committed
updates to processors table
1 parent c6296aa commit dc03760

File tree

8 files changed

+457
-34
lines changed

8 files changed

+457
-34
lines changed

components/Forms/CpuForm.vue

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -961,16 +961,23 @@ const submitCore = async () => {
961961
}
962962
963963
const url = editingCore.value
964-
? `${useRuntimeConfig().public.backendUrl}/cpus/${cpuId}/cores/${editingCore.value.core_id}`
965-
: `${useRuntimeConfig().public.backendUrl}/cpus/${cpuId}/cores`
964+
? `/api/cpus/${cpuId}/cores/${editingCore.value.core_id}`
965+
: `/api/cpus/${cpuId}/cores`
966966
967967
const method = editingCore.value ? 'PUT' : 'POST'
968+
const authToken = getAuthToken()
969+
970+
// #region agent log
971+
if (typeof fetch !== 'undefined') {
972+
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'CpuForm.vue:950',message:'submitCore called',data:{cpuId,url,method,hasAuthToken:!!authToken,windowLocation:typeof window !== 'undefined' ? window.location.href : 'server',isLocalhost:typeof window !== 'undefined' ? window.location.hostname === 'localhost' : false},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
973+
}
974+
// #endregion
968975
969976
const response = await fetch(url, {
970977
method,
971978
headers: {
972979
'Content-Type': 'application/json',
973-
'Authorization': `Bearer ${getAuthToken()}`
980+
'Authorization': `Bearer ${authToken}`
974981
},
975982
body: JSON.stringify({
976983
core_name: coreForm.value.core_name,
@@ -980,6 +987,12 @@ const submitCore = async () => {
980987
})
981988
})
982989
990+
// #region agent log
991+
if (typeof fetch !== 'undefined') {
992+
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'CpuForm.vue:982',message:'submitCore response',data:{status:response.status,statusText:response.statusText,ok:response.ok,url:response.url,actualUrl:url},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
993+
}
994+
// #endregion
995+
983996
if (response.ok) {
984997
successMessage.value = `Core ${editingCore.value ? 'updated' : 'added'} successfully!`
985998
cancelCoreForm()
@@ -989,12 +1002,24 @@ const submitCore = async () => {
9891002
// Emit event to refresh data without page reload
9901003
emit('data-refreshed')
9911004
} else {
992-
const errorData = await response.json()
1005+
const errorData = await response.json().catch(() => ({ error: 'Failed to parse error response' }))
9931006
errorMessage.value = errorData.error || 'Failed to save core'
1007+
1008+
// #region agent log
1009+
if (typeof fetch !== 'undefined') {
1010+
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'CpuForm.vue:992',message:'submitCore error response',data:{status:response.status,errorData},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});
1011+
}
1012+
// #endregion
9941013
}
9951014
} catch (error) {
9961015
console.error('Error submitting core:', error)
9971016
errorMessage.value = 'Error submitting core'
1017+
1018+
// #region agent log
1019+
if (typeof fetch !== 'undefined') {
1020+
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'CpuForm.vue:996',message:'submitCore exception',data:{errorMessage:error.message,errorName:error.name,errorStack:error.stack?.substring(0,300)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
1021+
}
1022+
// #endregion
9981023
}
9991024
}
10001025
@@ -1008,7 +1033,7 @@ const deleteCore = async (coreId) => {
10081033
return
10091034
}
10101035
1011-
const response = await fetch(`${useRuntimeConfig().public.backendUrl}/cpus/${cpuId}/cores/${coreId}`, {
1036+
const response = await fetch(`/api/cpus/${cpuId}/cores/${coreId}`, {
10121037
method: 'DELETE',
10131038
headers: {
10141039
'Authorization': `Bearer ${getAuthToken()}`

components/Forms/GpuForm.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,8 @@ const submitCore = async () => {
11721172
}
11731173
11741174
const url = editingCore.value
1175-
? `${useRuntimeConfig().public.backendUrl}/gpus/${gpuId}/cores/${editingCore.value.core_id}`
1176-
: `${useRuntimeConfig().public.backendUrl}/gpus/${gpuId}/cores`
1175+
? `/api/gpus/${gpuId}/cores/${editingCore.value.core_id}`
1176+
: `/api/gpus/${gpuId}/cores`
11771177
11781178
const method = editingCore.value ? 'PUT' : 'POST'
11791179
@@ -1219,7 +1219,7 @@ const deleteCore = async (coreId) => {
12191219
return
12201220
}
12211221
1222-
const response = await fetch(`${useRuntimeConfig().public.backendUrl}/gpus/${gpuId}/cores/${coreId}`, {
1222+
const response = await fetch(`/api/gpus/${gpuId}/cores/${coreId}`, {
12231223
method: 'DELETE',
12241224
headers: {
12251225
'Authorization': `Bearer ${getAuthToken()}`

components/Forms/SocForm.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ const associateProcessor = async (processor) => {
888888
889889
try {
890890
const config = useRuntimeConfig()
891+
console.log('[SocForm] Backend URL from config:', config.public.backendUrl)
891892
// Normalize backendUrl - remove trailing slash and handle /api prefix
892893
let backendUrl = config.public.backendUrl || 'http://localhost:3001'
893894
backendUrl = backendUrl.replace(/\/$/, '') // Remove trailing slash

components/PrivateTable.vue

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,12 @@ const formatYear = (date) => {
287287
const uniqueId = (row) => {
288288
const socClass = props.className.toLowerCase();
289289
290-
// #region agent log
291-
if (typeof fetch !== 'undefined') {
292-
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'PrivateTable.vue:uniqueId',message:'uniqueId called',data:{className:props.className,socClass:socClass,rowKeys:Object.keys(row),soc_id:row.soc_id,id:row.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
293-
}
294-
// #endregion
295-
296290
switch (socClass) {
297291
case 'soc':
298292
case 'socs':
299293
// For SOC, use soc_id for linking to detail page
300294
// Multiple rows may share same soc_id (one per processor), which is fine for detail links
301295
const socId = row.soc_id || row.id;
302-
303-
// #region agent log
304-
if (typeof fetch !== 'undefined') {
305-
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'PrivateTable.vue:uniqueId',message:'SOC ID resolved',data:{socId:socId,type:typeof socId,isString:typeof socId === 'string',containsApi:socId && typeof socId === 'string' && socId.includes('/api/')},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
306-
}
307-
// #endregion
308-
309296
return socId;
310297
case 'cpu':
311298
return row.cpu_id || '';
@@ -322,24 +309,11 @@ const getDetailPath = (row) => {
322309
const id = uniqueId(row);
323310
const basePath = props.className.replace(/s$/i, '');
324311
const fullPath = `/${basePath}/${id}`;
325-
326-
// #region agent log
327-
if (typeof fetch !== 'undefined') {
328-
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'PrivateTable.vue:getDetailPath',message:'Detail path generated',data:{className:props.className,basePath:basePath,id:id,fullPath:fullPath,containsApi:fullPath.includes('/api/')},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
329-
}
330-
// #endregion
331-
332312
return fullPath;
333313
}
334314
335315
const logNavigation = (row) => {
336316
const path = getDetailPath(row);
337-
338-
// #region agent log
339-
if (typeof fetch !== 'undefined') {
340-
fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'PrivateTable.vue:logNavigation',message:'Navigation clicked',data:{path:path,rowId:row.soc_id || row.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});
341-
}
342-
// #endregion
343317
}
344318
345319
// --- Helper: Format Column Label ---

server/api/cpus/[id]/cores.js

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
import { defineEventHandler, createError, getRouterParam, readBody } from 'h3'
2+
3+
export default defineEventHandler(async (event) => {
4+
// #region agent log
5+
const logData = {
6+
location: 'server/api/cpus/[id]/cores.js:3',
7+
message: 'Cores API route entry',
8+
data: {
9+
url: event.node.req.url,
10+
method: event.node.req.method,
11+
hasAuthHeader: !!event.node.req.headers.authorization,
12+
nodeEnv: process.env.NODE_ENV,
13+
isPrerender: import.meta.prerender
14+
},
15+
timestamp: Date.now(),
16+
sessionId: 'debug-session',
17+
runId: 'run1',
18+
hypothesisId: 'A'
19+
}
20+
try {
21+
await fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0', {
22+
method: 'POST',
23+
headers: { 'Content-Type': 'application/json' },
24+
body: JSON.stringify(logData)
25+
}).catch(() => {})
26+
} catch {}
27+
// #endregion
28+
29+
if (import.meta.prerender) {
30+
throw createError({
31+
statusCode: 404,
32+
statusMessage: 'Not available during build'
33+
})
34+
}
35+
36+
try {
37+
const cpuId = getRouterParam(event, 'id')
38+
const method = event.node.req.method
39+
40+
if (!cpuId) {
41+
throw createError({
42+
statusCode: 400,
43+
statusMessage: 'CPU ID is required'
44+
})
45+
}
46+
47+
const config = useRuntimeConfig()
48+
let backendUrl = config.public.backendUrl || 'http://localhost:3001'
49+
backendUrl = backendUrl.replace(/\/$/, '')
50+
const apiPrefix = backendUrl.endsWith('/api') ? '' : '/api'
51+
const url = `${backendUrl}${apiPrefix}/cpus/${cpuId}/cores`
52+
53+
// #region agent log
54+
const logData2 = {
55+
location: 'server/api/cpus/[id]/cores.js:26',
56+
message: 'Backend URL constructed',
57+
data: {
58+
cpuId,
59+
method,
60+
backendUrl: config.public.backendUrl,
61+
constructedUrl: url,
62+
apiPrefix,
63+
hasBackendUrl: !!config.public.backendUrl
64+
},
65+
timestamp: Date.now(),
66+
sessionId: 'debug-session',
67+
runId: 'run1',
68+
hypothesisId: 'B'
69+
}
70+
try {
71+
await fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0', {
72+
method: 'POST',
73+
headers: { 'Content-Type': 'application/json' },
74+
body: JSON.stringify(logData2)
75+
}).catch(() => {})
76+
} catch {}
77+
// #endregion
78+
79+
// Get auth token from headers
80+
const authHeader = event.node.req.headers.authorization
81+
82+
// #region agent log
83+
const logData3 = {
84+
location: 'server/api/cpus/[id]/cores.js:38',
85+
message: 'Auth header check',
86+
data: {
87+
hasAuthHeader: !!authHeader,
88+
authHeaderPrefix: authHeader ? authHeader.substring(0, 20) : null,
89+
method
90+
},
91+
timestamp: Date.now(),
92+
sessionId: 'debug-session',
93+
runId: 'run1',
94+
hypothesisId: 'C'
95+
}
96+
try {
97+
await fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0', {
98+
method: 'POST',
99+
headers: { 'Content-Type': 'application/json' },
100+
body: JSON.stringify(logData3)
101+
}).catch(() => {})
102+
} catch {}
103+
// #endregion
104+
105+
const options = {
106+
method,
107+
headers: {
108+
'Content-Type': 'application/json',
109+
'Accept': 'application/json'
110+
}
111+
}
112+
113+
if (authHeader) {
114+
options.headers['Authorization'] = authHeader
115+
}
116+
117+
// Handle request body for POST/PUT
118+
if (method === 'POST' || method === 'PUT') {
119+
const body = await readBody(event)
120+
options.body = JSON.stringify(body)
121+
}
122+
123+
// #region agent log
124+
const logData4 = {
125+
location: 'server/api/cpus/[id]/cores.js:60',
126+
message: 'Before backend fetch',
127+
data: {
128+
url,
129+
method,
130+
hasAuth: !!options.headers['Authorization'],
131+
hasBody: !!options.body
132+
},
133+
timestamp: Date.now(),
134+
sessionId: 'debug-session',
135+
runId: 'run1',
136+
hypothesisId: 'D'
137+
}
138+
try {
139+
await fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0', {
140+
method: 'POST',
141+
headers: { 'Content-Type': 'application/json' },
142+
body: JSON.stringify(logData4)
143+
}).catch(() => {})
144+
} catch {}
145+
// #endregion
146+
147+
const response = await fetch(url, options)
148+
149+
// #region agent log
150+
const logData5 = {
151+
location: 'server/api/cpus/[id]/cores.js:68',
152+
message: 'Backend response received',
153+
data: {
154+
status: response.status,
155+
statusText: response.statusText,
156+
ok: response.ok,
157+
url
158+
},
159+
timestamp: Date.now(),
160+
sessionId: 'debug-session',
161+
runId: 'run1',
162+
hypothesisId: 'E'
163+
}
164+
try {
165+
await fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0', {
166+
method: 'POST',
167+
headers: { 'Content-Type': 'application/json' },
168+
body: JSON.stringify(logData5)
169+
}).catch(() => {})
170+
} catch {}
171+
// #endregion
172+
173+
if (!response.ok) {
174+
const errorText = await response.text()
175+
throw createError({
176+
statusCode: response.status,
177+
statusMessage: `Backend API error: ${response.statusText}`
178+
})
179+
}
180+
181+
const data = await response.json()
182+
return data
183+
} catch (error) {
184+
// #region agent log
185+
const logData6 = {
186+
location: 'server/api/cpus/[id]/cores.js:85',
187+
message: 'Cores API error',
188+
data: {
189+
errorMessage: error.message,
190+
errorStatus: error.statusCode,
191+
errorStatusMessage: error.statusMessage,
192+
stack: error.stack?.substring(0, 200)
193+
},
194+
timestamp: Date.now(),
195+
sessionId: 'debug-session',
196+
runId: 'run1',
197+
hypothesisId: 'F'
198+
}
199+
try {
200+
await fetch('http://127.0.0.1:7242/ingest/a2e5b876-28c3-4b64-9549-c4e9792dd0b0', {
201+
method: 'POST',
202+
headers: { 'Content-Type': 'application/json' },
203+
body: JSON.stringify(logData6)
204+
}).catch(() => {})
205+
} catch {}
206+
// #endregion
207+
208+
console.error('Error in cores API:', error)
209+
throw createError({
210+
statusCode: error.statusCode || 500,
211+
statusMessage: error.statusMessage || 'Failed to fetch cores data'
212+
})
213+
}
214+
})
215+

0 commit comments

Comments
 (0)