From: David Schoonover Date: Tue, 12 Jun 2012 18:12:15 +0000 (-0700) Subject: Updates dashboard and display to use AppView X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=8a9ec5118be6244dddeb86c63a4ac541a39493e4;p=limn.git Updates dashboard and display to use AppView --- diff --git a/lib/main-dashboard.co b/lib/main-dashboard.co index 3cbffc1..5bc8c8d 100644 --- a/lib/main-dashboard.co +++ b/lib/main-dashboard.co @@ -3,6 +3,8 @@ Backbone = require 'backbone' { _, op, } = require 'kraken/util' +{ AppView, +} = require 'kraken/app' { BaseView, BaseModel, BaseList, } = require 'kraken/base' { ChartType, DygraphsChartType, @@ -13,40 +15,15 @@ Backbone = require 'backbone' } = require 'kraken/dashboard' - root = this -CHART_OPTIONS_SPEC = [] -CHART_DEFAULT_OPTIONS = {} # Create the Graph Scaffold main = -> - # Set up Dygraph chart type spec - # TODO: load this on-demand - dyglib = new DygraphsChartType CHART_OPTIONS_SPEC - - # _.dump _.clone(data.options), 'data.options' - # Instantiate model & view - dashboard = root.dashboard = new DashboardView do - graph_spec : root.CHART_OPTIONS_SPEC # FIXME: necessary? - - $ '#content .inner' .append dashboard.el - - - -# Load dygraph chart options -Seq([ <[ CHART_OPTIONS_SPEC /schema/dygraph.json ]> -]) -.parEach_ (next, [key, url]) -> - jQuery.ajax do - url : url, - dataType : 'json' - success : (res) -> - root[key] = res - next.ok() - error : (err) -> console.error err -.seq -> - # console.log 'All data loaded!' - jQuery main + root.app = new AppView -> + @view = root.dashboard = new DashboardView {@model} + + +jQuery main diff --git a/lib/main-display.co b/lib/main-display.co index b99be29..f5f2b04 100644 --- a/lib/main-display.co +++ b/lib/main-display.co @@ -3,6 +3,8 @@ Backbone = require 'backbone' { _, op, } = require 'kraken/util' +{ AppView, +} = require 'kraken/app' { BaseView, BaseModel, BaseList, } = require 'kraken/base' { ChartType, DygraphsChartType, @@ -18,10 +20,6 @@ CHART_DEFAULT_OPTIONS = {} # Create the Graph Scaffold main = -> - # Set up Dygraph chart type spec - # TODO: load this on-demand - dyglib = new DygraphsChartType CHART_OPTIONS_SPEC - # Bind to URL changes History.Adapter.bind window, 'statechange', -> # console.log 'StateChange!\n\n', String(root.location), '\n\n' @@ -33,12 +31,12 @@ main = -> data = {} # If we got querystring args, apply them to the graph - if loc.split '?' .1 - data = _.uncollapseObject _.fromKV that.replace('#', '%23') - data.parents = JSON.parse that if data.parents - data.options = _.synthesize do - data.options or {} - (v, k) -> [ k, dyglib.parseOption(k,v) ] + # if loc.split '?' .1 + # data = _.uncollapseObject _.fromKV that.replace('#', '%23') + # data.parents = JSON.parse that if data.parents + # data.options = _.synthesize do + # data.options or {} + # (v, k) -> [ k, dyglib.parseOption(k,v) ] # Extract id from URL if match = /\/graphs\/([^\/?]+)/i.exec loc @@ -48,27 +46,8 @@ main = -> # _.dump _.clone(data.options), 'data.options' # Instantiate model & view - graph = root.graph = new Graph data, {+parse} - view = root.view = new GraphDisplayView do - graph_spec : root.CHART_OPTIONS_SPEC # FIXME: necessary? - model : graph - - $ '#content .inner' .append view.el - - - -# Load data files -Seq([ <[ CHART_OPTIONS_SPEC /schema/dygraph.json ]> -]) -.parEach_ (next, [key, url]) -> - jQuery.ajax do - url : url, - dataType : 'json' - success : (res) -> - root[key] = res - next.ok() - error : (err) -> console.error err -.seq -> - # console.log 'All data loaded!' - jQuery main + root.app = new AppView -> + @model = root.graph = new Graph data, {+parse} + @view = root.view = new GraphDisplayView {@model} +jQuery main diff --git a/www/css/dashboard.styl b/www/css/dashboard.styl index 8e27375..c53a83b 100644 --- a/www/css/dashboard.styl +++ b/www/css/dashboard.styl @@ -22,7 +22,8 @@ #dashboard section.graph - margin 7em auto + margin 0 auto + padding 3.5em 0 section.graph:first-child margin-top 0