cpee 2.0.30 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (330) hide show
  1. checksums.yaml +4 -4
  2. data/cockpit/js/instance.js +3 -3
  3. data/cockpit/js/wfadaptor.js +2 -0
  4. data/cockpit/templates.legacy/Async.xml +12 -12
  5. data/cockpit/templates.legacy/BCO.xml +9 -11
  6. data/cockpit/templates.legacy/BCS.xml +9 -11
  7. data/cockpit/templates.legacy/Centurio.xml +7 -7
  8. data/cockpit/templates.legacy/Concurrent.xml +7 -7
  9. data/cockpit/templates.legacy/Coopis Testset.xml +7 -7
  10. data/cockpit/templates.legacy/Endpoints and Data Manipulation.xml +6 -7
  11. data/cockpit/templates.legacy/ICSOC Testset.xml +7 -7
  12. data/cockpit/templates.legacy/Infinity.xml +7 -7
  13. data/cockpit/templates.legacy/Lego Boxer.xml +13 -13
  14. data/cockpit/templates.legacy/Lego Conveyor.xml +13 -13
  15. data/cockpit/templates.legacy/Lego Crane.xml +16 -16
  16. data/cockpit/templates.legacy/Lego Ejector.xml +16 -16
  17. data/cockpit/templates.legacy/Lego Full.xml +12 -12
  18. data/cockpit/templates.legacy/Lego Liddy.xml +13 -13
  19. data/cockpit/templates.legacy/Lego Plate.xml +13 -13
  20. data/cockpit/templates.legacy/Lego Transporter.xml +14 -14
  21. data/cockpit/templates.legacy/Lego_Part_1.xml +12 -12
  22. data/cockpit/templates.legacy/LgLinear.xml +7 -10
  23. data/cockpit/templates.legacy/Linear.xml +11 -14
  24. data/cockpit/templates.legacy/Log.xml +11 -12
  25. data/cockpit/templates.legacy/Mangler 1.xml +7 -7
  26. data/cockpit/templates.legacy/Mangler 2.xml +7 -7
  27. data/cockpit/templates.legacy/Manuel Labels.xml +11 -11
  28. data/cockpit/templates.legacy/Promise.xml +30 -30
  29. data/cockpit/templates.legacy/SOPROMO Test Sonification.xml +7 -7
  30. data/cockpit/templates.legacy/Subprocess.xml +15 -15
  31. data/cockpit/templates.legacy/Syncing P34 1.xml +8 -11
  32. data/cockpit/templates.legacy/Syncing P34 2.xml +8 -11
  33. data/cockpit/templates.legacy/Syncing P34 3.xml +8 -11
  34. data/cockpit/templates.legacy/Syncing P34.xml +8 -11
  35. data/cockpit/templates.legacy/TEST - Bad Loop.xml +7 -7
  36. data/cockpit/templates.legacy/TEST - Wrong Positions.xml +7 -7
  37. data/cockpit/templates.legacy/Take_5.xml +14 -14
  38. data/cockpit/templates.legacy/Update.xml +11 -11
  39. data/cockpit/templates.legacy/Worklist Parallel.xml +17 -17
  40. data/cockpit/templates.legacy/Worklist Test CPEE.xml +14 -14
  41. data/cockpit/templates.legacy/Worklist Test.xml +14 -14
  42. data/cockpit/templates.legacy/Worklist Test2.xml +14 -14
  43. data/cockpit/templates/Coopis 2010.xml +8 -8
  44. data/cockpit/templates/IUPC arXiv:1104.3609 P34 1.xml +8 -11
  45. data/cockpit/templates/IUPC arXiv:1104.3609 P34 2.xml +8 -11
  46. data/cockpit/templates/IUPC arXiv:1104.3609 P34 3.xml +8 -11
  47. data/cockpit/templates/Track Test Local.xml +2 -2
  48. data/cockpit/templates/Track Test.xml +1 -1
  49. data/cockpit/templates/UR-VUE 2020 Manual Adjust.xml +1 -1
  50. data/cockpit/templates/UR-VUE 2020 Solution Baseline.xml +1 -1
  51. data/cockpit/templates/UR-VUE 2020 Solution NN.xml +1 -1
  52. data/cockpit/templates/UR-VUE 2020 Solution View.xml +1 -1
  53. data/cockpit/templates/UR-VUE 2020.xml +1 -1
  54. data/cockpit/templates/Worklist.xml +14 -14
  55. data/cockpit/templates/instantiate.local/Take_Sub.xml +2 -2
  56. data/cockpit/templates/instantiate/Take_Perf.xml +1 -1
  57. data/cockpit/templates/instantiate/Take_Sub.xml +2 -2
  58. data/cockpit/templates/instantiate/Take_X.xml +2 -2
  59. data/cockpit/themes/compact/rngs/start.rng +83 -0
  60. data/cockpit/themes/compact/symbols/start.svg +1 -1
  61. data/cockpit/themes/control/rngs/start.rng +83 -0
  62. data/cockpit/themes/control/symbols/start.svg +1 -1
  63. data/cockpit/themes/default/rngs/start.rng +83 -0
  64. data/cockpit/themes/default/symbols/start.svg +1 -1
  65. data/cockpit/themes/default/theme.js +1 -1
  66. data/cockpit/themes/extended/rngs/start.rng +83 -0
  67. data/cockpit/themes/extended/symbols/start.svg +1 -1
  68. data/cockpit/themes/model/symbols/start.svg +1 -1
  69. data/cockpit/themes/packed/rngs/start.rng +83 -0
  70. data/cockpit/themes/packed/symbols/start.svg +1 -1
  71. data/cockpit/themes/preset/rngs/start.rng +83 -0
  72. data/cockpit/themes/preset/symbols/start.svg +1 -1
  73. data/cockpit/themes/preset/theme.js +1 -1
  74. data/cpee.gemspec +2 -2
  75. data/lib/cpee/attributes_helper.rb +14 -0
  76. data/lib/cpee/implementation.rb +10 -8
  77. data/lib/cpee/implementation_callbacks.rb +14 -0
  78. data/lib/cpee/implementation_notifications.rb +14 -0
  79. data/lib/cpee/implementation_properties.rb +128 -24
  80. data/lib/cpee/persistence.rb +0 -27
  81. data/lib/cpee/statemachine.rb +14 -0
  82. data/lib/cpee/value_helper.rb +14 -0
  83. data/lib/properties.xml +4 -4
  84. data/lib/properties/{handlerwrapper.rng → executionhandler.rng} +2 -2
  85. data/lib/properties/properties.rng +2 -2
  86. data/lib/properties/set-properties.rng +2 -2
  87. data/lib/properties/set-some-properties.rng +2 -2
  88. data/server/{resources → executionhandlers/ruby}/backend/README.md +0 -0
  89. data/server/{resources → executionhandlers/ruby}/backend/instance.template +2 -4
  90. data/server/{resources → executionhandlers/ruby}/backend/opts.yaml +2 -2
  91. data/server/executionhandlers/ruby/backend/run +37 -0
  92. data/server/{handlerwrappers/default.rb → executionhandlers/ruby/connection.rb} +3 -3
  93. data/server/executionhandlers/ruby/controller.rb +195 -0
  94. data/server/{resources/transformation_dslx.xsl → executionhandlers/ruby/dsl_to_dslx.xsl} +53 -8
  95. data/server/executionhandlers/ruby/execution.rb +81 -0
  96. data/server/resources/properties.empty +1 -1
  97. data/server/resources/properties.init +1 -1
  98. data/server/resources/topics.xml +2 -2
  99. data/server/routing/persist.rb +3 -3
  100. data/tools/cpee +9 -3
  101. data/tools/server/cpee +1 -1
  102. data/tools/server/resources/properties.init +1 -1
  103. metadata +19 -237
  104. data/cockpit/templates.legacy/convert_cpee2.rb +0 -15
  105. data/lib/cpee/controller.rb +0 -199
  106. data/lib/cpee/transform.rb +0 -95
  107. data/server/resources/backend/instance.rb +0 -23
  108. data/server/resources/backend/run +0 -33
  109. data/server/routing/end.pid +0 -1
  110. data/server/routing/forward-events.pid +0 -1
  111. data/server/routing/forward-votes.pid +0 -1
  112. data/server/routing/persist.pid +0 -1
  113. data/server/server.pid +0 -1
  114. data/tools/test/README +0 -4
  115. data/tools/test/config.json +0 -3
  116. data/tools/test/contrib/graph_example.svg +0 -1166
  117. data/tools/test/contrib/legend.svg +0 -817
  118. data/tools/test/contrib/symbols.svg +0 -224
  119. data/tools/test/contrib/transformation1.xsl +0 -264
  120. data/tools/test/contrib/transformation2.xsl +0 -10
  121. data/tools/test/contrib/tree_example.svg +0 -788
  122. data/tools/test/css/model.css +0 -24
  123. data/tools/test/css/track.css +0 -60
  124. data/tools/test/css/ui.css +0 -214
  125. data/tools/test/css/wfadaptor.css +0 -422
  126. data/tools/test/edit.html +0 -258
  127. data/tools/test/graph.html +0 -69
  128. data/tools/test/index.html +0 -258
  129. data/tools/test/js/details.js +0 -109
  130. data/tools/test/js/instance.js +0 -1344
  131. data/tools/test/js/model.js +0 -41
  132. data/tools/test/js/parameters.js +0 -82
  133. data/tools/test/js/track.js +0 -18
  134. data/tools/test/js/ui.js +0 -104
  135. data/tools/test/js/wfadaptor.js +0 -763
  136. data/tools/test/js_libs.zip +0 -0
  137. data/tools/test/js_libs/Makefile +0 -2
  138. data/tools/test/js_libs/ansi_up.js +0 -333
  139. data/tools/test/js_libs/console.js +0 -80
  140. data/tools/test/js_libs/custommenu.css +0 -84
  141. data/tools/test/js_libs/custommenu.js +0 -104
  142. data/tools/test/js_libs/experiments1/relaxngui.css +0 -185
  143. data/tools/test/js_libs/experiments1/relaxngui.js +0 -488
  144. data/tools/test/js_libs/experiments1/rngtest9.html +0 -60
  145. data/tools/test/js_libs/experiments1/rngtest9.rng +0 -35
  146. data/tools/test/js_libs/experiments1/rngtest9.xml +0 -8
  147. data/tools/test/js_libs/jquery-2.2.4.min.js +0 -4
  148. data/tools/test/js_libs/jquery-3.2.1.min.js +0 -4
  149. data/tools/test/js_libs/jquery-3.3.1.min.js +0 -2
  150. data/tools/test/js_libs/jquery.browser.js +0 -40
  151. data/tools/test/js_libs/jquery.caret.min.js +0 -10
  152. data/tools/test/js_libs/jquery.cookie.js +0 -117
  153. data/tools/test/js_libs/jquery.min.js +0 -1
  154. data/tools/test/js_libs/jquery.svg.min.js +0 -6
  155. data/tools/test/js_libs/jquery.svgdom.min.js +0 -6
  156. data/tools/test/js_libs/markdown.min.js +0 -1
  157. data/tools/test/js_libs/parsequery.js +0 -21
  158. data/tools/test/js_libs/printf.js +0 -368
  159. data/tools/test/js_libs/relaxngui.css +0 -213
  160. data/tools/test/js_libs/relaxngui.js +0 -543
  161. data/tools/test/js_libs/strftime.min.js +0 -1
  162. data/tools/test/js_libs/tests/dataelements.html +0 -59
  163. data/tools/test/js_libs/tests/dataelements.rng +0 -8
  164. data/tools/test/js_libs/tests/dataelements.xml +0 -3
  165. data/tools/test/js_libs/tests/relaxngui.css +0 -203
  166. data/tools/test/js_libs/tests/relaxngui.js +0 -502
  167. data/tools/test/js_libs/tests/rngtest1.html +0 -66
  168. data/tools/test/js_libs/tests/rngtest1.rng +0 -147
  169. data/tools/test/js_libs/tests/rngtest1.xml +0 -13
  170. data/tools/test/js_libs/tests/rngtest2.html +0 -60
  171. data/tools/test/js_libs/tests/rngtest2.rng +0 -6
  172. data/tools/test/js_libs/tests/rngtest2.xml +0 -3
  173. data/tools/test/js_libs/tests/rngtest3.html +0 -60
  174. data/tools/test/js_libs/tests/rngtest3.rng +0 -23
  175. data/tools/test/js_libs/tests/rngtest3.xml +0 -9
  176. data/tools/test/js_libs/tests/rngtest4.html +0 -60
  177. data/tools/test/js_libs/tests/rngtest4.rng +0 -19
  178. data/tools/test/js_libs/tests/rngtest4.xml +0 -12
  179. data/tools/test/js_libs/tests/rngtest5.html +0 -60
  180. data/tools/test/js_libs/tests/rngtest5.rng +0 -75
  181. data/tools/test/js_libs/tests/rngtest5.xml +0 -40
  182. data/tools/test/js_libs/tests/rngtest6.html +0 -60
  183. data/tools/test/js_libs/tests/rngtest6.rng +0 -24
  184. data/tools/test/js_libs/tests/rngtest6.xml +0 -6
  185. data/tools/test/js_libs/tests/rngtest8.html +0 -60
  186. data/tools/test/js_libs/tests/rngtest8.rng +0 -13
  187. data/tools/test/js_libs/tests/rngtest8.xml +0 -2
  188. data/tools/test/js_libs/tests/rngtest9.html +0 -60
  189. data/tools/test/js_libs/tests/rngtest9.rng +0 -31
  190. data/tools/test/js_libs/tests/rngtest9.xml +0 -8
  191. data/tools/test/js_libs/ui.css +0 -333
  192. data/tools/test/js_libs/ui.html +0 -168
  193. data/tools/test/js_libs/ui.js +0 -177
  194. data/tools/test/js_libs/underscore.min.js +0 -27
  195. data/tools/test/js_libs/util.js +0 -81
  196. data/tools/test/js_libs/vkbeautify.0.99.00.beta.js +0 -358
  197. data/tools/test/js_libs/vkbeautify.js +0 -1
  198. data/tools/test/js_libs/webcomponents.min.js +0 -196
  199. data/tools/test/model.html +0 -192
  200. data/tools/test/rngs/attributes.rng +0 -8
  201. data/tools/test/rngs/dataelements.rng +0 -8
  202. data/tools/test/rngs/endpoints.rng +0 -8
  203. data/tools/test/templates.legacy/Async.xml +0 -46
  204. data/tools/test/templates.legacy/BCO.xml +0 -70
  205. data/tools/test/templates.legacy/BCS.xml +0 -70
  206. data/tools/test/templates.legacy/Centurio.xml +0 -75
  207. data/tools/test/templates.legacy/Concurrent.xml +0 -40
  208. data/tools/test/templates.legacy/Coopis Testset.xml +0 -76
  209. data/tools/test/templates.legacy/Endpoints and Data Manipulation.xml +0 -30
  210. data/tools/test/templates.legacy/ICSOC Testset.xml +0 -95
  211. data/tools/test/templates.legacy/Infinity.xml +0 -28
  212. data/tools/test/templates.legacy/Lego Boxer.xml +0 -31
  213. data/tools/test/templates.legacy/Lego Conveyor.xml +0 -31
  214. data/tools/test/templates.legacy/Lego Crane.xml +0 -87
  215. data/tools/test/templates.legacy/Lego Ejector.xml +0 -55
  216. data/tools/test/templates.legacy/Lego Full.xml +0 -142
  217. data/tools/test/templates.legacy/Lego Liddy.xml +0 -40
  218. data/tools/test/templates.legacy/Lego Plate.xml +0 -31
  219. data/tools/test/templates.legacy/Lego Transporter.xml +0 -43
  220. data/tools/test/templates.legacy/Lego_Part_1.xml +0 -85
  221. data/tools/test/templates.legacy/LgLinear.xml +0 -65
  222. data/tools/test/templates.legacy/Linear.xml +0 -77
  223. data/tools/test/templates.legacy/Log.xml +0 -117
  224. data/tools/test/templates.legacy/Mangler 1.xml +0 -87
  225. data/tools/test/templates.legacy/Mangler 2.xml +0 -103
  226. data/tools/test/templates.legacy/Manuel Labels.xml +0 -55
  227. data/tools/test/templates.legacy/Promise.xml +0 -275
  228. data/tools/test/templates.legacy/SOPROMO Test Sonification.xml +0 -83
  229. data/tools/test/templates.legacy/Subprocess.xml +0 -56
  230. data/tools/test/templates.legacy/Syncing P34 1.xml +0 -77
  231. data/tools/test/templates.legacy/Syncing P34 2.xml +0 -77
  232. data/tools/test/templates.legacy/Syncing P34 3.xml +0 -77
  233. data/tools/test/templates.legacy/Syncing P34.xml +0 -77
  234. data/tools/test/templates.legacy/TEST - Bad Loop.xml +0 -173
  235. data/tools/test/templates.legacy/TEST - Wrong Positions.xml +0 -174
  236. data/tools/test/templates.legacy/Take_5.xml +0 -48
  237. data/tools/test/templates.legacy/Update.xml +0 -32
  238. data/tools/test/templates.legacy/Worklist Parallel.xml +0 -104
  239. data/tools/test/templates.legacy/Worklist Test CPEE.xml +0 -40
  240. data/tools/test/templates.legacy/Worklist Test.xml +0 -42
  241. data/tools/test/templates.legacy/Worklist Test2.xml +0 -43
  242. data/tools/test/templates.legacy/convert_cpee2.rb +0 -15
  243. data/tools/test/templates.legacy/convert_preset.rb +0 -32
  244. data/tools/test/templates.legacy/testsets.xml +0 -37
  245. data/tools/test/templates.legacy/transformations.xml +0 -4
  246. data/tools/test/templates/Coopis 2010.xml +0 -76
  247. data/tools/test/templates/IUPC arXiv:1104.3609 P34 1.xml +0 -77
  248. data/tools/test/templates/IUPC arXiv:1104.3609 P34 2.xml +0 -77
  249. data/tools/test/templates/IUPC arXiv:1104.3609 P34 3.xml +0 -77
  250. data/tools/test/templates/Track Test Local.xml +0 -82
  251. data/tools/test/templates/Track Test.xml +0 -82
  252. data/tools/test/templates/UR-VUE 2020 Manual Adjust.xml +0 -182
  253. data/tools/test/templates/UR-VUE 2020 Solution Baseline.xml +0 -203
  254. data/tools/test/templates/UR-VUE 2020 Solution NN.xml +0 -197
  255. data/tools/test/templates/UR-VUE 2020 Solution View.xml +0 -151
  256. data/tools/test/templates/UR-VUE 2020.xml +0 -26
  257. data/tools/test/templates/Worklist.xml +0 -42
  258. data/tools/test/templates/instantiate.local/Take_Sub.xml +0 -59
  259. data/tools/test/templates/instantiate/Take_Perf.xml +0 -46
  260. data/tools/test/templates/instantiate/Take_Sub.xml +0 -58
  261. data/tools/test/templates/instantiate/Take_X.xml +0 -48
  262. data/tools/test/themes/compact/theme.js +0 -1285
  263. data/tools/test/themes/diana/theme.js +0 -1650
  264. data/tools/test/themes/extended/theme.js +0 -1325
  265. data/tools/test/themes/model/rngs/alternative.rng +0 -1
  266. data/tools/test/themes/model/rngs/call.rng +0 -67
  267. data/tools/test/themes/model/rngs/callmanipulate.rng +0 -72
  268. data/tools/test/themes/model/rngs/choose.rng +0 -1
  269. data/tools/test/themes/model/rngs/critical.rng +0 -1
  270. data/tools/test/themes/model/rngs/escape.rng +0 -1
  271. data/tools/test/themes/model/rngs/group.rng +0 -1
  272. data/tools/test/themes/model/rngs/loop.rng +0 -1
  273. data/tools/test/themes/model/rngs/manipulate.rng +0 -1
  274. data/tools/test/themes/model/rngs/otherwise.rng +0 -1
  275. data/tools/test/themes/model/rngs/parallel.rng +0 -1
  276. data/tools/test/themes/model/rngs/parallel_branch.rng +0 -1
  277. data/tools/test/themes/model/rngs/scripts.rng +0 -7
  278. data/tools/test/themes/model/rngs/stop.rng +0 -1
  279. data/tools/test/themes/model/rngs/terminate.rng +0 -1
  280. data/tools/test/themes/model/theme.js +0 -1268
  281. data/tools/test/themes/packed/theme.js +0 -1286
  282. data/tools/test/themes/preset/rngs/alternative.rng +0 -25
  283. data/tools/test/themes/preset/rngs/call.rng +0 -122
  284. data/tools/test/themes/preset/rngs/callmanipulate.rng +0 -145
  285. data/tools/test/themes/preset/rngs/choose.rng +0 -14
  286. data/tools/test/themes/preset/rngs/closed_loop.rng +0 -62
  287. data/tools/test/themes/preset/rngs/closed_loop_cancel.rng +0 -5
  288. data/tools/test/themes/preset/rngs/closed_loop_control.rng +0 -31
  289. data/tools/test/themes/preset/rngs/closed_loop_measuring.rng +0 -12
  290. data/tools/test/themes/preset/rngs/critical.rng +0 -5
  291. data/tools/test/themes/preset/rngs/escape.rng +0 -1
  292. data/tools/test/themes/preset/rngs/group.rng +0 -3
  293. data/tools/test/themes/preset/rngs/loop.rng +0 -22
  294. data/tools/test/themes/preset/rngs/manipulate.rng +0 -9
  295. data/tools/test/themes/preset/rngs/otherwise.rng +0 -22
  296. data/tools/test/themes/preset/rngs/parallel.rng +0 -21
  297. data/tools/test/themes/preset/rngs/parallel_branch.rng +0 -8
  298. data/tools/test/themes/preset/rngs/scripts.rng +0 -23
  299. data/tools/test/themes/preset/rngs/stop.rng +0 -5
  300. data/tools/test/themes/preset/rngs/terminate.rng +0 -1
  301. data/tools/test/themes/preset/symbols/alternative.svg +0 -5
  302. data/tools/test/themes/preset/symbols/arrow.svg +0 -3
  303. data/tools/test/themes/preset/symbols/call.svg +0 -6
  304. data/tools/test/themes/preset/symbols/callmanipulate.svg +0 -8
  305. data/tools/test/themes/preset/symbols/choose.svg +0 -5
  306. data/tools/test/themes/preset/symbols/choose_exclusive.svg +0 -5
  307. data/tools/test/themes/preset/symbols/choose_inclusive.svg +0 -4
  308. data/tools/test/themes/preset/symbols/closed_loop.svg +0 -5
  309. data/tools/test/themes/preset/symbols/closed_loop_cancel.svg +0 -5
  310. data/tools/test/themes/preset/symbols/closed_loop_control.svg +0 -5
  311. data/tools/test/themes/preset/symbols/closed_loop_measuring.svg +0 -6
  312. data/tools/test/themes/preset/symbols/complex.svg +0 -8
  313. data/tools/test/themes/preset/symbols/critical.svg +0 -4
  314. data/tools/test/themes/preset/symbols/end.svg +0 -3
  315. data/tools/test/themes/preset/symbols/escape.svg +0 -5
  316. data/tools/test/themes/preset/symbols/event_end.svg +0 -3
  317. data/tools/test/themes/preset/symbols/loop.svg +0 -5
  318. data/tools/test/themes/preset/symbols/manipulate.svg +0 -4
  319. data/tools/test/themes/preset/symbols/otherwise.svg +0 -5
  320. data/tools/test/themes/preset/symbols/parallel.svg +0 -5
  321. data/tools/test/themes/preset/symbols/parallel_branch.svg +0 -5
  322. data/tools/test/themes/preset/symbols/parallel_branch_compact.svg +0 -4
  323. data/tools/test/themes/preset/symbols/parallel_branch_event.svg +0 -14
  324. data/tools/test/themes/preset/symbols/parallel_branch_normal.svg +0 -5
  325. data/tools/test/themes/preset/symbols/scripts.svg +0 -4
  326. data/tools/test/themes/preset/symbols/start.svg +0 -3
  327. data/tools/test/themes/preset/symbols/stop.svg +0 -5
  328. data/tools/test/themes/preset/symbols/terminate.svg +0 -4
  329. data/tools/test/themes/preset/theme.js +0 -1287
  330. data/tools/test/track.html +0 -142
@@ -1,109 +0,0 @@
1
- $(document).ready(function() {
2
- var timer;
3
-
4
- $(document).on('input','#dat_details input, #dat_details textarea, #dat_details [contenteditable]',function(e){
5
- clearTimeout(timer);
6
- timer = setTimeout(do_main_save, 5000);
7
- });
8
- $(document).on('change','#dat_details select',function(e){
9
- clearTimeout(timer);
10
- do_main_save();
11
- });
12
- $(document).on('blur','#dat_details input, #dat_details textarea, #dat_details [contenteditable]',function(e){
13
- clearTimeout(timer);
14
- do_main_save();
15
- });
16
- $(document).on('keypress','#dat_details input',function(e){
17
- if (e.keyCode == 13) {
18
- clearTimeout(timer);
19
- do_main_save();
20
- }
21
- });
22
- $(document).on('keypress','#dat_details [contenteditable]',function(e){
23
- if (e.keyCode == 13) {
24
- document.execCommand('insertText', false, '\n');
25
- return false;
26
- }
27
- });
28
- $(document).on('relaxngui_remove', '#dat_details', function(e){
29
- clearTimeout(timer);
30
- do_main_save();
31
- });
32
- $(document).on('relaxngui_move', '#dat_details', function(e){
33
- clearTimeout(timer);
34
- do_main_save();
35
- });
36
- });
37
-
38
- function do_main_save() { //{{{
39
- if (save['details'].has_changed()) {
40
- do_main_work();
41
- }
42
- } //}}}
43
-
44
- function do_main_work() { //{{{
45
- var svgid = save['details_target'].svgid;
46
- var desc = save['details_target'].model;
47
- var node = desc.get_node_by_svg_id(svgid);
48
- var orignode = save['graph_adaptor'].illustrator.get_node_by_svg_id(svgid).parents('g.element[element-id]');
49
- var origtype = orignode.attr('element-type') + '_' + orignode.attr('element-endpoint');
50
-
51
- var url = $('body').attr('current-instance');
52
- $('#main ui-tabbar ui-behind button').removeClass('highlight');
53
- save['details'].set_checkpoint();
54
-
55
- var nnew = $(save['details'].save().documentElement);
56
- nnew.attr('svg-id',svgid);
57
-
58
- if ($('*[svg-id]',node).length > 0) {
59
- nnew.append(node.children().filter(function(){ return this.attributes['svg-id'] != undefined; }));
60
- }
61
-
62
- if (node[0].namespaceURI == nnew.attr('xmlns')) { // remove xmlns when it is the same as in the parent node
63
- nnew[0].removeAttribute('xmlns');
64
- }
65
- node.replaceWith(nnew);
66
-
67
- var ttarget = manifestation.adaptor.illustrator.get_node_by_svg_id(svgid);
68
- var tnewnode = ttarget.parents('g.element[element-id]');
69
- var tnewtype = tnewnode.attr('element-type') + '_' + tnewnode.attr('element-endpoint');
70
-
71
- desc.refresh(function(graphrealization){
72
- var vtarget = manifestation.adaptor.illustrator.get_node_by_svg_id(svgid);
73
- if (vtarget.length > 0) {
74
- vtarget.parents('g.element[element-id]').addClass('selected');
75
- }
76
- manifestation.adaptor.illustrator.get_label_by_svg_id(svgid).addClass('selected');
77
-
78
-
79
- var newnode = vtarget.parents('g.element[element-id]');
80
- var newtype = newnode.attr('element-type') + '_' + newnode.attr('element-endpoint');
81
- var g = graphrealization.get_description();
82
- save['graph'] = $X(g);
83
- save['graph'].removeAttr('svg-id');
84
- save['graph'].removeAttr('svg-type');
85
- save['graph'].removeAttr('svg-subtype');
86
- save['graph'].removeAttr('svg-label');
87
-
88
- if (newtype != origtype) {
89
- manifestation.update_details(svgid);
90
- do_main_work();
91
- } else {
92
- $.ajax({
93
- type: "PUT",
94
- url: url + "/properties/description/",
95
- contentType: 'text/xml',
96
- headers: {
97
- 'Content-ID': 'description',
98
- 'CPEE-Event-Source': myid
99
- },
100
- data: desc.get_description()
101
- });
102
- adaptor_update();
103
- format_instance_pos();
104
-
105
- document.dispatchEvent(graph_changed);
106
- }
107
-
108
- });
109
- } //}}}
@@ -1,1344 +0,0 @@
1
- var es;
2
- var suspended_monitoring = false;
3
- var myid = ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
4
- var paths = '#dat_details input, #dat_details textarea, #dat_details select, #dat_details button, #dat_details [contenteditable], #dat_dataelements input, #dat_dataelements textarea, #dat_dataelements select, #dat_dataelements button, #dat_dataelements [contenteditable], #dat_endpoints input, #dat_endpoints textarea, #dat_endpoints select, #dat_endpoints button, #dat_endpoints [contenteditable], #dat_attributes input, #dat_attributes textarea, #dat_attributes select, #dat_attributes button, #dat_attributes [contenteditable]';
5
- var loading = false;
6
- var subscription;
7
- var subscription_state = 'less';
8
- var graph_changed = new Event("graph:changed", {"bubbles":true, "cancelable":false});
9
- var save = {};
10
- save['endpoints'] = undefined;
11
- save['dataelements'] = undefined;
12
- save['attributes'] = undefined;
13
- var node_state = {};
14
-
15
- function global_init() {
16
- suspended_monitoring = false;
17
- loading = false;
18
- subscription = undefined;
19
- subscription_state = 'less';
20
- save['state']= undefined;
21
- save['dsl'] = undefined;
22
- save['activity_states'] = {}
23
- save['graph'] = undefined;
24
- save['graph_theme'] = undefined;
25
- save['graph_adaptor'] = undefined;
26
- save['endpoints_cache'] = {};
27
- save['endpoints_list'] = {};
28
- save['details'] = undefined;
29
- save['details_target'] = undefined;
30
- save['instance_pos'] = [];
31
- node_state = {};
32
- }
33
-
34
- global_init();
35
-
36
- var sub_more = 'topic' + '=' + 'activity' + '&' +// {{{
37
- 'events' + '=' + 'calling,status,manipulating,failed,done' + '&' +
38
- 'topic' + '=' + 'activity' + '&' +
39
- 'votes' + '=' + 'syncing_after' + '&' +
40
- 'topic' + '=' + 'description' + '&' +
41
- 'events' + '=' + 'change,error' + '&' +
42
- 'topic' + '=' + 'position' + '&' +
43
- 'events' + '=' + 'change' + '&' +
44
- 'topic' + '=' + 'state' + '&' +
45
- 'events' + '=' + 'change' + '&' +
46
- 'topic' + '=' + 'dataelements' + '&' +
47
- 'events' + '=' + 'change' + '&' +
48
- 'topic' + '=' + 'endpoints' + '&' +
49
- 'events' + '=' + 'change' + '&' +
50
- 'topic' + '=' + 'attributes' + '&' +
51
- 'events' + '=' + 'change' + '&' +
52
- 'topic' + '=' + 'task' + '&' +
53
- 'events' + '=' + 'instantiation' + '&' +
54
- 'topic' + '=' + 'transformation' + '&' +
55
- 'events' + '=' + 'change' + '&' +
56
- 'topic' + '=' + 'handlerwrapper' + '&' +
57
- 'events' + '=' + 'error,change' + '&' +
58
- 'topic' + '=' + 'handlers' + '&' +
59
- 'events' + '=' + 'change';// }}}
60
- var sub_less = 'topic' + '=' + 'activity' + '&' +// {{{
61
- 'events' + '=' + 'calling,status,manipulating,failed,done' + '&' +
62
- 'topic' + '=' + 'position' + '&' +
63
- 'events' + '=' + 'change' + '&' +
64
- 'topic' + '=' + 'description' + '&' +
65
- 'events' + '=' + 'change,error' + '&' +
66
- 'topic' + '=' + 'state' + '&' +
67
- 'events' + '=' + 'change' + '&' +
68
- 'topic' + '=' + 'dataelements' + '&' +
69
- 'events' + '=' + 'change' + '&' +
70
- 'topic' + '=' + 'endpoints' + '&' +
71
- 'events' + '=' + 'change' + '&' +
72
- 'topic' + '=' + 'attributes' + '&' +
73
- 'events' + '=' + 'change' + '&' +
74
- 'topic' + '=' + 'task' + '&' +
75
- 'events' + '=' + 'instantiation' + '&' +
76
- 'topic' + '=' + 'transformation' + '&' +
77
- 'events' + '=' + 'change' + '&' +
78
- 'topic' + '=' + 'handlerwrapper' + '&' +
79
- 'events' + '=' + 'error,change' + '&' +
80
- 'topic' + '=' + 'handlers' + '&' +
81
- 'events' + '=' + 'change';// }}}
82
-
83
- function cockpit() { //{{{
84
- $("button[name=base]").click(function(){ create_instance($("input[name=base-url]").val(),null,false,false); });
85
- $("button[name=instance]").click(function(){ ui_activate_tab("#tabinstance"); monitor_instance($("input[name=instance-url]").val(),$("input[name=res-url]").val(),false,false); });
86
- $("button[name=loadtestset]").click(function(e){new CustomMenu(e).menu($('#templates'),function(){ load_testset(false) } ); });
87
- $("button[name=loadtestsetfile]").click(load_testsetfile);
88
- $("button[name=loadmodelfile]").click(load_modelfile);
89
- $("button[name=loadmodeltype]").click(function(e){new CustomMenu(e).menu($('#modeltypes'),load_modeltype, $("button[name=loadmodeltype]")); });
90
- $("button[name=savetestsetfile]").click(function(){ save_testsetfile(); });
91
- $("button[name=savesvgfile]").click(function(){ save_svgfile(); });
92
- $("button[name=state_start]").click(function(){ $(this).parent().find('button').attr("disabled","disabled");start_instance(); });
93
- $("button[name=state_stop]").click(function(){ $(this).parent().find('button').attr("disabled","disabled");stop_instance(); });
94
- $("button[name=state_replay]").click(function(){ $(this).parent().find('button').attr("disabled","disabled");replay_instance(); });
95
- $("button[name=state_abandon]").click(function(){ aba_instance(); });
96
- $("input[name=votecontinue]").click(check_subscription);
97
- $("input[name=testsetfile]").change(load_testsetfile_after);
98
- $("input[name=modelfile]").change(load_modelfile_after);
99
-
100
- $.ajax({
101
- url: $('body').attr('current-templates') + ".templates.xml",
102
- dataType: 'xml',
103
- success: function(res){
104
- $('testset',res).each(function(){
105
- var ts = $(this).text();
106
- $('#templates').append($("<div class='menuitem'></div>").text(ts));
107
- });
108
- var q = $.parseQuerySimple();
109
- if (q.min || q.min == "") {
110
- ui_toggle_vis_tab($('#instance'));
111
- ui_toggle_vis_tab($('#parameters'));
112
- }
113
- if (q.monitor && q.load) {
114
- if (q.load.match(/https?:\/\//)) {
115
- $('body').attr('load-testset',q.load);
116
- } else {
117
- $("#templates div.menuitem").each(function(k,v){
118
- if ($(v).text() == q.load) { $(v).attr('data-selected','selected'); }
119
- });
120
- }
121
- ui_activate_tab("#tabexecution");
122
- monitor_instance(q.monitor,$("body").attr('current-resources'),true,false);
123
- } else if (q.load) {
124
- if (q.load.match(/https?:\/\//)) {
125
- $('body').attr('load-testset',q.load);
126
- } else {
127
- $("#templates div.menuitem").each(function(k,v){
128
- if ($(v).text() == q.load) { $(v).attr('data-selected','selected'); }
129
- });
130
- }
131
- ui_activate_tab("#tabexecution");
132
- create_instance($("body").attr('current-base'),q.load,true,false);
133
- } else if (q.instantiate) {
134
- if (q.instantiate.match(/https?:\/\//)) {
135
- ui_activate_tab("#tabexecution");
136
- create_instance_from($("body").attr('current-base'),q.instantiate,false);
137
- } else {
138
- alert('Nope. Url!');
139
- }
140
- } else if (q.new || q.new == "") {
141
- ui_activate_tab("#tabinstance");
142
- create_instance($("body").attr('current-base'),"Plain Instance",false,false);
143
- } else if (q.monitor) {
144
- ui_activate_tab("#tabexecution");
145
- monitor_instance(q.monitor,$("body").attr('current-resources'),false,false);
146
- } else if (q.exec) {
147
- if (q.exec.match(/https?:\/\//)) {
148
- $('body').attr('load-testset',q.load);
149
- } else {
150
- $("#templates div.menuitem").each(function(k,v){
151
- if ($(v).text() == q.exec) { $(v).attr('data-selected','selected'); }
152
- });
153
- }
154
- ui_activate_tab("#tabexecution");
155
- create_instance($("body").attr('current-base'),q.exec,true,true);
156
- }
157
- }
158
- });
159
- $.ajax({
160
- url: $('body').attr('current-templates') + ".transformations.xml",
161
- dataType: 'xml',
162
- success: function(res){
163
- $('transformation',res).each(function(){
164
- var ts = $(this).text();
165
- $('#modeltypes').append($("<div class='menuitem'></div>").text(ts));
166
- });
167
- }
168
- });
169
- } //}}}
170
-
171
- function sanitize_url(url) { //{{{
172
- var lastChar = url.substr(url.length - 1)
173
- if (lastChar != '/') {
174
- url = (url + '/');
175
- }
176
- return url;
177
- }
178
- //}}}
179
- function check_subscription() { // {{{
180
- var url = $('body').attr('current-instance');
181
- var num = 0;
182
- if ($("input[name=votecontinue]").is(':checked')) num += 1;
183
- if (num > 0 && subscription_state == 'less') {
184
- $.ajax({
185
- type: "PUT",
186
- url: url + "/notifications/subscriptions/" + subscription + '/',
187
- data: sub_more
188
- });
189
- subscription_state = 'more';
190
- }
191
- if (num == 0 && subscription_state == 'more') {
192
- $.ajax({
193
- type: "PUT",
194
- url: url + "/notifications/subscriptions/" + subscription + '/',
195
- data: sub_less
196
- });
197
- subscription_state = 'less';
198
- }
199
- }// }}}
200
-
201
- function create_instance_from(base,url,exec) {// {{{
202
- $.get({
203
- url: url,
204
- dataType: "text",
205
- success: function(res) {
206
- $.ajax({
207
- type: "POST",
208
- url: base,
209
- contentType: 'application/xml',
210
- dataType: "text",
211
- headers: { 'CONTENT-ID': 'xml' },
212
- data: res,
213
- success: function(res){
214
- var iu = (base + "//" + res + "/").replace(/\/+/g,"/").replace(/:\//,"://");
215
- monitor_instance(iu,$("body").attr('current-resources'),false,exec);
216
- },
217
- error: function(a,b,c) {
218
- alert("No CPEE running.");
219
- }
220
- });
221
- }
222
- });
223
- }// }}}
224
- function create_instance(base,name,load,exec) {// {{{
225
- var info = name ? name : prompt("Instance info?", "Enter info here");
226
- if (info != null) {
227
- if (info.match(/\S/)) {
228
- $.ajax({
229
- type: "POST",
230
- url: base,
231
- dataType: "text",
232
- data: "info=" + info,
233
- success: function(res){
234
- var iu = (base + "//" + res + "/").replace(/\/+/g,"/").replace(/:\//,"://");
235
- if (name) {
236
- monitor_instance(iu,$("body").attr('current-resources'),load,exec);
237
- } else {
238
- $("body").attr('current-instance', sanitize_url(iu));
239
- $("input[name=instance-url]").val(iu);
240
- }
241
- },
242
- error: function(a,b,c) {
243
- alert("No CPEE running.");
244
- }
245
- });
246
- } else {
247
- alert("An instance info is necessary!");
248
- }
249
- }
250
- }// }}}
251
-
252
- function sse() { //{{{
253
- var url = $('body').attr('current-instance');
254
- if (subscription) {
255
- es = new EventSource(url + "/notifications/subscriptions/" + subscription + "/sse/");
256
- es.onopen = function() {
257
- append_to_log("monitoring", "opened", "nice.");
258
- };
259
- es.onmessage = function(e) {
260
- data = JSON.parse(e.data);
261
- if (data['type'] == 'event') {
262
- switch(data['topic']) {
263
- case 'dataelements':
264
- monitor_instance_values("dataelements");
265
- break;
266
- case 'description':
267
- monitor_instance_dsl();
268
- break;
269
- case 'endpoints':
270
- monitor_instance_values("endpoints");
271
- break;
272
- case 'attributes':
273
- monitor_instance_values("attributes");
274
- monitor_instance_transformation();
275
- if (!suspended_monitoring) { // or else it would load twice, because dsl changes also trigger
276
- if (save['graph_theme'] != data.content.values.theme) {
277
- monitor_graph_change(true);
278
- }
279
- }
280
- break;
281
- case 'task':
282
- if ($('#trackcolumn').length > 0) {
283
- $('#trackcolumn').append($('<iframe src="track.html?monitor=' + data.content.received['CPEE-INSTANCE-URL'].replace(/\/*$/,'/') + '"></iframe>'));
284
- $('#graphcolumn').addClass('resize');
285
- }
286
- break;
287
- case 'state':
288
- monitor_instance_state_change(data['content']['state']);
289
- break;
290
- case 'position':
291
- monitor_instance_pos_change(data['content']);
292
- break;
293
- case 'activity':
294
- monitor_instance_running(data['content'],data['name']);
295
- break;
296
- }
297
- }
298
- if (data['type'] == 'vote') {
299
- monitor_instance_vote_add(data['content']);
300
- }
301
- append_to_log(data['type'], data['topic'] + '/' + data['name'], JSON.stringify(data['content']));
302
- };
303
- es.onerror = function() {
304
- append_to_log("monitoring", "closed", "finished or abandoned or not existing or server down. one of these, i assume.");
305
- // setTimeout(sse,10000);
306
- };
307
- }
308
- monitor_instance_values("dataelements");
309
- monitor_instance_values("endpoints");
310
- monitor_instance_values("attributes");
311
- monitor_instance_transformation();
312
- monitor_instance_dsl();
313
- monitor_instance_state();
314
- } //}}}
315
-
316
- function monitor_instance(cin,rep,load,exec) {// {{{
317
- global_init();
318
- format_visual_clear();
319
- format_visual_vote_clear();
320
-
321
- $("body").attr('current-instance',sanitize_url(cin));
322
- $("body").attr('current-resources',sanitize_url(rep));
323
-
324
- $("input[name=instance-url]").val($("body").attr('current-instance'));
325
- $("input[name=res-url]").val($("body").attr('current-resources'));
326
-
327
- $('.tabbehind button').hide();
328
- $('#dat_details').empty();
329
-
330
- url = $("body").attr('current-instance');
331
-
332
- $.ajax({
333
- type: "GET",
334
- url: url,
335
- success: function(res){
336
- $("ui-tabbed.hidden, ui-rest.hidden").removeClass("hidden");
337
- $("ui-resizehandle.hidden").removeClass("hidden");
338
- $("ui-tabbed ui-tab.hidden, ui-rest ui-tab.hidden").removeClass("hidden");
339
-
340
- // Change url to return to current instance when reloading
341
- $("#current-instance").show();
342
- $("#current-instance").text(url.match(/(\d+)\/?$/)[1]);
343
- $("#current-instance").attr('href',url);
344
- $("#current-instance-properties").show();
345
- $("#current-instance-properties").attr('href',url + 'properties/');
346
- $("#current-instance-subscriptions").show();
347
- $("#current-instance-subscriptions").attr('href',url + 'notifications/subscriptions/');
348
- $("#current-instance-callbacks").show();
349
- $("#current-instance-callbacks").attr('href',url + 'callbacks/');
350
- $("#current-monitor").show();
351
- $("#current-monitor").attr('href','edit.html?monitor=' + url);
352
- $("#current-graph").show();
353
- $("#current-graph").attr('href','graph.html?monitor=' + url);
354
- $("#current-track").show();
355
- $("#current-track").attr('href','track.html?monitor=' + url);
356
- var q = $.parseQuerySimple();
357
- history.replaceState({}, '', '?' + (q.min || q.min=="" ? "min&" : "") + 'monitor='+url);
358
-
359
- // Change url to return to current instance when reloading (because new subscription is made)
360
- $("input[name=votecontinue]").prop( "checked", false );
361
-
362
- $.ajax({
363
- type: "POST",
364
- url: url + "/notifications/subscriptions/",
365
- data: sub_less,
366
- success: function(res){
367
- subscription = res;
368
- append_to_log("monitoring", "id", subscription);
369
- sse();
370
- if (load || exec) {
371
- load_testset(exec);
372
- }
373
- },
374
- error: function() {
375
- subscription = undefined;
376
- append_to_log("monitoring", "closed", "For Good.");
377
- sse();
378
- }
379
- });
380
- },
381
- error: function(a,b,c) {
382
- alert("This ain't no CPEE instance");
383
- ui_activate_tab("#tabnew");
384
- }
385
- });
386
- }// }}}
387
-
388
- function monitor_instance_values(val) {// {{{
389
- var url = $('body').attr('current-instance');
390
- var rep = $('body').attr('current-resources');
391
- var bas = $('body').attr('current-base');
392
-
393
- $.ajax({
394
- type: "GET",
395
- url: url + "/properties/" + val + "/",
396
- success: function(res){
397
- save[val].content(res);
398
- if (val == "endpoints") {
399
- save['endpoints_list'] = {};
400
- var tmp = {};
401
- $(res).find(" > endpoints > *").each(function(k,v) {
402
- save['endpoints_list'][v.localName] = v.lastChild.nodeValue;
403
- $.ajax({
404
- url: rep + encodeURIComponent($(v).text()),
405
- success: function() {
406
- tmp[v.tagName] = {};
407
- var deferreds = [new $.Deferred(), new $.Deferred(), new $.Deferred()];
408
- $.ajax({
409
- url: rep + encodeURIComponent($(v).text()) + "/symbol.svg",
410
- success: function(res) {
411
- tmp[v.tagName]['symbol'] = res;
412
- deferreds[0].resolve(true);
413
- },
414
- error: deferreds[0].resolve
415
- })
416
- $.ajax({
417
- url: rep + encodeURIComponent($(v).text()) + "/schema.rng",
418
- success: function(res) {
419
- tmp[v.tagName]['schema'] = res;
420
- deferreds[1].resolve(true);
421
- },
422
- error: deferreds[1].resolve
423
- })
424
- $.ajax({
425
- url: rep + encodeURIComponent($(v).text()) + "/properties.json",
426
- success: function(res) {
427
- tmp[v.tagName]['properties'] = res;
428
- deferreds[2].resolve(true);
429
- },
430
- error: deferreds[2].resolve
431
- })
432
- $.when.apply($, deferreds).then(function(x) {
433
- save['endpoints_cache'] = tmp;
434
- // when updating attributes clear the attributes, because they might change as well. New arguments are possible.
435
- $('#dat_details').empty();
436
- adaptor_update();
437
- });
438
- }
439
- });
440
- });
441
- } else if(val == "attributes") {
442
- var text = $(" > attributes > info",res).text() + " (" + url.replace(/\/$/,'').split(/[\\/]/).pop() + ")";
443
- $('#title').text(text);
444
- document.title = text;
445
- if ($('body').attr('current-save')) {
446
- $('body').attr('current-save-dir',$(" > attributes > design_dir",res).text());
447
- }
448
- if ($('body').attr('current-logs')) {
449
- var uuid = $(" > attributes > uuid",res).text();
450
- $("#current-log").show();
451
- $("#current-log").attr('href',$('body').attr('current-logs') + uuid + '.xes.yaml');
452
- if ($("#current-log").text() == '') {
453
- $("#current-log").text(uuid + '.xes.yaml');
454
- }
455
- }
456
- }
457
- }
458
- });
459
- } // }}}
460
-
461
- function adaptor_update() { //{{{
462
- $('g.element[element-endpoint]').each(function(k,ele){
463
- if (save['endpoints_cache'][$(ele).attr('element-endpoint')] && save['endpoints_cache'][$(ele).attr('element-endpoint')]) {
464
- var c = $(ele).find('g.replace');
465
- var symbol = save['endpoints_cache'][$(ele).attr('element-endpoint')].symbol;
466
- if (symbol) {
467
- c.replaceWith($(symbol.documentElement).clone());
468
- }
469
- }
470
- });
471
- } //}}}
472
- function adaptor_init(url,theme,dslx) { //{{{
473
- if (save['graph_theme'] != theme) {
474
- save['graph_theme'] = theme;
475
- save['graph_adaptor'] = new WfAdaptor($('body').data('theme-base') + '/' + theme + '/theme.js',function(graphrealization){
476
- manifestation.endpoints = save.endpoints_list;
477
- graphrealization.draw_labels = function(max,labels,shift,striped) {
478
- $('#graphcanvas').css('grid-row', '1/span ' + (max.row + 2));
479
- if (striped == true) {
480
- if (!$('#graphgrid').hasClass('striped')) {
481
- $('#graphgrid').addClass('striped');
482
- }
483
- } else {
484
- $('#graphgrid').removeClass('striped');
485
- }
486
-
487
- $('#graphgrid .graphlabel, #graphgrid .graphempty, #graphgrid .graphlast').remove();
488
- var tlabels = {};
489
- var tcolumns = [];
490
- var tcolumncount = {}
491
- _.each(labels,function(val){
492
- if (val.label != "") {
493
- tlabels[val.row] = [];
494
- _.each(val.label,function(col) {
495
- if (!tcolumns.includes(col.column)) {
496
- tcolumns.push(col.column);
497
- tcolumncount[col.column] = 0;
498
- }
499
- if (col.value != undefined) {
500
- tcolumncount[col.column] += 1;
501
- }
502
- tlabels[val.row][tcolumns.indexOf(col.column)] = { label: col.value, type: val.tname, id: val.element_id };
503
- });
504
- }
505
- });
506
- $('#graphgrid').css({
507
- 'grid-template-rows': (shift/2) + 'px repeat(' + max.row + ', 1fr) ' + (shift/2) + 'px',
508
- 'grid-template-columns': 'max-content' + (tcolumns.length > 0 ? ' repeat(' + tcolumns.length.toString() + ',max-content)' : '') + ' auto'
509
- });
510
- for (var i = 0; i < max.row; i++) {
511
- for (var j =0; j < tcolumns.length; j++) {
512
- if (tlabels[i+1] != undefined && tlabels[i+1][j] != undefined && tlabels[i+1][j].label != undefined && tlabels[i+1][j].label != '') {
513
- var col = tlabels[i+1][j];
514
- var ele = $('<div class="graphlabel ' + (i % 2 == 0 ? 'odd' : 'even') + '" element-type="' + col.type + '" element-id="' + col.id + '" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '"><span>' + col.label + '</span></div>');
515
- graphrealization.illustrator.draw.bind_event(ele,col.type,false);
516
- $('#graphgrid').append(ele);
517
- } else {
518
- if (tcolumncount[tcolumns[j]] != 0) {
519
- var ele = $('<div class="graphempty ' + (i % 2 == 0 ? 'odd' : 'even') + '" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '; padding-bottom: ' + shift + 'px">&#032;</div>');
520
- $('#graphgrid').append(ele);
521
- }
522
- }
523
- }
524
- var j = tcolumns.length;
525
- var ele = $('<div class="graphlast ' + (i % 2 == 0 ? 'odd' : 'even') + '" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '; padding-bottom: ' + shift + 'px">&#032;</div>');
526
- $('#graphgrid').append(ele);
527
- }
528
- };
529
- graphrealization.set_svg_container($('#graphcanvas'));
530
- graphrealization.set_label_container($('#graphgrid'));
531
- graphrealization.set_description($(dslx), true);
532
- graphrealization.notify = function(svgid) {
533
- var g = graphrealization.get_description();
534
- save['graph'] = $X(g);
535
- save['graph'].removeAttr('svg-id');
536
- save['graph'].removeAttr('svg-type');
537
- save['graph'].removeAttr('svg-subtype');
538
- save['graph'].removeAttr('svg-label');
539
- document.dispatchEvent(graph_changed);
540
- $.ajax({
541
- type: "PUT",
542
- url: url + "/properties/description/",
543
- contentType: 'text/xml',
544
- headers: {
545
- 'Content-ID': 'description',
546
- 'CPEE-Event-Source': myid
547
- },
548
- data: g,
549
- error: report_failure
550
- });
551
- adaptor_update();
552
- manifestation.events.click(svgid);
553
- format_instance_pos();
554
- if (manifestation.selected() == "unknown") { // nothing selected
555
- $('#dat_details').empty();
556
- }
557
- };
558
- adaptor_update();
559
- monitor_instance_pos();
560
- $('#dat_details').empty();
561
- });
562
- } else {
563
- save['graph_adaptor'].update(function(graphrealization){
564
- var svgid = manifestation.selected();
565
- graphrealization.set_description($(dslx));
566
- adaptor_update();
567
- manifestation.events.click(svgid);
568
- format_instance_pos();
569
- });
570
- }
571
- suspended_monitoring = false;
572
- } //}}}
573
-
574
- function monitor_graph_change(force) { //{{{
575
- var url = $('body').attr('current-instance');
576
- $.ajax({
577
- type: "GET",
578
- url: url + "/properties/dslx/",
579
- success: function(dslx){
580
- if (force || !save['graph'] || (save['graph'] && save['graph'].serializePrettyXML() != $(dslx.documentElement).serializePrettyXML())) {
581
- $.ajax({
582
- type: "GET",
583
- url: url + "/properties/attributes/theme/",
584
- success: function(res){
585
- adaptor_init(url,res,dslx);
586
- },
587
- error: function() {
588
- adaptor_init(url,'preset',dslx);
589
- }
590
- });
591
- }
592
- }
593
- });
594
- } //}}}
595
-
596
- function monitor_instance_dsl() {// {{{
597
- var url = $('body').attr('current-instance');
598
- $.ajax({
599
- type: "GET",
600
- dataType: "text",
601
- url: url + "/properties/dsl/",
602
- success: function(res){
603
- if (res != save['dsl']) {
604
- save['dsl'] = res;
605
- var ctv = $("#areadsl");
606
- ctv.empty();
607
-
608
- res = format_code(res,false,true);
609
- res = res.replace(/activity\s+:([A-Za-z][a-zA-Z0-9_]+)/g,"<span class='activities' id=\"activity-$1\">activity :$1</span>");
610
- res = res.replace(/activity\s+\[:([A-Za-z][a-zA-Z0-9_]+)([^\]]*\])/g,"<span class='activities' id=\"activity-$1\">activity [:$1$2</span>");
611
-
612
- ctv.append(res);
613
- monitor_graph_change(false);
614
- }
615
- }
616
- });
617
- }// }}}
618
-
619
- function monitor_instance_state() {// {{{
620
- var url = $('body').attr('current-instance');
621
- $.ajax({
622
- type: "GET",
623
- url: url + "/properties/state/",
624
- dataType: "text",
625
- success: function(res){
626
- monitor_instance_state_change(res);
627
- }
628
- });
629
- }// }}}
630
- function monitor_instance_transformation() {// {{{
631
- var url = $('body').attr('current-instance');
632
- $.ajax({
633
- type: "GET",
634
- url: url + "/properties/attributes/modeltype",
635
- success: function(res){
636
- $("#currentmodel").text(res);
637
- },
638
- error: function() {
639
- $("#currentmodel").text('???');
640
- }
641
- });
642
- }// }}}
643
-
644
- function monitor_instance_pos() {// {{{
645
- var url = $('body').attr('current-instance');
646
- $.ajax({
647
- type: "GET",
648
- url: url + "/properties/positions/",
649
- success: function(res){
650
- save['instance_pos'] = $("positions > *",res);
651
- format_visual_clear();
652
- format_instance_pos();
653
- }
654
- });
655
- }// }}}
656
-
657
- function monitor_instance_running(content,event) {// {{{
658
- if (save['state'] == "stopping") return;
659
- if (event == "calling") {
660
- save['activity_states'][content.activity_uuid] = true
661
- format_visual_add(content.activity,"active")
662
- }
663
- if (event == "manipulating") {
664
- if (!save['activity_states'][content.activity_uuid]) {
665
- format_visual_add(content.activity,"active")
666
- }
667
- }
668
- if (event == "done") {
669
- delete save['activity_states'][content.activity_uuid];
670
- format_visual_remove(content.activity,"active")
671
- }
672
- } // }}}
673
- function monitor_instance_state_change(notification) { //{{{
674
- if ($('#trackcolumn').length > 0) {
675
- if (notification == "finished" || notification == "abandoned") {
676
- parent.closeIFrame(window.location.search);
677
- }
678
- }
679
- if (notification == "ready" || notification == "stopped" || notification == "running") {
680
- $("#state button").removeAttr('disabled');
681
- }
682
-
683
- // sometimes, out of sheer network routingness, stopping comes after stopped, which fucks the UI hard
684
- // thus, we are having none of it
685
- if (notification == 'stopping' && save['state'] == 'stopped')
686
- return;
687
- if (notification != save['state']) {
688
- save['state'] = notification;
689
-
690
- if (notification == "stopped") {
691
- monitor_instance_pos();
692
- }
693
- if (notification == "running") {
694
- format_visual_clear();
695
- }
696
-
697
- var but = "";
698
- if (notification == "ready" || notification == "stopped") {
699
- $('#state_extended').show();
700
- $("button[name=state_start]").show();
701
- $("button[name=state_stop]").hide();
702
- $("button[name=state_replay]").show();
703
- $("button[name=state_abandon]").show();
704
- } else if (notification == "running") {
705
- $('#state_extended').hide();
706
- $("button[name=state_start]").hide();
707
- $("button[name=state_stop]").show();
708
- $("button[name=state_replay]").hide();
709
- $("button[name=state_abandon]").hide();
710
- } else {
711
- $('#state_extended').hide();
712
- $("button[name=state_start]").hide();
713
- $("button[name=state_stop]").hide();
714
- $("button[name=state_replay]").hide();
715
- $("button[name=state_abandon]").hide();
716
- }
717
-
718
- // disable all input, also check themes
719
- format_visual_forms();
720
- // remove all markings with state change
721
- if (save['graph_adaptor'] && save['graph_adaptor'].illustrator) {
722
- save['graph_adaptor'].illustrator.get_elements().removeClass('marked');
723
- }
724
-
725
- if (notification != "ready" && notification != "stopped" && notification != "running") {
726
- $('.tabbehind button').hide();
727
- $('#state_any').hide();
728
- } else {
729
- $('#parameters .tabbehind button').show();
730
- $('#state_any').show();
731
- }
732
-
733
- $("#state_text").text(notification);
734
- }
735
- } //}}}
736
- function monitor_instance_pos_change(content) {// {{{
737
- if (content['unmark']) {
738
- $.each(content['unmark'],function(a,b){
739
- format_visual_remove(b.position,"passive")
740
- });
741
- }
742
- if (content['at']) {
743
- $.each(content['at'],function(a,b){
744
- format_visual_add(b.position,"passive");
745
- });
746
- }
747
- if (!content['at'] && !content['unmark'] && !content['after'] && !content['wait']) {
748
- monitor_instance_pos();
749
- }
750
- } // }}}
751
-
752
- function monitor_instance_vote_add(parts) {// {{{
753
- var ctv = $("#votes");
754
-
755
- astr = '';
756
- if ($("input[name=votecontinue]").is(':checked'))
757
- astr += "<button id='vote_to_continue-" + parts.activity + "-" + parts.key + "' onclick='$(this).attr(\"disabled\",\"disabled\");monitor_instance_vote_remove(\"" + parts.activity + "\",\"" + parts.key + "\",\"true\");'>" + parts.activity + "</button>";
758
- ctv.append(astr);
759
- format_visual_add(parts.activity,"vote")
760
- }// }}}
761
- function monitor_instance_vote_remove(activity,callback,value) {//{{{
762
- var url = $('body').attr('current-instance');
763
- $.ajax({
764
- type: "PUT",
765
- url: url + "/callbacks/" + callback,
766
- data: ({'continue': value}),
767
- error: report_failure
768
- });
769
- format_visual_remove(activity,"vote");
770
- $('#vote_to_continue-' + activity + '-' + callback).remove();
771
- }//}}}
772
-
773
- function start_instance() {// {{{
774
- var url = $('body').attr('current-instance');
775
- $.ajax({
776
- type: "PUT",
777
- url: url + "/properties/state",
778
- data: ({value: "running"}),
779
- error: report_failure
780
- });
781
- }// }}}
782
- function replay_instance() {// {{{
783
- var url = $('body').attr('current-instance');
784
- $.ajax({
785
- type: "PUT",
786
- url: url + "/properties/state",
787
- data: ({value: "replaying"}),
788
- error: report_failure
789
- });
790
- }// }}}
791
- function aba_instance() {// {{{
792
- monitor_instance_state_change('abandoned');
793
- var url = $('body').attr('current-instance');
794
- $.ajax({
795
- type: "PUT",
796
- url: url + "/properties/state",
797
- data: ({value: "abandoned"}),
798
- error: report_failure
799
- });
800
- }// }}}
801
- function stop_instance() {// {{{
802
- var url = $('body').attr('current-instance');
803
- $.ajax({
804
- type: "PUT",
805
- url: url + "/properties/state",
806
- data: ({value: "stopping"}),
807
- error: report_failure
808
- });
809
- }// }}}
810
-
811
- function save_testsetfile() {// {{{
812
- var def = new $.Deferred();
813
- def.done(function(name,testset) {
814
- var ct = new Date();
815
- $('#savetestsetfile').attr('download',name + '.xml');
816
- $('#savetestsetfile').attr('href','data:application/xml;charset=utf-8;base64,' + $B64(testset.serializePrettyXML()));
817
- document.getElementById('savetestsetfile').click();
818
- });
819
- get_testset(def);
820
- }// }}}
821
-
822
- function get_testset(deferred) {// {{{
823
- var url = $('body').attr('current-instance');
824
-
825
- $.ajax({
826
- type: "GET",
827
- url: url + "/properties/",
828
- success: function(res){
829
- var testset = $X('<testset xmlns="http://cpee.org/ns/properties/2.0"/>');
830
- testset.append($(res.documentElement).children());
831
- $('testset > state',testset).remove();
832
- $('testset > status',testset).remove();
833
- $('testset > positions',testset).remove();
834
- $('testset > dsl',testset).remove();
835
- $('testset > description > *',testset).remove();
836
- $('testset > description',testset).append($('testset > dslx',testset).children());
837
- $('testset > transformation',testset).remove();
838
- $('testset > dsl',testset).remove();
839
- $('testset > dslx',testset).remove();
840
- $('testset > attributes > uuid',testset).remove();
841
- testset.append($X('<transformation xmlns="http://cpee.org/ns/properties/2.0"><description type="copy"/><dataelements type="none"/><endpoints type="none"/></transformation>'));
842
- var name = $('testset > attributes > info',testset).text();
843
- $('[xmlns]',testset).each((idx,ele) => {
844
- if (ele.parentNode.namespaceURI == ele.getAttribute('xmlns')) {
845
- ele.removeAttribute('xmlns');
846
- }
847
- });
848
- deferred.resolve(name,testset);
849
- },
850
- error: function() { deferred.reject(); report_failure(); }
851
- });
852
- }// }}}
853
- function save_svgfile() {// {{{
854
- var url = $('body').attr('current-instance');
855
-
856
- var gc = $('#graphcanvas').clone();
857
- $.ajax({
858
- type: "GET",
859
- url: "css/wfadaptor.css",
860
- success: function(res){
861
- gc.prepend($X('<style xmlns="http://www.w3.org/2000/svg" type="text/css"><![CDATA[' + res + ']]></style>'));
862
- $(window.document.styleSheets).each(function(i,x){
863
- if (x && x.href && x.href.match(/wfadaptor\.css$/)) {
864
- var varreps = {};
865
- $(x.cssRules).each(function(j,y){
866
- if (y.selectorText == ":root") {
867
- $(y.style).each(function(k,z) {
868
- varreps['var\\(' + z + '\\)'] = getComputedStyle(document.documentElement).getPropertyValue(z).toString();
869
- });
870
- }
871
- var loc = $(gc).find(y.selectorText.replace(/svg /g,''));
872
- var cst = y.style.cssText;
873
- for (k in varreps) {
874
- cst = cst.replace(new RegExp(k,'g'),varreps[k]);
875
- }
876
- loc.each(function(k,loco) {
877
- var sty = $(loco).attr('style') == undefined ? '' : $(loco).attr('style');
878
- $(loco).attr('style',cst + sty);
879
- });
880
- });
881
- var loc = $(gc).find('text.super');
882
- loc.attr('style',loc.attr('style') + ' display: none');
883
- var loc = $(gc).find('.stripe');
884
- loc.attr('style',loc.attr('style') + ' display: none');
885
- }
886
- });
887
- $.ajax({
888
- type: "GET",
889
- url: url + "/properties/attributes/info/",
890
- success: function(res){
891
- $('#savesvgfile').attr('download',res + '.svg');
892
- $('#savesvgfile').attr('href','data:application/xml;charset=utf-8;base64,' + $B64(gc.serializeXML()));
893
- document.getElementById('savesvgfile').click();
894
- },
895
- error: report_failure
896
- });
897
- }
898
- });
899
- }// }}}
900
- async function set_testset(testset,exec) {// {{{
901
- var url = $('body').attr('current-instance');
902
- suspended_monitoring = true;
903
-
904
- var promises = [];
905
-
906
- var tset = $X('<properties xmlns="http://cpee.org/ns/properties/2.0"/>');
907
- tset.append($("testset > handlerwrapper",testset));
908
- tset.append($("testset > positions",testset));
909
- tset.append($("testset > dataelements",testset));
910
- tset.append($("testset > endpoints",testset));
911
- tset.append($("testset > attributes",testset));
912
- tset.append($("testset > description",testset));
913
- tset.append($("testset > transformation",testset));
914
- $('testset > attributes > info',tset).remove();
915
-
916
- promises.push(
917
- $.ajax({
918
- type: "GET",
919
- url: url + "/notifications/subscriptions/",
920
- error: report_failure
921
- }).then(async function(res) {
922
- var rcount = 0;
923
- var values = $("subscriptions > subscription[url]",res);
924
- var vals = [];
925
- values.each(function(){
926
- vals.push($(this).attr('url'));
927
- });
928
- await load_testset_handlers(url,testset,vals);
929
- })
930
- );
931
- promises.push(
932
- $.ajax({
933
- type: 'PATCH',
934
- url: url + "/properties/",
935
- contentType: 'text/xml',
936
- headers: {
937
- 'Content-ID': 'properties',
938
- 'CPEE-Event-Source': myid
939
- },
940
- data: tset.serializeXML(),
941
- error: report_failure
942
- })
943
- );
944
-
945
- await Promise.all(promises);
946
-
947
- $.ajax({
948
- type: "GET",
949
- url: url + "/properties/state/",
950
- dataType: "text",
951
- success: function(res){
952
- $.ajax({
953
- type: "PUT",
954
- url: url + "/properties/state",
955
- data: ({value: res}),
956
- error: report_failure,
957
- success: function(res){
958
- if (exec) start_instance();
959
- }
960
- });
961
- }
962
- });
963
- }// }}}
964
-
965
- function load_testsetfile_after() { //{{{
966
- if (loading) return;
967
- loading = true;
968
- if (typeof window.FileReader !== 'function') {
969
- alert('FileReader not yet supportet');
970
- return;
971
- }
972
- var files = $('#testsetfile').get(0).files;
973
- var reader = new FileReader();
974
- reader.onload = function(){
975
- set_testset($.parseXML(reader.result),false);
976
- document.getElementById('fuckchrome').reset();
977
- loading = false;
978
- }
979
- reader.onerror = function(){ console.log('error reading file'); loading = false; }
980
- reader.onabort = function(){ console.log('abort reading file'); loading = false; }
981
- reader.readAsText(files[0]);
982
- } //}}}
983
- function load_testsetfile() {// {{{
984
- if (loading) return;
985
- document.getElementById('testsetfile').click();
986
- }// }}}
987
-
988
- function load_modelfile_after() { //{{{
989
- if (loading) return;
990
- loading = true;
991
- if (typeof window.FileReader !== 'function') {
992
- alert('FileReader not yet supportet');
993
- return;
994
- }
995
- var files = $('#modelfile').get(0).files;
996
- var reader = new FileReader();
997
- reader.onload = function(){
998
- var url = $('body').attr('current-instance');
999
- load_des(url,reader.result);
1000
- loading = false;
1001
- }
1002
- reader.onerror = function(){ loading = false; }
1003
- reader.onabort = function(){ loading = false; }
1004
- reader.readAsText(files[0]);
1005
- } //}}}
1006
- function load_modelfile() {// {{{
1007
- if (loading) return;
1008
- document.getElementById('modelfile').click();
1009
- }// }}}
1010
-
1011
- function load_testset(exec) {// {{{
1012
- if (loading) return;
1013
- loading = true;
1014
-
1015
- var name = $("#templates div.menuitem[data-selected=selected]").text();
1016
- var url;
1017
- if (name) {
1018
- url = $('body').attr('current-templates') + name + ".xml";
1019
- } else {
1020
- if ($('body').attr('load-testset').length > 0) {
1021
- url = $('body').attr('load-testset');
1022
- }
1023
- }
1024
- if (url) {
1025
- $.ajax({
1026
- cache: false,
1027
- dataType: 'xml',
1028
- url: url,
1029
- success: function(res){
1030
- save['dsl'] = null; // reload dsl and position under all circumstances
1031
- $('#main .tabbehind button').hide();
1032
- $('#dat_details').empty();
1033
-
1034
- document.title = "Untitled";
1035
- set_testset(res,exec);
1036
- },
1037
- complete: function() {
1038
- loading = false;
1039
- }
1040
- });
1041
- }
1042
- }// }}}
1043
- function load_modeltype() {// {{{
1044
- if (loading) return;
1045
- var url = $('body').attr('current-instance');
1046
- loading = true;
1047
-
1048
- var name = $("#modeltypes div.menuitem[data-selected=selected]").text();
1049
- $.ajax({
1050
- cache: false,
1051
- dataType: 'xml',
1052
- url: $('body').attr('current-templates') + "." + name + ".xml",
1053
- success: function(res){
1054
- $.ajax({
1055
- type: "PUT",
1056
- url: url + "/properties/attributes/modeltype",
1057
- data: ({value: name}),
1058
- success: function(){
1059
- set_testset(res,false);
1060
- },
1061
- error: report_failure
1062
- });
1063
- },
1064
- complete: function() {
1065
- loading = false;
1066
- }
1067
- });
1068
- }// }}}
1069
-
1070
- async function load_des(url,model) { //{{{
1071
- return $.ajax({
1072
- type: "PUT",
1073
- url: url + "/properties/description/",
1074
- contentType: 'text/xml',
1075
- headers: {
1076
- 'Content-ID': 'description',
1077
- 'CPEE-Event-Source': myid
1078
- },
1079
- data: model,
1080
- error: report_failure
1081
- });
1082
- } //}}}
1083
- async function load_testset_handlers(url,testset,vals) {// {{{
1084
- var promises = [];
1085
- $("testset > handlers > *",testset).each(async function(){
1086
- var han = this;
1087
- var suburl = $(han).attr('url');
1088
- if ($.inArray(suburl,vals) == -1) {
1089
- var inp = "url="+encodeURIComponent(suburl).replace(/~/,'%7E');
1090
- $("*",han).each(function(){
1091
- inp += "&topic=" + $(this).attr('topic');
1092
- inp += "&" + this.nodeName + "=" + $(this).text();
1093
- });
1094
- promises.push(
1095
- $.ajax({
1096
- type: "POST",
1097
- url: url + "/notifications/subscriptions/",
1098
- data: inp
1099
- })
1100
- )
1101
- }
1102
- });
1103
- return Promise.all(promises);
1104
- }// }}}
1105
-
1106
- function format_visual_add(what,cls) {//{{{
1107
- if (node_state[what] == undefined)
1108
- node_state[what] = {};
1109
- if (node_state[what][cls] == undefined)
1110
- node_state[what][cls] = 0;
1111
- node_state[what][cls] += 1;
1112
- format_visual_set(what);
1113
- }//}}}
1114
- function format_visual_remove(what,cls) {//{{{
1115
- if (node_state[what] == undefined)
1116
- node_state[what] = {};
1117
- if (node_state[what][cls] == undefined)
1118
- node_state[what][cls] = 0;
1119
- node_state[what][cls] -= 1;
1120
- if (node_state[what][cls] < 0)
1121
- node_state[what][cls] = 0;
1122
- format_visual_set(what);
1123
- }//}}}
1124
-
1125
- function scroll_into_view(what) { //{{{
1126
- var tcontainer = $('#graphcanvas').parent()[0];
1127
- if ($('g[element-id="' + what + '"]').length > 0) {
1128
- var telement = $('g[element-id="' + what + '"]')[0].getBBox().y;
1129
- if (tcontainer.scrollTop > telement) {
1130
- tcontainer.scroll( { top: telement - 5, behavior: 'smooth' } );
1131
- }
1132
- if (tcontainer.scrollTop + tcontainer.offsetHeight - 40 < telement) {
1133
- tcontainer.scroll( { top: telement - tcontainer.offsetHeight + 40, behavior: 'smooth' } );
1134
- }
1135
- }
1136
- } //}}}
1137
-
1138
- function format_visual_set(what) {//{{{
1139
- if (node_state[what] != undefined) {
1140
- if (node_state[what]['vote'] == undefined) node_state[what]['vote'] = 0;
1141
- if (node_state[what]['active'] == undefined) node_state[what]['active'] = 0;
1142
- if (node_state[what]['passive'] == undefined) node_state[what]['passive'] = 0;
1143
-
1144
- var votes = node_state[what]['vote'];
1145
- var actives = node_state[what]['active'];
1146
- var passives = node_state[what]['passive'];
1147
-
1148
- scroll_into_view(what);
1149
-
1150
- if (actives > 0 && votes > 0)
1151
- $('g[element-id="' + what + '"] .super .colon').each(function(a,b){
1152
- b.setAttribute('class','colon necessary');
1153
- });
1154
- else
1155
- $('g[element-id="' + what + '"] .super .colon').each(function(a,b){
1156
- b.setAttribute('class','colon');
1157
- });
1158
- if (actives > 0)
1159
- $('g[element-id="' + what + '"] .super .active').each(function(a,b){
1160
- b.setAttribute('class','active necessary');
1161
- var txt = b.childNodes[0];
1162
- txt.nodeValue = actives;
1163
- });
1164
- else
1165
- $('g[element-id="' + what + '"] .super .active').each(function(a,b){
1166
- b.setAttribute('class','active');
1167
- });
1168
- if (votes > 0)
1169
- $('g[element-id="' + what + '"] .super .vote').each(function(a,b){
1170
- b.setAttribute('class','vote necessary');
1171
- var txt = b.childNodes[0];
1172
- txt.nodeValue = votes;
1173
- });
1174
- else
1175
- $('g[element-id="' + what + '"] .super .vote').each(function(a,b){
1176
- b.setAttribute('class','vote');
1177
- });
1178
-
1179
- $.each(['#activity-' + what, 'g[element-id="' + what + '"] g'],function(i,t){
1180
- $(t).each(function(a,b){
1181
- if (actives > 0) vs = 'active';
1182
- else if (votes > 0) vs = 'vote';
1183
- else if (passives > 0) vs = 'passive';
1184
- else vs = '';
1185
- b.setAttribute("class",'activities ' + vs);
1186
- });
1187
- });
1188
- }
1189
-
1190
- }//}}}
1191
- function format_visual_clear() {//{{{
1192
- node_state = {};
1193
- $('.super .active').each(function(a,b){b.setAttribute('class','active');});
1194
- $('.super .passive').each(function(a,b){b.setAttribute('class','passive');});
1195
- $('.super .vote').each(function(a,b){b.setAttribute('class','vote');});
1196
- $('.super .colon').each(function(a,b){b.setAttribute('class','colon');});
1197
- $('.activities').each(function(a,b){
1198
- if (b.hasAttribute('selected')) {
1199
- b.setAttribute('class','activities selected');
1200
- } else {
1201
- b.setAttribute('class','activities');
1202
- }
1203
- });
1204
- $('#votes').empty();
1205
-
1206
- }//}}}
1207
- function format_visual_vote_clear() {//{{{
1208
- node_state = {};
1209
- $('.super .vote').each(function(a,b){b.setAttribute("class","vote");});
1210
- $("#votes").empty();
1211
- }//}}}
1212
-
1213
- function format_instance_pos() { //{{{
1214
- $(save['instance_pos']).each(function(){
1215
- var what = this.nodeName;
1216
- format_visual_add(what,save['state'] == 'running' ? 'active' : 'passive');
1217
- });
1218
- } //}}}
1219
-
1220
- function format_visual_forms() { //{{{
1221
- if (save['state'] != "ready" && save['state'] != "stopped") {
1222
- $(paths).each(function(k,e){
1223
- if ($(e).attr('contenteditable')) { $(e).attr('contenteditable','false'); }
1224
- $(e).attr('disabled','disable');
1225
- });
1226
- } else {
1227
- $(paths).each(function(k,e){
1228
- if ($(e).attr('contenteditable')) { $(e).attr('contenteditable','true'); }
1229
- $(e).removeAttr('disabled');
1230
- });
1231
- }
1232
- } //}}}
1233
-
1234
- function format_code(res,skim,lnums) {// {{{
1235
- try {
1236
- res = res.replace(/&/g,'&amp;');
1237
- res = res.replace(/</g,'&lt;');
1238
- res = res.replace(/>/g,'&gt;');
1239
- res = res.replace(/\t/g,' ');
1240
- res = res.replace(/\t/g,' ');
1241
- res = res.replace(/\r/g,'');
1242
- res = res.replace(/\s*$/gm,'');
1243
- res = res.replace(/^(\s*\n)*/m,'');
1244
-
1245
- if (res.match(/\S/)) {
1246
- if (skim) format_text_skim(res);
1247
-
1248
- var m;
1249
- var l = 1;
1250
- while (m = res.match(/^ +|^(?!<div style=)|^$/m)) {
1251
- m = m[0];
1252
- var tm = (m.length + 2) * 0.6 + 2 * 0.6 + 4 * 0.6;
1253
- var ln = (lnums ? $.sprintf("%03d",l) + ':&#160;' : '');
1254
- res = res.replace(/^ +|^(?!<div style=)|^$/m,"<div style='text-indent:-" + tm + "em;margin-left:" + tm + "em'>" + ln + "&#160;".repeat(m.length));
1255
- l++;
1256
- }
1257
- res = res.replace(/ /g," &#160;");
1258
- res = res.replace(/\n$/g,"\n<div>&#160;");
1259
- res = res.replace(/\n|$/g,"</div>\n");
1260
- }
1261
- } catch(e) {
1262
- alert(e.toString());
1263
- }
1264
- return res;
1265
- }// }}}
1266
- function format_text(res) {// {{{
1267
- res = res.replace(/&/g,'&amp;');
1268
- res = res.replace(/</g,'&lt;');
1269
- res = res.replace(/>/g,'&gt;');
1270
- return res;
1271
- }// }}}
1272
- function format_text_skim(res) {// {{{
1273
- var l = res.match(/^ */);
1274
- l = l[0].length;
1275
- res = res.replace(new RegExp("^ {" + l + "}",'mg'),'');
1276
- return res;
1277
- }// }}}
1278
-
1279
- function serialize_hash(ary) { //{{{
1280
- var xml = $X('<content/>');
1281
- $.each(ary,function(k,v) {
1282
- if (k.match(/^[a-zA-Z][a-zA-Z0-9_]*$/)) {
1283
- xml.append($X('<' + k + '>' + v + '</' + k + '>'));
1284
- }
1285
- });
1286
- return xml.serializeXML();
1287
- } //}}}
1288
-
1289
- function append_to_log(what,type,message) {//{{{
1290
- var d = new Date();
1291
- message = message.replace(/,\"/g,', "');
1292
- message = message.replace(/,\{/g,', {');
1293
- message = message.replace(/,\[/g,', [');
1294
- message = message.replace(/:\"/g,': "');
1295
- message = message.replace(/:\{/g,': {');
1296
- message = message.replace(/:\[/g,': [');
1297
- $("#dat_log").prepend("<tr><td class='fixed'><a title=\"" + d.strftime("[%d/%b/%Y %H:%M:%S]") + "\">D</a></td><td class='fixed'>&#160;-&#160;</td><td class='fixed'><a title=\"" + what + "\">T</a></td><td class='fixed'>&#160;-&#160;</td><td class='fixed'>" + type + "</td><td class='fixed'>&#160;-&#160;</td><td class='long'>" + message + "</td></tr>");
1298
- var dle = $("#dat_log").children();
1299
- if (dle.length > 100) {
1300
- dle.slice(100).each((k,ele) => {
1301
- $(ele).remove();
1302
- });
1303
- }
1304
- }//}}}
1305
-
1306
- function report_failure(){}
1307
-
1308
- function ui_pos(e,bl) {
1309
- var url = $('body').attr('current-instance');
1310
- var coll = [];
1311
- $('g.element.primitive > g.activities.active, g.element.primitive > g.activities.passive').each(function(a,b){
1312
- coll.push($(b).parent().attr('element-id'));
1313
- });
1314
- coll = bl(coll);
1315
- var vals = "";
1316
- $(coll).each(function(k,ele){
1317
- vals += "<" + ele + ">at</" + ele + ">";
1318
- });
1319
- vals = "<positions xmlns='http://cpee.org/ns/properties/2.0'>" + vals + "</positions>";
1320
- $.ajax({
1321
- type: "PUT",
1322
- url: url + "/properties/positions/",
1323
- contentType: 'application/xml',
1324
- headers: {
1325
- 'Content-ID': 'positions',
1326
- 'CPEE-Event-Source': myid
1327
- },
1328
- data: vals,
1329
- success: monitor_instance_pos,
1330
- error: report_failure
1331
- });
1332
- }
1333
- function del_ui_pos(e) {
1334
- ui_pos(e,function(coll){
1335
- coll.splice(coll.indexOf($(e).attr('id')),1);
1336
- return coll;
1337
- });
1338
- }
1339
- function add_ui_pos(e) {
1340
- ui_pos(e,function(coll){
1341
- coll.push($(e).attr('id'));
1342
- return coll;
1343
- });
1344
- }