blob: 65e0b71d9e70a4522250e9c53f26499f68ad4c1e [file] [log] [blame]
Pankaj Berdec4ae4b82013-01-12 09:56:47 -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.FlowView = Backbone.View.extend({
19
20 initialize:function () {
21 this.template = _.template(tpl.get('flow'));
22 this.model.bind("change", this.render, this);
23 },
24
25 render:function (eventName) {
26 $(this.el).html(this.template(this.model.toJSON()));
27 return this;
28 }
29
30});
31
32window.FlowListItemView = Backbone.View.extend({
33
34 tagName:"tr",
35
36 initialize:function () {
37 this.template = _.template(tpl.get('flow-list-item'));
38 this.model.bind("change", this.render, this);
39 },
40
41 render:function (eventName) {
42 $(this.el).html(this.template(this.model.toJSON()));
43 return this;
44 }
45
46});
47
48// TODO throughput (bps) and pps sparklines would be nice here
49// TODO hovering over a MAC address could show a compact view of that host
50window.FlowListView = Backbone.View.extend({
51
52 initialize:function () {
53 this.template = _.template(tpl.get('flow-list'));
54 this.model.bind("change", this.render, this);
55 this.model.bind("add", this.render, this);
56 },
57
58 render:function (eventName) {
59 // console.log("rendering flow list view: " + this.model.models.length);
60 $(this.el).html(this.template({nflows:this.model.length}));
61 _.each(this.model.models, function (f) {
62 $(this.el).find('table.flow-table > tbody')
63 .append(new FlowListItemView({model:f}).render().el);
64 }, this);
65 return this;
66 },
67
68});
69