Fix modules to work when WebAdmin has custom base URL (#3043)

This commit is contained in:
Badlop 2019-10-02 13:08:35 +02:00
parent b7222c8828
commit 20ba631f3e
2 changed files with 34 additions and 26 deletions

View File

@ -1040,9 +1040,9 @@ web_page_main(_, #request{path=[<<"statsdx">>], lang = Lang} = _Request) ->
?XE(<<"tr">>,
[?XE(<<"td">>, [?CT(<<"Top rosters">>)]),
?XE(<<"td">>, [
?ACT(<<"top/roster/30">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/roster/100">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/roster/500">>, <<"500">>) ])]
?ACT(<<"top/roster/30/">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/roster/100/">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/roster/500/">>, <<"500">>) ])]
)
])
]),
@ -1054,18 +1054,18 @@ web_page_main(_, #request{path=[<<"statsdx">>], lang = Lang} = _Request) ->
?XE(<<"tr">>,
[?XE(<<"td">>, [?CT(<<"Top offline message queues">>) ]),
?XE(<<"td">>, [
?ACT(<<"top/offlinemsg/30">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/100">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/500">>, <<"500">>) ])]
?ACT(<<"top/offlinemsg/30/">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/100/">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/500/">>, <<"500">>) ])]
),
do_stat(global, Lang, "vcards"),
?XE(<<"tr">>,
[?XE(<<"td">>, [?CT(<<"Top vCard sizes">>) ]),
?XE(<<"td">>, [
?ACT(<<"top/vcard/5">>, <<"5">>), ?C(<<", ">>),
?ACT(<<"top/vcard/30">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/vcard/100">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/vcard/500">>, <<"500">>) ])]
?ACT(<<"top/vcard/5/">>, <<"5">>), ?C(<<", ">>),
?ACT(<<"top/vcard/30/">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/vcard/100/">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/vcard/500/">>, <<"500">>) ])]
)
])
]),
@ -1171,7 +1171,11 @@ do_top_table(_Node, Lang, Topic, TopnumberBin, Host) ->
User = binary_to_list(UserB),
Server = binary_to_list(ServerB),
UserJID = User++"@"++Server,
UserJIDUrl = "/admin/server/" ++ Server ++ "/user/" ++ User ++ "/",
Level = case Host of
server -> 4;
_ -> 6
end,
UserJIDUrl = lists:duplicate(Level, "../") ++ "server/" ++ Server ++ "/user/" ++ User ++ "/",
ValueString = integer_to_list(Value),
ValueEl = case Topic of
<<"offlinemsg">> -> {url, UserJIDUrl++"queue/", ValueString};
@ -1349,9 +1353,9 @@ web_page_host(_, Host,
?XE(<<"tr">>,
[?XE(<<"td">>, [?C(<<"Top rosters">>) ]),
?XE(<<"td">>, [
?ACT(<<"top/roster/30">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/roster/100">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/roster/500">>, <<"500">>) ])]
?ACT(<<"top/roster/30/">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/roster/100/">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/roster/500/">>, <<"500">>) ])]
)
])
]),
@ -1364,17 +1368,17 @@ web_page_host(_, Host,
?XE(<<"tr">>,
[?XE(<<"td">>, [?C(<<"Top offline message queues">>)]),
?XE(<<"td">>, [
?ACT(<<"top/offlinemsg/30">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/100">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/500">>, <<"500">>) ])]
?ACT(<<"top/offlinemsg/30/">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/100/">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/offlinemsg/500/">>, <<"500">>) ])]
),
?XE(<<"tr">>,
[?XE(<<"td">>, [?C(<<"Top vCard sizes">>) ]),
?XE(<<"td">>, [
?ACT(<<"top/vcard/5">>, <<"5">>), ?C(<<", ">>),
?ACT(<<"top/vcard/30">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/vcard/100">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/vcard/500">>, <<"500">>) ])]
?ACT(<<"top/vcard/5/">>, <<"5">>), ?C(<<", ">>),
?ACT(<<"top/vcard/30/">>, <<"30">>), ?C(<<", ">>),
?ACT(<<"top/vcard/100/">>, <<"100">>), ?C(<<", ">>),
?ACT(<<"top/vcard/500/">>, <<"500">>) ])]
)
])
]),
@ -1526,7 +1530,7 @@ make_url(StatLink, L) ->
[L1, L2] = string:tokens(L, "/"),
[Stat1, L1, Stat2, L2]
end,
string:join(List, "/").
string:join(List, "/")++["/"].
do_stat_table(global, Lang, Stat, Host) ->
Os = mod_statsdx:get_statistic(global, [Stat, Host]),
@ -1545,7 +1549,11 @@ do_sessions_table(_Node, _Lang, Filter, {Sort_direction, Sort_column}, Host) ->
Lang = list_to_binary(LangS),
User = binary_to_list(JID#jid.luser),
Server = binary_to_list(JID#jid.lserver),
UserURL = "/admin/server/" ++ Server ++ "/user/" ++ User ++ "/",
Level = case Host of
server -> 1 + length(Filter);
_ -> 3 + length(Filter)
end,
UserURL = lists:duplicate(Level, "../") ++ "server/" ++ Server ++ "/user/" ++ User ++ "/",
?XE(<<"tr">>, [
?XE(<<"td">>, [?AC(list_to_binary(UserURL), jid:encode(JID))]),
?XCTB("td", atom_to_list(Client_id)),

View File

@ -945,8 +945,8 @@ web_page_host(_, _Host,
lang = Lang} = _Request) ->
Res = [?XCT(<<"h1">>, <<"Web Presence">>),
?XE(<<"ul">>, [
?LI([?ACT(<<"stats">>, <<"Statistics">>)]),
?LI([?ACT(<<"users">>, <<"Registered Users">>)])])],
?LI([?ACT(<<"stats/">>, <<"Statistics">>)]),
?LI([?ACT(<<"users/">>, <<"Registered Users">>)])])],
{stop, Res};
web_page_host(_, Host,
@ -979,7 +979,7 @@ make_users_table(Records, Lang) ->
TList = lists:map(
fun([User, RidUrl, JIDUrl, XML, Avatar, JS, Text, Icon]) ->
?XE(<<"tr">>,
[?XE(<<"td">>, [?AC(?BC([<<"../user/">>, User, <<"/">>]), User)]),
[?XE(<<"td">>, [?AC(?BC([<<"../../user/">>, User, <<"/">>]), User)]),
?XC(<<"td">>, iolist_to_binary(atom_to_list(JIDUrl))),
?XC(<<"td">>, ridurl_out(RidUrl)),
?XC(<<"td">>, Icon),