25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

WebAdmin: Sort alphabetically the menu items, except the most used ones

This commit is contained in:
Badlop 2024-05-15 10:50:31 +02:00
parent 9ee23d3649
commit 5872ccc992

View File

@ -1158,7 +1158,11 @@ search_running_node(SNode, [Node | Nodes]) ->
get_node(global, Node, [], Query, Lang) -> get_node(global, Node, [], Query, Lang) ->
Res = node_parse_query(Node, Query), Res = node_parse_query(Node, Query),
Base = get_base_path(global, Node, 2), Base = get_base_path(global, Node, 2),
MenuItems2 = make_menu_items(global, Node, Base, Lang), BaseItems = [{<<"db">>, <<"Database">>},
{<<"backup">>, <<"Backup">>},
{<<"stats">>, <<"Statistics">>},
{<<"update">>, <<"Update">>}],
MenuItems = make_menu_items(global, Node, Base, Lang, BaseItems),
[?XC(<<"h1">>, [?XC(<<"h1">>,
(str:translate_and_format(Lang, ?T("Node ~p"), [Node])))] (str:translate_and_format(Lang, ?T("Node ~p"), [Node])))]
++ ++
@ -1168,12 +1172,7 @@ get_node(global, Node, [], Query, Lang) ->
nothing -> [] nothing -> []
end end
++ ++
[?XE(<<"ul">>, [?XE(<<"ul">>, MenuItems),
([?LI([?ACT(<<"db/">>, ?T("Database"))]),
?LI([?ACT(<<"backup/">>, ?T("Backup"))]),
?LI([?ACT(<<"stats/">>, ?T("Statistics"))]),
?LI([?ACT(<<"update/">>, ?T("Update"))])]
++ MenuItems2)),
?XAE(<<"form">>, ?XAE(<<"form">>,
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}], [{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}],
[?INPUTT(<<"submit">>, <<"restart">>, ?T("Restart")), [?INPUTT(<<"submit">>, <<"restart">>, ?T("Restart")),
@ -1181,7 +1180,7 @@ get_node(global, Node, [], Query, Lang) ->
?INPUTTD(<<"submit">>, <<"stop">>, ?T("Stop"))])]; ?INPUTTD(<<"submit">>, <<"stop">>, ?T("Stop"))])];
get_node(Host, Node, [], _Query, Lang) -> get_node(Host, Node, [], _Query, Lang) ->
Base = get_base_path(Host, Node, 4), Base = get_base_path(Host, Node, 4),
MenuItems2 = make_menu_items(Host, Node, Base, Lang), MenuItems2 = make_menu_items(Host, Node, Base, Lang, []),
[?XC(<<"h1">>, (str:translate_and_format(Lang, ?T("Node ~p"), [Node]))), [?XC(<<"h1">>, (str:translate_and_format(Lang, ?T("Node ~p"), [Node]))),
?XE(<<"ul">>, MenuItems2)]; ?XE(<<"ul">>, MenuItems2)];
get_node(global, Node, [<<"db">>], Query, Lang) -> get_node(global, Node, [<<"db">>], Query, Lang) ->
@ -1944,19 +1943,16 @@ make_navigation_menu(Host, Node, Lang, JID, Level) ->
NodeMenu = make_node_menu(Host, Node, Lang, Level), NodeMenu = make_node_menu(Host, Node, Lang, Level),
make_server_menu(HostMenu, NodeMenu, Lang, JID, Level). make_server_menu(HostMenu, NodeMenu, Lang, JID, Level).
make_menu_items(global, cluster, Base, Lang) -> make_menu_items(Host, Node, Base, Lang, Acc) ->
HookItems = get_menu_items_hook(server, Lang), Place = case {Host, Node} of
make_menu_items(Lang, {Base, <<"">>, HookItems}); {global, cluster} -> server;
make_menu_items(global, Node, Base, Lang) -> {global, Node} -> {node, Node};
HookItems = get_menu_items_hook({node, Node}, Lang), {Host, cluster} -> {host, Host};
make_menu_items(Lang, {Base, <<"">>, HookItems}); {Host, Node} -> {hostnode, Host, Node}
make_menu_items(Host, cluster, Base, Lang) -> end,
HookItems = get_menu_items_hook({host, Host}, Lang), HookItems = get_menu_items_hook(Place, Lang),
make_menu_items(Lang, {Base, <<"">>, HookItems}); Items = lists:keysort(2, HookItems ++ Acc),
make_menu_items(Host, Node, Base, Lang) -> make_menu_items(Lang, {Base, <<"">>, Items}).
HookItems = get_menu_items_hook({hostnode, Host, Node},
Lang),
make_menu_items(Lang, {Base, <<"">>, HookItems}).
make_host_node_menu(global, _, _Lang, _JID, _Level) -> make_host_node_menu(global, _, _Lang, _JID, _Level) ->
{<<"">>, <<"">>, []}; {<<"">>, <<"">>, []};
@ -1976,14 +1972,15 @@ make_host_menu(global, _HostNodeMenu, _Lang, _JID, _Level) ->
make_host_menu(Host, HostNodeMenu, Lang, JID, Level) -> make_host_menu(Host, HostNodeMenu, Lang, JID, Level) ->
HostBase = get_base_path(Host, cluster, Level), HostBase = get_base_path(Host, cluster, Level),
HostFixed = [{<<"users">>, ?T("Users")}, HostFixed = [{<<"users">>, ?T("Users")},
{<<"online-users">>, ?T("Online Users")}] {<<"online-users">>, ?T("Online Users")}],
++ HostFixedAdditional =
get_lastactivity_menuitem_list(Host) ++ get_lastactivity_menuitem_list(Host) ++
[{<<"nodes">>, ?T("Nodes"), HostNodeMenu}, [{<<"nodes">>, ?T("Nodes"), HostNodeMenu},
{<<"stats">>, ?T("Statistics")}] {<<"stats">>, ?T("Statistics")}]
++ get_menu_items_hook({host, Host}, Lang), ++ get_menu_items_hook({host, Host}, Lang),
HostFixedAll = HostFixed ++ lists:keysort(2, HostFixedAdditional),
HostFixed2 = [Tuple HostFixed2 = [Tuple
|| Tuple <- HostFixed, || Tuple <- HostFixedAll,
is_allowed_path(Host, Tuple, JID)], is_allowed_path(Host, Tuple, JID)],
{HostBase, Host, HostFixed2}. {HostBase, Host, HostFixed2}.
@ -1997,18 +1994,20 @@ make_node_menu(global, Node, Lang, Level) ->
{<<"update">>, ?T("Update")}] {<<"update">>, ?T("Update")}]
++ get_menu_items_hook({node, Node}, Lang), ++ get_menu_items_hook({node, Node}, Lang),
{NodeBase, iolist_to_binary(atom_to_list(Node)), {NodeBase, iolist_to_binary(atom_to_list(Node)),
NodeFixed}; lists:keysort(2, NodeFixed)};
make_node_menu(_Host, _Node, _Lang, _Level) -> make_node_menu(_Host, _Node, _Lang, _Level) ->
{<<"">>, <<"">>, []}. {<<"">>, <<"">>, []}.
make_server_menu(HostMenu, NodeMenu, Lang, JID, Level) -> make_server_menu(HostMenu, NodeMenu, Lang, JID, Level) ->
Base = get_base_path(global, cluster, Level), Base = get_base_path(global, cluster, Level),
Fixed = [{<<"vhosts">>, ?T("Virtual Hosts"), HostMenu}, Fixed = [{<<"vhosts">>, ?T("Virtual Hosts"), HostMenu},
{<<"nodes">>, ?T("Nodes"), NodeMenu}, {<<"nodes">>, ?T("Nodes"), NodeMenu}],
{<<"stats">>, ?T("Statistics")}] FixedAdditional =
[{<<"stats">>, ?T("Statistics")}]
++ get_menu_items_hook(server, Lang), ++ get_menu_items_hook(server, Lang),
FixedAll = Fixed ++ lists:keysort(2, FixedAdditional),
Fixed2 = [Tuple Fixed2 = [Tuple
|| Tuple <- Fixed, || Tuple <- FixedAll,
is_allowed_path(global, Tuple, JID)], is_allowed_path(global, Tuple, JID)],
{Base, <<"">>, Fixed2}. {Base, <<"">>, Fixed2}.