graphgvc.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  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. pluginLHS().centerOnItem(0, true); // scale to fit.
  516. }
  517. }
  518. if (isrunning == '1' || (isrunning != '1' && forceFinalCountRefresh)) {
  519. if (graphloaded != '1') {
  520. document.getElementById('auto').checked = true;
  521. }
  522. if (gt != null) {
  523. clearTimeout(gt);
  524. }
  525. gt = setTimeout("reloadGraph()", 8000);
  526. }
  527. update_details();
  528. if (wuinfoJson == null) {
  529. loadGraphs();
  530. }
  531. return true;
  532. }
  533. function findEcl(NodeId) {
  534. var ecltextarea = document.getElementById('gvcECLCode');
  535. if (ecltextarea) {
  536. var xgmmldecoded = getInnerText(document.getElementById('xml_xgmml'));
  537. var i = xgmmldecoded.indexOf('node id="' + NodeId + '"');
  538. if (i > -1) {
  539. var Label = '';
  540. var a = xgmmldecoded.indexOf('label="', i);
  541. if (a > -1) {
  542. var b = xgmmldecoded.indexOf('">', a);
  543. if (b) {
  544. Label = xgmmldecoded.substring(a + 7, b).replace(/&apos;/g, "'");
  545. }
  546. }
  547. var j = xgmmldecoded.indexOf('ecl" value="', i);
  548. if (j > -1) {
  549. var k = xgmmldecoded.indexOf('/>', j);
  550. if (k > -1) {
  551. ecltextarea.innerHTML = '<b>' + Label + '</b>: ' + xgmmldecoded.substring(j + 12, k - 1).replace(/&apos;/g, "'");
  552. var eclrow = document.getElementById('eclrow');
  553. eclrow.style.display = 'block';
  554. eclrow.style.visibility = 'visible';
  555. return;
  556. }
  557. }
  558. }
  559. }
  560. ecltextarea.innerHTML = 'ECL for Activity ' + NodeId + ' not found.';
  561. }
  562. function getInnerText(elt) {
  563. if (isFF) {
  564. return elt.textContent;
  565. }
  566. else {
  567. return elt.innerText;
  568. }
  569. }
  570. var wuinfoJson = null;
  571. function clearPage() {
  572. if (reloading)
  573. {
  574. return;
  575. }
  576. var xgmml = document.getElementById('xml_xgmml');
  577. if (xgmml) {
  578. xgmml.innerHTML = '';
  579. }
  580. pluginLHS().clear();
  581. pluginRHS().clear();
  582. }
  583. function loadWuInfo(xmlResponse)
  584. {
  585. reloadThisGraph = true;
  586. if (graphloaded == '1' && isrunning == '1' && currentgraph != graphName)
  587. {
  588. reloadThisGraph = false;
  589. }
  590. var k = xmlResponse.indexOf('<WUInfoResponse');
  591. if (k > -1)
  592. {
  593. var l = xmlResponse.indexOf('</WUInfoResponse>', k);
  594. if (l > -1)
  595. {
  596. var xotree = new XML.ObjTree();
  597. wuinfoJson = xotree.parseXML(xmlResponse.substring(k, l+17));
  598. xotree = null;
  599. //wuinfoJson = xml2json.parser(xmlResponse.substring(k, l+17));
  600. state = wuinfoJson.WUInfoResponse.Workunit.State;
  601. isrunning = '0';
  602. if (state == 'running')
  603. {
  604. isrunning = '1';
  605. }
  606. stateId = translateWuCompletion(wuinfoJson.WUInfoResponse.Workunit.StateID);
  607. havesubgraphtimings = wuinfoJson.WUInfoResponse.Workunit.HaveSubGraphTimings;
  608. currentgraph = '';
  609. currentgraphnode = '';
  610. removeElements('wugraphs');
  611. try
  612. {
  613. var label = '';
  614. try
  615. {
  616. label = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Label;
  617. if (!label)
  618. {
  619. label = '';
  620. }
  621. }
  622. catch(e)
  623. {
  624. }
  625. try
  626. {
  627. if (wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Running == '1')
  628. {
  629. currentgraph = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Name;
  630. currentgraphnode = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.RunningId;
  631. }
  632. }
  633. catch(e)
  634. {
  635. }
  636. var graphstate = 0;
  637. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Failed != 'undefined' && wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Failed == '1')
  638. {
  639. graphstate = 3;
  640. }
  641. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Complete != 'undefined' && wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Complete == '1')
  642. {
  643. graphstate = 1;
  644. }
  645. addGraphElement(wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph.Name, graphstate, label);
  646. }
  647. catch(e) {
  648. for (var n = 0; n < 400; n++)
  649. {
  650. try
  651. {
  652. var label = '';
  653. try
  654. {
  655. label = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Label;
  656. if (!label)
  657. {
  658. label = '';
  659. }
  660. }
  661. catch(e)
  662. {
  663. }
  664. try
  665. {
  666. if (wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Running == '1')
  667. {
  668. currentgraph = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Name;
  669. currentgraphnode = wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].RunningId;
  670. }
  671. }
  672. catch(e)
  673. {
  674. }
  675. var graphstate = '0';
  676. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Failed != 'undefined')
  677. {
  678. graphstate = 3;
  679. }
  680. if (typeof wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Complete != 'undefined')
  681. {
  682. graphstate = 1;
  683. }
  684. addGraphElement(wuinfoJson.WUInfoResponse.Workunit.Graphs.ECLGraph[n].Name, graphstate, label);
  685. }
  686. catch(e)
  687. {
  688. break;
  689. }
  690. }
  691. }
  692. displayWsWorkunitsDetails();
  693. update_details();
  694. }
  695. }
  696. return;
  697. }
  698. function getEspAddressAndPort(Url)
  699. {
  700. espUri = parseUri(Url);
  701. var s = espUri.source.substring(0, espUri.source.length - espUri.relative.length);
  702. return s;
  703. }
  704. function parseUri (str) {
  705. var o = parseUri.options,
  706. m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
  707. uri = {},
  708. i = 14;
  709. while (i--) uri[o.key[i]] = m[i] || "";
  710. uri[o.q.name] = {};
  711. uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
  712. if ($1) uri[o.q.name][$1] = $2;
  713. });
  714. return uri;
  715. };
  716. parseUri.options = {
  717. strictMode: false,
  718. key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
  719. q: {
  720. name: "queryKey",
  721. parser: /(?:^|&)([^&=]*)=?([^&]*)/g
  722. },
  723. parser: {
  724. strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
  725. loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
  726. }
  727. };
  728. function getUrlParam( Url, Param)
  729. {
  730. Param = Param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  731. Url = Url.replace(/%3F/g, '?');
  732. Url = Url.replace(/%3D/g, '=');
  733. Url = Url.replace(/%26/g, '&');
  734. var regexS = "[\\?&]"+Param+"=([^&#]*)";
  735. var regex = new RegExp( regexS );
  736. var results = regex.exec( Url );
  737. if (results == null)
  738. {
  739. return "";
  740. }
  741. return results[1];
  742. }
  743. function getWsWorkunitsDetails(Url)
  744. {
  745. wuid = getUrlParam(Url, 'Wuid');
  746. if (wuid.length < 1)
  747. {
  748. wuid = getUrlParam(Url, 'Name');
  749. }
  750. graphName = getUrlParam(Url, 'GraphName');
  751. if (graphName.length < 1)
  752. {
  753. graphName = getUrlParam(Url, 'Name');
  754. }
  755. displayWsWorkunitsDetails();
  756. }
  757. function displayWsWorkunitsDetails()
  758. {
  759. 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;
  760. if (subgraphOnly && subgraphId != '0')
  761. {
  762. description = description + '&#160;<b>Subgraph:</b>&#160;' + subgraphId;
  763. }
  764. var queryName = document.getElementById('WuidQueryName');
  765. if (queryName) {
  766. queryName.innerHTML = description;
  767. }
  768. }
  769. function getRoxieConfigDetails(Url)
  770. {
  771. wuid = getUrlParam(Url, 'QueryName');
  772. if (wuid.length < 1)
  773. {
  774. wuid = getUrlParam(Url, 'Name');
  775. }
  776. graphName = 'graph1';
  777. displayRoxieConfigDetails();
  778. }
  779. function getWsRoxieQueryDetails(Url) {
  780. wuid = getUrlParam(Url, 'QueryName');
  781. if (wuid.length < 1) {
  782. wuid = getUrlParam(Url, 'Name');
  783. }
  784. graphName = 'graph1';
  785. displayRoxieConfigDetails();
  786. }
  787. function displayRoxieConfigDetails() {
  788. var queryName = document.getElementById('WuidQueryName');
  789. if (queryName) {
  790. queryName.innerHTML = '<b>Query:</b>&#160;' + wuid + '&#160;<b>Graph:</b>&#160;' + graphName;
  791. }
  792. }
  793. function getGraph(Url) {
  794. isRoxieGraph = false;
  795. isEclWatchGraph = false;
  796. isWsRoxieQueryGraph = false;
  797. requestSourceUrl = '';
  798. requestSOAPAction = '';
  799. wuinfoJson = null;
  800. espAddressAndPort = getEspAddressAndPort(Url);
  801. if (Url.toLowerCase().indexOf('ws_roxieconfig') > -1)
  802. {
  803. isRoxieGraph = true;
  804. getRoxieConfigDetails(Url);
  805. requestEnvelope = getRoxieConfigRequestEnvelope(wuid, graphName);
  806. requestSourceUrl = espAddressAndPort + '/ws_roxieconfig/ShowGVCGraph';
  807. requestSOAPAction = 'ws_roxieconfig/ShowGVCGraph';
  808. }
  809. if (Url.toLowerCase().indexOf('wsroxiequery') > -1) {
  810. isWsRoxieQueryGraph = true;
  811. getWsRoxieQueryDetails(Url);
  812. requestEnvelope = getWsRoxieQueryRequestEnvelope(wuid, graphName, cluster);
  813. requestSourceUrl = espAddressAndPort + '/WsRoxieQuery/ShowGVCGraph';
  814. requestSOAPAction = 'WsRoxieQuery/ShowGVCGraph';
  815. }
  816. if (Url.toLowerCase().indexOf('wsworkunits') > -1)
  817. {
  818. requestSOAPAction = 'WsWorkunits/WUGetGraph?ver_=1.21';
  819. isEclWatchGraph = true;
  820. getWsWorkunitsDetails(Url);
  821. setWuInfo();
  822. sendWuInfoRequest();
  823. return;
  824. }
  825. sendGraphRequest();
  826. }
  827. function setWuInfo()
  828. {
  829. requestWuInfoEnvelope = getWuInfoRequestEnvelope(wuid);
  830. requestWuInfoSourceUrl = espAddressAndPort + '/WsWorkunits/WUInfo?ver_=1.19';
  831. }
  832. function sendGraphRequest()
  833. {
  834. if (!reloading) {
  835. window.graphloaded = '0';
  836. subgraphOnly = false;
  837. subgraphId = '0';
  838. setScale(100);
  839. clearPage();
  840. pluginLHS().setMessage("Loading Data...");
  841. }
  842. if (graphRequest != null)
  843. {
  844. graphRequest.abort();
  845. graphRequest = null;
  846. }
  847. showElement('loadingMsg');
  848. //window.clipboardData.setData('Text', requestEnvelope);
  849. var connectionCallback = {
  850. success: function(o) {
  851. var response = o.responseText;
  852. suppressGvcControlLoad = document.getElementById('xgmmlonly').checked;
  853. loadXGMMLGraph(response);
  854. },
  855. failure: function(o) {
  856. alert('Failure:' + o.statusText);
  857. }
  858. };
  859. YAHOO.util.Connect.initHeader("SOAPAction", requestSOAPAction);
  860. YAHOO.util.Connect.initHeader("Content-Type", "text/xml");
  861. YAHOO.util.Connect._use_default_post_header = false;
  862. var getXML = YAHOO.util.Connect.asyncRequest("POST",
  863. "/" + requestSOAPAction,
  864. connectionCallback, requestEnvelope);
  865. }
  866. function sendWuInfoRequest() {
  867. showElement('loadingMsg');
  868. if (gt != null)
  869. {
  870. clearTimeout(gt);
  871. gt = null;
  872. }
  873. // abort requests if there are any.
  874. if (wuinfoRequest != null)
  875. {
  876. wuinfoRequest.abort();
  877. wuinfoRequest = null;
  878. }
  879. // send request.
  880. requestWuInfoSOAPAction = 'WsWorkunits/WUInfo?ver_=1.19';
  881. var connectionCallback = {
  882. success: function(o) {
  883. var response = o.responseText;
  884. loadWuInfo(response);
  885. if (reloadThisGraph) {
  886. requestEnvelope = getWsWorkunitsRequestEnvelope(wuid, graphName, subgraphOnly ? subgraphId : '');
  887. requestSourceUrl = espAddressAndPort + '/WsWorkunits/WUGetGraph';
  888. if (checkVersion()) {
  889. sendGraphRequest();
  890. }
  891. }
  892. else {
  893. gt = setTimeout("reloadGraph()", 8000);
  894. hideElement('loadingMsg');
  895. }
  896. },
  897. failure: function(o) {
  898. alert('Failure:' + o.statusText);
  899. }
  900. };
  901. var postBody = requestWuInfoEnvelope;
  902. YAHOO.util.Connect.initHeader("SOAPAction", requestWuInfoSOAPAction);
  903. YAHOO.util.Connect.initHeader("Content-Type", "text/xml");
  904. YAHOO.util.Connect._use_default_post_header = false;
  905. var getXML = YAHOO.util.Connect.asyncRequest("POST",
  906. "/" + requestWuInfoSOAPAction,
  907. connectionCallback, postBody);
  908. return {};
  909. /*
  910. wuinfoRequest = new Ajax.Request(requestWuInfoSourceUrl,
  911. { method: 'post',
  912. requestHeaders: {SOAPAction: requestWuInfoSOAPAction},
  913. contentType: 'text/xml; charset=UTF-8',
  914. postBody: requestWuInfoEnvelope,
  915. onSuccess: function(transport)
  916. {
  917. var response = transport.responseText || "no response text";
  918. //alert(response);
  919. //window.clipboardData.setData('Text', response);
  920. loadWuInfo(response);
  921. if (reloadThisGraph)
  922. {
  923. requestEnvelope = getWsWorkunitsRequestEnvelope(wuid, graphName, subgraphOnly ? subgraphId : '');
  924. requestSourceUrl = espAddressAndPort + '/WsWorkunits/WUGetGraph';
  925. sendGraphRequest();
  926. }
  927. else
  928. {
  929. gt = setTimeout("reloadGraph()", 8000);
  930. hideElement('loadingMsg');
  931. }
  932. },
  933. onFailure: function()
  934. { alert('Ajax Error.') }
  935. });
  936. */
  937. }
  938. function getRoxieConfigRequestEnvelope(QueryName, GraphName)
  939. {
  940. 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>';
  941. RoxieConfigSOAPEnvelope = RoxieConfigSOAPEnvelope.replace('%QueryName%', QueryName);
  942. RoxieConfigSOAPEnvelope = RoxieConfigSOAPEnvelope.replace('%GraphName%', GraphName);
  943. return RoxieConfigSOAPEnvelope;
  944. }
  945. function getWsRoxieQueryRequestEnvelope(QueryName, GraphName, Cluster) {
  946. 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><RoxieQueryShowGVCGraphRequest><ClusterName>%Cluster%</ClusterName><QueryName>%QueryName%</QueryName><GraphName>%GraphName%</GraphName></RoxieQueryShowGVCGraphRequest></soap:Body></soap:Envelope>';
  947. RoxieQuerySOAPEnvelope = RoxieQuerySOAPEnvelope.replace('%Cluster%', Cluster);
  948. RoxieQuerySOAPEnvelope = RoxieQuerySOAPEnvelope.replace('%QueryName%', QueryName);
  949. RoxieQuerySOAPEnvelope = RoxieQuerySOAPEnvelope.replace('%GraphName%', GraphName);
  950. return RoxieQuerySOAPEnvelope;
  951. }
  952. function getWsWorkunitsRequestEnvelope(wuid, GraphName, SubGraphId)
  953. {
  954. 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>';
  955. WsworkunitsSOAPEnvelope = WsworkunitsSOAPEnvelope.replace('%wuid%', wuid);
  956. WsworkunitsSOAPEnvelope = WsworkunitsSOAPEnvelope.replace('%GraphName%', GraphName);
  957. WsworkunitsSOAPEnvelope = WsworkunitsSOAPEnvelope.replace('%SubGraphId%', SubGraphId);
  958. return WsworkunitsSOAPEnvelope;
  959. }
  960. function getWuInfoRequestEnvelope(wuid)
  961. {
  962. 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>';
  963. WuInfoSOAPEnvelope = WuInfoSOAPEnvelope.replace('%wuid%', wuid);
  964. return WuInfoSOAPEnvelope;
  965. }
  966. function showGraphStats()
  967. {
  968. var link = document.getElementById('StatsLink');
  969. link.innerHTML = 'Loading Stats...';
  970. var baseUrl = '/ws_roxieconfig/ProcessGraph?FileName=' + queryName + '/' + graphName;
  971. var url = baseUrl + '.htm&Stats=1';
  972. var wnd = window.open("about:blank", "_graphStats_",
  973. "toolbar=0,location=0,directories=0,status=0,menubar=0," +
  974. "scrollbars=1, resizable=1, width=640, height=480");
  975. link.innerHTML = 'Stats...';
  976. if (wnd)
  977. {
  978. wnd.location = url;
  979. wnd.focus();
  980. }
  981. else
  982. {
  983. alert( "Popup window could not be opened! " +
  984. "Please disable any popup killer and try again.");
  985. }
  986. }
  987. function selectGraph(GraphId) {
  988. //document.getElementById('Graph:' + graphName).style.border = '1 solid white';
  989. reloading = false;
  990. clearPage();
  991. if (gt != null)
  992. {
  993. clearTimeout(gt);
  994. }
  995. if (graphRequest != null)
  996. {
  997. graphRequest.abort();
  998. graphRequest = null;
  999. }
  1000. resetFind();
  1001. window.graphloaded = '0';
  1002. graphName = 'graph' + GraphId;
  1003. var newGraphTd = document.getElementById('Graph:' + graphName);
  1004. if (newGraphTd != null)
  1005. {
  1006. newGraphTd.style.border = '1 solid black';
  1007. }
  1008. if (isRoxieGraph)
  1009. {
  1010. displayRoxieConfigDetails();
  1011. requestEnvelope = getRoxieConfigRequestEnvelope(wuid, graphName);
  1012. sendGraphRequest();
  1013. return;
  1014. }
  1015. if (isEclWatchGraph)
  1016. {
  1017. displayWsWorkunitsDetails();
  1018. sendWuInfoRequest();
  1019. }
  1020. if (isWsEclGraph)
  1021. {
  1022. loadGvcGraph(GraphId);
  1023. }
  1024. if (isWsRoxieQueryGraph) {
  1025. displayRoxieConfigDetails();
  1026. requestEnvelope = getWsRoxieQueryRequestEnvelope(wuid, graphName, cluster);
  1027. sendGraphRequest();
  1028. }
  1029. return;
  1030. }