omf_web 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. data/.gitignore +0 -1
  2. data/README.md +8 -2
  3. data/doc/screenshot.png +0 -0
  4. data/example/{basic → NOT_WORKING/basic}/hello-world-wired.rb +0 -0
  5. data/example/{basic → NOT_WORKING/basic}/visualisation.yml +0 -0
  6. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklynDemo.sq3 +0 -0
  7. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_gps.dat +0 -0
  8. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_server.rb +0 -0
  9. data/example/{brooklyn → NOT_WORKING/brooklyn}/brooklyn_wimax.dat +0 -0
  10. data/example/{brooklyn → NOT_WORKING/brooklyn}/sql_source.rb +0 -0
  11. data/example/{code → NOT_WORKING/code}/code_server.rb +0 -0
  12. data/example/{frisbee → NOT_WORKING/frisbee}/data_sources/parse_log.rb +0 -0
  13. data/example/{frisbee → NOT_WORKING/frisbee}/data_sources/pxe_slice-2012-06-02t02.25.00-04.00.log +0 -0
  14. data/example/{frisbee → NOT_WORKING/frisbee}/progress_chart.yaml +0 -0
  15. data/example/{frisbee → NOT_WORKING/frisbee}/progress_tab.yaml +0 -0
  16. data/example/{frisbee → NOT_WORKING/frisbee}/progress_table.yaml +0 -0
  17. data/example/{frisbee → NOT_WORKING/frisbee}/viz_server.rb +0 -0
  18. data/example/{gec12 → NOT_WORKING/gec12}/gec12-53.rb +0 -0
  19. data/example/{gec12 → NOT_WORKING/gec12}/gec12_demo.sq3 +0 -0
  20. data/example/{gec12 → NOT_WORKING/gec12}/gec12_demo_server.rb +0 -0
  21. data/example/{gec12 → NOT_WORKING/gec12}/visualization.rb +0 -0
  22. data/example/{incoming → NOT_WORKING/incoming}/ofpu_barchart_widget.yaml +0 -0
  23. data/example/{log → NOT_WORKING/log}/log_config.xml +0 -0
  24. data/example/{log → NOT_WORKING/log}/log_server.rb +0 -0
  25. data/example/{network → NOT_WORKING/network}/flow_tab.yaml +0 -0
  26. data/example/{network → NOT_WORKING/network}/network_server.rb +0 -0
  27. data/example/{text → NOT_WORKING/text}/test.md +0 -0
  28. data/example/{text → NOT_WORKING/text}/test.rb +0 -0
  29. data/example/{wimax → NOT_WORKING/wimax}/downlink.yaml +0 -0
  30. data/example/{wimax → NOT_WORKING/wimax}/power.yaml +0 -0
  31. data/example/{wimax → NOT_WORKING/wimax}/snapshot.db +0 -0
  32. data/example/{wimax → NOT_WORKING/wimax}/snapshot.sql +0 -0
  33. data/example/{wimax → NOT_WORKING/wimax}/test.rb +0 -0
  34. data/example/{wimax → NOT_WORKING/wimax}/uplink.yaml +0 -0
  35. data/example/{wimax → NOT_WORKING/wimax}/viz_server.rb +0 -0
  36. data/example/demo/data_sources/mobile_network.rb +3 -0
  37. data/example/demo/data_sources/static_network.rb +54 -0
  38. data/example/demo/widgets/charts_tab.yaml +21 -16
  39. data/example/demo/widgets/linked_graphs_tab.yaml +95 -0
  40. data/example/demo/widgets/mobile_network_widget.yaml +1 -1
  41. data/example/demo/widgets/pie_chart_widget.yaml +1 -1
  42. data/lib/omf-web/config.ru +2 -2
  43. data/lib/omf-web/data_source_proxy.rb +81 -19
  44. data/lib/omf-web/rack/websocket_handler.rb +77 -23
  45. data/lib/omf-web/theme/abstract_page.rb +43 -26
  46. data/lib/omf-web/theme/bright/code_renderer.rb +1 -1
  47. data/lib/omf-web/theme/bright/page.rb +1 -0
  48. data/lib/omf-web/theme/bright/tabbed_renderer.rb +7 -0
  49. data/lib/omf-web/version.rb +7 -0
  50. data/lib/omf-web/widget/data_widget.rb +38 -46
  51. data/lib/omf-web/widget/layout/stacked_layout.rb +2 -1
  52. data/lib/omf-web/widget/layout/tabbed_layout.rb +1 -2
  53. data/{MARUKU-LICENSE → lib/omf-web/widget/text/maruku/MARUKU-LICENSE} +0 -0
  54. data/lib/{maruku → omf-web/widget/text/maruku}/helpers.rb +0 -0
  55. data/lib/{maruku → omf-web/widget/text/maruku}/input/parse_block.rb +0 -0
  56. data/lib/{maruku → omf-web/widget/text/maruku}/output/to_html.rb +26 -21
  57. data/lib/omf-web/widget/text/maruku.rb +5 -0
  58. data/omf_web.gemspec +2 -1
  59. data/share/htdocs/{js → UNUSED}/log/table.js +0 -0
  60. data/share/htdocs/{css → graph/css}/graph.css +0 -0
  61. data/share/htdocs/{image/graph → graph/img}/bar_chart.png +0 -0
  62. data/share/htdocs/{image/graph → graph/img}/donut_chart.png +0 -0
  63. data/share/htdocs/{image/graph → graph/img}/funnel.png +0 -0
  64. data/share/htdocs/{image/graph → graph/img}/info.png +0 -0
  65. data/share/htdocs/{image/graph → graph/img}/line_chart.png +0 -0
  66. data/share/htdocs/{image/graph → graph/img}/line_chart_fill.png +0 -0
  67. data/share/htdocs/{image/graph → graph/img}/misc.png +0 -0
  68. data/share/htdocs/{image/graph → graph/img}/overview.png +0 -0
  69. data/share/htdocs/{image/graph → graph/img}/pie_chart.png +0 -0
  70. data/share/htdocs/{image/graph → graph/img}/scatter_plot.png +0 -0
  71. data/share/htdocs/{image/graph → graph/img}/stacked_bar_chart.png +0 -0
  72. data/share/htdocs/{image/graph → graph/img}/stacked_line_chart.png +0 -0
  73. data/share/htdocs/{image/graph → graph/img}/table.png +0 -0
  74. data/share/htdocs/{js/graph → graph/js}/abstract_chart.js +1 -1
  75. data/share/htdocs/{js/graph → graph/js}/abstract_nv_chart.js +8 -13
  76. data/share/htdocs/{js/graph → graph/js}/abstract_widget.js +9 -16
  77. data/share/htdocs/{js/graph → graph/js}/axis.js +1 -1
  78. data/share/htdocs/{js/graph → graph/js}/barchart.js +2 -2
  79. data/share/htdocs/{js/graph → graph/js}/code_mirror.js +1 -5
  80. data/share/htdocs/{js/graph → graph/js}/discrete_bar_chart.js +1 -1
  81. data/share/htdocs/{js/graph → graph/js}/histogram2.js +1 -1
  82. data/share/htdocs/{js/graph → graph/js}/holt_winters_chart.js +1 -1
  83. data/share/htdocs/{js/graph → graph/js}/line_chart3.js +1 -1
  84. data/share/htdocs/{js/graph → graph/js}/line_chart_with_focus.js +1 -1
  85. data/share/htdocs/{js/graph → graph/js}/map2.js +1 -1
  86. data/share/htdocs/{js/graph → graph/js}/multi_barchart.js +1 -1
  87. data/share/htdocs/graph/js/network2.js +412 -0
  88. data/share/htdocs/{js/graph → graph/js}/pie_chart2.js +1 -1
  89. data/share/htdocs/{js/graph → graph/js}/scatter_plot.js +1 -1
  90. data/share/htdocs/{js/graph → graph/js}/table2.js +17 -20
  91. data/share/htdocs/js/data_source2.js +187 -60
  92. data/share/htdocs/js/require3.js +38 -57
  93. data/share/htdocs/theme/bright/css/bright.css +4 -4
  94. data/share/htdocs/vendor/jquery/jquery.js +9404 -0
  95. data/share/htdocs/vendor/osa/LICENSE.txt +11 -0
  96. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_arrow_green_left.svg +0 -0
  97. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_arrow_yellow_right.svg +0 -0
  98. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_awareness.svg +0 -0
  99. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_camera-web.svg +0 -0
  100. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_cloud.svg +0 -0
  101. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_contract.svg +0 -0
  102. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_database.svg +0 -0
  103. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_desktop.svg +0 -0
  104. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_desktop_imac.svg +0 -0
  105. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-music.svg +0 -0
  106. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-scanner.svg +0 -0
  107. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-usb-wifi.svg +0 -0
  108. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-usb.svg +0 -0
  109. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_device-wireless-router.svg +0 -0
  110. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_disposal.svg +0 -0
  111. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_drive-harddisk.svg +0 -0
  112. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_drive-optical.svg +0 -0
  113. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_firewall.svg +0 -0
  114. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_home.svg +0 -0
  115. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_hub.svg +0 -0
  116. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_iPhone.svg +0 -0
  117. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_drive.svg +0 -0
  118. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_plc.svg +0 -0
  119. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_ics_thermometer.svg +0 -0
  120. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_id_card.svg +0 -0
  121. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_image-generic.svg +0 -0
  122. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_laptop.svg +0 -0
  123. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_lifecycle.svg +0 -0
  124. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_lightning.svg +0 -0
  125. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-flash.svg +0 -0
  126. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-optical.svg +0 -0
  127. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_media-tape.svg +0 -0
  128. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_mobile_pda.svg +0 -0
  129. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_padlock.svg +0 -0
  130. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_printer.svg +0 -0
  131. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server.svg +0 -0
  132. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_application.svg +0 -0
  133. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_database.svg +0 -0
  134. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_directory.svg +0 -0
  135. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_distribution.svg +0 -0
  136. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_file.svg +0 -0
  137. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_gateway.svg +0 -0
  138. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_identity.svg +0 -0
  139. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_mail.svg +0 -0
  140. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_media.svg +0 -0
  141. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_monitor.svg +0 -0
  142. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_proxy.svg +0 -0
  143. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_terminal.svg +0 -0
  144. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_server_web.svg +0 -0
  145. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-branch.svg +0 -0
  146. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-factory.svg +0 -0
  147. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-head-office.svg +0 -0
  148. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_site-neighbourhood.svg +0 -0
  149. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_audit.svg +0 -0
  150. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_black_hat.svg +0 -0
  151. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue.svg +0 -0
  152. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_security_specialist.svg +0 -0
  153. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_sysadmin.svg +0 -0
  154. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_tester.svg +0 -0
  155. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_blue_tie.svg +0 -0
  156. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green.svg +0 -0
  157. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_architect.svg +0 -0
  158. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_business_manager.svg +0 -0
  159. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_developer.svg +0 -0
  160. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_operations.svg +0 -0
  161. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_project_manager.svg +0 -0
  162. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_service_manager.svg +0 -0
  163. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_green_warning.svg +0 -0
  164. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_user_large_group.svg +0 -0
  165. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_users_blue_green.svg +0 -0
  166. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_vpn.svg +0 -0
  167. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_warning.svg +0 -0
  168. data/share/htdocs/{svg/osa → vendor/osa/svg}/osa_wireless_network.svg +0 -0
  169. data/share/htdocs/{image → vendor/unknown/image}/.DS_Store +0 -0
  170. data/share/htdocs/{image → vendor/unknown/image}/add_icon.gif +0 -0
  171. data/share/htdocs/{image → vendor/unknown/image}/alertbad_icon.gif +0 -0
  172. data/share/htdocs/{image → vendor/unknown/image}/alertgood_icon.gif +0 -0
  173. data/share/htdocs/{image → vendor/unknown/image}/back_disabled.jpg +0 -0
  174. data/share/htdocs/{image → vendor/unknown/image}/back_disabled.png +0 -0
  175. data/share/htdocs/{image → vendor/unknown/image}/back_enabled.jpg +0 -0
  176. data/share/htdocs/{image → vendor/unknown/image}/back_enabled.png +0 -0
  177. data/share/htdocs/{image → vendor/unknown/image}/back_enabled_hover.jpg +0 -0
  178. data/share/htdocs/{image → vendor/unknown/image}/back_enabled_hover.png +0 -0
  179. data/share/htdocs/{image → vendor/unknown/image}/bottom-bg.gif +0 -0
  180. data/share/htdocs/{image → vendor/unknown/image}/forward_disabled.jpg +0 -0
  181. data/share/htdocs/{image → vendor/unknown/image}/forward_disabled.png +0 -0
  182. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled.jpg +0 -0
  183. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled.png +0 -0
  184. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled_hover.jpg +0 -0
  185. data/share/htdocs/{image → vendor/unknown/image}/forward_enabled_hover.png +0 -0
  186. data/share/htdocs/{image → vendor/unknown/image}/icon-remove.gif +0 -0
  187. data/share/htdocs/{image → vendor/unknown/image}/indicator.gif +0 -0
  188. data/share/htdocs/{image → vendor/unknown/image}/laptop.png +0 -0
  189. data/share/htdocs/{image → vendor/unknown/image}/logo-bottom.gif +0 -0
  190. data/share/htdocs/{image → vendor/unknown/image}/nav-tab-arrow.gif +0 -0
  191. data/share/htdocs/{image → vendor/unknown/image}/norbit_big.gif +0 -0
  192. data/share/htdocs/{image → vendor/unknown/image}/norbit_clipart.png +0 -0
  193. data/share/htdocs/{image → vendor/unknown/image}/progress_bar.gif +0 -0
  194. data/share/htdocs/{image → vendor/unknown/image}/right-bg.gif +0 -0
  195. data/share/htdocs/{image → vendor/unknown/image}/sort_asc.png +0 -0
  196. data/share/htdocs/{image → vendor/unknown/image}/sort_asc_disabled.png +0 -0
  197. data/share/htdocs/{image → vendor/unknown/image}/sort_both.png +0 -0
  198. data/share/htdocs/{image → vendor/unknown/image}/sort_desc.png +0 -0
  199. data/share/htdocs/{image → vendor/unknown/image}/sort_desc_disabled.png +0 -0
  200. data/share/htdocs/{image → vendor/unknown/image}/spinner.gif +0 -0
  201. data/share/htdocs/{svg → vendor/unknown/svg}/ap.svg +0 -0
  202. data/share/htdocs/{svg → vendor/unknown/svg}/router.svg +0 -0
  203. metadata +198 -216
  204. data/example/demo/widgets/dashboard_tab.yaml +0 -28
  205. data/example/demo/widgets/download_tab.yaml +0 -42
  206. data/example/demo/widgets/edit_tab.yaml +0 -20
  207. data/example/demo/widgets/generator_tab.yaml +0 -12
  208. data/lib/omf-oml/endpoint.rb +0 -175
  209. data/lib/omf-oml/indexed_table.rb +0 -57
  210. data/lib/omf-oml/network.rb +0 -413
  211. data/lib/omf-oml/oml_tuple.rb +0 -62
  212. data/lib/omf-oml/schema.rb +0 -191
  213. data/lib/omf-oml/sequel/sequel_server.rb +0 -412
  214. data/lib/omf-oml/sql_row.rb +0 -302
  215. data/lib/omf-oml/sql_source.rb +0 -131
  216. data/lib/omf-oml/table.rb +0 -131
  217. data/lib/omf-oml/tuple.rb +0 -97
  218. data/lib/omf_oml.rb +0 -4
  219. data/share/htdocs/css/coderay.css +0 -127
  220. data/share/htdocs/css/ie.css +0 -40
  221. data/share/htdocs/css/lightbox.css +0 -62
  222. data/share/htdocs/css/scaffold.css +0 -74
  223. data/share/htdocs/css/screen.css +0 -1313
  224. data/share/htdocs/css/search.css +0 -102
  225. data/share/htdocs/css/table.css +0 -538
  226. data/share/htdocs/css/table2.css +0 -191
  227. data/share/htdocs/css/welcome.css +0 -103
  228. data/share/htdocs/css/wfob.css +0 -171
  229. data/share/htdocs/css/wshow.css +0 -69
  230. data/share/htdocs/gec9_demo.html +0 -39
  231. data/share/htdocs/images +0 -1
  232. data/share/htdocs/js/graph/histogram.js +0 -229
  233. data/share/htdocs/js/graph/line_chart.js +0 -342
  234. data/share/htdocs/js/graph/line_chart2.js +0 -232
  235. data/share/htdocs/js/graph/line_chart_fc.js +0 -94
  236. data/share/htdocs/js/graph/map.js +0 -85
  237. data/share/htdocs/js/graph/network.js +0 -591
  238. data/share/htdocs/js/graph/network2.js +0 -318
  239. data/share/htdocs/js/graph/pie_chart.js +0 -130
  240. data/share/htdocs/js/graph/table.js +0 -94
  241. data/share/htdocs/js/require2.js +0 -1998
  242. data/share/htdocs/js/timelines.js +0 -101
  243. data/share/htdocs/stylesheet/grid.css +0 -31
@@ -1,318 +0,0 @@
1
- L.provide('OML.network2', ["graph/abstract_chart", "#OML.abstract_chart", "/resource/vendor/d3/d3.js"], function () {
2
-
3
-
4
-
5
- OML['network2'] = OML.abstract_chart.extend({
6
- decl_properties: {
7
- nodes: [['key', 'key', {property: 'id'}],
8
- ['radius', 'int', 30],
9
- ['fill_color', 'color', 'blue'],
10
- ['stroke_width', 'int', 1],
11
- ['stroke_color', 'color', 'black'],
12
- ['x', 'int', 10],
13
- ['y', 'int', 10]
14
- ],
15
- links: [['key', 'key', {property: 'id'}],
16
- ['stroke_width', 'int', 2],
17
- ['stroke_color', 'color', 'black'],
18
- ['stroke_fill', 'color', 'blue'],
19
- ['from', 'index', {key: 'from_id', join_stream: 'nodes', join_key: 'id'}],
20
- ['to', 'index', {key: 'to_id', join_stream: 'nodes'}] // join_key: 'id' ... default
21
- ]
22
- },
23
-
24
-
25
- configure_base_layer: function(vis) {
26
- var ca = this.widget_area;
27
-
28
- this.graph_layer = vis.append("svg:g")
29
- .attr("transform", "translate(0, " + ca.h + ")")
30
- ;
31
- this.legend_layer = vis.append("svg:g");
32
- },
33
-
34
- base_css_class: 'oml-network',
35
-
36
- // Find the appropriate data source and bind to it
37
- //
38
- init_data_source: function() {
39
- var o = this.opts;
40
- var sources = o.data_sources;
41
- var self = this;
42
-
43
- if (! (sources instanceof Array)) {
44
- throw "Expected an array"
45
- }
46
- if (sources.length == 1) {
47
- // Check if the source name is 'default' and we can find
48
- // a _links and _nodes source
49
- var s = sources[0];
50
- if (s.name == 'default') {
51
- // ok, lets expand it
52
- var ss = s.stream;
53
- if (typeof(ss) != 'object') {
54
- ss = { name: ss };
55
- }
56
- var prefix = ss.name;
57
- var sn = {}; for (var p in ss) { sn[p] = ss[p]; }; sn.name = prefix + '_nodes';
58
- var sl = {}; for (var p in ss) { sl[p] = ss[p]; }; sl.name = prefix + '_links';
59
- sources = [
60
- {name: 'nodes', stream: sn},
61
- {name: 'links', stream: sl},
62
- ]
63
- }
64
- }
65
- if (sources.length != 2) {
66
- throw "Expected TWO data source, one for nodes and one for links"
67
- }
68
- var dsh = this.data_source = {};
69
- _.map(sources, function(s) {
70
- dsh[s.name] = self.init_single_data_source(s);
71
- });
72
- if (dsh.links == undefined || dsh.nodes == undefined) {
73
- throw "Data sources need to be named 'links' and 'nodes'. Missing one or both.";
74
- }
75
- },
76
-
77
- process_schema: function() {
78
- this.schema = {
79
- nodes: this.process_single_schema(this.data_source.nodes),
80
- links: this.process_single_schema(this.data_source.links)
81
- };
82
-
83
- var om = this.opts.mapping;
84
- if (om.links == undefined || om.nodes == undefined) {
85
- throw "Missing mapping instructions in 'options' for either 'links' or 'nodes', or both.";
86
- }
87
- this.mapping = {
88
- nodes: this.process_single_mapping('nodes', om.nodes, this.decl_properties.nodes),
89
- links: this.process_single_mapping('links', om.links, this.decl_properties.links)
90
- };
91
- },
92
-
93
- /*
94
- * Return schema for +stream+.
95
- */
96
- schema_for_stream: function(stream) {
97
- var schema = this.schema[stream];
98
- return schema;
99
- },
100
-
101
- data_source_for_stream: function(stream) {
102
- var ds = this.data_source[stream];
103
- if (ds == undefined) {
104
- throw "Unknown data_source '" + stream + "'.";
105
- }
106
- return ds;
107
- },
108
-
109
- update: function() {
110
-
111
- var ldata = this.data_source.links.events;
112
- var ndata = this.data_source.nodes.events;
113
-
114
- this.redraw({links: ldata, nodes: ndata});
115
- },
116
-
117
- redraw: function(data) {
118
- var self = this;
119
- var o = this.opts;
120
- var mapping = this.mapping; //o.mapping || {};
121
- var ca = this.widget_area;
122
-
123
- var x = function(v) {
124
- var x = v * ca.w + ca.x;
125
- var x = v * ca.w;
126
- return x;
127
- };
128
- var y = function(v) {
129
- var y = -1 * (v * ca.h + ca.y);
130
- var y = -1 * (v * ca.h);
131
- return y;
132
- };
133
-
134
- var vis = this.base_layer;
135
- var lmapping = mapping.links;
136
- var nmapping = mapping.nodes;
137
- var iline_f = d3.svg.line().interpolate('basis');
138
-
139
- // curved line
140
- var line_f = function(d) {
141
- var a = 0.2;
142
- var b = 0.3;
143
- var o = 30;
144
-
145
- var from = lmapping.from(d);
146
- var to = lmapping.to(d);
147
-
148
- var x1 = x(nmapping.x(from));
149
- var y1 = y(nmapping.y(from));
150
- var x3 = x(nmapping.x(to));
151
- var y3 = y(nmapping.y(to));
152
-
153
- var dx = x3 - x1;
154
- var dy = y3 - y1;
155
- var l = Math.sqrt(dx * dx + dy * dy);
156
-
157
- var mx = x1 + a * dx;
158
- var my = y1 + a * dy;
159
- var x2 = mx - (dy * o / l)
160
- var y2 = my + (dx * o / l);
161
-
162
- return iline_f([[x1, y1], [x2, y2], [x3, y3]]);
163
- };
164
-
165
- var ldata = data.links
166
- var link2 = this.graph_layer.selectAll("path.link")
167
- .data(d3.values(ldata))
168
- //.each(position) // update existing markers
169
- .style("stroke", lmapping.stroke_color)
170
- .style("stroke-width", lmapping.stroke_width)
171
- .attr("d", line_f)
172
- .enter().append("svg:path")
173
- .attr("class", "link")
174
- .style("stroke", lmapping.stroke_color)
175
- .style("stroke-width", lmapping.stroke_width)
176
- .attr("fill", "none")
177
- .attr("d", line_f)
178
- .on("mouseover", function(d) {
179
- var id = lmapping.key(d);
180
- self.on_highlighted({'elements': [{'id': id, 'type': 'link'}]});
181
- })
182
- .on("mouseout", function(d) {
183
- var id = lmapping.key(d);
184
- self.on_dehighlighted({'elements': [{'id': id, 'type': 'link'}]});
185
- })
186
- ;
187
-
188
- var ndata = data.nodes;
189
- var node = this.graph_layer.selectAll("circle.node")
190
- .data(d3.values(ndata))
191
- .attr("cx", function(d) { return x(nmapping.x(d)) })
192
- .attr("cy", function(d) { return y(nmapping.y(d)) })
193
- .attr("r", nmapping.radius)
194
- .style("fill", nmapping.fill_color)
195
- .style("stroke", nmapping.stroke_color)
196
- .style("stroke-width", nmapping.stroke_width)
197
- .enter().append("svg:circle")
198
- .attr("class", "node")
199
- .attr("cx", function(d) { return x(nmapping.x(d)) })
200
- .attr("cy", function(d) { return y(nmapping.y(d)) })
201
- .attr("r", nmapping.radius)
202
- .style("fill", nmapping.fill_color)
203
- .style("stroke", nmapping.stroke_color)
204
- .style("stroke-width", nmapping.stroke_width)
205
- .attr("fixed", true)
206
- //.call(force.drag)
207
- .on("mouseover", function(d) {
208
- var id = nmapping.key(d);
209
- self.on_highlighted({'elements': [{'id': id, 'type': 'node'}]});
210
- })
211
- .on("mouseout", function(d) {
212
- var id = nmapping.key(d);
213
- self.on_dehighlighted({'elements': [{'id': id, 'type': 'node'}]});
214
- })
215
- .transition()
216
- .attr("r", nmapping.radius)
217
- .delay(0)
218
- ;
219
- },
220
-
221
- // this.init_svg = function(w, h) {
222
- // var opts = this.opts;
223
- //
224
- // //if (opts.svg) return opts.svg;
225
- //
226
- // var base_el = opts.base_el || "body";
227
- // if (typeof(base_el) == "string") base_el = d3.select(base_el);
228
- // var vis = opts.svg = base_el.append("svg:svg")
229
- // .attr("width", w)
230
- // .attr("height", h)
231
- // .attr('class', 'oml-network');
232
- // return vis;
233
- // }
234
-
235
- on_highlighted: function(evt) {
236
- var els = evt.elements;
237
- var links = _.filter(els, function(el) { return el.type == 'link'});
238
- if (links.length > 0) { this._on_links_highlighted(links); }
239
- var nodes = _.filter(els, function(el) { return el.type == 'node'});
240
- if (nodes.length > 0) { this._on_nodes_highlighted(nodes); }
241
-
242
- if (evt.source == null) {
243
- evt.source = this;
244
- OHUB.trigger("graph.highlighted", evt);
245
- }
246
- },
247
-
248
- on_dehighlighted: function(evt) {
249
- this._on_links_dehighlighted();
250
- this._on_nodes_dehighlighted();
251
-
252
- if (evt.source == null) {
253
- evt.source = this;
254
- OHUB.trigger("graph.dehighlighted", evt);
255
- }
256
- },
257
-
258
- _on_nodes_highlighted: function(nodes) {
259
- var names = _.map(nodes, function(el) { return el.id});
260
- var vis = this.base_layer;
261
- var key_f = this.mapping.nodes.key;
262
- this.graph_layer.selectAll("circle.node")
263
- .filter(function(d) {
264
- var key = key_f(d);
265
- return ! _.include(names, key);
266
- })
267
- .transition()
268
- .style("stroke", "lightgray")
269
- .style("fill", "rgb(240,240,240)")
270
- .delay(0)
271
- .duration(300);
272
- },
273
-
274
- _on_nodes_dehighlighted: function() {
275
- var vis = this.base_layer;
276
- var nmapping = this.mapping.nodes;
277
- this.graph_layer.selectAll("circle.node")
278
- .transition()
279
- .style("fill", nmapping.fill_color)
280
- .style("stroke", nmapping.stroke_color)
281
- .delay(0)
282
- .duration(300);
283
- },
284
-
285
- _on_links_highlighted: function(links) {
286
- var names = _.map(links, function(el) { return el.id});
287
- var vis = this.base_layer;
288
- var key_f = this.mapping.links.key;
289
- this.graph_layer.selectAll("path.link")
290
- .filter(function(d) {
291
- var key = key_f(d);
292
- return ! _.include(names, key);
293
- })
294
- .transition()
295
- .style("opacity", 0.1)
296
- .delay(0)
297
- .duration(300);
298
- },
299
-
300
- _on_links_dehighlighted: function() {
301
- var vis = this.base_layer;
302
- this.graph_layer.selectAll("path.link")
303
- .transition()
304
- .style("opacity", 1.0)
305
- .delay(0)
306
- .duration(300)
307
- }
308
-
309
- })
310
- })
311
-
312
- /*
313
- Local Variables:
314
- mode: Javascript
315
- tab-width: 2
316
- indent-tabs-mode: nil
317
- End:
318
- */
@@ -1,130 +0,0 @@
1
- L.provide('OML.pie_chart', ["graph/abstract_chart", "#OML.abstract_chart"], function () {
2
-
3
- var o = OML;
4
-
5
-
6
- OML.pie_chart = OML.abstract_chart.extend({
7
- decl_properties: [
8
- ['value', 'key', {property: 'value'}],
9
- // ['group_by', 'key', {property: 'id', optional: true}],
10
- ['stroke_width', 'int', 2],
11
- ['stroke_color', 'color', 'white'],
12
- ['fill_color', 'color', 'category20()'],
13
- ['label', 'key', {optional: true}]
14
- ],
15
-
16
- defaults: function() {
17
- return this.deep_defaults({
18
- inner_radius: 0.4 // size of donought hole in the middle
19
- }, OML.pie_chart.__super__.defaults.call(this));
20
- },
21
-
22
- configure_base_layer: function(vis) {
23
- this.legend_layer = vis.append("svg:g");
24
- this.chart_layer = vis.append("svg:g");
25
- },
26
-
27
- base_css_class: 'oml-pie-chart',
28
-
29
- redraw: function(data) {
30
- var self = this;
31
- var o = this.opts;
32
- var ca = this.widget_area;
33
- var m = this.mapping;
34
- var w = ca.w,
35
- h = ca.h,
36
- r = Math.min(w, h) / 2;
37
-
38
- var arc = d3.svg.arc().outerRadius(r);
39
- var i_r = o.inner_radius;
40
- if (i_r > 0) {
41
- if (i_r < 1) {
42
- i_r = i_r * r; // fractional
43
- }
44
- arc.innerRadius(i_r);
45
- }
46
- var sa = arc.startAngle();
47
-
48
- var self = this;
49
-
50
- var vis = this.chart_layer
51
- .data([data])
52
- ;
53
- var arcs = vis.selectAll("g.arc")
54
- .data(d3.layout.pie().value(m.value))
55
- .enter().append("g")
56
- .attr("class", "arc")
57
- //.attr("transform", "translate(" + (r + ca.x) + "," + (r + ca.ty) + ")");
58
- .attr("transform", "translate(" + (w / 2 + ca.x) + "," + (h / 2 + ca.ty) + ")");
59
-
60
- arcs.append("path")
61
- .attr("fill", function(d, i) {
62
- return m.fill_color(i);
63
- })
64
- .attr("d", arc)
65
- .attr("stroke", m.stroke_color)
66
- .attr('stroke-width', m.stroke_width)
67
- .on("mouseover", function(data) {
68
- self.on_highlighted({'elements': [{'id': data.value}]});
69
- })
70
- .on("mouseout", function() {
71
- self.on_dehighlighted({});
72
- })
73
- ;
74
-
75
- var text_f = m.label;
76
- if (m.label) {
77
- text_f = function(d) { return m.label(d.data); };
78
- } else {
79
- text_f = function(d) { return d.value.toFixed(2); };
80
- }
81
- arcs.append("text")
82
- .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; })
83
- .attr("dy", ".35em")
84
- .attr("text-anchor", "middle")
85
- .attr("display", function(d) { return d.value > .15 ? null : "none"; })
86
- .text(text_f);
87
- },
88
-
89
- on_highlighted: function(evt) {
90
- var els = evt.elements;
91
- var piece_id = els[0].id
92
- var vis = this.chart_layer;
93
- vis.selectAll("path")
94
- .filter(function(d) {
95
- return d.value != piece_id;
96
- })
97
- .transition()
98
- .style("opacity", 0.3)
99
- .delay(0)
100
- .duration(300)
101
- ;
102
- if (evt.source == null) {
103
- evt.source = this;
104
- OHUB.trigger("graph.highlighted", evt);
105
- }
106
- },
107
-
108
- on_dehighlighted: function(evt) {
109
- var vis = this.chart_layer;
110
- vis.selectAll("path")
111
- .transition()
112
- .style("opacity", 1.0)
113
- .delay(0)
114
- .duration(300)
115
- if (evt.source == null) {
116
- evt.source = this;
117
- OHUB.trigger("graph.dehighlighted", evt);
118
- }
119
- },
120
-
121
- })
122
- })
123
-
124
- /*
125
- Local Variables:
126
- mode: Javascript
127
- tab-width: 2
128
- indent-tabs-mode: nil
129
- End:
130
- */
@@ -1,94 +0,0 @@
1
-
2
-
3
- L.provide('OML.table', ["table2.css", ["/resource/vendor/jquery/jquery.js", "/resource/vendor/jquery/jquery.dataTables.js"]], function () {
4
- if (typeof(OML) == "undefined") {
5
- OML = {};
6
- }
7
-
8
- OML['table'] = Backbone.Model.extend({
9
-
10
- initialize: function(opts) {
11
- this.opts = opts;
12
-
13
- /* create table template */
14
- var base_el = opts.base_el || '#table'
15
-
16
- this.init_data_source();
17
-
18
- var tid = base_el.substr(1) + "_t";
19
- var tbid = base_el.substr(1) + "_tb";
20
- var h = "<table id='" + tid;
21
- h += "' cellpadding='0' cellspacing='0' border='0' class='oml_table' width='100%'>";
22
- h += "<thead><tr>";
23
-
24
- var schema = this.schema = this.data_source.schema; //this.process_single_schema(this.data_source);
25
- if (schema) {
26
- for (var i = 0; i < schema.length; i++) {
27
- var col = schema[i];
28
- h += "<th class='oml_c" + i + " oml_" + col.name + "'>" + col.name + "</th>";
29
- }
30
- }
31
- h += "</tr></thead>";
32
- h += "<tbody id='" + tbid + "'></tbody>";
33
- h += "</table>";
34
- $(base_el).prepend(h);
35
- this.table_el = $('#' + tid);
36
- this.tbody_el = $('#' + tbid);
37
-
38
- this.dataTable = this.table_el.dataTable({
39
- "sPaginationType": "full_numbers"
40
- });
41
-
42
- this.update();
43
- // var data = opts.data;
44
- // if (data) this.update(data);
45
- },
46
-
47
- // Find the appropriate data source and bind to it
48
- //
49
- init_data_source: function() {
50
- var o = this.opts;
51
- var sources = o.data_sources;
52
- var self = this;
53
-
54
- if (! (sources instanceof Array)) {
55
- throw "Expected an array"
56
- }
57
- if (sources.length != 1) {
58
- throw "Can only process a SINGLE source"
59
- }
60
- var ds = this.data_source = OML.data_sources[sources[0].stream];
61
- if (o.dynamic == true) {
62
- ds.on_changed(function(evt) {
63
- self.update();
64
- });
65
- }
66
-
67
- },
68
-
69
-
70
- update: function() {
71
- var data_source = this.data_source;
72
- if ((this.data = data_source.events) == null) {
73
- throw "Missing events array in data source"
74
- }
75
- this.render_rows(this.data, false);
76
- },
77
-
78
-
79
- /* Add rows */
80
- render_rows: function(rows, update) {
81
- this.dataTable.fnClearTable();
82
- this.dataTable.fnAddData(rows);
83
- }
84
-
85
- })
86
- });
87
-
88
- /*
89
- Local Variables:
90
- mode: Javascript
91
- tab-width: 2
92
- indent-tabs-mode: nil
93
- End:
94
- */