Brozy123 commited on
Commit
c60bc87
·
verified ·
1 Parent(s): 5450e32

Create stats.html

Browse files
Files changed (1) hide show
  1. stats.html +171 -0
stats.html ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>FriendlyBot — Advanced Stats</title>
7
+ <link rel="icon" href="/logo.png" />
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
9
+ <style>
10
+ :root {
11
+ --bg: #0a0a1a; --surface: #12122a; --surface2: #1a1a3a; --border: rgba(255,255,255,0.08);
12
+ --text: #fff; --text-dim: rgba(255,255,255,0.6); --gold: #FFD700;
13
+ --accent: #5865F2; --radius: 16px; --red: #ED4245;
14
+ }
15
+ * { box-sizing: border-box; margin:0; padding:0; }
16
+ body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 40px 20px; }
17
+ header { max-width: 800px; margin: 0 auto 40px; display: flex; justify-content: space-between; align-items: center; }
18
+ h1 { font-size: 28px; font-weight: 700; }
19
+ .btn {
20
+ display: inline-block; padding: 10px 20px; background: var(--accent);
21
+ color: #fff; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 14px; border: none; cursor: pointer;
22
+ }
23
+ .btn-secondary { background: var(--surface2); border: 1px solid var(--border); }
24
+ .container { max-width: 800px; margin: 0 auto; }
25
+ .card {
26
+ background: rgba(18,18,42,0.85); backdrop-filter: blur(8px);
27
+ border: 1px solid var(--border); border-radius: var(--radius);
28
+ padding: 32px; margin-bottom: 30px;
29
+ }
30
+ .card h2 { font-size: 20px; margin-bottom: 12px; }
31
+ .card p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
32
+
33
+ .config-grid { display: grid; gap: 24px; }
34
+ .input-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
35
+ input, select {
36
+ width: 100%; padding: 14px; background: var(--surface2); border: 1px solid var(--border);
37
+ border-radius: 10px; color: #fff; font-size: 15px; outline: none;
38
+ }
39
+
40
+ #guild-selector { margin-bottom: 30px; }
41
+ .server-select { width: 100%; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; }
42
+
43
+ .save-bar { position: sticky; bottom: 20px; background: var(--surface); border: 1px solid var(--border); padding: 16px 24px; border-radius: 100px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 100; }
44
+ </style>
45
+ </head>
46
+ <body>
47
+ <header>
48
+ <div style="display:flex; align-items:center; gap:16px">
49
+ <div style="font-size:32px">📊</div>
50
+ <h1>Advanced Stats</h1>
51
+ </div>
52
+ <a href="/dashboard" class="btn btn-secondary">Back to Dashboard</a>
53
+ </header>
54
+
55
+ <div class="container">
56
+ <div id="guild-selector">
57
+ <label style="display:block; font-size:13px; color:var(--text-dim); margin-bottom:10px">Select a Server to Configure</label>
58
+ <select id="server-list" class="server-select" onchange="loadConfig(this.value)">
59
+ <option value="">Loading your servers...</option>
60
+ </select>
61
+ </div>
62
+
63
+ <div class="card" id="config-card" style="display:none">
64
+ <h2>Leaderboards & Analytics</h2>
65
+ <p>Configure how stats are tracked and displayed in your server.</p>
66
+
67
+ <div class="config-grid">
68
+ <div class="input-group">
69
+ <label>Leaderboard Channel</label>
70
+ <select id="config-leaderboard-channel" onchange="checkChanges()">
71
+ <option value="">Select a channel...</option>
72
+ </select>
73
+ <p style="font-size:12px; color:var(--text-dim); margin-top:8px">The bot will automatically update a leaderboard message in this channel.</p>
74
+ </div>
75
+
76
+ <div class="input-group">
77
+ <label>Auto-Post Stats</label>
78
+ <select id="config-stats-frequency" onchange="checkChanges()">
79
+ <option value="never">Never</option>
80
+ <option value="daily">Daily</option>
81
+ <option value="weekly">Weekly</option>
82
+ <option value="monthly">Monthly</option>
83
+ </select>
84
+ <p style="font-size:12px; color:var(--text-dim); margin-top:8px">How often should the bot post the top performers of the period?</p>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>
89
+
90
+ <div class="save-bar" id="save-bar" style="display:none; max-width:800px; margin: 0 auto;">
91
+ <span style="font-size:14px; font-weight:500">You have unsaved changes!</span>
92
+ <button class="btn" onclick="saveConfig()">Save Stats Settings</button>
93
+ </div>
94
+
95
+ <script>
96
+ let currentGuildId = null;
97
+
98
+ async function init() {
99
+ try {
100
+ const serversR = await fetch('/api/servers');
101
+ const serversData = await serversR.json();
102
+ const serverSelect = document.getElementById('server-list');
103
+ const servers = serversData.servers || [];
104
+
105
+ if (servers.length === 0) {
106
+ serverSelect.innerHTML = '<option value="">No manageable servers found</option>';
107
+ return;
108
+ }
109
+
110
+ serverSelect.innerHTML = '<option value="">-- Choose a Server --</option>' +
111
+ servers.map(s => `<option value="${s.id}">${s.name}</option>`).join('');
112
+ } catch (e) { console.error(e); }
113
+ }
114
+
115
+ async function loadConfig(guildId) {
116
+ if (!guildId) {
117
+ document.getElementById('config-card').style.display = 'none';
118
+ document.getElementById('save-bar').style.display = 'none';
119
+ return;
120
+ }
121
+
122
+ currentGuildId = guildId;
123
+ document.getElementById('config-card').style.display = 'block';
124
+
125
+ try {
126
+ const [configR, channelsR] = await Promise.all([
127
+ fetch(`/api/config/${guildId}`),
128
+ fetch(`/api/channels/${guildId}`)
129
+ ]);
130
+
131
+ const data = await configR.json();
132
+ const channels = await channelsR.json();
133
+
134
+ const channelSelect = document.getElementById('config-leaderboard-channel');
135
+ channelSelect.innerHTML = '<option value="">Select a channel...</option>' +
136
+ channels.map(c => `<option value="${c.id}" ${c.id === data.leaderboardChannel ? 'selected' : ''}>#${c.name}</option>`).join('');
137
+
138
+ document.getElementById('config-stats-frequency').value = data.statsFrequency || 'never';
139
+ document.getElementById('save-bar').style.display = 'none';
140
+ } catch (e) { alert('Failed to load configuration'); }
141
+ }
142
+
143
+ function checkChanges() {
144
+ if (!currentGuildId) return;
145
+ document.getElementById('save-bar').style.display = 'flex';
146
+ }
147
+
148
+ async function saveConfig() {
149
+ const leaderboardChannel = document.getElementById('config-leaderboard-channel').value;
150
+ const statsFrequency = document.getElementById('config-stats-frequency').value;
151
+
152
+ try {
153
+ const r = await fetch(`/api/config/${currentGuildId}`, {
154
+ method: 'POST',
155
+ headers: { 'Content-Type': 'application/json' },
156
+ body: JSON.stringify({ leaderboardChannel, statsFrequency })
157
+ });
158
+ const data = await r.json();
159
+ if (data.success) {
160
+ alert('✅ Stats settings saved!');
161
+ document.getElementById('save-bar').style.display = 'none';
162
+ } else {
163
+ alert('❌ Error: ' + data.error);
164
+ }
165
+ } catch (e) { alert('❌ Failed to save'); }
166
+ }
167
+
168
+ init();
169
+ </script>
170
+ </body>
171
+ </html>