omf_web 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/bin/omf_web_server +18 -0
  2. data/example/bridge/README.md +7 -0
  3. data/example/bridge/data_sources/sensor-sqlite.rb +15 -15
  4. data/example/bridge/htdocs/graph/js/bridge.js +35 -45
  5. data/example/bridge/htdocs/graph/js/event_line_chart.js +20 -18
  6. data/example/bridge/htdocs/graph/js/event_table.js +26 -28
  7. data/example/bridge/viz_server.rb +5 -9
  8. data/example/demo/demo_viz_server.rb +2 -2
  9. data/example/demo/widgets/linked_graphs_tab.yaml +9 -32
  10. data/example/openflow-gec15/code_tab.yaml +7 -12
  11. data/example/openflow-gec15/dashboard_tab.yaml +11 -12
  12. data/example/openflow-gec15/exp_source.rb +26 -26
  13. data/example/openflow-gec15/of_viz_server.rb +7 -7
  14. data/example/simple/simple.yaml +2 -1
  15. data/example/simple/simple_dynamic.yaml +1 -1
  16. data/example/web_rtc/web_rtc.yaml +54 -0
  17. data/example/web_rtc/webrtc-exp_1381786573.sq3 +0 -0
  18. data/lib/omf-web/config.ru +1 -1
  19. data/lib/omf-web/content/content_proxy.rb +2 -2
  20. data/lib/omf-web/content/file_repository.rb +11 -53
  21. data/lib/omf-web/content/git_repository.rb +1 -1
  22. data/lib/omf-web/content/irods_repository.rb +1 -1
  23. data/lib/omf-web/content/repository.rb +5 -3
  24. data/lib/omf-web/content/static_repository.rb +25 -11
  25. data/lib/omf-web/data_source_proxy.rb +3 -3
  26. data/lib/omf-web/rack/content_handler.rb +2 -2
  27. data/lib/omf-web/rack/session_authenticator.rb +3 -3
  28. data/lib/omf-web/rack/tab_mapper.rb +2 -2
  29. data/lib/omf-web/rack/update_handler.rb +2 -2
  30. data/lib/omf-web/rack/websocket_handler.rb +3 -3
  31. data/lib/omf-web/rack/widget_mapper.rb +2 -2
  32. data/lib/omf-web/session_store.rb +2 -2
  33. data/lib/omf-web/theme/abstract_page.rb +15 -24
  34. data/lib/omf-web/theme/bright/code_renderer.rb +24 -30
  35. data/lib/omf-web/theme/bright/data_renderer.rb +7 -5
  36. data/lib/omf-web/theme/bright/page.rb +2 -1
  37. data/lib/omf-web/theme/bright/widget_chrome.rb +16 -14
  38. data/lib/omf-web/theme.rb +1 -1
  39. data/lib/omf-web/thin/logging.rb +18 -13
  40. data/lib/omf-web/thin/runner.rb +2 -2
  41. data/lib/omf-web/thin/server.rb +105 -27
  42. data/lib/omf-web/version.rb +1 -1
  43. data/lib/omf-web/widget/abstract_widget.rb +3 -3
  44. data/lib/omf-web/widget/data_widget.rb +1 -0
  45. data/lib/omf-web/widget/text/maruku.rb +1 -1
  46. data/lib/omf-web/widget.rb +22 -22
  47. data/lib/omf_web.rb +1 -1
  48. data/omf_web.gemspec +18 -15
  49. data/share/htdocs/graph/js/abstract_chart.js +69 -68
  50. data/share/htdocs/graph/js/abstract_nv_chart.js +35 -33
  51. data/share/htdocs/graph/js/abstract_widget.js +61 -62
  52. data/share/htdocs/graph/js/axis.js +30 -25
  53. data/share/htdocs/graph/js/barchart_brush.js +23 -21
  54. data/share/htdocs/graph/js/code_mirror.js +35 -33
  55. data/share/htdocs/graph/js/discrete_bar_chart.js +27 -30
  56. data/share/htdocs/graph/js/histogram2.js +37 -47
  57. data/share/htdocs/graph/js/line_chart3.js +36 -30
  58. data/share/htdocs/graph/js/line_chart_with_focus.js +10 -9
  59. data/share/htdocs/graph/js/multi_barchart.js +33 -30
  60. data/share/htdocs/graph/js/network2.js +98 -97
  61. data/share/htdocs/graph/js/pie_chart2.js +25 -23
  62. data/share/htdocs/graph/js/scatter_plot.js +38 -36
  63. data/share/htdocs/graph/js/table2.js +60 -54
  64. data/share/htdocs/js/app.js +43 -0
  65. data/share/htdocs/js/{data_source2.js → data_source3.js} +44 -73
  66. data/share/htdocs/js/data_source_repo.js +42 -0
  67. data/share/htdocs/require/nv_d3.js +2 -0
  68. data/share/htdocs/theme/abstract/abstract.js +4 -4
  69. data/share/htdocs/vendor/VERSION_MAP.yaml +2 -0
  70. data/share/htdocs/vendor/require-2.1.8/require.js +2053 -0
  71. data/share/htdocs/vendor/require-2.1.8/require.min.js +36 -0
  72. data/share/htdocs/vendor/require-css-0.0.7/.gitignore +1 -0
  73. data/share/htdocs/vendor/require-css-0.0.7/LICENSE +10 -0
  74. data/share/htdocs/vendor/require-css-0.0.7/README.md +231 -0
  75. data/share/htdocs/vendor/require-css-0.0.7/bower.json +5 -0
  76. data/share/htdocs/vendor/require-css-0.0.7/css-builder.js +251 -0
  77. data/share/htdocs/vendor/require-css-0.0.7/css.js +436 -0
  78. data/share/htdocs/vendor/require-css-0.0.7/normalize.js +138 -0
  79. data/share/htdocs/vendor/require-css-0.0.7/package.json +5 -0
  80. data/share/htdocs/vendor/spin/jquery.spin.js +6 -4
  81. metadata +100 -74
  82. checksums.yaml +0 -7
  83. data/bin/omf_web_demo +0 -3
  84. data/bin/omf_web_demo.sh +0 -7
  85. data/bin/omf_web_server.rb +0 -157
  86. data/lib/omf_common/lobject.rb +0 -187
  87. data/lib/omf_common/log4r_outputter.rb +0 -69
  88. data/sample.sq3 +0 -0
  89. data/share/htdocs/js/data_source.js +0 -173
  90. data/share/htdocs/js/require3.js +0 -292
@@ -1,47 +1,47 @@
1
- L.provide('OML.scatter_plot', ["graph/js/abstract_chart", "#OML.abstract_chart", "graph/js/axis", "#OML.axis"], function () {
1
+ define(["graph/abstract_nv_chart"], function (abstract_nv_chart) {
2
2
 
3
- OML.scatter_plot = OML.abstract_chart.extend({
3
+ var scatter_plot = abstract_nv_chart.extend({
4
4
  decl_properties: [
5
- ['x_axis', 'key', {property: 'x'}],
6
- ['y_axis', 'key', {property: 'y'}],
7
- ['radius', 'int', 10],
8
- ['stroke_width', 'int', 2],
5
+ ['x_axis', 'key', {property: 'x'}],
6
+ ['y_axis', 'key', {property: 'y'}],
7
+ ['radius', 'int', 10],
8
+ ['stroke_width', 'int', 2],
9
9
  ['stroke_color', 'color', 'black'],
10
10
  ['fill_color', 'color', 'orange']
11
11
  ],
12
-
12
+
13
13
  defaults: function() {
14
14
  return this.deep_defaults({
15
15
  transition: 400, // Time in msec for transition when elements change
16
16
  axis: {
17
17
  orientation: 'horizontal'
18
18
  }
19
- }, OML.scatter_plot.__super__.defaults.call(this));
20
- },
21
-
22
-
19
+ }, scatter_plot.__super__.defaults.call(this));
20
+ },
21
+
22
+
23
23
  configure_base_layer: function(vis) {
24
24
  var base = this.base_layer = vis.append("svg:g")
25
25
  .attr("class", "scatterplot")
26
26
  ;
27
27
  //.attr("transform", "translate(0, " + this.h + ")");
28
28
 
29
- var ca = this.chart_area;
29
+ var ca = this.chart_area;
30
30
  this.legend_layer = base.append("svg:g");
31
31
  this.chart_layer = base.append("svg:g");
32
32
  this.axis_layer = base.append('g');
33
33
  },
34
34
 
35
35
  resize: function() {
36
- OML.scatter_plot.__super__.resize.call(this);
36
+ scatter_plot.__super__.resize.call(this);
37
37
  return this;
38
- },
38
+ },
39
39
 
40
40
  redraw: function(data) {
41
41
  var self = this;
42
42
  var o = this.opts;
43
43
  var ca = this.widget_area;
44
-
44
+
45
45
  var m = this.mapping;
46
46
  var x_m = m.x_axis;
47
47
  var y_m = m.y_axis;
@@ -56,13 +56,13 @@ L.provide('OML.scatter_plot', ["graph/js/abstract_chart", "#OML.abstract_chart",
56
56
  .range([0, ca.h])
57
57
  .nice();
58
58
  var r_f = typeof(r_m) != 'function' ? d3.functor(r_m) : r_m;
59
- var w_f = typeof(r_m) != 'function' ? (2 * r_m) : function(d) { return 2 * r_m(d); }
60
-
61
- var x = function(d) {
62
- return x_f(x_m(d)) + ca.x - r_f(d);
59
+ var w_f = typeof(r_m) != 'function' ? (2 * r_m) : function(d) { return 2 * r_m(d); };
60
+
61
+ var x = function(d) {
62
+ return x_f(x_m(d)) + ca.x - r_f(d);
63
63
  };
64
- var y = function(d) {
65
- return ca.ty + ca.h - y_f(y_m(d)) - r_f(d);
64
+ var y = function(d) {
65
+ return ca.ty + ca.h - y_f(y_m(d)) - r_f(d);
66
66
  };
67
67
  var rects = this.chart_layer.selectAll("rect").data(data);
68
68
  rects.transition().duration(o.transition)
@@ -86,10 +86,10 @@ L.provide('OML.scatter_plot', ["graph/js/abstract_chart", "#OML.abstract_chart",
86
86
  rects.exit()
87
87
  .remove()
88
88
  ;
89
-
89
+
90
90
  this.redraw_axis(data, x_f, y_f);
91
91
  },
92
-
92
+
93
93
  redraw_axis: function(data, x, y) {
94
94
  var self = this;
95
95
  var ca = this.widget_area;
@@ -100,7 +100,7 @@ L.provide('OML.scatter_plot', ["graph/js/abstract_chart", "#OML.abstract_chart",
100
100
  var xAxis = this.xAxis.scale(x);
101
101
  this.axis_layer.select('g.x.axis').call(xAxis);
102
102
  } else {
103
- var xAxis = this.xAxis = OML.line_chart2_axis(oAxis.x).scale(x).orient("bottom").range([0, ca.w]);
103
+ var xAxis = this.xAxis = line_chart2_axis(oAxis.x).scale(x).orient("bottom").range([0, ca.w]);
104
104
  this.axis_layer
105
105
  .append('g')
106
106
  .attr("transform", "translate(" + ca.x + "," + (ca.ty + ca.h) + ")")
@@ -108,13 +108,13 @@ L.provide('OML.scatter_plot', ["graph/js/abstract_chart", "#OML.abstract_chart",
108
108
  .call(xAxis)
109
109
  ;
110
110
  }
111
-
111
+
112
112
  var inv_y = y.range([ca.h, 0]);
113
113
  if (this.yAxis) {
114
114
  var yAxis = this.yAxis.scale(inv_y);
115
115
  this.axis_layer.select('g.y.axis').call(yAxis);
116
116
  } else {
117
- var yAxis = this.yAxis = OML.line_chart2_axis(oAxis.y).scale(inv_y).orient("left").range([0, ca.h]);
117
+ var yAxis = this.yAxis = line_chart2_axis(oAxis.y).scale(inv_y).orient("left").range([0, ca.h]);
118
118
  this.axis_layer
119
119
  .append('g')
120
120
  .attr("transform", "translate(" + ca.x + "," + ca.ty + ")")
@@ -122,14 +122,14 @@ L.provide('OML.scatter_plot', ["graph/js/abstract_chart", "#OML.abstract_chart",
122
122
  .call(yAxis)
123
123
  ;
124
124
  }
125
-
126
-
125
+
126
+
127
127
  },
128
-
129
-
128
+
129
+
130
130
  on_highlighted: function(evt) {
131
131
  var els = evt.elements;
132
- var piece_id = els[0].id
132
+ var piece_id = els[0].id;
133
133
  var vis = this.chart_layer;
134
134
  vis.selectAll("path")
135
135
  .filter(function(d) {
@@ -150,17 +150,19 @@ L.provide('OML.scatter_plot', ["graph/js/abstract_chart", "#OML.abstract_chart",
150
150
  var vis = this.chart_layer;
151
151
  vis.selectAll("path")
152
152
  .transition()
153
- .style("opacity", 1.0)
153
+ .style("opacity", 1.0)
154
154
  .delay(0)
155
- .duration(300)
155
+ .duration(300);
156
156
  if (evt.source == null) {
157
157
  evt.source = this;
158
158
  OHUB.trigger("graph.dehighlighted", evt);
159
159
  }
160
160
  },
161
-
162
- })
163
- })
161
+
162
+ });
163
+
164
+ return scatter_plot;
165
+ });
164
166
 
165
167
  /*
166
168
  Local Variables:
@@ -1,25 +1,29 @@
1
1
 
2
- L.provide('jquery.event.drag', ['vendor/jquery/jquery.event.drag.js'], function() {
3
- // L.require(['theme/bright/css/slickgrid.css'], function() { // We seem to have a race condition with the CSS file
4
- L.provide('slickgrid', [
5
- 'vendor/slickgrid/slick.core.js',
6
- 'vendor/slickgrid/slick.formatters.js',
7
- 'vendor/slickgrid/slick.editors.js',
8
- 'vendor/slickgrid/plugins/slick.rowselectionmodel.js',
9
- 'vendor/slickgrid/slick.grid.js',
10
- 'vendor/slickgrid/slick.dataview.js',
11
- 'vendor/slickgrid/controls/slick.pager.js',
12
- 'vendor/slickgrid/controls/slick.columnpicker.js',
13
- 'theme/bright/css/slickgrid.css'
14
- ]);
15
- // });
2
+ require.config({
3
+ shim: {
4
+ 'vendor/slickgrid/slick.formatters': ['vendor/slickgrid/slick.core'],
5
+ 'vendor/slickgrid/slick.editors': ['vendor/slickgrid/slick.core'],
6
+ 'vendor/slickgrid/plugins/slick.rowselectionmodel': ['vendor/slickgrid/slick.core'],
7
+ 'vendor/slickgrid/slick.grid': ['vendor/slickgrid/slick.core'],
8
+ 'vendor/slickgrid/slick.dataview': ['vendor/slickgrid/slick.core'],
9
+ 'vendor/slickgrid/controls/slick.pager': ['vendor/slickgrid/slick.core'],
10
+ 'vendor/slickgrid/controls/slick.columnpicker': ['vendor/slickgrid/slick.core']
11
+ }
16
12
  });
17
-
18
- L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#slickgrid'], function () {
19
13
 
20
- if (typeof(OML) == "undefined") OML = {};
21
-
22
- OML.table2 = OML.abstract_widget.extend({
14
+
15
+ define(["graph/abstract_widget",
16
+ 'vendor/jquery/jquery.event.drag',
17
+ 'vendor/slickgrid/slick.formatters',
18
+ 'vendor/slickgrid/slick.editors',
19
+ 'vendor/slickgrid/plugins/slick.rowselectionmodel',
20
+ 'vendor/slickgrid/slick.grid',
21
+ 'vendor/slickgrid/slick.dataview',
22
+ 'vendor/slickgrid/controls/slick.pager',
23
+ 'vendor/slickgrid/controls/slick.columnpicker',
24
+ 'css!theme/bright/css/slickgrid'], function(abstract_widget) {
25
+
26
+ var table2 = abstract_widget.extend({
23
27
  defaults: function() {
24
28
  return this.deep_defaults({
25
29
  // add defaults
@@ -35,17 +39,17 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
35
39
  right: 20,
36
40
  bottom: 2
37
41
  },
38
- }, OML.table2.__super__.defaults.call(this));
39
- },
42
+ }, table2.__super__.defaults.call(this));
43
+ },
40
44
 
41
45
  initialize: function(opts) {
42
- OML.table2.__super__.initialize.call(this, opts);
46
+ table2.__super__.initialize.call(this, opts);
43
47
  // var ca = this.widget_area;
44
48
  // this.base_el
45
49
  // .style('height', ca.h + 'px')
46
- // .style('width', ca.w + 'px')
47
- // .style('margin-left', ca.x + 'px')
48
- // .style('margin-top', ca.ty + 'px')
50
+ // .style('width', ca.w + 'px')
51
+ // .style('margin-left', ca.x + 'px')
52
+ // .style('margin-top', ca.ty + 'px')
49
53
  // ;
50
54
  $(opts.base_el).focus(function(e) {
51
55
  // all your magic resize mojo goes here
@@ -54,29 +58,29 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
54
58
  this.init_grid();
55
59
  this.update();
56
60
  },
57
-
61
+
58
62
  resize: function() {
59
- OML.table2.__super__.resize.call(this);
63
+ table2.__super__.resize.call(this);
60
64
  // var ca = this.widget_area;
61
65
  // this.base_el
62
66
  // .style('height', ca.oh + 'px')
63
- // .style('width', ca.w + 'px')
67
+ // .style('width', ca.w + 'px')
64
68
  // .style('margin-left', ca.x + 'px')
65
- // .style('margin-right', ca.ow - ca.w - ca.x + 'px')
66
- // .style('margin-top', ca.ty + 'px')
69
+ // .style('margin-right', ca.ow - ca.w - ca.x + 'px')
70
+ // .style('margin-top', ca.ty + 'px')
67
71
  // ;
68
72
  if (this.grid) {
69
73
  this.grid.resizeCanvas();
70
74
  //this.grid.setColumns(this.columns);
71
75
  }
72
-
76
+
73
77
  return this;
74
- },
75
-
78
+ },
79
+
76
80
  redraw: function(data) {
77
81
  //this.resize();
78
-
79
- this.data = data;
82
+
83
+ this.data = data;
80
84
  var self = this;
81
85
  // Should sort first
82
86
  if (this.sort_on_column) {
@@ -85,23 +89,23 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
85
89
  data = data.sort(function(a, b) {
86
90
  var x = a[sid], y = b[sid];
87
91
  var cmp = (x == y ? 0 : (x > y ? 1 : -1));
88
- return asc ? cmp : -1 * cmp;
92
+ return asc ? cmp : -1 * cmp;
89
93
  });
90
94
  }
91
95
  this.sorted_data = data;
92
-
96
+
93
97
  this.grid.updateRowCount(); // fixes scroll bar
94
98
  this.grid.invalidateAllRows();
95
99
  this.grid.render();
96
100
  },
97
-
101
+
98
102
  init_grid: function() {
99
103
  var schema = this.data_source.schema;
100
104
  var opts = this.opts;
101
105
  var self = this;
102
-
106
+
103
107
  var columns = this.init_columns();
104
-
108
+
105
109
  // Define function used to get the data.
106
110
  //var currentSortCol = { id: "title" };
107
111
  var self = this;
@@ -113,8 +117,8 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
113
117
  function getLength() {
114
118
  return self.sorted_data.length;
115
119
  }
116
-
117
- var topts = this.opts.topts
120
+
121
+ var topts = this.opts.topts;
118
122
  topts.dataItemColumnValueExtractor = function(item, columnDef) {
119
123
  var i = 0;
120
124
  return item[columnDef.id];
@@ -135,9 +139,9 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
135
139
  // grid.onSelectedRowsChanged.subscribe(function(e, args) {
136
140
  // var i = 0;
137
141
  // });
138
-
142
+
139
143
  },
140
-
144
+
141
145
  /*
142
146
  * Return an array of columns definitions to be used for the slick grid constructor
143
147
  */
@@ -145,10 +149,10 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
145
149
  var schema = this.data_source.schema;
146
150
  var opts = this.opts;
147
151
  var self = this;
148
-
152
+
149
153
  var columns;
150
154
  if (opts.columns) {
151
- var sh = {}; _.each(schema, function(e) { sh[e.name] = e; })
155
+ var sh = {}; _.each(schema, function(e) { sh[e.name] = e; });
152
156
  columns = _.map(opts.columns, function(c) {
153
157
  if (typeof c === 'string') {
154
158
  c = {field: c};
@@ -159,9 +163,9 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
159
163
  name: s.title || s.name,
160
164
  width: 0,
161
165
  sortable: true,
162
- })
166
+ });
163
167
  if (c.format) {
164
- c.formatter = self.find_formatter(c.type || s.type, c)
168
+ c.formatter = self.find_formatter(c.type || s.type, c);
165
169
  }
166
170
  return c;
167
171
  });
@@ -183,21 +187,23 @@ L.provide('OML.table2', ["graph/js/abstract_widget", "#OML.abstract_widget", '#s
183
187
  var d_f = d3.time.format(opts.format || "%X");
184
188
  return function(r, c, v) {
185
189
  var date = new Date(1000 * v); // TODO: Implicitly assuming that value is in seconds is most likely NOT a good idea
186
- var fs = d_f(date);
190
+ var fs = d_f(date);
187
191
  return fs;
188
- }
192
+ };
189
193
  } else if (type == 'key') {
190
194
  var lm = opts.format;
191
195
  return function(r, c, v) {
192
196
  var l = lm[v] || ('??-' + v);
193
197
  return l;
194
- }
198
+ };
195
199
  } else {
196
200
  var formatter = d3.format(opts.format);
197
201
  return function(r, c, v) {
198
202
  return formatter(v);
199
- }
203
+ };
200
204
  }
201
205
  }
202
- })
203
- })
206
+ });
207
+
208
+ return table2;
209
+ });
@@ -0,0 +1,43 @@
1
+
2
+ var i = 0;
3
+ require.config({
4
+ //By default load any module IDs from js/lib
5
+ baseUrl: '/resource',
6
+ //except, if the module ID starts with "app",
7
+ //load it from the js/app directory. paths
8
+ //config is relative to the baseUrl, and
9
+ //never includes a ".js" extension since
10
+ //the paths config could be for a directory.
11
+ paths: {
12
+ omf: 'js',
13
+ vendor: 'vendor',
14
+ graph: 'graph/js',
15
+ graph_css: 'graph/css'
16
+ },
17
+ shim: {
18
+ 'vendor/jquery/jquery': {
19
+ //deps: ['jquery'],
20
+ exports: 'jQuery'
21
+ },
22
+ },
23
+ map: {
24
+ '*': {
25
+ 'css': 'vendor/require-css/css'
26
+ }
27
+ }
28
+ });
29
+
30
+ // Start the main app logic.
31
+ // requirejs(['vendor/jquery', 'vendor/backbone'],
32
+ // function($, _) {
33
+ // //jQuery, canvas and the app/sub module are all
34
+ // //loaded and can be used here now.
35
+ // var i = 0;
36
+ // });
37
+
38
+ require(['css!graph_css/graph'],
39
+ function(css) {
40
+ //jQuery, canvas and the app/sub module are all
41
+ //loaded and can be used here now.
42
+ var i = 0;
43
+ });