omf_web 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/omf_web_server +18 -0
- data/example/bridge/README.md +7 -0
- data/example/bridge/data_sources/sensor-sqlite.rb +15 -15
- data/example/bridge/htdocs/graph/js/bridge.js +35 -45
- data/example/bridge/htdocs/graph/js/event_line_chart.js +20 -18
- data/example/bridge/htdocs/graph/js/event_table.js +26 -28
- data/example/bridge/viz_server.rb +5 -9
- data/example/demo/demo_viz_server.rb +2 -2
- data/example/demo/widgets/linked_graphs_tab.yaml +9 -32
- data/example/openflow-gec15/code_tab.yaml +7 -12
- data/example/openflow-gec15/dashboard_tab.yaml +11 -12
- data/example/openflow-gec15/exp_source.rb +26 -26
- data/example/openflow-gec15/of_viz_server.rb +7 -7
- data/example/simple/simple.yaml +2 -1
- data/example/simple/simple_dynamic.yaml +1 -1
- data/example/web_rtc/web_rtc.yaml +54 -0
- data/example/web_rtc/webrtc-exp_1381786573.sq3 +0 -0
- data/lib/omf-web/config.ru +1 -1
- data/lib/omf-web/content/content_proxy.rb +2 -2
- data/lib/omf-web/content/file_repository.rb +11 -53
- data/lib/omf-web/content/git_repository.rb +1 -1
- data/lib/omf-web/content/irods_repository.rb +1 -1
- data/lib/omf-web/content/repository.rb +5 -3
- data/lib/omf-web/content/static_repository.rb +25 -11
- data/lib/omf-web/data_source_proxy.rb +3 -3
- data/lib/omf-web/rack/content_handler.rb +2 -2
- data/lib/omf-web/rack/session_authenticator.rb +3 -3
- data/lib/omf-web/rack/tab_mapper.rb +2 -2
- data/lib/omf-web/rack/update_handler.rb +2 -2
- data/lib/omf-web/rack/websocket_handler.rb +3 -3
- data/lib/omf-web/rack/widget_mapper.rb +2 -2
- data/lib/omf-web/session_store.rb +2 -2
- data/lib/omf-web/theme/abstract_page.rb +15 -24
- data/lib/omf-web/theme/bright/code_renderer.rb +24 -30
- data/lib/omf-web/theme/bright/data_renderer.rb +7 -5
- data/lib/omf-web/theme/bright/page.rb +2 -1
- data/lib/omf-web/theme/bright/widget_chrome.rb +16 -14
- data/lib/omf-web/theme.rb +1 -1
- data/lib/omf-web/thin/logging.rb +18 -13
- data/lib/omf-web/thin/runner.rb +2 -2
- data/lib/omf-web/thin/server.rb +105 -27
- data/lib/omf-web/version.rb +1 -1
- data/lib/omf-web/widget/abstract_widget.rb +3 -3
- data/lib/omf-web/widget/data_widget.rb +1 -0
- data/lib/omf-web/widget/text/maruku.rb +1 -1
- data/lib/omf-web/widget.rb +22 -22
- data/lib/omf_web.rb +1 -1
- data/omf_web.gemspec +18 -15
- data/share/htdocs/graph/js/abstract_chart.js +69 -68
- data/share/htdocs/graph/js/abstract_nv_chart.js +35 -33
- data/share/htdocs/graph/js/abstract_widget.js +61 -62
- data/share/htdocs/graph/js/axis.js +30 -25
- data/share/htdocs/graph/js/barchart_brush.js +23 -21
- data/share/htdocs/graph/js/code_mirror.js +35 -33
- data/share/htdocs/graph/js/discrete_bar_chart.js +27 -30
- data/share/htdocs/graph/js/histogram2.js +37 -47
- data/share/htdocs/graph/js/line_chart3.js +36 -30
- data/share/htdocs/graph/js/line_chart_with_focus.js +10 -9
- data/share/htdocs/graph/js/multi_barchart.js +33 -30
- data/share/htdocs/graph/js/network2.js +98 -97
- data/share/htdocs/graph/js/pie_chart2.js +25 -23
- data/share/htdocs/graph/js/scatter_plot.js +38 -36
- data/share/htdocs/graph/js/table2.js +60 -54
- data/share/htdocs/js/app.js +43 -0
- data/share/htdocs/js/{data_source2.js → data_source3.js} +44 -73
- data/share/htdocs/js/data_source_repo.js +42 -0
- data/share/htdocs/require/nv_d3.js +2 -0
- data/share/htdocs/theme/abstract/abstract.js +4 -4
- data/share/htdocs/vendor/VERSION_MAP.yaml +2 -0
- data/share/htdocs/vendor/require-2.1.8/require.js +2053 -0
- data/share/htdocs/vendor/require-2.1.8/require.min.js +36 -0
- data/share/htdocs/vendor/require-css-0.0.7/.gitignore +1 -0
- data/share/htdocs/vendor/require-css-0.0.7/LICENSE +10 -0
- data/share/htdocs/vendor/require-css-0.0.7/README.md +231 -0
- data/share/htdocs/vendor/require-css-0.0.7/bower.json +5 -0
- data/share/htdocs/vendor/require-css-0.0.7/css-builder.js +251 -0
- data/share/htdocs/vendor/require-css-0.0.7/css.js +436 -0
- data/share/htdocs/vendor/require-css-0.0.7/normalize.js +138 -0
- data/share/htdocs/vendor/require-css-0.0.7/package.json +5 -0
- data/share/htdocs/vendor/spin/jquery.spin.js +6 -4
- metadata +100 -74
- checksums.yaml +0 -7
- data/bin/omf_web_demo +0 -3
- data/bin/omf_web_demo.sh +0 -7
- data/bin/omf_web_server.rb +0 -157
- data/lib/omf_common/lobject.rb +0 -187
- data/lib/omf_common/log4r_outputter.rb +0 -69
- data/sample.sq3 +0 -0
- data/share/htdocs/js/data_source.js +0 -173
- data/share/htdocs/js/require3.js +0 -292
|
@@ -1,50 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var sources = {};
|
|
5
|
-
|
|
6
|
-
function context() {};
|
|
7
|
-
|
|
8
|
-
context.register = function(opts) {
|
|
9
|
-
var id = opts.id || opts.name;
|
|
10
|
-
if (sources[id] == null) {
|
|
11
|
-
sources[id] = new OML.data_source(opts);
|
|
12
|
-
}
|
|
13
|
-
return context;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
context.lookup = function(ds_descr) {
|
|
17
|
-
var name;
|
|
18
|
-
var dynamic = false;
|
|
19
|
-
|
|
20
|
-
if (typeof(ds_descr) == 'object') {
|
|
21
|
-
name = ds_descr.id || ds_descr.name;
|
|
22
|
-
dynamic = ds_descr.dynamic;
|
|
23
|
-
} else {
|
|
24
|
-
name = ds_descr;
|
|
25
|
-
}
|
|
26
|
-
var source = sources[name];
|
|
27
|
-
if (! source) {
|
|
28
|
-
throw("Unknown data source '" + name + "'.");
|
|
29
|
-
}
|
|
30
|
-
if (dynamic) {
|
|
31
|
-
source.is_dynamic(dynamic);
|
|
32
|
-
}
|
|
33
|
-
return source;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return context;
|
|
37
|
-
}();
|
|
3
|
+
function omf_web_data_source(opts) {
|
|
38
4
|
|
|
39
|
-
OML.data_source = function(opts) {
|
|
40
|
-
|
|
41
5
|
var name = opts.id || opts.name;
|
|
42
6
|
var event_name = "data_source." + name + ".changed";
|
|
43
7
|
var rows = opts.rows || [];
|
|
44
8
|
//var offset = opts.offset || -1; // Number of (initial) rows skipped (count towards 'max_rows')
|
|
45
|
-
var offset = opts.offset || 0; // Number of (initial) rows skipped (count towards 'max_rows')
|
|
9
|
+
var offset = opts.offset || 0; // Number of (initial) rows skipped (count towards 'max_rows')
|
|
46
10
|
var schema = opts.schema;
|
|
47
|
-
|
|
11
|
+
|
|
48
12
|
var data_source = {
|
|
49
13
|
version: "0.1",
|
|
50
14
|
name: name,
|
|
@@ -54,10 +18,10 @@ OML.data_source = function(opts) {
|
|
|
54
18
|
is_dynamic: is_dynamic,
|
|
55
19
|
event_name: event_name,
|
|
56
20
|
}
|
|
57
|
-
|
|
21
|
+
|
|
58
22
|
var indexes = {};
|
|
59
23
|
var unique_index_check = null;
|
|
60
|
-
|
|
24
|
+
|
|
61
25
|
var update_interval = -1;
|
|
62
26
|
var ws = null; // points to web socket instance
|
|
63
27
|
|
|
@@ -72,7 +36,7 @@ OML.data_source = function(opts) {
|
|
|
72
36
|
return indexes[i][key]; // need fresh lookup as we may redo index
|
|
73
37
|
}
|
|
74
38
|
}
|
|
75
|
-
|
|
39
|
+
|
|
76
40
|
function update_indexes() {
|
|
77
41
|
// This can most likley be done more efficiently if we consider what has changed
|
|
78
42
|
_.each(indexes, function(ignore, i) {
|
|
@@ -80,12 +44,12 @@ OML.data_source = function(opts) {
|
|
|
80
44
|
_.each(rows, function(r) { index[r[i]] = r; })
|
|
81
45
|
});
|
|
82
46
|
}
|
|
83
|
-
|
|
47
|
+
|
|
84
48
|
function is_dynamic(_) {
|
|
85
49
|
if (!arguments.length) {
|
|
86
50
|
return update_interval > 0 || ws;
|
|
87
51
|
}
|
|
88
|
-
|
|
52
|
+
|
|
89
53
|
var opts = _;
|
|
90
54
|
var interval = -1;
|
|
91
55
|
if (typeof(opts) == 'number') {
|
|
@@ -102,11 +66,11 @@ OML.data_source = function(opts) {
|
|
|
102
66
|
start_polling_backend();
|
|
103
67
|
}
|
|
104
68
|
}
|
|
105
|
-
|
|
69
|
+
|
|
106
70
|
var ws = null; // Websocket identifier
|
|
107
71
|
function start_web_socket() {
|
|
108
72
|
if (ws) return; // already running
|
|
109
|
-
|
|
73
|
+
|
|
110
74
|
var url = 'ws://' + window.location.host + '/_ws?sid=' + (opts.sid || OML.session_id);
|
|
111
75
|
ws = new WebSocket(url);
|
|
112
76
|
ws.onopen = on_open;
|
|
@@ -117,10 +81,10 @@ OML.data_source = function(opts) {
|
|
|
117
81
|
ws.onerror = function(evt) {
|
|
118
82
|
var status = "onerror";
|
|
119
83
|
};
|
|
120
|
-
}
|
|
121
|
-
|
|
84
|
+
}
|
|
85
|
+
|
|
122
86
|
// Send a message to the server
|
|
123
|
-
//
|
|
87
|
+
//
|
|
124
88
|
// @params type - Type of message
|
|
125
89
|
// @params args - Hash of additional args ('ds_name' of this data source will be added)
|
|
126
90
|
//
|
|
@@ -132,13 +96,13 @@ OML.data_source = function(opts) {
|
|
|
132
96
|
ws.send(JSON.stringify(msg));
|
|
133
97
|
}
|
|
134
98
|
|
|
135
|
-
|
|
99
|
+
|
|
136
100
|
function on_open() {
|
|
137
101
|
if (!active_slice_col_name) {
|
|
138
102
|
send_server_msg('register_data_source', {offset: offset + rows.length})
|
|
139
103
|
}
|
|
140
104
|
};
|
|
141
|
-
|
|
105
|
+
|
|
142
106
|
function on_message(evt) {
|
|
143
107
|
// evt.data contains received string.
|
|
144
108
|
var msg = jQuery.parseJSON(evt.data);
|
|
@@ -153,7 +117,7 @@ OML.data_source = function(opts) {
|
|
|
153
117
|
throw "Unknown message type '" + msg.type + "'.";
|
|
154
118
|
}
|
|
155
119
|
};
|
|
156
|
-
|
|
120
|
+
|
|
157
121
|
function on_update(msg) {
|
|
158
122
|
if (unique_index_check) {
|
|
159
123
|
// Let's first see if we simply replace a row
|
|
@@ -161,7 +125,7 @@ OML.data_source = function(opts) {
|
|
|
161
125
|
if (!unique_index_check(r)) {
|
|
162
126
|
rows.push(r); // new index
|
|
163
127
|
}
|
|
164
|
-
});
|
|
128
|
+
});
|
|
165
129
|
} else {
|
|
166
130
|
// need to append to 'rows' as it's referenced in other closures
|
|
167
131
|
// _.each(msg.rows, function(r) { rows.push(r) });
|
|
@@ -170,7 +134,7 @@ OML.data_source = function(opts) {
|
|
|
170
134
|
// rows = _.rest(rows, chop);
|
|
171
135
|
// }
|
|
172
136
|
switch (msg.action) {
|
|
173
|
-
case 'added':
|
|
137
|
+
case 'added':
|
|
174
138
|
_.each(msg.rows, function(r) { rows.push(r) });
|
|
175
139
|
break;
|
|
176
140
|
case 'removed':
|
|
@@ -193,17 +157,17 @@ OML.data_source = function(opts) {
|
|
|
193
157
|
throw "Unknown message action '" + msg.action + "'.";
|
|
194
158
|
}
|
|
195
159
|
}
|
|
196
|
-
|
|
160
|
+
|
|
197
161
|
update_indexes();
|
|
198
162
|
var evt = {data_source: data_source};
|
|
199
163
|
OHUB.trigger(event_name, evt);
|
|
200
164
|
OHUB.trigger("data_source.changed", evt);
|
|
201
165
|
}
|
|
202
|
-
|
|
166
|
+
|
|
203
167
|
// Request a new slice from the server. Clear existing state
|
|
204
168
|
function set_slice_column(col_value) {
|
|
205
169
|
if (active_slice_value == col_value) return;
|
|
206
|
-
|
|
170
|
+
|
|
207
171
|
active_slice_column_id = col_value;
|
|
208
172
|
// Reset state
|
|
209
173
|
rows = [];
|
|
@@ -213,14 +177,14 @@ OML.data_source = function(opts) {
|
|
|
213
177
|
}
|
|
214
178
|
var active_slice_col_name = null;
|
|
215
179
|
var active_slice_value = null;
|
|
216
|
-
|
|
217
|
-
function start_polling_backend() {
|
|
180
|
+
|
|
181
|
+
function start_polling_backend() {
|
|
218
182
|
var first_time = this.update_interval < 0;
|
|
219
|
-
|
|
183
|
+
|
|
220
184
|
if (this.update_interval < 0 || this.update_interval > interval) {
|
|
221
185
|
this.update_interval = interval;
|
|
222
186
|
}
|
|
223
|
-
|
|
187
|
+
|
|
224
188
|
if (first_time) {
|
|
225
189
|
var self = this;
|
|
226
190
|
L.require(['vendor/jquery/jquery.js', 'vendor/jquery/jquery.periodicalupdater.js'], function() {
|
|
@@ -246,7 +210,7 @@ OML.data_source = function(opts) {
|
|
|
246
210
|
}
|
|
247
211
|
return true;
|
|
248
212
|
}
|
|
249
|
-
|
|
213
|
+
|
|
250
214
|
// Let's check if this data_source maintains uniqueness along one axis (column)
|
|
251
215
|
if (opts.unique_column) {
|
|
252
216
|
var col_name = opts.unique_column;
|
|
@@ -270,18 +234,18 @@ OML.data_source = function(opts) {
|
|
|
270
234
|
key2row[key] = row;
|
|
271
235
|
return false;
|
|
272
236
|
}
|
|
273
|
-
// pre-seed
|
|
237
|
+
// pre-seed
|
|
274
238
|
rows = _.uniq(rows, false, function(r) { return r[index]; });
|
|
275
239
|
_.each(rows, function(r) { key2row[r[index]] = r; });
|
|
276
240
|
} else {
|
|
277
241
|
throw "Error in processing option 'unique_column'. Unknown column '" + col_name + "'."
|
|
278
242
|
}
|
|
279
243
|
}
|
|
280
|
-
|
|
244
|
+
|
|
281
245
|
// In slice mode, only fetch a 'slice' of the underlying data source. A slice
|
|
282
246
|
// is defined by specific value in the 'slice_column' of all rows.
|
|
283
247
|
//
|
|
284
|
-
// opts.slice:
|
|
248
|
+
// opts.slice:
|
|
285
249
|
// slice_column: id
|
|
286
250
|
// event:
|
|
287
251
|
// name: graph.static_network.links.changed
|
|
@@ -289,36 +253,43 @@ OML.data_source = function(opts) {
|
|
|
289
253
|
if (opts.slice) {
|
|
290
254
|
var so = opts.slice;
|
|
291
255
|
active_slice_col_name = so.slice_column;
|
|
292
|
-
|
|
256
|
+
|
|
293
257
|
if (so.event) {
|
|
294
258
|
var evt_name = so.event.name;
|
|
295
|
-
if (! evt_name)
|
|
259
|
+
if (! evt_name)
|
|
296
260
|
throw "Missing event name in slice definition for data source '" + name + "'.";
|
|
297
261
|
OHUB.bind(evt_name, function(msg) {
|
|
298
262
|
var schema = msg.schema || msg.data_source.schema;
|
|
299
|
-
|
|
263
|
+
|
|
300
264
|
var key = so.event.key;
|
|
301
265
|
var col = _.find(schema, function(cd) { return cd.name == key });
|
|
302
266
|
if (col) {
|
|
303
267
|
var event = msg.datum;
|
|
304
|
-
var col_id = event[col.index];
|
|
268
|
+
var col_id = event[col.index];
|
|
305
269
|
if (col_id) {
|
|
306
|
-
set_slice_column(col_id);
|
|
270
|
+
set_slice_column(col_id);
|
|
307
271
|
}
|
|
308
272
|
}
|
|
309
273
|
})
|
|
310
274
|
}
|
|
311
275
|
}
|
|
312
|
-
|
|
276
|
+
|
|
313
277
|
if (window.WebSocket) {
|
|
314
278
|
start_web_socket();
|
|
315
279
|
}
|
|
316
|
-
|
|
280
|
+
|
|
317
281
|
// Bind to event directly
|
|
318
282
|
// this.on_changed = function(update_f) {
|
|
319
283
|
// OHUB.bind(this.event_name, update_f);
|
|
320
284
|
// }
|
|
321
|
-
|
|
285
|
+
|
|
322
286
|
return data_source;
|
|
323
287
|
}
|
|
324
288
|
|
|
289
|
+
define(function() {
|
|
290
|
+
return function(opts) {
|
|
291
|
+
return omf_web_data_source(opts);
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
define(['omf/data_source3'], function(data_source) {
|
|
3
|
+
function data_source_repo() {
|
|
4
|
+
console.log("Creating data source repo");
|
|
5
|
+
var sources = {};
|
|
6
|
+
|
|
7
|
+
function context() {};
|
|
8
|
+
|
|
9
|
+
context.register = function(opts) {
|
|
10
|
+
var id = opts.id || opts.name;
|
|
11
|
+
if (sources[id] == null) {
|
|
12
|
+
sources[id] = data_source(opts);
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
context.lookup = function(ds_descr) {
|
|
18
|
+
var name;
|
|
19
|
+
var dynamic = false;
|
|
20
|
+
|
|
21
|
+
if (typeof(ds_descr) == 'object') {
|
|
22
|
+
name = ds_descr.id || ds_descr.name;
|
|
23
|
+
dynamic = ds_descr.dynamic;
|
|
24
|
+
} else {
|
|
25
|
+
name = ds_descr;
|
|
26
|
+
}
|
|
27
|
+
var source = sources[name];
|
|
28
|
+
if (! source) {
|
|
29
|
+
throw("Unknown data source '" + name + "'.");
|
|
30
|
+
}
|
|
31
|
+
if (dynamic) {
|
|
32
|
+
source.is_dynamic(dynamic);
|
|
33
|
+
}
|
|
34
|
+
return source;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return context;
|
|
38
|
+
}
|
|
39
|
+
return data_source_repo(); // Create the singleton
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
OML = {
|
|
3
3
|
data_sources: {},
|
|
4
4
|
widgets: {},
|
|
5
5
|
window_size: {width: null, height: null}
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
var OHUB = {};
|
|
9
9
|
_.extend(OHUB, Backbone.Events);
|
|
10
10
|
|
|
@@ -13,10 +13,10 @@ $(window).resize(function(x) {
|
|
|
13
13
|
var width = w.width();
|
|
14
14
|
var height = w.height();
|
|
15
15
|
var current = OML.window_size;
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
if (current.width != width || current.height != height) {
|
|
18
18
|
current.width = width; current.height = height;
|
|
19
19
|
OHUB.trigger('window.resize', current);
|
|
20
20
|
OHUB.trigger('layout.resize', {});
|
|
21
21
|
}
|
|
22
|
-
});
|
|
22
|
+
});
|