Punkt 2 implementieren GitHub CoPilot
This commit is contained in:
@@ -23,12 +23,42 @@ function createInfoServer(httpsOptions, sharedState, robot, GCode, senders) {
|
||||
|
||||
/* ---------- API ---------- */
|
||||
if (req.url === '/api/status') {
|
||||
const sendersStatus = senders.map(({ name, instance }) => {
|
||||
const status = instance?.getStatus ? instance.getStatus() : {
|
||||
state: instance?.isTestMode ? 'connected' : instance?.tSocket ? 'connected' : 'disconnected',
|
||||
url: instance?.url || null,
|
||||
error: instance?.error || null,
|
||||
isTestMode: !!instance?.isTestMode,
|
||||
reconnectAttempt: instance?.reconnectAttempt || 0,
|
||||
reconnectTimer: !!instance?.reconnectTimer
|
||||
};
|
||||
|
||||
const state = status.state || (instance?.tSocket ? 'connected' : 'disconnected');
|
||||
const health = state === 'connected'
|
||||
? 'ok'
|
||||
: state === 'reconnecting'
|
||||
? 'warning'
|
||||
: 'disconnected';
|
||||
const reason = state === 'disconnected'
|
||||
? status.error || 'no active socket connection'
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
name,
|
||||
state,
|
||||
url: status.url || null,
|
||||
isTestMode: !!status.isTestMode,
|
||||
error: status.error || null,
|
||||
reconnectAttempt: status.reconnectAttempt || 0,
|
||||
reconnectTimer: !!status.reconnectTimer,
|
||||
health,
|
||||
reason
|
||||
};
|
||||
});
|
||||
|
||||
const status = {
|
||||
clients: sharedState.connectedClients,
|
||||
senders: senders.map(s => ({
|
||||
name: s.name,
|
||||
status: s.instance?.tSocket ? 'connected' : 'disconnected'
|
||||
})),
|
||||
senders: sendersStatus,
|
||||
lastCommands: sharedState.lastCommands,
|
||||
lastPings: sharedState.lastPings
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user