From 2ea0e371488e69def56df318fc0c1cd2f02eab1d Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 8 Feb 2021 12:43:04 +0100 Subject: [PATCH] Add admin form to check a user quota usage from their public key --- www/admin/inner.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/www/admin/inner.js b/www/admin/inner.js index 8b6bed1d9..4b0875be2 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -51,6 +51,7 @@ define([ 'cp-admin-defaultlimit', 'cp-admin-setlimit', 'cp-admin-getlimits', + 'cp-admin-getquota', ], 'stats': [ 'cp-admin-refresh-stats', @@ -467,6 +468,43 @@ define([ return $div; }; + create['getquota'] = function () { + var key = 'getquota'; + var $div = makeBlock(key, true); + + var input = h('input#cp-admin-getquota', { + type: 'text' + }); + var $input = $(input); + + var $button = $div.find('button'); + $button.before(h('div.cp-admin-setlimit-form', [ + input, + ])); + + $button.click(function () { + var val = $input.val(); + if (!val || !val.trim()) { return; } + var key = Keys.canonicalize(val); + if (!key) { return; } + $input.val(''); + sFrameChan.query('Q_ADMIN_RPC', { + cmd: 'GET_USER_TOTAL_SIZE', + data: key + }, function (e, obj) { + if (e || (obj && obj.error)) { + console.error(e || obj.error); + return void UI.warn(Messages.error); + } + var size = Array.isArray(obj) && obj[0]; + if (typeof(size) !== "number") { return; } + UI.alert(Util.getPrettySize(size, Messages)); + }); + }); + + return $div; + }; + var onRefreshStats = Util.mkEvent(); create['refresh-stats'] = function () {