MCPcopy
hub / github.com/joeferner/redis-commander / getJsTreeData

Function getJsTreeData

web/static/scripts/redisCommander.js:101–130  ·  view source on GitHub ↗
(node, cb)

Source from the content-addressed store, hash-verified

99 return onJSTreeDataComplete();
100
101 function getJsTreeData(node, cb) {
102 if (node.id === '#') return cb(connections.treeObjects);
103
104 var dataUrl;
105 if (node.parent === '#') {
106 dataUrl = 'apiv2/keystree/' + encodeURIComponent(node.id) + '/';
107 }
108 else {
109 var root = getRootConnection(node);
110 var path = getFullKeyPath(node);
111 dataUrl = 'apiv2/keystree/' + encodeURIComponent(root) + '/' + encodeURIComponent(path) + '?absolute=false';
112 }
113 $.get({
114 url: dataUrl,
115 dataType: 'json'
116 }).done(function(nodeData) {
117 if (Array.isArray(nodeData.data)) {
118 nodeData.data.forEach(function(elem) {
119 if (elem.rel) elem.icon = getIconForType(elem.rel);
120 });
121 }
122 cb(nodeData.data)
123 }).fail(function(error) {
124 console.log('Error fetching data for node ' + node.id + ': ' + JSON.stringify(error));
125 if (error.responseJSON && error.responseJSON.connectionClosed) {
126 setRootConnectionNetworkError(true, node)
127 }
128 cb('Error fetching data');
129 });
130 }
131
132 function getIconForType(type) {
133 switch (type) {

Callers

nothing calls this directly

Calls 4

getRootConnectionFunction · 0.85
getFullKeyPathFunction · 0.85
getIconForTypeFunction · 0.85

Tested by

no test coverage detected