aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/stores/flowstore.js
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-11-27 01:38:30 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-11-27 01:38:30 +0100
commit38bf34ebd9826c6f69d97906282632fbd5cff06b (patch)
tree1616a6918c4b1a939a810a441a033ea5cf4b0122 /web/src/js/stores/flowstore.js
parent021e209ce0fbfa5fa993ad43e8167a29a759d120 (diff)
downloadmitmproxy-38bf34ebd9826c6f69d97906282632fbd5cff06b.tar.gz
mitmproxy-38bf34ebd9826c6f69d97906282632fbd5cff06b.tar.bz2
mitmproxy-38bf34ebd9826c6f69d97906282632fbd5cff06b.zip
web++
Diffstat (limited to 'web/src/js/stores/flowstore.js')
-rw-r--r--web/src/js/stores/flowstore.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/web/src/js/stores/flowstore.js b/web/src/js/stores/flowstore.js
index 53048441..91a5d9ec 100644
--- a/web/src/js/stores/flowstore.js
+++ b/web/src/js/stores/flowstore.js
@@ -37,13 +37,8 @@ _.extend(FlowStore.prototype, {
this._pos_map[flow.id] = i;
}
},
- open_view: function (filt, sort) {
- var view = new FlowView(this._flow_list, filt, sort);
- this._views.push(view);
- return view;
- },
- close_view: function (view) {
- this._views = _.without(this._views, view);
+ get: function(flow_id){
+ return this._flow_list[this._pos_map[flow_id]];
}
});
@@ -60,6 +55,15 @@ function LiveFlowStore(endpoint) {
}.bind(this);
}
_.extend(LiveFlowStore.prototype, FlowStore.prototype, {
+ close: function(){
+ this.conn.close();
+ },
+ add: function(flow) {
+ // Make sure that deferred adds don't add an element twice.
+ if(!this._pos_map[flow.id]){
+ FlowStore.prototype.add.call(this, flow);
+ }
+ },
handle_update: function (type, data) {
console.log("LiveFlowStore.handle_update", type, data);
if (this.updates_before_init) {
@@ -100,16 +104,22 @@ SortByInsertionOrder.prototype.key = function (flow) {
var default_sort = (new SortByInsertionOrder()).key;
-function FlowView(flows, filt, sort) {
+function FlowView(store, filt, sort) {
EventEmitter.call(this);
filt = filt || function (flow) {
return true;
};
sort = sort || default_sort;
- this.recalculate(flows, filt, sort);
+
+ this.store = store;
+ this.store._views.push(this);
+ this.recalculate(this.store._flow_list, filt, sort);
}
_.extend(FlowView.prototype, EventEmitter.prototype, {
+ close: function(){
+ this.store._views = _.without(this.store._views, this);
+ },
recalculate: function (flows, filt, sort) {
if (filt) {
this.filt = filt;