fix(web): restore merge-dropped API signatures and lost methods

The rebase-merge silently dropped parameter lists and const bindings
from several API methods, so calling them threw ReferenceError at
runtime (e.g. 'request is not defined' when opening a role, which
broke tag/plugin loading):

- agent.js: restore getAgentSnapshots/getAgentSnapshot/restoreAgentSnapshot/
  deleteAgentSnapshot (deleted by the merge but still used by
  AgentSnapshotDialog) and repair getAgentTags signature + request binding
- model.js: restore onTerminalFailure/retryCount/retryStartedAt params and
  const request bindings on getModelNames/getLlmModelCodeList/getModelVoices;
  restore getRAGModels used by KnowledgeBaseDialog
- device.js: restore dropped failCallback params on five methods
- admin.js: restore failCallback param on addParam (guarded call)
- register/retrievePassword: log the response object instead of the
  nonexistent 'error' identifier in the captcha else-branch

Verified with an AST no-undef scan (acorn+eslint-scope) across all
.vue/.js sources and an Api.* cross-reference against module exports.
agentSnapshotApi regression tests pass (7/7).
This commit is contained in:
lapy 2026-10-13 11:11:51 +01:00
parent 232b43fa6b
commit 583c5304a2
6 changed files with 125 additions and 17 deletions

View file

@ -80,7 +80,7 @@ export default {
}).send() }).send()
}, },
// Save // Save
addParam(data, callback) { addParam(data, callback, failCallback) {
RequestService.sendRequest() RequestService.sendRequest()
.url(`${getServiceUrl()}/admin/params`) .url(`${getServiceUrl()}/admin/params`)
.method('POST') .method('POST')
@ -91,7 +91,9 @@ export default {
}) })
.fail((err) => { .fail((err) => {
RequestService.clearRequestTime() RequestService.clearRequestTime()
failCallback(err) if (failCallback) {
failCallback(err)
}
}) })
.networkFail((err) => { .networkFail((err) => {
console.error('Failed to add parameter:', err) console.error('Failed to add parameter:', err)

View file

@ -116,7 +116,93 @@ export default {
}); });
}).send(); }).send();
}, },
// New method: Get agent template // Get agent config snapshot list
getAgentSnapshots(agentId, params, callback, onTerminalFailure, retryCount = 0, retryStartedAt = 0) {
const retryWindowStartedAt = retryStartedAt || Date.now()
const request = RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/${agentId}/snapshots`)
.method('GET')
.data(params)
.success((res) => {
RequestService.clearRequestTime();
callback(res);
})
.networkFail((error) => {
retryCallbackRequest(
(nextRetryCount, nextRetryStartedAt) => this.getAgentSnapshots(
agentId,
params,
callback,
onTerminalFailure,
nextRetryCount,
nextRetryStartedAt
),
retryCount,
onTerminalFailure,
error,
retryWindowStartedAt
)
})
attachTerminalFailure(request, onTerminalFailure).send();
},
// Get agent config snapshot detail
getAgentSnapshot(agentId, snapshotId, callback, onTerminalFailure, retryCount = 0, retryStartedAt = 0) {
const retryWindowStartedAt = retryStartedAt || Date.now()
const request = RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/${agentId}/snapshots/${snapshotId}`)
.method('GET')
.success((res) => {
RequestService.clearRequestTime();
callback(res);
})
.networkFail((error) => {
retryCallbackRequest(
(nextRetryCount, nextRetryStartedAt) => this.getAgentSnapshot(
agentId,
snapshotId,
callback,
onTerminalFailure,
nextRetryCount,
nextRetryStartedAt
),
retryCount,
onTerminalFailure,
error,
retryWindowStartedAt
)
})
attachTerminalFailure(request, onTerminalFailure).send();
},
// Restore agent config snapshot
restoreAgentSnapshot(agentId, snapshotId, currentStateToken, callback, onTerminalFailure) {
const request = RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/${agentId}/snapshots/${snapshotId}/restore`)
.method('POST')
.data({ currentStateToken })
.success((res) => {
RequestService.clearRequestTime();
callback(res);
})
.networkFail((error) => {
terminateCallbackRequest(onTerminalFailure, error)
})
attachTerminalFailure(request, onTerminalFailure).send();
},
// Delete Agent config snapshot
deleteAgentSnapshot(agentId, snapshotId, callback, onTerminalFailure) {
const request = RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/${agentId}/snapshots/${snapshotId}`)
.method('DELETE')
.success((res) => {
RequestService.clearRequestTime();
callback(res);
})
.networkFail((error) => {
terminateCallbackRequest(onTerminalFailure, error)
})
attachTerminalFailure(request, onTerminalFailure).send();
},
// New method: Get Agent template
getAgentTemplate(callback) { // Remove templateName parameter getAgentTemplate(callback) { // Remove templateName parameter
RequestService.sendRequest() RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/template`) .url(`${getServiceUrl()}/agent/template`)
@ -459,8 +545,9 @@ export default {
}); });
}).send(); }).send();
}, },
getAgentTags(agentId, callback) { getAgentTags(agentId, callback, onTerminalFailure, retryCount = 0, retryStartedAt = 0) {
RequestService.sendRequest() const retryWindowStartedAt = retryStartedAt || Date.now()
const request = RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/${agentId}/tags`) .url(`${getServiceUrl()}/agent/${agentId}/tags`)
.method('GET') .method('GET')
.success((res) => { .success((res) => {

View file

@ -3,7 +3,7 @@ import RequestService from '../httpRequest';
export default { export default {
// Bound devices // Bound devices
getAgentBindDevices(agentId, callback) { getAgentBindDevices(agentId, callback, failCallback) {
RequestService.sendRequest() RequestService.sendRequest()
.url(`${getServiceUrl()}/device/bind/${agentId}`) .url(`${getServiceUrl()}/device/bind/${agentId}`)
.method('GET') .method('GET')
@ -25,7 +25,7 @@ export default {
}).send(); }).send();
}, },
// Unbind device // Unbind device
unbindDevice(device_id, callback) { unbindDevice(device_id, callback, failCallback) {
RequestService.sendRequest() RequestService.sendRequest()
.url(`${getServiceUrl()}/device/unbind`) .url(`${getServiceUrl()}/device/unbind`)
.method('POST') .method('POST')
@ -48,7 +48,7 @@ export default {
}).send(); }).send();
}, },
// Bind device // Bind device
bindDevice(agentId, deviceCode, callback) { bindDevice(agentId, deviceCode, callback, failCallback) {
RequestService.sendRequest() RequestService.sendRequest()
.url(`${getServiceUrl()}/device/bind/${agentId}/${deviceCode}`) .url(`${getServiceUrl()}/device/bind/${agentId}/${deviceCode}`)
.method('POST') .method('POST')
@ -93,7 +93,7 @@ export default {
}).send() }).send()
}, },
// Manually add device // Manually add device
manualAddDevice(params, callback) { manualAddDevice(params, callback, failCallback) {
RequestService.sendRequest() RequestService.sendRequest()
.url(`${getServiceUrl()}/device/manual-add`) .url(`${getServiceUrl()}/device/manual-add`)
.method('POST') .method('POST')
@ -116,7 +116,7 @@ export default {
}).send(); }).send();
}, },
// Get device status // Get device status
getDeviceStatus(agentId, callback) { getDeviceStatus(agentId, callback, failCallback) {
RequestService.sendRequest() RequestService.sendRequest()
.url(`${getServiceUrl()}/device/bind/${agentId}`) .url(`${getServiceUrl()}/device/bind/${agentId}`)
.method('POST') .method('POST')

View file

@ -112,8 +112,9 @@ export default {
}).send() }).send()
}, },
// Get model name list // Get model name list
getModelNames(modelType, modelName, callback) { getModelNames(modelType, modelName, callback, onTerminalFailure, retryCount = 0, retryStartedAt = 0) {
RequestService.sendRequest() const retryWindowStartedAt = retryStartedAt || Date.now();
const request = RequestService.sendRequest()
.url(`${getServiceUrl()}/models/names`) .url(`${getServiceUrl()}/models/names`)
.method('GET') .method('GET')
.data({ modelType, modelName }) .data({ modelType, modelName })
@ -146,8 +147,9 @@ export default {
request.send(); request.send();
}, },
// Get LLM model name list // Get LLM model name list
getLlmModelCodeList(modelName, callback) { getLlmModelCodeList(modelName, callback, onTerminalFailure, retryCount = 0, retryStartedAt = 0) {
RequestService.sendRequest() const retryWindowStartedAt = retryStartedAt || Date.now();
const request = RequestService.sendRequest()
.url(`${getServiceUrl()}/models/llm/names`) .url(`${getServiceUrl()}/models/llm/names`)
.method('GET') .method('GET')
.data({ modelName }) .data({ modelName })
@ -179,7 +181,8 @@ export default {
request.send(); request.send();
}, },
// Get model voice list // Get model voice list
getModelVoices(modelId, voiceName, callback) { getModelVoices(modelId, voiceName, callback, onTerminalFailure, retryCount = 0, retryStartedAt = 0) {
const retryWindowStartedAt = retryStartedAt || Date.now();
const queryParams = new URLSearchParams({ const queryParams = new URLSearchParams({
voiceName: voiceName || '' voiceName: voiceName || ''
}).toString(); }).toString();
@ -410,5 +413,21 @@ export default {
this.getPluginFunctionList(params, callback) this.getPluginFunctionList(params, callback)
}) })
}).send() }).send()
},
// Get RAG model list
getRAGModels(callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/datasets/rag-models`)
.method('GET')
.success((res) => {
RequestService.clearRequestTime()
callback(res)
})
.networkFail((err) => {
console.error('Failed to get RAG model list:', err)
RequestService.reAjaxFun(() => {
this.getRAGModels(callback)
})
}).send()
} }
} }

View file

@ -180,7 +180,7 @@ export default {
this.captchaUrl = URL.createObjectURL(blob); this.captchaUrl = URL.createObjectURL(blob);
} else { } else {
console.error('Captcha loading exception:', error); console.error('Captcha loading exception:', res);
showDanger(this.$t('register.captchaLoadFailed')); showDanger(this.$t('register.captchaLoadFailed'));
} }
}); });

View file

@ -150,7 +150,7 @@ export default {
this.captchaUrl = URL.createObjectURL(blob); this.captchaUrl = URL.createObjectURL(blob);
} else { } else {
console.error('Captcha loading exception:', error); console.error('Captcha loading exception:', res);
showDanger('Captcha loading failed, click to refresh'); showDanger('Captcha loading failed, click to refresh');
} }
}); });