Guest User

Untitled

a guest
May 21st, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. {
  2. "id": 116,
  3. "name": "flow",
  4. "op_start": 9,
  5. "op_start_type": "web_hook",
  6. "style": {
  7. "x": 41,
  8. "y": 35,
  9. "width": 250,
  10. "height": 250
  11. },
  12. "modules": {
  13. "web_hook": {
  14. "8": {
  15. "id": 8,
  16. "request_body": "auth",
  17. "name": "nameew",
  18. "op_success": null,
  19. "op_failure": null,
  20. "op_success_type": null,
  21. "op_failure_type": null,
  22. "style": {
  23. "x": 628,
  24. "y": 70,
  25. "width": 250,
  26. "height": 250
  27. }
  28. },
  29. "9": {
  30. "id": 9,
  31. "request_body": "auth",
  32. "name": "testontest",
  33. "op_success": 1,
  34. "op_failure": null,
  35. "op_success_type": "ring",
  36. "op_failure_type": null,
  37. "style": {
  38. "x": 438,
  39. "y": 140,
  40. "width": 250,
  41. "height": 250
  42. }
  43. }
  44. },
  45. "ring": {
  46. "1": {
  47. "id": 1,
  48. "request_body": "auth",
  49. "name": "testontest",
  50. "op_success": null,
  51. "op_failure": null,
  52. "op_success_type": null,
  53. "op_failure_type": null,
  54. "style": {
  55. "x": 438,
  56. "y": 140,
  57. "width": 250,
  58. "height": 250
  59. }
  60. }
  61. }
  62. }
  63. }
  64.  
  65. {
  66. "nodes": [
  67. {
  68. "name": "flow",
  69. "id": 116,
  70. "x": 41,
  71. "y": 35,
  72. "width": 250,
  73. "inputConnectors": [],
  74. "outputConnectors": [
  75. {
  76. "name": "op_start"
  77. }
  78. ]
  79. },
  80. {
  81. "name": "web_hook",
  82. "id": 8,
  83. "x": 628,
  84. "y": 70,
  85. "inputConnectors": [
  86. {
  87. "name": "iA"
  88. }
  89. ],
  90. "outputConnectors": [
  91. {
  92. "name": "op_success"
  93. },
  94. {
  95. "name": "op_failure"
  96. }
  97. ],
  98. "width": 250
  99. },
  100. {
  101. "name": "ring",
  102. "id": 9,
  103. "x": 438,
  104. "y": 140,
  105. "inputConnectors": [
  106. {
  107. "name": "iA"
  108. }
  109. ],
  110. "outputConnectors": [
  111. {
  112. "name": "op_success"
  113. }
  114. ],
  115. "width": 250
  116. }
  117. ],
  118. "connections": [
  119. {
  120. "source": {
  121. "nodeID": 116,
  122. "connectorIndex": 0
  123. },
  124. "dest": {
  125. "nodeID": 8,
  126. "connectorIndex": 0
  127. }
  128. },
  129. {
  130. "source": {
  131. "nodeID": 8,
  132. "connectorIndex": 0
  133. },
  134. "dest": {
  135. "nodeID": 9,
  136. "connectorIndex": 0
  137. }
  138. }
  139. ]
  140. }
  141.  
  142. var resData = response.data; // input json is inside response.data
  143. // Creating first fixed node
  144. var newDefinition = {
  145. "nodes": [
  146. {
  147. "name": "flow",
  148. "id": resData.id,
  149. "x": resData.x,
  150. "y": resData.y,
  151. "width": resData.width,
  152. "inputConnectors": [],
  153. "outputConnectors": [
  154. {
  155. "name": "op_start"
  156. }
  157. ]
  158. }
  159. ],
  160. "connections": []
  161. };
  162.  
  163. // Getting the first connected node
  164. var nextType = resData.op_start_type;
  165. var nextId = resData.op_start;
  166. var next = resData.modules[nextType][nextId];
  167.  
  168. newDefinition.nodes.push({
  169. "name": next.name,
  170. "id": next.id,
  171. "x": next.style.x,
  172. "y": next.style.y,
  173. "width": next.style.width,
  174. "inputConnectors": [
  175. {
  176. name: ''
  177. }
  178. ],
  179. "outputConnectors": [
  180. {
  181. "name": "op_start"
  182. }
  183. ]
  184. });
Add Comment
Please, Sign In to add comment