]> granicus.if.org Git - ejabberd/commitdiff
* src/web/ejabberd_web_admin.erl: Added "Virtual Hosts" page
authorAlexey Shchepin <alexey@process-one.net>
Fri, 29 Jul 2005 20:34:57 +0000 (20:34 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Fri, 29 Jul 2005 20:34:57 +0000 (20:34 +0000)
SVN Revision: 382

ChangeLog
src/web/ejabberd_web_admin.erl

index 44b25e0d2bdb306e8bca2eb238da9510891688bf..3e85ed07c544b4b718ea916f96cb6942141836b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * src/ejabberd_router.erl: Added filter_packet hook
index cac24c77304c27f780122b4e157e02487c30e8f6..86bccb2a956f3cd15c6534b1de4806b61ef56f12 100644 (file)
@@ -76,6 +76,7 @@ make_xhtml(Els, global, Lang) ->
                       [?XE("ul",
                            [?LI([?ACT("/admin/acls/", "Access Control Lists")]),
                             ?LI([?ACT("/admin/access/", "Access Rules")]),
+                            ?LI([?ACT("/admin/vhosts/", "Virtual Hosts")]),
                             ?LI([?ACT("/admin/nodes/", "Nodes")]),
                             ?LI([?ACT("/admin/stats/", "Statistics")])
                            ]
@@ -528,6 +529,7 @@ process_admin(global,
                          ?ACT("/admin/acls-raw/", "(raw)")]),
                     ?LI([?ACT("/admin/access/", "Access Rules"), ?C(" "),
                          ?ACT("/admin/access-raw/", "(raw)")]),
+                    ?LI([?ACT("/admin/vhosts/", "Virtual Hosts")]),
                     ?LI([?ACT("/admin/nodes/", "Nodes")]),
                     ?LI([?ACT("/admin/stats/", "Statistics")])
                    ]
@@ -821,11 +823,19 @@ process_admin(Host,
                     ])
               ], 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,
              #request{us = US,
-                       path = ["users"],
-                       q = Query,
-                       lang = Lang} = Request) when is_list(Host) ->
+                      path = ["users"],
+                      q = Query,
+                      lang = Lang} = Request) when is_list(Host) ->
     Res = list_users(Host, Query, Lang),
     make_xhtml([?XCT("h1", "ejabberd users")] ++ Res, Host, Lang);
 
@@ -839,9 +849,9 @@ process_admin(Host,
 
 process_admin(Host,
              #request{us = US,
-                       path = ["online-users"],
-                       q = Query,
-                       lang = Lang} = Request) when is_list(Host) ->
+                      path = ["online-users"],
+                      q = Query,
+                      lang = Lang} = Request) when is_list(Host) ->
     Res = list_online_users(Host, Lang),
     make_xhtml([?XCT("h1", "ejabberd users")] ++ Res, Host, Lang);
 
@@ -941,17 +951,17 @@ process_admin(Host,
 
 process_admin(Host,
              #request{us = US,
-                       path = ["shared-roster"],
-                       q = Query,
-                       lang = Lang} = Request) ->
+                      path = ["shared-roster"],
+                      q = Query,
+                      lang = Lang} = Request) ->
     Res = list_shared_roster_groups(Query, Lang),
     make_xhtml(Res, Host, Lang);
 
 process_admin(Host,
              #request{us = US,
-                       path = ["shared-roster", Group],
-                       q = Query,
-                       lang = Lang} = Request) ->
+                      path = ["shared-roster", Group],
+                      q = Query,
+                      lang = Lang} = Request) ->
     Res = shared_roster_group(Group, Query, Lang),
     make_xhtml(Res, Host, Lang);
 
@@ -1188,6 +1198,30 @@ parse_access_rule(Text) ->
     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) ->