admin-console: implement Dynamic client CRD counting, S3 storage metrics, CSV export
This commit is contained in:
@@ -125,19 +125,38 @@
|
||||
|
||||
function renderUsage(rows) {
|
||||
if (!rows?.length) return '<p class="loader">Нет данных</p>';
|
||||
return `<table>
|
||||
const btn = `<div style="margin-bottom:12px">
|
||||
<button onclick="exportCSV()">📥 Экспорт CSV</button>
|
||||
</div>`;
|
||||
return btn + `<table>
|
||||
<tr><th>Namespace</th><th>Email</th><th>Функции</th><th>Вызовы</th><th>Хранилище GB</th><th>Период</th></tr>
|
||||
${rows.map(u => `<tr>
|
||||
<td><span class="pill pill-blue">${u.namespace}</span></td>
|
||||
<td>${u.user_email || '—'}</td>
|
||||
<td>${u.functions}</td>
|
||||
<td>${u.invocations_total}</td>
|
||||
<td>${u.storage_gb.toFixed(2)}</td>
|
||||
<td>${(u.storage_gb || 0).toFixed(3)}</td>
|
||||
<td>${u.period_start} — ${u.period_end}</td>
|
||||
</tr>`).join('')}
|
||||
</table>`;
|
||||
}
|
||||
|
||||
function exportCSV() {
|
||||
const table = document.querySelector('table');
|
||||
if (!table) return;
|
||||
let csv = '\uFEFF'; // BOM для Excel
|
||||
table.querySelectorAll('tr').forEach(row => {
|
||||
const cells = [];
|
||||
row.querySelectorAll('th,td').forEach(c => cells.push('"' + c.textContent.replace(/"/g, '""') + '"'));
|
||||
csv += cells.join(',') + '\n';
|
||||
});
|
||||
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = `usage-${new Date().toISOString().slice(0,10)}.csv`;
|
||||
a.click();
|
||||
}
|
||||
|
||||
function renderUsers(rows) {
|
||||
if (!rows?.length) return '<p class="loader">Нет пользователей</p>';
|
||||
return `<table>
|
||||
|
||||
Reference in New Issue
Block a user