refactor(rendering): restore NodeDetails active tab; keyed partial updates by IP; add escapeHtml in base Component and use in members; simplify ApiClient methods by removing redundant try/catch

This commit is contained in:
2025-08-31 11:24:39 +02:00
parent b757cb68da
commit 1bdaed9a2c
3 changed files with 51 additions and 87 deletions

View File

@@ -51,92 +51,56 @@ class ApiClient {
}
async getClusterMembers() {
try {
return await this.request('/api/cluster/members', { method: 'GET' });
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request('/api/cluster/members', { method: 'GET' });
}
async getClusterMembersFromNode(ip) {
try {
return await this.request(`/api/cluster/members`, {
method: 'GET',
query: { ip: ip }
});
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request(`/api/cluster/members`, {
method: 'GET',
query: { ip: ip }
});
}
async getDiscoveryInfo() {
try {
return await this.request('/api/discovery/nodes', { method: 'GET' });
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request('/api/discovery/nodes', { method: 'GET' });
}
async selectRandomPrimaryNode() {
try {
return await this.request('/api/discovery/random-primary', {
method: 'POST',
body: { timestamp: new Date().toISOString() }
});
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request('/api/discovery/random-primary', {
method: 'POST',
body: { timestamp: new Date().toISOString() }
});
}
async getNodeStatus(ip) {
try {
return await this.request(`/api/node/status/${encodeURIComponent(ip)}`, { method: 'GET' });
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request(`/api/node/status/${encodeURIComponent(ip)}`, { method: 'GET' });
}
async getTasksStatus(ip) {
try {
return await this.request('/api/tasks/status', { method: 'GET', query: ip ? { ip } : undefined });
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request('/api/tasks/status', { method: 'GET', query: ip ? { ip } : undefined });
}
async getCapabilities(ip) {
try {
return await this.request('/api/capabilities', { method: 'GET', query: ip ? { ip } : undefined });
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request('/api/capabilities', { method: 'GET', query: ip ? { ip } : undefined });
}
async callCapability({ ip, method, uri, params }) {
try {
return await this.request('/api/proxy-call', {
method: 'POST',
body: { ip, method, uri, params }
});
} catch (error) {
throw new Error(`Request failed: ${error.message}`);
}
return this.request('/api/proxy-call', {
method: 'POST',
body: { ip, method, uri, params }
});
}
async uploadFirmware(file, nodeIp) {
try {
const formData = new FormData();
formData.append('file', file);
return await this.request(`/api/node/update`, {
method: 'POST',
query: { ip: nodeIp },
body: formData,
isForm: true,
headers: {},
});
} catch (error) {
throw new Error(`Upload failed: ${error.message}`);
}
const formData = new FormData();
formData.append('file', file);
return this.request(`/api/node/update`, {
method: 'POST',
query: { ip: nodeIp },
body: formData,
isForm: true,
headers: {},
});
}
}