2014-09-17 13:22:42 +00:00
|
|
|
// http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html (also contains inverse example)
|
|
|
|
var AutoScrollMixin = {
|
|
|
|
componentWillUpdate: function () {
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
this._shouldScrollBottom = node.scrollTop + node.clientHeight === node.scrollHeight;
|
|
|
|
},
|
|
|
|
componentDidUpdate: function () {
|
|
|
|
if (this._shouldScrollBottom) {
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
node.scrollTop = node.scrollHeight;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2014-09-18 19:13:50 +00:00
|
|
|
var StickyHeadMixin = {
|
2014-09-18 23:35:36 +00:00
|
|
|
adjustHead: function () {
|
2014-09-18 19:13:50 +00:00
|
|
|
// Abusing CSS transforms to set the element
|
|
|
|
// referenced as head into some kind of position:sticky.
|
|
|
|
var head = this.refs.head.getDOMNode();
|
2014-09-18 23:35:36 +00:00
|
|
|
head.style.transform = "translate(0," + this.getDOMNode().scrollTop + "px)";
|
2014-09-18 19:13:50 +00:00
|
|
|
}
|
|
|
|
};
|
2014-09-18 00:22:10 +00:00
|
|
|
|
|
|
|
var Key = {
|
|
|
|
UP: 38,
|
|
|
|
DOWN: 40,
|
2014-09-18 19:13:50 +00:00
|
|
|
PAGE_UP: 33,
|
|
|
|
PAGE_DOWN: 34,
|
2014-09-18 00:22:10 +00:00
|
|
|
LEFT: 37,
|
|
|
|
RIGHT: 39,
|
|
|
|
ENTER: 13,
|
2014-09-19 15:56:54 +00:00
|
|
|
ESC: 27,
|
|
|
|
TAB: 9,
|
|
|
|
SPACE: 32,
|
|
|
|
J: 74,
|
|
|
|
K: 75,
|
|
|
|
H: 72,
|
|
|
|
L: 76
|
2014-09-18 19:13:50 +00:00
|
|
|
};
|
2014-09-18 23:35:36 +00:00
|
|
|
|
2014-09-19 15:56:54 +00:00
|
|
|
var formatSize = function (bytes) {
|
|
|
|
var size = bytes;
|
2014-09-18 23:35:36 +00:00
|
|
|
var prefix = ["B", "KB", "MB", "GB", "TB"];
|
|
|
|
while (size >= 1024 && prefix.length > 1) {
|
|
|
|
prefix.shift();
|
|
|
|
size = size / 1024;
|
|
|
|
}
|
2014-09-19 15:56:54 +00:00
|
|
|
return (Math.floor(size * 100) / 100.0).toFixed(2) + prefix.shift();
|
|
|
|
};
|
|
|
|
|
|
|
|
var formatTimeDelta = function (milliseconds) {
|
|
|
|
var time = milliseconds;
|
|
|
|
var prefix = ["ms", "s", "m", "h"];
|
|
|
|
var div = [1000, 60, 60];
|
|
|
|
while (time >= div[0] && prefix.length > 1) {
|
|
|
|
prefix.shift();
|
|
|
|
time = time / div.shift();
|
|
|
|
}
|
|
|
|
return Math.round(time) + prefix.shift();
|
2014-09-18 23:35:36 +00:00
|
|
|
};
|
2014-09-15 16:08:26 +00:00
|
|
|
const PayloadSources = {
|
2014-09-17 13:22:42 +00:00
|
|
|
VIEW: "view",
|
|
|
|
SERVER: "server"
|
2014-09-15 16:08:26 +00:00
|
|
|
};
|
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
|
2014-09-17 00:13:37 +00:00
|
|
|
function Dispatcher() {
|
2014-09-16 09:06:30 +00:00
|
|
|
this.callbacks = [];
|
|
|
|
}
|
2014-09-17 00:13:37 +00:00
|
|
|
Dispatcher.prototype.register = function (callback) {
|
2014-09-16 09:06:30 +00:00
|
|
|
this.callbacks.push(callback);
|
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
Dispatcher.prototype.unregister = function (callback) {
|
2014-09-16 09:06:30 +00:00
|
|
|
var index = this.callbacks.indexOf(f);
|
|
|
|
if (index >= 0) {
|
|
|
|
this.callbacks.splice(this.callbacks.indexOf(f), 1);
|
2014-09-14 00:44:13 +00:00
|
|
|
}
|
2014-09-16 09:06:30 +00:00
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
Dispatcher.prototype.dispatch = function (payload) {
|
2014-09-16 09:06:30 +00:00
|
|
|
console.debug("dispatch", payload);
|
2014-09-17 00:13:37 +00:00
|
|
|
this.callbacks.forEach(function (callback) {
|
2014-09-16 09:06:30 +00:00
|
|
|
callback(payload);
|
|
|
|
});
|
|
|
|
};
|
2014-09-14 00:44:13 +00:00
|
|
|
|
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
AppDispatcher = new Dispatcher();
|
2014-09-17 00:13:37 +00:00
|
|
|
AppDispatcher.dispatchViewAction = function (action) {
|
2014-09-17 13:22:42 +00:00
|
|
|
action.source = PayloadSources.VIEW;
|
2014-09-15 22:56:43 +00:00
|
|
|
this.dispatch(action);
|
2014-09-15 16:08:26 +00:00
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
AppDispatcher.dispatchServerAction = function (action) {
|
2014-09-17 13:22:42 +00:00
|
|
|
action.source = PayloadSources.SERVER;
|
2014-09-15 22:56:43 +00:00
|
|
|
this.dispatch(action);
|
2014-09-15 22:05:06 +00:00
|
|
|
};
|
2014-09-16 04:26:16 +00:00
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
var ActionTypes = {
|
2014-09-17 15:30:19 +00:00
|
|
|
//Settings
|
2014-09-17 13:22:42 +00:00
|
|
|
UPDATE_SETTINGS: "update_settings",
|
2014-09-17 15:30:19 +00:00
|
|
|
|
|
|
|
//EventLog
|
|
|
|
ADD_EVENT: "add_event",
|
|
|
|
|
|
|
|
//Flow
|
|
|
|
ADD_FLOW: "add_flow",
|
|
|
|
UPDATE_FLOW: "update_flow",
|
2014-09-15 16:08:26 +00:00
|
|
|
};
|
2014-09-14 00:44:13 +00:00
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
var SettingsActions = {
|
2014-09-17 00:13:37 +00:00
|
|
|
update: function (settings) {
|
2014-09-15 22:56:43 +00:00
|
|
|
settings = _.merge({}, SettingsStore.getAll(), settings);
|
|
|
|
//TODO: Update server.
|
|
|
|
|
|
|
|
//Facebook Flux: We do an optimistic update on the client already.
|
|
|
|
AppDispatcher.dispatchViewAction({
|
2014-09-17 13:22:42 +00:00
|
|
|
type: ActionTypes.UPDATE_SETTINGS,
|
2014-09-15 22:56:43 +00:00
|
|
|
settings: settings
|
|
|
|
});
|
|
|
|
}
|
2014-09-15 16:08:26 +00:00
|
|
|
};
|
2014-09-14 00:44:13 +00:00
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
var EventLogActions = {
|
|
|
|
add_event: function(message, level){
|
|
|
|
AppDispatcher.dispatchViewAction({
|
|
|
|
type: ActionTypes.ADD_EVENT,
|
|
|
|
data: {
|
|
|
|
message: message,
|
|
|
|
level: level || "info",
|
|
|
|
source: "ui"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2014-09-18 23:35:36 +00:00
|
|
|
var _MessageUtils = {
|
|
|
|
getContentType: function (message) {
|
2014-09-18 23:57:50 +00:00
|
|
|
return this.get_first_header(message, /^Content-Type$/i);
|
2014-09-18 23:35:36 +00:00
|
|
|
},
|
|
|
|
get_first_header: function (message, regex) {
|
|
|
|
//FIXME: Cache Invalidation.
|
|
|
|
if (!message._headerLookups)
|
|
|
|
Object.defineProperty(message, "_headerLookups", {
|
|
|
|
value: {},
|
|
|
|
configurable: false,
|
|
|
|
enumerable: false,
|
|
|
|
writable: false
|
|
|
|
});
|
|
|
|
if (!(regex in message._headerLookups)) {
|
|
|
|
var header;
|
|
|
|
for (var i = 0; i < message.headers.length; i++) {
|
|
|
|
if (!!message.headers[i][0].match(regex)) {
|
|
|
|
header = message.headers[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
message._headerLookups[regex] = header ? header[1] : undefined;
|
|
|
|
}
|
|
|
|
return message._headerLookups[regex];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var defaultPorts = {
|
|
|
|
"http": 80,
|
|
|
|
"https": 443
|
|
|
|
};
|
|
|
|
|
|
|
|
var RequestUtils = _.extend(_MessageUtils, {
|
|
|
|
pretty_host: function (request) {
|
|
|
|
//FIXME: Add hostheader
|
|
|
|
return request.host;
|
|
|
|
},
|
|
|
|
pretty_url: function (request) {
|
|
|
|
var port = "";
|
|
|
|
if (defaultPorts[request.scheme] !== request.port) {
|
|
|
|
port = ":" + request.port;
|
|
|
|
}
|
|
|
|
return request.scheme + "://" + this.pretty_host(request) + port + request.path;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var ResponseUtils = _.extend(_MessageUtils, {});
|
2014-09-16 09:06:30 +00:00
|
|
|
function EventEmitter() {
|
|
|
|
this.listeners = {};
|
|
|
|
}
|
2014-09-17 00:13:37 +00:00
|
|
|
EventEmitter.prototype.emit = function (event) {
|
2014-09-16 09:06:30 +00:00
|
|
|
if (!(event in this.listeners)) {
|
|
|
|
return;
|
2014-09-15 22:56:43 +00:00
|
|
|
}
|
2014-09-17 13:22:42 +00:00
|
|
|
var args = Array.prototype.slice.call(arguments, 1);
|
2014-09-17 00:13:37 +00:00
|
|
|
this.listeners[event].forEach(function (listener) {
|
2014-09-17 13:22:42 +00:00
|
|
|
listener.apply(this, args);
|
2014-09-16 09:06:30 +00:00
|
|
|
}.bind(this));
|
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
EventEmitter.prototype.addListener = function (event, f) {
|
2014-09-16 09:06:30 +00:00
|
|
|
this.listeners[event] = this.listeners[event] || [];
|
|
|
|
this.listeners[event].push(f);
|
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
EventEmitter.prototype.removeListener = function (event, f) {
|
2014-09-16 09:06:30 +00:00
|
|
|
if (!(event in this.listeners)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var index = this.listeners[event].indexOf(f);
|
|
|
|
if (index >= 0) {
|
|
|
|
this.listeners[event].splice(index, 1);
|
2014-09-15 22:56:43 +00:00
|
|
|
}
|
2014-09-16 09:06:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function _SettingsStore() {
|
|
|
|
EventEmitter.call(this);
|
|
|
|
|
|
|
|
//FIXME: What do we do if we haven't requested anything from the server yet?
|
|
|
|
this.settings = {
|
|
|
|
version: "0.12",
|
|
|
|
showEventLog: true,
|
|
|
|
mode: "transparent",
|
2014-09-17 00:13:37 +00:00
|
|
|
};
|
2014-09-16 09:06:30 +00:00
|
|
|
}
|
|
|
|
_.extend(_SettingsStore.prototype, EventEmitter.prototype, {
|
2014-09-17 00:13:37 +00:00
|
|
|
getAll: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return this.settings;
|
2014-09-16 09:06:30 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
handle: function (action) {
|
2014-09-17 13:22:42 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.UPDATE_SETTINGS:
|
2014-09-15 22:56:43 +00:00
|
|
|
this.settings = action.settings;
|
|
|
|
this.emit("change");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2014-09-16 09:06:30 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-15 16:08:26 +00:00
|
|
|
|
|
|
|
var SettingsStore = new _SettingsStore();
|
|
|
|
AppDispatcher.register(SettingsStore.handle.bind(SettingsStore));
|
2014-09-16 04:26:16 +00:00
|
|
|
|
2014-09-15 22:56:43 +00:00
|
|
|
//
|
|
|
|
// We have an EventLogView and an EventLogStore:
|
|
|
|
// The basic architecture is that one can request views on the event log
|
|
|
|
// from the store, which returns a view object and then deals with getting the data required for the view.
|
|
|
|
// The view object is accessed by React components and distributes updates etc.
|
|
|
|
//
|
|
|
|
// See also: components/EventLog.react.js
|
2014-09-16 09:06:30 +00:00
|
|
|
function EventLogView(store, live) {
|
|
|
|
EventEmitter.call(this);
|
2014-09-17 13:22:42 +00:00
|
|
|
this._store = store;
|
2014-09-16 09:06:30 +00:00
|
|
|
this.live = live;
|
|
|
|
this.log = [];
|
2014-09-15 16:08:26 +00:00
|
|
|
|
2014-09-16 09:06:30 +00:00
|
|
|
this.add = this.add.bind(this);
|
2014-09-15 22:56:43 +00:00
|
|
|
|
2014-09-16 09:06:30 +00:00
|
|
|
if (live) {
|
2014-09-17 13:22:42 +00:00
|
|
|
this._store.addListener(ActionTypes.ADD_EVENT, this.add);
|
2014-09-15 22:56:43 +00:00
|
|
|
}
|
2014-09-16 09:06:30 +00:00
|
|
|
}
|
|
|
|
_.extend(EventLogView.prototype, EventEmitter.prototype, {
|
2014-09-17 00:13:37 +00:00
|
|
|
close: function () {
|
2014-09-17 13:22:42 +00:00
|
|
|
this._store.removeListener(ActionTypes.ADD_EVENT, this.add);
|
2014-09-16 09:06:30 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
getAll: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return this.log;
|
2014-09-16 09:06:30 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
add: function (entry) {
|
2014-09-15 22:56:43 +00:00
|
|
|
this.log.push(entry);
|
|
|
|
this.emit("change");
|
2014-09-16 09:06:30 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
add_bulk: function (messages) {
|
2014-09-15 22:56:43 +00:00
|
|
|
var log = messages;
|
|
|
|
var last_id = log[log.length - 1].id;
|
2014-09-17 00:13:37 +00:00
|
|
|
var to_add = _.filter(this.log, function (entry) {
|
|
|
|
return entry.id > last_id;
|
|
|
|
});
|
2014-09-15 22:56:43 +00:00
|
|
|
this.log = log.concat(to_add);
|
|
|
|
this.emit("change");
|
2014-09-16 09:06:30 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-15 22:05:06 +00:00
|
|
|
|
|
|
|
|
2014-09-17 00:13:37 +00:00
|
|
|
function _EventLogStore() {
|
2014-09-16 09:06:30 +00:00
|
|
|
EventEmitter.call(this);
|
|
|
|
}
|
|
|
|
_.extend(_EventLogStore.prototype, EventEmitter.prototype, {
|
2014-09-17 00:13:37 +00:00
|
|
|
getView: function (since) {
|
2014-09-15 22:56:43 +00:00
|
|
|
var view = new EventLogView(this, !since);
|
2014-09-17 13:22:42 +00:00
|
|
|
return view;
|
|
|
|
/*
|
2014-09-15 22:56:43 +00:00
|
|
|
//TODO: Really do bulk retrieval of last messages.
|
2014-09-17 00:13:37 +00:00
|
|
|
window.setTimeout(function () {
|
|
|
|
view.add_bulk([
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
message: "Hello World"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
message: "I was already transmitted as an event."
|
|
|
|
}
|
|
|
|
]);
|
2014-09-15 22:56:43 +00:00
|
|
|
}, 100);
|
|
|
|
|
|
|
|
var id = 2;
|
|
|
|
view.add({
|
|
|
|
id: id++,
|
|
|
|
message: "I was already transmitted as an event."
|
|
|
|
});
|
|
|
|
view.add({
|
|
|
|
id: id++,
|
|
|
|
message: "I was only transmitted as an event before the bulk was added.."
|
|
|
|
});
|
2014-09-17 00:13:37 +00:00
|
|
|
window.setInterval(function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
view.add({
|
|
|
|
id: id++,
|
|
|
|
message: "."
|
|
|
|
});
|
|
|
|
}, 1000);
|
|
|
|
return view;
|
2014-09-17 13:22:42 +00:00
|
|
|
*/
|
2014-09-16 09:06:30 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
handle: function (action) {
|
2014-09-17 13:22:42 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.ADD_EVENT:
|
|
|
|
this.emit(ActionTypes.ADD_EVENT, action.data);
|
2014-09-15 22:56:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2014-09-16 09:06:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
|
|
|
|
var EventLogStore = new _EventLogStore();
|
|
|
|
AppDispatcher.register(EventLogStore.handle.bind(EventLogStore));
|
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
function FlowView(store, live) {
|
|
|
|
EventEmitter.call(this);
|
|
|
|
this._store = store;
|
|
|
|
this.live = live;
|
|
|
|
this.flows = [];
|
|
|
|
|
|
|
|
this.add = this.add.bind(this);
|
|
|
|
this.update = this.update.bind(this);
|
|
|
|
|
|
|
|
if (live) {
|
|
|
|
this._store.addListener(ActionTypes.ADD_FLOW, this.add);
|
|
|
|
this._store.addListener(ActionTypes.UPDATE_FLOW, this.update);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_.extend(FlowView.prototype, EventEmitter.prototype, {
|
|
|
|
close: function () {
|
|
|
|
this._store.removeListener(ActionTypes.ADD_FLOW, this.add);
|
|
|
|
this._store.removeListener(ActionTypes.UPDATE_FLOW, this.update);
|
|
|
|
},
|
|
|
|
getAll: function () {
|
|
|
|
return this.flows;
|
|
|
|
},
|
|
|
|
add: function (flow) {
|
|
|
|
return this.update(flow);
|
|
|
|
},
|
|
|
|
add_bulk: function (flows) {
|
|
|
|
//Treat all previously received updates as newer than the bulk update.
|
|
|
|
//If they weren't newer, we're about to receive an update for them very soon.
|
|
|
|
var updates = this.flows;
|
|
|
|
this.flows = flows;
|
|
|
|
updates.forEach(function(flow){
|
2014-09-17 19:14:55 +00:00
|
|
|
this._update(flow);
|
2014-09-17 15:30:19 +00:00
|
|
|
}.bind(this));
|
2014-09-17 19:14:55 +00:00
|
|
|
this.emit("change");
|
2014-09-17 15:30:19 +00:00
|
|
|
},
|
2014-09-17 19:14:55 +00:00
|
|
|
_update: function(flow){
|
2014-09-17 15:30:19 +00:00
|
|
|
var idx = _.findIndex(this.flows, function(f){
|
2014-09-18 00:22:10 +00:00
|
|
|
return flow.id === f.id;
|
2014-09-17 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if(idx < 0){
|
|
|
|
this.flows.push(flow);
|
|
|
|
} else {
|
|
|
|
this.flows[idx] = flow;
|
|
|
|
}
|
2014-09-17 19:14:55 +00:00
|
|
|
},
|
|
|
|
update: function(flow){
|
|
|
|
this._update(flow);
|
2014-09-17 15:30:19 +00:00
|
|
|
this.emit("change");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function _FlowStore() {
|
|
|
|
EventEmitter.call(this);
|
|
|
|
}
|
|
|
|
_.extend(_FlowStore.prototype, EventEmitter.prototype, {
|
|
|
|
getView: function (since) {
|
|
|
|
var view = new FlowView(this, !since);
|
2014-09-17 19:14:55 +00:00
|
|
|
|
|
|
|
$.getJSON("/static/flows.json", function(flows){
|
2014-09-18 00:22:10 +00:00
|
|
|
flows = flows.concat(_.cloneDeep(flows)).concat(_.cloneDeep(flows));
|
|
|
|
var id = 1;
|
|
|
|
flows.forEach(function(flow){
|
2014-09-18 19:13:50 +00:00
|
|
|
flow.id = "uuid-" + id++;
|
|
|
|
});
|
2014-09-17 19:14:55 +00:00
|
|
|
view.add_bulk(flows);
|
2014-09-18 00:22:10 +00:00
|
|
|
|
2014-09-17 19:14:55 +00:00
|
|
|
});
|
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
return view;
|
|
|
|
},
|
|
|
|
handle: function (action) {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.ADD_FLOW:
|
|
|
|
case ActionTypes.UPDATE_FLOW:
|
|
|
|
this.emit(action.type, action.data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var FlowStore = new _FlowStore();
|
|
|
|
AppDispatcher.register(FlowStore.handle.bind(FlowStore));
|
|
|
|
|
2014-09-16 21:40:25 +00:00
|
|
|
function _Connection(url) {
|
|
|
|
this.url = url;
|
|
|
|
}
|
2014-09-17 00:13:37 +00:00
|
|
|
_Connection.prototype.init = function () {
|
2014-09-16 09:06:30 +00:00
|
|
|
this.openWebSocketConnection();
|
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
_Connection.prototype.openWebSocketConnection = function () {
|
2014-09-16 21:40:25 +00:00
|
|
|
this.ws = new WebSocket(this.url.replace("http", "ws"));
|
2014-09-16 09:06:30 +00:00
|
|
|
var ws = this.ws;
|
|
|
|
|
|
|
|
ws.onopen = this.onopen.bind(this);
|
|
|
|
ws.onmessage = this.onmessage.bind(this);
|
|
|
|
ws.onerror = this.onerror.bind(this);
|
|
|
|
ws.onclose = this.onclose.bind(this);
|
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
_Connection.prototype.onopen = function (open) {
|
2014-09-16 09:06:30 +00:00
|
|
|
console.log("onopen", this, arguments);
|
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
_Connection.prototype.onmessage = function (message) {
|
2014-09-16 09:06:30 +00:00
|
|
|
//AppDispatcher.dispatchServerAction(...);
|
2014-09-17 01:58:56 +00:00
|
|
|
var m = JSON.parse(message.data);
|
2014-09-17 13:22:42 +00:00
|
|
|
AppDispatcher.dispatchServerAction(m);
|
2014-09-16 09:06:30 +00:00
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
_Connection.prototype.onerror = function (error) {
|
2014-09-17 15:30:19 +00:00
|
|
|
EventLogActions.add_event("WebSocket Connection Error.");
|
2014-09-16 09:06:30 +00:00
|
|
|
console.log("onerror", this, arguments);
|
|
|
|
};
|
2014-09-17 00:13:37 +00:00
|
|
|
_Connection.prototype.onclose = function (close) {
|
2014-09-17 15:30:19 +00:00
|
|
|
EventLogActions.add_event("WebSocket Connection closed.");
|
2014-09-16 09:06:30 +00:00
|
|
|
console.log("onclose", this, arguments);
|
|
|
|
};
|
2014-09-14 00:44:13 +00:00
|
|
|
|
2014-09-16 21:40:25 +00:00
|
|
|
var Connection = new _Connection(location.origin + "/updates");
|
2014-09-16 04:26:16 +00:00
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
2014-09-18 21:22:02 +00:00
|
|
|
//React utils. For other utilities, see ../utils.js
|
|
|
|
|
|
|
|
var Splitter = React.createClass({displayName: 'Splitter',
|
|
|
|
getDefaultProps: function () {
|
2014-09-19 15:56:54 +00:00
|
|
|
return {
|
|
|
|
axis: "x"
|
|
|
|
};
|
2014-09-18 21:22:02 +00:00
|
|
|
},
|
|
|
|
getInitialState: function(){
|
|
|
|
return {
|
|
|
|
applied: false,
|
|
|
|
startX: false,
|
|
|
|
startY: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
onMouseDown: function(e){
|
|
|
|
this.setState({
|
|
|
|
startX: e.pageX,
|
|
|
|
startY: e.pageY
|
|
|
|
});
|
|
|
|
window.addEventListener("mousemove",this.onMouseMove);
|
|
|
|
window.addEventListener("mouseup",this.onMouseUp);
|
2014-09-18 21:47:54 +00:00
|
|
|
// Occasionally, only a dragEnd event is triggered, but no mouseUp.
|
|
|
|
window.addEventListener("dragend",this.onDragEnd);
|
2014-09-18 21:22:02 +00:00
|
|
|
},
|
2014-09-18 21:47:54 +00:00
|
|
|
onDragEnd: function(){
|
|
|
|
this.getDOMNode().style.transform="";
|
|
|
|
window.removeEventListener("dragend",this.onDragEnd);
|
2014-09-18 21:22:02 +00:00
|
|
|
window.removeEventListener("mouseup",this.onMouseUp);
|
|
|
|
window.removeEventListener("mousemove",this.onMouseMove);
|
2014-09-18 21:47:54 +00:00
|
|
|
},
|
|
|
|
onMouseUp: function(e){
|
|
|
|
this.onDragEnd();
|
2014-09-18 21:22:02 +00:00
|
|
|
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
var prev = node.previousElementSibling;
|
|
|
|
var next = node.nextElementSibling;
|
|
|
|
|
|
|
|
var dX = e.pageX-this.state.startX;
|
|
|
|
var dY = e.pageY-this.state.startY;
|
|
|
|
var flexBasis;
|
|
|
|
if(this.props.axis === "x"){
|
|
|
|
flexBasis = prev.offsetWidth + dX;
|
|
|
|
} else {
|
|
|
|
flexBasis = prev.offsetHeight + dY;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev.style.flex = "0 0 "+Math.max(0, flexBasis)+"px";
|
|
|
|
next.style.flex = "1 1 auto";
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
applied: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onMouseMove: function(e){
|
|
|
|
var dX = 0, dY = 0;
|
|
|
|
if(this.props.axis === "x"){
|
|
|
|
dX = e.pageX-this.state.startX;
|
|
|
|
} else {
|
|
|
|
dY = e.pageY-this.state.startY;
|
|
|
|
}
|
|
|
|
this.getDOMNode().style.transform = "translate("+dX+"px,"+dY+"px)";
|
|
|
|
},
|
2014-09-18 21:47:54 +00:00
|
|
|
reset: function(willUnmount) {
|
|
|
|
if (!this.state.applied) {
|
2014-09-18 21:22:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var node = this.getDOMNode();
|
|
|
|
var prev = node.previousElementSibling;
|
|
|
|
var next = node.nextElementSibling;
|
|
|
|
|
|
|
|
prev.style.flex = "";
|
|
|
|
next.style.flex = "";
|
2014-09-18 21:47:54 +00:00
|
|
|
|
|
|
|
if(!willUnmount){
|
|
|
|
this.setState({
|
|
|
|
applied: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
componentWillUnmount: function(){
|
|
|
|
this.reset(true);
|
2014-09-18 21:22:02 +00:00
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var className = "splitter";
|
|
|
|
if(this.props.axis === "x"){
|
|
|
|
className += " splitter-x";
|
|
|
|
} else {
|
|
|
|
className += " splitter-y";
|
|
|
|
}
|
2014-09-18 21:47:54 +00:00
|
|
|
return (
|
|
|
|
React.DOM.div({className: className},
|
|
|
|
React.DOM.div({onMouseDown: this.onMouseDown, draggable: "true"})
|
|
|
|
)
|
|
|
|
);
|
2014-09-18 21:22:02 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
var MainMenu = React.createClass({displayName: 'MainMenu',
|
2014-09-18 19:13:50 +00:00
|
|
|
statics: {
|
|
|
|
title: "Traffic",
|
|
|
|
route: "flows"
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
toggleEventLog: function () {
|
2014-09-15 16:08:26 +00:00
|
|
|
SettingsActions.update({
|
2014-09-15 22:05:06 +00:00
|
|
|
showEventLog: !this.props.settings.showEventLog
|
2014-09-15 16:08:26 +00:00
|
|
|
});
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return (
|
|
|
|
React.DOM.div(null,
|
|
|
|
React.DOM.button({className: "btn " + (this.props.settings.showEventLog ? "btn-primary" : "btn-default"), onClick: this.toggleEventLog},
|
2014-09-15 16:39:25 +00:00
|
|
|
React.DOM.i({className: "fa fa-database"}), " Display Event Log"
|
2014-09-15 22:56:43 +00:00
|
|
|
)
|
2014-09-15 16:08:26 +00:00
|
|
|
)
|
2014-09-17 00:13:37 +00:00
|
|
|
);
|
2014-09-14 00:44:13 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-18 19:13:50 +00:00
|
|
|
|
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
var ToolsMenu = React.createClass({displayName: 'ToolsMenu',
|
2014-09-18 19:13:50 +00:00
|
|
|
statics: {
|
|
|
|
title: "Tools",
|
|
|
|
route: "flows"
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return React.DOM.div(null, "Tools Menu");
|
2014-09-14 00:44:13 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-18 19:13:50 +00:00
|
|
|
|
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
var ReportsMenu = React.createClass({displayName: 'ReportsMenu',
|
2014-09-18 19:13:50 +00:00
|
|
|
statics: {
|
|
|
|
title: "Visualization",
|
|
|
|
route: "reports"
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return React.DOM.div(null, "Reports Menu");
|
2014-09-14 00:44:13 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
|
2014-09-18 19:13:50 +00:00
|
|
|
var header_entries = [MainMenu, ToolsMenu, ReportsMenu];
|
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
|
|
|
|
var Header = React.createClass({displayName: 'Header',
|
2014-09-17 00:13:37 +00:00
|
|
|
getInitialState: function () {
|
2014-09-15 16:08:26 +00:00
|
|
|
return {
|
2014-09-18 19:13:50 +00:00
|
|
|
active: header_entries[0]
|
2014-09-15 16:08:26 +00:00
|
|
|
};
|
2014-09-14 00:44:13 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
handleClick: function (active) {
|
2014-09-18 19:13:50 +00:00
|
|
|
ReactRouter.transitionTo(active.route);
|
2014-09-14 00:44:13 +00:00
|
|
|
this.setState({active: active});
|
|
|
|
return false;
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
handleFileClick: function () {
|
2014-09-14 00:44:13 +00:00
|
|
|
console.log("File click");
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
2014-09-18 19:13:50 +00:00
|
|
|
var header = header_entries.map(function(entry){
|
|
|
|
var classes = React.addons.classSet({
|
|
|
|
active: entry == this.state.active
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
React.DOM.a({key: entry.title,
|
|
|
|
href: "#",
|
|
|
|
className: classes,
|
|
|
|
onClick: this.handleClick.bind(this, entry)
|
|
|
|
},
|
|
|
|
entry.title
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}.bind(this));
|
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
return (
|
2014-09-15 16:08:26 +00:00
|
|
|
React.DOM.header(null,
|
|
|
|
React.DOM.div({className: "title-bar"},
|
2014-09-15 22:05:06 +00:00
|
|
|
"mitmproxy ", this.props.settings.version
|
2014-09-15 16:08:26 +00:00
|
|
|
),
|
2014-09-18 19:13:50 +00:00
|
|
|
React.DOM.nav({className: "nav-tabs nav-tabs-lg"},
|
2014-09-15 16:08:26 +00:00
|
|
|
React.DOM.a({href: "#", className: "special", onClick: this.handleFileClick}, " File "),
|
|
|
|
header
|
|
|
|
),
|
|
|
|
React.DOM.div({className: "menu"},
|
2014-09-18 19:13:50 +00:00
|
|
|
this.state.active({settings: this.props.settings})
|
2014-09-15 16:08:26 +00:00
|
|
|
)
|
2014-09-15 22:56:43 +00:00
|
|
|
)
|
2014-09-17 00:13:37 +00:00
|
|
|
);
|
2014-09-14 00:44:13 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-16 04:26:16 +00:00
|
|
|
|
2014-09-14 00:44:13 +00:00
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
2014-09-17 19:14:55 +00:00
|
|
|
|
|
|
|
var TLSColumn = React.createClass({displayName: 'TLSColumn',
|
|
|
|
statics: {
|
|
|
|
renderTitle: function(){
|
|
|
|
return React.DOM.th({key: "tls", className: "col-tls"});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
|
|
|
var ssl = (flow.request.scheme == "https");
|
2014-09-18 19:13:50 +00:00
|
|
|
var classes = React.addons.classSet({
|
|
|
|
"col-tls": true,
|
|
|
|
"col-tls-https": ssl,
|
|
|
|
"col-tls-http": !ssl
|
|
|
|
});
|
|
|
|
return React.DOM.td({className: classes});
|
2014-09-17 19:14:55 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var IconColumn = React.createClass({displayName: 'IconColumn',
|
|
|
|
statics: {
|
|
|
|
renderTitle: function(){
|
|
|
|
return React.DOM.th({key: "icon", className: "col-icon"});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
2014-09-18 23:57:50 +00:00
|
|
|
|
|
|
|
var icon;
|
2014-09-19 15:56:54 +00:00
|
|
|
if(flow.response){
|
|
|
|
var contentType = ResponseUtils.getContentType(flow.response);
|
|
|
|
|
|
|
|
//TODO: We should assign a type to the flow somewhere else.
|
|
|
|
var icon;
|
|
|
|
if(flow.response.code == 304) {
|
|
|
|
icon = "resource-icon-not-modified";
|
|
|
|
} else if(300 <= flow.response.code && flow.response.code < 400) {
|
|
|
|
icon = "resource-icon-redirect";
|
|
|
|
} else if(contentType.indexOf("image") >= 0) {
|
|
|
|
icon = "resource-icon-image";
|
|
|
|
} else if (contentType.indexOf("javascript") >= 0) {
|
|
|
|
icon = "resource-icon-js";
|
|
|
|
} else if (contentType.indexOf("css") >= 0) {
|
|
|
|
icon = "resource-icon-css";
|
|
|
|
} else if (contentType.indexOf("html") >= 0) {
|
|
|
|
icon = "resource-icon-document";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!icon){
|
2014-09-18 23:57:50 +00:00
|
|
|
icon = "resource-icon-plain";
|
|
|
|
}
|
2014-09-19 15:56:54 +00:00
|
|
|
|
|
|
|
|
2014-09-18 23:57:50 +00:00
|
|
|
icon += " resource-icon";
|
|
|
|
return React.DOM.td({className: "col-icon"}, React.DOM.div({className: icon}));
|
2014-09-17 19:14:55 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
var PathColumn = React.createClass({displayName: 'PathColumn',
|
|
|
|
statics: {
|
|
|
|
renderTitle: function(){
|
2014-09-17 19:14:55 +00:00
|
|
|
return React.DOM.th({key: "path", className: "col-path"}, "Path");
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
2014-09-18 19:13:50 +00:00
|
|
|
return React.DOM.td({className: "col-path"}, flow.request.scheme + "://" + flow.request.host + flow.request.path);
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-17 19:14:55 +00:00
|
|
|
|
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
var MethodColumn = React.createClass({displayName: 'MethodColumn',
|
|
|
|
statics: {
|
|
|
|
renderTitle: function(){
|
2014-09-17 19:14:55 +00:00
|
|
|
return React.DOM.th({key: "method", className: "col-method"}, "Method");
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
2014-09-18 19:13:50 +00:00
|
|
|
return React.DOM.td({className: "col-method"}, flow.request.method);
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-17 19:14:55 +00:00
|
|
|
|
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
var StatusColumn = React.createClass({displayName: 'StatusColumn',
|
|
|
|
statics: {
|
|
|
|
renderTitle: function(){
|
2014-09-17 19:14:55 +00:00
|
|
|
return React.DOM.th({key: "status", className: "col-status"}, "Status");
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
|
|
|
var status;
|
|
|
|
if(flow.response){
|
2014-09-17 19:14:55 +00:00
|
|
|
status = flow.response.code;
|
2014-09-17 15:30:19 +00:00
|
|
|
} else {
|
|
|
|
status = null;
|
|
|
|
}
|
2014-09-18 19:13:50 +00:00
|
|
|
return React.DOM.td({className: "col-status"}, status);
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-17 19:14:55 +00:00
|
|
|
|
|
|
|
|
2014-09-18 23:35:36 +00:00
|
|
|
var SizeColumn = React.createClass({displayName: 'SizeColumn',
|
|
|
|
statics: {
|
|
|
|
renderTitle: function(){
|
|
|
|
return React.DOM.th({key: "size", className: "col-size"}, "Size");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
|
|
|
var size = formatSize(
|
|
|
|
flow.request.contentLength +
|
|
|
|
(flow.response.contentLength || 0));
|
|
|
|
return React.DOM.td({className: "col-size"}, size);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
var TimeColumn = React.createClass({displayName: 'TimeColumn',
|
|
|
|
statics: {
|
|
|
|
renderTitle: function(){
|
2014-09-17 19:14:55 +00:00
|
|
|
return React.DOM.th({key: "time", className: "col-time"}, "Time");
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
|
|
|
var time;
|
|
|
|
if(flow.response){
|
2014-09-19 15:56:54 +00:00
|
|
|
time = formatTimeDelta(1000 * (flow.response.timestamp_end - flow.request.timestamp_start));
|
2014-09-17 15:30:19 +00:00
|
|
|
} else {
|
|
|
|
time = "...";
|
|
|
|
}
|
2014-09-18 19:13:50 +00:00
|
|
|
return React.DOM.td({className: "col-time"}, time);
|
2014-09-17 15:30:19 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-17 19:14:55 +00:00
|
|
|
|
2014-09-18 23:35:36 +00:00
|
|
|
var all_columns = [
|
|
|
|
TLSColumn,
|
|
|
|
IconColumn,
|
|
|
|
PathColumn,
|
|
|
|
MethodColumn,
|
|
|
|
StatusColumn,
|
|
|
|
SizeColumn,
|
|
|
|
TimeColumn];
|
2014-09-17 19:14:55 +00:00
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
|
2014-09-18 00:22:10 +00:00
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
|
|
|
var FlowRow = React.createClass({displayName: 'FlowRow',
|
|
|
|
render: function(){
|
|
|
|
var flow = this.props.flow;
|
|
|
|
var columns = this.props.columns.map(function(column){
|
2014-09-18 19:13:50 +00:00
|
|
|
return column({key: column.displayName, flow: flow});
|
2014-09-18 00:22:10 +00:00
|
|
|
}.bind(this));
|
|
|
|
var className = "";
|
|
|
|
if(this.props.selected){
|
|
|
|
className += "selected";
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
React.DOM.tr({className: className, onClick: this.props.selectFlow.bind(null, flow)},
|
|
|
|
columns
|
|
|
|
));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var FlowTableHead = React.createClass({displayName: 'FlowTableHead',
|
|
|
|
render: function(){
|
|
|
|
var columns = this.props.columns.map(function(column){
|
|
|
|
return column.renderTitle();
|
|
|
|
}.bind(this));
|
2014-09-18 01:56:35 +00:00
|
|
|
return React.DOM.thead(null, React.DOM.tr(null, columns));
|
2014-09-18 00:22:10 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var FlowTableBody = React.createClass({displayName: 'FlowTableBody',
|
|
|
|
render: function(){
|
|
|
|
var rows = this.props.flows.map(function(flow){
|
|
|
|
var selected = (flow == this.props.selected);
|
|
|
|
return FlowRow({key: flow.id,
|
|
|
|
ref: flow.id,
|
|
|
|
flow: flow,
|
|
|
|
columns: this.props.columns,
|
|
|
|
selected: selected,
|
|
|
|
selectFlow: this.props.selectFlow}
|
|
|
|
);
|
|
|
|
}.bind(this));
|
2014-09-19 15:56:54 +00:00
|
|
|
return React.DOM.tbody(null, rows);
|
2014-09-18 00:22:10 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-09-17 15:30:19 +00:00
|
|
|
var FlowTable = React.createClass({displayName: 'FlowTable',
|
2014-09-18 19:13:50 +00:00
|
|
|
mixins: [StickyHeadMixin, AutoScrollMixin],
|
2014-09-17 00:13:37 +00:00
|
|
|
getInitialState: function () {
|
2014-09-14 00:44:13 +00:00
|
|
|
return {
|
2014-09-17 15:30:19 +00:00
|
|
|
columns: all_columns
|
2014-09-14 00:44:13 +00:00
|
|
|
};
|
|
|
|
},
|
2014-09-18 19:13:50 +00:00
|
|
|
scrollIntoView: function(flow){
|
2014-09-18 00:22:10 +00:00
|
|
|
// Now comes the fun part: Scroll the flow into the view.
|
|
|
|
var viewport = this.getDOMNode();
|
|
|
|
var flowNode = this.refs.body.refs[flow.id].getDOMNode();
|
|
|
|
var viewport_top = viewport.scrollTop;
|
|
|
|
var viewport_bottom = viewport_top + viewport.offsetHeight;
|
|
|
|
var flowNode_top = flowNode.offsetTop;
|
|
|
|
var flowNode_bottom = flowNode_top + flowNode.offsetHeight;
|
|
|
|
|
|
|
|
// Account for pinned thead by pretending that the flowNode starts
|
|
|
|
// -thead_height pixel earlier.
|
|
|
|
flowNode_top -= this.refs.body.getDOMNode().offsetTop;
|
|
|
|
|
|
|
|
if(flowNode_top < viewport_top){
|
|
|
|
viewport.scrollTop = flowNode_top;
|
|
|
|
} else if(flowNode_bottom > viewport_bottom) {
|
|
|
|
viewport.scrollTop = flowNode_bottom - viewport.offsetHeight;
|
|
|
|
}
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
|
|
|
return (
|
2014-09-18 19:13:50 +00:00
|
|
|
React.DOM.div({className: "flow-table", onScroll: this.adjustHead},
|
|
|
|
React.DOM.table(null,
|
|
|
|
FlowTableHead({ref: "head",
|
|
|
|
columns: this.state.columns}),
|
|
|
|
FlowTableBody({ref: "body",
|
|
|
|
flows: this.props.flows,
|
|
|
|
selected: this.props.selected,
|
|
|
|
selectFlow: this.props.selectFlow,
|
2014-09-19 15:56:54 +00:00
|
|
|
columns: this.state.columns})
|
2014-09-18 19:13:50 +00:00
|
|
|
)
|
2014-09-17 15:30:19 +00:00
|
|
|
)
|
2014-09-17 00:13:37 +00:00
|
|
|
);
|
2014-09-15 22:56:43 +00:00
|
|
|
}
|
2014-09-14 00:44:13 +00:00
|
|
|
});
|
2014-09-16 04:26:16 +00:00
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
/** @jsx React.DOM */
|
2014-09-14 00:44:13 +00:00
|
|
|
|
2014-09-18 19:13:50 +00:00
|
|
|
var FlowDetailNav = React.createClass({displayName: 'FlowDetailNav',
|
|
|
|
render: function(){
|
|
|
|
|
2014-09-19 15:56:54 +00:00
|
|
|
var items = this.props.tabs.map(function(e){
|
2014-09-18 19:13:50 +00:00
|
|
|
var str = e.charAt(0).toUpperCase() + e.slice(1);
|
|
|
|
var className = this.props.active === e ? "active" : "";
|
|
|
|
var onClick = function(){
|
|
|
|
this.props.selectTab(e);
|
|
|
|
return false;
|
|
|
|
}.bind(this);
|
|
|
|
return React.DOM.a({key: e,
|
|
|
|
href: "#",
|
|
|
|
className: className,
|
|
|
|
onClick: onClick}, str);
|
|
|
|
}.bind(this));
|
|
|
|
return (
|
|
|
|
React.DOM.nav({ref: "head", className: "nav-tabs nav-tabs-sm"},
|
|
|
|
items
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-18 23:35:36 +00:00
|
|
|
var Headers = React.createClass({displayName: 'Headers',
|
|
|
|
render: function(){
|
|
|
|
var rows = this.props.message.headers.map(function(header){
|
|
|
|
return (
|
|
|
|
React.DOM.tr(null,
|
2014-09-19 15:56:54 +00:00
|
|
|
React.DOM.td({className: "header-name"}, header[0]+":"),
|
2014-09-18 23:35:36 +00:00
|
|
|
React.DOM.td({className: "header-value"}, header[1])
|
|
|
|
)
|
|
|
|
);
|
2014-09-19 15:56:54 +00:00
|
|
|
});
|
2014-09-18 23:35:36 +00:00
|
|
|
return (
|
|
|
|
React.DOM.table({className: "header-table"},
|
|
|
|
React.DOM.tbody(null,
|
|
|
|
rows
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2014-09-19 15:56:54 +00:00
|
|
|
});
|
2014-09-18 23:35:36 +00:00
|
|
|
|
2014-09-18 19:13:50 +00:00
|
|
|
var FlowDetailRequest = React.createClass({displayName: 'FlowDetailRequest',
|
|
|
|
render: function(){
|
2014-09-18 23:35:36 +00:00
|
|
|
var flow = this.props.flow;
|
2014-09-18 23:57:50 +00:00
|
|
|
var first_line = [
|
|
|
|
flow.request.method,
|
|
|
|
RequestUtils.pretty_url(flow.request),
|
|
|
|
"HTTP/"+ flow.response.httpversion.join(".")
|
|
|
|
].join(" ");
|
2014-09-18 23:35:36 +00:00
|
|
|
var content = null;
|
|
|
|
if(flow.request.contentLength > 0){
|
|
|
|
content = "Request Content Size: "+ formatSize(flow.request.contentLength);
|
|
|
|
} else {
|
|
|
|
content = React.DOM.div({className: "alert alert-info"}, "No Content");
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: Styling
|
|
|
|
|
|
|
|
return (
|
|
|
|
React.DOM.section(null,
|
2014-09-18 23:57:50 +00:00
|
|
|
React.DOM.code(null, first_line ),
|
2014-09-18 23:35:36 +00:00
|
|
|
Headers({message: flow.request}),
|
|
|
|
React.DOM.hr(null),
|
|
|
|
content
|
|
|
|
)
|
|
|
|
);
|
2014-09-18 19:13:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var FlowDetailResponse = React.createClass({displayName: 'FlowDetailResponse',
|
|
|
|
render: function(){
|
2014-09-18 23:57:50 +00:00
|
|
|
var flow = this.props.flow;
|
|
|
|
var first_line = [
|
|
|
|
"HTTP/"+ flow.response.httpversion.join("."),
|
|
|
|
flow.response.code,
|
|
|
|
flow.response.msg
|
|
|
|
].join(" ");
|
|
|
|
var content = null;
|
|
|
|
if(flow.response.contentLength > 0){
|
|
|
|
content = "Response Content Size: "+ formatSize(flow.response.contentLength);
|
|
|
|
} else {
|
|
|
|
content = React.DOM.div({className: "alert alert-info"}, "No Content");
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: Styling
|
|
|
|
|
|
|
|
return (
|
|
|
|
React.DOM.section(null,
|
|
|
|
React.DOM.code(null, first_line ),
|
|
|
|
Headers({message: flow.response}),
|
|
|
|
React.DOM.hr(null),
|
|
|
|
content
|
|
|
|
)
|
|
|
|
);
|
2014-09-18 19:13:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-19 15:56:54 +00:00
|
|
|
var TimeStamp = React.createClass({displayName: 'TimeStamp',
|
|
|
|
render: function() {
|
|
|
|
var ts, delta;
|
|
|
|
|
|
|
|
if(!this.props.t && this.props.optional){
|
|
|
|
//should be return null, but that triggers a React bug.
|
|
|
|
return React.DOM.tr(null);
|
|
|
|
} else if (!this.props.t){
|
|
|
|
ts = "active";
|
|
|
|
} else {
|
|
|
|
ts = (new Date(this.props.t * 1000)).toISOString();
|
|
|
|
ts = ts.replace("T", " ").replace("Z","");
|
|
|
|
|
|
|
|
if(this.props.deltaTo){
|
|
|
|
delta = Math.round((this.props.t-this.props.deltaTo)*1000) + "ms";
|
|
|
|
delta = React.DOM.span({className: "text-muted"}, "(" + delta + ")");
|
|
|
|
} else {
|
|
|
|
delta = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return React.DOM.tr(null, React.DOM.td(null, this.props.title + ":"), React.DOM.td(null, ts, " ", delta));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var ConnectionInfo = React.createClass({displayName: 'ConnectionInfo',
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
var conn = this.props.conn;
|
|
|
|
var address = conn.address.address.join(":");
|
|
|
|
|
|
|
|
var sni = React.DOM.tr({key: "sni"}); //should be null, but that triggers a React bug.
|
|
|
|
if(conn.sni){
|
|
|
|
sni = React.DOM.tr({key: "sni"}, React.DOM.td(null, React.DOM.abbr({title: "TLS Server Name Indication"}, "TLS SNI:")), React.DOM.td(null, conn.sni));
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
React.DOM.table({className: "connection-table"},
|
|
|
|
React.DOM.tbody(null,
|
|
|
|
React.DOM.tr({key: "address"}, React.DOM.td(null, "Address:"), React.DOM.td(null, address)),
|
|
|
|
sni,
|
|
|
|
TimeStamp({title: "Start time",
|
|
|
|
key: "start",
|
|
|
|
t: conn.timestamp_start}),
|
|
|
|
TimeStamp({title: "TCP Setup",
|
|
|
|
key: "tcpsetup",
|
|
|
|
t: conn.timestamp_tcp_setup,
|
|
|
|
deltaTo: conn.timestamp_start,
|
|
|
|
optional: true}),
|
|
|
|
TimeStamp({title: "SSL handshake",
|
|
|
|
key: "sslsetup",
|
|
|
|
t: conn.timestamp_ssl_setup,
|
|
|
|
deltaTo: conn.timestamp_start,
|
|
|
|
optional: true}),
|
|
|
|
TimeStamp({title: "End time",
|
|
|
|
key: "end",
|
|
|
|
t: conn.timestamp_end,
|
|
|
|
deltaTo: conn.timestamp_start})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var CertificateInfo = React.createClass({displayName: 'CertificateInfo',
|
|
|
|
render: function(){
|
|
|
|
//TODO: We should fetch human-readable certificate representation
|
|
|
|
// from the server
|
|
|
|
var flow = this.props.flow;
|
|
|
|
var client_conn = flow.client_conn;
|
|
|
|
var server_conn = flow.server_conn;
|
|
|
|
return (
|
|
|
|
React.DOM.div(null,
|
|
|
|
client_conn.cert ? React.DOM.h4(null, "Client Certificate") : null,
|
|
|
|
client_conn.cert ? React.DOM.pre(null, client_conn.cert) : null,
|
|
|
|
|
|
|
|
server_conn.cert ? React.DOM.h4(null, "Server Certificate") : null,
|
|
|
|
server_conn.cert ? React.DOM.pre(null, server_conn.cert) : null
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-18 19:13:50 +00:00
|
|
|
var FlowDetailConnectionInfo = React.createClass({displayName: 'FlowDetailConnectionInfo',
|
|
|
|
render: function(){
|
2014-09-19 15:56:54 +00:00
|
|
|
var flow = this.props.flow;
|
|
|
|
var client_conn = flow.client_conn;
|
|
|
|
var server_conn = flow.server_conn;
|
|
|
|
return (
|
|
|
|
React.DOM.section(null,
|
|
|
|
|
|
|
|
React.DOM.h4(null, "Client Connection"),
|
|
|
|
ConnectionInfo({conn: client_conn}),
|
|
|
|
|
|
|
|
React.DOM.h4(null, "Server Connection"),
|
|
|
|
ConnectionInfo({conn: server_conn}),
|
|
|
|
|
|
|
|
CertificateInfo({flow: flow})
|
|
|
|
|
|
|
|
)
|
|
|
|
);
|
2014-09-18 19:13:50 +00:00
|
|
|
}
|
2014-09-18 21:22:02 +00:00
|
|
|
});
|
2014-09-18 19:13:50 +00:00
|
|
|
|
|
|
|
var tabs = {
|
|
|
|
request: FlowDetailRequest,
|
|
|
|
response: FlowDetailResponse,
|
|
|
|
details: FlowDetailConnectionInfo
|
2014-09-18 21:22:02 +00:00
|
|
|
};
|
2014-09-18 19:13:50 +00:00
|
|
|
|
|
|
|
var FlowDetail = React.createClass({displayName: 'FlowDetail',
|
2014-09-19 15:56:54 +00:00
|
|
|
getDefaultProps: function(){
|
|
|
|
return {
|
|
|
|
tabs: ["request","response", "details"]
|
|
|
|
};
|
|
|
|
},
|
2014-09-18 19:13:50 +00:00
|
|
|
mixins: [StickyHeadMixin],
|
2014-09-19 15:56:54 +00:00
|
|
|
nextTab: function(i) {
|
|
|
|
var currentIndex = this.props.tabs.indexOf(this.props.active);
|
|
|
|
// JS modulo operator doesn't correct negative numbers, make sure that we are positive.
|
|
|
|
var nextIndex = (currentIndex + i + this.props.tabs.length) % this.props.tabs.length;
|
|
|
|
this.props.selectTab(this.props.tabs[nextIndex]);
|
|
|
|
},
|
2014-09-18 19:13:50 +00:00
|
|
|
render: function(){
|
|
|
|
var flow = JSON.stringify(this.props.flow, null, 2);
|
|
|
|
var Tab = tabs[this.props.active];
|
|
|
|
return (
|
|
|
|
React.DOM.div({className: "flow-detail", onScroll: this.adjustHead},
|
2014-09-19 15:56:54 +00:00
|
|
|
FlowDetailNav({ref: "head",
|
|
|
|
tabs: this.props.tabs,
|
|
|
|
active: this.props.active,
|
|
|
|
selectTab: this.props.selectTab}),
|
2014-09-18 23:35:36 +00:00
|
|
|
Tab({flow: this.props.flow})
|
2014-09-18 19:13:50 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
|
|
|
var MainView = React.createClass({displayName: 'MainView',
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
flows: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
componentDidMount: function () {
|
|
|
|
console.log("get view");
|
|
|
|
this.flowStore = FlowStore.getView();
|
|
|
|
this.flowStore.addListener("change",this.onFlowChange);
|
|
|
|
},
|
|
|
|
componentWillUnmount: function () {
|
|
|
|
this.flowStore.removeListener("change",this.onFlowChange);
|
|
|
|
this.flowStore.close();
|
|
|
|
},
|
|
|
|
onFlowChange: function () {
|
|
|
|
this.setState({
|
|
|
|
flows: this.flowStore.getAll()
|
|
|
|
});
|
|
|
|
},
|
2014-09-19 15:56:54 +00:00
|
|
|
selectDetailTab: function(panel) {
|
|
|
|
ReactRouter.replaceWith(
|
|
|
|
"flow",
|
|
|
|
{
|
|
|
|
flowId: this.props.params.flowId,
|
|
|
|
detailTab: panel
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
2014-09-18 19:13:50 +00:00
|
|
|
selectFlow: function(flow) {
|
|
|
|
if(flow){
|
|
|
|
ReactRouter.replaceWith(
|
|
|
|
"flow",
|
|
|
|
{
|
|
|
|
flowId: flow.id,
|
|
|
|
detailTab: this.props.params.detailTab || "request"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.refs.flowTable.scrollIntoView(flow);
|
|
|
|
} else {
|
|
|
|
ReactRouter.replaceWith("flows");
|
|
|
|
}
|
|
|
|
},
|
2014-09-19 15:56:54 +00:00
|
|
|
selectFlowRelative: function(i){
|
|
|
|
var index;
|
|
|
|
if(!this.props.params.flowId){
|
|
|
|
if(i > 0){
|
|
|
|
index = this.state.flows.length-1;
|
|
|
|
} else {
|
|
|
|
index = 0;
|
2014-09-18 19:13:50 +00:00
|
|
|
}
|
2014-09-19 15:56:54 +00:00
|
|
|
} else {
|
|
|
|
index = _.findIndex(this.state.flows, function(f){
|
|
|
|
return f.id === this.props.params.flowId;
|
|
|
|
}.bind(this));
|
|
|
|
index = Math.min(Math.max(0, index+i), this.state.flows.length-1);
|
|
|
|
}
|
|
|
|
this.selectFlow(this.state.flows[index]);
|
|
|
|
},
|
|
|
|
onKeyDown: function(e){
|
|
|
|
switch(e.keyCode){
|
|
|
|
case Key.K:
|
|
|
|
case Key.UP:
|
|
|
|
this.selectFlowRelative(-1);
|
|
|
|
break;
|
|
|
|
case Key.J:
|
|
|
|
case Key.DOWN:
|
|
|
|
this.selectFlowRelative(+1);
|
|
|
|
break;
|
|
|
|
case Key.SPACE:
|
|
|
|
case Key.PAGE_DOWN:
|
|
|
|
this.selectFlowRelative(+10);
|
|
|
|
break;
|
|
|
|
case Key.PAGE_UP:
|
|
|
|
this.selectFlowRelative(-10);
|
|
|
|
break;
|
|
|
|
case Key.ESC:
|
|
|
|
this.selectFlow(null);
|
|
|
|
break;
|
|
|
|
case Key.H:
|
|
|
|
case Key.LEFT:
|
|
|
|
if(this.refs.flowDetails){
|
|
|
|
this.refs.flowDetails.nextTab(-1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Key.L:
|
|
|
|
case Key.TAB:
|
|
|
|
case Key.RIGHT:
|
|
|
|
if(this.refs.flowDetails){
|
|
|
|
this.refs.flowDetails.nextTab(+1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.debug("keydown", e.keyCode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return false;
|
2014-09-18 19:13:50 +00:00
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
var selected = _.find(this.state.flows, { id: this.props.params.flowId });
|
|
|
|
|
2014-09-19 15:56:54 +00:00
|
|
|
var details;
|
2014-09-18 19:13:50 +00:00
|
|
|
if(selected){
|
|
|
|
details = (
|
|
|
|
FlowDetail({ref: "flowDetails",
|
|
|
|
flow: selected,
|
|
|
|
selectTab: this.selectDetailTab,
|
|
|
|
active: this.props.params.detailTab})
|
|
|
|
);
|
2014-09-19 15:56:54 +00:00
|
|
|
} else {
|
|
|
|
details = null;
|
2014-09-18 19:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2014-09-19 15:56:54 +00:00
|
|
|
React.DOM.div({className: "main-view", onKeyDown: this.onKeyDown, tabIndex: "0"},
|
2014-09-18 19:13:50 +00:00
|
|
|
FlowTable({ref: "flowTable",
|
|
|
|
flows: this.state.flows,
|
|
|
|
selectFlow: this.selectFlow,
|
|
|
|
selected: selected}),
|
2014-09-19 15:56:54 +00:00
|
|
|
details ? Splitter(null) : null,
|
2014-09-18 19:13:50 +00:00
|
|
|
details
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
var EventLog = React.createClass({displayName: 'EventLog',
|
2014-09-17 13:22:42 +00:00
|
|
|
mixins:[AutoScrollMixin],
|
2014-09-17 00:13:37 +00:00
|
|
|
getInitialState: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return {
|
|
|
|
log: []
|
|
|
|
};
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
componentDidMount: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
this.log = EventLogStore.getView();
|
|
|
|
this.log.addListener("change", this.onEventLogChange);
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
componentWillUnmount: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
this.log.removeListener("change", this.onEventLogChange);
|
|
|
|
this.log.close();
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
onEventLogChange: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
this.setState({
|
|
|
|
log: this.log.getAll()
|
|
|
|
});
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
close: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
SettingsActions.update({
|
|
|
|
showEventLog: false
|
|
|
|
});
|
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
2014-09-17 13:22:42 +00:00
|
|
|
var messages = this.state.log.map(function(row) {
|
2014-09-17 15:30:19 +00:00
|
|
|
var indicator = null;
|
|
|
|
if(row.source === "ui"){
|
|
|
|
indicator = React.DOM.i({className: "fa fa-html5"});
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
React.DOM.div({key: row.id},
|
|
|
|
indicator, " ", row.message
|
|
|
|
));
|
2014-09-17 13:22:42 +00:00
|
|
|
});
|
|
|
|
return React.DOM.pre({className: "eventlog"}, messages);
|
2014-09-15 16:08:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
|
|
|
var Footer = React.createClass({displayName: 'Footer',
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
2014-09-15 23:05:29 +00:00
|
|
|
var mode = this.props.settings.mode;
|
2014-09-15 16:08:26 +00:00
|
|
|
return (
|
|
|
|
React.DOM.footer(null,
|
2014-09-15 23:05:29 +00:00
|
|
|
mode != "regular" ? React.DOM.span({className: "label label-success"}, mode, " mode") : null
|
2014-09-15 16:08:26 +00:00
|
|
|
)
|
2014-09-17 00:13:37 +00:00
|
|
|
);
|
2014-09-15 16:08:26 +00:00
|
|
|
}
|
|
|
|
});
|
2014-09-16 04:26:16 +00:00
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
/** @jsx React.DOM */
|
|
|
|
|
|
|
|
//TODO: Move out of here, just a stub.
|
2014-09-14 00:44:13 +00:00
|
|
|
var Reports = React.createClass({displayName: 'Reports',
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
|
|
|
return React.DOM.div(null, "ReportEditor");
|
2014-09-15 22:56:43 +00:00
|
|
|
}
|
2014-09-14 00:44:13 +00:00
|
|
|
});
|
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
|
|
|
|
var ProxyAppMain = React.createClass({displayName: 'ProxyAppMain',
|
2014-09-17 00:13:37 +00:00
|
|
|
getInitialState: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return { settings: SettingsStore.getAll() };
|
2014-09-15 22:05:06 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
componentDidMount: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
SettingsStore.addListener("change", this.onSettingsChange);
|
2014-09-15 22:05:06 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
componentWillUnmount: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
SettingsStore.removeListener("change", this.onSettingsChange);
|
2014-09-15 22:05:06 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
onSettingsChange: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
this.setState({settings: SettingsStore.getAll()});
|
2014-09-15 22:05:06 +00:00
|
|
|
},
|
2014-09-17 00:13:37 +00:00
|
|
|
render: function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
return (
|
|
|
|
React.DOM.div({id: "container"},
|
2014-09-16 04:26:16 +00:00
|
|
|
Header({settings: this.state.settings}),
|
2014-09-18 19:13:50 +00:00
|
|
|
this.props.activeRouteHandler({settings: this.state.settings}),
|
2014-09-18 21:47:54 +00:00
|
|
|
this.state.settings.showEventLog ? Splitter({axis: "y"}) : null,
|
2014-09-17 13:22:42 +00:00
|
|
|
this.state.settings.showEventLog ? EventLog(null) : null,
|
2014-09-16 04:26:16 +00:00
|
|
|
Footer({settings: this.state.settings})
|
2014-09-15 22:56:43 +00:00
|
|
|
)
|
2014-09-17 00:13:37 +00:00
|
|
|
);
|
2014-09-15 16:08:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-09-18 19:13:50 +00:00
|
|
|
var Routes = ReactRouter.Routes;
|
|
|
|
var Route = ReactRouter.Route;
|
|
|
|
var Redirect = ReactRouter.Redirect;
|
|
|
|
var DefaultRoute = ReactRouter.DefaultRoute;
|
|
|
|
var NotFoundRoute = ReactRouter.NotFoundRoute;
|
|
|
|
|
|
|
|
|
2014-09-15 16:08:26 +00:00
|
|
|
var ProxyApp = (
|
2014-09-18 19:13:50 +00:00
|
|
|
Routes({location: "hash"},
|
|
|
|
Route({path: "/", handler: ProxyAppMain},
|
|
|
|
Route({name: "flows", path: "flows", handler: MainView}),
|
|
|
|
Route({name: "flow", path: "flows/:flowId/:detailTab", handler: MainView}),
|
2014-09-18 21:22:02 +00:00
|
|
|
Route({name: "reports", handler: Reports}),
|
|
|
|
Redirect({path: "/", to: "flows"})
|
2014-09-15 22:56:43 +00:00
|
|
|
)
|
2014-09-14 00:44:13 +00:00
|
|
|
)
|
2014-09-17 00:13:37 +00:00
|
|
|
);
|
|
|
|
$(function () {
|
2014-09-15 22:56:43 +00:00
|
|
|
Connection.init();
|
|
|
|
app = React.renderComponent(ProxyApp, document.body);
|
2014-09-15 16:08:26 +00:00
|
|
|
});
|
2014-09-14 00:44:13 +00:00
|
|
|
//# sourceMappingURL=app.js.map
|