Skip to content

Commit 777f4e7

Browse files
MarkoVcodeclaude
andcommitted
Fix frontend API calls to use correct endpoint format
Updated PSU and DMM components to use the correct API endpoint format without set_ and query_ prefixes. The API has smart resolution that automatically maps: - GET requests: partial names → query_* methods - POST requests: partial names → set_* methods Changes: - PSU component: - GET: /voltage instead of /query_voltage - GET: /current instead of /query_current - POST: /voltage/{value} instead of /set_voltage/{value} - POST: /current/{value} instead of /set_current/{value} - GET: /output_voltage instead of /query_output_voltage - GET: /output_current instead of /query_output_current - GET: /output_power instead of /query_output_power - DMM component: - POST: /mode/{value} instead of /set_mode/{value} - GET: /voltage instead of /query_voltage - GET: /current instead of /query_current - GET: /power instead of /query_power This aligns with the API naming convention documented in CLAUDE.md which prevents arbitrary method execution and enforces the security model where only query_* and set_* methods are accessible. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1a00ed7 commit 777f4e7

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

benchmesh-serial-service/frontend/src/ui/classes/DMM/GenericDMM.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function GenericDMM({ channelPath, registry }: { channelPath?: string, re
128128
const k = klass || 'DMM'
129129
const did = deviceId || '{id}'
130130
const ch = channel || '1'
131-
return `/instruments/${k}/${did}/${ch}/set_mode/{value}`
131+
return `/instruments/${k}/${did}/${ch}/mode/{value}`
132132
}, [klass, deviceId, channel])
133133

134134
const handleModeChange = async (newMode: string) => {
@@ -404,9 +404,9 @@ function ReadonlyBigNumber({ kind, label, value, channelPath, parameter }: { kin
404404
</label>
405405
</div>
406406
<span className="psu-api" title={
407-
kind === 'U' ? `GET ${channelPath}/query_voltage` :
408-
kind === 'I' ? `GET ${channelPath}/query_current` :
409-
kind === 'P' ? `GET ${channelPath}/query_power` : ''
407+
kind === 'U' ? `GET ${channelPath}/voltage` :
408+
kind === 'I' ? `GET ${channelPath}/current` :
409+
kind === 'P' ? `GET ${channelPath}/power` : ''
410410
}>API</span>
411411
</>
412412
)}

benchmesh-serial-service/frontend/src/ui/classes/PSU/GenericPSU.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export function GenericPSU({ channelPath, registry }: { channelPath?: string, re
6767
if (!channelPath) return
6868
try {
6969
const [rv, rc] = await Promise.all([
70-
fetch(`${apiBase}${channelPath}/query_voltage`),
71-
fetch(`${apiBase}${channelPath}/query_current`),
70+
fetch(`${apiBase}${channelPath}/voltage`),
71+
fetch(`${apiBase}${channelPath}/current`),
7272
])
7373
if (!cancelled) {
7474
if (rv.ok) {
@@ -182,8 +182,8 @@ function EditableBigNumber({ kind, label, value, onChange, withSet, channelPath,
182182
{withSet && channelPath && (
183183
<>
184184
<button className="psu-set" type="button" disabled={busy} title={
185-
kind === 'U' ? `POST ${channelPath}/set_voltage/{value}` :
186-
kind === 'I' ? `POST ${channelPath}/set_current/{value}` : ''
185+
kind === 'U' ? `POST ${channelPath}/voltage/{value}` :
186+
kind === 'I' ? `POST ${channelPath}/current/{value}` : ''
187187
} onClick={async (e) => {
188188
e.preventDefault(); e.stopPropagation();
189189
if (busy) return
@@ -192,16 +192,16 @@ function EditableBigNumber({ kind, label, value, onChange, withSet, channelPath,
192192
const endp = (kind as string | undefined) || ((label as any)?.props?.symbol as string | undefined)
193193
const val = value || '0'
194194
let url: string | undefined
195-
if (endp === 'U') url = `${apiBase}${channelPath}/set_voltage/${val}`
196-
if (endp === 'I') url = `${apiBase}${channelPath}/set_current/${val}`
195+
if (endp === 'U') url = `${apiBase}${channelPath}/voltage/${val}`
196+
if (endp === 'I') url = `${apiBase}${channelPath}/current/${val}`
197197
if (url) await fetch(url, { method: 'POST' })
198198
} catch (err) {
199199
console.debug('SET failed', err)
200200
} finally { setBusy(false) }
201201
}}>{busy ? (<><span className="spinner"/>SET</>) : 'SET'}</button>
202202
<span className="psu-api" title={
203-
kind === 'U' ? `GET ${channelPath}/query_voltage` :
204-
kind === 'I' ? `GET ${channelPath}/query_current` : (channelPath || '')
203+
kind === 'U' ? `GET ${channelPath}/voltage` :
204+
kind === 'I' ? `GET ${channelPath}/current` : (channelPath || '')
205205
}>API</span>
206206
</>
207207
)}
@@ -266,9 +266,9 @@ function ReadonlyBigNumber({ kind, label, value, channelPath, parameter }: { kin
266266
</label>
267267
</div>
268268
<span className="psu-api" title={
269-
kind === 'U' ? `GET ${channelPath}/query_output_voltage` :
270-
kind === 'I' ? `GET ${channelPath}/query_output_current` :
271-
kind === 'P' ? `GET ${channelPath}/query_output_power` : ''
269+
kind === 'U' ? `GET ${channelPath}/output_voltage` :
270+
kind === 'I' ? `GET ${channelPath}/output_current` :
271+
kind === 'P' ? `GET ${channelPath}/output_power` : ''
272272
}>API</span>
273273
</>
274274
)}

0 commit comments

Comments
 (0)