Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
081b3ca
replace schema view with component
Jun 4, 2016
8a98f79
rebased and using new hadron-app-registry
Jul 29, 2016
8c959dc
getting StatusAction from appRegistry
Jul 29, 2016
7031402
register QueryAction
Jul 29, 2016
34862ad
rename schema-store.jsx to index.jsx
Jul 29, 2016
8e8326f
singular names for lib/* folders in status package
Jul 29, 2016
3041487
QueryAction, file renames, cleanup
Jul 29, 2016
5e96b85
handle error when stream ends.
Jul 29, 2016
ccbc8a5
trigger filterChanged event on apply
Jul 29, 2016
00099ff
INT-1663: Move sampling message to query
durran Aug 4, 2016
103978d
INT-1663: Use sampling message in schema view
durran Aug 4, 2016
001a6f6
INT-1663: Expose Document component
durran Aug 7, 2016
93cdbc8
Revert "INT-1663: Expose Document component"
durran Aug 18, 2016
345c493
INT-1663: Split rendering between tabs on message
durran Aug 18, 2016
8e97608
INT-1663: Change sampling message based on tab
durran Aug 18, 2016
6328a2c
fix const/let bug in coordinates.js
Aug 18, 2016
3d675bc
fix single vs. double quotes linting issue
Aug 18, 2016
8598917
adding “minicharts” for document and array.
Aug 18, 2016
3d5c375
bump eslint-config-mongodb-js@2.0.1
Aug 18, 2016
dcbd81c
fix edge case for empty subdocs with 0 fields.
Aug 18, 2016
5b8438f
INT-1663: Sample didn't error with 0 sampled docs
durran Aug 18, 2016
78f6bce
INT-1663: Ensure document list re-renders on collection change
durran Aug 22, 2016
2dbc77a
INT-1663: Show number of loaded documents in sample bar
durran Aug 22, 2016
233359d
INT-1663: Update react-bootstrap
durran Aug 22, 2016
59e2676
INT-1663: Resize minicharts on schema tab click
durran Aug 22, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"debug": "mongodb-js/debug#v2.2.3",
"debug-menu": "^0.3.0",
"electron-squirrel-startup": "^1.0.0",
"detect-coordinates": "^0.1.0",
"font-awesome": "https://github.com/FortAwesome/Font-Awesome/archive/v4.4.0.tar.gz",
"get-object-path": "azer/get-object-path#74eb42de0cfd02c14ffdd18552f295aba723d394",
"hadron-action": "^0.1.0",
Expand All @@ -124,7 +125,7 @@
"mongodb-data-service": "^1.1.1",
"mongodb-database-model": "^0.1.2",
"mongodb-explain-plan-model": "^0.2.0",
"mongodb-extended-json": "^1.6.0",
"mongodb-extended-json": "^1.7.0",
"mongodb-js-metrics": "^1.2.0",
"mongodb-language-model": "^0.3.3",
"mongodb-ns": "^1.0.3",
Expand All @@ -136,8 +137,12 @@
"qs": "^5.2.0",
"raf": "^3.1.0",
"react": "^15.2.1",
"react-bootstrap": "0.29.5",
"react-bootstrap": "0.30.2",
"react-dom": "^15.2.1",
"react-native-listener": "^1.0.1",
"react-tooltip": "^2.0.3",
"reflux": "0.4.1",
"reflux-state-mixin": "^0.7.0",
"semver": "^5.1.0",
"storage-mixin": "^0.8.0",
"tunnel-ssh": "^3.2.1-beta",
Expand All @@ -147,10 +152,11 @@
"uuid": "^2.0.1"
},
"devDependencies": {
"babel-eslint": "^6.0.4",
"chai": "^3.4.1",
"chai-as-promised": "^5.1.0",
"electron-prebuilt": "1.2.8",
"eslint-config-mongodb-js": "^1.0.6",
"eslint-config-mongodb-js": "^2.0.1",
"eslint-plugin-react": "^4.1.0",
"hadron-build": "^0.7.2",
"mocha": "^2.3.4",
Expand Down
10 changes: 6 additions & 4 deletions src/app/connect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var ConnectFormView = require('./connect-form-view');
var Connection = require('../models/connection');
var ConnectionCollection = require('../models/connection-collection');
var MongoDBConnection = require('mongodb-connection-model');

var SidebarWrapperView = require('./sidebar');
var View = require('ampersand-view');

Expand Down Expand Up @@ -38,6 +37,9 @@ var sslMethods = require('./ssl');
*/
var sshTunnelMethods = require('./ssh-tunnel');


var StatusAction = app.appRegistry.getAction('StatusAction');

var ConnectView = View.extend({
template: indexTemplate,
screenName: 'Connect',
Expand Down Expand Up @@ -428,7 +430,7 @@ var ConnectView = View.extend({
this.dispatch('error received');
return;
}
app.statusbar.show();
StatusAction.showIndeterminateProgressBar();

var onSave = function() {
this.connections.add(this.connection, { merge: true });
Expand All @@ -437,8 +439,8 @@ var ConnectView = View.extend({
};

connection.test(function(err) {
app.statusbar.hide();
if (!err) {
StatusAction.hide();
// now save connection
this.connection = connection;
this.connection.save({ last_used: new Date() }, { success: onSave.bind(this) });
Expand All @@ -459,7 +461,7 @@ var ConnectView = View.extend({
*/
useConnection: function(connection) {
connection = connection || this.connection;
app.statusbar.hide();
StatusAction.hide();
metrics.track('Connection', 'used', {
authentication: connection.authentication,
ssl: connection.ssl,
Expand Down
87 changes: 53 additions & 34 deletions src/app/home/collection.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var View = require('ampersand-view');
var Action = require('hadron-action');
var CollectionStatsView = require('../collection-stats');
var DocumentView = require('../documents');
var SchemaView = require('../schema');
var IndexView = require('../indexes');
var RefineBarView = require('../refine-view');
var ExplainView = require('../explain-plan');
var MongoDBCollection = require('../models/mongodb-collection');
var React = require('react');
var ReactDOM = require('react-dom');
var NamespaceStore = require('hadron-reflux-store').NamespaceStore;
var _ = require('lodash');

Expand All @@ -15,6 +17,14 @@ var debug = require('debug')('mongodb-compass:home:collection');

var collectionTemplate = require('./collection.jade');

// map tab label to correct view and switch views
var tabToViewMap = {
'DOCUMENTS': 'documentView',
'SCHEMA': 'schemaView',
'EXPLAIN PLAN': 'explainView',
'INDEXES': 'indexView'
};

var MongoDBCollectionView = View.extend({
// modelType: 'Collection',
template: collectionTemplate,
Expand Down Expand Up @@ -68,6 +78,7 @@ var MongoDBCollectionView = View.extend({
},
documentView: {
hook: 'document-subview',
waitFor: 'ns',
prepareView: function(el) {
return new DocumentView({
el: el,
Expand All @@ -78,6 +89,7 @@ var MongoDBCollectionView = View.extend({
},
schemaView: {
hook: 'schema-subview',
waitFor: 'ns',
prepareView: function(el) {
return new SchemaView({
el: el,
Expand All @@ -88,6 +100,7 @@ var MongoDBCollectionView = View.extend({
},
indexView: {
hook: 'index-subview',
waitFor: 'ns',
prepareView: function(el) {
return new IndexView({
el: el,
Expand All @@ -105,63 +118,69 @@ var MongoDBCollectionView = View.extend({
model: this.model
});
}
},
refineBarView: {
hook: 'refine-bar-subview',
prepareView: function(el) {
var view = new RefineBarView({
el: el,
parent: this,
queryOptions: app.queryOptions,
volatileQueryOptions: app.volatileQueryOptions
});
view.on('submit', function() {
this.trigger('submit:query');
}.bind(this));
return view;
}
}
// refineBarView: {
// hook: 'refine-bar-subview',
// prepareView: function(el) {
// var view = new RefineBarView({
// el: el,
// parent: this,
// queryOptions: app.queryOptions,
// volatileQueryOptions: app.volatileQueryOptions
// });
// view.on('submit', function() {
// this.trigger('submit:query');
// }.bind(this));
// return view;
// }
// }
},
initialize: function() {
this.model = new MongoDBCollection();
this.listenToAndRun(this.parent, 'change:ns', this.onCollectionChanged.bind(this));
NamespaceStore.listen( this.onCollectionChanged.bind(this) );
this.schemaActions = app.appRegistry.getAction('SchemaAction');
// this.listenToAndRun(this.parent, 'change:ns', this.onCollectionChanged.bind(this));
},
render: function() {
this.renderWithTemplate(this);
// render query bar here for now
var queryBarComponent = app.appRegistry.getComponent('App:QueryBar');
ReactDOM.render(React.createElement(queryBarComponent), this.queryByHook('refine-bar-subview'));
},
onTabClicked: function(e) {
e.preventDefault();
e.stopPropagation();

// map tab label to correct view and switch views
var tabToViewMap = {
'DOCUMENTS': 'documentView',
'SCHEMA': 'schemaView',
'EXPLAIN PLAN': 'explainView',
'INDEXES': 'indexView'
};
this.switchView(tabToViewMap[e.target.innerText]);
},
switchView: function(viewStr) {
debug('switching to', viewStr);
// disable all views but the active one
_.each(this._subviews, function(subview) {
subview.visible = false;
});
if (this[viewStr]) {
this[viewStr].visible = true;
}
this.activeView = viewStr;
_.each(_.values(tabToViewMap), function(subview) {
if (!this[subview]) return;
if (subview === viewStr) {
this[viewStr].el.classList.remove('hidden');
} else {
this[subview].el.classList.add('hidden');
}
}.bind(this));
// Temporary hack to generate a resize when the schema is clicked.
if (viewStr === 'schemaView') {
this.schemaActions.resizeMiniCharts();
}
},
onCollectionChanged: function() {
this.ns = this.parent.ns;
this.ns = NamespaceStore.ns;
if (!this.ns) {
this.visible = false;
debug('No active collection namespace so no schema has been requested yet.');
return;
}
this.visible = true;
this.model._id = this.ns;
// Need to keep the global state in sync.
NamespaceStore.ns = this.ns;
this.model.once('sync', this.onCollectionFetched.bind(this));
this.model.fetch();
Action.filterChanged(app.queryOptions.query.serialize());
},
onCollectionFetched: function(model) {
this.switchView(this.activeView);
Expand Down
2 changes: 2 additions & 0 deletions src/app/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var IdentifyView = require('../identify');
var CollectionView = require('./collection');
var InstancePropertyView = require('./instance-properties');
var CollectionListItemView = require('./collection-list-item');
var NamespaceStore = require('hadron-reflux-store').NamespaceStore;
var TourView = require('../tour');
var NetworkOptInView = require('../network-optin');
var app = require('ampersand-app');
Expand Down Expand Up @@ -141,6 +142,7 @@ var HomeView = View.extend({
}

this.ns = model.getId();
NamespaceStore.ns = ns.ns;
this.updateTitle(model);
this.showNoCollectionsZeroState = false;
this.showDefaultZeroState = false;
Expand Down
44 changes: 26 additions & 18 deletions src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ var Preferences = require('./models/preferences');
var ApplicationStore = require('hadron-reflux-store').ApplicationStore;
var User = require('./models/user');
var Router = require('./router');
var Statusbar = require('./statusbar');
// var Statusbar = require('./statusbar');
var migrateApp = require('./migrations');
var metricsSetup = require('./metrics');
var metrics = require('mongodb-js-metrics')();

var React = require('react');
var ReactDOM = require('react-dom');
var AutoUpdate = require('../auto-update');

var addInspectElementMenu = require('debug-menu').install;
Expand Down Expand Up @@ -254,15 +256,17 @@ var Application = View.extend({
pushState: false,
root: '/'
});
app.statusbar.hide();
var StatusAction = app.appRegistry.getAction('StatusAction');
StatusAction.hide();
},
onFatalError: function(id, err) {
debug('clearing client stall timeout...');
clearTimeout(this.clientStalledTimeout);

console.error('Fatal Error!: ', id, err);
metrics.error(err);
app.statusbar.fatal(err);
var StatusAction = app.appRegistry.getAction('StatusAction');
StatusAction.setMessage(err);
},
// ms we'll wait for a `mongodb-scope-client` instance
// to become readable before giving up and showing
Expand Down Expand Up @@ -317,10 +321,13 @@ var Application = View.extend({
});
debug('rendering statusbar...');

this.statusbar = new Statusbar({
el: this.queryByHook('statusbar')
});
this.statusbar.render();
// this.statusbar = new Statusbar({
// el: this.queryByHook('statusbar')
// });
// this.statusbar.render();

this.statusComponent = app.appRegistry.getComponent('App:Status');
ReactDOM.render(React.createElement(this.statusComponent), this.queryByHook('statusbar'));

this.autoUpdate = new AutoUpdate({
el: this.queryByHook('auto-update')
Expand Down Expand Up @@ -376,10 +383,13 @@ app.extend({
state.startRouter();
return;
}

app.statusbar.show({
var StatusAction = app.appRegistry.getAction('StatusAction');
StatusAction.configure({
visible: true,
message: 'Retrieving connection details...',
staticSidebar: true
progressbar: true,
progress: 100,
sidebar: true
});

state.connection = new Connection({
Expand All @@ -392,9 +402,7 @@ app.extend({
state.onFatalError('fetch connection', err);
return;
}
app.statusbar.show({
message: 'Connecting to MongoDB...'
});
StatusAction.setMessage('Connecting to MongoDB...');

var DataService = require('mongodb-data-service');
app.dataService = new DataService(state.connection)
Expand Down Expand Up @@ -434,11 +442,11 @@ app.extend({
}
});

Object.defineProperty(app, 'statusbar', {
get: function() {
return state.statusbar;
}
});
// Object.defineProperty(app, 'statusbar', {
// get: function() {
// return state.statusbar;
// }
// });

Object.defineProperty(app, 'autoUpdate', {
get: function() {
Expand Down
8 changes: 5 additions & 3 deletions src/app/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
@import "documents/index.less";
@import "schema/index.less";
@import "home/index.less";
@import "minicharts/index.less";
@import "refine-view/index.less";
@import "sampling-message/index.less";
@import "statusbar/index.less";
@import "tour/index.less";
@import "sidebar/index.less";
@import "network-optin/index.less";
Expand All @@ -25,4 +22,9 @@
@import "metrics/index.less";
@import "./styles/mapbox-gl.css";

// Packages
// @todo don't hard-code these, style manager needs to handle package styles
@import "../internal-packages/crud/styles/crud.less";
@import "../internal-packages/status/styles/index.less";
@import "../internal-packages/query/styles/index.less";
@import "../internal-packages/schema/styles/index.less";
9 changes: 8 additions & 1 deletion src/app/minicharts/d3fns/few.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,14 @@ var minicharts_d3fns_few = function() {

function chart(selection) {
selection.each(function(data) {
var values = _.pluck(data, 'count');
var values = _.map(data, 'count');
_.each(data, (d, i) => {
data[i].xpos = _.sum(_(data)
.slice(0, i)
.map('count')
.value()
);
});
var sumValues = d3.sum(values);
var maxValue = d3.max(values);
var percentFormat = shared.friendlyPercentFormat(maxValue / sumValues * 100);
Expand Down
Loading