skybox 0.2.3.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,5 @@
1
1
  (function() {
2
2
  var table = null;
3
- var actions = [];
4
3
  var properties = [];
5
4
 
6
5
  //----------------------------------------------------------------------------
@@ -20,7 +19,7 @@ var properties = [];
20
19
  */
21
20
  function ready(callback) {
22
21
  // Clears dependencies and checks for completion.
23
- var dependencies = ["actions", "properties"];
22
+ var dependencies = ["properties"];
24
23
  var removedep = function(dependency) {
25
24
  dependencies = dependencies.filter(function(i) { return i != dependency; });
26
25
  if(dependencies.length == 0) {
@@ -30,7 +29,6 @@ function ready(callback) {
30
29
 
31
30
  // Initialize and wait for dependencies.
32
31
  $(document).ready(function() {
33
- actions_load().done(function() { removedep("actions"); });
34
32
  properties_load().done(function() { removedep("properties"); });
35
33
  });
36
34
  }
@@ -49,49 +47,6 @@ function table_get(_) {
49
47
  }
50
48
 
51
49
 
52
- //--------------------------------------
53
- // Actions
54
- //--------------------------------------
55
-
56
- /**
57
- * Sets or retrieves the actions.
58
- */
59
- function actions_get(_) {
60
- if (!arguments.length) return actions;
61
- actions = _;
62
- }
63
-
64
- /**
65
- * Retrieves an action object by id.
66
- */
67
- function actions_find(id) {
68
- for(var i=0; i<actions.length; i++) {
69
- if(actions[i].id == id || actions[i].name == id) {
70
- return actions[i];
71
- }
72
- }
73
- }
74
-
75
- /**
76
- * Loads action data.
77
- *
78
- * @return {Object} The XHR used to load the action data.
79
- */
80
- function actions_load() {
81
- var xhr = $.getJSON("/actions", {table:table}, function(data) {
82
- actions = [
83
- {id:"enter", name:"Session Start"},
84
- {id:"exit", name:"Session End"},
85
- {id:"other", name:"Other"}
86
- ].concat(data);
87
- })
88
- .fail(function() {
89
- alert("Unable to load action data");
90
- });
91
- return xhr;
92
- }
93
-
94
-
95
50
  //--------------------------------------
96
51
  // Properties
97
52
  //--------------------------------------
@@ -121,7 +76,7 @@ function properties_find(id) {
121
76
  * @return {Object} The XHR used to load the property data.
122
77
  */
123
78
  function properties_load() {
124
- var xhr = $.getJSON("/properties", {table:table}, function(data) {
79
+ var xhr = $.getJSON("/api/" + table + "/properties", function(data) {
125
80
  properties = data;
126
81
  })
127
82
  .fail(function() {
@@ -168,97 +123,6 @@ function data_normalize(data, nodes, links, options) {
168
123
  }
169
124
 
170
125
 
171
- //--------------------------------------
172
- // Query
173
- //--------------------------------------
174
-
175
- /**
176
- * Converts a query into a human readable HTML string.
177
- *
178
- * @param {Object} query The query.
179
- *
180
- * @return {String} The HTML string.
181
- */
182
- function query_html(query) {
183
- return (query.selections.length > 0 ? query_selection_html(query.selections[0]) : "");
184
- }
185
-
186
- /**
187
- * Converts a selection into a human readable HTML string.
188
- *
189
- * @param {Object} selection The selection object.
190
- *
191
- * @return {String} The HTML string.
192
- */
193
- function query_selection_html(selection) {
194
- var fields_html = query_selection_fields_html(selection);
195
- var conditions_html = query_selection_conditions_html(selection);
196
-
197
- var html = [];
198
- if(fields_html) html.push(fields_html);
199
- if(conditions_html) html.push(conditions_html);
200
- return html.join(" ") + ".";
201
- }
202
-
203
- /**
204
- * Converts the fields/groups of a selection into a human readable HTML string.
205
- *
206
- * @param {Object} selection The selection object.
207
- *
208
- * @return {String} The HTML string.
209
- */
210
- function query_selection_fields_html(selection) {
211
- // Generate the field/group section.
212
- var html = "Find the "
213
- html += '<span rel="popover" class="selection">';
214
- switch(selection.fields[0].aggregationType) {
215
- case "count": html += "number of ";
216
- }
217
- html += (selection.groups[0].expression == "action_id" ? "actions performed" : selection.groups[0].expression);
218
- html += "</span>"
219
-
220
- return html;
221
- }
222
-
223
- /**
224
- * Converts the conditions of a selection into a human readable HTML string.
225
- *
226
- * @param {Object} selection The selection object.
227
- *
228
- * @return {String} The HTML string.
229
- */
230
- function query_selection_conditions_html(selection) {
231
- if(!selection.conditions || selection.conditions.length == 0) return null;
232
-
233
- var htmls = [];
234
- for(i=0; i<selection.conditions.length; i++) {
235
- var condition = selection.conditions[i];
236
-
237
-
238
- var html = '<span class="condition" data-condition-index="' + i + '">';
239
- html += condition.type + " ";
240
- if(condition.action == "enter") {
241
- html += "session start";
242
- }
243
- else {
244
- var action = actions_find(condition.action.id);
245
- html += "<em>" + (action ? "'" + action.name + "'" : "&lt;action&gt;") + "</em>";
246
- }
247
- html += "</span>"
248
- htmls.push(html);
249
- }
250
- switch(selection.fields[0].aggregationType) {
251
- case "count": html += "The number of ";
252
- }
253
- html += (selection.groups[0].expression == "action_id" ? "actions performed" : selection.groups[0].expression);
254
- html += "</span>"
255
-
256
- return htmls.join(" and ");
257
- }
258
-
259
-
260
-
261
-
262
126
  //----------------------------------------------------------------------------
263
127
  //
264
128
  // Public Interface
@@ -268,18 +132,11 @@ function query_selection_conditions_html(selection) {
268
132
  skybox = {
269
133
  ready:ready,
270
134
  table:table_get,
271
- query:{
272
- html:query_html
273
- },
274
135
  data:{
275
136
  normalize:data_normalize
276
137
  }
277
138
  };
278
139
 
279
- // Actions namespace.
280
- skybox.actions = actions_get,
281
- skybox.actions.find = actions_find;
282
- skybox.actions.load = actions_load;
283
140
 
284
141
  // Properties namespace.
285
142
  skybox.properties = properties_get,
@@ -0,0 +1,96 @@
1
+ (function() {
2
+ if(!skybox) skybox = {}
3
+ skybox.query = function() {}
4
+ skybox.query.selections = function() {}
5
+
6
+ //--------------------------------------
7
+ // Branches
8
+ //--------------------------------------
9
+
10
+ /**
11
+ * Retrieves a list of all non-leaf nodes in the query.
12
+ *
13
+ * @param {Object} query The query
14
+ *
15
+ * @return {Array} A list of non-leaf nodes (query, conditions) in the query.
16
+ */
17
+ skybox.query.branches = function(query) {
18
+ if(!query) return [];
19
+
20
+ var branches = [];
21
+ if(query.type != "selection") {
22
+ branches = [query];
23
+ for(var i=0; i<query.steps.length; i++) {
24
+ branches = branches.concat(skybox.query.branches(query.steps[i]))
25
+ }
26
+ }
27
+ return branches;
28
+ }
29
+
30
+
31
+ //--------------------------------------
32
+ // Selections
33
+ //--------------------------------------
34
+
35
+ /**
36
+ * Extracts an array of selection objects from a query.
37
+ *
38
+ * @param {Object} query The query
39
+ *
40
+ * @return {Array} A list of selections.
41
+ */
42
+ skybox.query.selections = function(query) {
43
+ if(!query) return [];
44
+
45
+ var selections = [];
46
+ if(query.type == "selection") {
47
+ selections = [query];
48
+ } else if(query.steps) {
49
+ for(var i=0; i<query.steps.length; i++) {
50
+ selections = selections.concat(skybox.query.selections(query.steps[i]))
51
+ }
52
+ }
53
+ return selections;
54
+ }
55
+
56
+ /**
57
+ * Extracts a lookup of selection objects from a query by name.
58
+ *
59
+ * @param {Object} query The query
60
+ *
61
+ * @return {Object} A lookup of selections by name.
62
+ */
63
+ skybox.query.selections.hash = function (query) {
64
+ var hash = {};
65
+ var selections = skybox.query.selections(query);
66
+ for(var i=0; i<selections.length; i++) {
67
+ var selection = selections[i];
68
+ if(selection.name) {
69
+ hash[selection.name] = selection;
70
+ }
71
+ }
72
+ return hash;
73
+ }
74
+
75
+
76
+ /**
77
+ * Finds the parent of a selection.
78
+ *
79
+ * @param {Object} query The query
80
+ * @param {Object} selection The selection to find the parent of.
81
+ *
82
+ * @return {Object} The parent of the selection.
83
+ */
84
+ skybox.query.selections.parent = function(query, selection) {
85
+ var branches = skybox.query.branches(query);
86
+ for(var i=0; i<branches.length; i++) {
87
+ var branch = branches[i];
88
+ for(var j=0; j<branch.steps.length; j++) {
89
+ if(branch.steps[j] == selection) {
90
+ return branch;
91
+ }
92
+ }
93
+ }
94
+ return null;
95
+ }
96
+ })();
@@ -1,3 +1,3 @@
1
1
  class Skybox
2
- VERSION = "0.2.3.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,9 +1,12 @@
1
- <div class="content row">
2
- <div class="span12">
3
- <p id="query-text" class="lead"></p>
4
- </div>
5
- </div>
1
+ <link href="/css/skybox.explore.css" rel="stylesheet">
2
+ <script src="/js/skybox.explore.js"></script>
6
3
 
7
4
  <div class="content row">
8
5
  <div id="chart" class="span12"></div>
9
6
  </div>
7
+
8
+ <script>
9
+ skybox.ready(function() {
10
+ skybox.explore.init();
11
+ });
12
+ </script>
@@ -8,7 +8,7 @@
8
8
  <select class="span6 table-name">
9
9
  <option></option>
10
10
  <% @tables.each do |table| %>
11
- <option><%= table['name'] %></option>
11
+ <option><%= table.name %></option>
12
12
  <% end %>
13
13
  </select>
14
14
  </div>
@@ -10,22 +10,17 @@
10
10
  <link href="/css/bootstrap.css" rel="stylesheet">
11
11
  <link href="/css/bootstrap-responsive.css" rel="stylesheet">
12
12
  <link href="/css/skybox.css" rel="stylesheet">
13
- <% if File.exists?("#{settings.public_folder}/css/skybox.#{@action}.css") %>
14
- <link href="/css/skybox.<%= @action %>.css" rel="stylesheet">
15
- <% end %>
16
13
 
17
14
  <script src="/js/jquery-1.9.1.js"></script>
18
15
  <script src="/js/bootstrap.js"></script>
16
+ <script src="/js/humanize.js"></script>
19
17
  <script src="/js/d3.v3.js"></script>
20
18
  <script src="/js/d3.flow.js"></script>
21
- <script src="/js/humanize.js"></script>
22
19
  <script src="/js/skybox.js"></script>
23
- <% if File.exists?("#{settings.public_folder}/css/skybox.#{@action}.css") %>
24
- <script src="/js/skybox.<%= @action %>.js"></script>
25
- <% end %>
20
+ <script src="/js/skybox.query.js"></script>
26
21
 
27
22
  <script>
28
- skybox.table(<%= @table.to_json %>);
23
+ skybox.table(<%= @table_name.to_json %>);
29
24
  </script>
30
25
 
31
26
  <!--[if lt IE 9]>
@@ -38,17 +33,9 @@
38
33
  <% if request.path != '/' %>
39
34
  <div class="navbar">
40
35
  <div class="navbar-inner">
41
- <a class="brand" href="/"><%= @table.nil? ? 'Skybox' : @table %></a>
36
+ <a class="brand" href="/"><%= @table_name.nil? ? 'Skybox' : @table_name %></a>
42
37
  <ul class="nav">
43
- <li class="<%= @action == 'explore' ? 'active' : '' %>"><a href="/<%=@table%>/explore">Explore</a></li>
44
- <li class="dropdown">
45
- <a href="#" role="button" class="dropdown-toggle <%= request.path.index(/[^\/]+\/admin/i).nil? ? '' : 'active' %>" data-toggle="dropdown">Admin <b class="caret"></b></a>
46
- <ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
47
- <li role="presentation"><a role="menuitem" tabindex="-1" href="/<%= @table %>/admin/actions">Manage Actions</a></li>
48
- <li role="presentation"><a role="menuitem" tabindex="-1" href="/<%= @table %>/admin/properties">Manage Properties</a></li>
49
- </ul>
50
- </li>
51
-
38
+ <li class="<%= @action == 'explore' ? 'active' : '' %>"><a href="/<%=@table_name%>/explore">Explore</a></li>
52
39
  </ul>
53
40
 
54
41
  <div class="pull-right"><img class="loading" src="/img/loading.gif"/></div>
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skybox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3.1
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ben Johnson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
11
+ date: 2013-04-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sinatra
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 1.3.3
19
+ version: 1.4.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 1.3.3
26
+ version: 1.4.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thin
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,39 +41,34 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: commander
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 4.1.2
47
+ version: 4.1.3
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: 4.1.2
54
+ version: 4.1.3
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: skydb
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: 0.2.3
61
+ version: 0.3.0
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
77
- version: 0.2.3
68
+ version: 0.3.0
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: unindentable
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,87 +83,76 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
101
- version: 10.0.3
89
+ version: 10.0.4
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
109
- version: 10.0.3
96
+ version: 10.0.4
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: minitest
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
117
- version: 4.3.3
103
+ version: 4.7.0
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
125
- version: 4.3.3
110
+ version: 4.7.0
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: mocha
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
133
- version: 0.13.1
117
+ version: 0.13.3
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ~>
140
123
  - !ruby/object:Gem::Version
141
- version: 0.13.1
124
+ version: 0.13.3
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: rerun
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ~>
148
130
  - !ruby/object:Gem::Version
149
- version: 0.7.1
131
+ version: 0.8.0
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ~>
156
137
  - !ruby/object:Gem::Version
157
- version: 0.7.1
138
+ version: 0.8.0
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: rb-fsevent
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - ~>
164
144
  - !ruby/object:Gem::Version
165
- version: 0.9.1
145
+ version: 0.9.3
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - ~>
172
151
  - !ruby/object:Gem::Version
173
- version: 0.9.1
152
+ version: 0.9.3
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: rack-test
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
157
  - - ~>
180
158
  - !ruby/object:Gem::Version
@@ -182,7 +160,6 @@ dependencies:
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
164
  - - ~>
188
165
  - !ruby/object:Gem::Version
@@ -211,9 +188,8 @@ files:
211
188
  - lib/skybox/static/js/jquery-1.9.1.js
212
189
  - lib/skybox/static/js/skybox.explore.js
213
190
  - lib/skybox/static/js/skybox.js
191
+ - lib/skybox/static/js/skybox.query.js
214
192
  - lib/skybox/version.rb
215
- - lib/skybox/views/admin/actions/index.erb
216
- - lib/skybox/views/admin/properties/index.erb
217
193
  - lib/skybox/views/explore.erb
218
194
  - lib/skybox/views/index.erb
219
195
  - lib/skybox/views/layout.erb
@@ -222,32 +198,25 @@ files:
222
198
  - bin/skybox
223
199
  homepage: http://github.com/skydb/skybox
224
200
  licenses: []
201
+ metadata: {}
225
202
  post_install_message:
226
203
  rdoc_options: []
227
204
  require_paths:
228
205
  - lib
229
206
  required_ruby_version: !ruby/object:Gem::Requirement
230
- none: false
231
207
  requirements:
232
208
  - - ! '>='
233
209
  - !ruby/object:Gem::Version
234
210
  version: '0'
235
- segments:
236
- - 0
237
- hash: 4266038721710341627
238
211
  required_rubygems_version: !ruby/object:Gem::Requirement
239
- none: false
240
212
  requirements:
241
213
  - - ! '>='
242
214
  - !ruby/object:Gem::Version
243
215
  version: '0'
244
- segments:
245
- - 0
246
- hash: 4266038721710341627
247
216
  requirements: []
248
217
  rubyforge_project:
249
- rubygems_version: 1.8.25
218
+ rubygems_version: 2.0.3
250
219
  signing_key:
251
- specification_version: 3
220
+ specification_version: 4
252
221
  summary: Sky-based Analytics Frontend
253
222
  test_files: []