From 79463d7f7d7ecaf35197bcc26ca8b42c1bf06c6c Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 3 Mar 2009 18:29:53 +0000 Subject: [PATCH] Merge 1873 from trunk. * src/web/ejabberd_web_admin.erl: Show big integers with comma separators for easy reading SVN Revision: 1939 --- ChangeLog | 3 +++ src/web/ejabberd_web_admin.erl | 49 +++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2395362a5..e489f3d61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-03-03 Badlop + * src/web/ejabberd_web_admin.erl: Show big integers with comma + separators for easy reading + * src/web/ejabberd_web_admin.erl: Calls to the hook webadmin_menu_node provide the node as first argument, and calls to webadmin_menu_hostnode provide both the host and the node. Fix diff --git a/src/web/ejabberd_web_admin.erl b/src/web/ejabberd_web_admin.erl index 7092697a4..61664d2ce 100644 --- a/src/web/ejabberd_web_admin.erl +++ b/src/web/ejabberd_web_admin.erl @@ -1297,8 +1297,8 @@ list_vhosts(Lang) -> ejabberd_auth:get_vh_registered_users_number(Host), ?XE('tr', [?XE('td', [?AC("../server/" ++ Host ++ "/", Host)]), - ?XC('td', integer_to_list(RegisteredUsers)), - ?XC('td', integer_to_list(OnlineUsers)) + ?XC('td', pretty_string_int(RegisteredUsers)), + ?XC('td', pretty_string_int(OnlineUsers)) ]) end, SHosts) )])]. @@ -1408,11 +1408,10 @@ list_given_users(Users, Prefix, Lang, URLFunc) -> QueueLen = length(mnesia:dirty_read({offline_msg, US})), [?AC(URLFunc({users_queue, Prefix, User, Server}), - integer_to_list(QueueLen))] + pretty_string_int(QueueLen))] catch _:_ -> [#xmlcdata{cdata = <<"Can't access the offline messages storage.">>}] end, - FLast = case ejabberd_sm:get_user_resources(UserB, ServerB) of [] -> @@ -1461,13 +1460,13 @@ get_stats(global, Lang) -> [?XAE('table', [], [?XE('tbody', [?XE('tr', [?XCT('td', "Registered Users:"), - ?XC('td', integer_to_list(RegisteredUsers))]), + ?XC('td', pretty_string_int(RegisteredUsers))]), ?XE('tr', [?XCT('td', "Online Users:"), - ?XC('td', integer_to_list(OnlineUsers))]), + ?XC('td', pretty_string_int(OnlineUsers))]), ?XE('tr', [?XCT('td', "Outgoing s2s Connections:"), - ?XC('td', integer_to_list(S2SConnections))]), + ?XC('td', pretty_string_int(S2SConnections))]), ?XE('tr', [?XCT('td', "Outgoing s2s Servers:"), - ?XC('td', integer_to_list(S2SServers))]) + ?XC('td', pretty_string_int(S2SServers))]) ]) ])]; @@ -1477,9 +1476,9 @@ get_stats(Host, Lang) -> [?XAE('table', [], [?XE('tbody', [?XE('tr', [?XCT('td', "Registered Users:"), - ?XC('td', integer_to_list(RegisteredUsers))]), + ?XC('td', pretty_string_int(RegisteredUsers))]), ?XE('tr', [?XCT('td', "Online Users:"), - ?XC('td', integer_to_list(OnlineUsers))]) + ?XC('td', pretty_string_int(OnlineUsers))]) ]) ])]. @@ -1626,7 +1625,7 @@ list_last_activity(Host, Lang, Integral, Period) -> [?XMLATTR('style', "width:" ++ integer_to_list( trunc(90 * V / Max)) ++ "%;")], - [#xmlcdata{cdata = list_to_binary(integer_to_list(V))}]) + [#xmlcdata{cdata = list_to_binary(pretty_string_int(V))}]) || V <- Hist ++ Tail])] end end. @@ -1770,9 +1769,9 @@ get_node(global, Node, ["db"], Query, Lang) -> ?XE('td', [db_storage_select( STable, Type, Lang)]), ?XAC('td', [?XMLATTR('class', <<"alignright">>)], - integer_to_list(Size)), + pretty_string_int(Size)), ?XAC('td', [?XMLATTR('class', <<"alignright">>)], - integer_to_list(Memory)) + pretty_string_int(Memory)) ]) end, STables), [?XC('h1', ?T("Database Tables at ") ++ atom_to_list(Node))] ++ @@ -1927,19 +1926,19 @@ get_node(global, Node, ["stats"], _Query, Lang) -> CPUTimeS)]), ?XE('tr', [?XCT('td', "Online Users:"), ?XAC('td', [?XMLATTR('class', <<"alignright">>)], - integer_to_list(OnlineUsers))]), + pretty_string_int(OnlineUsers))]), ?XE('tr', [?XCT('td', "Transactions Committed:"), ?XAC('td', [?XMLATTR('class', <<"alignright">>)], - integer_to_list(TransactionsCommitted))]), + pretty_string_int(TransactionsCommitted))]), ?XE('tr', [?XCT('td', "Transactions Aborted:"), ?XAC('td', [?XMLATTR('class', <<"alignright">>)], - integer_to_list(TransactionsAborted))]), + pretty_string_int(TransactionsAborted))]), ?XE('tr', [?XCT('td', "Transactions Restarted:"), ?XAC('td', [?XMLATTR('class', <<"alignright">>)], - integer_to_list(TransactionsRestarted))]), + pretty_string_int(TransactionsRestarted))]), ?XE('tr', [?XCT('td', "Transactions Logged:"), ?XAC('td', [?XMLATTR('class', <<"alignright">>)], - integer_to_list(TransactionsLogged))]) + pretty_string_int(TransactionsLogged))]) ]) ])]; @@ -2328,6 +2327,20 @@ last_modified() -> cache_control_public() -> {"Cache-Control", "public"}. +%% Transform 1234567890 into "1,234,567,890" +pretty_string_int(Integer) when is_integer(Integer) -> + pretty_string_int(integer_to_list(Integer)); +pretty_string_int(String) when is_list(String) -> + {_, Result} = lists:foldl( + fun(NewNumber, {3, Result}) -> + {1, [NewNumber, $, | Result]}; + (NewNumber, {CountAcc, Result}) -> + {CountAcc+1, [NewNumber | Result]} + end, + {0, ""}, + lists:reverse(String)), + Result. + %%% %%% Navigation Menu