2
-export([sys_table_view/1]).
6
-define(sysTabMnesia,2).
9
sys_table_view([CpId,{match,Pattern},TableType, ViewType]) ->
13
lists:sort(mnesia:system_info(tables));
15
lists:sort(rpc:call(CpId,ets,all,[]));
17
lists:sort(rpc:call(CpId,ets,all,[]) --
18
mnesia:system_info(tables));
19
_ -> %%% Happens at registration only
22
%% Filter the matching table names, skip unnamed tables first:
23
NamedTableList = lists:filter(fun (X) -> is_atom(X) end, AllTableList),
29
%% Filter the ones whose name begins with the Pattern:
31
lists:prefix(Pattern, atom_to_list(T))
33
lists:filter(Filter, NamedTableList)
36
Fields = [{text, [{value,"CpId: " ++ atom_to_list(CpId)}]},
37
{text, [{value,"TabSpec=" ++ Pattern},
38
{value_format, term}]},
39
{text, [{value,"Table type: " ++ formatTableType(TableType)},
40
{value_format, term}]}],
42
Template = [[{type, index},
43
{link, {?MODULE, sys_table_browse,
44
[{"CpId",CpId},{"TableType",TableType},
46
{"FirstKey",1}, {"KeyPattern",""}]}}],
49
{title, "Table name"},
50
{display_value, {erlang, atom_to_list}}], %%% else crash
53
{title, "No of rows"},
54
{display_value, term}],
58
{display_value, term}]
61
TableAttr = [{rows, [[T,T|tableSize(T,TableType,CpId)] ||
65
Page = [{header, {"Filter tables", "Selected tables"}},
66
{buttons, [reload, back]},
67
{layout, [{form, Fields},
72
%%--------------------------------------------------------------------
74
%% @spec tableSize(T::atom(),TableType::integer(),CpId::atom()) ->
76
%% @doc Return the table size and memory size of the table.
78
%%---------------------------------------------------------------------
80
tableSize(T, TableType, CpId) ->
83
[rpc:call(CpId, ets, info, [T, size]),
84
rpc:call(CpId, ets, info, [T, memory])];
86
[mnesia:table_info(T, size),mnesia:table_info(T, memory)];
97
_ -> %%% Registration !