UNPKG

@spalger/kibana

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

40 lines (31 loc) 1.32 kB
define(function (require) { // get the kibana/table_vis module, and make sure that it requires the "kibana" module if it // didn't already var module = require('ui/modules').get('kibana/table_vis', ['kibana']); // add a controller to tha module, which will transform the esResponse into a // tabular format that we can pass to the table directive module.controller('KbnTableVisController', function ($scope, Private) { var tabifyAggResponse = Private(require('ui/agg_response/tabify/tabify')); $scope.$watch('esResponse', function (resp, oldResp) { var tableGroups = $scope.tableGroups = null; var hasSomeRows = $scope.hasSomeRows = null; if (resp) { var vis = $scope.vis; var params = vis.params; tableGroups = tabifyAggResponse(vis, resp, { partialRows: params.showPartialRows, minimalColumns: vis.isHierarchical() && !params.showMeticsAtAllLevels, asAggConfigResults: true }); hasSomeRows = tableGroups.tables.some(function haveRows(table) { if (table.tables) return table.tables.some(haveRows); return table.rows.length > 0; }); } $scope.hasSomeRows = hasSomeRows; if (hasSomeRows) { $scope.tableGroups = tableGroups; } }); }); });