Updates dashboard and display to use AppView
authorDavid Schoonover <dsc@wikimedia.org>
Tue, 12 Jun 2012 18:12:15 +0000 (11:12 -0700)
committerDavid Schoonover <dsc@wikimedia.org>
Tue, 12 Jun 2012 18:12:15 +0000 (11:12 -0700)
docs/todo.md
lib/main-dashboard.co
lib/main-display.co
www/css/dashboard.styl

index d501f71..9b16166 100644 (file)
@@ -1,7 +1,7 @@
 # todo
 
 ## GitHub Migration
-- Replace all instances of "Kraken" and "Limn" with "Limn"
+- Replace all instances of "Kraken" and "GraphKit" with "Limn"
 - Create library entry point & config
 - Resolve workflow for /data
     - Extract history for /data, re-commit metadata files
index 3cbffc1..5bc8c8d 100644 (file)
@@ -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
 
index b99be29..f5f2b04 100644 (file)
@@ -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
index 8e27375..c53a83b 100644 (file)
@@ -22,7 +22,8 @@
 #dashboard
     
     section.graph
-        margin 7em auto
+        margin 0 auto
+        padding 3.5em 0
     
     section.graph:first-child
         margin-top 0