25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

* src/web/ejabberd_web_admin.erl: Updated

SVN Revision: 234
This commit is contained in:
Alexey Shchepin 2004-05-16 20:13:38 +00:00
parent 0ef7655697
commit d46abc7ad4
3 changed files with 141 additions and 25 deletions

View File

@ -1,3 +1,7 @@
2004-05-16 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_web_admin.erl: Updated
2004-05-14 Alexey Shchepin <alexey@sevcom.net> 2004-05-14 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_web_admin.erl: Updated * src/web/ejabberd_web_admin.erl: Updated

View File

@ -415,7 +415,7 @@ set_form(["running nodes", ENode, "DB"], Lang, XData) ->
Node -> Node ->
lists:foreach( lists:foreach(
fun({SVar, SVals}) -> fun({SVar, SVals}) ->
% We believe that this is allowed only for good peoples % We believe that this is allowed only for good people
Table = list_to_atom(SVar), Table = list_to_atom(SVar),
Type = case SVals of Type = case SVals of
["unknown"] -> unknown; ["unknown"] -> unknown;

View File

@ -457,6 +457,10 @@ div#content {
margin-top: 5px; margin-top: 5px;
} }
*.alignright {
text-align: right;
}
". ".
logo() -> logo() ->
@ -780,7 +784,7 @@ process_admin(#request{user = User,
false -> false ->
make_xhtml([?XC("h1", "Node not found")], Lang); make_xhtml([?XC("h1", "Node not found")], Lang);
Node -> Node ->
Res = get_node(Node, NPath, Lang), Res = get_node(Node, NPath, Query, Lang),
make_xhtml(Res, Lang) make_xhtml(Res, Lang)
end; end;
@ -1169,7 +1173,7 @@ search_running_node(SNode, [Node | Nodes]) ->
search_running_node(SNode, Nodes) search_running_node(SNode, Nodes)
end. end.
get_node(Node, [], Lang) -> get_node(Node, [], Query, Lang) ->
[?XC("h1", "Node: " ++ atom_to_list(Node)), [?XC("h1", "Node: " ++ atom_to_list(Node)),
?XE("ul", ?XE("ul",
[?LI([?ACT("db/", "DB Management")]), [?LI([?ACT("db/", "DB Management")]),
@ -1177,43 +1181,118 @@ get_node(Node, [], Lang) ->
?LI([?ACT("statistics/", "Statistics")]) ?LI([?ACT("statistics/", "Statistics")])
])]; ])];
get_node(Node, ["db"], Lang) -> get_node(Node, ["db"], Query, Lang) ->
case rpc:call(Node, mnesia, system_info, [tables]) of case rpc:call(Node, mnesia, system_info, [tables]) of
{badrpc, _Reason} -> {badrpc, _Reason} ->
[?XC("h1", "RPC call error")]; [?XC("h1", "RPC call error")];
Tables -> Tables ->
Res = node_db_parse_query(Node, Tables, Query),
STables = lists:sort(Tables), STables = lists:sort(Tables),
Rows = lists:map( Rows = lists:map(
fun(Table) -> fun(Table) ->
Type = case rpc:call(Node,
mnesia,
table_info,
[Table, storage_type]) of
{badrpc, _} ->
unknown;
T ->
T
end,
STable = atom_to_list(Table), STable = atom_to_list(Table),
TInfo =
case rpc:call(Node,
mnesia,
table_info,
[Table, all]) of
{badrpc, _} ->
[];
I ->
I
end,
{Type, Size, Memory} =
case {lists:keysearch(storage_type, 1, TInfo),
lists:keysearch(size, 1, TInfo),
lists:keysearch(memory, 1, TInfo)} of
{{value, {storage_type, T}},
{value, {size, S}},
{value, {memory, M}}} ->
{T, S, M};
_ ->
{unknown, 0, 0}
end,
?XE("tr", ?XE("tr",
[?XC("td", STable), [?XC("td", STable),
?XE("td", [db_storage_select( ?XE("td", [db_storage_select(
STable, Type, Lang)]) STable, Type, Lang)]),
?XAC("td", [{"class", "alignright"}],
integer_to_list(Size)),
?XAC("td", [{"class", "alignright"}],
integer_to_list(Memory))
]) ])
end, STables), end, STables),
[?XC("h1", "DB Tables at " ++ atom_to_list(Node)), [?XC("h1", "DB Tables at " ++ atom_to_list(Node))] ++
?XAE("table", [], case Res of
[?XE("tbody", ok -> [?C("submited"), ?P];
Rows ++ error -> [?C("bad format"), ?P];
[?XE("tr", nothing -> []
[?X("td"), end ++
?XE("td", [?INPUTT("submit", "submit", "Submit")]) [?XAE("form", [{"method", "post"}],
] [?XAE("table", [],
)] [?XE("thead",
)])] [?XE("tr",
[?XCT("td", "Name"),
?XCT("td", "Storage Type"),
?XCT("td", "Size"),
?XCT("td", "Memory")
])]),
?XE("tbody",
Rows ++
[?XE("tr",
[?XAE("td", [{"colspan", "4"},
{"class", "alignright"}],
[?INPUTT("submit", "submit",
"Submit")])
])]
)])])]
end; end;
get_node(Node, NPath, Lang) -> get_node(Node, ["backup"], Query, Lang) ->
[?XC("h1", "Backup Management at " ++ atom_to_list(Node)),
?XAE("form", [{"method", "post"}],
[?XAE("table", [],
[?XE("tbody",
[?XE("tr",
[?XCT("td", "Store a backup in a file"),
?XE("td", [?INPUT("text", "storepath",
"ejabberd.backup")]),
?XE("td", [?INPUTT("submit", "store",
"OK")])
]),
?XE("tr",
[?XCT("td", "Restore a backup from a file"),
?XE("td", [?INPUT("text", "restorepath",
"ejabberd.backup")]),
?XE("td", [?INPUTT("submit", "restore",
"OK")])
]),
?XE("tr",
[?XCT("td",
"Install a database fallback from a file"),
?XE("td", [?INPUT("text", "fallbackpath",
"ejabberd.backup")]),
?XE("td", [?INPUTT("submit", "fallback",
"OK")])
]),
?XE("tr",
[?XCT("td", "Dump a database in a text file"),
?XE("td", [?INPUT("text", "dumppath",
"ejabberd.dump")]),
?XE("td", [?INPUTT("submit", "dump",
"OK")])
]),
?XE("tr",
[?XCT("td", "Restore a database from a text file"),
?XE("td", [?INPUT("text", "loadpath",
"ejabberd.dump")]),
?XE("td", [?INPUTT("submit", "load",
"OK")])
])
])
])])];
get_node(Node, NPath, Query, Lang) ->
[?XC("h1", "Not found")]. [?XC("h1", "Not found")].
@ -1233,3 +1312,36 @@ db_storage_select(ID, Opt, Lang) ->
{disc_only_copies, "Disc only copy"}, {disc_only_copies, "Disc only copy"},
{unknown, "Remote copy"}])). {unknown, "Remote copy"}])).
node_db_parse_query(Node, Tables, Query) ->
lists:foreach(
fun(Table) ->
STable = atom_to_list(Table),
case lists:keysearch("table" ++ STable, 1, Query) of
{value, {_, SType}} ->
Type = case SType of
"unknown" -> unknown;
"ram_copies" -> ram_copies;
"disc_copies" -> disc_copies;
"disc_only_copies" -> disc_only_copies;
_ -> false
end,
if
Type == false ->
ok;
Type == unknown ->
mnesia:del_table_copy(Table, Node);
true ->
case mnesia:add_table_copy(Table, Node, Type) of
{aborted, _} ->
mnesia:change_table_copy_type(
Table, Node, Type);
_ ->
ok
end
end;
_ ->
ok
end
end, Tables),
ok.