Scott Baker | e41c908 | 2014-10-27 23:02:48 -0700 | [diff] [blame] | 1 | TestApp = new Marionette.Application(); |
| 2 | |
| 3 | TestApp.addRegions({ |
| 4 | deploymentList: "#deploymentList", |
| 5 | imageList: "#imageList", |
| 6 | networkTemplateList: "#networkTemplateList", |
| 7 | networkList: "#networkList", |
| 8 | nodeList: "#nodeList", |
| 9 | serviceList: "#serviceList", |
| 10 | siteList: "#siteList", |
| 11 | sliceList: "#sliceList", |
| 12 | sliverList: "#sliverList", |
| 13 | userList: "#userList" |
| 14 | }); |
| 15 | |
| 16 | // ---- Deployment ---- |
| 17 | |
| 18 | TestApp.DeploymentListItemView = Marionette.ItemView.extend({ |
| 19 | template: '#test-deployment-listitem-template', |
| 20 | tagName: 'tr', |
| 21 | className: 'test-tablerow', |
| 22 | }); |
| 23 | |
| 24 | TestApp.DeploymentListView = Marionette.CompositeView.extend({ |
| 25 | childView: TestApp.DeploymentListItemView, |
| 26 | childViewContainer: 'tbody', |
| 27 | template: '#test-deployment-list-template', |
| 28 | |
| 29 | initialize: function() { |
| 30 | this.listenTo(this.collection, 'change', this._renderChildren) |
| 31 | }, |
| 32 | }); |
| 33 | |
| 34 | TestApp.on("start", function() { |
| 35 | var objs = ['deployment', 'image', 'networkTemplate', 'network', 'node', 'service', 'site', 'slice', 'sliver']; |
| 36 | |
| 37 | for (var index in objs) { |
| 38 | name = objs[index]; |
| 39 | tr_template = '#test-' + name + '-listitem-template'; |
| 40 | table_template = '#test-' + name + '-list-template'; |
| 41 | collection_name = name + "s"; |
| 42 | region_name = name + "List"; |
| 43 | |
| 44 | itemViewClass = Marionette.ItemView.extend({ |
| 45 | template: tr_template, |
| 46 | tagName: 'tr', |
| 47 | className: 'test-tablerow', |
| 48 | }); |
| 49 | |
| 50 | listViewClass = Marionette.CompositeView.extend({ |
| 51 | childView: itemViewClass, |
| 52 | childViewContainer: 'tbody', |
| 53 | template: table_template, |
| 54 | collection: xos[collection_name], |
| 55 | |
| 56 | initialize: function() { |
| 57 | this.listenTo(this.collection, 'change', this._renderChildren) |
| 58 | }, |
| 59 | }); |
| 60 | |
| 61 | var listView = new listViewClass(); |
| 62 | |
| 63 | TestApp[region_name].show(listView); |
| 64 | xos[collection_name].startPolling(); |
| 65 | } |
| 66 | }); |
| 67 | |
| 68 | $(document).ready(function(){ |
| 69 | TestApp.start();
|
| 70 | }); |
| 71 | |