From d7299d3ef09a2054ab797eb8d80ea9420811ca46 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 --- .../datasources/mobile_devices/mobile_devices.yaml | 24 +++++++++ .../mobile_devices_applications.yaml | 28 +++++++++++ .../mobile_devices/mobile_devices_browsers.yaml | 24 +++++++++ lib/dashboard/dashboard-model.co | 7 ++- lib/dashboard/dashboard-view.co | 52 ++++++++++++-------- 5 files changed, 112 insertions(+), 23 deletions(-) create mode 100644 data/datasources/mobile_devices/mobile_devices.yaml create mode 100644 data/datasources/mobile_devices/mobile_devices_applications.yaml create mode 100644 data/datasources/mobile_devices/mobile_devices_browsers.yaml diff --git a/data/datasources/mobile_devices/mobile_devices.yaml b/data/datasources/mobile_devices/mobile_devices.yaml new file mode 100644 index 0000000..862130c --- /dev/null +++ b/data/datasources/mobile_devices/mobile_devices.yaml @@ -0,0 +1,24 @@ +id: mobile_devices +name: Mobile Devices +shortName : Mobile Devices +format: csv +url: /data/datasources/mobile_devices/mobile_devices.csv + +timespan: + end: 2012/03/01 + start: 2011/11/01 + step: 1mo + +columns: + labels: + - Month + - Total + - Browser + - Apps + types: + - date + - int + - int + - int +chart: + chartType: dygraphs diff --git a/data/datasources/mobile_devices/mobile_devices_applications.yaml b/data/datasources/mobile_devices/mobile_devices_applications.yaml new file mode 100644 index 0000000..4f46be4 --- /dev/null +++ b/data/datasources/mobile_devices/mobile_devices_applications.yaml @@ -0,0 +1,28 @@ +id: mobile_devices_applications +name: Mobile Devices Applications +shortName : Mobile Devices Applications +format: csv +url: /data/datasources/mobile_devices/mobile_devices_applications.csv + +timespan: + end: 2012/03/01 + start: 2011/11/01 + step: 1mo + +columns: + labels: + - Month + - Wikimedia Andriod + - Other Android + - Wikimedia iOS + - Other iOS + - Unspecified + types: + - date + - int + - int + - int + - int + - int +chart: + chartType: dygraphs diff --git a/data/datasources/mobile_devices/mobile_devices_browsers.yaml b/data/datasources/mobile_devices/mobile_devices_browsers.yaml new file mode 100644 index 0000000..85d37e1 --- /dev/null +++ b/data/datasources/mobile_devices/mobile_devices_browsers.yaml @@ -0,0 +1,24 @@ +id: mobile_devices_applications +name: Mobile Devices Browsers +shortName : Mobile Devices Browsers +format: csv +url: /data/datasources/mobile_devices/mobile_devices_browsers.csv + +timespan: + end: 2012/03/01 + start: 2011/11/01 + step: 1mo + +columns: + labels: + - Month + - Tablet Browser + - Other Browser + - WAP Access + types: + - date + - int + - int + - int +chart: + chartType: dygraphs 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