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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"dependencies": {
"debug": "^2.2.0",
"electron-squirrel-startup": "^0.1.4",
"google-maps": "^3.1.0",
"keytar": "^3.0.0",
"localforage": "^1.3.0",
"mongodb-collection-model": "^0.1.1",
Expand Down Expand Up @@ -154,6 +153,7 @@
"uuid": "^2.0.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.6.0"
"watchify": "^3.6.0",
"xor-it": "^1.0.1"
}
}
6 changes: 1 addition & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ var Application = View.extend({
* @see http://learn.humanjavascript.com/react-ampersand/creating-a-router-and-pages
*/
router: 'object',
/**
* Enable/Disable features with one global switch
*/
features: 'object',
clientStartedAt: 'date',
clientStalledTimeout: 'number'
},
Expand Down Expand Up @@ -237,7 +233,7 @@ var state = new Application({
var FEATURES = {
querybuilder: true,
keychain: true,
'Geo Minicharts': true,
'Google Map Minicharts': true,
'Connect with SSL': false,
'Connect with Kerberos': false,
'Connect with LDAP': false,
Expand Down
3 changes: 2 additions & 1 deletion src/connect/filereader-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var _ = require('lodash');
var path = require('path');
var remote = window.require('remote');
var dialog = remote.require('dialog');
var BrowserWindow = remote.require('browser-window');
var format = require('util').format;
var bindings = require('ampersand-dom-bindings');
var fileReaderTemplate = require('./filereader-default.jade');
Expand Down Expand Up @@ -172,7 +173,7 @@ module.exports = InputView.extend({
this.runTests();
},
loadFileButtonClicked: function() {
dialog.showOpenDialog({
dialog.showOpenDialog(BrowserWindow.getFocusedWindow(), {
properties: ['openFile', 'multiSelections']
}, function(filenames) {
this.inputValue = filenames || [];
Expand Down
11 changes: 0 additions & 11 deletions src/home/collection.jade
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
.collection-view.clearfix
div.modal.fade(tabindex='-1', role='dialog', arialabelledby='Share Schema Confirmation', data-hook='share-schema-confirmation')
div.modal-dialog.modal-sm
.modal-content
.modal-header
button.close(type='button', data-dismiss='modal', aria-label='Close')
span(aria-hidden='true') ×
h4.modal-title Share Schema
.modal-body
p The schema definition in JSON format has been copied to the clipboard.
.modal-footer
button.btn.btn-default(type='button', data-dismiss='modal') Close
header
.row
.col-md-6
Expand Down
18 changes: 14 additions & 4 deletions src/home/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ var RefineBarView = require('../refine-view');
var MongoDBCollection = require('../models/mongodb-collection');
var SampledSchema = require('../models/sampled-schema');
var app = require('ampersand-app');
var $ = require('jquery');
var _ = require('lodash');
var remote = window.require('remote');
var dialog = remote.require('dialog');
var BrowserWindow = remote.require('browser-window');
var format = require('util').format;
var debug = require('debug')('scout:home:collection');

require('bootstrap/js/modal');

var MongoDBCollectionView = View.extend({
// modelType: 'Collection',
template: require('./collection.jade'),
Expand Down Expand Up @@ -83,7 +84,16 @@ var MongoDBCollectionView = View.extend({
onShareSchema: function() {
var clipboard = window.require('clipboard');
clipboard.writeText(JSON.stringify(this.schema.serialize(), null, ' '));
$(this.queryByHook('share-schema-confirmation')).modal('show');

var detail = format('The schema definition of %s has been copied to your '
+ 'clipboard in JSON format.', this.model._id);

dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
type: 'info',
message: 'Share Schema',
detail: detail,
buttons: ['OK']
});
},
onCollectionChanged: function() {
var ns = this.parent.ns;
Expand Down
160 changes: 160 additions & 0 deletions src/minicharts/d3fns/coordinates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
var d3 = require('d3');
var _ = require('lodash');
var shared = require('./shared');
var tooltipHtml = require('./tooltip.jade');

require('../d3-tip')(d3);

// var debug = require('debug')('scout:minicharts:coordinates');

var minicharts_d3fns_coordinates = function() {
// --- beginning chart setup ---
var width = 400;
var height = 100;
var options = {
view: null
};
var margin = shared.margin;
margin.bottom = 20;

var xScale = d3.scale.linear();
var yScale = d3.scale.linear();

var xAxis = d3.svg.axis()
.ticks(10)
.scale(xScale)
.orient('bottom');

var yAxis = d3.svg.axis()
.ticks(6)
.scale(yScale)
.orient('left');

var coordFormat = d3.format('.1f');

// set up tooltips
var tip = d3.tip()
.attr('class', 'd3-tip')
.direction('n')
.offset([-9, 0]);

// --- end chart setup ---

function chart(selection) {
selection.each(function(data) {
var el = d3.select(this);
var innerWidth = width - margin.left - margin.right;
var innerHeight = height - margin.top - margin.bottom;

// setup tool tips
tip.html(function(d) {
return tooltipHtml({
label: 'lng: ' + coordFormat(d[0]) + ', lat: ' + coordFormat(d[1])
});
});
el.call(tip);

xScale
.domain([
d3.min(data, function(d) { return d[0]; }) - 3,
d3.max(data, function(d) { return d[0]; }) + 3
])
.range([0, innerWidth]);

yScale
.domain([
d3.min(data, function(d) { return d[1]; }) - 3,
d3.max(data, function(d) { return d[1]; }) + 3
])
.range([innerHeight, 0]);

var g = el.selectAll('g').data([null]);

// append g element if it doesn't exist yet
g.enter()
.append('g')
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')
.attr('width', innerWidth)
.attr('height', innerHeight);

var x = g.selectAll('.x.axis').data([null]);
x.enter().append('g')
.attr('class', 'x axis')
.attr('transform', 'translate(0, ' + innerHeight + ')')
.append('text')
// .attr('class', 'label')
.attr('x', innerWidth)
.attr('y', -6)
.style('text-anchor', 'end')
.text('lng');
x.call(xAxis);

var y = g.selectAll('.y.axis').data([null]);
y.enter().append('g')
.attr('class', 'y axis')
.append('text')
// .attr('class', 'label')
.attr('transform', 'rotate(-90)')
.attr('y', 6)
.attr('dy', '.71em')
.style('text-anchor', 'end')
.text('lat');
y.call(yAxis);

// select all g.bar elements
var circle = g.selectAll('circle.circle')
.data(data);

circle
.transition() // only apply transition to already existing elements
.attr('cx', function(d) {
return xScale(d[0]);
})
.attr('cy', function(d) {
return yScale(d[1]);
});

circle.enter().append('circle')
.attr('class', 'circle')
.attr('cx', function(d) {
return xScale(d[0]);
})
.attr('cy', function(d) {
return yScale(d[1]);
})
.attr('r', 4.5)
.on('mouseover', tip.show)
.on('mouseout', tip.hide);

circle.exit().remove();
});
}

chart.width = function(value) {
if (!arguments.length) {
return width;
}
width = value;
return chart;
};

chart.height = function(value) {
if (!arguments.length) {
return height;
}
height = value;
return chart;
};

chart.options = function(value) {
if (!arguments.length) {
return options;
}
_.assign(options, value);
return chart;
};

return chart;
};

module.exports = minicharts_d3fns_coordinates;
Loading