1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2013-2018. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19-module(cdv_dist_cb). 20 21-export([col_to_elem/1, 22 col_spec/0, 23 get_info/1, 24 get_detail_cols/1, 25 get_details/2, 26 detail_pages/0, 27 format/1]). 28 29-include_lib("wx/include/wx.hrl"). 30-include("crashdump_viewer.hrl"). 31 32%% Columns 33-define(COL_NAME, 0). 34-define(COL_TYPE, ?COL_NAME+1). 35-define(COL_CTRL, ?COL_TYPE+1). 36-define(COL_CH, ?COL_CTRL+1). 37-define(COL_CRE, ?COL_CH+1). 38 39%% Callbacks for cdv_virtual_list_wx 40col_to_elem(id) -> col_to_elem(?COL_CH); 41col_to_elem(?COL_NAME) -> #nod.name; 42col_to_elem(?COL_CH) -> #nod.channel; 43col_to_elem(?COL_CTRL) -> #nod.controller; 44col_to_elem(?COL_CRE) -> #nod.creation; 45col_to_elem(?COL_TYPE) -> #nod.conn_type. 46 47col_spec() -> 48 [{"Name", ?wxLIST_FORMAT_LEFT, 300}, 49 {"Connection type", ?wxLIST_FORMAT_LEFT, 130}, 50 {"Controller", ?wxLIST_FORMAT_LEFT, 130}, 51 {"Channel", ?wxLIST_FORMAT_RIGHT, 80}, 52 {"Creation", ?wxLIST_FORMAT_RIGHT, 80}]. 53 54get_info(_) -> 55 {ok,Info,TW} = crashdump_viewer:dist_info(), 56 {Info,TW}. 57 58get_detail_cols(_) -> 59 {[{node, ?COL_CH},{port,?COL_CTRL}],true}. 60 61%% Callbacks for cdv_detail_wx 62get_details(Id, _) -> 63 case crashdump_viewer:node_info(Id) of 64 {ok,Info,TW} -> 65 Proplist = crashdump_viewer:to_proplist(record_info(fields,nod),Info), 66 Title = io_lib:format("~s (~s)",[Info#nod.name,Id]), 67 {ok,{Title,Proplist,TW}}; 68 {error,not_found} -> 69 Info = "The node you are searching for could not be found.", 70 {info,Info} 71 end. 72 73detail_pages() -> 74 [{"General Information", fun init_gen_page/2}]. 75 76init_gen_page(Parent, Info) -> 77 Fields = info_fields(), 78 cdv_info_wx:start_link(Parent,{Fields,Info,[]}). 79 80format({creations,Creations}) -> 81 lists:flatten(lists:join(",",[integer_to_list(C) || C <- Creations])); 82format(D) -> 83 D. 84 85%%%----------------------------------------------------------------- 86%%% Internal 87info_fields() -> 88 [{"Overview", 89 [{"Name", name}, 90 {"Type", conn_type}, 91 {"Channel", channel}, 92 {"Controller", {click,controller}}, 93 {"Creation", {{format,fun format/1},creation}}, 94 {"Extra Info", error}]}, 95 {scroll_boxes, 96 [{"Remote Links",1,{click,remote_links}}, 97 {"Remote Monitors",1,{click,remote_mon}}, 98 {"Remote Monitored By",1,{click,remote_mon_by}}]}]. 99