Skip to content

Commit

Permalink
Use const/let in table_vis plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
epixa committed Feb 2, 2016
1 parent 78cb6aa commit 44700a6
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 deletions.
38 changes: 19 additions & 19 deletions src/plugins/table_vis/public/__tests__/_table_vis.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
describe('Integration', function () {
var $ = require('jquery');
var _ = require('lodash');
var expect = require('expect.js');
var ngMock = require('ngMock');
var sinon = require('auto-release-sinon');

var $rootScope;
var TableGroup;
var $compile;
var $scope;
var $el;
var Vis;
var indexPattern;
var fixtures;
const $ = require('jquery');
const _ = require('lodash');
const expect = require('expect.js');
const ngMock = require('ngMock');
const sinon = require('auto-release-sinon');

let $rootScope;
let TableGroup;
let $compile;
let $scope;
let $el;
let Vis;
let indexPattern;
let fixtures;

beforeEach(ngMock.module('kibana', 'kibana/table_vis'));
beforeEach(ngMock.inject(function (Private, $injector) {
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('Integration', function () {
it('passes the table groups to the kbnAggTableGroup directive', function () {
init(new OneRangeVis(), fixtures.oneRangeBucket);

var $atg = $el.find('kbn-agg-table-group').first();
const $atg = $el.find('kbn-agg-table-group').first();
expect($atg.size()).to.be(1);
expect($atg.attr('group')).to.be('tableGroups');
expect($atg.isolateScope().group).to.be($atg.scope().tableGroups);
Expand All @@ -104,18 +104,18 @@ describe('Integration', function () {

expect($el.find('kbn-agg-table-group').size()).to.be(0);

var $err = $el.find('.table-vis-error');
const $err = $el.find('.table-vis-error');
expect($err.size()).to.be(1);
expect($err.text().trim()).to.be('No results found');
});

it('displays an error if the search hits, but didn\'t create any rows', function () {
var visParams = {
const visParams = {
showPartialRows: false,
metricsAtAllLevels: true
};

var resp = _.cloneDeep(fixtures.threeTermBuckets);
const resp = _.cloneDeep(fixtures.threeTermBuckets);
resp.aggregations.agg_2.buckets.forEach(function (extensionBucket) {
extensionBucket.agg_3.buckets.forEach(function (countryBucket) {
// clear all the machine os buckets
Expand All @@ -127,7 +127,7 @@ describe('Integration', function () {

expect($el.find('kbn-agg-table-group').size()).to.be(0);

var $err = $el.find('.table-vis-error');
const $err = $el.find('.table-vis-error');
expect($err.size()).to.be(1);
expect($err.text().trim()).to.be('No results found');
});
Expand Down
54 changes: 27 additions & 27 deletions src/plugins/table_vis/public/__tests__/_table_vis_controller.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
describe('Controller', function () {
var $ = require('jquery');
var _ = require('lodash');
var expect = require('expect.js');
var ngMock = require('ngMock');
var sinon = require('auto-release-sinon');

var $rootScope;
var TableGroup;
var $compile;
var Private;
var $scope;
var $el;
var Vis;
var fixtures;
const $ = require('jquery');
const _ = require('lodash');
const expect = require('expect.js');
const ngMock = require('ngMock');
const sinon = require('auto-release-sinon');

let $rootScope;
let TableGroup;
let $compile;
let Private;
let $scope;
let $el;
let Vis;
let fixtures;

beforeEach(ngMock.module('kibana', 'kibana/table_vis'));
beforeEach(ngMock.inject(function ($injector) {
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('Controller', function () {
initController(new OneRangeVis());

// modify the data to not have any buckets
var resp = _.cloneDeep(fixtures.oneRangeBucket);
const resp = _.cloneDeep(fixtures.oneRangeBucket);
resp.aggregations.agg_2.buckets = {};

attachEsResponseToScope(resp);
Expand All @@ -114,11 +114,11 @@ describe('Controller', function () {

it('passes partialRows:true to tabify based on the vis params', function () {
// spy on the tabify private module
var tabifyPm = require('ui/agg_response/tabify/tabify');
var spiedTabify = sinon.spy(Private(tabifyPm));
const tabifyPm = require('ui/agg_response/tabify/tabify');
const spiedTabify = sinon.spy(Private(tabifyPm));
Private.stub(tabifyPm, spiedTabify);

var vis = new OneRangeVis({ showPartialRows: true });
const vis = new OneRangeVis({ showPartialRows: true });
initController(vis);
attachEsResponseToScope(fixtures.oneRangeBucket);

Expand All @@ -128,11 +128,11 @@ describe('Controller', function () {

it('passes partialRows:false to tabify based on the vis params', function () {
// spy on the tabify private module
var tabifyPm = require('ui/agg_response/tabify/tabify');
var spiedTabify = sinon.spy(Private(tabifyPm));
const tabifyPm = require('ui/agg_response/tabify/tabify');
const spiedTabify = sinon.spy(Private(tabifyPm));
Private.stub(tabifyPm, spiedTabify);

var vis = new OneRangeVis({ showPartialRows: false });
const vis = new OneRangeVis({ showPartialRows: false });
initController(vis);
attachEsResponseToScope(fixtures.oneRangeBucket);

Expand All @@ -142,11 +142,11 @@ describe('Controller', function () {

it('passes partialRows:true to tabify based on the vis params', function () {
// spy on the tabify private module
var tabifyPm = require('ui/agg_response/tabify/tabify');
var spiedTabify = sinon.spy(Private(tabifyPm));
const tabifyPm = require('ui/agg_response/tabify/tabify');
const spiedTabify = sinon.spy(Private(tabifyPm));
Private.stub(tabifyPm, spiedTabify);

var vis = new OneRangeVis({ showPartialRows: true });
const vis = new OneRangeVis({ showPartialRows: true });
initController(vis);
attachEsResponseToScope(fixtures.oneRangeBucket);

Expand All @@ -156,11 +156,11 @@ describe('Controller', function () {

it('passes partialRows:false to tabify based on the vis params', function () {
// spy on the tabify private module
var tabifyPm = require('ui/agg_response/tabify/tabify');
var spiedTabify = sinon.spy(Private(tabifyPm));
const tabifyPm = require('ui/agg_response/tabify/tabify');
const spiedTabify = sinon.spy(Private(tabifyPm));
Private.stub(tabifyPm, spiedTabify);

var vis = new OneRangeVis({ showPartialRows: false });
const vis = new OneRangeVis({ showPartialRows: false });
initController(vis);
attachEsResponseToScope(fixtures.oneRangeBucket);

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/table_vis/public/table_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ define(function (require) {

// define the TableVisType
function TableVisTypeProvider(Private) {
var TemplateVisType = Private(require('ui/template_vis_type/TemplateVisType'));
var Schemas = Private(require('ui/Vis/Schemas'));
const TemplateVisType = Private(require('ui/template_vis_type/TemplateVisType'));
const Schemas = Private(require('ui/Vis/Schemas'));

// define the TableVisController which is used in the template
// by angular's ng-controller directive
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/table_vis/public/table_vis_controller.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
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']);
const 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'));
const tabifyAggResponse = Private(require('ui/agg_response/tabify/tabify'));

$scope.$watch('esResponse', function (resp, oldResp) {
var tableGroups = $scope.tableGroups = null;
var hasSomeRows = $scope.hasSomeRows = null;
let tableGroups = $scope.tableGroups = null;
let hasSomeRows = $scope.hasSomeRows = null;

if (resp) {
var vis = $scope.vis;
var params = vis.params;
const vis = $scope.vis;
const params = vis.params;

tableGroups = tabifyAggResponse(vis, resp, {
partialRows: params.showPartialRows,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/table_vis/public/table_vis_params.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
var _ = require('lodash');
const _ = require('lodash');

require('ui/modules').get('kibana/table_vis')
.directive('tableVisParams', function () {
Expand All @@ -13,7 +13,7 @@ define(function (require) {
], function () {
if (!$scope.vis) return;

var params = $scope.vis.params;
const params = $scope.vis.params;
if (params.showPartialRows || params.showMeticsAtAllLevels) {
$scope.metricsAtAllLevels = true;
} else {
Expand Down

0 comments on commit 44700a6

Please sign in to comment.