add button to custom limits table to generate account reports

and always display results in the table rather than the list view
This commit is contained in:
ansuz 2022-09-20 16:40:15 +05:30
parent 919af10913
commit 27522b5114
2 changed files with 43 additions and 31 deletions

View file

@ -26,7 +26,6 @@
} }
} }
.cp-admin-setlimit-form, .cp-admin-broadcast-form { .cp-admin-setlimit-form, .cp-admin-broadcast-form {
label { label {
font-weight: normal !important; font-weight: normal !important;
@ -46,6 +45,10 @@
} }
} }
.cp-admin-getlimits { .cp-admin-getlimits {
td {
overflow: hidden;
text-overflow: ellipsis;
}
code { code {
cursor: pointer; cursor: pointer;
} }
@ -62,6 +65,9 @@
max-width: 500px; max-width: 500px;
} }
@media screen and (max-width: 1200px) { @media screen and (max-width: 1200px) {
button.cp-report {
display: none;
}
:is(td, th).note { :is(td, th).note {
display: none; display: none;
} }

View file

@ -1608,8 +1608,6 @@ define([
return obj[a].limit > obj[b].limit; return obj[a].limit > obj[b].limit;
}); });
var compact = list.length > 10;
var content = list.map(function (key) { var content = list.map(function (key) {
var user = obj[key]; var user = obj[key];
var limit = getPrettySize(user.limit); var limit = getPrettySize(user.limit);
@ -1617,42 +1615,50 @@ define([
Messages._getKey('admin_limitPlan', [user.plan]) + ', ' + Messages._getKey('admin_limitPlan', [user.plan]) + ', ' +
Messages._getKey('admin_limitNote', [user.note]); Messages._getKey('admin_limitNote', [user.note]);
var infoButton = h('button.btn.primary.cp-report', {
style: 'margin-left: 10px; cursor: pointer;',
}, Messages.admin_diskUsageButton);
$(infoButton).click(() => {
console.log(key);
getAccountData(key, (err, data) => {
if (err) { return void console.error(err); }
console.log(data);
var table = renderAccountData(data);
UI.alert(table, () => {
}, {
wide: true,
});
});
});
var keyEl = h('code.cp-limit-key', key); var keyEl = h('code.cp-limit-key', key);
$(keyEl).click(function () { $(keyEl).click(function () {
$('.cp-admin-setlimit-form').find('.cp-setlimit-key').val(key); $('.cp-admin-setlimit-form').find('.cp-setlimit-key').val(key);
$('.cp-admin-setlimit-form').find('.cp-setlimit-quota').val(Math.floor(user.limit / 1024 / 1024)); $('.cp-admin-setlimit-form').find('.cp-setlimit-quota').val(Math.floor(user.limit / 1024 / 1024));
$('.cp-admin-setlimit-form').find('.cp-setlimit-note').val(user.note); $('.cp-admin-setlimit-form').find('.cp-setlimit-note').val(user.note);
}); });
if (compact) {
return h('tr.cp-admin-limit', { var attr = { title: title };
title: title return h('tr.cp-admin-limit', [
}, [ h('td', [
h('td', keyEl), keyEl,
h('td.limit', limit), infoButton,
h('td.plan', user.plan), ]),
h('td.note', user.note) h('td.limit', attr, limit),
]); h('td.plan', attr, user.plan),
} h('td.note', attr, user.note)
return h('li.cp-admin-limit', [
keyEl,
h('ul.cp-limit-data', [
h('li.limit', Messages._getKey('admin_limit', [limit])),
h('li.plan', Messages._getKey('admin_limitPlan', [user.plan])),
h('li.note', Messages._getKey('admin_limitNote', [user.note]))
])
]); ]);
}); });
if (compact) { return $div.append(h('table.cp-admin-all-limits', [
return $div.append(h('table.cp-admin-all-limits', [ h('tr', [
h('tr', [ h('th', Messages.settings_publicSigningKey),
h('th', Messages.settings_publicSigningKey), h('th.limit', Messages.admin_planlimit),
h('th.limit', Messages.admin_planlimit), h('th.plan', Messages.admin_planName),
h('th.plan', Messages.admin_planName), h('th.note', Messages.admin_note)
h('th.note', Messages.admin_note) ]),
]), ].concat(content)));
].concat(content)));
}
$div.append(h('ul.cp-admin-all-limits', content));
}); });
}; };
APP.refreshLimits(); APP.refreshLimits();