Skip to content

Commit

Permalink
Improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Nov 27, 2019
1 parent 2ff88db commit d466df1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import { getAngularModule, wrapInI18nContext, getServices } from '../kibana_serv
import { getRootBreadcrumbs } from '../helpers/breadcrumbs';
import html from './doc.html';
import { Doc } from '../components/doc/doc';

interface LazyScope extends ng.IScope {
[key: string]: any;
}

const { timefilter } = getServices();
const app = getAngularModule();
app.directive('discoverDoc', function(reactDirective: any) {
Expand All @@ -44,7 +49,7 @@ app.config(($routeProvider: any) => {
})
// the new route, es 7 deprecated types, es 8 removed them
.when('/discover/doc/:indexPattern/:index', {
controller: ($scope: any, $route: any, es: any) => {
controller: ($scope: LazyScope, $route: any, es: any) => {
timefilter.disableAutoRefreshSelector();
timefilter.disableTimeRangeSelector();
$scope.esClient = es;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function createTableRowDirective(
$el.empty();

// when we compile the details, we use this $scope
let $detailsScope: any;
let $detailsScope: LazyScope;

// when we compile the toggle button in the summary, we use this $scope
let $toggleScope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import _ from 'lodash';
import { UiSettingsClient } from 'kibana/public';
import html from './doc_table.html';
import './infinite_scroll';
import './components/table_header';
Expand All @@ -28,8 +29,12 @@ import './lib/pager';
// @ts-ignore
import { getLimitedSearchResultsMessage } from './doc_table_strings';

interface LazyScope extends ng.IScope {
[key: string]: any;
}

export function createDocTableDirective(
config: any,
config: UiSettingsClient,
getAppState: any,
pagerFactory: any,
$filter: any
Expand All @@ -54,7 +59,7 @@ export function createDocTableDirective(
onRemoveColumn: '=?',
inspectorAdapters: '=?',
},
link: ($scope: any, $el: any) => {
link: ($scope: LazyScope, $el: JQuery) => {
$scope.$watch('minimumVisibleRows', (minimumVisibleRows: number) => {
$scope.limit = Math.max(minimumVisibleRows || 50, $scope.limit || 50);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@

import $ from 'jquery';

interface LazyScope extends ng.IScope {
[key: string]: any;
}

export function createInfiniteScrollDirective() {
return {
restrict: 'E',
scope: {
more: '=',
},
link: ($scope: any, $element: any) => {
link: ($scope: LazyScope, $element: JQuery) => {
const $window = $(window);
let checkTimer: any;

Expand All @@ -34,7 +38,8 @@ export function createInfiniteScrollDirective() {

const winHeight = Number($window.height());
const winBottom = Number(winHeight) + Number($window.scrollTop());
const elTop = $element.offset().top;
const offset = $element.offset();
const elTop = offset ? offset.top : 0;
const remaining = elTop - winBottom;

if (remaining <= winHeight * 0.5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class SearchEmbeddable extends Embeddable<SearchInput, SearchOutput>
});
const inspectorRequest = this.inspectorAdaptors.requests.start(title, { description });
inspectorRequest.stats(getRequestInspectorStats(searchSource));
searchSource.getSearchRequestBody().then((body: any) => {
searchSource.getSearchRequestBody().then((body: Record<string, unknown>) => {
inspectorRequest.json(body);
});
this.searchScope.isLoading = true;
Expand Down

0 comments on commit d466df1

Please sign in to comment.