提交 4009be27 编写于 作者: R rsercano

resolves #355

上级 0ace9c77
...@@ -124,7 +124,8 @@ ...@@ -124,7 +124,8 @@
</li> </li>
<li class="{{isActivePath regex='schemaAnalyzer'}}"> <li class="{{isActivePath regex='schemaAnalyzer'}}">
<a class="aNavigations" href="{{pathFor route='schemaAnalyzer'}}"><i <a id="anchorSchemaAnalyzer" class="aNavigations"
href="{{pathFor route='schemaAnalyzer'}}"><i
class="fa fa-braille"></i> <span class="fa fa-braille"></i> <span
class="nav-label">Schema Analyzer</span> class="nav-label">Schema Analyzer</span>
</a> </a>
......
...@@ -6,6 +6,7 @@ import {Session} from "meteor/session"; ...@@ -6,6 +6,7 @@ import {Session} from "meteor/session";
import {FlowRouter} from "meteor/kadira:flow-router"; import {FlowRouter} from "meteor/kadira:flow-router";
import {Connections} from "/lib/imports/collections/connections"; import {Connections} from "/lib/imports/collections/connections";
import Helper from "/client/imports/helper"; import Helper from "/client/imports/helper";
import Enums from "/lib/imports/enums";
import {connect} from "/client/imports/views/layouts/top_navbar/connections/connections"; import {connect} from "/client/imports/views/layouts/top_navbar/connections/connections";
import {initializeForm, resetForm} 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 resetCappedForm} from "./convert_capped_collection/convert_to_capped";
...@@ -120,6 +121,23 @@ export const renderCollectionNames = function () { ...@@ -120,6 +121,23 @@ export const renderCollectionNames = function () {
}); });
}; };
const showMongoBinaryInfo = function () {
if (!localStorage.getItem(Enums.LOCAL_STORAGE_KEYS.MONGO_BINARY_INFO)) {
swal({
title: "Mongo Binary",
text: "Mongo executable to be used on shell and schema analyzer is configurable, you can change it from <b>Settings</b>",
type: "info",
html: true,
confirmButtonColor: "#18A689",
confirmButtonText: "Cool, don't show again!"
}, function (isConfirm) {
if (isConfirm) {
localStorage.setItem(Enums.LOCAL_STORAGE_KEYS.MONGO_BINARY_INFO, "true");
}
});
}
};
Template.navigation.events({ Template.navigation.events({
'click #anchorShell'(e) { 'click #anchorShell'(e) {
e.preventDefault(); e.preventDefault();
...@@ -131,6 +149,11 @@ Template.navigation.events({ ...@@ -131,6 +149,11 @@ Template.navigation.events({
} }
FlowRouter.go('/shell'); FlowRouter.go('/shell');
showMongoBinaryInfo();
},
'click #anchorSchemaAnalyzer'() {
showMongoBinaryInfo();
}, },
'click #anchorDatabaseDumpRestore'(e) { 'click #anchorDatabaseDumpRestore'(e) {
......
...@@ -160,8 +160,8 @@ const initializeCommandCodeMirror = function () { ...@@ -160,8 +160,8 @@ const initializeCommandCodeMirror = function () {
let regex = new RegExp('^' + curWord, 'i'); let regex = new RegExp('^' + curWord, 'i');
return { return {
list: (!curWord ? list : list.filter(function (item) { list: (!curWord ? list : list.filter(function (item) {
return item.match(regex); return item.match(regex);
})), })),
from: CodeMirror.Pos(cursor.line, start), from: CodeMirror.Pos(cursor.line, start),
to: CodeMirror.Pos(cursor.line, end) to: CodeMirror.Pos(cursor.line, end)
}; };
......
...@@ -167,6 +167,17 @@ ...@@ -167,6 +167,17 @@
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-lg-3 control-label">Mongo executable path</label>
<div class="col-lg-9">
<input id="inputMongoExecutable" required="true" type="file"
class="form-control filestyle">
<span class="help-block m-b-none">
<b>By default</b> Mongoclient uses an internal <b>Mongo</b> binary regarding to your OS, you can assign another binary with this setting
</span>
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="col-lg-12"> <div class="col-lg-12">
<button id="btnSaveSettings" <button id="btnSaveSettings"
......
import {Template} from "meteor/templating"; import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {Settings} from "/lib/imports/collections/settings"; import {Settings} from "/lib/imports/collections/settings";
import {loadFile} from "/client/imports/views/layouts/top_navbar/top_navbar";
import "./settings.html"; import "./settings.html";
const toastr = require('toastr'); const toastr = require('toastr');
...@@ -9,7 +9,7 @@ const Ladda = require('ladda'); ...@@ -9,7 +9,7 @@ const Ladda = require('ladda');
* Created by RSercan on 9.1.2016. * Created by RSercan on 9.1.2016.
*/ */
const getSettingsFromForm = function () { const proceedSavingSettings = function (mongoBinary) {
const settings = {}; const settings = {};
settings.autoCompleteFields = $('#divAutoCompleteFields').iCheck('update')[0].checked; settings.autoCompleteFields = $('#divAutoCompleteFields').iCheck('update')[0].checked;
settings.scale = $("#cmbScale").chosen().val(); settings.scale = $("#cmbScale").chosen().val();
...@@ -21,15 +21,21 @@ const getSettingsFromForm = function () { ...@@ -21,15 +21,21 @@ const getSettingsFromForm = function () {
settings.showDBStats = $('#divShowDBStats').iCheck('update')[0].checked; settings.showDBStats = $('#divShowDBStats').iCheck('update')[0].checked;
settings.showLiveChat = $('#divShowLiveChat').iCheck('update')[0].checked; settings.showLiveChat = $('#divShowLiveChat').iCheck('update')[0].checked;
settings.dumpPath = $('#inputDumpPath').val(); settings.dumpPath = $('#inputDumpPath').val();
settings.mongoBinaryName = $('#inputMongoExecutable').siblings('.bootstrap-filestyle').children('input').val() || 'mongo';
settings.singleTabResultSets = $('#divUseSingleTab').iCheck('update')[0].checked; settings.singleTabResultSets = $('#divUseSingleTab').iCheck('update')[0].checked;
return settings;
Meteor.call('updateSettings', settings, mongoBinary, function (err) {
if (err) this.showMeteorFuncError(err, null, "Couldn't save");
else toastr.success('Successfuly saved !');
Ladda.stopAll();
});
}; };
Template.settings.onRendered(function () { Template.settings.onRendered(function () {
$('#divAutoCompleteFields, #divShowDBStats, #divShowLiveChat, #divUseSingleTab').iCheck({ $('#divAutoCompleteFields, #divShowDBStats, #divShowLiveChat, #divUseSingleTab').iCheck({
checkboxClass: 'icheckbox_square-green' checkboxClass: 'icheckbox_square-green'
}); });
$('.filestyle').filestyle({});
$('#cmbScale, #cmbResultView').chosen(); $('#cmbScale, #cmbResultView').chosen();
let settings = this.subscribe('settings'); let settings = this.subscribe('settings');
...@@ -47,12 +53,7 @@ Template.settings.events({ ...@@ -47,12 +53,7 @@ Template.settings.events({
e.preventDefault(); e.preventDefault();
Ladda.create(document.querySelector('#btnSaveSettings')).start(); Ladda.create(document.querySelector('#btnSaveSettings')).start();
loadFile(Settings.findOne().mongoBinary, $('#inputMongoExecutable'), proceedSavingSettings);
Meteor.call('updateSettings', getSettingsFromForm());
toastr.success('Successfuly saved !');
Ladda.stopAll();
} }
}); });
...@@ -61,15 +62,6 @@ const load = function () { ...@@ -61,15 +62,6 @@ const load = function () {
const settings = Settings.findOne(); const settings = Settings.findOne();
const cmbScale = $('#cmbScale'); const cmbScale = $('#cmbScale');
const cmbResultView = $('#cmbResultView'); const cmbResultView = $('#cmbResultView');
const inputMaxAllowedFetchSize = $('#inputMaxAllowedFetchSize');
const inputSocketTimeout = $('#inputSocketTimeout');
const inputConnectionTimeout = $('#inputConnectionTimeout');
const inputDBStatsScheduler = $('#inputDBStatsScheduler');
const inputAutoCompleteFields = $('#inputAutoCompleteFields');
const inputShowLiveChat = $('#inputShowLiveChat');
const inputShowDBStats = $('#inputShowDBStats');
const inputDumpPath = $('#inputDumpPath');
const inputUseSingleTab = $('#inputUseSingleTab');
cmbScale.val(settings.scale); cmbScale.val(settings.scale);
cmbScale.trigger("chosen:updated"); cmbScale.trigger("chosen:updated");
...@@ -77,30 +69,15 @@ const load = function () { ...@@ -77,30 +69,15 @@ const load = function () {
cmbResultView.val(settings.defaultResultView); cmbResultView.val(settings.defaultResultView);
cmbResultView.trigger("chosen:updated"); cmbResultView.trigger("chosen:updated");
if (settings.dumpPath) inputDumpPath.val(settings.dumpPath); $('#inputDumpPath').val(settings.dumpPath || '');
$('#inputMaxAllowedFetchSize').val(settings.maxAllowedFetchSize || 0);
if (settings.maxAllowedFetchSize) inputMaxAllowedFetchSize.val(settings.maxAllowedFetchSize); $('#inputSocketTimeout').val(settings.socketTimeoutInSeconds || 0);
else inputMaxAllowedFetchSize.val(0); $('#inputConnectionTimeout').val(settings.connectionTimeoutInSeconds || 0);
$('#inputDBStatsScheduler').val(settings.dbStatsScheduler || 3000);
if (settings.socketTimeoutInSeconds) inputSocketTimeout.val(settings.socketTimeoutInSeconds); $('#inputAutoCompleteFields').iCheck(settings.autoCompleteFields ? 'check' : 'uncheck');
else inputSocketTimeout.val(0); $('#inputShowLiveChat').iCheck(settings.showLiveChat ? 'check' : 'uncheck');
$('#inputUseSingleTab').iCheck(settings.singleTabResultSets ? 'check' : 'uncheck');
if (settings.connectionTimeoutInSeconds) inputConnectionTimeout.val(settings.connectionTimeoutInSeconds); $('#inputShowDBStats').iCheck(settings.showDBStats ? 'check' : 'uncheck');
else inputConnectionTimeout.val(0); $('#inputMongoExecutable').siblings('.bootstrap-filestyle').children('input').val(settings.mongoBinaryName || 'mongo');
if (settings.dbStatsScheduler) inputDBStatsScheduler.val(settings.dbStatsScheduler);
else inputDBStatsScheduler.val(3000);
if (settings.autoCompleteFields) inputAutoCompleteFields.iCheck('check');
else inputAutoCompleteFields.iCheck('uncheck');
if (settings.showLiveChat) inputShowLiveChat.iCheck('check');
else inputShowLiveChat.iCheck('uncheck');
if (settings.singleTabResultSets) inputUseSingleTab.iCheck('check');
else inputUseSingleTab.iCheck('uncheck');
if (settings.showDBStats) inputShowDBStats.iCheck('check');
else inputShowDBStats.iCheck('uncheck');
}; };
\ No newline at end of file
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
* Created by RSercan on 29.12.2015. * Created by RSercan on 29.12.2015.
*/ */
let Enums = function () { let Enums = function () {
this.LOCAL_STORAGE_KEYS = {
MONGO_BINARY_INFO: 'mongoclient-mongo-binary-warn'
};
this.QUERY_TYPES = { this.QUERY_TYPES = {
BULK_WRITE: "bulkWrite", BULK_WRITE: "bulkWrite",
FIND: "find", FIND: "find",
......
...@@ -12,7 +12,7 @@ import SchemaAnalyzeResult from "/lib/imports/collections/schema_analyze_result" ...@@ -12,7 +12,7 @@ import SchemaAnalyzeResult from "/lib/imports/collections/schema_analyze_result"
import {HTTP} from "meteor/http"; import {HTTP} from "meteor/http";
import LOGGER from "../internal/logger"; import LOGGER from "../internal/logger";
const fs = require('fs');
const packageJson = require('/package.json'); const packageJson = require('/package.json');
const mongodbUrlParser = require('parse-mongo-url'); const mongodbUrlParser = require('parse-mongo-url');
...@@ -186,10 +186,23 @@ Meteor.methods({ ...@@ -186,10 +186,23 @@ Meteor.methods({
Dumps.insert(dump); Dumps.insert(dump);
}, },
updateSettings(settings) { updateSettings(settings, mongoBinary) {
LOGGER.info('[updateSettings]', JSON.stringify(settings)); try {
Settings.remove({}); LOGGER.info('[updateSettings]', JSON.stringify(settings));
Settings.insert(settings);
if (mongoBinary) {
let currentDir = process.cwd().replace(/\\/g, '/');
currentDir = currentDir.substring(0, currentDir.lastIndexOf("/")) + '/web.browser/app/mongo/';
fs.chmodSync(currentDir, '777');
fs.writeFileSync(currentDir + "user_mongo", new Buffer(mongoBinary), {mode: '777'});
}
Settings.remove({});
Settings.insert(settings);
}
catch (ex) {
LOGGER.error('[updateSettings]', ex);
throw new Meteor.Error(ex.message);
}
}, },
saveConnection(connection) { saveConnection(connection) {
......
...@@ -82,6 +82,10 @@ const getMongoExternalsPath = function () { ...@@ -82,6 +82,10 @@ const getMongoExternalsPath = function () {
const getProperMongo = function () { const getProperMongo = function () {
let currentDir = getMongoExternalsPath(); let currentDir = getMongoExternalsPath();
if (fs.existsSync(currentDir + "user_mongo")) {
LOGGER.info('[userMongo]', 'found a mongo binary set by user, choosing it');
return currentDir + "user_mongo";
}
switch (os.platform()) { switch (os.platform()) {
case 'darwin': case 'darwin':
return currentDir + 'darwin/mongo'; return currentDir + 'darwin/mongo';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册