devcode-canavar-pro 3.5.2 → 3.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Dashboard.js +74 -30
- package/package.json +1 -1
package/lib/Dashboard.js
CHANGED
|
@@ -4,8 +4,9 @@ const path = require('path');
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* DevCode SYSTEMATIC COMMAND CENTER - v3.5.
|
|
7
|
+
* DevCode SYSTEMATIC COMMAND CENTER - v3.5.7
|
|
8
8
|
* The ultimate VDS management experience.
|
|
9
|
+
* FIXED: Removed all backticks from inner script tags to prevent syntax errors on varied Node versions.
|
|
9
10
|
*/
|
|
10
11
|
class Dashboard {
|
|
11
12
|
constructor(core, port = 3000) {
|
|
@@ -209,21 +210,37 @@ class Dashboard {
|
|
|
209
210
|
</main>
|
|
210
211
|
</div>
|
|
211
212
|
<script>
|
|
212
|
-
|
|
213
|
+
var secret = localStorage.getItem('dc_cc_key');
|
|
213
214
|
if (secret) init();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
|
|
216
|
+
function api(p, m, b) {
|
|
217
|
+
return fetch(p, {
|
|
218
|
+
method: m || 'GET',
|
|
219
|
+
headers: { 'Content-Type': 'application/json', 'x-dashboard-secret': secret },
|
|
220
|
+
body: b ? JSON.stringify(b) : null
|
|
221
|
+
}).then(function(r) {
|
|
222
|
+
if (r.status === 401) logout();
|
|
223
|
+
return r.json();
|
|
224
|
+
});
|
|
218
225
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
|
|
227
|
+
function login() {
|
|
228
|
+
var v = document.getElementById('gate-key').value;
|
|
229
|
+
fetch('/api/login', {
|
|
230
|
+
method: 'POST',
|
|
231
|
+
headers: { 'Content-Type': 'application/json' },
|
|
232
|
+
body: JSON.stringify({ secret: v })
|
|
233
|
+
}).then(function(res) {
|
|
234
|
+
return res.json();
|
|
235
|
+
}).then(function(d) {
|
|
236
|
+
if (d.success) { secret = v; localStorage.setItem('dc_cc_key', v); init(); }
|
|
237
|
+
else { document.getElementById('login-err').style.display = 'block'; }
|
|
238
|
+
});
|
|
224
239
|
}
|
|
240
|
+
|
|
225
241
|
function logout() { localStorage.removeItem('dc_cc_key'); location.reload(); }
|
|
226
|
-
|
|
242
|
+
|
|
243
|
+
function init() {
|
|
227
244
|
document.getElementById('login-gate').style.display = 'none';
|
|
228
245
|
document.getElementById('ui-wrapper').classList.add('ready');
|
|
229
246
|
document.getElementById('m-ip').innerText = location.hostname;
|
|
@@ -231,28 +248,55 @@ class Dashboard {
|
|
|
231
248
|
setInterval(refresh, 5000);
|
|
232
249
|
setInterval(loadLogs, 2000);
|
|
233
250
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
251
|
+
|
|
252
|
+
function refresh() {
|
|
253
|
+
api('/api/stats').then(function(d) {
|
|
254
|
+
document.getElementById('m-ram').innerText = d.memory.used + ' / ' + d.memory.total + ' GB';
|
|
255
|
+
document.getElementById('m-up').innerText = d.uptime + 's';
|
|
256
|
+
var list = document.getElementById('tenant-list');
|
|
257
|
+
var html = '';
|
|
258
|
+
d.databases.forEach(function(db) {
|
|
259
|
+
html += '<div class="tenant-btn" onclick="selectDB(\\'' + db.name + '\\', \\'' + db.ns + '\\')">' +
|
|
260
|
+
'<div style="font-size: 1.5rem">💠</div>' +
|
|
261
|
+
'<div style="display: flex; flex-direction: column">' +
|
|
262
|
+
'<span style="font-weight: 700;">' + db.name + '</span>' +
|
|
263
|
+
'<span style="font-size: 0.6rem; opacity: 0.4">' + db.ns.substring(0,10) + '...</span>' +
|
|
264
|
+
'</div></div>';
|
|
265
|
+
});
|
|
266
|
+
list.innerHTML = html;
|
|
267
|
+
});
|
|
240
268
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
269
|
+
|
|
270
|
+
function loadLogs() {
|
|
271
|
+
api('/api/logs').then(function(d) {
|
|
272
|
+
if (!d || !d.logs) return;
|
|
273
|
+
var html = '';
|
|
274
|
+
d.logs.forEach(function(l) {
|
|
275
|
+
html += '<div class="log-entry"><span>[' + l.time + ']</span> <u>' + l.ns + '</u> <b>' + l.action + '</b> <i>' + l.db + '.' + l.col + '</i></div>';
|
|
276
|
+
});
|
|
277
|
+
document.getElementById('audit-stream').innerHTML = html;
|
|
278
|
+
});
|
|
245
279
|
}
|
|
246
|
-
|
|
280
|
+
|
|
281
|
+
function selectDB(name, ns) {
|
|
247
282
|
document.getElementById('view-title').innerText = name;
|
|
248
|
-
|
|
249
|
-
|
|
283
|
+
api('/api/db/' + encodeURIComponent(name) + '/ns/' + encodeURIComponent(ns)).then(function(data) {
|
|
284
|
+
var html = '';
|
|
285
|
+
data.collections.forEach(function(c) {
|
|
286
|
+
html += '<div class="badge" onclick="selectCol(\\'' + name + '\\', \\'' + ns + '\\', \\'' + c + '\\')">' + c + '</div>';
|
|
287
|
+
});
|
|
288
|
+
document.getElementById('col-pills').innerHTML = html;
|
|
289
|
+
});
|
|
250
290
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
291
|
+
|
|
292
|
+
function selectCol(db, ns, col) {
|
|
293
|
+
api('/api/db/' + encodeURIComponent(db) + '/ns/' + encodeURIComponent(ns) + '/col/' + encodeURIComponent(col)).then(function(data) {
|
|
294
|
+
var html = '<table><thead><tr><th>Payload</th></tr></thead><tbody>';
|
|
295
|
+
data.docs.forEach(function(doc) {
|
|
296
|
+
html += '<tr><td><pre>' + JSON.stringify(doc, null, 2) + '</pre></td></tr>';
|
|
297
|
+
});
|
|
298
|
+
document.getElementById('data-area').innerHTML = html + '</tbody></table>';
|
|
299
|
+
});
|
|
256
300
|
}
|
|
257
301
|
</script>
|
|
258
302
|
</body>
|
package/package.json
CHANGED