-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevelopers-panel.html
More file actions
402 lines (362 loc) · 15.6 KB
/
developers-panel.html
File metadata and controls
402 lines (362 loc) · 15.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Developer Dashboard - Phantom Store</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
:root {
--header-transition: all 0.3s ease;
}
.hero-section {
min-height: 100vh;
background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)),
url('https://everwallpaper.com/cdn/shop/files/ring-nubula-wallpaper-mural.jpg?v=1654148245') center/cover;
display: flex;
align-items: center;
color: white;
}
.scrolled-header {
background: rgba(255,255,255,0.95) !important;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.app-card {
transition: transform 0.3s, box-shadow 0.3s;
border: none;
}
.app-card:hover {
transform: translateY(-5px);
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.rating-stars {
color: #ffd700;
font-size: 1.2rem;
}
.progress-ring {
width: 100px;
height: 100px;
}
.progress-ring__circle {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
.review-card {
border-left: 3px solid #0d6efd;
transition: all 0.3s ease;
}
.get-started-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 15px;
padding: 2rem;
text-align: center;
}
</style>
</head>
<body>
<!-- Auth Section -->
<section class="auth-section align-self-auto h-100 w-100 mt-5" id="authSection">
<div class="auth-card d-none a" id="signinCard">
<div class="text-center mb-4">
<h2 class="mb-3">Phantom Dev</h2>
<p class="text-muted">Developer Dashboard</p>
</div>
<div class="d-grid gap-3">
<button class="btn btn-primary btn-lg w-50 m-auto" id="signinButton">
<i class="fas fa-sign-in-alt me-2"></i>Sign In
</button>
<p class="text-center mt-3">
Don't have an account? <br>
<a href="#" id="registerLink">Contact admin for access</a>
</p>
</div>
</div>
</section>
<div class="d-none" id="dashboardContent">
<!-- Header -->
<nav class="navbar navbar-expand-lg fixed-top navbar-light py-3" id="mainHeader">
<div class="container">
<a class="navbar-brand" href="#" style="color: rgb(255, 0, 0);">Phantom Dev</a>
<div class="d-flex align-items-center">
<div class="me-3 text-muted" id="devWelcome">Welcome, Loading...</div>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#appModal">
<i class="fas fa-plus me-2"></i>New Distribution
</button>
</div>
</div>
</nav>
<!-- Apps Grid -->
<main class="container py-5 mt-5">
<section class="mb-5">
<h2 class="mb-4">Your Applications</h2>
<div class="row g-4" id="appsGrid">
<!-- Apps will be loaded here -->
</div>
<!-- Get Started Card -->
<div class="row g-4 d-none" id="getStarted">
<div class="col-md-12">
<div class="get-started-card">
<h3>Ready to Publish Your First App?</h3>
<p class="lead mb-4">Start your journey by submitting your first application</p>
<button class="btn btn-light btn-lg px-5" data-bs-toggle="modal" data-bs-target="#appModal">
<i class="fas fa-rocket me-2"></i>Get Started
</button>
</div>
</div>
</div>
</section>
</main>
</div>
<!-- App Modal -->
<div class="modal fade" id="appModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">New App Distribution</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<form id="appForm">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label">App Name</label>
<input type="text" class="form-control" name="name" required>
</div>
<div class="col-md-6">
<label class="form-label">Category</label>
<select class="form-select" name="category_id" required>
<option value="1">Games</option>
<option value="2">Productivity</option>
<option value="3">Education</option>
</select>
</div>
<div class="col-12">
<label class="form-label">Description</label>
<textarea class="form-control" rows="3" name="description" required></textarea>
</div>
<div class="col-md-6">
<label class="form-label">Icon URL</label>
<input type="url" class="form-control" name="icon_url" required>
</div>
<div class="col-md-6">
<label class="form-label">Download URL</label>
<input type="url" class="form-control" name="download_url" required>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="submitApp">Submit</button>
</div>
</div>
</div>
</div>
<script>
const API_BASE = 'http://localhost:3000';
let currentUser = null;
// Auth Functions
async function checkAuth() {
const token = localStorage.getItem('phantom-dev-token');
if (!token) {
showAuth();
return false;
}
try {
const response = await fetch(`${API_BASE}/validate-token`, {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
localStorage.removeItem('phantom-dev-token');
showAuth();
return false;
}
const data = await response.json();
currentUser = data.user;
currentDeveloper = data.user; // Also set the developer
showDashboard();
return true;
} catch (error) {
showAuth();
return false;
}
}
// UI Functions
function showDashboard() {
document.getElementById('authSection').classList.add('d-none');
document.getElementById('dashboardContent').classList.remove('d-none');
document.getElementById('devWelcome').textContent = `Welcome, ${currentUser.company_name || currentUser.email}`;
loadDeveloperApps();
}
function showAuth() {
document.getElementById('authSection').classList.remove('d-none');
document.getElementById('dashboardContent').classList.add('d-none');
document.getElementById('signinCard').classList.remove('d-none');
}
// Event Listeners
document.getElementById('signinButton').addEventListener('click', () => {
window.location.href = '/login'; // Your login page
});
// Initialization
(async () => {
const isAuthenticated = await checkAuth();
isAuthenticated ? showDashboard() : showAuth();
})();
</script>
<script>
let currentDeveloper = null;
const headers = {
'Authorization': `Bearer ${localStorage.getItem('phantom-dev-token')}`,
'Content-Type': 'application/json'
};
async function loadDeveloperApps() {
try {
const response = await fetch(`${API_BASE}/developer/apps?user_id=${currentDeveloper.user_id}`, {
headers: headers
});
const apps = await response.json();
const appsGrid = document.getElementById('appsGrid');
const getStarted = document.getElementById('getStarted');
if(apps.length === 0) {
appsGrid.classList.add('d-none');
getStarted.classList.remove('d-none');
} else {
appsGrid.classList.remove('d-none');
getStarted.classList.add('d-none');
renderApps(apps);
}
} catch (error) {
console.error('Error loading apps:', error);
}
}
function renderApps(apps) {
const grid = document.getElementById('appsGrid');
grid.innerHTML = apps.map(app => `
<div class="col-md-6">
<div class="card app-card">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h3>${app.name}</h3>
<span class="badge ${app.status === 'approved' ? 'bg-success' :
app.status === 'rejected' ? 'bg-danger' : 'bg-warning'}">
${app.status}
</span>
</div>
<p class="text-muted">${app.description}</p>
<div class="d-flex justify-content-between">
<button class="btn btn-outline-primary btn-sm">
<i class="fas fa-chart-line me-2"></i>Analytics
</button>
<div>
<button class="btn btn-outline-danger btn-sm delete-btn"
data-id="${app.app_id}">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
</div>
</div>
</div>
`).join('');
// Add delete event listeners
document.querySelectorAll('.delete-btn').forEach(btn => {
btn.addEventListener('click', async (e) => {
const appId = e.target.closest('button').dataset.id;
if(confirm('Are you sure you want to delete this app?')) {
try {
await fetch(`${API_BASE}/apps/${appId}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
developer_id: currentDeveloper.user_id
})
});
loadDeveloperApps();
} catch (error) {
console.error('Delete error:', error);
}
}
});
});
}
// Form Submission
document.getElementById('submitApp').addEventListener('click', async () => {
const formData = new FormData(document.getElementById('appForm'));
const appData = {
name: formData.get('name'),
description: formData.get('description'),
icon_url: formData.get('icon_url'),
download_url: formData.get('download_url'),
category_id: formData.get('category_id'),
developer_id: currentDeveloper.user_id
};
try {
const response = await fetch(`${API_BASE}/apps`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(appData)
});
if(response.ok) {
$('#appModal').modal('hide');
document.getElementById('appForm').reset();
loadDeveloperApps();
}
} catch (error) {
console.error('Submission error:', error);
}
});
// Initialize
document.addEventListener('DOMContentLoaded', async () => {
// First check authentication status
const isAuthenticated = await checkAuth();
if (isAuthenticated) {
// If authenticated, load the dashboard
document.getElementById('devWelcome').textContent = `Welcome, ${currentUser.name || currentUser.email}`;
await loadDeveloperApps();
} else {
// If not authenticated, show auth section
showAuth();
// Set up login button handler
document.getElementById('signinButton').addEventListener('click', async (e) => {
e.preventDefault();
// In a real implementation, this would redirect to your login page
// For now, we'll simulate a successful login
await simulateLogin();
});
}
});
// Simulate login function for testing
async function simulateLogin() {
try {
// In a real app, you would get this from your login API
const mockToken = 'mock-token-123';
const mockUser = {
user_id: 1,
name: "Dev User",
email: "dev@example.com",
company_name: "Phantom Dev"
};
// Store the token and user data
localStorage.setItem('phantom-dev-token', mockToken);
currentUser = mockUser;
currentDeveloper = mockUser;
// Update UI
showDashboard();
document.getElementById('devWelcome').textContent = `Welcome, ${currentUser.name}`;
// Load apps
await loadDeveloperApps();
} catch (error) {
console.error('Login error:', error);
alert('Login failed. Please try again.');
}
}
</script>
</body>
</html>