ulduldp commited on
Commit
3212189
·
verified ·
1 Parent(s): 4798350

Create public/index.html

Browse files
Files changed (1) hide show
  1. public/index.html +134 -0
public/index.html ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <title>Live Logs</title>
6
+
7
+ <style>
8
+ body {
9
+ margin: 0;
10
+ background: #0b1020;
11
+ color: #e2e8f0;
12
+ font-family: monospace;
13
+ display: flex;
14
+ flex-direction: column;
15
+ height: 100vh;
16
+ }
17
+
18
+ header {
19
+ padding: 10px;
20
+ background: #111827;
21
+ border-bottom: 1px solid #1f2937;
22
+ }
23
+
24
+ #logs {
25
+ flex: 1;
26
+ overflow-y: auto;
27
+ padding: 10px;
28
+ font-size: 13px;
29
+ }
30
+
31
+ .log {
32
+ margin-bottom: 6px;
33
+ word-break: break-word;
34
+ }
35
+
36
+ .time {
37
+ color: #64748b;
38
+ margin-right: 6px;
39
+ }
40
+
41
+ footer {
42
+ display: flex;
43
+ padding: 8px;
44
+ background: #111827;
45
+ border-top: 1px solid #1f2937;
46
+ }
47
+
48
+ input {
49
+ flex: 1;
50
+ padding: 10px;
51
+ background: #0b1020;
52
+ border: none;
53
+ color: white;
54
+ border-radius: 6px;
55
+ outline: none;
56
+ }
57
+
58
+ button {
59
+ margin-left: 8px;
60
+ padding: 10px 14px;
61
+ background: #2563eb;
62
+ border: none;
63
+ color: white;
64
+ border-radius: 6px;
65
+ }
66
+ </style>
67
+ </head>
68
+
69
+ <body>
70
+
71
+ <header>📡 Live Logs Terminal</header>
72
+
73
+ <div id="logs"></div>
74
+
75
+ <footer>
76
+ <input id="cmd" placeholder="Enter command..." />
77
+ <button onclick="sendCmd()">Send</button>
78
+ </footer>
79
+
80
+ <script src="/socket.io/socket.io.js"></script>
81
+ <script>
82
+ const socket = io();
83
+ const logsDiv = document.getElementById('logs');
84
+ const input = document.getElementById('cmd');
85
+
86
+ function formatTime(ts) {
87
+ return new Date(ts).toLocaleString('en-IN', {
88
+ timeZone: 'Asia/Kolkata',
89
+ hour12: false
90
+ });
91
+ }
92
+
93
+ function addLog(log) {
94
+ const div = document.createElement('div');
95
+ div.className = 'log';
96
+
97
+ div.innerHTML = `
98
+ <span class="time">[${formatTime(log.timestamp)}]</span>
99
+ ${log.html}
100
+ `;
101
+
102
+ logsDiv.appendChild(div);
103
+ logsDiv.scrollTop = logsDiv.scrollHeight;
104
+ }
105
+
106
+ // load old logs
107
+ fetch('/api/logs')
108
+ .then(res => res.json())
109
+ .then(data => data.forEach(addLog));
110
+
111
+ // live logs
112
+ socket.on('log', addLog);
113
+
114
+ function sendCmd() {
115
+ const val = input.value.trim();
116
+ if (!val) return;
117
+
118
+ socket.emit('command', { command: val });
119
+
120
+ addLog({
121
+ html: '<span style="color:#22c55e">> ' + val + '</span>',
122
+ timestamp: new Date()
123
+ });
124
+
125
+ input.value = '';
126
+ }
127
+
128
+ input.addEventListener('keypress', e => {
129
+ if (e.key === 'Enter') sendCmd();
130
+ });
131
+ </script>
132
+
133
+ </body>
134
+ </html>