blob: e9aadb9103a13b320e9131add8e0dfc68ca015fe [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/*
2 Copyright 2012 IBM
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17// not used for now
18window.PortView = Backbone.View.extend({
19
20 initialize:function () {
21 this.template = _.template(tpl.get('port'));
22 this.model.bind("change", this.render, this);
23 //this.model.bind("destroy", this.close, this);
24 },
25
26 render:function (eventName) {
27 $(this.el).html(this.template(this.model.toJSON()));
28 return this;
29 }
30
31});
32
33window.PortListItemView = Backbone.View.extend({
34
35 tagName:"tr",
36
37 initialize:function () {
38 this.template = _.template(tpl.get('port-list-item'));
39 this.model.bind("change", this.render, this);
40 //this.model.bind("destroy", this.close, this);
41 },
42
43 render:function (eventName) {
44 $(this.el).html(this.template(this.model.toJSON()));
45 return this;
46 }
47
48});
49
50// TODO throughput sparklines would be nice here
51window.PortListView = Backbone.View.extend({
52
53 initialize:function () {
54 this.template = _.template(tpl.get('port-list'));
55 this.model.bind("change", this.render, this);
56 this.model.bind("add", this.render, this);
57 },
58
59 render:function (eventName) {
60 // console.log("rendering port list view");
61 $(this.el).html(this.template({nports:this.model.length}));
62 _.each(this.model.models, function (p) {
63 $(this.el).find('table.port-table > tbody')
64 .append(new PortListItemView({model:p}).render().el);
65 }, this);
66 return this;
67 },
68
69});
70