Skip to content

Commit 244514a

Browse files
Merge pull request #157 from ProjectZeroDays/add-dashboard-features
Add dashboard features and social links
2 parents 163b8e1 + b2f971f commit 244514a

22 files changed

+2023
-650
lines changed

src/backend/api/trojan_api.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,46 @@ def deploy_trojan_api(trojan_id):
146146
logger.error(f"Error deploying trojan: {str(e)}")
147147
return jsonify({'message': 'Error deploying trojan', 'error': str(e)}), 500
148148

149+
@app.route('/deploy/server/<int:server_id>', methods=['POST'])
150+
@require_api_key
151+
def deploy_trojan_server(server_id):
152+
logger.info(f"API request: {request.method} /deploy/server/{server_id}")
153+
server = TrojanServer.query.get(server_id)
154+
if not server:
155+
return jsonify({'message': f'Trojan server with ID {server_id} not found.'}), 404
156+
157+
try:
158+
logger.info(f"Deploying trojan server with ID: {server_id}")
159+
deployment_feedback = deploy_trojan(server_id)
160+
logger.info(f"Trojan server {server_id} deployed successfully.")
161+
return jsonify({'message': 'Trojan server deployed successfully', 'feedback': deployment_feedback})
162+
except subprocess.CalledProcessError as e:
163+
logger.error(f"Subprocess error deploying trojan server: {str(e)}")
164+
return jsonify({'message': f'Subprocess error deploying trojan server: {str(e)}', 'error': str(e)}), 500
165+
except Exception as e:
166+
logger.error(f"Error deploying trojan server: {str(e)}")
167+
return jsonify({'message': 'Error deploying trojan server', 'error': str(e)}), 500
168+
169+
@app.route('/deploy/client/<int:client_id>', methods=['POST'])
170+
@require_api_key
171+
def deploy_trojan_client(client_id):
172+
logger.info(f"API request: {request.method} /deploy/client/{client_id}")
173+
client = TrojanClient.query.get(client_id)
174+
if not client:
175+
return jsonify({'message': f'Trojan client with ID {client_id} not found.'}), 404
176+
177+
try:
178+
logger.info(f"Deploying trojan client with ID: {client_id}")
179+
deployment_feedback = deploy_trojan(client_id)
180+
logger.info(f"Trojan client {client_id} deployed successfully.")
181+
return jsonify({'message': 'Trojan client deployed successfully', 'feedback': deployment_feedback})
182+
except subprocess.CalledProcessError as e:
183+
logger.error(f"Subprocess error deploying trojan client: {str(e)}")
184+
return jsonify({'message': f'Subprocess error deploying trojan client: {str(e)}', 'error': str(e)}), 500
185+
except Exception as e:
186+
logger.error(f"Error deploying trojan client: {str(e)}")
187+
return jsonify({'message': 'Error deploying trojan client', 'error': str(e)}), 500
188+
149189
@app.route('/ai_features', methods=['POST'])
150190
@require_api_key
151191
def ai_features():

src/backend/app.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,46 @@ def deploy_trojan_api(trojan_id):
157157
logger.error(f"Error deploying trojan: {str(e)}")
158158
return jsonify({'message': 'Error deploying trojan', 'error': str(e)}), 500
159159

160+
@app.route('/deploy/server/<int:server_id>', methods=['POST'])
161+
@require_api_key
162+
def deploy_trojan_server(server_id):
163+
logger.info(f"API request: {request.method} /deploy/server/{server_id}")
164+
server = TrojanServer.query.get(server_id)
165+
if not server:
166+
return jsonify({'message': f'Trojan server with ID {server_id} not found.'}), 404
167+
168+
try:
169+
logger.info(f"Deploying trojan server with ID: {server_id}")
170+
deployment_feedback = deploy_trojan(server_id)
171+
logger.info(f"Trojan server {server_id} deployed successfully.")
172+
return jsonify({'message': 'Trojan server deployed successfully', 'feedback': deployment_feedback})
173+
except subprocess.CalledProcessError as e:
174+
logger.error(f"Subprocess error deploying trojan server: {str(e)}")
175+
return jsonify({'message': f'Subprocess error deploying trojan server: {str(e)}', 'error': str(e)}), 500
176+
except Exception as e:
177+
logger.error(f"Error deploying trojan server: {str(e)}")
178+
return jsonify({'message': 'Error deploying trojan server', 'error': str(e)}), 500
179+
180+
@app.route('/deploy/client/<int:client_id>', methods=['POST'])
181+
@require_api_key
182+
def deploy_trojan_client(client_id):
183+
logger.info(f"API request: {request.method} /deploy/client/{client_id}")
184+
client = TrojanClient.query.get(client_id)
185+
if not client:
186+
return jsonify({'message': f'Trojan client with ID {client_id} not found.'}), 404
187+
188+
try:
189+
logger.info(f"Deploying trojan client with ID: {client_id}")
190+
deployment_feedback = deploy_trojan(client_id)
191+
logger.info(f"Trojan client {client_id} deployed successfully.")
192+
return jsonify({'message': 'Trojan client deployed successfully', 'feedback': deployment_feedback})
193+
except subprocess.CalledProcessError as e:
194+
logger.error(f"Subprocess error deploying trojan client: {str(e)}")
195+
return jsonify({'message': f'Subprocess error deploying trojan client: {str(e)}', 'error': str(e)}), 500
196+
except Exception as e:
197+
logger.error(f"Error deploying trojan client: {str(e)}")
198+
return jsonify({'message': 'Error deploying trojan client', 'error': str(e)}), 500
199+
160200
@app.route('/ai_features', methods=['POST'])
161201
@require_api_key
162202
def ai_features():

src/backend/caching.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import redis
2+
3+
cache = redis.Redis(host="localhost", port=6379, db=0)
4+
5+
def get_cached_response(key):
6+
cached_response = cache.get(key)
7+
return cached_response.decode("utf-8") if cached_response else None
8+
9+
def cache_response(key, response, ttl=300):
10+
cache.set(key, response, ex=ttl)
11+
12+
# Example usage
13+
response = get_cached_response("ai_response_123")
14+
if not response:
15+
response = "AI-generated response"
16+
cache_response("ai_response_123", response)

src/chatbot/templates/index.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,41 @@ <h1>Chatbot Interface</h1>
1818
<input type="file" id="doc-upload" accept=".txt,.md,.pdf" onchange="handleDocUpload()" />
1919
</div>
2020

21+
<div class="chatbox-tabs">
22+
<button onclick="openTab('agents')">Agents</button>
23+
<button onclick="openTab('llm-models')">LLM Models</button>
24+
<button onclick="openTab('ai-dev')">AI Dev</button>
25+
<button onclick="openTab('messages')">Messages</button>
26+
</div>
27+
28+
<div id="agents" class="tab-content">
29+
<h2>Agents</h2>
30+
<!-- Content for Agents tab -->
31+
</div>
32+
33+
<div id="llm-models" class="tab-content">
34+
<h2>LLM Models</h2>
35+
<!-- Content for LLM Models tab -->
36+
</div>
37+
38+
<div id="ai-dev" class="tab-content">
39+
<h2>AI Dev</h2>
40+
<!-- Content for AI Dev tab -->
41+
</div>
42+
43+
<div id="messages" class="tab-content">
44+
<h2>Messages</h2>
45+
<div id="message-box"></div>
46+
<input type="text" id="message-input" placeholder="Type your message..." autofocus>
47+
<button onclick="sendMessage()">Send</button>
48+
<button onclick="attachFile()">📎 Attach File</button>
49+
</div>
50+
51+
<button onclick="openSettings()">⚙️ Settings</button>
52+
<button onclick="minimizeChatbox()">➖ Minimize</button>
53+
<button onclick="closeChatbox()">❌ Close</button>
54+
<button onclick="viewFullscreen()">⛶ Fullscreen</button>
55+
2156
<h2>Network Scan and Vulnerability Test</h2>
2257
<h2>Setup API Keys</h2>
2358
<form id="apiKeysForm" method="POST" action="/setup_api_keys">
@@ -161,6 +196,34 @@ <h2>Search GitHub Projects</h2>
161196
document.getElementById("twilioInputs").style.display = value === "2" ? "block" : "none";
162197
document.getElementById("textbeltInputs").style.display = value === "3" ? "block" : "none";
163198
}
199+
200+
function openTab(tabName) {
201+
const tabs = document.getElementsByClassName("tab-content");
202+
for (let i = 0; i < tabs.length; i++) {
203+
tabs[i].style.display = "none";
204+
}
205+
document.getElementById(tabName).style.display = "block";
206+
}
207+
208+
function openSettings() {
209+
// Open settings logic
210+
}
211+
212+
function minimizeChatbox() {
213+
// Minimize chatbox logic
214+
}
215+
216+
function closeChatbox() {
217+
// Close chatbox logic
218+
}
219+
220+
function viewFullscreen() {
221+
// View fullscreen logic
222+
}
223+
224+
function attachFile() {
225+
// Attach file logic
226+
}
164227
</script>
165228
</body>
166229
</html>

src/dashboard/dashboard.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(self, logger: logging.Logger, settings_manager):
5858
self.event_log = []
5959
self.current_view = "main" # "main" or module name
6060
self.selected_module = None
61+
self.sidebar_open = False # Initialize sidebar state
6162

6263
# Initialize all imported modules
6364
self.advanced_decryption = AdvancedDecryption()
@@ -453,3 +454,64 @@ def verify_component_linkage(self):
453454
if not component:
454455
raise ValueError(f"Component {component} is not properly linked.")
455456
self.logger.info("All components are properly linked and functional.")
457+
458+
def add_sidebar(self):
459+
print("----- Sidebar -----")
460+
print("User Profile Picture [Edit]")
461+
print("Settings [Icon]")
462+
print("Dashboard Pages:")
463+
for name in self.modules.keys():
464+
print(f" - {name} [Icon] [Link]")
465+
print("-------------------")
466+
467+
def toggle_sidebar(self):
468+
if self.sidebar_open:
469+
self.sidebar_open = False
470+
print("Sidebar closed")
471+
else:
472+
self.sidebar_open = True
473+
print("Sidebar opened")
474+
475+
def close_sidebar_on_click_outside(self, click_position):
476+
if self.sidebar_open and not self.is_click_inside_sidebar(click_position):
477+
self.sidebar_open = False
478+
print("Sidebar closed due to outside click")
479+
480+
def is_click_inside_sidebar(self, click_position):
481+
# Placeholder logic to determine if click is inside sidebar
482+
return False
483+
484+
def add_horizontal_area(self):
485+
print("----- Horizontal Area -----")
486+
print("Icon Buttons:")
487+
print(" - Split View 1|1")
488+
print(" - 1 Top and Horizontal Bottom Area")
489+
print(" - 2 Top Split View and Bottom Horizontal Area")
490+
print(" - 4 Split View with and without Bottom Area")
491+
print("Settings Icon for Switching Bottom Horizontal Area:")
492+
print(" - PowerShell")
493+
print(" - Fish")
494+
print(" - Bash")
495+
print(" - Console")
496+
print(" - File Manager")
497+
print(" - Network Status")
498+
print(" - msfconsole")
499+
print(" - no-ip ddns status")
500+
print(" - AI Training Status")
501+
print("---------------------------")
502+
503+
def add_visualizations(self):
504+
print("----- Visualizations -----")
505+
print("Configurable and Modifiable Elements:")
506+
print(" - Current Network Status")
507+
print(" - Information about the Connection")
508+
print(" - Current DEFCON Threat Level")
509+
print("---------------------------")
510+
511+
def add_notifications_sidebar(self):
512+
print("----- Notifications Sidebar -----")
513+
print("Notifications Icon Button [Top Right]")
514+
print("Text Link to Clear Notifications [Bottom Right]")
515+
print("Swipe Functionality to Remove Notifications")
516+
print("On-Click Functionality to Open Corresponding Dashboard Page or Alert Window")
517+
print("---------------------------")

src/frontend/admin_profile.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Admin Profile and Account Settings</title>
7+
<link rel="stylesheet" href="styles.css">
8+
</head>
9+
<body>
10+
<header>
11+
<h1>Admin Profile and Account Settings</h1>
12+
</header>
13+
<main>
14+
<section id="admin-profile">
15+
<h2>Admin Profile</h2>
16+
<form id="admin-profile-form">
17+
<label for="admin-username">Username:</label>
18+
<input type="text" id="admin-username" name="admin-username" required>
19+
20+
<label for="admin-email">Email:</label>
21+
<input type="email" id="admin-email" name="admin-email" required>
22+
23+
<label for="admin-profile-picture">Profile Picture:</label>
24+
<input type="file" id="admin-profile-picture" name="admin-profile-picture" accept="image/*">
25+
26+
<button type="submit">Save Changes</button>
27+
</form>
28+
</section>
29+
<section id="admin-account-settings">
30+
<h2>Account Settings</h2>
31+
<form id="admin-account-settings-form">
32+
<label for="admin-password">Password:</label>
33+
<input type="password" id="admin-password" name="admin-password" required>
34+
35+
<label for="admin-confirm-password">Confirm Password:</label>
36+
<input type="password" id="admin-confirm-password" name="admin-confirm-password" required>
37+
38+
<button type="submit">Update Password</button>
39+
</form>
40+
</section>
41+
</main>
42+
<footer>
43+
<p>&copy; 2023 ProjectZeroDays. All rights reserved.</p>
44+
</footer>
45+
<script src="scripts.js"></script>
46+
</body>
47+
</html>

0 commit comments

Comments
 (0)