24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-14 22:00:16 +02:00

* src/web/ejabberd_web_admin.erl: Added "Virtual Hosts" page

SVN Revision: 382
This commit is contained in:
Alexey Shchepin 2005-07-29 20:34:57 +00:00
parent 9da4594fd0
commit 8f90927d83
2 changed files with 50 additions and 12 deletions

View File

@ -1,3 +1,7 @@
2005-07-29 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_web_admin.erl: Added "Virtual Hosts" page
2005-07-27 Alexey Shchepin <alexey@sevcom.net> 2005-07-27 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_router.erl: Added filter_packet hook * src/ejabberd_router.erl: Added filter_packet hook

View File

@ -76,6 +76,7 @@ make_xhtml(Els, global, Lang) ->
[?XE("ul", [?XE("ul",
[?LI([?ACT("/admin/acls/", "Access Control Lists")]), [?LI([?ACT("/admin/acls/", "Access Control Lists")]),
?LI([?ACT("/admin/access/", "Access Rules")]), ?LI([?ACT("/admin/access/", "Access Rules")]),
?LI([?ACT("/admin/vhosts/", "Virtual Hosts")]),
?LI([?ACT("/admin/nodes/", "Nodes")]), ?LI([?ACT("/admin/nodes/", "Nodes")]),
?LI([?ACT("/admin/stats/", "Statistics")]) ?LI([?ACT("/admin/stats/", "Statistics")])
] ]
@ -528,6 +529,7 @@ process_admin(global,
?ACT("/admin/acls-raw/", "(raw)")]), ?ACT("/admin/acls-raw/", "(raw)")]),
?LI([?ACT("/admin/access/", "Access Rules"), ?C(" "), ?LI([?ACT("/admin/access/", "Access Rules"), ?C(" "),
?ACT("/admin/access-raw/", "(raw)")]), ?ACT("/admin/access-raw/", "(raw)")]),
?LI([?ACT("/admin/vhosts/", "Virtual Hosts")]),
?LI([?ACT("/admin/nodes/", "Nodes")]), ?LI([?ACT("/admin/nodes/", "Nodes")]),
?LI([?ACT("/admin/stats/", "Statistics")]) ?LI([?ACT("/admin/stats/", "Statistics")])
] ]
@ -821,11 +823,19 @@ process_admin(Host,
]) ])
], Host, Lang); ], Host, Lang);
process_admin(global,
#request{us = US,
path = ["vhosts"],
q = Query,
lang = Lang} = Request) ->
Res = list_vhosts(Lang),
make_xhtml([?XCT("h1", "ejabberd virtual hosts")] ++ Res, global, Lang);
process_admin(Host, process_admin(Host,
#request{us = US, #request{us = US,
path = ["users"], path = ["users"],
q = Query, q = Query,
lang = Lang} = Request) when is_list(Host) -> lang = Lang} = Request) when is_list(Host) ->
Res = list_users(Host, Query, Lang), Res = list_users(Host, Query, Lang),
make_xhtml([?XCT("h1", "ejabberd users")] ++ Res, Host, Lang); make_xhtml([?XCT("h1", "ejabberd users")] ++ Res, Host, Lang);
@ -839,9 +849,9 @@ process_admin(Host,
process_admin(Host, process_admin(Host,
#request{us = US, #request{us = US,
path = ["online-users"], path = ["online-users"],
q = Query, q = Query,
lang = Lang} = Request) when is_list(Host) -> lang = Lang} = Request) when is_list(Host) ->
Res = list_online_users(Host, Lang), Res = list_online_users(Host, Lang),
make_xhtml([?XCT("h1", "ejabberd users")] ++ Res, Host, Lang); make_xhtml([?XCT("h1", "ejabberd users")] ++ Res, Host, Lang);
@ -941,17 +951,17 @@ process_admin(Host,
process_admin(Host, process_admin(Host,
#request{us = US, #request{us = US,
path = ["shared-roster"], path = ["shared-roster"],
q = Query, q = Query,
lang = Lang} = Request) -> lang = Lang} = Request) ->
Res = list_shared_roster_groups(Query, Lang), Res = list_shared_roster_groups(Query, Lang),
make_xhtml(Res, Host, Lang); make_xhtml(Res, Host, Lang);
process_admin(Host, process_admin(Host,
#request{us = US, #request{us = US,
path = ["shared-roster", Group], path = ["shared-roster", Group],
q = Query, q = Query,
lang = Lang} = Request) -> lang = Lang} = Request) ->
Res = shared_roster_group(Group, Query, Lang), Res = shared_roster_group(Group, Query, Lang),
make_xhtml(Res, Host, Lang); make_xhtml(Res, Host, Lang);
@ -1188,6 +1198,30 @@ parse_access_rule(Text) ->
end. end.
list_vhosts(Lang) ->
Hosts = ?MYHOSTS,
SHosts = lists:sort(Hosts),
[?XE("table",
[?XE("thead",
[?XE("tr",
[?XCT("td", "Host"),
?XCT("td", "Registered users"),
?XCT("td", "Online users")
])]),
?XE("tbody",
lists:map(
fun(Host) ->
OnlineUsers =
length(ejabberd_sm:get_vh_session_list(Host)),
RegisteredUsers =
length(ejabberd_auth:get_vh_registered_users(Host)),
?XE("tr",
[?XE("td", [?AC("../server/" ++ Host ++ "/", Host)]),
?XC("td", integer_to_list(RegisteredUsers)),
?XC("td", integer_to_list(OnlineUsers))
])
end, SHosts)
)])].
list_users(Host, Query, Lang) -> list_users(Host, Query, Lang) ->