graphgvc.js 34 KB

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