fix delete connection POST request

This commit is contained in:
dido committed 2026-09-24 08:39:26 +03:00
1 parent 27f2314c96
commit 5141bcdb0f
5 files changed
+28 -12

No files matched your search

+6 -5
View File
@@ -776,16 +776,17 @@ function disconnectConnection(id) {
}
}
function deleteConnection(id) {
async function deleteConnection(id) {
if (!confirm('Delete this connection?')) return;
const conn = getConnection(id);
if (conn && conn.socket) {
conn.socket.close();
if (!await deleteConnectionFromServer(id)) {
alert('Failed to delete connection from server. Please try again.');
return;
}
if (conn && conn.socket) conn.socket.close();
connections = connections.filter(c => c.id !== id);
deleteConnectionFromServer(id); // Delete from server storage
autoSaveConnections();
if (currentConnectionId === id) {
+15 -6
View File
@@ -75,18 +75,27 @@ def parse_size(size_str):
size_str = size_str.upper().strip()
logger.info(f"parse_size called with: '{size_str}'")
if size_str.endswith('M') or size_str.endswith('MB'):
# Remove 'M' or 'MB' and convert to bytes
if size_str.endswith('MB'):
result = int(float(size_str[:-2]) * 1024 * 1024)
logger.info(f"parse_size result: {result} bytes (from {size_str})")
return result
elif size_str.endswith('M'):
result = int(float(size_str[:-1]) * 1024 * 1024)
logger.info(f"parse_size result: {result} bytes (from {size_str})")
return result
elif size_str.endswith('K') or size_str.endswith('KB'):
# Remove 'K' or 'KB' and convert to bytes
elif size_str.endswith('KB'):
result = int(float(size_str[:-2]) * 1024)
logger.info(f"parse_size result: {result} bytes (from {size_str})")
return result
elif size_str.endswith('K'):
result = int(float(size_str[:-1]) * 1024)
logger.info(f"parse_size result: {result} bytes (from {size_str})")
return result
elif size_str.endswith('G') or size_str.endswith('GB'):
# Remove 'G' or 'GB' and convert to bytes
elif size_str.endswith('GB'):
result = int(float(size_str[:-2]) * 1024 * 1024 * 1024)
logger.info(f"parse_size result: {result} bytes (from {size_str})")
return result
elif size_str.endswith('G'):
result = int(float(size_str[:-1]) * 1024 * 1024 * 1024)
logger.info(f"parse_size result: {result} bytes (from {size_str})")
return result
+4
View File
@@ -208,8 +208,12 @@ class CredentialsManager:
"DELETE FROM connections WHERE id = ? AND username = ?",
(conn_id, username)
)
deleted = cursor.rowcount
conn.commit()
conn.close()
if deleted != 1:
logger.warning(f"Connection {conn_id} not found for user {username}")
return False
logger.info(f"Deleted connection {conn_id} for user {username}")
return True
except Exception as e:
+2
View File
@@ -46,6 +46,8 @@ class LoginHandler(BaseHTTPRequestHandler):
self.handle_verify()
elif parsed.path == '/api/connections':
self.handle_save_connection()
elif parsed.path == '/api/connections/delete':
self.handle_delete_connection()
elif parsed.path == '/api/connections/status':
self.handle_connection_status()
elif parsed.path == '/api/config':