4315 |
23 Jan 17 |
nicklas |
var Remote = function() |
4315 |
23 Jan 17 |
nicklas |
2 |
{ |
4315 |
23 Jan 17 |
nicklas |
var remote = {}; |
4318 |
24 Jan 17 |
nicklas |
var debug = 0; |
4315 |
23 Jan 17 |
nicklas |
5 |
|
4315 |
23 Jan 17 |
nicklas |
remote.initPage = function() |
4315 |
23 Jan 17 |
nicklas |
7 |
{ |
4315 |
23 Jan 17 |
nicklas |
var url = 'OpenGrid.servlet?ID='+App.getSessionId(); |
4317 |
23 Jan 17 |
nicklas |
url += '&cmd=GetHostInfo&jobAgentDetails=1'; |
4315 |
23 Jan 17 |
nicklas |
url += '&hostId='+encodeURIComponent(Data.get('page-data', 'host-id')); |
4315 |
23 Jan 17 |
nicklas |
11 |
|
4315 |
23 Jan 17 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
4315 |
23 Jan 17 |
nicklas |
request.open("GET", url, true); |
4315 |
23 Jan 17 |
nicklas |
Ajax.setReadyStateHandler(request, remote.onHostInfoLoaded, remote.onHostInfoLoaded); |
4315 |
23 Jan 17 |
nicklas |
request.send(null); |
4315 |
23 Jan 17 |
nicklas |
16 |
|
4315 |
23 Jan 17 |
nicklas |
// All other initialization happens after info has been loaded |
4315 |
23 Jan 17 |
nicklas |
18 |
} |
4315 |
23 Jan 17 |
nicklas |
19 |
|
4315 |
23 Jan 17 |
nicklas |
remote.onHostInfoLoaded = function(request) |
4315 |
23 Jan 17 |
nicklas |
21 |
{ |
4315 |
23 Jan 17 |
nicklas |
if (debug) App.debug(Strings.encodeTags(request.responseText)); |
4315 |
23 Jan 17 |
nicklas |
var response; |
4315 |
23 Jan 17 |
nicklas |
var error = false; |
4315 |
23 Jan 17 |
nicklas |
try |
4315 |
23 Jan 17 |
nicklas |
26 |
{ |
4315 |
23 Jan 17 |
nicklas |
response = JSON.parse(request.responseText); |
4315 |
23 Jan 17 |
nicklas |
if (response.status != 'ok') |
4315 |
23 Jan 17 |
nicklas |
29 |
{ |
4315 |
23 Jan 17 |
nicklas |
error = response.message || response.stacktrace || 'Unexpected error'; |
4315 |
23 Jan 17 |
nicklas |
31 |
} |
4315 |
23 Jan 17 |
nicklas |
32 |
} |
4315 |
23 Jan 17 |
nicklas |
catch (ex) |
4315 |
23 Jan 17 |
nicklas |
34 |
{ |
4315 |
23 Jan 17 |
nicklas |
error = ex; |
4315 |
23 Jan 17 |
nicklas |
36 |
} |
4315 |
23 Jan 17 |
nicklas |
37 |
|
4315 |
23 Jan 17 |
nicklas |
if (error) |
4315 |
23 Jan 17 |
nicklas |
39 |
{ |
4315 |
23 Jan 17 |
nicklas |
alert(error); |
4315 |
23 Jan 17 |
nicklas |
return; |
4315 |
23 Jan 17 |
nicklas |
42 |
} |
4315 |
23 Jan 17 |
nicklas |
43 |
|
4318 |
24 Jan 17 |
nicklas |
var host = response.host; |
4315 |
23 Jan 17 |
nicklas |
var connectionInfo = host.connection; |
4315 |
23 Jan 17 |
nicklas |
var hostInfo = host.clusterInfo.hostInfo; |
4315 |
23 Jan 17 |
nicklas |
var openGridInfo = host.clusterInfo.openGridInfo; |
4315 |
23 Jan 17 |
nicklas |
var config = host.config; |
4315 |
23 Jan 17 |
nicklas |
49 |
|
4315 |
23 Jan 17 |
nicklas |
Doc.element('host-name').innerHTML = Strings.encodeTags(connectionInfo.name); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('host-address').innerHTML = Strings.encodeTags(connectionInfo.address+':'+connectionInfo.port); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('username').innerHTML = Strings.encodeTags(connectionInfo.user); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('fingerprint').innerHTML = Strings.encodeTags(connectionInfo.fingerprint); |
4315 |
23 Jan 17 |
nicklas |
54 |
|
5986 |
10 Jul 20 |
nicklas |
Doc.element('ogs-type').innerHTML = Strings.encodeTags(config.type); |
4318 |
24 Jan 17 |
nicklas |
Doc.element('cluster-info-cmd').innerHTML = Strings.encodeTags('> ' + hostInfo.cmd); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('cluster-info-result').innerHTML = remote.getCmdResultString(hostInfo); |
4318 |
24 Jan 17 |
nicklas |
Doc.element('ogs-info-cmd').innerHTML = Strings.encodeTags('> ' + openGridInfo.cmd); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('ogs-info-result').innerHTML = remote.getCmdResultString(openGridInfo); |
4315 |
23 Jan 17 |
nicklas |
60 |
|
4318 |
24 Jan 17 |
nicklas |
Doc.element('time-cmd').innerHTML = Strings.encodeTags('> ' + config.dateCommand); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('time-diff').innerHTML = host.clusterInfo.timeAdjustment + ' seconds'; |
4315 |
23 Jan 17 |
nicklas |
63 |
|
4317 |
23 Jan 17 |
nicklas |
Doc.element('job-agent').innerHTML = remote.getJobAgentString(config.jobAgent); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('job-folder').innerHTML = Strings.encodeTags(config.jobFolder); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('tmp-folder').innerHTML = Strings.encodeTags(config.tmpFolder); |
4315 |
23 Jan 17 |
nicklas |
Doc.element('tmp-folder-debug').innerHTML = Strings.encodeTags(config.tmpFolderDebug); |
4315 |
23 Jan 17 |
nicklas |
68 |
|
4315 |
23 Jan 17 |
nicklas |
var nodes = ''; |
4315 |
23 Jan 17 |
nicklas |
if (config.nodes.length > 0) |
4315 |
23 Jan 17 |
nicklas |
71 |
{ |
4315 |
23 Jan 17 |
nicklas |
nodes = '<ul>'; |
4315 |
23 Jan 17 |
nicklas |
for (var i = 0; i < config.nodes.length; i++) |
4315 |
23 Jan 17 |
nicklas |
74 |
{ |
4315 |
23 Jan 17 |
nicklas |
nodes += '<li>'+Strings.encodeTags(config.nodes[i].name); |
4315 |
23 Jan 17 |
nicklas |
76 |
} |
4315 |
23 Jan 17 |
nicklas |
nodes += '</ul>'; |
4315 |
23 Jan 17 |
nicklas |
78 |
} |
4315 |
23 Jan 17 |
nicklas |
else |
4315 |
23 Jan 17 |
nicklas |
80 |
{ |
4315 |
23 Jan 17 |
nicklas |
nodes = '<i>Not configured</i>'; |
4315 |
23 Jan 17 |
nicklas |
82 |
} |
4315 |
23 Jan 17 |
nicklas |
Doc.element('nodes').innerHTML = nodes; |
4317 |
23 Jan 17 |
nicklas |
84 |
|
4317 |
23 Jan 17 |
nicklas |
var linkedItems = document.getElementsByClassName('linked-item'); |
4317 |
23 Jan 17 |
nicklas |
for (var itemNo = 0; itemNo < linkedItems.length; itemNo++) |
4317 |
23 Jan 17 |
nicklas |
87 |
{ |
4317 |
23 Jan 17 |
nicklas |
Events.addEventHandler(linkedItems[itemNo], 'click', Items.itemOnClick); |
4317 |
23 Jan 17 |
nicklas |
89 |
} |
4317 |
23 Jan 17 |
nicklas |
90 |
|
4317 |
23 Jan 17 |
nicklas |
var sharedItems = document.getElementsByClassName('shared-item'); |
4317 |
23 Jan 17 |
nicklas |
for (var itemNo = 0; itemNo < sharedItems.length; itemNo++) |
4317 |
23 Jan 17 |
nicklas |
93 |
{ |
4317 |
23 Jan 17 |
nicklas |
Events.addEventHandler(sharedItems[itemNo], 'click', Buttons.shareItem); |
4317 |
23 Jan 17 |
nicklas |
95 |
} |
4315 |
23 Jan 17 |
nicklas |
96 |
} |
4315 |
23 Jan 17 |
nicklas |
97 |
|
4315 |
23 Jan 17 |
nicklas |
remote.getCmdResultString = function(cmdData) |
4315 |
23 Jan 17 |
nicklas |
99 |
{ |
4315 |
23 Jan 17 |
nicklas |
var r = ''; |
4315 |
23 Jan 17 |
nicklas |
if (cmdData.exitStatus != 0) |
4315 |
23 Jan 17 |
nicklas |
102 |
{ |
4315 |
23 Jan 17 |
nicklas |
r += '<div class="stderr">['+cmdData.exitStatus+'] '; |
4315 |
23 Jan 17 |
nicklas |
r += Strings.encodeTags(cmdData.stderr); |
4315 |
23 Jan 17 |
nicklas |
r += '</div>'; |
4315 |
23 Jan 17 |
nicklas |
106 |
} |
4315 |
23 Jan 17 |
nicklas |
else |
4315 |
23 Jan 17 |
nicklas |
108 |
{ |
4315 |
23 Jan 17 |
nicklas |
r += '<div class="stdout">'; |
4315 |
23 Jan 17 |
nicklas |
r += Strings.encodeTags(cmdData.stdout); |
4315 |
23 Jan 17 |
nicklas |
r += '</div>'; |
4315 |
23 Jan 17 |
nicklas |
112 |
} |
4315 |
23 Jan 17 |
nicklas |
return r; |
4315 |
23 Jan 17 |
nicklas |
114 |
} |
4315 |
23 Jan 17 |
nicklas |
115 |
|
4317 |
23 Jan 17 |
nicklas |
remote.getJobAgentString = function(jobAgent) |
4317 |
23 Jan 17 |
nicklas |
117 |
{ |
4317 |
23 Jan 17 |
nicklas |
var html = ''; |
4317 |
23 Jan 17 |
nicklas |
if (!jobAgent) |
4317 |
23 Jan 17 |
nicklas |
120 |
{ |
4317 |
23 Jan 17 |
nicklas |
html = '<i>Not connected</i>'; |
4317 |
23 Jan 17 |
nicklas |
122 |
} |
4317 |
23 Jan 17 |
nicklas |
else if (jobAgent.exception) |
4317 |
23 Jan 17 |
nicklas |
124 |
{ |
4317 |
23 Jan 17 |
nicklas |
html = Strings.encodeTags(jobAgent.externalId + ' [' + jobAgent.exception + ']'); |
4317 |
23 Jan 17 |
nicklas |
126 |
} |
4317 |
23 Jan 17 |
nicklas |
else |
4317 |
23 Jan 17 |
nicklas |
128 |
{ |
4317 |
23 Jan 17 |
nicklas |
if (jobAgent.isShared) |
4317 |
23 Jan 17 |
nicklas |
130 |
{ |
4317 |
23 Jan 17 |
nicklas |
html += '<span class="icon link shared-item" title="Set access permissions" data-item-type="JOBAGENT" data-item-id="'+jobAgent.id+'">'; |
4317 |
23 Jan 17 |
nicklas |
html += '<img src="../../images/shared.png"></span> '; |
4317 |
23 Jan 17 |
nicklas |
133 |
} |
4317 |
23 Jan 17 |
nicklas |
html += '<span class="link linked-item" title="View/edit this job agent" data-item-type="JOBAGENT" data-item-id="'+jobAgent.id+'">'; |
4317 |
23 Jan 17 |
nicklas |
html += Strings.encodeTags(jobAgent.externalId)+'</span>'; |
4317 |
23 Jan 17 |
nicklas |
136 |
} |
4317 |
23 Jan 17 |
nicklas |
return html; |
4317 |
23 Jan 17 |
nicklas |
138 |
} |
4317 |
23 Jan 17 |
nicklas |
139 |
|
4315 |
23 Jan 17 |
nicklas |
return remote; |
4315 |
23 Jan 17 |
nicklas |
141 |
}(); |
4315 |
23 Jan 17 |
nicklas |
142 |
|
4315 |
23 Jan 17 |
nicklas |
Doc.onLoad(Remote.initPage); |