forked from Polychart/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoly.coffee
49 lines (40 loc) · 1.69 KB
/
poly.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require('poly/main/init')
ChartMainView = require('poly/main/main/chartbuilder')
ChartViewerMainView = require('poly/main/main/chartviewer')
DashMainView = require('poly/main/main/dashbuilder')
DashViewerMainView = require('poly/main/main/dashviewer')
{LocalDataSource, RemoteDataSource} = require('poly/main/data/dataSource')
module.exports = {
dashboard: (params) ->
# Mark the target element
$(params.dom).addClass 'polychart-ui'
view = new DashMainView(params)
ko.renderTemplate("tmpl-main", view, {}, params.dom)
# return only the public facing functions
serialize: view.serialize
dashviewer: (params) ->
# Mark the target element
$(params.dom).addClass 'polychart-ui'
view = new DashViewerMainView(params)
ko.renderTemplate("tmpl-dashboard-viewer", view, {}, params.dom)
return {} # is there something to be returned?
chartbuilder: (params) ->
# Mark the target element
$(params.dom).addClass 'polychart-ui'
view = new ChartMainView(params)
ko.renderTemplate("tmpl-main-chart", view, {}, params.dom)
# return only the public facing functions
serialize: view.serialize
chartviewer: (params) ->
# Mark the target element
$(params.dom).addClass 'polychart-ui'
view = new ChartViewerMainView(params)
ko.renderTemplate("tmpl-chart-viewer", view, {afterRender: view.init}, params.dom)
return {} # is there something to be returned?
data: (args) ->
switch args.type
when 'local'
new LocalDataSource(args.tables)
when 'remote'
new RemoteDataSource(args.dataSourceKey, args.customBackend, args.dataSourceType)
}