hermes-web-cli/wwwroot/services.js
yumoqing 3edfa140e9 Fix bricks framework API usage and file structure
- Move all JS files from wwwroot/scripts/ to wwwroot/ root directory to comply with ahserver requirements
- Fix component registration: use bricks.Factory.register() instead of bricks.register()
- Fix function registration: use bricks.RF.register() instead of bricks.registerFunction()
- Update UI files to use item_template_url with external templates for List components
- Add proper list item template files (session-list-item.ui, service-list-item.ui, model-list-item.ui)
- Ensure all custom components and functions use correct bricks framework API
2026-04-22 15:49:36 +08:00

37 lines
1.4 KiB
JavaScript

// Register functions for services management
bricks.RF.register('remove_service', async function(params) {
try {
const response = await fetch('/hermes-web-cli/services/remove/?id=' + params.service_id);
const result = await response.json();
if (result.success) {
// Refresh the services list
const listWidget = bricks.getWidget('services-list');
if (listWidget) {
listWidget.reload();
}
bricks.showMessage('Service removed successfully', 'success');
} else {
bricks.showMessage(result.error || 'Failed to remove service', 'error');
}
} catch (error) {
bricks.showMessage('Network error: ' + error.message, 'error');
}
});
bricks.RF.register('test_service_connection', async function(params) {
try {
const response = await fetch('/hermes-web-cli/services/test/?id=' + params.service_id);
const result = await response.json();
if (result.status) {
// Update the status badge
// This would require more complex DOM manipulation
bricks.showMessage('Connection test completed', 'info');
} else {
bricks.showMessage(result.error || 'Failed to test connection', 'error');
}
} catch (error) {
bricks.showMessage('Network error: ' + error.message, 'error');
}
});