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

Merge pull request #97 from rsercano/#62

resolves #62 
/*! jQuery UI - v1.11.4 - 2015-05-11
* http://jqueryui.com
* Includes: core.css, draggable.css, resizable.css, selectable.css, sortable.css
* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-draggable-handle{-ms-touch-action:none;touch-action:none}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block;-ms-touch-action:none;touch-action:none}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable{-ms-touch-action:none;touch-action:none}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-sortable-handle{-ms-touch-action:none;touch-action:none}
\ No newline at end of file
此差异已折叠。
......@@ -20,7 +20,7 @@ tr.selected {
top: 0;
}
#btnManageRoles, #btnEditUser, #btnManageUsers {
#btnManageRoles, #btnEditUser, #btnManageUsers, #btnExecuteAggregatePipeline {
margin-bottom: 0 !important;
}
......@@ -30,4 +30,12 @@ tr.selected {
.chosen-container {
width: 100% !important;
}
#remove-stage-element {
margin-bottom: 5px;
}
.CodeMirror {
width: 100%;
}
\ No newline at end of file
......@@ -92,6 +92,13 @@
class="nav-label">Easy Edit</span>
</a>
</li>
<li class="{{isActiveRoute regex='aggregatePipeline'}}">
<a class="aNavigations" href="{{pathFor route='aggregatePipeline'}}"><i
class="fa fa-tasks"></i> <span
class="nav-label">Aggregate</span>
</a>
</li>
</ul>
</li>
......
......@@ -18,15 +18,7 @@ Template.adminQueries.onRendered(function () {
});
cmb.chosen();
$('#aConvertIsoDates').iCheck({
checkboxClass: 'icheckbox_square-green'
});
$('#aConvertObjectIds').iCheck({
checkboxClass: 'icheckbox_square-green'
});
$('#aRunOnAdminDB').iCheck({
$('#aConvertIsoDates, #aConvertObjectIds, #aRunOnAdminDB').iCheck({
checkboxClass: 'icheckbox_square-green'
});
......
<template name="aggregatePipeline">
{{#if isConnected}}
{{> pageHeading title='Aggregate' }}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Aggregate
<small>Drag stages between list
</small>
</h5>
<div class="ibox-tools">
<button id="btnExecuteAggregatePipeline" type="button"
class="btn btn-sm btn-primary ladda-button" data-style="contract">
Execute
</button>
<a id="aConvertIsoDates" class="i-checks"
style="display: none;"
data-toggle="tooltip"
title="Enable/Disable YYYY-MM-DD HH:MM:ss formatted strings to ISODate conversion">
<input id="inputConvertIsoDates" type="checkbox" value=""
class="form-control"
checked=""
style="position: absolute; opacity: 0;"/>
</a>
<a id="aConvertObjectIds" class="i-checks"
style="display: none;"
data-toggle="tooltip"
title="Enable/Disable valid ObjectID strings to ObjectID conversion">
<input id="inputConvertObjectIDs" type="checkbox" value=""
class="form-control"
checked=""
style="position: absolute; opacity: 0;"/>
</a>
</div>
</div>
<div class="ibox-content">
<form class="form-horizontal">
<div class="form-group">
<label class="col-lg-1 control-label">Collection</label>
<div class="col-lg-11">
<select id="cmbCollections"
data-placeholder="Choose a collection..."
class="chosen-select form-control"
tabindex="-1">
<option></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-1 control-label">Pick a Stage</label>
<div class="col-lg-11">
<select id="cmbStageQueries"
data-placeholder="Choose a stage query.."
class="chosen-select form-control"
tabindex="-1">
<option></option>
<option>project</option>
<option>match</option>
<option>redact</option>
<option>limit</option>
<option>skip</option>
<option>unwind</option>
<option>group</option>
<option>sample</option>
<option>sort</option>
<option>geoNear</option>
<option>lookup</option>
<option>out</option>
<option>indexStats</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-1 control-label">Pipeline</label>
<ul class="sortable-list agile-list col-lg-11" id="stages">
</ul>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{{> aggregateResultModal}}
{{/if}}
</template>
\ No newline at end of file
/**
* Created by RSercan on 14.5.2016.
*/
var stageNumbers;
Template.aggregatePipeline.onRendered(function () {
if (Session.get(Template.strSessionCollectionNames) == undefined) {
Router.go('databaseStats');
return;
}
$("#stages").sortable({
connectWith: ".connectList"
});
$('#cmbStageQueries').chosen();
$('#aConvertIsoDates, #aConvertObjectIds').iCheck({
checkboxClass: 'icheckbox_square-green'
});
stageNumbers = 0;
Template.changeConvertOptionsVisibility(true);
Template.aggregatePipeline.initializeCollectionsCombobox();
});
Template.aggregatePipeline.events({
'click #btnExecuteAggregatePipeline': function (e) {
e.preventDefault();
var selectedCollection = $("#cmbCollections").chosen().val();
var stages = $('#stages').find('li');
if (!selectedCollection) {
toastr.warning('Please select a collection first !');
return;
}
if (stages.length == 0) {
toastr.warning('At least one stage is required !');
return;
}
var l = $('#btnExecuteAggregatePipeline').ladda();
l.ladda('start');
var pipeline;
try {
pipeline = Template.aggregatePipeline.createPipeline(stages);
}
catch (e) {
toastr.error('One of the stages has error, stage name: ' + e.message);
Ladda.stopAll();
return;
}
var convertIds = $('#aConvertObjectIds').iCheck('update')[0].checked;
var convertDates = $('#aConvertIsoDates').iCheck('update')[0].checked;
Meteor.call("aggregate", selectedCollection, pipeline, convertIds, convertDates,
function (err, result) {
if (err || result.error) {
Template.showMeteorFuncError(err, result, "Couldn't execute ");
}
else {
Template.aggregateResultModal.setResult(result.result);
$('#aggregateResultModal').modal('show');
}
Ladda.stopAll();
}
);
},
'change #cmbStageQueries': function (e) {
var cmb = $("#cmbStageQueries");
var query = cmb.chosen().val();
if (query) {
query = '$' + query;
var liElement = '<li class="success-element" id="stage' + stageNumbers + '">' + query + '<div id="wrapper' + stageNumbers + '" class="agile-detail">' +
'<a id="remove-stage-element" href="#" data-number="' + stageNumbers + '" class="pull-right btn btn-xs btn-white"><i class="fa fa-remove"></i> Remove</a>';
var initCodeMirror;
switch (query) {
case '$limit':
liElement += '<input id="inputNumberStage' + stageNumbers + '" min="0" type="number" class="form-control">';
break;
case '$skip':
liElement += '<input id="inputNumberStage' + stageNumbers + '" min="0" type="number" class="form-control">';
break;
case '$out':
liElement += '<input type="text" class="form-control" id="txtStringStage' + stageNumbers + '"/>';
break;
default:
initCodeMirror = true;
liElement += '<textarea id="txtObjectStage' + stageNumbers + '" class="form-control"></textarea>';
break;
}
liElement += '</div> </li>';
$('#stages').append(liElement);
if (initCodeMirror) {
Template.aggregatePipeline.initCodeMirrorStage();
}
Session.set(Template.strSessionAggregateStageName, query);
cmb.val('').trigger('chosen:updated');
stageNumbers++;
}
},
'click #remove-stage-element': function (e) {
e.preventDefault();
var stageId = '#stage' + $(e.target).data('number');
$(stageId).remove();
}
});
Template.aggregatePipeline.initializeCollectionsCombobox = function () {
var cmb = $('#cmbCollections');
cmb.append($("<optgroup id='optGroupCollections' label='Collections'></optgroup>"));
var cmbOptGroupCollection = cmb.find('#optGroupCollections');
var collectionNames = Session.get(Template.strSessionCollectionNames);
$.each(collectionNames, function (index, value) {
cmbOptGroupCollection.append($("<option></option>")
.attr("value", value.name)
.text(value.name));
});
cmb.chosen();
cmb.on('change', function (evt, params) {
var selectedCollection = params.selected;
if (selectedCollection) {
Template.getDistinctKeysForAutoComplete(selectedCollection);
}
});
};
Template.aggregatePipeline.initCodeMirrorStage = function () {
var divSelector = $('#wrapper' + stageNumbers);
if (!divSelector.data('editor')) {
var codeMirror = CodeMirror.fromTextArea(document.getElementById('txtObjectStage' + stageNumbers), {
mode: "javascript",
theme: "neat",
styleActiveLine: true,
lineNumbers: true,
lineWrapping: false,
extraKeys: {
"Ctrl-Q": function (cm) {
cm.foldCode(cm.getCursor());
},
"Ctrl-Space": "autocomplete"
},
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
});
codeMirror.setSize('%100', 100);
divSelector.data('editor', codeMirror);
}
};
Template.aggregatePipeline.createPipeline = function (stageListElements) {
var pipeline = [];
stageListElements.each(function (index) {
var stage = {};
var liElement = $(this);
var queryName = liElement.text().split(' ')[0].trim();
if (liElement.find('[id^=inputNumberStage]').length != 0) {
stage[queryName] = parseInt(liElement.find('[id^=inputNumberStage]').val());
} else if (liElement.find('[id^=wrapper]').data('editor')) {
var jsonValue = liElement.find('[id^=wrapper]').data('editor').getValue();
jsonValue = Template.convertAndCheckJSON(jsonValue);
if (jsonValue["ERROR"]) {
throw queryName + " error: " + jsonValue["ERROR"];
}
stage[queryName] = jsonValue;
}
else if (liElement.find('[id^=txtStringStage]').length != 0) {
stage[queryName] = liElement.find('[id^=txtStringStage]').val();
} else {
throw queryName;
}
pipeline.push(stage);
});
return pipeline;
};
\ No newline at end of file
<template name="aggregateResultModal">
<div class="modal inmodal" id="aggregateResultModal" tabindex="-1" role="dialog" aria-hidden="true"
style="display: none;">
<div class="modal-dialog modal-lg">
<div class="modal-content animated bounceInRight">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
class="sr-only">Close</span></button>
<h4 class="modal-title">Aggregation Result</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div id="divJsonEditorWrapper" class="form-group">
<div id="divJsonEditor" style="width: 100%;height:500px" class="col-lg-12">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white btn-block" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</template>
\ No newline at end of file
/**
* Created by RSercan on 19.5.2016.
*/
Template.aggregateResultModal.onRendered(function () {
var jsonEditor = new JSONEditor(document.getElementById('divJsonEditor'), {
mode: 'tree',
modes: ['code', 'form', 'text', 'tree', 'view'],
search: true
});
$('#divJsonEditorWrapper').data('jsoneditor', jsonEditor);
});
Template.aggregateResultModal.setResult = function (value) {
$('#divJsonEditorWrapper').data('jsoneditor').set(value);
};
\ No newline at end of file
......@@ -30,11 +30,7 @@ Template.browseCollection.onRendered(function () {
Template.queryHistories.initQueryHistories();
});
$('#aConvertIsoDates').iCheck({
checkboxClass: 'icheckbox_square-green'
});
$('#aConvertObjectIds').iCheck({
$('#aConvertIsoDates, #aConvertObjectIds').iCheck({
checkboxClass: 'icheckbox_square-green'
});
......
......@@ -10,11 +10,7 @@ Template.editDocument.onRendered(function () {
Template.editDocument.initializeCollectionsCombobox();
Session.set(Template.strSessionEasyEditID, undefined);
$('#aConvertIsoDates').iCheck({
checkboxClass: 'icheckbox_square-green'
});
$('#aConvertObjectIds').iCheck({
$('#aConvertIsoDates, #aConvertObjectIds').iCheck({
checkboxClass: 'icheckbox_square-green'
});
......
......@@ -2,16 +2,11 @@
* Created by RSercan on 9.1.2016.
*/
Template.settings.onRendered(function () {
$('#divAutoCompleteFields').iCheck({
$('#divAutoCompleteFields, #divShowDBStats').iCheck({
checkboxClass: 'icheckbox_square-green'
});
$('#divShowDBStats').iCheck({
checkboxClass: 'icheckbox_square-green'
});
$('#cmbScale').chosen();
$('#cmbResultView').chosen();
$('#cmbScale, #cmbResultView').chosen();
Template.settings.load();
});
......
/**
* Created by sercan on 16.02.2016.
*/
Router.route('/aggregatePipeline', {
waitOn: function () {
return [Meteor.subscribe('settings'), Meteor.subscribe('connections')];
}
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册