diff --git a/client/imports/helper.js b/client/imports/helper.js index 298f71d4876f6a83e568096127f007708cacaee9..38fc8197785a073f7cd6add809b1a949193cdb20 100644 --- a/client/imports/helper.js +++ b/client/imports/helper.js @@ -84,12 +84,14 @@ let Helper = function () { this.strSessionServerStatus = "serverStatus"; this.strSessionDBStats = "dbStats"; this.strSessionUsedTabIDs = "usedTabIDs"; + this.strSessionUsedTabIDsAggregate = "usedTabIDsAggregate"; this.strSessionSelectedDump = "selectedDump"; this.strSessionSelectedFile = "selectedFile"; this.strSessionSelectedStoredFunction = "selectedStoredFunction"; this.strSessionDistinctFields = "distinctFields"; this.strSessionSelectedQueryHistory = "selectedQueryHistory"; this.strSessionSelectedShellHistory = "selectedShellHistory"; + this.strSessionSelectedAggregateHistory = "selectedAggregateHistory"; this.strSessionSelectorValue = "selectorValue"; this.strSessionSelectionUserManagement = "userManagementValue"; this.strSessionUsermanagementInfo = "userManagementInfo"; diff --git a/client/imports/views/pages/aggregate_pipeline/aggregate_histories/aggregate_histories.html b/client/imports/views/pages/aggregate_pipeline/aggregate_histories/aggregate_histories.html new file mode 100644 index 0000000000000000000000000000000000000000..dcdde9b1169f67259282b1fb52c1abe7e9044455 --- /dev/null +++ b/client/imports/views/pages/aggregate_pipeline/aggregate_histories/aggregate_histories.html @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/client/imports/views/pages/aggregate_pipeline/aggregate_histories/aggregate_histories.js b/client/imports/views/pages/aggregate_pipeline/aggregate_histories/aggregate_histories.js new file mode 100644 index 0000000000000000000000000000000000000000..6e3aa7b9cad4e0165c74a290f4e9d36d1f93e692 --- /dev/null +++ b/client/imports/views/pages/aggregate_pipeline/aggregate_histories/aggregate_histories.js @@ -0,0 +1,84 @@ +import {Template} from "meteor/templating"; +import {Session} from "meteor/session"; +import {FlowRouter} from "meteor/kadira:flow-router"; +import {renderQuery} from "../aggregate_pipeline"; +import Helper from "/client/imports/helper"; +import Enums from "/lib/imports/enums"; +import "./aggregate_histories.html"; + +const Ladda = require('ladda'); + +/** + * Created by RSercan on 24.2.2016. + */ +/*global moment*/ +Template.aggregateHistories.onRendered(function () { + if (Session.get(Helper.strSessionCollectionNames) == undefined) { + FlowRouter.go('/databaseStats'); + return; + } + + const selector = $('#tblAggregateHistories'); + selector.find('tbody').on('click', 'tr', function () { + const table = selector.DataTable(); + Helper.doTableRowSelectable(table, $(this)); + + if (table.row(this).data()) { + Session.set(Helper.strSessionSelectedAggregateHistory, table.row(this).data()); + $('#btnUseHistoricalPipeline').prop('disabled', false); + } + }); +}); + +Template.aggregateHistories.events({ + 'click #btnUseHistoricalPipeline' (e) { + e.preventDefault(); + const history = Session.get(Helper.strSessionSelectedAggregateHistory); + if (history) renderQuery({queryInfo: history.collection, queryParams: history.pipeline}); + } +}); + +export const initAggregateHistories = function () { + Ladda.create(document.querySelector('#btnUseHistoricalPipeline')).start(); + + const tbl = $('#tblAggregateHistories'); + + // destroy jquery datatable to prevent reinitialization (https://datatables.net/manual/tech-notes/3) + if ($.fn.dataTable.isDataTable('#tblAggregateHistories')) { + tbl.DataTable().destroy(); + } + + const history = JSON.parse(localStorage.getItem(Enums.LOCAL_STORAGE_KEYS.AGGREGATE_COMMAND_HISTORY) || "[]"); + tbl.DataTable({ + responsive: true, + lengthMenu: [5, 10, 20], + data: history, + autoWidth: false, + columns: [ + { + data: "collection", + width: "20%" + }, + { + data: "pipeline", + width: "60%", + render: function (cellData) { + let str = ""; + for (let stage of cellData) { + str += Object.keys(stage)[0] + "
"; + } + return str; + } + }, + { + data: "date", + width: "20%", + render: function (cellData) { + return moment(cellData).format('YYYY-MM-DD HH:mm:ss'); + } + } + ] + }); + + Ladda.stopAll(); +}; \ No newline at end of file diff --git a/client/imports/views/pages/aggregate_pipeline/aggregate_pipeline.html b/client/imports/views/pages/aggregate_pipeline/aggregate_pipeline.html index 861550ee17f3c750147394048a82327ad8b7a961..34c0ec639689bc331ef632c77a0a1daa46f641c1 100644 --- a/client/imports/views/pages/aggregate_pipeline/aggregate_pipeline.html +++ b/client/imports/views/pages/aggregate_pipeline/aggregate_pipeline.html @@ -9,6 +9,11 @@
Drag stages between list to re-order
+
-