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 {
|
||||
const data = JSON.parse(event.data);
|
||||
if (data.event === 'getConnectionsResponse') {
|
||||
if (data.success) {
|
||||
this.connections = data.data || [];
|
||||
// Die Daemon-Antwort hat die Struktur: {event, total, unauthenticated, users: {userId: count}}
|
||||
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;
|
||||
} else {
|
||||
this.error = data.error || this.$t('admin.servicesStatus.daemon.connections.error');
|
||||
this.connections = [];
|
||||
this.error = null;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Fehler beim Verarbeiten der Daemon-Nachricht:', err);
|
||||
this.error = this.$t('admin.servicesStatus.daemon.connections.error');
|
||||
}
|
||||
},
|
||||
formatDuration(seconds) {
|
||||
|
||||
Reference in New Issue
Block a user