(event, data)
| 219 | } |
| 220 | |
| 221 | function treeNodeSelected (event, data) { |
| 222 | $('#body').html('Loading...'); |
| 223 | var connectionId; |
| 224 | if (data.node.parent === '#') { |
| 225 | connectionId = data.node.id; |
| 226 | $.get('apiv2/server/' + connectionId + '/info') |
| 227 | .done(function (infoData, status) { |
| 228 | if (status !== 'success') { |
| 229 | return alert('Could not load server info'); |
| 230 | } |
| 231 | if (typeof infoData === 'string') infoData = JSON.parse(infoData); |
| 232 | infoData.data.some(function (instance) { |
| 233 | if (instance.connectionId === connectionId) { |
| 234 | if (!instance.disabled) { |
| 235 | setRootConnectionNetworkError(false, data.node); |
| 236 | renderEjs('templates/serverInfo.ejs', instance, $('#body'), setupAddKeyButton); |
| 237 | } |
| 238 | else { |
| 239 | setRootConnectionNetworkError(true, data.node); |
| 240 | var html = '<h5>ERROR: ' + (instance.error ? instance.error : 'Server not available - cannot query status information.') + '</h5>'; |
| 241 | $('#body').html(html); |
| 242 | setupAddKeyButton(); |
| 243 | } |
| 244 | return true; |
| 245 | } |
| 246 | return false; |
| 247 | }); |
| 248 | }) |
| 249 | .fail(function (error) { |
| 250 | if (error.responseJSON) { |
| 251 | if (error.responseJSON.message) { |
| 252 | $('#body').html('<h5>Got ERROR: ' + error.responseJSON + '</h5>'); |
| 253 | } |
| 254 | else { |
| 255 | $('#body').html('<h5>Network ERROR calling server...</h5>'); |
| 256 | } |
| 257 | if (error.responseJSON.connectionClosed) setRootConnectionNetworkError(true, data.node); |
| 258 | } |
| 259 | }); |
| 260 | } else { |
| 261 | connectionId = getRootConnection(data.node); |
| 262 | var path = getFullKeyPath(data.node); |
| 263 | return loadKey(connectionId, path); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | /** finds root entry with connection object of the node given and changes icon to show disconnect state |
| 268 | * |
nothing calls this directly
no test coverage detected