From e89265ee2f75f11aa68fe8235350a62260954512 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Thu, 11 Jun 2015 20:55:52 +0200 Subject: [PATCH 1/2] suppress uglifier warnings an exclude pattern would be nice, but no dice :( --- client/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/webpack.config.js b/client/webpack.config.js index 08cd37923..74c314fc3 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -116,7 +116,7 @@ var appConfig = _.merge({}, config, { }, plugins: config.plugins.concat(DEBUG ? [] : [ new webpack.optimize.DedupePlugin(), - new webpack.optimize.UglifyJsPlugin(), + new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}}), new webpack.optimize.AggressiveMergingPlugin() ] ) From 49c1493c793d8f4772dec2cbea0fe81d4eed96d7 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Thu, 11 Jun 2015 20:57:13 +0200 Subject: [PATCH 2/2] replaced console.log with debug package --- client/app/scripts/charts/nodes-chart.js | 12 +++++++----- client/app/scripts/charts/nodes-layout.js | 3 ++- client/app/scripts/stores/app-store.js | 3 ++- client/package.json | 4 +++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index 5a5d8648f..e77456153 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -1,6 +1,8 @@ const _ = require('lodash'); const d3 = require('d3'); +const debug = require('debug')('nodes-chart'); const React = require('react'); +const timely = require('timely'); const Edge = require('./edge'); const Naming = require('../constants/naming'); @@ -163,7 +165,7 @@ const NodesChart = React.createClass({ const target = nodes[edge[1]]; if (!source || !target) { - console.error('Missing edge node', edge[0], source, edge[1], target); + debug('Missing edge node', edge[0], source, edge[1], target); } edges[edgeId] = { @@ -188,9 +190,8 @@ const NodesChart = React.createClass({ const n = _.size(props.nodes); const nodeScale = d3.scale.linear().range([0, nodeSize / Math.pow(n, 0.7)]); - const layoutId = 'layered node chart'; - console.time(layoutId); - const graph = NodesLayout.doLayout( + const timedLayouter = timely(NodesLayout.doLayout); + const graph = timedLayouter( nodes, edges, props.width, @@ -198,7 +199,8 @@ const NodesChart = React.createClass({ nodeScale, MARGINS ); - console.timeEnd(layoutId); + + debug('graph layout took ' + timedLayouter.time + 'ms'); // adjust layout based on viewport diff --git a/client/app/scripts/charts/nodes-layout.js b/client/app/scripts/charts/nodes-layout.js index d21006894..651aef71c 100644 --- a/client/app/scripts/charts/nodes-layout.js +++ b/client/app/scripts/charts/nodes-layout.js @@ -1,4 +1,5 @@ const dagre = require('dagre'); +const debug = require('debug')('nodes-layout'); const _ = require('lodash'); const MAX_NODES = 100; @@ -9,7 +10,7 @@ const doLayout = function(nodes, edges, width, height, scale, margins) { const g = new dagre.graphlib.Graph({}); if (_.size(nodes) > MAX_NODES) { - console.error('Too many nodes for graph layout engine. Limit: ' + MAX_NODES); + debug('Too many nodes for graph layout engine. Limit: ' + MAX_NODES); return null; } diff --git a/client/app/scripts/stores/app-store.js b/client/app/scripts/stores/app-store.js index a55234b1f..4670b823d 100644 --- a/client/app/scripts/stores/app-store.js +++ b/client/app/scripts/stores/app-store.js @@ -1,6 +1,7 @@ const EventEmitter = require('events').EventEmitter; const _ = require('lodash'); const assign = require('object-assign'); +const debug = require('debug')('app-store'); const AppDispatcher = require('../dispatcher/app-dispatcher'); const ActionTypes = require('../constants/action-types'); @@ -179,7 +180,7 @@ AppStore.registeredCallback = function(payload) { break; case ActionTypes.RECEIVE_NODES_DELTA: - console.log('RECEIVE_NODES_DELTA', + debug('RECEIVE_NODES_DELTA', 'remove', _.size(payload.delta.remove), 'update', _.size(payload.delta.update), 'add', _.size(payload.delta.add)); diff --git a/client/package.json b/client/package.json index 5c7d0207c..72669ceab 100644 --- a/client/package.json +++ b/client/package.json @@ -8,6 +8,7 @@ "dependencies": { "d3": "^3.5.5", "dagre": "^0.7.2", + "debug": "^2.2.0", "flux": "^2.0.3", "font-awesome": "^4.3.0", "keymirror": "^0.1.1", @@ -18,7 +19,8 @@ "react": "^0.13.3", "react-tap-event-plugin": "^0.1.7", "react-tween-state": "0.0.5", - "reqwest": "~1.1.5" + "reqwest": "~1.1.5", + "timely": "^0.1.0" }, "devDependencies": { "autoprefixer-core": "^5.2.0",