Skip to content

Commit 6a62b36

Browse files
committed
Server Data Explorer: Add hover tooltips for all Plugin IDs, for easier identification. Fixes #211.
1 parent 036a5ca commit 6a62b36

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

htdocs/js/pages/PageUtils.class.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,40 +2852,43 @@ Page.PageUtils = class PageUtils extends Page.Base {
28522852

28532853
// Data Tree:
28542854

2855-
getDataTree(obj) {
2855+
getDataTree(obj, key_tooltip_map) {
28562856
// get HTML for JSON tree
28572857
var html = '';
28582858

28592859
var sorted_keys = Object.keys(obj).sort((a, b) => a.localeCompare(b));
28602860
for (var idx = 0, len = sorted_keys.length; idx < len; idx++) {
28612861
var key = sorted_keys[idx];
2862-
html += this.getDataBranch('', key, obj[key]);
2862+
html += this.getDataBranch('', key, obj[key], key_tooltip_map);
28632863
}
28642864

28652865
return html;
28662866
}
28672867

2868-
getDataBranch(path, key, value) {
2868+
getDataBranch(path, key, value, key_tooltip_map) {
28692869
var html = '';
28702870
var type = (value === null) ? 'null' : typeof(value);
28712871

28722872
if (path && !key.match(/^\[\d+\]$/)) path += '.';
28732873
path += key;
28742874

2875+
var tooltip = '';
2876+
if (key_tooltip_map && key_tooltip_map[key]) tooltip = encode_attrib_entities(key_tooltip_map[key]);
2877+
28752878
if (type == 'object') {
28762879
// hash or array
28772880
html += `<div class="tree_row">`;
28782881
html += `<span class="tree_ctrl mdi mdi-minus-box-outline" onClick="$P().toggleDataBranch(this)"></span>`;
28792882
html += `<span class="tree_folder mdi mdi-folder-open-outline"></span>`;
2880-
html += `<span class="tree_key hljs-variable" data-path="${encode_attrib_entities(path)}"><b>${encode_entities(key)}</b></span>`;
2883+
html += `<span class="tree_key hljs-variable" data-path="${encode_attrib_entities(path)}" title="${tooltip}"><b>${encode_entities(key)}</b></span>`;
28812884
html += `</div>`;
28822885
}
28832886

28842887
if (Array.isArray(value)) {
28852888
// recurse for array
28862889
html += `<div class="tree_indent expanded">`;
28872890
for (var idx = 0, len = value.length; idx < len; idx++) {
2888-
html += this.getDataBranch(path, '[' + idx + ']', value[idx]);
2891+
html += this.getDataBranch(path, '[' + idx + ']', value[idx], key_tooltip_map);
28892892
}
28902893
html += `</div>`;
28912894
}
@@ -2895,7 +2898,7 @@ Page.PageUtils = class PageUtils extends Page.Base {
28952898
var sorted_keys = Object.keys(value).sort((a, b) => a.localeCompare(b));
28962899
for (var idx = 0, len = sorted_keys.length; idx < len; idx++) {
28972900
var sub_key = sorted_keys[idx];
2898-
html += this.getDataBranch(path, sub_key, value[sub_key]);
2901+
html += this.getDataBranch(path, sub_key, value[sub_key], key_tooltip_map);
28992902
}
29002903
html += `</div>`;
29012904
}
@@ -2912,7 +2915,7 @@ Page.PageUtils = class PageUtils extends Page.Base {
29122915

29132916
html += `<div class="tree_row">`;
29142917
html += `<span class="tree_file mdi mdi-${icon}"></span>`;
2915-
html += `<span class="tree_key hljs-variable" data-path="${encode_attrib_entities(path)}">${encode_entities(key)}</span>`;
2918+
html += `<span class="tree_key hljs-variable" data-path="${encode_attrib_entities(path)}" title="${tooltip}">${encode_entities(key)}</span>`;
29162919
html += `<span class="tree_value ${extra_class}">${encode_entities(JSON.stringify(value))}</span>`;
29172920
html += `</div>`;
29182921
}
@@ -3117,8 +3120,12 @@ Page.PageUtils = class PageUtils extends Page.Base {
31173120
// now load server host data
31183121
app.api.get( 'app/get_server', { id }, function(resp) {
31193122

3123+
// include map of plugin IDs to titles, for tooltips
3124+
var key_tooltip_map = {};
3125+
app.plugins.forEach( function(plugin) { key_tooltip_map[plugin.id] = plugin.title; } );
3126+
31203127
// render json tree
3121-
$('#d_ex_tree > .ex_tree_inner').html( self.getDataTree(resp.data.data) );
3128+
$('#d_ex_tree > .ex_tree_inner').html( self.getDataTree(resp.data.data, key_tooltip_map) );
31223129

31233130
// add click handler to all keys
31243131
$('#d_ex_tree .tree_key').on('click', function() {

0 commit comments

Comments
 (0)