Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"mongodb-connection-model": "^3.0.6",
"mongodb-instance-model": "^1.0.2",
"mongodb-ns": "^1.0.1",
"mongodb-js-metrics": "^0.2.2",
"ms": "^0.7.1",
"node-notifier": "^4.3.1",
"scout-server": "http://bin.mongodb.org/js/scout-server/v0.4.6/scout-server-0.4.6.tar.gz"
Expand All @@ -103,7 +104,6 @@
"backoff": "^2.4.1",
"bootstrap": "https://github.com/twbs/bootstrap/archive/v3.3.5.tar.gz",
"browserify": "^12.0.1",
"bugsnag-js": "^2.4.8",
"chalk": "^1.1.1",
"d3": "^3.5.6",
"del": "^2.0.2",
Expand Down
46 changes: 39 additions & 7 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ app.extend({
}
});

var bugsnag = require('./bugsnag');
bugsnag.listen(app);

var metrics = require('mongodb-js-metrics');
var _ = require('lodash');
var domReady = require('domready');
var qs = require('qs');
Expand All @@ -27,6 +25,7 @@ var localLinks = require('local-links');
var QueryOptions = require('./models/query-options');
var Connection = require('./models/connection');
var MongoDBInstance = require('./models/mongodb-instance');
var User = require('./models/user');
var Router = require('./router');
var Statusbar = require('./statusbar');

Expand Down Expand Up @@ -116,6 +115,9 @@ var Application = View.extend({
clientStartedAt: 'date',
clientStalledTimeout: 'number'
},
children: {
user: User
},
events: {
'click a': 'onLinkClick'
},
Expand Down Expand Up @@ -143,14 +145,26 @@ var Application = View.extend({
pushState: false,
root: '/'
});

metrics.listen(app);

User.getOrCreate(function(err, user) {
if (err) {
metrics.error(err, 'user: get or create');
return;
}
this.user.set(user.serialize());
this.user.trigger('sync');
}.bind(this));

app.statusbar.hide();
},
onFatalError: function(id, err) {
debug('clearing client stall timeout...');
clearTimeout(this.clientStalledTimeout);

console.error('Fatal Error!: ', id, err);
bugsnag.notifyException(err, 'Fatal Error: ' + id);
metrics.error(err, 'Fatal Error: ' + id);
app.statusbar.fatal(err);
},
// ms we'll wait for a `scout-client` instance
Expand Down Expand Up @@ -228,20 +242,30 @@ var state = new Application({
connection_id: connection_id
});

// @todo (imlucas): Feature flags can be overrideen
// via `window.localStorage`.
/**
* @todo (imlucas): Feature flags can be overridden
* via `window.localStorage`.
*/
var FEATURES = {
querybuilder: true,
keychain: true,
'Google Map Minicharts': true,
'Connect with SSL': false,
'Connect with Kerberos': false,
'Connect with LDAP': false,
'Connect with X.509': false
'Connect with X.509': false,
intercom: true,
bugsnag: true,
'google-analytics': true
};

app.extend({
client: null,
config: {
intercom: {
app_id: 'p57suhg7'
}
},
/**
* Check whether a feature flag is currently enabled.
*
Expand All @@ -267,6 +291,7 @@ app.extend({
debug('message received from main process:', msg);
this.trigger(msg);
},
metrics: metrics,
init: function() {
domReady(function() {
state.render();
Expand Down Expand Up @@ -344,6 +369,13 @@ Object.defineProperty(app, 'router', {
}
});

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


app.init();

// expose app globally for debugging purposes
Expand Down
54 changes: 0 additions & 54 deletions src/bugsnag.js

This file was deleted.

4 changes: 3 additions & 1 deletion src/connect/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ module.exports = State.extend({
// the user has modified the form fields and opted not to save the
// changes. We need to create a new connection and leave the old
// one intact.
view.form.setValues({name: ''});
view.form.setValues({
name: ''
});
connection = new Connection(view.form.data);
} else {
connection = view.connection;
Expand Down
7 changes: 4 additions & 3 deletions src/connect/filereader-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ module.exports = InputView.extend({
if (spec.multi) {
this.multi = spec.multi;
}
_.defaults(spec, {value: []});
_.defaults(spec, {
value: []
});
this.invalidClass = 'has-error';
this.validityClassSelector = '.form-item-file';
InputView.prototype.initialize.call(this, spec);
Expand Down Expand Up @@ -118,8 +120,7 @@ module.exports = InputView.extend({
* Turn into no-op, as we don't work on input elements
* @see ampersand-input-view.js#handleTypeChange
*/
handleTypeChange: function() {
},
handleTypeChange: function() {},
/**
* Turn into identity, as we don't need to trim the value
* @param {Array} val the value to pass through
Expand Down
29 changes: 15 additions & 14 deletions src/connect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var debug = require('debug')('scout:connect:index');
var _ = require('lodash');
var app = require('ampersand-app');
var format = require('util').format;
var metrics = require('mongodb-js-metrics');

/**
* AuthenticationOptionCollection
Expand Down Expand Up @@ -299,7 +300,9 @@ var ConnectView = View.extend({
this.connection = new Connection(this.form.data);
}
this.connection.is_favorite = true;
this.connection.save(null, {validate: false});
this.connection.save(null, {
validate: false
});
this.connections.add(this.connection, {
merge: true
});
Expand Down Expand Up @@ -366,23 +369,18 @@ var ConnectView = View.extend({
useConnection: function(connection) {
connection = connection || this.connection;
app.statusbar.hide();
/**
* @todo (imlucas): So we can see what auth mechanisms
* and accoutrement people are actually using IRL.
*
* metrics.trackEvent('connect success', {
* authentication: model.authentication,
* ssl: model.ssl
* });
*/
metrics.track('connect success', {
authentication: connection.authentication,
ssl: connection.ssl
});

/**
* @see ./src/app.js `params.connection_id`
*/
window.open(
format('%s?connection_id=%s#schema',
window.location.origin,
connection.getId())
window.location.origin,
connection.getId())
);
setTimeout(this.set.bind(this, {
message: ''
Expand Down Expand Up @@ -447,8 +445,11 @@ var ConnectView = View.extend({
* @api private
*/
onError: function(err, connection) {
// @todo (imlucas): `metrics.trackEvent('connect error', authentication
// + ssl boolean)`
metrics.error(err, 'connect error', {
authentication: connection.authentication,
ssl: connection.ssl
});

debug('showing error message', {
err: err,
model: connection
Expand Down
21 changes: 15 additions & 6 deletions src/electron/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,18 @@ function nonDarwinMenu(menuState) {

var MenuState = State.extend({
props: {
showCompassOverview: { type: 'boolean', default: false },
showConnect: { type: 'boolean', default: true },
showShare: { type: 'boolean', default: false }
showCompassOverview: {
type: 'boolean',
default: false
},
showConnect: {
type: 'boolean',
default: true
},
showShare: {
type: 'boolean',
default: false
}
}
});

Expand Down Expand Up @@ -300,7 +309,7 @@ var AppMenu = (function() {
getTemplate: function(winID) {
var menuState = this.windowTemplates.get(winID);

debug("WINDOW's " + winID + ' Menu State');
debug('WINDOW\'s ' + winID + ' Menu State');
debug('showCompassOverview: ' + menuState.showCompassOverview);
debug('showConnect: ' + menuState.showConnect);
debug('showShare: ' + menuState.showShare);
Expand Down Expand Up @@ -329,9 +338,9 @@ var AppMenu = (function() {
}

this.setTemplate(_window.id);
debug('WINDOW ' + _window.id + "'s menu loaded");
debug('WINDOW ' + _window.id + '\'s menu loaded');
} else {
debug('WINDOW ' + _window.id + "'s menu already loaded");
debug('WINDOW ' + _window.id + '\'s menu already loaded');
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ doctype html
html(lang='en')
head
title MongoDB
meta(http-equiv="Content-Security-Policy", content="default-src *; script-src 'self' https://*.googleapis.com https://maps.gstatic.com http://localhost:35729 'unsafe-eval'; style-src 'self' https://fonts.googleapis.com 'unsafe-inline';")
meta(http-equiv="Content-Security-Policy", content="default-src *; script-src 'self' https://*.googleapis.com https://maps.gstatic.com http://localhost:35729 https://widget.intercom.io https://js.intercomcdn.com/ 'unsafe-eval'; style-src 'self' https://fonts.googleapis.com 'unsafe-inline';")
meta(name='viewport', content='initial-scale=1')
link(rel='stylesheet', href='index.css', charset='UTF-8')
body
Expand Down
2 changes: 2 additions & 0 deletions src/minicharts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ module.exports = AmpersandView.extend(QueryBuilderMixin, {
// been here before, don't need to do it again
return true;
}

if (!app.isFeatureEnabled('Geo Minicharts')) {
return false;
}
if (!navigator.onLine) {
return false;
}

if (this.model.name === 'Document') {
if (this.model.fields.length !== 2
|| !this.model.fields.get('type')
Expand Down
6 changes: 3 additions & 3 deletions src/models/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var connectionSync = require('./connection-sync')();
var client = require('scout-client');
var debug = require('debug')('scout:models:connection');
var uuid = require('uuid');
var bugsnag = require('../bugsnag');
var metrics = require('mongodb-js-metrics');

/**
* Configuration for connecting to a MongoDB Deployment.
Expand Down Expand Up @@ -46,13 +46,13 @@ module.exports = Connection.extend({
return;
}
debug('could not get collection list :( sending to bugsnag for follow up...');
bugsnag.notify(err, 'collection list failed');
metrics.error(err, 'collection list failed');
done(err);
}.bind(this);

var onTested = function(err) {
if (err) {
bugsnag.notify(err, 'connection test failed');
metrics.error(err, 'connection test failed');
return done(err);
}

Expand Down
Loading