Refactor ServicesStatusView to handle daemon response structure
- Updated the handling of daemon responses to accommodate a new structure that includes user connection counts. - Transformed the users object into an array for easier template rendering. - Improved error handling for JSON parsing and daemon message processing.
This commit is contained in:
@@ -218,16 +218,23 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
if (data.event === 'getConnectionsResponse') {
|
if (data.event === 'getConnectionsResponse') {
|
||||||
if (data.success) {
|
// Die Daemon-Antwort hat die Struktur: {event, total, unauthenticated, users: {userId: count}}
|
||||||
this.connections = data.data || [];
|
if (data.users && typeof data.users === 'object') {
|
||||||
|
// Transformiere das users-Objekt in ein Array für das Template
|
||||||
|
this.connections = Object.entries(data.users).map(([userId, connectionCount]) => ({
|
||||||
|
userId: userId,
|
||||||
|
connectionCount: connectionCount,
|
||||||
|
connections: [] // Detaillierte Verbindungsinfos sind in der aktuellen Antwort nicht enthalten
|
||||||
|
}));
|
||||||
this.error = null;
|
this.error = null;
|
||||||
} else {
|
} else {
|
||||||
this.error = data.error || this.$t('admin.servicesStatus.daemon.connections.error');
|
|
||||||
this.connections = [];
|
this.connections = [];
|
||||||
|
this.error = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Fehler beim Verarbeiten der Daemon-Nachricht:', err);
|
console.error('Fehler beim Verarbeiten der Daemon-Nachricht:', err);
|
||||||
|
this.error = this.$t('admin.servicesStatus.daemon.connections.error');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatDuration(seconds) {
|
formatDuration(seconds) {
|
||||||
|
|||||||
Reference in New Issue
Block a user