graphgvc.js 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. /*##############################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ############################################################################## */
  17. /*
  18. *! global vars
  19. */
  20. var isRoxieGraph = false;
  21. var isEclWatchGraph = false;
  22. var isWsEclGraph = false;
  23. var isWsRoxieQueryGraph = false;
  24. var resultsoffset = 100;
  25. var OffsetHeight = 90;
  26. var gotosubgraph = '0';
  27. var gotovertex = '0';
  28. var currentgraphnode = '';
  29. var currentgraph = '';
  30. var statsWnd = null;
  31. var timingsWnd = null;
  32. var reloading = false;
  33. var reloadThisGraph = true;
  34. var gt = null;
  35. var wuinfoRequest = null;
  36. var graphRequest = null;
  37. var wseclGraphXml = null;
  38. var subgraphOnly = false;
  39. var subgraphId = 0;
  40. var havesubgraphtimings = '1';
  41. var espUri = null;
  42. function go(url)
  43. {
  44. document.location.href=url;
  45. }
  46. function pluginLHS() {
  47. return document.getElementById('pluginLHS');
  48. }
  49. function pluginRHS() {
  50. return document.getElementById('pluginRHS');
  51. }
  52. // Events
  53. function addEvent(obj, name, func) {
  54. if (window.addEventListener) {
  55. obj.addEventListener(name, func, false);
  56. } else {
  57. obj.attachEvent("on" + name, func);
  58. }
  59. }
  60. function layoutFinished() {
  61. pluginLHS().setMessage('');
  62. pluginLHS().centerOnItem(0, true);
  63. }
  64. function layoutFinishedRHS() {
  65. pluginRHS().setMessage('');
  66. pluginRHS().centerOnItem(1, true);
  67. }
  68. function mouseDoubleClick(item) {
  69. pluginLHS().centerOnItem(item, true);
  70. }
  71. function centerOn(item) {
  72. pluginLHS().centerOnItem(item, false);
  73. }
  74. function selectionChanged(items) {
  75. DisplaySelectedProperties(items);
  76. }
  77. function selectionChangedRHS(items) {
  78. var selection = pluginRHS().getSelectionAsGlobalID();
  79. pluginLHS().setSelectedAsGlobalID(selection);
  80. DisplaySelectedProperties(pluginLHS().getSelection());
  81. var selectionLHS = pluginLHS().getSelection();
  82. if (selectionLHS.length > 0)
  83. pluginLHS().centerOnItem(selectionLHS[0], true);
  84. }
  85. function DisplaySelectedProperties(items) {
  86. pluginRHS().setMessage("Loading Data...");
  87. pluginRHS().loadXGMML(pluginLHS().getLocalisedXGMML(items));
  88. pluginRHS().setMessage("Performing Layout...");
  89. var selection = pluginLHS().getSelectionAsGlobalID();
  90. pluginRHS().setSelectedAsGlobalID(selection);
  91. pluginRHS().startLayout("dot");
  92. var propsText = '';
  93. for (var i = 0; i < items.length; ++i) {
  94. var props = pluginLHS().getProperties(items[i]);
  95. propsText += '<table border="1">';
  96. propsText += '<tr><td colspan="2" align="center">';
  97. propsText += '<input type="button" style="cursor:hand;" onclick="javascript:centerOn(' + items[i] + ')" value="' + props['id'] + '" />'
  98. propsText += '</td></tr>';
  99. for (var key in props) {
  100. propsText += '<tr>';
  101. propsText += '<td>' + key + '</td><td>' + props[key] + '</td>';
  102. propsText += '</tr>';
  103. }
  104. propsText += '</table>';
  105. }
  106. document.getElementById('props').innerHTML = propsText;
  107. }
  108. function loadXGMML() {
  109. pluginLHS().setMessage("Loading Data...");
  110. pluginLHS().loadXGMML(document.getElementById('TextXGMML').value);
  111. pluginLHS().setMessage("Performing Layout...");
  112. pluginLHS().startLayout("dot");
  113. }
  114. function mergeXGMML() {
  115. pluginLHS().setMessage("Merging Data...");
  116. pluginLHS().mergeXGMML(document.getElementById('TextXGMML').value);
  117. pluginLHS().setMessage("Performing Layout...");
  118. pluginLHS().startLayout("dot");
  119. }
  120. /******************************************************************/
  121. function layoutFinished() {
  122. if (!reloading) {
  123. pluginLHS().setMessage('');
  124. pluginLHS().centerOnItem(0, true);
  125. if (window.graphloaded != '1') {
  126. if (gotosubgraph != '0') {
  127. selectSubGraph(gotosubgraph);
  128. gotosubgraph = '0';
  129. }
  130. else {
  131. if (gotovertex != '0') {
  132. selectVertex(gotovertex);
  133. gotovertex = '0';
  134. }
  135. else {
  136. graphloaded = '1';
  137. }
  138. }
  139. }
  140. }
  141. hideElement('loadingMsg');
  142. }
  143. function scaled(newScale) {
  144. slider.setValue(newScale);
  145. }
  146. function scaled2(newScale) {
  147. slider2.setValue(newScale);
  148. }
  149. var oldScale;
  150. function setScale(newScale) {
  151. oldScale = pluginLHS().setScale(newScale);
  152. }
  153. var oldScale;
  154. function setScaleRHS(newScale) {
  155. oldScale = pluginRHS().setScale(newScale);
  156. }
  157. function onUnload()
  158. {
  159. try {
  160. if (statsWnd)
  161. {
  162. statsWnd.close();
  163. }
  164. if (timingsWnd)
  165. {
  166. timingsWnd.close();
  167. }
  168. }
  169. catch (e)
  170. {
  171. }
  172. }
  173. var GraphCtlCreated = false;
  174. function pause_resume()
  175. {
  176. if (isrunning == '1')
  177. {
  178. if (gt == null)
  179. {
  180. gt = setTimeout("reloadGraph()", 500);
  181. }
  182. else
  183. {
  184. clearTimeout(gt)
  185. gt = null;
  186. }
  187. }
  188. }
  189. function open_new_window(popupId)
  190. {
  191. showNodeOrEdgeDetails(popupId, graphName, wuid);
  192. }
  193. function checkVersion() {
  194. var verDiv = document.getElementById('install_div');
  195. if (verDiv) {
  196. try {
  197. var curVersion = pluginLHS().version;
  198. if (curVersion == null) {
  199. alert("Graph Control Needs to be installed to visualize activity graphs.");
  200. document.location = '/WsRoxieQuery/BrowseResources';
  201. return false;
  202. }
  203. document.getElementById('current_version').innerHTML = curVersion;
  204. if (curVersion < 20110523) {
  205. showElement('install_div');
  206. }
  207. }
  208. catch(e) {
  209. showElement('no_control_msg');
  210. showElement('install_div');
  211. return false;
  212. }
  213. }
  214. return true;
  215. }
  216. function update_details() {
  217. resize();
  218. if (!isWsEclGraph)
  219. {
  220. showElement('Stats');
  221. }
  222. if (isEclWatchGraph && havesubgraphtimings == '1')
  223. {
  224. showElement('Timings');
  225. }
  226. showElement('findNodeBlock');
  227. showElement('autoSpan');
  228. if (isrunning != '1' && forceFinalCountRefresh == false)
  229. {
  230. hideElement('autoSpan');
  231. isrunningsave = '0';
  232. hideElement('SelectVertex');
  233. return;
  234. }
  235. if (currentgraphnode != '')
  236. {
  237. var obj = document.getElementById('CurrentNode');
  238. if (obj)
  239. {
  240. obj.title = 'Executing subgraph ' + currentgraphnode + ' in ' + currentgraph;
  241. obj.innerHTML = 'Goto executing (' + currentgraphnode + ')';
  242. }
  243. showElement('SelectVertex');
  244. }
  245. showElement('autoSpan');
  246. }
  247. function resize() {
  248. var gvcheight;
  249. var graphwidth;
  250. if (document.body) {
  251. gvcheight = document.body.clientHeight - OffsetHeight - 100;
  252. graphwidth = document.body.clientWidth - 300;
  253. } else {
  254. gvcheight = document.height - OffsetHeight - 100;
  255. graphwidth = document.width - 300;
  256. }
  257. document.getElementById('pluginLHS').style.height = gvcheight;
  258. document.getElementById('pluginRHS').style.height = "360px";
  259. }
  260. function test()
  261. {
  262. alert('test');
  263. }
  264. function selectGraphSubGraph(GraphNameToSelect, VertexIdToSelect)
  265. {
  266. if (graphName.substring(5) == GraphNameToSelect)
  267. {
  268. selectSubGraph(VertexIdToSelect);
  269. }
  270. else
  271. {
  272. gotosubgraph = VertexIdToSelect;
  273. selectGraph(GraphNameToSelect);
  274. }
  275. }
  276. function selectSubGraph(VertexId) {
  277. pluginLHS().centerOnItem(pluginLHS().getItem(VertexId), true);
  278. }
  279. function findGraphVertex(searchstring) {
  280. if (searchstring == 'jo debug')
  281. {
  282. showElement('xml_xgmml');
  283. return;
  284. }
  285. if (searchstring.toString().length == 0)
  286. {
  287. return;
  288. }
  289. resetFind();
  290. document.getElementById('findgvcId').value = searchstring;
  291. var ivs_test = null;
  292. var found = pluginLHS().find(searchstring);
  293. pluginLHS().setSelected(found);
  294. DisplaySelectedProperties(found);
  295. document.getElementById('resetFindBtn').disabled = false;
  296. }
  297. function resetFind() {
  298. var props = document.getElementById('props');
  299. props.innerHTML = '';
  300. document.getElementById('findgvcId').value = '';
  301. }
  302. var Timer;
  303. function addGraphElement(GraphNode, GraphState, GraphLabel) {
  304. var ni = document.getElementById('wugraphs');
  305. var graphelementname = GraphNode.substring(5);
  306. var thisGraphLabel = GraphLabel.length < 1 ? '' : GraphLabel;
  307. var opt = new Option(graphelementname + ' - ' + thisGraphLabel, graphelementname);
  308. ni.options[ni.options.length] = opt;
  309. if (graphelementname == graphName.substring(5)) {
  310. ni.selectedIndex = graphelementname -1;
  311. }
  312. if (!GraphState || GraphState == 0) {
  313. opt.style.background = 'lightgrey';
  314. opt.title = thisGraphLabel;
  315. }
  316. if (GraphState == 3) {
  317. opt.style.background = '#FF9999';
  318. opt.title = thisGraphLabel + ' (Failed)';
  319. }
  320. if (GraphState == 1) {
  321. opt.style.background = 'white';
  322. opt.title = thisGraphLabel + ' (Completed)';
  323. }
  324. if (GraphState == 2) {
  325. opt.style.background = 'lightgreen';
  326. opt.title = thisGraphLabel + ' (Running)';
  327. }
  328. }
  329. function setElementHtml(ElementId, ElementText)
  330. {
  331. obj = document.getElementById(ElementId);
  332. if (obj)
  333. {
  334. obj.innerHTML = ElementText;
  335. }
  336. }
  337. function setElementText(ElementId, ElementText)
  338. {
  339. obj = document.getElementById(ElementId);
  340. if (obj)
  341. {
  342. obj.innerHTML = ElementText;
  343. }
  344. }
  345. function hideElement(ElementId)
  346. {
  347. obj = document.getElementById(ElementId);
  348. if (obj)
  349. {
  350. obj.style.display = 'none';
  351. obj.style.visibility = 'hidden';
  352. }
  353. }
  354. function showElement(ElementId)
  355. {
  356. obj = document.getElementById(ElementId);
  357. if (obj)
  358. {
  359. obj.style.display = 'block';
  360. obj.style.visibility = 'visible';
  361. }
  362. }
  363. function removeElements(ParentId)
  364. {
  365. var ctrl = document.getElementById(ParentId);
  366. while (ctrl.childNodes[0])
  367. {
  368. ctrl.removeChild(ctrl.childNodes[0]);
  369. }
  370. }
  371. function setStateDescription()
  372. {
  373. var WUStates=new Array("StateUnknown","Compiled","Running","Completed","Failed","Archived","Aborting","Aborted","Blocked","Submitted","Scheduled","Compiling","Wait","UploadingFiles");
  374. setElementHtml('state', '<b>Status:</b>&nbsp;' + WUStates[state]);
  375. }
  376. function checkFindEnter() {
  377. if (window.event && window.event.keyCode == 13) {
  378. findGraphVertex(document.getElementById('findgvcId').value);
  379. }
  380. return !(window.event && window.event.keyCode == 13);
  381. }
  382. function checkFindEclEnter() {
  383. if (window.event && window.event.keyCode == 13) {
  384. findEcl(document.getElementById('gvcECL').value);
  385. }
  386. return !(window.event && window.event.keyCode == 13);
  387. }
  388. function selectGraphVertex(GraphToSelect, VertextToSelect)
  389. {
  390. if (graphName.substring(5) == GraphToSelect)
  391. {
  392. selectVertex(VertextToSelect);
  393. }
  394. else
  395. {
  396. gotovertex = VertextToSelect;
  397. initfind = true;
  398. selectGraph(GraphToSelect);
  399. }
  400. }
  401. function selectVertex(TargetVertex) {
  402. var FoundVertex = String(TargetVertex);
  403. pluginLHS().centerOnItem(pluginLHS().getItem(FoundVertex), true);
  404. }
  405. var forceFinalCountRefresh = true;
  406. function reloadGraph()
  407. {
  408. if (isrunning == '1' || forceFinalCountRefresh)
  409. {
  410. if (document.getElementById('auto').checked)
  411. {
  412. reloading = true;
  413. sendWuInfoRequest();
  414. if (isrunning != '1') {
  415. forceFinalCountRefresh = false;
  416. }
  417. }
  418. }
  419. }
  420. function loadGraphs() {
  421. removeElements('wugraphs');
  422. if (graphsJson != null)
  423. {
  424. try {
  425. addGraphElement(graphsJson.GraphNames.Item, 1, '');
  426. }
  427. catch (e) {
  428. for (var n = 0; n < 400; n++) {
  429. if (typeof (graphsJson.GraphNames.Item[n]) != "undefined") {
  430. addGraphElement(graphsJson.GraphNames.Item[n], 1, '');
  431. }
  432. else {
  433. break;
  434. }
  435. }
  436. }
  437. }
  438. }
  439. function translateWuCompletion(WuStateId)
  440. {
  441. switch(WuStateId)
  442. {
  443. case '4':
  444. case '7':
  445. return 3;
  446. case '3':
  447. return 2;
  448. case '2':
  449. return 1;
  450. case '8':
  451. return 0;
  452. }
  453. return 0;
  454. }
  455. function loadXGMMLGraph(xgmmlResponse) {
  456. var xgmmlStr = xgmmlResponse;
  457. var i = 0;
  458. var j = 0;
  459. if (xgmmlStr.indexOf('/Exception') > -1) {
  460. i = xgmmlStr.indexOf('<Message>');
  461. if (i > -1) {
  462. j = xgmmlStr.indexOf('</Message>', i);
  463. if (j > -1) {
  464. alert(xgmmlStr.substring(i + 9, j));
  465. }
  466. }
  467. hideElement('loadingMsg');
  468. return;
  469. }
  470. i = xgmmlStr.indexOf('<Name>' + graphName + '</Name');
  471. if (i > -1) {
  472. i = xgmmlStr.indexOf('<Graph>', i);
  473. j = xgmmlStr.indexOf('</Graph>', i);
  474. xgmmlStr = '&lt;graphxgmml&gt;' + xgmmlResponse.substring(i + 7, j - 1) + '&lt;/graphxgmml&gt;';
  475. document.getElementById('xml_xgmml').innerHTML = xgmmlStr;
  476. }
  477. else {
  478. i = xgmmlStr.indexOf('<TheGraph>');
  479. if (i > -1) {
  480. var k = xgmmlStr.indexOf('<GraphNames>');
  481. if (k > -1) {
  482. var l = xgmmlStr.indexOf('</GraphNames>', k);
  483. if (l > -1) {
  484. var xotree = new XML.ObjTree();
  485. graphsJson = xotree.parseXML(xgmmlStr.substring(k, l + 13));
  486. xotree = null;
  487. //graphsJson = xml2json.parser(xgmmlStr.substring(k, l+13));
  488. }
  489. }
  490. j = xgmmlStr.indexOf('</TheGraph>');
  491. xgmmlStr = '&lt;graphxgmml&gt;' + xgmmlResponse.substring(i + 10, j) + '&lt;/graphxgmml&gt;';
  492. document.getElementById('xml_xgmml').innerHTML = xgmmlStr;
  493. xgmmlStr = getInnerText(document.getElementById('xml_xgmml'));
  494. i = xgmmlStr.indexOf('<xgmml>');
  495. if (i > -1) {
  496. j = xgmmlStr.indexOf('</xgmml>');
  497. document.getElementById('xml_xgmml').innerHTML = '&lt;graphxgmml&gt;' + xgmmlStr.substring(i + 7, j) + '&lt;/graphxgmml&gt;';
  498. }
  499. }
  500. }
  501. if (!suppressGvcControlLoad) {
  502. if (reloading) {
  503. var xgmmldecoded = getInnerText(document.getElementById('xml_xgmml'));
  504. pluginLHS().mergeXGMML(xgmmldecoded);
  505. //pluginLHS().startLayout("dot");
  506. pluginRHS().mergeXGMML(pluginLHS().getLocalisedXGMML(pluginLHS().getSelection()));
  507. reloading = false;
  508. hideElement('loadingMsg');
  509. }
  510. else {
  511. var xgmmldecoded = getInnerText(document.getElementById('xml_xgmml'));
  512. pluginLHS().loadXGMML(xgmmldecoded);
  513. pluginLHS().setMessage("Performing Layout...");
  514. pluginLHS().startLayout("dot");
  515. }
  516. }
  517. if (isrunning == '1' || (isrunning != '1' && forceFinalCountRefresh)) {
  518. if (graphloaded != '1') {
  519. document.getElementById('auto').checked = true;
  520. }
  521. if (gt != null) {
  522. clearTimeout(gt);
  523. }
  524. gt = setTimeout("reloadGraph()", 8000);
  525. }
  526. update_details();
  527. if (wuinfoJson == null) {
  528. loadGraphs();
  529. }
  530. return true;
  531. }
  532. function findEcl(NodeId) {
  533. var ecltextarea = document.getElementById('gvcECLCode');
  534. if (ecltextarea) {
  535. var xgmmldecoded = getInnerText(document.getElementById('xml_xgmml'));
  536. var i = xgmmldecoded.indexOf('node id="' + NodeId + '"');
  537. if (i > -1) {
  538. var Label = '';
  539. var a = xgmmldecoded.indexOf('label="', i);
  540. if (a > -1) {
  541. var b = xgmmldecoded.indexOf('">', a);
  542. if (b) {
  543. Label = xgmmldecoded.substring(a + 7, b).replace(/&apos;/g, "'");
  544. }
  545. }
  546. var j = xgmmldecoded.indexOf('ecl" value="', i);
  547. if (j > -1) {
  548. var k = xgmmldecoded.indexOf('/>', j);
  549. if (k > -1) {
  550. ecltextarea.innerHTML = '<b>' + Label + '</b>: ' + xgmmldecoded.substring(j + 12, k - 1).replace(/&apos;/g, "'");
  551. var eclrow = document.getElementById('eclrow');
  552. eclrow.style.display = 'block';
  553. eclrow.style.visibility = 'visible';
  554. return;
  555. }
  556. }
  557. }
  558. }
  559. ecltextarea.innerHTML = 'ECL for Activity ' + NodeId + ' not found.';
  560. }
  561. function getInnerText(elt) {
  562. if (isFF) {
  563. return elt.textContent;
  564. }
  565. else {
  566. return elt.innerText;
  567. }
  568. }
  569. var wuinfoJson = null;
  570. function clearPage() {
  571. if (reloading)
  572. {
  573. return;
  574. }
  575. var xgmml = document.getElementById('xml_xgmml');
  576. if (xgmml) {
  577. xgmml.innerHTML = '';
  578. }
  579. pluginLHS().clear();
  580. pluginRHS().clear();
  581. }
  582. function loadWuInfo(xmlResponse)
  583. {
  584. reloadThisGraph = true;
  585. if (graphloaded == '1' && isrunning == '1' && currentgraph != graphName)
  586. {
  587. reloadThisGraph = false;
  588. }
  589. var k = xmlResponse.indexOf('<WUInfoResponse');
  590. if (k > -1)
  591. {
  592. var l = xmlResponse.indexOf('</WUInfoResponse>', k);
  593. if (l > -1)
  594. {
  595. var xotree = new XML.ObjTree();
  596. wuinfoJson = xotree.parseXML(xmlResponse.substring(k, l+17));
  597. xotree = null;
  598. //wuinfoJson = xml2json.parser(xmlResponse.substring(k, l+17));
  599. state = wuinfoJson.WUInfoResponse.Workunit.State;
  600. isrunning = '0';
  601. if (state == 'running')
  602. {
  603. isrunning = '1';
  604. }
  605. stateId = translateWuCompletion(wuinfoJson.WUInfoResponse.Workunit.StateID);
  606. havesubgraphtimings = wuinfoJson.WUInfoResponse.Workunit.HaveSubGraphTimings;
  607. currentgraph = '';
  608. currentgraphnode = '';
  609. removeElements('wugraphs');
  610. try
  611. {
  612. var label = '';
  613. try
  614. {
  615. label = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Label;
  616. if (!label)
  617. {
  618. label = '';
  619. }
  620. }
  621. catch(e)
  622. {
  623. }
  624. try
  625. {
  626. if (wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Running == '1')
  627. {
  628. currentgraph = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Name;
  629. currentgraphnode = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.RunningId;
  630. }
  631. }
  632. catch(e)
  633. {
  634. }
  635. var graphstate = 0;
  636. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Failed != 'undefined' && wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Failed == '1')
  637. {
  638. graphstate = 3;
  639. }
  640. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Complete != 'undefined' && wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Complete == '1')
  641. {
  642. graphstate = 1;
  643. }
  644. addGraphElement(wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Name, graphstate, label);
  645. }
  646. catch(e) {
  647. for (var n = 0; n < 400; n++)
  648. {
  649. try
  650. {
  651. var label = '';
  652. try
  653. {
  654. label = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Label;
  655. if (!label)
  656. {
  657. label = '';
  658. }
  659. }
  660. catch(e)
  661. {
  662. }
  663. try
  664. {
  665. if (wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Running == '1')
  666. {
  667. currentgraph = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Name;
  668. currentgraphnode = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].RunningId;
  669. }
  670. }
  671. catch(e)
  672. {
  673. }
  674. var graphstate = '0';
  675. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Failed != 'undefined')
  676. {
  677. graphstate = 3;
  678. }
  679. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Complete != 'undefined')
  680. {
  681. graphstate = 1;
  682. }
  683. addGraphElement(wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Name, graphstate, label);
  684. }
  685. catch(e)
  686. {
  687. break;
  688. }
  689. }
  690. }
  691. displayWsWorkunitsDetails();
  692. update_details();
  693. }
  694. }
  695. return;
  696. }
  697. function getEspAddressAndPort(Url)
  698. {
  699. espUri = parseUri(Url);
  700. var s = espUri.source.substring(0, espUri.source.length - espUri.relative.length);
  701. return s;
  702. }
  703. function parseUri (str) {
  704. var o = parseUri.options,
  705. m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
  706. uri = {},
  707. i = 14;
  708. while (i--) uri[o.key[i]] = m[i] || "";
  709. uri[o.q.name] = {};
  710. uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
  711. if ($1) uri[o.q.name][$1] = $2;
  712. });
  713. return uri;
  714. };
  715. parseUri.options = {
  716. strictMode: false,
  717. key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
  718. q: {
  719. name: "queryKey",
  720. parser: /(?:^|&)([^&=]*)=?([^&]*)/g
  721. },
  722. parser: {
  723. strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
  724. loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
  725. }
  726. };
  727. function getUrlParam( Url, Param)
  728. {
  729. Param = Param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  730. Url = Url.replace(/%3F/g, '?');
  731. Url = Url.replace(/%3D/g, '=');
  732. Url = Url.replace(/%26/g, '&');
  733. var regexS = "[\\?&]"+Param+"=([^&#]*)";
  734. var regex = new RegExp( regexS );
  735. var results = regex.exec( Url );
  736. if (results == null)
  737. {
  738. return "";
  739. }
  740. return results[1];
  741. }
  742. function getWsWorkunitsDetails(Url)
  743. {
  744. wuid = getUrlParam(Url, 'Wuid');
  745. if (wuid.length < 1)
  746. {
  747. wuid = getUrlParam(Url, 'Name');
  748. }
  749. graphName = getUrlParam(Url, 'GraphName');
  750. if (graphName.length < 1)
  751. {
  752. graphName = getUrlParam(Url, 'Name');
  753. }
  754. displayWsWorkunitsDetails();
  755. }
  756. function displayWsWorkunitsDetails()
  757. {
  758. var description = '<b>Wuid:</b>&#160;<a href="/WsWorkunits/WUInfo?Wuid=' + wuid + '">' + wuid + '</a>&#160;<b>Graph:</b>&#160;' + graphName + '&#160;<b>State:</b>&#160;' + state;
  759. if (subgraphOnly && subgraphId != '0')
  760. {
  761. description = description + '&#160;<b>Subgraph:</b>&#160;' + subgraphId;
  762. }
  763. var queryName = document.getElementById('WuidQueryName');
  764. if (queryName) {
  765. queryName.innerHTML = description;
  766. }
  767. }
  768. function getRoxieConfigDetails(Url)
  769. {
  770. wuid = getUrlParam(Url, 'QueryName');
  771. if (wuid.length < 1)
  772. {
  773. wuid = getUrlParam(Url, 'Name');
  774. }
  775. graphName = 'graph1';
  776. displayRoxieConfigDetails();
  777. }
  778. function getWsRoxieQueryDetails(Url) {
  779. wuid = getUrlParam(Url, 'QueryName');
  780. if (wuid.length < 1) {
  781. wuid = getUrlParam(Url, 'Name');
  782. }
  783. graphName = 'graph1';
  784. displayRoxieConfigDetails();
  785. }
  786. function displayRoxieConfigDetails() {
  787. var queryName = document.getElementById('WuidQueryName');
  788. if (queryName) {
  789. queryName.innerHTML = '<b>Query:</b>&#160;' + wuid + '&#160;<b>Graph:</b>&#160;' + graphName;
  790. }
  791. }
  792. function getGraph(Url) {
  793. isRoxieGraph = false;
  794. isEclWatchGraph = false;
  795. isWsRoxieQueryGraph = false;
  796. requestSourceUrl = '';
  797. requestSOAPAction = '';
  798. wuinfoJson = null;
  799. espAddressAndPort = getEspAddressAndPort(Url);
  800. if (Url.toLowerCase().indexOf('ws_roxieconfig') > -1)
  801. {
  802. isRoxieGraph = true;
  803. forceFinalCountRefresh = false;
  804. hideElement('autoSpan');
  805. getRoxieConfigDetails(Url);
  806. requestEnvelope = getRoxieConfigRequestEnvelope(wuid, graphName);
  807. requestSourceUrl = espAddressAndPort + '/ws_roxieconfig/ShowGVCGraph';
  808. requestSOAPAction = 'ws_roxieconfig/ShowGVCGraph';
  809. }
  810. if (Url.toLowerCase().indexOf('wsroxiequery') > -1) {
  811. isWsRoxieQueryGraph = true;
  812. forceFinalCountRefresh = false;
  813. hideElement('autoSpan');
  814. getWsRoxieQueryDetails(Url);
  815. requestEnvelope = getWsRoxieQueryRequestEnvelope(wuid, graphName, cluster);
  816. requestSourceUrl = espAddressAndPort + '/WsRoxieQuery/ShowGVCGraph';
  817. requestSOAPAction = 'WsRoxieQuery/ShowGVCGraph';
  818. }
  819. if (Url.toLowerCase().indexOf('wsworkunits') > -1)
  820. {
  821. requestSOAPAction = 'WsWorkunits/WUGetGraph?ver_=1.21';
  822. isEclWatchGraph = true;
  823. getWsWorkunitsDetails(Url);
  824. setWuInfo();
  825. sendWuInfoRequest();
  826. return;
  827. }
  828. sendGraphRequest();
  829. }
  830. function setWuInfo()
  831. {
  832. requestWuInfoEnvelope = getWuInfoRequestEnvelope(wuid);
  833. requestWuInfoSourceUrl = espAddressAndPort + '/WsWorkunits/WUInfo?ver_=1.19';
  834. }
  835. function sendGraphRequest()
  836. {
  837. if (!reloading) {
  838. window.graphloaded = '0';
  839. subgraphOnly = false;
  840. subgraphId = '0';
  841. setScale(100);
  842. clearPage();
  843. pluginLHS().setMessage("Loading Data...");
  844. }
  845. if (graphRequest != null)
  846. {
  847. graphRequest.abort();
  848. graphRequest = null;
  849. }
  850. showElement('loadingMsg');
  851. //window.clipboardData.setData('Text', requestEnvelope);
  852. var connectionCallback = {
  853. success: function(o) {
  854. var response = o.responseText;
  855. suppressGvcControlLoad = document.getElementById('xgmmlonly').checked;
  856. loadXGMMLGraph(response);
  857. },
  858. failure: function(o) {
  859. alert('Failure:' + o.statusText);
  860. }
  861. };
  862. YAHOO.util.Connect.initHeader("SOAPAction", requestSOAPAction);
  863. YAHOO.util.Connect.initHeader("Content-Type", "text/xml");
  864. YAHOO.util.Connect._use_default_post_header = false;
  865. var getXML = YAHOO.util.Connect.asyncRequest("POST",
  866. "/" + requestSOAPAction,
  867. connectionCallback, requestEnvelope);
  868. }
  869. function sendWuInfoRequest() {
  870. showElement('loadingMsg');
  871. if (gt != null)
  872. {
  873. clearTimeout(gt);
  874. gt = null;
  875. }
  876. // abort requests if there are any.
  877. if (wuinfoRequest != null)
  878. {
  879. wuinfoRequest.abort();
  880. wuinfoRequest = null;
  881. }
  882. // send request.
  883. requestWuInfoSOAPAction = 'WsWorkunits/WUInfo?ver_=1.19';
  884. var connectionCallback = {
  885. success: function(o) {
  886. var response = o.responseText;
  887. loadWuInfo(response);
  888. if (reloadThisGraph) {
  889. requestEnvelope = getWsWorkunitsRequestEnvelope(wuid, graphName, subgraphOnly ? subgraphId : '');
  890. requestSourceUrl = espAddressAndPort + '/WsWorkunits/WUGetGraph';
  891. if (checkVersion()) {
  892. sendGraphRequest();
  893. }
  894. }
  895. else {
  896. gt = setTimeout("reloadGraph()", 8000);
  897. hideElement('loadingMsg');
  898. }
  899. },
  900. failure: function(o) {
  901. alert('Failure:' + o.statusText);
  902. }
  903. };
  904. var postBody = requestWuInfoEnvelope;
  905. YAHOO.util.Connect.initHeader("SOAPAction", requestWuInfoSOAPAction);
  906. YAHOO.util.Connect.initHeader("Content-Type", "text/xml");
  907. YAHOO.util.Connect._use_default_post_header = false;
  908. var getXML = YAHOO.util.Connect.asyncRequest("POST",
  909. "/" + requestWuInfoSOAPAction,
  910. connectionCallback, postBody);
  911. return {};
  912. /*
  913. wuinfoRequest = new Ajax.Request(requestWuInfoSourceUrl,
  914. { method: 'post',
  915. requestHeaders: {SOAPAction: requestWuInfoSOAPAction},
  916. contentType: 'text/xml; charset=UTF-8',
  917. postBody: requestWuInfoEnvelope,
  918. onSuccess: function(transport)
  919. {
  920. var response = transport.responseText || "no response text";
  921. //alert(response);
  922. //window.clipboardData.setData('Text', response);
  923. loadWuInfo(response);
  924. if (reloadThisGraph)
  925. {
  926. requestEnvelope = getWsWorkunitsRequestEnvelope(wuid, graphName, subgraphOnly ? subgraphId : '');
  927. requestSourceUrl = espAddressAndPort + '/WsWorkunits/WUGetGraph';
  928. sendGraphRequest();
  929. }
  930. else
  931. {
  932. gt = setTimeout("reloadGraph()", 8000);
  933. hideElement('loadingMsg');
  934. }
  935. },
  936. onFailure: function()
  937. { alert('Ajax Error.') }
  938. });
  939. */
  940. }
  941. function getRoxieConfigRequestEnvelope(QueryName, GraphName)
  942. {
  943. var RoxieConfigSOAPEnvelope = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding" xmlns="http://webservices.seisint.com/ws_roxieconfig"><soap:Body><ShowGVCGraphRequest><QueryId>%QueryName%</QueryId><GraphName>%GraphName%</GraphName></ShowGVCGraphRequest></soap:Body></soap:Envelope>';
  944. RoxieConfigSOAPEnvelope = RoxieConfigSOAPEnvelope.replace('%QueryName%', QueryName);
  945. RoxieConfigSOAPEnvelope = RoxieConfigSOAPEnvelope.replace('%GraphName%', GraphName);
  946. return RoxieConfigSOAPEnvelope;
  947. }
  948. function getWsRoxieQueryRequestEnvelope(QueryName, GraphName, Cluster) {
  949. var RoxieQuerySOAPEnvelope = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding" xmlns="http://webservices.seisint.com/WsRoxieQuery"><soap:Body><ShowGVCGraphRequest><Cluster>%Cluster%</Cluster><QueryId>%QueryName%</QueryId><GraphName>%GraphName%</GraphName></ShowGVCGraphRequest></soap:Body></soap:Envelope>';
  950. RoxieQuerySOAPEnvelope = RoxieQuerySOAPEnvelope.replace('%Cluster%', Cluster);
  951. RoxieQuerySOAPEnvelope = RoxieQuerySOAPEnvelope.replace('%QueryName%', QueryName);
  952. RoxieQuerySOAPEnvelope = RoxieQuerySOAPEnvelope.replace('%GraphName%', GraphName);
  953. return RoxieQuerySOAPEnvelope;
  954. }
  955. function getWsWorkunitsRequestEnvelope(wuid, GraphName, SubGraphId)
  956. {
  957. var WsworkunitsSOAPEnvelope = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding" xmlns="http://webservices.seisint.com/WsWorkunits"><soap:Body><WUGetGraphRequest><Wuid>%wuid%</Wuid><GraphName>%GraphName%</GraphName><SubGraphId>%SubGraphId%</SubGraphId></WUGetGraphRequest></soap:Body></soap:Envelope>';
  958. WsworkunitsSOAPEnvelope = WsworkunitsSOAPEnvelope.replace('%wuid%', wuid);
  959. WsworkunitsSOAPEnvelope = WsworkunitsSOAPEnvelope.replace('%GraphName%', GraphName);
  960. WsworkunitsSOAPEnvelope = WsworkunitsSOAPEnvelope.replace('%SubGraphId%', SubGraphId);
  961. return WsworkunitsSOAPEnvelope;
  962. }
  963. function getWuInfoRequestEnvelope(wuid)
  964. {
  965. var WuInfoSOAPEnvelope = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding" xmlns="http://webservices.seisint.com/WsWorkunits"><soap:Body><WUInfoRequest><Wuid>%wuid%</Wuid><Type></Type><IncludeExceptions>0</IncludeExceptions><IncludeGraphs>1</IncludeGraphs><IncludeSourceFiles>0</IncludeSourceFiles><IncludeResults>0</IncludeResults><IncludeVariables>0</IncludeVariables><IncludeTimers>0</IncludeTimers><IncludeDebugValues>0</IncludeDebugValues><IncludeApplicationValues>0</IncludeApplicationValues><IncludeWorkflows>0</IncludeWorkflows><SuppressResultSchemas>1</SuppressResultSchemas></WUInfoRequest></soap:Body></soap:Envelope>';
  966. WuInfoSOAPEnvelope = WuInfoSOAPEnvelope.replace('%wuid%', wuid);
  967. return WuInfoSOAPEnvelope;
  968. }
  969. function showGraphStats()
  970. {
  971. var link = document.getElementById('StatsLink');
  972. link.innerHTML = 'Loading Stats...';
  973. var baseUrl = '/ws_roxieconfig/ProcessGraph?FileName=' + queryName + '/' + graphName;
  974. var url = baseUrl + '.htm&Stats=1';
  975. var wnd = window.open("about:blank", "_graphStats_",
  976. "toolbar=0,location=0,directories=0,status=0,menubar=0," +
  977. "scrollbars=1, resizable=1, width=640, height=480");
  978. link.innerHTML = 'Stats...';
  979. if (wnd)
  980. {
  981. wnd.location = url;
  982. wnd.focus();
  983. }
  984. else
  985. {
  986. alert( "Popup window could not be opened! " +
  987. "Please disable any popup killer and try again.");
  988. }
  989. }
  990. function selectGraph(GraphId) {
  991. //document.getElementById('Graph:' + graphName).style.border = '1 solid white';
  992. reloading = false;
  993. clearPage();
  994. if (gt != null)
  995. {
  996. clearTimeout(gt);
  997. }
  998. if (graphRequest != null)
  999. {
  1000. graphRequest.abort();
  1001. graphRequest = null;
  1002. }
  1003. resetFind();
  1004. window.graphloaded = '0';
  1005. graphName = 'graph' + GraphId;
  1006. var newGraphTd = document.getElementById('Graph:' + graphName);
  1007. if (newGraphTd != null)
  1008. {
  1009. newGraphTd.style.border = '1 solid black';
  1010. }
  1011. if (isRoxieGraph)
  1012. {
  1013. displayRoxieConfigDetails();
  1014. requestEnvelope = getRoxieConfigRequestEnvelope(wuid, graphName);
  1015. sendGraphRequest();
  1016. return;
  1017. }
  1018. if (isEclWatchGraph)
  1019. {
  1020. displayWsWorkunitsDetails();
  1021. sendWuInfoRequest();
  1022. }
  1023. if (isWsEclGraph)
  1024. {
  1025. loadGvcGraph(GraphId);
  1026. }
  1027. if (isWsRoxieQueryGraph) {
  1028. displayRoxieConfigDetails();
  1029. requestEnvelope = getWsRoxieQueryRequestEnvelope(wuid, graphName, cluster);
  1030. sendGraphRequest();
  1031. }
  1032. return;
  1033. }