37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
// Register functions for services management
|
|
bricks.registerFunction('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.registerFunction('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');
|
|
}
|
|
}); |