Skip to content
Browse files

group_by buttons

  • Loading branch information...
1 parent bb24c60 commit 3d9ceb96d9fcd0b2c06abad57d6a0caed7d3c072 @myf myf committed
Showing with 42 additions and 16 deletions.
  1. +10 −0 bamboo-meteor-client.html
  2. +13 −0 client/client.coffee
  3. +19 −16 server/server.coffee
View
10 bamboo-meteor-client.html
@@ -23,8 +23,18 @@
<ul>
<li>control panel</li>
<button class="btn" id="charting-button" > chart </button>
+ =======================
+ {{#each groups}}
+ {{> group}}
+ {{/each}}
</ul>
</template>
+<template name="group">
+<li>
+ <button class="btn" id="{{this}}" > {{this}}</button>
+</li>
+
+</template>
<template name="navbar">
<div class="navbar-inner">
View
13 client/client.coffee
@@ -12,6 +12,7 @@ if root.Meteor.is_client
url = $('#datasource-url').val()
Session.set('currentDatasetURL', url)
#TODO: put the following in a Meteor.subscribe section?
+ #TODO: eliminates null url from being registered into db
if !Datasets.findOne(url: url)
console.log "caching server side.."
Meteor.call('register_dataset', url)
@@ -19,6 +20,17 @@ if root.Meteor.is_client
console.log "already cached server side.."
root.Template.control.events = "click button": ->
Meteor.call("charting")
+ root.Template.control.groups = ->
+ url = Session.get('currentDatasetURL')
+ datacursor = Summaries.find(datasetSourceURL: url, groupKey: '', groupVal: '(ALL)')
+ _(datacursor.fetch()).pluck("name")
+ root.Template.group.events = "click button": ->
+ group = this
+ url = Session.get('currentDatasetURL')
+ Meteor.call("summarize_by_group",[url,group])
+
+
+
root.Template.maincontent.columns = ->
url = Session.get('currentDatasetURL')
@@ -37,6 +49,7 @@ if root.Meteor.is_client
Meteor.startup ->
Session.set('currentDatasetURL', constants.defaultURL)
+ Session.set('currentGroup', '')
############# UI LIB #############################
View
35 server/server.coffee
@@ -10,22 +10,25 @@ summaryURLf = (id,group) -> datasetsURL + '/' + id + '/summary' + if group then
#Note: methods can live anywhere, regardless of server or client
Meteor.methods(
register_dataset: (url) ->
- console.log "server received url: " + url
- unless Datasets.findOne({url: url})
- post_options =
- uri: datasetsURL
- method: 'POST'
- form: {url: url}
- request post_options, (e, b, response) ->
- Fiber(->
- Datasets.insert
- bambooID: JSON.parse(response).id
- url: url
- cached_at: Date.now()
- ).run()
- summaryCallback = -> Fiber( ->
- Meteor.call('summarize_by_group', [url, ''])).run()
- setTimeout summaryCallback, 1000
+ if url is null
+ console.log "null url! discard!"
+ else
+ console.log "server received url " + url
+ unless Datasets.findOne({url: url})
+ post_options =
+ uri: datasetsURL
+ method: 'POST'
+ form: {url: url}
+ request post_options, (e, b, response) ->
+ Fiber(->
+ Datasets.insert
+ bambooID: JSON.parse(response).id
+ url: url
+ cached_at: Date.now()
+ ).run()
+ summaryCallback = -> Fiber( ->
+ Meteor.call('summarize_by_group', [url, ''])).run()
+ setTimeout summaryCallback, 1000
summarize_by_group: (obj) ->
# tease out individual summary objects from bamboo output + store
[datasetURL, groupkey] = obj

0 comments on commit 3d9ceb9

Please sign in to comment.
Something went wrong with that request. Please try again.