graphgvc.js 35 KB

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