feat: label editor
This commit is contained in:
44
index.js
44
index.js
@@ -678,6 +678,16 @@ app.post('/api/proxy-call', async (req, res) => {
|
||||
fetchOptions.body = bodyParams.toString();
|
||||
}
|
||||
|
||||
// Debug logging to trace upstream requests
|
||||
try {
|
||||
console.log('[proxy-call] →', upperMethod, fullUrl);
|
||||
if (upperMethod !== 'GET') {
|
||||
console.log('[proxy-call] body:', fetchOptions.body);
|
||||
}
|
||||
} catch (_) {
|
||||
// ignore logging errors
|
||||
}
|
||||
|
||||
// Execute request
|
||||
const response = await fetch(fullUrl, fetchOptions);
|
||||
const respContentType = response.headers.get('content-type') || '';
|
||||
@@ -690,6 +700,8 @@ app.post('/api/proxy-call', async (req, res) => {
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
// Surface upstream failure details for easier debugging
|
||||
console.warn('[proxy-call] Upstream error', response.status, response.statusText, 'for', upperMethod, fullUrl);
|
||||
return res.status(response.status).json({
|
||||
error: 'Upstream request failed',
|
||||
status: response.status,
|
||||
@@ -727,6 +739,31 @@ app.get('/api/node/status/:ip', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Endpoint to trigger a cluster refresh
|
||||
app.post('/api/cluster/refresh', async (req, res) => {
|
||||
try {
|
||||
const { reason } = req.body || {};
|
||||
console.log(`🔄 Manual cluster refresh triggered: ${reason || 'unknown reason'}`);
|
||||
console.log(`📡 WebSocket clients connected: ${wsClients.size}`);
|
||||
|
||||
// Trigger a cluster update broadcast
|
||||
broadcastMemberListChange(reason || 'manual_refresh');
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Cluster refresh triggered',
|
||||
reason: reason || 'manual_refresh',
|
||||
wsClients: wsClients.size
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error triggering cluster refresh:', error);
|
||||
res.status(500).json({
|
||||
error: 'Failed to trigger cluster refresh',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// File upload endpoint for firmware updates
|
||||
app.post('/api/node/update', async (req, res) => {
|
||||
try {
|
||||
@@ -919,6 +956,13 @@ async function getCurrentClusterMembers() {
|
||||
console.log(`📡 Fetching real cluster data from ${discoveredNodes.size} nodes for WebSocket broadcast`);
|
||||
const clusterResponse = await performWithFailover((client) => client.getClusterStatus());
|
||||
const apiMembers = clusterResponse.members || [];
|
||||
|
||||
// Debug: Log the labels from the API response
|
||||
apiMembers.forEach(member => {
|
||||
if (member.labels && Object.keys(member.labels).length > 0) {
|
||||
console.log(`🏷️ API member ${member.ip} labels:`, member.labels);
|
||||
}
|
||||
});
|
||||
|
||||
// Update our local discoveredNodes with fresh information from the API
|
||||
let updatedNodes = false;
|
||||
|
||||
Reference in New Issue
Block a user