fix delete connection POST request
This commit is contained in:
1 parent
27f2314c96
commit
5141bcdb0f
5 files changed
+28
-12
No files matched your search
@@ -38,7 +38,7 @@ services:
|
|||||||
# Optionally expose code to other services (read-only)
|
# Optionally expose code to other services (read-only)
|
||||||
# - ./:/srv/webssh:ro
|
# - ./:/srv/webssh:ro
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
|
test: ["CMD", "python", "-c", "import sys, urllib.request; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8080/', timeout=5).getcode() == 200 else 1)"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -776,16 +776,17 @@ function disconnectConnection(id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteConnection(id) {
|
async function deleteConnection(id) {
|
||||||
if (!confirm('Delete this connection?')) return;
|
if (!confirm('Delete this connection?')) return;
|
||||||
|
|
||||||
const conn = getConnection(id);
|
const conn = getConnection(id);
|
||||||
if (conn && conn.socket) {
|
if (!await deleteConnectionFromServer(id)) {
|
||||||
conn.socket.close();
|
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);
|
connections = connections.filter(c => c.id !== id);
|
||||||
deleteConnectionFromServer(id); // Delete from server storage
|
|
||||||
autoSaveConnections();
|
autoSaveConnections();
|
||||||
|
|
||||||
if (currentConnectionId === id) {
|
if (currentConnectionId === id) {
|
||||||
|
|||||||
@@ -75,18 +75,27 @@ def parse_size(size_str):
|
|||||||
size_str = size_str.upper().strip()
|
size_str = size_str.upper().strip()
|
||||||
logger.info(f"parse_size called with: '{size_str}'")
|
logger.info(f"parse_size called with: '{size_str}'")
|
||||||
|
|
||||||
if size_str.endswith('M') or size_str.endswith('MB'):
|
if size_str.endswith('MB'):
|
||||||
# Remove 'M' or 'MB' and convert to bytes
|
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)
|
result = int(float(size_str[:-1]) * 1024 * 1024)
|
||||||
logger.info(f"parse_size result: {result} bytes (from {size_str})")
|
logger.info(f"parse_size result: {result} bytes (from {size_str})")
|
||||||
return result
|
return result
|
||||||
elif size_str.endswith('K') or size_str.endswith('KB'):
|
elif size_str.endswith('KB'):
|
||||||
# Remove 'K' or 'KB' and convert to bytes
|
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)
|
result = int(float(size_str[:-1]) * 1024)
|
||||||
logger.info(f"parse_size result: {result} bytes (from {size_str})")
|
logger.info(f"parse_size result: {result} bytes (from {size_str})")
|
||||||
return result
|
return result
|
||||||
elif size_str.endswith('G') or size_str.endswith('GB'):
|
elif size_str.endswith('GB'):
|
||||||
# Remove 'G' or 'GB' and convert to bytes
|
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)
|
result = int(float(size_str[:-1]) * 1024 * 1024 * 1024)
|
||||||
logger.info(f"parse_size result: {result} bytes (from {size_str})")
|
logger.info(f"parse_size result: {result} bytes (from {size_str})")
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -208,8 +208,12 @@ class CredentialsManager:
|
|||||||
"DELETE FROM connections WHERE id = ? AND username = ?",
|
"DELETE FROM connections WHERE id = ? AND username = ?",
|
||||||
(conn_id, username)
|
(conn_id, username)
|
||||||
)
|
)
|
||||||
|
deleted = cursor.rowcount
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
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}")
|
logger.info(f"Deleted connection {conn_id} for user {username}")
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class LoginHandler(BaseHTTPRequestHandler):
|
|||||||
self.handle_verify()
|
self.handle_verify()
|
||||||
elif parsed.path == '/api/connections':
|
elif parsed.path == '/api/connections':
|
||||||
self.handle_save_connection()
|
self.handle_save_connection()
|
||||||
|
elif parsed.path == '/api/connections/delete':
|
||||||
|
self.handle_delete_connection()
|
||||||
elif parsed.path == '/api/connections/status':
|
elif parsed.path == '/api/connections/status':
|
||||||
self.handle_connection_status()
|
self.handle_connection_status()
|
||||||
elif parsed.path == '/api/config':
|
elif parsed.path == '/api/config':
|
||||||
|
|||||||
Reference in new issue
Block a user