feat: SSH keys management, backups fixes, instances/nodes/templates improvements, dev mode support
Some checks failed
Backend Tests / pytest (Python 3.12) (push) Has been cancelled

This commit is contained in:
markmorado
2026-05-07 00:30:21 +02:00
parent a92cb0df33
commit 323d1e57fa
40 changed files with 4112 additions and 288 deletions

View File

@@ -146,8 +146,11 @@ class ApiClient {
});
}
delete<T>(path: string) {
return this.request<T>(path, { method: 'DELETE' });
delete<T>(path: string, body?: unknown) {
return this.request<T>(path, {
method: 'DELETE',
body: body ? JSON.stringify(body) : undefined,
});
}
}

View File

@@ -35,7 +35,8 @@ export class WebSocketManager {
}
connect() {
if (this.ws?.readyState === WebSocket.OPEN) return;
// Don't create a new socket if one is already open or connecting
if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) return;
const token = localStorage.getItem('access_token');
const separator = this.options.url.includes('?') ? '&' : '?';
@@ -49,6 +50,13 @@ export class WebSocketManager {
this._isConnected = true;
this.reconnectAttempts = 0;
this.startPing();
// Re-send subscribe messages for all active channels (handles initial
// subscribe-before-open and reconnect cases).
for (const channel of this.subscribers.keys()) {
try {
this.ws?.send(JSON.stringify({ type: 'subscribe', channel }));
} catch { /* ignore */ }
}
this.options.onOpen?.();
};
@@ -107,15 +115,20 @@ export class WebSocketManager {
subscribe(channel: string, handler: MessageHandler) {
if (!this.subscribers.has(channel)) {
this.subscribers.set(channel, new Set());
// Only send a subscribe message the first time someone subscribes to
// this channel. If WS is not OPEN yet, onopen() will replay it.
this.send({ type: 'subscribe', channel });
}
this.subscribers.get(channel)!.add(handler);
// Send subscribe message
this.send({ type: 'subscribe', channel });
// Return unsubscribe function
return () => {
this.subscribers.get(channel)?.delete(handler);
const handlers = this.subscribers.get(channel);
handlers?.delete(handler);
if (handlers && handlers.size === 0) {
this.subscribers.delete(channel);
this.send({ type: 'unsubscribe', channel });
}
};
}