Skip to content
This repository was archived by the owner on Dec 10, 2018. It is now read-only.
Open
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "frontend/lib/bootstrap"]
path = frontend/lib/bootstrap
url = git@github.com:twbs/bootstrap.git
[submodule "frontend/lib/doctrine"]
path = frontend/lib/doctrine
url = git@github.com:Constellation/doctrine.git
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var JS_LIB = [
LIB_DIR + 'codemirror/lib/codemirror.js',
LIB_DIR + 'codemirror/mode/javascript/javascript.js',
LIB_DIR + 'codemirror/addon/edit/matchbrackets.js',
LIB_DIR + 'codemirror/addon/hint/show-hint.js',
LIB_DIR + 'doctrine/doctrine.js',
LIB_DIR + 'suspend.js/dist/suspend.js'
];

Expand Down Expand Up @@ -163,6 +165,7 @@ module.exports = function (grunt) {
'frontend/dist/mongoWebShell.min.css': [
LIB_DIR + 'codemirror/lib/codemirror.css',
LIB_DIR + 'codemirror/theme/solarized.css',
LIB_DIR + 'codemirror/addon/hint/show-hint.css',
FRONTEND_DIR + 'mongoWebShell.css'
]
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/codemirror
1 change: 1 addition & 0 deletions frontend/lib/doctrine
Submodule doctrine added at 9705e9
38 changes: 38 additions & 0 deletions frontend/mongoWebShell.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,41 @@ div.CodeMirror-vscrollbar {
.mws-cm-plain-text, .mws-cm-plain-text span {
color: inherit !important;
}


.CodeMirror-hint-styled {
max-width: none;
}

.CodeMirror-hint-styled .return-type {
font-size: 12px;
padding-left: 5px;
padding-right: 3px;
text-align: right;
float: left;
width: 110px;
}

.CodeMirror-hint-styled:not(.CodeMirror-hint-active) .return-type {
color: rgb(74, 132, 204);
}

.CodeMirror-hint-styled .signature {
padding-left: 3px;
padding-right: 5px;
text-align: left;
min-width: 100px;
}

.CodeMirror-hint-styled .autocompletion-type {

}

.CodeMirror-hint-autocompletion-description {
line-height: 25px;
border-top: 10px;
border-top-color: rgb(200, 200, 200);
font-size: 11px;
font-family: Helvetica, Arial, sans-serif;
}

42 changes: 42 additions & 0 deletions frontend/src/mws/Coll.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,24 @@ mongo.Coll.prototype.toString = function () {
/**
* Makes a Cursor that is the result of a find request on the mongod backing
* server.
* @name find
* @param {object} query
* @param {object} projection
* @returns {mongo.Cursor}
*/
mongo.Coll.prototype.find = function (query, projection) {
mongo.events.functionTrigger(this.shell, 'db.collection.find', arguments,
{collection: this.name});
return new mongo.Cursor(this, query, projection);
};

/**
* Finds a single document based on the query
* @name findOne
* @param {object} query
* @param {object} projection
* @returns {object}
*/
mongo.Coll.prototype.findOne = function (query, projection) {
mongo.events.functionTrigger(this.shell, 'db.collection.findOne', arguments,
{collection: this.name});
Expand All @@ -70,12 +81,24 @@ mongo.Coll.prototype.findOne = function (query, projection) {
}.bind(this));
};

/**
* Count number of matching documents in the db to a query.
* @name count
* @param {object} query
* @param {object} projection
* @returns {number}
*/
mongo.Coll.prototype.count = function (query, projection) {
mongo.events.functionTrigger(this.shell, 'db.collection.count', arguments,
{collection: this.name});
return new mongo.Cursor(this, query, projection).count();
};

/**
* Inserts a single document into MongoDB.
* @name insert
* @param {object} doc
*/
mongo.Coll.prototype.insert = function (doc) {
var url = this.urlBase + 'insert';
var params = {document: doc};
Expand All @@ -84,6 +107,11 @@ mongo.Coll.prototype.insert = function (doc) {
mongo.request.makeRequest(url, params, 'POST', 'dbCollectionInsert', this.shell);
};

/**
* Save a document. Simple full document replacement function.
* @name save
* @param {object} doc
*/
mongo.Coll.prototype.save = function (doc) {
var url = this.urlBase + 'save';
var params = {document: doc};
Expand All @@ -96,6 +124,9 @@ mongo.Coll.prototype.save = function (doc) {
* Makes a remove request to the mongod instance on the backing server. On
* success, the item(s) are removed from the collection, otherwise a failure
* message is printed and an error is thrown.
* @name remove
* @param {object} constraint
* @param {boolean} justOne
*/
mongo.Coll.prototype.remove = function (constraint, justOne) {
var url = this.urlBase + 'remove';
Expand All @@ -113,6 +144,12 @@ mongo.Coll.prototype.remove = function (constraint, justOne) {
* Optionally, an object which specifies whether to perform an upsert and/or
* a multiple update may be used instead of the individual upsert and multi
* parameters.
*
* @name update
* @param {object} query
* @param update
* @param {object} upsert
* @param {object} multi
*/
mongo.Coll.prototype.update = function (query, update, upsert, multi) {
var url = this.urlBase + 'update';
Expand All @@ -139,6 +176,8 @@ mongo.Coll.prototype.update = function (query, update, upsert, multi) {
* Makes a drop request to the mongod instance on the backing server. On
* success, the collection is dropped from the database, otherwise a failure
* message is printed and an error is thrown.
*
* @name drop
*/
mongo.Coll.prototype.drop = function () {
var url = this.urlBase + 'drop';
Expand All @@ -151,6 +190,9 @@ mongo.Coll.prototype.drop = function () {
* Makes an aggregation request to the mongod instance on the backing server.
* On success, the result of the aggregation is returned, otherwise a failure
* message is printed and an error is thrown.
*
* @name aggregate
* @param {object} query
*/
mongo.Coll.prototype.aggregate = function() {
var query;
Expand Down
26 changes: 15 additions & 11 deletions frontend/src/mws/Readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ mongo.Readline = function (codemirror, submitFunction) {
};

mongo.Readline.prototype.keydown = function (event) {
// check if the autocomplete window is open, if it is, just return, that gets priority
if (this.inputBox.state.completionActive) {
return;
}
var key = mongo.config.keycodes;
var line;
switch (event.keyCode) {
case key.up:
line = this.getOlderHistoryEntry();
break;
case key.down:
line = this.getNewerHistoryEntry();
break;
case key.enter:
this.submit(this.inputBox.getValue());
break;
default:
return;
case key.up:
line = this.getOlderHistoryEntry();
break;
case key.down:
line = this.getNewerHistoryEntry();
break;
case key.enter:
this.submit(this.inputBox.getValue());
break;
default:
return;
}

if (line !== undefined && line !== null) {
Expand Down
Loading