From 4ed66273fe973f0b37c0a8c45ec1c6a00cbe1760 Mon Sep 17 00:00:00 2001 From: erosen Date: Thu, 5 Jul 2012 19:02:32 -0700 Subject: [PATCH] added yaml files for mobile charts --- lib/dashboard/dashboard-model.co | 7 +++-- lib/dashboard/dashboard-view.co | 52 +++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/lib/dashboard/dashboard-model.co b/lib/dashboard/dashboard-model.co index 6b4a866..a1e9544 100644 --- a/lib/dashboard/dashboard-model.co +++ b/lib/dashboard/dashboard-model.co @@ -114,16 +114,17 @@ Dashboard = exports.Dashboard = BaseModel.extend do # {{{ # consolidate graph_ids to one array graph_ids = _(@tabs).chain().values().map((tab_obj) -> tab_obj.graph_ids).flatten().value() - Seq [graph_ids] - .flatten() + Seq graph_ids .parMap_ (next, graph_id) -> - next null [graph_id] + next null, [graph_id] .parEach_ (next, graph_id_arr) ~> Graph.lookup graph_id_arr[0], @pushAsync next, graph_id_arr # Graph.lookup graph_id_arr[0], (err, el) -> # graph_id_arr.push el # next null # .parEach_ @show + .parMap_ (next, [id, graph]:tuple) ~> + graph.once 'ready', -> next.ok tuple .unflatten() .seq_ (next, graph_tuples) ~> @graphs = _.generate graph_tuples diff --git a/lib/dashboard/dashboard-view.co b/lib/dashboard/dashboard-view.co index fafbb2c..2831d17 100644 --- a/lib/dashboard/dashboard-view.co +++ b/lib/dashboard/dashboard-view.co @@ -23,27 +23,28 @@ DashboardView = exports.DashboardView = BaseView.extend do # {{{ events: # Select the whole permalink URI text when it receives focus. 'click .graphs.tabbable .nav a' : 'onTabClick' - 'shown .graphs.tabbable .nav a' : 'onTabShown' + 'shown .graphs.tabbable .nav a' : 'render' + # 'shown .graphs.tabbable .nav a' : 'onTabShown' # 'click a[data-target="#other-graphs"]' : 'onTabShown' # 'click .load-button' : 'load' - subviews : [] + # subviews : [] graphs : null ready : false constructor: function DashboardView(options={}) @model = options.model - @subviews = [] + # @subviews = [] @graphs = new GraphList - Backbone.View ... + BaseView ... initialize: -> @model or= new Dashboard BaseView::initialize ... # @graphs.on 'add', @attachGraphs, this # @graphs.on 'add', @attachGraph, this - @model.on('ready', @load, this) + @model.on 'ready', @load, this # FIXME: @@ -52,29 +53,40 @@ DashboardView = exports.DashboardView = BaseView.extend do # {{{ # TODO: # - only render graph when scrolling makes it visible load: -> - _.map(@model.tabs, @addTab) + console.log "#this.load! Model ready!", @model + _.map @model.tabs, @addTab addTab: (tab) -> - self = this + # self = this graphs = _(tab.graph_ids).map((graph_id) ~> @model.graphs[graph_id]) Seq(graphs) - .parMap (graph) -> - self.graphs.add graph - this null, new GraphDisplayView {model:graph} - .parMap (view) -> - return if view.isAttached - graphs_el = self.$el.find tab.name - graphs_el.append view.el - self.subviews.push view - view.isAttached = true + .parMap_ (next, graph) ~> + @graphs.add graph + next null, new GraphDisplayView {model:graph} + .parMap_ (next, view) ~> + return next.ok() if view.isAttached + @addSubview view + tabEl = @$ tab.name + if tabEl.length + tabEl.append view.$el + view.isAttached = true + else + console.log "#this.addTab: Unable to find bind-point for #view!", view + next.ok() + .seq ~> + console.log "#this.addTab: All graphs added!" + @render() + this ### Tabs {{{ onTabShown: (e) -> - Seq @subviews - .parMap (view) -> - # view.resizeViewport() - view.renderChart() + @render() + # @renderSubviews() + # Seq @subviews + # .parMap (view) -> + # # view.resizeViewport() + # view.renderChart() onTabClick: (evt) -> evt.preventDefault() -- 1.7.0.4