提交 ed32dbce 编写于 作者: S Sercan Özdemir 提交者: GitHub

Merge pull request #353 from mongoclient/dev2

#352 
......@@ -309,7 +309,7 @@ Helper.prototype = {
out: {inline: 1}
};
Meteor.call("mapReduce", selectedCollection, mapFunc, reduceFunc, options, (err, result) => {
Meteor.call("mapReduce", selectedCollection, mapFunc, reduceFunc, options, Meteor.default_connection._lastSessionId, (err, result) => {
if (err || result.error) {
this.showMeteorFuncError(err, result, "Couldn't fetch distinct fields for autocomplete");
}
......@@ -373,8 +373,8 @@ Helper.prototype = {
const regex = new RegExp('^' + curWord, 'i');
return {
list: (!curWord ? list : list.filter(function (item) {
return item.match(regex);
})).sort(),
return item.match(regex);
})).sort(),
from: CodeMirror.Pos(cursor.line, start),
to: CodeMirror.Pos(cursor.line, end)
};
......
......@@ -15,7 +15,7 @@ export const initializeForm = function (collection) {
Ladda.create(document.querySelector('#btnCreateCollection')).start();
const connection = Connections.findOne({_id: Session.get(Helper.strSessionConnection)});
Meteor.call('listCollectionNames', connection.databaseName, function (err, result) {
Meteor.call('listCollectionNames', connection.databaseName, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Ladda.stopAll();
Helper.showMeteorFuncError(err, result, "Couldn't fetch data");
......@@ -334,7 +334,7 @@ Template.addCollection.events({
Ladda.create(document.querySelector('#btnCreateCollection')).start();
Meteor.call('createCollection', name, options, function (err, res) {
Meteor.call('createCollection', name, options, Meteor.default_connection._lastSessionId, function (err, res) {
if (err || (res && res.error)) {
Helper.showMeteorFuncError(err, res, "Couldn't create");
} else {
......
......@@ -29,7 +29,7 @@ Template.convertToCapped.events({
size: parseInt(size)
};
Meteor.call('command', command, false, {}, function (err, result) {
Meteor.call('command', command, false, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't convert");
} else {
......
......@@ -7,7 +7,7 @@ import {FlowRouter} from "meteor/kadira:flow-router";
import {Connections} from "/lib/imports/collections/connections";
import Helper from "/client/imports/helper";
import {connect} from "/client/imports/views/layouts/top_navbar/connections/connections";
import {resetForm, initializeForm} from "./add_collection/add_collection";
import {initializeForm, resetForm} from "./add_collection/add_collection";
import {resetForm as resetCappedForm} from "./convert_capped_collection/convert_to_capped";
import {resetForm as resetRenameForm} from "./rename_collection/rename_collection";
import {resetForm as resetValidationRulesForm} from "./validation_rules/validation_rules";
......@@ -41,7 +41,7 @@ const dropAllCollections = function () {
closeOnConfirm: true
}, function (isConfirm) {
if (isConfirm) {
Meteor.call('dropAllCollections', function (err, result) {
Meteor.call('dropAllCollections', Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't drop all collections");
}
......@@ -72,7 +72,7 @@ const handleNavigationAndSessions = function () {
};
const clearCollection = function (collectionName) {
Meteor.call('delete', collectionName, {}, function (err, result) {
Meteor.call('delete', collectionName, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't clear collection");
}
......@@ -83,7 +83,7 @@ const clearCollection = function (collectionName) {
};
const dropCollection = function (collectionName) {
Meteor.call('dropCollection', collectionName, function (err, result) {
Meteor.call('dropCollection', collectionName, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't drop collection");
}
......@@ -95,7 +95,7 @@ const dropCollection = function (collectionName) {
};
export const renderCollectionNames = function () {
Meteor.call('connect', Session.get(Helper.strSessionConnection), function (err, result) {
Meteor.call('connect', Session.get(Helper.strSessionConnection), Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't connect");
}
......@@ -166,7 +166,7 @@ Template.navigation.events({
confirmButtonText: "Yes, drop it!",
closeOnConfirm: false
}, function () {
Meteor.call('dropDB', function (err, result) {
Meteor.call('dropDB', Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't drop database");
}
......@@ -339,31 +339,6 @@ Template.navigation.onRendered(function () {
toastr.warning('No collection selected !');
}
}
},
drop_collection: {
name: "Drop Collection",
icon: "fa-trash",
callback: function () {
if ($(this) && $(this).context && $(this).context.innerText) {
const collectionName = $(this).context.innerText.substring(1).split(' ')[0];
swal({
title: "Are you sure?",
text: collectionName + " collection will be dropped, are you sure ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, drop it!",
closeOnConfirm: true
}, function (isConfirm) {
if (isConfirm) {
dropCollection(collectionName);
}
});
} else {
toastr.warning('No collection selected !');
}
}
}
}
},
......@@ -401,6 +376,30 @@ Template.navigation.onRendered(function () {
connect(true);
}
},
drop_collection: {
name: "Drop Collection",
icon: "fa-trash",
callback: function () {
if ($(this) && $(this).context && $(this).context.innerText) {
const collectionName = $(this).context.innerText.substring(1).split(' ')[0];
swal({
title: "Are you sure?",
text: collectionName + " collection will be dropped, are you sure ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, drop it!",
closeOnConfirm: true
}, function (isConfirm) {
if (isConfirm) {
dropCollection(collectionName);
}
});
} else {
toastr.warning('No collection selected !');
}
}
},
drop_collections: {
name: "Drop All Collections",
icon: "fa-ban",
......
......@@ -32,7 +32,7 @@ Template.renameCollection.events({
return;
}
Meteor.call("rename", collection, newName, options, function (err, result) {
Meteor.call("rename", collection, newName, options, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't rename");
} else {
......
......@@ -33,7 +33,7 @@ const initRules = function () {
const cmbValidationLevel = $('#cmbValidationLevel');
const connection = Connections.findOne({_id: Session.get(Helper.strSessionConnection)});
Meteor.call('listCollectionNames', connection.databaseName, function (err, result) {
Meteor.call('listCollectionNames', connection.databaseName, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch rules");
}
......@@ -86,7 +86,7 @@ Template.validationRules.events({
command.validationLevel = validationLevel;
command.validationAction = validationAction;
Meteor.call('command', command, false, {}, function (err, result) {
Meteor.call('command', command, false, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't save rule");
} else {
......
......@@ -30,7 +30,7 @@ Template.pageHeading.helpers({
// get distinct field keys for auto complete on every collection change.
Helper.getDistinctKeysForAutoComplete(selectedCollection);
Meteor.call("stats", selectedCollection, {}, function (err, result) {
Meteor.call("stats", selectedCollection, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
$('#divCollectionInfo').html("<div class=\"row\"><div class=\"col-lg-7\"><b>Couldn't fetch stats:</b></div><div class=\"col-lg-5\">" + Helper.getErrorMessage(err, result) + "</div></div>");
}
......
......@@ -92,7 +92,7 @@ export const connect = function (isRefresh) {
Ladda.stopAll();
return;
}
Meteor.call('connect', connection._id, function (err, result) {
Meteor.call('connect', connection._id, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't connect");
}
......
......@@ -131,7 +131,7 @@ Template.topNavbar.events({
Ladda.create(document.querySelector('#btnConnectSwitchedDatabase')).start();
Meteor.call('listDatabases', function (err, result) {
Meteor.call('listDatabases', Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch databases");
}
......@@ -214,7 +214,7 @@ Template.topNavbar.events({
'click #btnDisconnect' (e) {
e.preventDefault();
Meteor.call('disconnect');
Meteor.call('disconnect', Meteor.default_connection._lastSessionId);
Helper.clearSessions();
FlowRouter.go('/databaseStats');
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import {FlowRouter} from 'meteor/kadira:flow-router';
import Helper from '/client/imports/helper';
import {setResult} from './aggregate_result_modal/aggregate_result_modal';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {FlowRouter} from "meteor/kadira:flow-router";
import Helper from "/client/imports/helper";
import {setResult} from "./aggregate_result_modal/aggregate_result_modal";
import './aggregate_pipeline.html';
import "./aggregate_pipeline.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -101,7 +101,7 @@ Template.aggregatePipeline.events({
}
Meteor.call("aggregate", selectedCollection, pipeline, function (err, result) {
Meteor.call("aggregate", selectedCollection, pipeline, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't execute ");
}
......
......@@ -485,7 +485,7 @@ const saveFindEditor = function () {
const selectedCollection = Session.get(Helper.strSessionSelectedCollection);
Meteor.call("saveFindResult", selectedCollection, updateObjects, deletedObjectIds, addedObjects, function (err) {
Meteor.call("saveFindResult", selectedCollection, updateObjects, deletedObjectIds, addedObjects, Meteor.default_connection._lastSessionId, function (err) {
if (err) {
Helper.showMeteorFuncError(err, null, "Couldn't proceed saving find result");
} else {
......@@ -521,7 +521,7 @@ const saveEditor = function () {
const selectedCollection = Session.get(Helper.strSessionSelectedCollection);
if (doc._id) {
Meteor.call("updateOne", selectedCollection, {_id: doc._id}, doc, {}, function (err, result) {
Meteor.call("updateOne", selectedCollection, {_id: doc._id}, doc, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't update document");
} else {
......@@ -559,7 +559,7 @@ const deleteDocument = function () {
const selectedCollection = Session.get(Helper.strSessionSelectedCollection);
if (doc._id) {
Meteor.call("delete", selectedCollection, {_id: doc._id}, function (err, result) {
Meteor.call("delete", selectedCollection, {_id: doc._id}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't delete document");
} else {
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import {FlowRouter} from 'meteor/kadira:flow-router';
import Helper from '/client/imports/helper';
import {Connections} from '/lib/imports/collections/connections';
import {Settings} from '/lib/imports/collections/settings';
import {Dumps} from '/lib/imports/collections/dumps';
import Enums from '/lib/imports/enums';
import './database_dump_restore.html';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {FlowRouter} from "meteor/kadira:flow-router";
import Helper from "/client/imports/helper";
import {Connections} from "/lib/imports/collections/connections";
import {Settings} from "/lib/imports/collections/settings";
import {Dumps} from "/lib/imports/collections/dumps";
import Enums from "/lib/imports/enums";
import "./database_dump_restore.html";
require('bootstrap-filestyle');
......@@ -28,7 +27,7 @@ const initCollectionsForImport = function () {
const cmbGroup = cmb.find('#optCollections');
const connection = Connections.findOne({_id: Session.get(Helper.strSessionConnection)});
Meteor.call('listCollectionNames', connection.databaseName, function (err, result) {
Meteor.call('listCollectionNames', connection.databaseName, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch collection names");
}
......@@ -179,7 +178,7 @@ Template.databaseDumpRestore.events({
const fileReader = new FileReader();
fileReader.onload = function (file) {
let fileContent = new Uint8Array(file.target.result);
Meteor.call('mongoimport', fileContent, selectedCollection, function (err, result) {
Meteor.call('mongoimport', fileContent, selectedCollection, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't import data");
}
......
......@@ -69,7 +69,7 @@ const lineOptions = {
const fetchStats = function () {
if (Session.get(Helper.strSessionCollectionNames) != undefined) {
let settings = Settings.findOne();
Meteor.call("dbStats", function (err, result) {
Meteor.call("dbStats", Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't execute dbStats");
Session.set(Helper.strSessionDBStats, undefined);
......@@ -103,7 +103,7 @@ const fetchStatus = function () {
if (Session.get(Helper.strSessionCollectionNames) != undefined) {
let settings = Settings.findOne();
if (settings) {
Meteor.call("serverStatus", function (err, result) {
Meteor.call("serverStatus", Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
const errorMessage = result.error ? result.error.message : err.message;
$('#errorMessage').text("Successfully connected but, couldn't fetch server status: " + errorMessage);
......@@ -129,7 +129,7 @@ const fetchStatus = function () {
}
});
Meteor.call("top", function (err, result) {
Meteor.call("top", Meteor.default_connection._lastSessionId, function (err, result) {
if (result && result.result && result.result.totals) {
const collectionReadWriteData = populateTopReadWriteData(result.result.totals);
initCollectionsReadWriteTable(collectionReadWriteData);
......
......@@ -17,7 +17,7 @@ const toastr = require('toastr');
const Ladda = require('ladda');
const proceedShowingMetadata = function (id, jsonEditor) {
Meteor.call('getFile', $('#txtBucketName').val(), id, function (err, result) {
Meteor.call('getFile', $('#txtBucketName').val(), id, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't find file");
}
......@@ -53,7 +53,7 @@ export const initFilesInformation = function () {
return;
}
Meteor.call('getFileInfos', $('#txtBucketName').val(), selector, $('#txtFileFetchLimit').val(), function (err, result) {
Meteor.call('getFileInfos', $('#txtBucketName').val(), selector, $('#txtFileFetchLimit').val(), Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't get file informations");
return;
......@@ -142,7 +142,7 @@ Template.fileManagement.events({
return;
}
Meteor.call('deleteFiles', $('#txtBucketName').val(), selector, function (err, result) {
Meteor.call('deleteFiles', $('#txtBucketName').val(), selector, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.err) {
Helper.showMeteorFuncError(err, result, "Couldn't delete files");
} else {
......@@ -163,7 +163,7 @@ Template.fileManagement.events({
e.preventDefault();
const fileRow = Session.get(Helper.strSessionSelectedFile);
if (fileRow) {
window.open('download?fileId=' + fileRow._id + '&bucketName=' + $('#txtBucketName').val());
window.open('download?fileId=' + fileRow._id + '&bucketName=' + $('#txtBucketName').val() + '&sessionId=' + Meteor.default_connection._lastSessionId);
}
},
......@@ -183,7 +183,7 @@ Template.fileManagement.events({
if (isConfirm) {
Ladda.create(document.querySelector('#btnReloadFiles')).start();
Meteor.call('deleteFile', $('#txtBucketName').val(), fileRow._id, function (err) {
Meteor.call('deleteFile', $('#txtBucketName').val(), fileRow._id, Meteor.default_connection._lastSessionId, function (err) {
if (err) {
toastr.error("Couldn't delete: " + err.message);
} else {
......@@ -216,7 +216,7 @@ Template.fileManagement.events({
delete setValue._id;
Meteor.call('updateOne', $('#txtBucketName').val() + '.files',
{'_id': {"$oid": Session.get(Helper.strSessionSelectedFile)._id}}, {"$set": setValue}, {}, function (err) {
{'_id': {"$oid": Session.get(Helper.strSessionSelectedFile)._id}}, {"$set": setValue}, {}, Meteor.default_connection._lastSessionId, function (err) {
if (err) {
toastr.error("Couldn't update file info: " + err.message);
} else {
......
......@@ -53,7 +53,7 @@ export const proceedUploading = function (blob, contentType, metaData, aliases)
Ladda.create(document.querySelector('#btnUpload')).start();
const fileReader = new FileReader();
fileReader.onload = function (file) {
Meteor.call('uploadFile', $('#txtBucketName').val(), new Uint8Array(file.target.result), blob.name, contentType, metaData, aliases, function (err, result) {
Meteor.call('uploadFile', $('#txtBucketName').val(), new Uint8Array(file.target.result), blob.name, contentType, metaData, aliases, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't upload file");
}
......
......@@ -19,7 +19,7 @@ export const prepareFormForView = function () {
return;
}
Meteor.call("indexInformation", selectedCollection, true, function (err, indexInformation) {
Meteor.call("indexInformation", selectedCollection, true, Meteor.default_connection._lastSessionId, function (err, indexInformation) {
if (err || indexInformation.error) {
Helper.showMeteorFuncError(err, indexInformation, "Couldn't fetch index information");
}
......@@ -367,7 +367,7 @@ Template.addIndex.events({
setOtherOptionsForIndex(index, ttl, partialFilterExpression, indexName, collation);
command.indexes.push(index);
Meteor.call("command", command, false, {}, function (err, result) {
Meteor.call("command", command, false, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't create index");
} else {
......
......@@ -21,19 +21,19 @@ export const initIndexes = function () {
}
Ladda.create(document.querySelector('#btnAddIndex')).start();
Meteor.call("indexInformation", selectedCollection, true, function (err, indexInformation) {
Meteor.call("indexInformation", selectedCollection, true, Meteor.default_connection._lastSessionId, function (err, indexInformation) {
if (err || indexInformation.error) {
Helper.showMeteorFuncError(err, indexInformation, "Couldn't fetch indexes");
Ladda.stopAll();
}
else {
Meteor.call("stats", selectedCollection, {}, function (statsErr, stats) {
Meteor.call("stats", selectedCollection, {}, Meteor.default_connection._lastSessionId, function (statsErr, stats) {
if (statsErr || stats.error) {
Helper.showMeteorFuncError(statsErr, stats, "Couldn't fetch indexes");
Ladda.stopAll();
}
else {
Meteor.call("aggregate", selectedCollection, [{$indexStats: {}}], {}, function (aggregateErr, indexStats) {
Meteor.call("aggregate", selectedCollection, [{$indexStats: {}}], {}, Meteor.default_connection._lastSessionId, function (aggregateErr, indexStats) {
const data = populateTableData(indexInformation, stats, indexStats);
initializeIndexesTable(data);
......@@ -280,7 +280,7 @@ Template.indexManagement.events({
}, function (isConfirm) {
if (isConfirm) {
Ladda.create(document.querySelector('#btnAddIndex')).start();
Meteor.call("dropIndex", selectedCollection, indexName, function (err, result) {
Meteor.call("dropIndex", selectedCollection, indexName, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't drop index");
} else {
......
......@@ -18,7 +18,7 @@ export const initialize = function () {
}
Ladda.create(document.querySelector('#btnCloseRawViewModal')).start();
Meteor.call("indexInformation", selectedCollection, true, function (err, indexInformation) {
Meteor.call("indexInformation", selectedCollection, true, Meteor.default_connection._lastSessionId, function (err, indexInformation) {
if (err || indexInformation.error) {
Helper.showMeteorFuncError(err, indexInformation, "Couldn't fetch index information");
}
......
......@@ -136,7 +136,7 @@ const initializeCommandCodeMirror = function () {
},
"Ctrl-Space": "autocomplete",
"Enter": function (cm) {
Meteor.call("executeShellCommand", cm.getValue(), Session.get(Helper.strSessionConnection), (err) => {
Meteor.call("executeShellCommand", cm.getValue(), Session.get(Helper.strSessionConnection), Meteor.default_connection._lastSessionId, (err) => {
if (err) {
Helper.showMeteorFuncError(err, null, "Couldn't execute shell command");
}
......@@ -177,7 +177,7 @@ const initializeCommandCodeMirror = function () {
Template.mcShell.events({
'click #btnClearShell': function () {
Helper.setCodeMirrorValue($('#divShellResult'), '');
Meteor.call('clearShell');
Meteor.call('clearShell', Meteor.default_connection._lastSessionId);
}
});
......@@ -196,7 +196,10 @@ Template.mcShell.onRendered(function () {
Helper.initializeCodeMirror(divResult, 'txtShellResult', false, 600);
divResult.data('editor').setOption("readOnly", true);
ShellCommands.find({connectionId: Session.get(Helper.strSessionConnection)}, {sort: {date: -1}}).observeChanges({
ShellCommands.find({
connectionId: Session.get(Helper.strSessionConnection),
sessionId: Meteor.default_connection._lastSessionId
}, {sort: {date: -1}}).observeChanges({
added: function (id, fields) {
let previousValue = Helper.getCodeMirrorValue(divResult);
if (previousValue && !previousValue.endsWith('\n')) {
......@@ -219,7 +222,7 @@ Template.mcShell.onRendered(function () {
initializeCommandCodeMirror();
Meteor.call("connectToShell", Session.get(Helper.strSessionConnection), (err) => {
Meteor.call("connectToShell", Session.get(Helper.strSessionConnection), Meteor.default_connection._lastSessionId, (err) => {
if (err) {
Helper.showMeteorFuncError(err, null, "Couldn't connect via shell");
}
......
......@@ -134,12 +134,15 @@ Template.schemaAnalyzer.onRendered(function () {
if (connections.ready() && settings.ready() && schemaAnalyzeResult.ready()) {
Helper.initializeCollectionsCombobox();
SchemaAnalyzeResult.find({connectionId: Session.get(Helper.strSessionConnection)}, {sort: {date: -1}}).observeChanges({
SchemaAnalyzeResult.find({
connectionId: Session.get(Helper.strSessionConnection),
sessionId: Meteor.default_connection._lastSessionId
}, {sort: {date: -1}}).observeChanges({
added: function (id, fields) {
let jsonData = Helper.convertAndCheckJSON(fields.message);
if (jsonData['ERROR']) {
toastr.error(fields.message);
Meteor.call("removeSchemaAnalyzeResult");
Meteor.call("removeSchemaAnalyzeResult", Meteor.default_connection._lastSessionId);
Ladda.stopAll();
return;
}
......@@ -156,7 +159,7 @@ Template.schemaAnalyzer.onRendered(function () {
});
Template.schemaAnalyzer.onDestroyed(function () {
Meteor.call("removeSchemaAnalyzeResult");
Meteor.call("removeSchemaAnalyzeResult", Meteor.default_connection._lastSessionId);
});
Template.schemaAnalyzer.events({
......@@ -173,7 +176,7 @@ Template.schemaAnalyzer.events({
Ladda.create(document.querySelector('#btnAnalyzeNow')).start();
Meteor.call("analyzeSchema", Session.get(Helper.strSessionConnection), collection, (err) => {
Meteor.call("analyzeSchema", Session.get(Helper.strSessionConnection), collection, Meteor.default_connection._lastSessionId, (err) => {
if (err) {
Helper.showMeteorFuncError(err, null, "Couldn't analyze collection");
}
......
......@@ -12,7 +12,7 @@ const Ladda = require('ladda');
const init = function (isRefresh) {
Ladda.create(document.querySelector('#btnAddNewStoredFunction')).start();
Meteor.call("find", "system.js", {}, {}, false, function (err, result) {
Meteor.call("find", "system.js", {}, {}, false, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch stored functions");
}
......@@ -112,7 +112,7 @@ Template.storedFunctions.events({
Ladda.create(document.querySelector('#btnSaveStoredFunction')).start();
if (modal.data('selected')) {
//edit
Meteor.call('updateOne', "system.js", {_id: data._id}, objectToSave, function (err, result) {
Meteor.call('updateOne', "system.js", {_id: data._id}, objectToSave, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't save");
} else {
......@@ -126,7 +126,7 @@ Template.storedFunctions.events({
}
else {
//add
Meteor.call('insertMany', "system.js", [objectToSave], {}, function (err, result) {
Meteor.call('insertMany', "system.js", [objectToSave], {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't insert");
} else {
......@@ -170,7 +170,7 @@ Template.storedFunctions.events({
}, function (isConfirm) {
if (isConfirm) {
Ladda.create(document.querySelector('#btnAddNewStoredFunction')).start();
Meteor.call('delete', "system.js", {_id: name}, function (err, result) {
Meteor.call('delete', "system.js", {_id: name}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't delete");
} else {
......
......@@ -28,7 +28,7 @@ const popEditRoleModal = function (role) {
showPrivileges: true
};
Meteor.call('command', rolesInfoCommand, runOnAdminDB, function (err, result) {
Meteor.call('command', rolesInfoCommand, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch roleInfo");
}
......@@ -211,7 +211,7 @@ const initResourcesForPrivileges = function (dbToSelect, collectionToSelect) {
const cmbDBGroup = cmb.find('#optDB');
Meteor.call('getDatabases', function (err, result) {
Meteor.call('getDatabases', Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch databases");
}
......@@ -257,7 +257,7 @@ const initCollectionsForPrivilege = function (collectionToSelect, db, stopLadda)
const cmbGroup = cmb.find('#optCollections');
if (db) {
Meteor.call('listCollectionNames', db, function (err, result) {
Meteor.call('listCollectionNames', db, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch collection names");
}
......@@ -319,7 +319,7 @@ const initActionsForPrivilege = function (actions) {
const cmb = $('#cmbActionsOfPrivilege');
cmb.empty();
Meteor.call('getAllActions', Session.get(Helper.strSessionConnection), function (err, result) {
Meteor.call('getAllActions', function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch actions from docs.mongodb.org");
}
......@@ -357,7 +357,7 @@ const initDatabasesForInheritRole = function () {
const cmb = $('#cmbDatabasesForInheritRole');
cmb.empty();
Meteor.call('getDatabases', function (err, result) {
Meteor.call('getDatabases', Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch databases");
}
......@@ -390,7 +390,7 @@ const initRolesForDBForInheritRole = function () {
Meteor.call('command', {
rolesInfo: 1,
showBuiltinRoles: true
}, false, false, runOnAdminDB, function (err, result) {
}, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch roles, please enter one manually");
}
......@@ -451,7 +451,7 @@ export const initRoles = function () {
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', command, runOnAdminDB, function (err, result) {
Meteor.call('command', command, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch roles");
}
......@@ -541,7 +541,7 @@ Template.manageRoles.events({
const command = {dropRole: Session.get(Helper.strSessionUsermanagementRole).role};
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', command, runOnAdminDB, function (err, result) {
Meteor.call('command', command, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't drop role");
}
......@@ -664,7 +664,7 @@ Template.manageRoles.events({
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', command, runOnAdminDB, function (err, result) {
Meteor.call('command', command, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't update role");
}
......
......@@ -101,7 +101,7 @@ export const popEditUserModal = function (user) {
showPrivileges: true
};
Meteor.call('command', userInfoCommand, runOnAdminDB, function (err, result) {
Meteor.call('command', userInfoCommand, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch userInfo");
}
......@@ -141,7 +141,7 @@ export const initUsers = function () {
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', command, runOnAdminDB, function (err, result) {
Meteor.call('command', command, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch users");
}
......@@ -232,7 +232,7 @@ Template.manageUsers.events({
const command = {dropUser: Session.get(Helper.strSessionUsermanagementUser).user};
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', command, runOnAdminDB, function (err, result) {
Meteor.call('command', command, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't drop user");
}
......@@ -275,7 +275,7 @@ Template.manageUsers.events({
showPrivileges: true
};
Meteor.call('command', userInfoCommand, runOnAdminDB, function (err, result) {
Meteor.call('command', userInfoCommand, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch userInfo");
}
......@@ -338,7 +338,7 @@ Template.manageUsers.events({
Ladda.create(document.querySelector('#btnApplyAddEditUser')).start();
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', command, runOnAdminDB, function (err, result) {
Meteor.call('command', command, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't update user");
}
......@@ -397,7 +397,7 @@ Template.manageUsers.events({
cmb.append($("<optgroup id='optGroupDatabases' label='Databases'></optgroup>"));
const cmbOptGroupCollection = cmb.find('#optGroupDatabases');
Meteor.call('getDatabases', function (err, result) {
Meteor.call('getDatabases', Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch databases");
}
......@@ -418,7 +418,10 @@ Template.manageUsers.events({
});
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', {rolesInfo: 1, showBuiltinRoles: true}, runOnAdminDB, function (err, result) {
Meteor.call('command', {
rolesInfo: 1,
showBuiltinRoles: true
}, runOnAdminDB, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch roles to populate table");
}
......
......@@ -32,7 +32,7 @@ const initUserTree = function () {
const runOnAdminDB = $('#aRunOnAdminDBToFetchUsers').iCheck('update')[0].checked;
Meteor.call('command', command, runOnAdminDB, function (err, result) {
Meteor.call('command', command, runOnAdminDB,{},Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch users");
}
......@@ -62,7 +62,7 @@ const initUserTree = function () {
showPrivileges: true
};
Meteor.call('command', userInfoCommand, runOnAdminDB, function (err, result) {
Meteor.call('command', userInfoCommand, runOnAdminDB,{},Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch userInfo");
}
......@@ -78,7 +78,7 @@ const initUserTree = function () {
showBuiltinRoles: true
};
Meteor.call('command', roleInfoCommand, runOnAdminDB, function (err, result) {
Meteor.call('command', roleInfoCommand, runOnAdminDB,{},Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't fetch roleInfo");
}
......
......@@ -57,7 +57,7 @@ Template.addUser.executeQuery = function () {
const runOnAdminDB = $('#aRunOnAdminDB').iCheck('update')[0].checked;
Meteor.call("addUser", username, password, options, runOnAdminDB, function (err, result) {
Meteor.call("addUser", username, password, options, runOnAdminDB,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -12,7 +12,7 @@ Template.buildInfo.onRendered(function() {
Template.buildInfo.executeQuery = function() {
initExecuteQuery();
Meteor.call("buildInfo", function(err, result) {
Meteor.call("buildInfo",Meteor.default_connection._lastSessionId, function(err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -54,7 +54,7 @@ Template.command.executeQuery = function () {
let runOnAdminDB = $('#aRunOnAdminDB').iCheck('update')[0].checked;
Meteor.call("command", command, runOnAdminDB, options, function (err, result) {
Meteor.call("command", command, runOnAdminDB, options,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
}
);
......
......@@ -15,7 +15,7 @@ Template.listDatabases.onRendered(function () {
Template.listDatabases.executeQuery = function () {
initExecuteQuery();
Meteor.call("listDatabases", function (err, result) {
Meteor.call("listDatabases",Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -15,7 +15,7 @@ Template.ping.onRendered(function () {
Template.ping.executeQuery = function () {
initExecuteQuery();
Meteor.call("ping", function (err, result) {
Meteor.call("ping",Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -14,7 +14,7 @@ Template.profilingInfo.onRendered(function () {
Template.profilingInfo.executeQuery = function () {
initExecuteQuery();
Meteor.call("profilingInfo", function (err, result) {
Meteor.call("profilingInfo",Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -27,7 +27,7 @@ Template.removeUser.executeQuery = function () {
const runOnAdminDB = $('#aRunOnAdminDB').iCheck('update')[0].checked;
Meteor.call("removeUser", username, runOnAdminDB, function (err, result) {
Meteor.call("removeUser", username, runOnAdminDB,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import Helper from '/client/imports/helper';
import {initExecuteQuery} from '/client/imports/views/pages/admin_queries/admin_queries';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import Helper from "/client/imports/helper";
import {initExecuteQuery} from "/client/imports/views/pages/admin_queries/admin_queries";
import './repl_set_get_status.html';
import "./repl_set_get_status.html";
/**
* Created by RSercan on 10.1.2016.
......@@ -15,7 +15,7 @@ Template.replSetGetStatus.onRendered(function () {
Template.replSetGetStatus.executeQuery = function () {
initExecuteQuery();
Meteor.call("replSetGetStatus", function (err, result) {
Meteor.call("replSetGetStatus", Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -15,7 +15,7 @@ Template.serverInfo.onRendered(function () {
Template.serverInfo.executeQuery = function () {
initExecuteQuery();
Meteor.call("serverInfo", function (err, result) {
Meteor.call("serverInfo",Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -15,7 +15,7 @@ Template.serverStatus.onRendered(function () {
Template.serverStatus.executeQuery = function () {
initExecuteQuery();
Meteor.call("serverStatus", function (err, result) {
Meteor.call("serverStatus",Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/admin_queries/admin_queries';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/admin_queries/admin_queries";
import './set_profiling_level.html';
import "./set_profiling_level.html";
/**
* Created by RSercan on 10.1.2016.
......@@ -18,7 +18,7 @@ Template.setProfilingLevel.executeQuery = function () {
initExecuteQuery();
const level = $('#cmbLevel').val();
Meteor.call("setProfilingLevel", level, function (err, result) {
Meteor.call("setProfilingLevel", level, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
......
......@@ -33,7 +33,7 @@ Template.validateCollection.executeQuery = function () {
return;
}
Meteor.call("validateCollection", collectionName, options, function (err, result) {
Meteor.call("validateCollection", collectionName, options,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, true);
});
};
\ No newline at end of file
......@@ -54,7 +54,7 @@ Template.aggregate.executeQuery = function (historyParams) {
options: options
};
Meteor.call("aggregate", selectedCollection, pipeline, options, function (err, result) {
Meteor.call("aggregate", selectedCollection, pipeline, options,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "aggregate", params, (!historyParams));
}
);
......
......@@ -50,7 +50,7 @@ Template.bulkWrite.executeQuery = function (historyParams) {
options: options
};
Meteor.call("bulkWrite", selectedCollection, operations, options, function (err, result) {
Meteor.call("bulkWrite", selectedCollection, operations, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "bulkWrite", params, (!historyParams));
}
);
......
......@@ -48,7 +48,7 @@ Template.count.executeQuery = function (historyParams) {
options: options
};
Meteor.call("count", selectedCollection, selector, options, function (err, result) {
Meteor.call("count", selectedCollection, selector, options,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "count", params, (!historyParams));
}
);
......
......@@ -55,7 +55,7 @@ Template.createIndex.executeQuery = function (historyParams) {
options: options
};
Meteor.call("createIndex", selectedCollection, fields, options, function (err, result) {
Meteor.call("createIndex", selectedCollection, fields, options,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "createIndex", params, (!historyParams));
});
};
......
......@@ -31,7 +31,7 @@ Template.delete.executeQuery = function (historyParams) {
selector: selector
};
Meteor.call("delete", selectedCollection, selector, function (err, result) {
Meteor.call("delete", selectedCollection, selector,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "delete", params, (!historyParams));
}
);
......
......@@ -66,7 +66,7 @@ Template.distinct.executeQuery = function (historyParams) {
options: options
};
Meteor.call("distinct", selectedCollection, selector, fieldName, options, function (err, result) {
Meteor.call("distinct", selectedCollection, selector, fieldName, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "distinct", params, (!historyParams));
}
);
......
......@@ -29,7 +29,7 @@ Template.dropIndex.executeQuery = function (historyParams) {
indexName: indexName
};
Meteor.call("dropIndex", selectedCollection, indexName, function (err, result) {
Meteor.call("dropIndex", selectedCollection, indexName, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "dropIndex", params, (!historyParams));
});
};
......
......@@ -30,7 +30,7 @@ const proceedFindQuery = function (selectedCollection, selector, cursorOptions,
window.open('export?format=' + exportFormat + '&selectedCollection=' + selectedCollection + "&selector=" + JSON.stringify(selector) + "&cursorOptions=" + JSON.stringify(cursorOptions));
Ladda.stopAll();
} else {
Meteor.call("find", selectedCollection, selector, cursorOptions, executeExplain, function (err, result) {
Meteor.call("find", selectedCollection, selector, cursorOptions, executeExplain, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "find", params, saveHistory);
});
}
......@@ -91,7 +91,7 @@ Template.find.executeQuery = function (historyParams, exportFormat) {
// max allowed fetch size != 0 and there's no project option, check for size
if (maxAllowedFetchSize && maxAllowedFetchSize != 0 && !(Enums.CURSOR_OPTIONS.PROJECT in cursorOptions)) {
// get stats to calculate fetched documents size from avgObjSize (stats could be changed, therefore we can't get it from html )
Meteor.call("stats", selectedCollection, {}, function (statsError, statsResult) {
Meteor.call("stats", selectedCollection, {}, Meteor.default_connection._lastSessionId, function (statsError, statsResult) {
if (statsError || statsResult.error || !(statsResult.result.avgObjSize)) {
// if there's an error, nothing we can do
proceedFindQuery(selectedCollection, selector, cursorOptions, (!historyParams), exportFormat);
......@@ -104,7 +104,7 @@ Template.find.executeQuery = function (historyParams, exportFormat) {
}
}
else {
Meteor.call("count", selectedCollection, selector, function (err, result) {
Meteor.call("count", selectedCollection, selector, {}, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
proceedFindQuery(selectedCollection, selector, cursorOptions, (!historyParams), exportFormat);
}
......
......@@ -57,7 +57,7 @@ Template.findOne.executeQuery = function (historyParams) {
cursorOptions: cursorOptions
};
Meteor.call("findOne", selectedCollection, selector, cursorOptions, function (err, result) {
Meteor.call("findOne", selectedCollection, selector, cursorOptions,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "findOne", params, (!historyParams));
}
);
......
......@@ -58,7 +58,7 @@ Template.findOneAndDelete.executeQuery = function (historyParams) {
options: options
};
Meteor.call("findOneAndDelete", selectedCollection, selector, options, function (err, result) {
Meteor.call("findOneAndDelete", selectedCollection, selector, options,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "findOneAndDelete", params, (!historyParams));
}
);
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {getSelectorValue} from '/client/imports/views/query_templates_options/selector/selector';
import {getOptions} from '/client/imports/views/query_templates_options/findone_modify_options/findone_modify_options';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {getSelectorValue} from "/client/imports/views/query_templates_options/selector/selector";
import {getOptions} from "/client/imports/views/query_templates_options/findone_modify_options/findone_modify_options";
import './findone_and_replace.html';
import "./findone_and_replace.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -65,7 +65,7 @@ Template.findOneAndReplace.executeQuery = function (historyParams) {
options: options
};
Meteor.call("findOneAndReplace", selectedCollection, selector, replaceObject, options, function (err, result) {
Meteor.call("findOneAndReplace", selectedCollection, selector, replaceObject, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "findOneAndReplace", params, (!historyParams));
}
);
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {getSelectorValue} from '/client/imports/views/query_templates_options/selector/selector';
import {getOptions} from '/client/imports/views/query_templates_options/findone_modify_options/findone_modify_options';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {getSelectorValue} from "/client/imports/views/query_templates_options/selector/selector";
import {getOptions} from "/client/imports/views/query_templates_options/findone_modify_options/findone_modify_options";
import '/client/imports/views/query_templates_options/set/set';
import './findone_and_update.html';
import "/client/imports/views/query_templates_options/set/set";
import "./findone_and_update.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -66,7 +66,7 @@ Template.findOneAndUpdate.executeQuery = function (historyParams) {
options: options
};
Meteor.call("findOneAndUpdate", selectedCollection, selector, setObject, options, function (err, result) {
Meteor.call("findOneAndUpdate", selectedCollection, selector, setObject, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "findOneAndUpdate", params, (!historyParams));
}
);
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {getOptions} from '/client/imports/views/query_templates_options/geo_haystack_search_options/geo_haystack_search_options';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {getOptions} from "/client/imports/views/query_templates_options/geo_haystack_search_options/geo_haystack_search_options";
import './geo_haystack_search.html';
import "./geo_haystack_search.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -58,7 +58,7 @@ Template.geoHaystackSearch.executeQuery = function (historyParams) {
options: options
};
Meteor.call("geoHaystackSearch", selectedCollection, xAxis, yAxis, options, function (err, result) {
Meteor.call("geoHaystackSearch", selectedCollection, xAxis, yAxis, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "geoHaystackSearch", params, (!historyParams));
});
};
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {getOptions} from '/client/imports/views/query_templates_options/geo_near_options/geo_near_options';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {getOptions} from "/client/imports/views/query_templates_options/geo_near_options/geo_near_options";
import './geo_near.html';
import "./geo_near.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -56,7 +56,7 @@ Template.geoNear.executeQuery = function (historyParams) {
options: options
};
Meteor.call("geoNear", selectedCollection, xAxis, yAxis, options, function (err, result) {
Meteor.call("geoNear", selectedCollection, xAxis, yAxis, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "geoNear", params, (!historyParams));
});
};
......
......@@ -84,7 +84,7 @@ Template.group.executeQuery = function (historyParams) {
command: command
};
Meteor.call("group", selectedCollection, keys, condition, initial, reduce, finalize, command, function (err, result) {
Meteor.call("group", selectedCollection, keys, condition, initial, reduce, finalize, command, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "group", params, (!historyParams));
});
};
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import './index_information.html';
import "./index_information.html";
/**
* Created by RSercan on 3.1.2016.
......@@ -24,7 +24,7 @@ Template.indexInformation.executeQuery = function (historyParams) {
full: fullVal
};
Meteor.call("indexInformation", selectedCollection, fullVal, function (err, result) {
Meteor.call("indexInformation", selectedCollection, fullVal, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "indexInformation", params, (!historyParams));
});
};
......
......@@ -48,7 +48,7 @@ Template.insertMany.executeQuery = function (historyParams) {
options: options
};
Meteor.call("insertMany", selectedCollection, docs, options, function (err, result) {
Meteor.call("insertMany", selectedCollection, docs, options,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "insertMany", params, (!historyParams));
});
};
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import './is_capped.html';
import "./is_capped.html";
/**
* Created by RSercan on 3.1.2016.
......@@ -16,7 +16,7 @@ Template.isCapped.executeQuery = function (historyParams) {
initExecuteQuery();
const selectedCollection = Session.get(Helper.strSessionSelectedCollection);
Meteor.call("isCapped", selectedCollection, function (err, result) {
Meteor.call("isCapped", selectedCollection, Meteor.default_connection._lastSessionId, function (err, result) {
if (!result.result) {
result.result = false;
}
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {getOptions} from '/client/imports/views/query_templates_options/map_reduce_options/map_reduce_options';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {getOptions} from "/client/imports/views/query_templates_options/map_reduce_options/map_reduce_options";
import './map_reduce.html';
import "./map_reduce.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -65,7 +65,7 @@ Template.mapReduce.executeQuery = function (historyParams) {
options: options
};
Meteor.call("mapReduce", selectedCollection, map, reduce, options, function (err, result) {
Meteor.call("mapReduce", selectedCollection, map, reduce, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "mapReduce", params, (!historyParams));
});
};
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import './options.html';
import "./options.html";
/**
* Created by RSercan on 5.1.2016.
......@@ -16,7 +16,7 @@ Template.options.executeQuery = function (historyParams) {
initExecuteQuery();
const selectedCollection = Session.get(Helper.strSessionSelectedCollection);
Meteor.call("options", selectedCollection, function (err, result) {
Meteor.call("options", selectedCollection, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "options", {}, (!historyParams));
});
};
......
......@@ -16,7 +16,7 @@ Template.reIndex.executeQuery = function (historyParams) {
initExecuteQuery();
const selectedCollection = Session.get(Helper.strSessionSelectedCollection);
Meteor.call("reIndex", selectedCollection, function (err, result) {
Meteor.call("reIndex", selectedCollection,Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "reIndex", {}, (!historyParams));
});
};
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {$} from 'meteor/jquery';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {$} from "meteor/jquery";
import './rename.html';
import "./rename.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -48,7 +48,7 @@ Template.rename.executeQuery = function () {
}
if (newName) {
Meteor.call("rename", selectedCollection, newName, options, function (err, result) {
Meteor.call("rename", selectedCollection, newName, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "rename");
if (err == undefined && result.error == undefined) {
renderCollectionnames(newName);
......@@ -62,7 +62,7 @@ Template.rename.executeQuery = function () {
};
const renderCollectionnames = function (newName) {
Meteor.call('connect', Session.get(Helper.strSessionConnection), function (err, result) {
Meteor.call('connect', Session.get(Helper.strSessionConnection), Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
Helper.showMeteorFuncError(err, result, "Couldn't connect");
} else {
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {$} from 'meteor/jquery';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {$} from "meteor/jquery";
import './stats.html';
import "./stats.html";
/**
* Created by sercan on 06.01.2016.
......@@ -56,7 +56,7 @@ Template.stats.executeQuery = function (historyParams) {
options: options
};
Meteor.call("stats", selectedCollection, options, function (err, result) {
Meteor.call("stats", selectedCollection, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "stats", params, (!historyParams));
});
};
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {getSelectorValue} from '/client/imports/views/query_templates_options/selector/selector';
import {$} from 'meteor/jquery';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {getSelectorValue} from "/client/imports/views/query_templates_options/selector/selector";
import {$} from "meteor/jquery";
import '/client/imports/views/query_templates_options/set/set';
import '/client/imports/views/query_templates_options/upsert/upsert';
import "/client/imports/views/query_templates_options/set/set";
import "/client/imports/views/query_templates_options/upsert/upsert";
import './update_many.html';
import "./update_many.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -82,7 +82,7 @@ Template.updateMany.executeQuery = function (historyParams) {
options: options
};
Meteor.call("updateMany", selectedCollection, selector, setObject, options, function (err, result) {
Meteor.call("updateMany", selectedCollection, selector, setObject, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "updateMany", params, (!historyParams));
}
);
......
import {Template} from 'meteor/templating';
import {Meteor} from 'meteor/meteor';
import {Session} from 'meteor/session';
import Helper from '/client/imports/helper';
import Enums from '/lib/imports/enums';
import {initExecuteQuery} from '/client/imports/views/pages/browse_collection/browse_collection';
import {getSelectorValue} from '/client/imports/views/query_templates_options/selector/selector';
import {$} from 'meteor/jquery';
import '/client/imports/views/query_templates_options/set/set';
import '/client/imports/views/query_templates_options/upsert/upsert';
import './update_one.html';
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {initExecuteQuery} from "/client/imports/views/pages/browse_collection/browse_collection";
import {getSelectorValue} from "/client/imports/views/query_templates_options/selector/selector";
import {$} from "meteor/jquery";
import "/client/imports/views/query_templates_options/set/set";
import "/client/imports/views/query_templates_options/upsert/upsert";
import "./update_one.html";
const toastr = require('toastr');
const Ladda = require('ladda');
......@@ -82,7 +82,7 @@ Template.updateOne.executeQuery = function (historyParams) {
options: options
};
Meteor.call("updateOne", selectedCollection, selector, setObject, options, function (err, result) {
Meteor.call("updateOne", selectedCollection, selector, setObject, options, Meteor.default_connection._lastSessionId, function (err, result) {
Helper.renderAfterQueryExecution(err, result, false, "updateOne", params, (!historyParams));
});
};
......
......@@ -17,6 +17,7 @@ const packageJson = require('/package.json');
const mongodbUrlParser = require('parse-mongo-url');
const checkAuthenticationOfConnection = function (connection) {
LOGGER.info('[checkAuthenticationOfConnection]', connection.authenticationType);
if (connection.authenticationType !== 'scram_sha_1') delete connection.scram_sha_1;
if (connection.authenticationType !== 'mongodb_cr') delete connection.mongodb_cr;
if (connection.authenticationType !== 'mongodb_x509') delete connection.mongodb_x509;
......@@ -31,6 +32,7 @@ const checkAuthenticationOfConnection = function (connection) {
export const parseUrl = function (connection) {
try {
LOGGER.info('[parseUrl]', connection.url);
let parsedUrl = mongodbUrlParser(connection.url);
connection.options = connection.options || {};
connection.ssl = connection.ssl || {};
......@@ -92,6 +94,7 @@ const checkConnection = function (connection) {
};
const saveConnectionToDB = function (connection) {
LOGGER.info('[saveConnectionToDB]', JSON.stringify(connection));
if (connection._id) {
Connections.remove({_id: connection._id});
}
......@@ -101,6 +104,7 @@ const saveConnectionToDB = function (connection) {
Meteor.methods({
subscribed(){
LOGGER.info('[subscriber]', 'setting as subscribed');
Settings.update({}, {
$set: {subscribed: true}
});
......@@ -128,6 +132,7 @@ Meteor.methods({
checkMongoclientVersion(){
try {
LOGGER.info('[checkMongoclientVersion]');
const response = HTTP.get('https://api.github.com/repos/mongoclient/mongoclient/releases/latest', {headers: {"User-Agent": "Mongoclient"}});
if (response && response.data && response.data.name && response.data.name !== packageJson.version) {
return "There's a new version of mongoclient: " + response.data.name + ", <a href='https://github.com/mongoclient/mongoclient/releases/latest' target='_blank'>download here</a>, if you're using docker just use pull for the <b>" + response.data.name + "</b> or <b>latest</b> tag !";
......@@ -138,15 +143,18 @@ Meteor.methods({
}
},
removeSchemaAnalyzeResult(){
SchemaAnalyzeResult.remove({});
removeSchemaAnalyzeResult(sessionId){
LOGGER.info('[removeSchemaAnalyzeResult]', sessionId);
SchemaAnalyzeResult.remove({sessionId: sessionId});
},
saveActions(action) {
LOGGER.info('[saveActions]', action);
Actions.insert(action);
},
saveQueryHistory(history) {
LOGGER.info('[saveQueryHistory]', history);
const queryHistoryCount = QueryHistory.find({
connectionId: history.connectionId,
collectionName: history.collectionName
......@@ -160,6 +168,7 @@ Meteor.methods({
},
updateDump(dump) {
LOGGER.info('[updateDump]', dump._id, dump.connectionName, dump.connectionId, dump.status);
Dumps.update({_id: dump._id}, {
$set: {
connectionName: dump.connectionName,
......@@ -173,19 +182,23 @@ Meteor.methods({
},
saveDump(dump) {
LOGGER.info('[saveDump]', dump._id, dump.connectionName, dump.connectionId, dump.status);
Dumps.insert(dump);
},
updateSettings(settings) {
LOGGER.info('[updateSettings]', JSON.stringify(settings));
Settings.remove({});
Settings.insert(settings);
},
saveConnection(connection) {
LOGGER.info('[saveConnection]', JSON.stringify(connection));
saveConnectionToDB(connection)
},
checkAndSaveConnection(connection){
LOGGER.info('[checkAndSaveConnection]', JSON.stringify(connection));
checkConnection(connection);
if (!connection.databaseName) {
......@@ -200,6 +213,7 @@ Meteor.methods({
},
removeConnection(connectionId) {
LOGGER.info('[removeConnection]', connectionId);
Connections.remove(connectionId);
Dumps.remove({connectionId: connectionId});
QueryHistory.remove({connectionId: connectionId});
......
......@@ -96,6 +96,7 @@ const migrateSSHPart = function (oldConnection, connection) {
host: oldConnection.sshAddress,
port: oldConnection.sshPort,
username: oldConnection.sshUser,
destinationPort: oldConnection.sshPort
};
if (oldConnection.sshPassword) connection.ssh.password = oldConnection.sshPassword;
......@@ -117,7 +118,7 @@ function tryInjectDefaultConnection() {
connection.connectionName = DEFAULT_CONNECTION_NAME;
// delete existing connection after we parsed the new one
let existingConnection = Connections.findOne({ connectionName: DEFAULT_CONNECTION_NAME });
let existingConnection = Connections.findOne({connectionName: DEFAULT_CONNECTION_NAME});
if (existingConnection) {
Connections.remove(existingConnection._id);
connection._id = existingConnection._id;
......@@ -155,5 +156,5 @@ Meteor.startup(function () {
ShellCommands.remove({});
SchemaAnalyzeResult.remove({});
migrateConnectionsIfExist();
tryInjectDefaultConnection();
tryInjectDefaultConnection();
});
......@@ -5,15 +5,15 @@
import LOGGER from "../internal/logger";
import Helper from "./helper";
import {Meteor} from "meteor/meteor";
import {database} from "./methods_common";
import {databasesBySessionId} from "./methods_common";
const proceedQueryExecution = function (methodArray, runOnAdminDB) {
LOGGER.info(JSON.stringify(methodArray), runOnAdminDB);
const proceedQueryExecution = function (methodArray, runOnAdminDB, sessionId) {
LOGGER.info(JSON.stringify(methodArray), runOnAdminDB, sessionId);
let result = Async.runSync(function (done) {
try {
let execution = runOnAdminDB ? database.admin() : database;
let execution = runOnAdminDB ? databasesBySessionId[sessionId].admin() : databasesBySessionId[sessionId];
for (let i = 0; i < methodArray.length; i++) {
let last = i == (methodArray.length - 1);
let entry = methodArray[i];
......@@ -35,7 +35,7 @@ const proceedQueryExecution = function (methodArray, runOnAdminDB) {
}
}
catch (ex) {
LOGGER.error(methodArray, ex);
LOGGER.error(methodArray, sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -44,17 +44,17 @@ const proceedQueryExecution = function (methodArray, runOnAdminDB) {
};
Meteor.methods({
top(){
LOGGER.info('[top]');
top(sessionId){
LOGGER.info('[top]', sessionId);
let result = Async.runSync(function (done) {
try {
database.executeDbAdminCommand({top: 1}, {}, function (err, res) {
databasesBySessionId[sessionId].executeDbAdminCommand({top: 1}, {}, function (err, res) {
done(err, res);
});
}
catch (ex) {
LOGGER.error('[top]', ex);
LOGGER.error('[top]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -62,17 +62,17 @@ Meteor.methods({
return Helper.convertBSONtoJSON(result);
},
dbStats() {
LOGGER.info('[stats]');
dbStats(sessionId) {
LOGGER.info('[stats]', sessionId);
let result = Async.runSync(function (done) {
try {
database.stats(function (err, docs) {
databasesBySessionId[sessionId].stats(function (err, docs) {
done(err, docs);
});
}
catch (ex) {
LOGGER.error('[stats]', ex);
LOGGER.error('[stats]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -80,111 +80,111 @@ Meteor.methods({
return Helper.convertBSONtoJSON(result);
},
validateCollection(collectionName, options) {
validateCollection(collectionName, options, sessionId) {
const methodArray = [
{
"validateCollection": [collectionName, options]
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
setProfilingLevel(level) {
setProfilingLevel(level, sessionId) {
const methodArray = [
{
"setProfilingLevel": [level]
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
serverStatus() {
serverStatus(sessionId) {
const methodArray = [
{
"serverStatus": []
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
serverInfo() {
serverInfo(sessionId) {
const methodArray = [
{
"serverInfo": []
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
replSetGetStatus() {
replSetGetStatus(sessionId) {
const methodArray = [
{
"replSetGetStatus": []
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
removeUser(username, runOnAdminDB) {
removeUser(username, runOnAdminDB, sessionId) {
const methodArray = [
{
"removeUser": [username]
}
];
return proceedQueryExecution(methodArray, runOnAdminDB);
return proceedQueryExecution(methodArray, runOnAdminDB, sessionId);
},
profilingInfo() {
profilingInfo(sessionId) {
const methodArray = [
{
"profilingInfo": []
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
ping() {
ping(sessionId) {
const methodArray = [
{
"ping": []
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
listDatabases() {
listDatabases(sessionId) {
const methodArray = [
{
"listDatabases": []
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
},
command (command, runOnAdminDB, options) {
command (command, runOnAdminDB, options, sessionId) {
const methodArray = [
{
"command": [command, options]
}
];
return proceedQueryExecution(methodArray, runOnAdminDB);
return proceedQueryExecution(methodArray, runOnAdminDB, sessionId);
},
addUser(username, password, options, runOnAdminDB) {
addUser(username, password, options, runOnAdminDB, sessionId) {
const methodArray = [
{
"addUser": [username, password, options]
}
];
return proceedQueryExecution(methodArray, runOnAdminDB);
return proceedQueryExecution(methodArray, runOnAdminDB, sessionId);
},
buildInfo() {
buildInfo(sessionId) {
const methodArray = [
{
"buildInfo": []
}
];
return proceedQueryExecution(methodArray, true);
return proceedQueryExecution(methodArray, true, sessionId);
}
});
\ No newline at end of file
......@@ -5,23 +5,23 @@
import LOGGER from "../internal/logger";
import Helper from "./helper";
import {Meteor} from "meteor/meteor";
import {database} from "./methods_common";
import {databasesBySessionId} from "./methods_common";
const proceedMapReduceExecution = function (selectedCollection, map, reduce, options) {
const proceedMapReduceExecution = function (selectedCollection, map, reduce, options, sessionId) {
options = Helper.convertJSONtoBSON(options);
LOGGER.info('[mapReduce]', selectedCollection, map, reduce, options);
LOGGER.info('[mapReduce]', selectedCollection, map, reduce, options, sessionId);
let result = Async.runSync(function (done) {
try {
const collection = database.collection(selectedCollection);
const collection = databasesBySessionId[sessionId].collection(selectedCollection);
collection.mapReduce(map, reduce, options, function (err, resultCollection) {
if (err) {
done(err, null);
return;
}
if ((typeof options.out) == 'string') {
if ((typeof options.out) === 'string') {
resultCollection.find().toArray(function (err, result) {
done(err, result);
});
......@@ -32,7 +32,7 @@ const proceedMapReduceExecution = function (selectedCollection, map, reduce, opt
});
}
catch (ex) {
LOGGER.error('[mapReduce]', ex);
LOGGER.error('[mapReduce]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -40,19 +40,19 @@ const proceedMapReduceExecution = function (selectedCollection, map, reduce, opt
return Helper.convertBSONtoJSON(result);
};
export const proceedQueryExecution = function (selectedCollection, methodArray, removeCollectionTopology) {
LOGGER.info(JSON.stringify(methodArray), selectedCollection);
export const proceedQueryExecution = function (selectedCollection, methodArray, sessionId, removeCollectionTopology) {
LOGGER.info(JSON.stringify(methodArray), selectedCollection, sessionId);
let result = Async.runSync(function (done) {
try {
let execution = database.collection(selectedCollection);
let execution = databasesBySessionId[sessionId].collection(selectedCollection);
for (let i = 0; i < methodArray.length; i++) {
let last = i == (methodArray.length - 1);
let last = (i === (methodArray.length - 1));
let entry = methodArray[i];
entry = Helper.convertJSONtoBSON(entry);
for (let key in entry) {
if (entry.hasOwnProperty(key)) {
if (last && key == Object.keys(entry)[Object.keys(entry).length - 1]) {
if (last && key === Object.keys(entry)[Object.keys(entry).length - 1]) {
entry[key].push(function (err, docs) {
done(err, docs);
});
......@@ -67,7 +67,7 @@ export const proceedQueryExecution = function (selectedCollection, methodArray,
}
}
catch (ex) {
LOGGER.error(methodArray, ex);
LOGGER.error(methodArray, sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -80,174 +80,174 @@ export const proceedQueryExecution = function (selectedCollection, methodArray,
};
Meteor.methods({
saveFindResult(selectedCollection, updateObjects, deleteObjectIds, addedObjects){
saveFindResult(selectedCollection, updateObjects, deleteObjectIds, addedObjects, sessionId){
for (let obj of updateObjects) {
proceedQueryExecution(selectedCollection, [{"updateOne": [{_id: obj._id}, obj, {}]}]);
proceedQueryExecution(selectedCollection, [{"updateOne": [{_id: obj._id}, obj, {}]}], sessionId);
}
if (deleteObjectIds.length > 0) {
proceedQueryExecution(selectedCollection, [{"deleteMany": [{_id: {$in: deleteObjectIds}}]}]);
proceedQueryExecution(selectedCollection, [{"deleteMany": [{_id: {$in: deleteObjectIds}}]}], sessionId);
}
if (addedObjects.length > 0) {
proceedQueryExecution(selectedCollection, [{"insertMany": [addedObjects]}]);
proceedQueryExecution(selectedCollection, [{"insertMany": [addedObjects]}], sessionId);
}
},
bulkWrite(selectedCollection, operations, options) {
bulkWrite(selectedCollection, operations, options, sessionId) {
const methodArray = [
{
"bulkWrite": [operations, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
updateOne(selectedCollection, selector, setObject, options) {
updateOne(selectedCollection, selector, setObject, options, sessionId) {
const methodArray = [
{
"updateOne": [selector, setObject, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
updateMany(selectedCollection, selector, setObject, options) {
updateMany(selectedCollection, selector, setObject, options, sessionId) {
const methodArray = [
{
"updateMany": [selector, setObject, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
stats(selectedCollection, options) {
stats(selectedCollection, options, sessionId) {
const methodArray = [
{
"stats": [options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
rename(selectedCollection, newName, options) {
rename(selectedCollection, newName, options, sessionId) {
const methodArray = [
{
"rename": [newName, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray, true);
return proceedQueryExecution(selectedCollection, methodArray, sessionId, true);
},
reIndex(selectedCollection) {
reIndex(selectedCollection, sessionId) {
const methodArray = [
{
"reIndex": []
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
options(selectedCollection) {
options(selectedCollection, sessionId) {
const methodArray = [
{
"options": []
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
mapReduce(selectedCollection, map, reduce, options) {
return proceedMapReduceExecution(selectedCollection, map, reduce, options);
mapReduce(selectedCollection, map, reduce, options, sessionId) {
return proceedMapReduceExecution(selectedCollection, map, reduce, options, sessionId);
},
isCapped(selectedCollection) {
isCapped(selectedCollection, sessionId) {
const methodArray = [
{
"isCapped": []
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
insertMany(selectedCollection, docs, options) {
insertMany(selectedCollection, docs, options, sessionId) {
const methodArray = [
{
"insertMany": [docs, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
indexInformation(selectedCollection, isFull) {
indexInformation(selectedCollection, isFull, sessionId) {
const methodArray = [
{
"indexInformation": [{'full': isFull}]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
geoNear(selectedCollection, xAxis, yAxis, options) {
geoNear(selectedCollection, xAxis, yAxis, options, sessionId) {
const methodArray = [
{
"geoNear": [xAxis, yAxis, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
geoHaystackSearch(selectedCollection, xAxis, yAxis, options) {
geoHaystackSearch(selectedCollection, xAxis, yAxis, options, sessionId) {
const methodArray = [
{
"geoHaystackSearch": [xAxis, yAxis, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
dropIndex(selectedCollection, indexName) {
dropIndex(selectedCollection, indexName, sessionId) {
const methodArray = [
{
"dropIndex": [indexName]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
distinct(selectedCollection, selector, fieldName, options) {
distinct(selectedCollection, selector, fieldName, options, sessionId) {
const methodArray = [
{
"distinct": [fieldName, selector, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
delete(selectedCollection, selector) {
delete(selectedCollection, selector, sessionId) {
const methodArray = [
{
"deleteMany": [selector]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
createIndex(selectedCollection, fields, options) {
createIndex(selectedCollection, fields, options, sessionId) {
const methodArray = [
{
"createIndex": [fields, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
findOne(selectedCollection, selector, cursorOptions) {
findOne(selectedCollection, selector, cursorOptions, sessionId) {
const methodArray = [
{
"find": [selector]
......@@ -262,10 +262,10 @@ Meteor.methods({
}
methodArray.push({'limit': [1]});
methodArray.push({'next': []});
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
find(selectedCollection, selector, cursorOptions, executeExplain) {
find(selectedCollection, selector, cursorOptions, executeExplain, sessionId) {
const methodArray = [
{
"find": [selector]
......@@ -285,61 +285,61 @@ Meteor.methods({
methodArray.push({'toArray': []});
}
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
findOneAndUpdate(selectedCollection, selector, setObject, options) {
findOneAndUpdate(selectedCollection, selector, setObject, options, sessionId) {
const methodArray = [
{
"findOneAndUpdate": [selector, setObject, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
findOneAndReplace(selectedCollection, selector, setObject, options) {
findOneAndReplace(selectedCollection, selector, setObject, options, sessionId) {
const methodArray = [
{
"findOneAndReplace": [selector, setObject, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
findOneAndDelete(selectedCollection, selector, options) {
findOneAndDelete(selectedCollection, selector, options, sessionId) {
const methodArray = [
{
"findOneAndDelete": [selector, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
aggregate(selectedCollection, pipeline, options = {}) {
aggregate(selectedCollection, pipeline, options = {}, sessionId) {
const methodArray = [
{
"aggregate": [pipeline, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
count(selectedCollection, selector, options) {
count(selectedCollection, selector, options, sessionId) {
const methodArray = [
{
"count": [selector, options]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
},
group (selectedCollection, keys, condition, initial, reduce, finalize, command){
group (selectedCollection, keys, condition, initial, reduce, finalize, command, sessionId){
const methodArray = [
{
"group": [keys, condition, initial, reduce, finalize, command]
}
];
return proceedQueryExecution(selectedCollection, methodArray);
return proceedQueryExecution(selectedCollection, methodArray, sessionId);
}
});
\ No newline at end of file
......@@ -18,33 +18,33 @@ const fs = require('fs');
const spawn = require('cross-spawn');
const os = require('os');
export let database;
let spawnedShell;
let tunnel;
export let databasesBySessionId = {};
let spawnedShellsBySessionId = {};
let tunnelsBySessionId = {};
const connectToShell = function (connectionId) {
const connectToShell = function (connectionId, sessionId) {
try {
const connection = Connections.findOne({_id: connectionId});
if (!spawnedShell) {
if (!spawnedShellsBySessionId[sessionId]) {
const connectionUrl = Helper.getConnectionUrl(connection);
const mongoPath = getProperMongo();
LOGGER.info('[shell]', mongoPath, connectionUrl);
spawnedShell = spawn(mongoPath, [connectionUrl]);
setEventsToShell(connectionId);
LOGGER.info('[shell]', mongoPath, connectionUrl, sessionId);
spawnedShellsBySessionId[sessionId] = spawn(mongoPath, [connectionUrl]);
setEventsToShell(connectionId, sessionId);
}
if (spawnedShell) {
LOGGER.info('[shell]', 'executing command "use ' + connection.databaseName + '" on shell');
spawnedShell.stdin.write('use ' + connection.databaseName + '\n');
if (spawnedShellsBySessionId[sessionId]) {
LOGGER.info('[shell]', 'executing command "use ' + connection.databaseName + '" on shell', sessionId);
spawnedShellsBySessionId[sessionId].stdin.write('use ' + connection.databaseName + '\n');
}
else {
return {err: new Meteor.Error("Couldn't spawn shell !"), result: null};
}
}
catch (ex) {
spawnedShell = null;
LOGGER.error('[shell]', ex);
spawnedShellsBySessionId[sessionId] = null;
LOGGER.error('[shell]', sessionId, ex);
return {err: new Meteor.Error(ex.message), result: null};
}
};
......@@ -93,7 +93,7 @@ const getProperMongo = function () {
}
};
const proceedConnectingMongodb = function (dbName, connectionUrl, connectionOptions, done) {
const proceedConnectingMongodb = function (dbName, sessionId, connectionUrl, connectionOptions, done) {
if (!connectionOptions) {
connectionOptions = {};
}
......@@ -101,79 +101,83 @@ const proceedConnectingMongodb = function (dbName, connectionUrl, connectionOpti
mongodbApi.MongoClient.connect(connectionUrl, connectionOptions, function (mainError, db) {
try {
if (mainError || !db) {
LOGGER.error(mainError, db);
LOGGER.error(mainError, sessionId, db);
done(mainError, db);
if (db) db.close();
if (tunnel) {
tunnel.close();
tunnel = null;
if (tunnelsBySessionId[sessionId]) {
tunnelsBySessionId[sessionId].close();
tunnelsBySessionId[sessionId] = null;
}
return;
}
database = db.db(dbName);
database.listCollections().toArray(function (err, collections) {
databasesBySessionId[sessionId] = db.db(dbName);
databasesBySessionId[sessionId].listCollections().toArray(function (err, collections) {
done(err, collections);
});
}
catch (ex) {
LOGGER.error('[connect]', ex);
LOGGER.error('[connect]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
if (db) db.close();
if (tunnel) {
tunnel.close();
tunnel = null;
if (tunnelsBySessionId[sessionId]) {
tunnelsBySessionId[sessionId].close();
tunnelsBySessionId[sessionId] = null;
}
}
});
};
const setEventsToShell = function (connectionId) {
LOGGER.info('[shell]', 'binding events to shell');
const setEventsToShell = function (connectionId, sessionId) {
LOGGER.info('[shell]', 'binding events to shell', connectionId, sessionId);
spawnedShell.on('error', Meteor.bindEnvironment(function (err) {
LOGGER.error('unexpected error on spawned shell: ' + err);
spawnedShell = null;
spawnedShellsBySessionId[sessionId].on('error', Meteor.bindEnvironment(function (err) {
LOGGER.error('unexpected error on spawned shell: ' + err, sessionId);
spawnedShellsBySessionId[sessionId] = null;
if (err) {
ShellCommands.insert({
'date': Date.now(),
'sessionId': sessionId,
'connectionId': connectionId,
'message': 'unexpected error ' + err.message
});
}
}));
spawnedShell.stdout.on('data', Meteor.bindEnvironment(function (data) {
spawnedShellsBySessionId[sessionId].stdout.on('data', Meteor.bindEnvironment(function (data) {
if (data && data.toString()) {
ShellCommands.insert({
'date': Date.now(),
'sessionId': sessionId,
'connectionId': connectionId,
'message': data.toString()
});
}
}));
spawnedShell.stderr.on('data', Meteor.bindEnvironment(function (data) {
spawnedShellsBySessionId[sessionId].stderr.on('data', Meteor.bindEnvironment(function (data) {
if (data && data.toString()) {
ShellCommands.insert({
'date': Date.now(),
'sessionId': sessionId,
'connectionId': connectionId,
'message': data.toString()
});
}
}));
spawnedShell.on('close', Meteor.bindEnvironment(function (code) {
spawnedShellsBySessionId[sessionId].on('close', Meteor.bindEnvironment(function (code) {
// show ended message in codemirror
ShellCommands.insert({
'date': Date.now(),
'connectionId': connectionId,
'sessionId': sessionId,
'message': 'shell closed ' + code.toString()
});
spawnedShell = null;
spawnedShellsBySessionId[sessionId] = null;
Meteor.setTimeout(function () {
// remove all for further
ShellCommands.remove({});
ShellCommands.remove({'sessionId': sessionId});
}, 500);
}));
};
......@@ -232,30 +236,30 @@ Meteor.methods({
});
},
listCollectionNames(dbName) {
LOGGER.info('[listCollectionNames]', dbName);
listCollectionNames(dbName, sessionId) {
LOGGER.info('[listCollectionNames]', dbName, sessionId);
return Async.runSync(function (done) {
try {
const wishedDB = database.db(dbName);
const wishedDB = databasesBySessionId[sessionId].db(dbName);
wishedDB.listCollections().toArray(function (err, collections) {
done(err, collections);
});
}
catch (ex) {
LOGGER.error('[listCollectionNames]', ex);
LOGGER.error('[listCollectionNames]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
getDatabases() {
LOGGER.info('[getDatabases]');
getDatabases(sessionId) {
LOGGER.info('[getDatabases]', sessionId);
return Async.runSync(function (done) {
try {
database.admin().listDatabases(function (err, dbs) {
databasesBySessionId[sessionId].admin().listDatabases(function (err, dbs) {
if (dbs) {
done(err, dbs.databases);
}
......@@ -265,30 +269,32 @@ Meteor.methods({
});
}
catch (ex) {
LOGGER.error('[getDatabases]', ex);
LOGGER.error('[getDatabases]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
disconnect() {
if (database) {
database.close();
disconnect(sessionId) {
LOGGER.info('[disconnect]', sessionId);
if (databasesBySessionId[sessionId]) {
databasesBySessionId[sessionId].close();
}
if (spawnedShell) {
spawnedShell.stdin.end();
spawnedShell = null;
if (spawnedShellsBySessionId[sessionId]) {
spawnedShellsBySessionId[sessionId].stdin.end();
spawnedShellsBySessionId[sessionId] = null;
}
ShellCommands.remove({});
ShellCommands.remove({'sessionId': sessionId});
SchemaAnaylzeResult.remove({});
},
connect(connectionId) {
connect(connectionId, sessionId) {
const connection = Connections.findOne({_id: connectionId});
const connectionUrl = Helper.getConnectionUrl(connection);
const connectionOptions = Helper.getConnectionOptions(connection);
LOGGER.info('[connect]', connectionUrl, Helper.clearConnectionOptionsForLog(connectionOptions));
LOGGER.info('[connect]', connectionUrl, Helper.clearConnectionOptionsForLog(connectionOptions), sessionId);
return Async.runSync(function (done) {
try {
......@@ -305,121 +311,122 @@ Meteor.methods({
if (connection.ssh.passPhrase) config.passphrase = connection.ssh.passPhrase;
if (connection.ssh.password) config.password = connection.ssh.password;
LOGGER.info('[connect]', '[ssh]', 'ssh is enabled, config is ' + JSON.stringify(config));
tunnel = tunnelSsh(config, Meteor.bindEnvironment(function (error) {
LOGGER.info('[connect]', '[ssh]', sessionId, 'ssh is enabled, config is ' + JSON.stringify(config));
tunnelsBySessionId[sessionId] = tunnelSsh(config, Meteor.bindEnvironment(function (error) {
if (error) {
done(new Meteor.Error(error.message), null);
return;
}
proceedConnectingMongodb(connection.databaseName, connectionUrl, connectionOptions, done);
spawnedShell = spawn(getProperMongo(), [connectionUrl]);
setEventsToShell(connectionId);
proceedConnectingMongodb(connection.databaseName, sessionId, connectionUrl, connectionOptions, done);
spawnedShellsBySessionId[sessionId] = spawn(getProperMongo(), [connectionUrl]);
setEventsToShell(connectionId, sessionId);
}));
tunnel.on('error', function (err) {
tunnelsBySessionId[sessionId].on('error', function (err) {
if (err) done(new Meteor.Error(err.message), null);
if (tunnel) {
tunnel.close();
tunnel = null;
if (tunnelsBySessionId[sessionId]) {
tunnelsBySessionId[sessionId].close();
tunnelsBySessionId[sessionId] = null;
}
});
}
else {
proceedConnectingMongodb(connection.databaseName, connectionUrl, connectionOptions, done);
proceedConnectingMongodb(connection.databaseName, sessionId, connectionUrl, connectionOptions, done);
}
}
catch (ex) {
LOGGER.error('[connect]', ex);
LOGGER.error('[connect]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
dropDB() {
LOGGER.info('[dropDatabase]');
dropDB(sessionId) {
LOGGER.info('[dropDatabase]', sessionId);
return Async.runSync(function (done) {
try {
database.dropDatabase(function (err, result) {
databasesBySessionId[sessionId].dropDatabase(function (err, result) {
done(err, result);
});
}
catch (ex) {
LOGGER.error('[dropDatabase]', ex);
LOGGER.error('[dropDatabase]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
dropCollection(collectionName) {
LOGGER.info('[dropCollection]', collectionName);
dropCollection(collectionName, sessionId) {
LOGGER.info('[dropCollection]', sessionId, collectionName);
return Async.runSync(function (done) {
try {
const collection = database.collection(collectionName);
const collection = databasesBySessionId[sessionId].collection(collectionName);
collection.drop(function (dropError) {
done(dropError, null);
});
}
catch (ex) {
LOGGER.error('[dropCollection]', ex);
LOGGER.error('[dropCollection]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
dropAllCollections() {
dropAllCollections(sessionId) {
LOGGER.info('[dropAllCollections]', sessionId);
return Async.runSync(function (done) {
try {
database.collections(function (err, collections) {
databasesBySessionId[sessionId].collections(function (err, collections) {
keepDroppingCollections(collections, 0, done);
});
}
catch (ex) {
LOGGER.error('[dropAllCollections]', ex);
LOGGER.error('[dropAllCollections]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
createCollection(collectionName, options) {
LOGGER.info('[createCollection]', collectionName, JSON.stringify(options));
createCollection(collectionName, options, sessionId) {
LOGGER.info('[createCollection]', collectionName, sessionId, JSON.stringify(options));
return Async.runSync(function (done) {
try {
database.createCollection(collectionName, options, function (err) {
databasesBySessionId[sessionId].createCollection(collectionName, options, function (err) {
done(err, null);
});
}
catch (ex) {
LOGGER.error('[createCollection]', ex);
LOGGER.error('[createCollection]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
clearShell(){
LOGGER.info('[clearShell]');
ShellCommands.remove({});
clearShell(sessionId){
LOGGER.info('[clearShell]', sessionId);
ShellCommands.remove({'sessionId': sessionId});
},
executeShellCommand(command, connectionId){
LOGGER.info('[shellCommand]', command, connectionId);
if (!spawnedShell) connectToShell(connectionId);
if (spawnedShell) spawnedShell.stdin.write(command + '\n');
executeShellCommand(command, connectionId, sessionId){
LOGGER.info('[shellCommand]', sessionId, command, connectionId);
if (!spawnedShellsBySessionId[sessionId]) connectToShell(connectionId, sessionId);
if (spawnedShellsBySessionId[sessionId]) spawnedShellsBySessionId[sessionId].stdin.write(command + '\n');
},
connectToShell(connectionId){
connectToShell(connectionId);
connectToShell(connectionId, sessionId){
connectToShell(connectionId, sessionId);
},
analyzeSchema(connectionId, collection){
analyzeSchema(connectionId, collection, sessionId){
const connectionUrl = Helper.getConnectionUrl(Connections.findOne({_id: connectionId}), true);
const mongoPath = getProperMongo();
let args = [connectionUrl, '--quiet', '--eval', 'var collection =\"' + collection + '\", outputFormat=\"json\"', getMongoExternalsPath() + '/variety/variety.js_'];
LOGGER.info('[analyzeSchema]', args, collection);
LOGGER.info('[analyzeSchema]', sessionId, args, collection);
try {
let spawned = spawn(mongoPath, args);
let message = "";
......@@ -433,6 +440,7 @@ Meteor.methods({
if (data.toString()) {
SchemaAnaylzeResult.insert({
'date': Date.now(),
'sessionId': sessionId,
'connectionId': connectionId,
'message': data.toString()
});
......@@ -442,6 +450,7 @@ Meteor.methods({
spawned.on('close', Meteor.bindEnvironment(function () {
SchemaAnaylzeResult.insert({
'date': Date.now(),
'sessionId': sessionId,
'connectionId': connectionId,
'message': message
});
......@@ -450,7 +459,7 @@ Meteor.methods({
spawned.stdin.end();
}
catch (ex) {
LOGGER.error('[analyzeSchema]', ex);
LOGGER.error('[analyzeSchema]', sessionId, ex);
return {err: new Meteor.Error(ex.message), result: null};
}
......
......@@ -2,31 +2,31 @@
* Created by RSercan on 17.1.2016.
*/
import {Connections} from '/lib/imports/collections/connections';
import {Meteor} from 'meteor/meteor';
import {Connections} from "/lib/imports/collections/connections";
import {Meteor} from "meteor/meteor";
import LOGGER from "../internal/logger";
import Helper from "./helper";
import Enums from "/lib/imports/enums";
import {proceedQueryExecution} from './methods_collection';
import {proceedQueryExecution} from "./methods_collection";
const backup = require('mongodb-backup');
const restore = require('mongodb-restore');
const fs = require('fs');
Meteor.methods({
mongoimport(blob, collection){
try{
mongoimport(blob, collection, sessionId){
try {
let buffer = new Buffer(blob);
LOGGER.info('[mongoimport]', collection);
LOGGER.info('[mongoimport]', sessionId, collection);
const methodArray = [
{
"insertMany": [JSON.parse(buffer.toString())]
}
];
return proceedQueryExecution(collection, methodArray);
}catch (ex){
LOGGER.error('[mongoimport]', ex);
return proceedQueryExecution(collection, methodArray, sessionId);
} catch (ex) {
LOGGER.error('[mongoimport]', sessionId, ex);
throw new Meteor.Error(ex.message);
}
},
......
......@@ -4,21 +4,21 @@
/*global Async*/
import LOGGER from "../internal/logger";
import Helper from "./helper";
import {database} from "./methods_common";
import {databasesBySessionId} from "./methods_common";
import {Meteor} from "meteor/meteor";
const mongodbApi = require('mongodb');
Meteor.methods({
deleteFiles(bucketName, selector){
LOGGER.info('[deleteFiles]', bucketName, selector);
deleteFiles(bucketName, selector, sessionId){
LOGGER.info('[deleteFiles]', bucketName, selector, sessionId);
selector = Helper.convertJSONtoBSON(selector);
let result = Async.runSync(function (done) {
try {
let filesCollection = database.collection(bucketName + ".files");
let chunksCollection = database.collection(bucketName + ".chunks");
let filesCollection = databasesBySessionId[sessionId].collection(bucketName + ".files");
let chunksCollection = databasesBySessionId[sessionId].collection(bucketName + ".chunks");
filesCollection.find(selector, {_id: 1}).toArray(function (err, docs) {
if (err) {
......@@ -31,14 +31,14 @@ Meteor.methods({
ids.push(obj._id);
}
LOGGER.info(JSON.stringify(selector) + " removing from " + bucketName + ".files");
LOGGER.info(JSON.stringify(selector) + " removing from " + bucketName + ".files", sessionId);
filesCollection.deleteMany({_id: {$in: ids}}, {}, function (err) {
if (err) {
done(err, null);
return;
}
LOGGER.info(JSON.stringify(selector) + " removing from " + bucketName + ".chunks");
LOGGER.info(JSON.stringify(selector) + " removing from " + bucketName + ".chunks", sessionId);
chunksCollection.deleteMany({files_id: {$in: ids}}, function (err) {
done(err, null);
})
......@@ -46,7 +46,7 @@ Meteor.methods({
});
}
catch (ex) {
LOGGER.error('[deleteFiles]', ex);
LOGGER.error('[deleteFiles]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -54,18 +54,18 @@ Meteor.methods({
return Helper.convertBSONtoJSON(result);
},
deleteFile(bucketName, fileId) {
LOGGER.info('[deleteFile]', bucketName, fileId);
deleteFile(bucketName, fileId, sessionId) {
LOGGER.info('[deleteFile]', bucketName, fileId, sessionId);
let result = Async.runSync(function (done) {
try {
const bucket = new mongodbApi.GridFSBucket(database, {bucketName: bucketName});
const bucket = new mongodbApi.GridFSBucket(databasesBySessionId[sessionId], {bucketName: bucketName});
bucket.delete(new mongodbApi.ObjectId(fileId), function (err) {
done(err, null);
});
}
catch (ex) {
LOGGER.error('[deleteFile]', ex);
LOGGER.error('[deleteFile]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -73,23 +73,23 @@ Meteor.methods({
return Helper.convertBSONtoJSON(result);
},
getFileInfos(bucketName, selector, limit) {
getFileInfos(bucketName, selector, limit, sessionId) {
limit = parseInt(limit) || 100;
selector = selector || {};
selector = Helper.convertJSONtoBSON(selector);
LOGGER.info('[getFileInfos]', bucketName, JSON.stringify(selector), limit);
LOGGER.info('[getFileInfos]', bucketName, JSON.stringify(selector), limit, sessionId);
let result = Async.runSync(function (done) {
try {
const bucket = new mongodbApi.GridFSBucket(database, {bucketName: bucketName});
const bucket = new mongodbApi.GridFSBucket(databasesBySessionId[sessionId], {bucketName: bucketName});
bucket.find(selector, {limit: limit}).toArray(function (err, files) {
done(err, files);
});
}
catch (ex) {
LOGGER.error('[getFileInfos]', ex);
LOGGER.error('[getFileInfos]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......@@ -97,18 +97,18 @@ Meteor.methods({
return Helper.convertBSONtoJSON(result);
},
uploadFile(bucketName, blob, fileName, contentType, metaData, aliases) {
uploadFile(bucketName, blob, fileName, contentType, metaData, aliases, sessionId) {
if (metaData) {
metaData = Helper.convertJSONtoBSON(metaData);
}
blob = new Buffer(blob);
LOGGER.info('[uploadFile]', bucketName, fileName, contentType, JSON.stringify(metaData), aliases);
LOGGER.info('[uploadFile]', bucketName, fileName, contentType, JSON.stringify(metaData), aliases, sessionId);
return Async.runSync(function (done) {
try {
const bucket = new mongodbApi.GridFSBucket(database, {bucketName: bucketName});
const bucket = new mongodbApi.GridFSBucket(databasesBySessionId[sessionId], {bucketName: bucketName});
let uploadStream = bucket.openUploadStream(fileName, {
metadata: metaData,
contentType: contentType,
......@@ -120,18 +120,18 @@ Meteor.methods({
});
}
catch (ex) {
LOGGER.error('[uploadFile]', ex);
LOGGER.error('[uploadFile]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
},
getFile(bucketName, fileId) {
LOGGER.info('[getFile]', bucketName, fileId);
getFile(bucketName, fileId, sessionId) {
LOGGER.info('[getFile]', bucketName, fileId, sessionId);
let result = Async.runSync(function (done) {
try {
let filesCollection = database.collection(bucketName + '.files');
let filesCollection = databasesBySessionId[sessionId].collection(bucketName + '.files');
filesCollection.find({_id: new mongodbApi.ObjectId(fileId)}).limit(1).next(function (err, doc) {
if (doc) {
done(null, doc);
......@@ -141,7 +141,7 @@ Meteor.methods({
});
}
catch (ex) {
LOGGER.error('[getFile]', ex);
LOGGER.error('[getFile]', sessionId, ex);
done(new Meteor.Error(ex.message), null);
}
});
......
/**
* Created by RSercan on 10.1.2016.
*/
import {Meteor} from 'meteor/meteor';
import {Actions} from '/lib/imports/collections/actions';
import {Meteor} from "meteor/meteor";
import {Actions} from "/lib/imports/collections/actions";
import LOGGER from "../internal/logger";
const cheerio = require('cheerio');
......@@ -60,7 +60,7 @@ Meteor.methods({
let loadedUrl = load(url);
fixHrefs(url, loadedUrl);
return loadedUrl("dt[id='authr." + action + "']").parent('dl[class=authaction]').children('dd').html();
return loadedUrl("dt[id='" + action + "']").parent('dl[class=authaction]').children('dd').html();
},
getRoleInfo(roleName) {
......
/**
* Created by RSercan on 19.1.2016.
*/
import {Meteor} from 'meteor/meteor';
import {Connections} from '/lib/imports/collections/connections';
import {Actions} from '/lib/imports/collections/actions';
import {Dumps} from '/lib/imports/collections/dumps';
import {QueryHistory} from '/lib/imports/collections/query_history';
import {Settings} from '/lib/imports/collections/settings';
import ShellCommands from '/lib/imports/collections/shell';
import SchemaAnalyzeResult from '/lib/imports/collections/schema_analyze_result';
import {Meteor} from "meteor/meteor";
import {Connections} from "/lib/imports/collections/connections";
import {Actions} from "/lib/imports/collections/actions";
import {Dumps} from "/lib/imports/collections/dumps";
import {QueryHistory} from "/lib/imports/collections/query_history";
import {Settings} from "/lib/imports/collections/settings";
import ShellCommands from "/lib/imports/collections/shell";
import SchemaAnalyzeResult from "/lib/imports/collections/schema_analyze_result";
Meteor.publish('schema_analyze_result', function () {
return SchemaAnalyzeResult.find();
return SchemaAnalyzeResult.find({});
});
Meteor.publish('shell_commands', function () {
return ShellCommands.find();
return ShellCommands.find({});
});
Meteor.publish('connections', function () {
......
/**
* Created by Sercan on 26.10.2016.
*/
import {WebApp} from 'meteor/webapp';
import {Meteor} from 'meteor/meteor';
import {Papa} from 'meteor/harrison:papa-parse';
import {database} from "/server/imports/mongodb/methods_common";
import {WebApp} from "meteor/webapp";
import {Meteor} from "meteor/meteor";
import {Papa} from "meteor/harrison:papa-parse";
import {databasesBySessionId} from "/server/imports/mongodb/methods_common";
import LOGGER from "/server/imports/internal/logger";
const mongodbApi = require('mongodb');
......@@ -18,7 +18,7 @@ WebApp.connectHandlers.use('/export', function (req, res) {
LOGGER.info('[export]', format, selectedCollection, selector, cursorOptions);
Meteor.call("find", selectedCollection, JSON.parse(selector), JSON.parse(cursorOptions), false, function (err, result) {
Meteor.call("find", selectedCollection, JSON.parse(selector), JSON.parse(cursorOptions), false, Meteor.default_connection._lastSessionId, function (err, result) {
if (err || result.error) {
LOGGER.error('[export]', err, result.error);
res.writeHead(400);
......@@ -52,9 +52,11 @@ WebApp.connectHandlers.use("/download", function (req, res) {
const urlParts = decodeURI(req.url).split('&');
let fileId = urlParts[0].substr(urlParts[0].indexOf('=') + 1);
let bucketName = urlParts[1].substr(urlParts[1].indexOf('=') + 1);
let sessionId = urlParts[2].substr(urlParts[2].indexOf('=') + 1);
LOGGER.info('[downloadFile]', fileId, bucketName);
LOGGER.info('[downloadFile]', fileId, bucketName, sessionId);
res.charset = 'UTF-8';
if (!bucketName || !fileId) {
LOGGER.info('[downloadFile]', 'file not found !');
res.writeHead(400);
......@@ -63,15 +65,15 @@ WebApp.connectHandlers.use("/download", function (req, res) {
}
try {
let filesCollection = database.collection(bucketName + '.files');
let filesCollection = databasesBySessionId[sessionId].collection(bucketName + '.files');
filesCollection.find({_id: new mongodbApi.ObjectId(fileId)}).limit(1).next(function (err, doc) {
if (doc) {
const bucket = new mongodbApi.GridFSBucket(database, {bucketName: bucketName});
const bucket = new mongodbApi.GridFSBucket(databasesBySessionId[sessionId], {bucketName: bucketName});
const headers = {
'Content-type': 'application/octet-stream',
'Content-Disposition': 'attachment; filename=' + doc.filename
'Content-Disposition': 'attachment; filename=' + encodeURIComponent(doc.filename)
};
LOGGER.info('[downloadFile]', 'file found and started downloading...');
LOGGER.info('[downloadFile]', 'file found and started downloading...', headers);
const downloadStream = bucket.openDownloadStream(new mongodbApi.ObjectID(fileId));
res.writeHead(200, headers);
const pipeStream = downloadStream.pipe(res);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册