`;
-
-const moduleName = 'app/timelion';
-
-const thirdPartyAngularDependencies = ['ngSanitize', 'ngRoute', 'react', 'angular-sortable-view'];
-
-function mountTimelionApp(appBasePath: string, element: HTMLElement, deps: RenderDeps) {
- const mountpoint = document.createElement('div');
- mountpoint.setAttribute('class', 'timelionAppContainer');
- // eslint-disable-next-line no-unsanitized/property
- mountpoint.innerHTML = mainTemplate(appBasePath);
- // bootstrap angular into detached element and attach it later to
- // make angular-within-angular possible
- const $injector = angular.bootstrap(mountpoint, [moduleName]);
-
- registerPanels({
- uiSettings: deps.core.uiSettings,
- timelionPanels: deps.timelionPanels,
- data: deps.plugins.data,
- $rootScope: $injector.get('$rootScope'),
- $compile: $injector.get('$compile'),
- });
- element.appendChild(mountpoint);
- return $injector;
-}
-
-function createLocalAngularModule(deps: RenderDeps) {
- createLocalI18nModule();
- createLocalIconModule();
-
- const dashboardAngularModule = angular.module(moduleName, [
- ...thirdPartyAngularDependencies,
- 'app/timelion/I18n',
- 'app/timelion/icon',
- ]);
- return dashboardAngularModule;
-}
-
-function createLocalIconModule() {
- angular
- .module('app/timelion/icon', ['react'])
- .directive('icon', (reactDirective) => reactDirective(EuiIcon));
-}
-
-function createLocalI18nModule() {
- angular
- .module('app/timelion/I18n', [])
- .provider('i18n', I18nProvider)
- .filter('i18n', i18nFilter)
- .directive('i18nId', i18nDirective);
-}
diff --git a/src/plugins/timelion/public/breadcrumbs.js b/src/plugins/timelion/public/breadcrumbs.js
deleted file mode 100644
index aff173823946b..0000000000000
--- a/src/plugins/timelion/public/breadcrumbs.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { i18n } from '@kbn/i18n';
-
-const ROOT_BREADCRUMB = {
- text: i18n.translate('timelion.breadcrumbs.root', {
- defaultMessage: 'Timelion',
- }),
- href: '#',
-};
-
-export function getCreateBreadcrumbs() {
- return [
- ROOT_BREADCRUMB,
- {
- text: i18n.translate('timelion.breadcrumbs.create', {
- defaultMessage: 'Create',
- }),
- },
- ];
-}
-
-export function getSavedSheetBreadcrumbs($route) {
- const { savedSheet } = $route.current.locals;
- return [
- ROOT_BREADCRUMB,
- {
- text: savedSheet.title,
- },
- ];
-}
diff --git a/src/plugins/timelion/public/components/timelion_deprecation.tsx b/src/plugins/timelion/public/components/timelion_deprecation.tsx
deleted file mode 100644
index 117aabed6773c..0000000000000
--- a/src/plugins/timelion/public/components/timelion_deprecation.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { FormattedMessage } from '@kbn/i18n/react';
-import { EuiSpacer, EuiCallOut, EuiLink } from '@elastic/eui';
-import React from 'react';
-import { DocLinksStart } from '../../../../core/public';
-
-export const TimelionDeprecation = ({ links }: DocLinksStart) => {
- const timelionDeprecationLink = links.visualize.timelionDeprecation;
- return (
- <>
-
-
-
- ),
- }}
- />
- }
- color="warning"
- iconType="alert"
- size="s"
- />
-
- >
- );
-};
diff --git a/src/plugins/timelion/public/components/timelion_deprecation_directive.js b/src/plugins/timelion/public/components/timelion_deprecation_directive.js
deleted file mode 100644
index 2aeea00991864..0000000000000
--- a/src/plugins/timelion/public/components/timelion_deprecation_directive.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import React from 'react';
-import { TimelionDeprecation } from './timelion_deprecation';
-
-export function initTimelionTDeprecationDirective(app, deps) {
- app.directive('timelionDeprecation', function (reactDirective) {
- return reactDirective(
- () => {
- return (
-
-
-
- );
- },
- [],
- {
- restrict: 'E',
- scope: {
- docLinks: '=',
- },
- }
- );
- });
-}
diff --git a/src/plugins/timelion/public/components/timelion_top_nav_directive.js b/src/plugins/timelion/public/components/timelion_top_nav_directive.js
deleted file mode 100644
index 4ec3b40e47c52..0000000000000
--- a/src/plugins/timelion/public/components/timelion_top_nav_directive.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import React from 'react';
-
-export function initTimelionTopNavDirective(app, deps) {
- app.directive('timelionTopNav', function (reactDirective) {
- return reactDirective(
- (props) => {
- const { TopNavMenu } = deps.plugins.navigation.ui;
- return (
-
-
-
- );
- },
- [
- ['topNavMenu', { watchDepth: 'reference' }],
- ['onTimeUpdate', { watchDepth: 'reference' }],
- ],
- {
- restrict: 'E',
- scope: {
- topNavMenu: '=',
- onTimeUpdate: '=',
- },
- }
- );
- });
-}
diff --git a/src/plugins/timelion/public/components/timelionhelp_tabs.js b/src/plugins/timelion/public/components/timelionhelp_tabs.js
deleted file mode 100644
index 537e1bfa393b7..0000000000000
--- a/src/plugins/timelion/public/components/timelionhelp_tabs.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import PropTypes from 'prop-types';
-import React from 'react';
-
-import { EuiTabs, EuiTab } from '@elastic/eui';
-
-import { FormattedMessage } from '@kbn/i18n/react';
-
-function handleClick(activateTab, tabName) {
- activateTab(tabName);
-}
-
-export function TimelionHelpTabs(props) {
- return (
-
- handleClick(props.activateTab, 'funcref')}
- >
-
-
- handleClick(props.activateTab, 'keyboardtips')}
- >
-
-
-
- );
-}
-
-TimelionHelpTabs.propTypes = {
- activeTab: PropTypes.string,
- activateTab: PropTypes.func,
-};
diff --git a/src/plugins/timelion/public/components/timelionhelp_tabs_directive.js b/src/plugins/timelion/public/components/timelionhelp_tabs_directive.js
deleted file mode 100644
index a88e156cb5c51..0000000000000
--- a/src/plugins/timelion/public/components/timelionhelp_tabs_directive.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import React from 'react';
-import { TimelionHelpTabs } from './timelionhelp_tabs';
-
-export function initTimelionTabsDirective(app, deps) {
- app.directive('timelionHelpTabs', function (reactDirective) {
- return reactDirective(
- (props) => {
- return (
-
-
-
- );
- },
- [['activeTab'], ['activateTab', { watchDepth: 'reference' }]],
- {
- restrict: 'E',
- scope: {
- activeTab: '=',
- activateTab: '=',
- },
- }
- );
- });
-}
diff --git a/src/plugins/timelion/public/directives/_form.scss b/src/plugins/timelion/public/directives/_form.scss
deleted file mode 100644
index 37a0cc4c0f3e5..0000000000000
--- a/src/plugins/timelion/public/directives/_form.scss
+++ /dev/null
@@ -1,83 +0,0 @@
-.form-control {
- @include euiFontSizeS;
- display: block;
- width: 100%;
- height: $euiFormControlCompressedHeight;
- padding: $euiSizeXS $euiSizeM;
- border: $euiBorderThin;
- background-color: $euiFormBackgroundColor;
- color: $euiTextColor;
- border-radius: $euiBorderRadius;
- cursor: pointer;
-
- &:not([type='range']) {
- appearance: none;
- }
-
- &:focus {
- border-color: $euiColorPrimary;
- outline: none;
- box-shadow: none;
- }
-}
-
-select.form-control { // stylelint-disable-line selector-no-qualifying-type
- // Makes the select arrow similar to EUI's arrowDown icon
- background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"%3E%3Cpath fill="#{hexToRGB($euiTextColor)}" d="M13.0688508,5.15725038 L8.38423975,9.76827428 C8.17054415,9.97861308 7.82999214,9.97914095 7.61576025,9.76827428 L2.93114915,5.15725038 C2.7181359,4.94758321 2.37277319,4.94758321 2.15975994,5.15725038 C1.94674669,5.36691756 1.94674669,5.70685522 2.15975994,5.9165224 L6.84437104,10.5275463 C7.48517424,11.1582836 8.51644979,11.1566851 9.15562896,10.5275463 L13.8402401,5.9165224 C14.0532533,5.70685522 14.0532533,5.36691756 13.8402401,5.15725038 C13.6272268,4.94758321 13.2818641,4.94758321 13.0688508,5.15725038 Z"/%3E%3C/svg%3E');
- background-size: $euiSize;
- background-repeat: no-repeat;
- background-position: calc(100% - #{$euiSizeS});
- padding-right: $euiSizeXL;
-}
-
-.fullWidth {
- width: 100%;
-}
-
-.timDropdownWarning {
- margin-bottom: $euiSize;
- padding: $euiSizeXS $euiSizeS;
- color: $euiColorDarkestShade;
- border-left: solid 2px $euiColorDanger;
- font-size: $euiSizeM;
-}
-
-.timFormCheckbox {
- display: flex;
- align-items: center;
- line-height: 1.5;
- position: relative;
-}
-
-.timFormCheckbox__input {
- appearance: none;
- background-color: $euiColorLightestShade;
- border: 1px solid $euiColorLightShade;
- border-radius: $euiSizeXS;
- width: $euiSize;
- height: $euiSize;
- font-size: $euiSizeM;
- transition: background-color .1s linear;
-}
-
-.timFormCheckbox__input:checked {
- border-color: $euiColorPrimary;
- background-color: $euiColorPrimary;
-}
-
-.timFormCheckbox__icon {
- position: absolute;
- top: 0;
- left: 2px;
-}
-
-.timFormTextarea {
- padding: $euiSizeXS $euiSizeM;
- font-size: $euiSize;
- line-height: 1.5;
- color: $euiColorDarkestShade;
- background-color: $euiFormBackgroundColor;
- border: 1px solid $euiColorLightShade;
- border-radius: $euiSizeXS;
- transition: border-color .1s linear;
-}
diff --git a/src/plugins/timelion/public/directives/_index.scss b/src/plugins/timelion/public/directives/_index.scss
deleted file mode 100644
index 2a015711062a6..0000000000000
--- a/src/plugins/timelion/public/directives/_index.scss
+++ /dev/null
@@ -1,7 +0,0 @@
-@import './timelion_expression_input';
-@import './cells/index';
-@import './timelion_expression_suggestions/index';
-@import './timelion_help/index';
-@import './timelion_interval/index';
-@import './saved_object_finder';
-@import './form';
diff --git a/src/plugins/timelion/public/directives/_saved_object_finder.scss b/src/plugins/timelion/public/directives/_saved_object_finder.scss
deleted file mode 100644
index 55882fe78e99e..0000000000000
--- a/src/plugins/timelion/public/directives/_saved_object_finder.scss
+++ /dev/null
@@ -1,132 +0,0 @@
-.list-group-menu {
- &.select-mode a {
- outline: none;
- color: tintOrShade($euiColorPrimary, 10%, 10%);
- }
-
- .list-group-menu-item {
- list-style: none;
- color: tintOrShade($euiColorPrimary, 10%, 10%);
-
- &.active {
- font-weight: bold;
- background-color: $euiColorLightShade;
- }
-
- &:hover {
- background-color: tintOrShade($euiColorPrimary, 90%, 90%);
- }
-
- li {
- list-style: none;
- color: tintOrShade($euiColorPrimary, 10%, 10%);
- }
- }
-}
-
-saved-object-finder {
-
- .timSearchBar {
- display: flex;
- align-items: center;
- }
-
- .timSearchBar__section {
- position: relative;
- margin-right: $euiSize;
- flex: 1;
- }
-
- .timSearchBar__icon {
- position: absolute;
- top: $euiSizeS;
- left: $euiSizeS;
- font-size: $euiSize;
- color: $euiColorDarkShade;
- }
-
- .timSearchBar__input {
- padding: $euiSizeS $euiSizeM;
- color: $euiColorDarkestShade;
- background-color: $euiColorEmptyShade;
- border: 1px solid $euiColorLightShade;
- border-radius: $euiSizeXS;
- transition: border-color .1s linear;
- padding-left: $euiSizeXL;
- width: 100%;
- font-size: $euiSize;
- }
-
- .timSearchBar__pagecount {
- font-size: $euiSize;
- color: $euiColorDarkShade;
- }
-
- .list-sort-button {
- border-top-left-radius: 0;
- border-top-right-radius: 0;
- border: none;
- padding: $euiSizeS $euiSize;
- font-weight: $euiFontWeightRegular;
- background-color: $euiColorLightestShade;
- margin-top: $euiSize;
- }
-
- .li-striped {
- li {
- border: none;
- }
-
- li:nth-child(even) {
- background-color: $euiColorLightestShade;
- }
-
- li:nth-child(odd) {
- background-color: $euiColorEmptyShade;
- }
-
- .paginate-heading {
- font-weight: $euiFontWeightRegular;
- color: $euiColorDarkestShade;
- }
-
- .list-group-item {
- padding: $euiSizeS $euiSize;
-
- ul {
- padding: 0;
- display: flex;
- flex-direction: row;
-
- .finder-type {
- margin-right: $euiSizeS;
- }
- }
-
- a {
- display: block;
- color: $euiColorPrimary;
-
- i {
- color: shade($euiColorPrimary, 10%);
- margin-right: $euiSizeS;
- }
- }
-
- &:first-child {
- border-top-left-radius: 0;
- border-top-right-radius: 0;
- }
-
- &.list-group-no-results p {
- margin-bottom: 0;
- }
- }
- }
-
- paginate {
- paginate-controls {
- margin: $euiSize;
- }
- }
-}
diff --git a/src/plugins/timelion/public/directives/_timelion_expression_input.scss b/src/plugins/timelion/public/directives/_timelion_expression_input.scss
deleted file mode 100644
index e4294d8454c7c..0000000000000
--- a/src/plugins/timelion/public/directives/_timelion_expression_input.scss
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * 1. Anchor suggestions beneath input.
- * 2. Allow for option of positioning suggestions absolutely.
- */
-
-.timExpressionInput__container {
- flex: 1 1 auto;
- display: flex;
- flex-direction: column; /* 1 */
- position: relative; /* 2 */
-}
-
-.timExpressionInput {
- min-height: 70px; // Matches buttons on the right with new vertical rhythm sizing
-}
diff --git a/src/plugins/timelion/public/directives/cells/_cells.scss b/src/plugins/timelion/public/directives/cells/_cells.scss
deleted file mode 100644
index d1e5e976fc8d2..0000000000000
--- a/src/plugins/timelion/public/directives/cells/_cells.scss
+++ /dev/null
@@ -1,61 +0,0 @@
-.timCell {
- display: inline-block;
- cursor: pointer;
- position: relative;
- box-sizing: border-box;
- border: 2px dashed transparent;
- // sass-lint:disable-block no-important
- padding-left: 0 !important;
- padding-right: 0 !important;
- margin-bottom: $euiSizeM;
-
- &.active {
- border-color: $euiColorLightShade;
- }
-}
-
-.timCell.running {
- opacity: .5;
-}
-
-.timCell__actions {
- position: absolute;
- bottom: $euiSizeXS;
- left: $euiSizeXS;
-
- > .timCell__action,
- > .timCell__id {
- @include euiFontSizeXS;
- font-weight: $euiFontWeightBold;
- color: $euiColorMediumShade;
- display: inline-block;
- text-align: center;
- width: $euiSizeL;
- height: $euiSizeL;
- border-radius: $euiSizeL / 2;
- border: $euiBorderThin;
- background-color: $euiColorLightestShade;
- z-index: $euiZLevel1;
- }
-
- > .timCell__action {
- opacity: 0;
-
- &:focus {
- opacity: 1;
- }
-
- &:hover,
- &:focus {
- color: $euiTextColor;
- border-color: $euiColorMediumShade;
- background-color: $euiColorLightShade;
- }
- }
-}
-
-.timCell:hover {
- .timCell__action {
- opacity: 1;
- }
-}
diff --git a/src/plugins/timelion/public/directives/cells/_index.scss b/src/plugins/timelion/public/directives/cells/_index.scss
deleted file mode 100644
index 8611b4d8ba1d0..0000000000000
--- a/src/plugins/timelion/public/directives/cells/_index.scss
+++ /dev/null
@@ -1 +0,0 @@
-@import './cells';
diff --git a/src/plugins/timelion/public/directives/cells/cells.html b/src/plugins/timelion/public/directives/cells/cells.html
deleted file mode 100644
index f90b85abaf920..0000000000000
--- a/src/plugins/timelion/public/directives/cells/cells.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
{{$index + 1}}
-
-
-
-
-
-
-
-
diff --git a/src/plugins/timelion/public/directives/cells/cells.js b/src/plugins/timelion/public/directives/cells/cells.js
deleted file mode 100644
index af9e315a7d944..0000000000000
--- a/src/plugins/timelion/public/directives/cells/cells.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { move } from './collection';
-import { initTimelionGridDirective } from '../timelion_grid';
-
-import html from './cells.html';
-
-export function initCellsDirective(app) {
- initTimelionGridDirective(app);
-
- app.directive('timelionCells', function () {
- return {
- restrict: 'E',
- scope: {
- sheet: '=',
- state: '=',
- transient: '=',
- onSearch: '=',
- onSelect: '=',
- onRemoveSheet: '=',
- },
- template: html,
- link: function ($scope) {
- $scope.removeCell = function (index) {
- $scope.onRemoveSheet(index);
- };
-
- $scope.dropCell = function (item, partFrom, partTo, indexFrom, indexTo) {
- move($scope.sheet, indexFrom, indexTo);
- $scope.onSelect(indexTo);
- };
- },
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/cells/collection.ts b/src/plugins/timelion/public/directives/cells/collection.ts
deleted file mode 100644
index 188f00bef16ae..0000000000000
--- a/src/plugins/timelion/public/directives/cells/collection.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import _ from 'lodash';
-
-/**
- * move an obj either up or down in the collection by
- * injecting it either before/after the prev/next obj that
- * satisfied the qualifier
- *
- * or, just from one index to another...
- *
- * @param {array} objs - the list to move the object within
- * @param {number|any} obj - the object that should be moved, or the index that the object is currently at
- * @param {number|boolean} below - the index to move the object to, or whether it should be moved up or down
- * @param {function} qualifier - a lodash-y callback, object = _.where, string = _.pluck
- * @return {array} - the objs argument
- */
-export function move(
- objs: any[],
- obj: object | number,
- below: number | boolean,
- qualifier?: ((object: object, index: number) => any) | Record | string
-): object[] {
- const origI = _.isNumber(obj) ? obj : objs.indexOf(obj);
- if (origI === -1) {
- return objs;
- }
-
- if (_.isNumber(below)) {
- // move to a specific index
- objs.splice(below, 0, objs.splice(origI, 1)[0]);
- return objs;
- }
-
- below = !!below;
- qualifier = qualifier && _.iteratee(qualifier);
-
- const above = !below;
- const finder = below ? _.findIndex : _.findLastIndex;
-
- // find the index of the next/previous obj that meets the qualifications
- const targetI = finder(objs, (otherAgg, otherI) => {
- if (below && otherI <= origI) {
- return;
- }
- if (above && otherI >= origI) {
- return;
- }
- return Boolean(_.isFunction(qualifier) && qualifier(otherAgg, otherI));
- });
-
- if (targetI === -1) {
- return objs;
- }
-
- // place the obj at it's new index
- objs.splice(targetI, 0, objs.splice(origI, 1)[0]);
- return objs;
-}
diff --git a/src/plugins/timelion/public/directives/chart/chart.js b/src/plugins/timelion/public/directives/chart/chart.js
deleted file mode 100644
index 8f02fb70436e7..0000000000000
--- a/src/plugins/timelion/public/directives/chart/chart.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { i18n } from '@kbn/i18n';
-
-export function Chart(timelionPanels) {
- return {
- restrict: 'A',
- scope: {
- seriesList: '=chart', // The flot object, data, config and all
- search: '=', // The function to execute to kick off a search
- interval: '=', // Required for formatting x-axis ticks
- rerenderTrigger: '=',
- },
- link: function ($scope, $elem) {
- let panelScope = $scope.$new(true);
-
- function render() {
- panelScope.$destroy();
-
- if (!$scope.seriesList) return;
-
- $scope.seriesList.render = $scope.seriesList.render || {
- type: 'timechart',
- };
-
- const panelSchema = timelionPanels.get($scope.seriesList.render.type);
-
- if (!panelSchema) {
- $elem.text(
- i18n.translate('timelion.chart.seriesList.noSchemaWarning', {
- defaultMessage: 'No such panel type: {renderType}',
- values: { renderType: $scope.seriesList.render.type },
- })
- );
- return;
- }
-
- panelScope = $scope.$new(true);
- panelScope.seriesList = $scope.seriesList;
- panelScope.interval = $scope.interval;
- panelScope.search = $scope.search;
-
- panelSchema.render(panelScope, $elem);
- }
-
- $scope.$watchGroup(['seriesList', 'rerenderTrigger'], render);
- },
- };
-}
diff --git a/src/plugins/timelion/public/directives/fixed_element.js b/src/plugins/timelion/public/directives/fixed_element.js
deleted file mode 100644
index 4349161892367..0000000000000
--- a/src/plugins/timelion/public/directives/fixed_element.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import $ from 'jquery';
-
-export function initFixedElementDirective(app) {
- app.directive('fixedElementRoot', function () {
- return {
- restrict: 'A',
- link: function ($elem) {
- let fixedAt;
- $(window).bind('scroll', function () {
- const fixed = $('[fixed-element]', $elem);
- const body = $('[fixed-element-body]', $elem);
- const top = fixed.offset().top;
-
- if ($(window).scrollTop() > top) {
- // This is a gross hack, but its better than it was. I guess
- fixedAt = $(window).scrollTop();
- fixed.addClass(fixed.attr('fixed-element'));
- body.addClass(fixed.attr('fixed-element-body'));
- body.css({ top: fixed.height() });
- }
-
- if ($(window).scrollTop() < fixedAt) {
- fixed.removeClass(fixed.attr('fixed-element'));
- body.removeClass(fixed.attr('fixed-element-body'));
- body.removeAttr('style');
- }
- });
- },
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/fullscreen/fullscreen.html b/src/plugins/timelion/public/directives/fullscreen/fullscreen.html
deleted file mode 100644
index 1ed6aa82ea3b9..0000000000000
--- a/src/plugins/timelion/public/directives/fullscreen/fullscreen.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
diff --git a/src/plugins/timelion/public/directives/fullscreen/fullscreen.js b/src/plugins/timelion/public/directives/fullscreen/fullscreen.js
deleted file mode 100644
index 8403d861a4479..0000000000000
--- a/src/plugins/timelion/public/directives/fullscreen/fullscreen.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import html from './fullscreen.html';
-
-export function initFullscreenDirective(app) {
- app.directive('timelionFullscreen', function () {
- return {
- restrict: 'E',
- scope: {
- expression: '=',
- series: '=',
- state: '=',
- transient: '=',
- onSearch: '=',
- },
- template: html,
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/input_focus.js b/src/plugins/timelion/public/directives/input_focus.js
deleted file mode 100644
index 23b8c54d623c3..0000000000000
--- a/src/plugins/timelion/public/directives/input_focus.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-export function initInputFocusDirective(app) {
- app.directive('inputFocus', function ($parse, $timeout) {
- return {
- restrict: 'A',
- link: function ($scope, $elem, attrs) {
- const isDisabled = attrs.disableInputFocus && $parse(attrs.disableInputFocus)($scope);
- if (!isDisabled) {
- $timeout(function () {
- $elem.focus();
- if (attrs.inputFocus === 'select') $elem.select();
- });
- }
- },
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/key_map.ts b/src/plugins/timelion/public/directives/key_map.ts
deleted file mode 100644
index 3e28bf3d7a3d5..0000000000000
--- a/src/plugins/timelion/public/directives/key_map.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-export const keyMap: { [key: number]: string } = {
- 8: 'backspace',
- 9: 'tab',
- 13: 'enter',
- 16: 'shift',
- 17: 'ctrl',
- 18: 'alt',
- 19: 'pause',
- 20: 'capsLock',
- 27: 'escape',
- 32: 'space',
- 33: 'pageUp',
- 34: 'pageDown',
- 35: 'end',
- 36: 'home',
- 37: 'left',
- 38: 'up',
- 39: 'right',
- 40: 'down',
- 45: 'insert',
- 46: 'delete',
- 48: '0',
- 49: '1',
- 50: '2',
- 51: '3',
- 52: '4',
- 53: '5',
- 54: '6',
- 55: '7',
- 56: '8',
- 57: '9',
- 65: 'a',
- 66: 'b',
- 67: 'c',
- 68: 'd',
- 69: 'e',
- 70: 'f',
- 71: 'g',
- 72: 'h',
- 73: 'i',
- 74: 'j',
- 75: 'k',
- 76: 'l',
- 77: 'm',
- 78: 'n',
- 79: 'o',
- 80: 'p',
- 81: 'q',
- 82: 'r',
- 83: 's',
- 84: 't',
- 85: 'u',
- 86: 'v',
- 87: 'w',
- 88: 'x',
- 89: 'y',
- 90: 'z',
- 91: 'leftWindowKey',
- 92: 'rightWindowKey',
- 93: 'selectKey',
- 96: '0',
- 97: '1',
- 98: '2',
- 99: '3',
- 100: '4',
- 101: '5',
- 102: '6',
- 103: '7',
- 104: '8',
- 105: '9',
- 106: 'multiply',
- 107: 'add',
- 109: 'subtract',
- 110: 'period',
- 111: 'divide',
- 112: 'f1',
- 113: 'f2',
- 114: 'f3',
- 115: 'f4',
- 116: 'f5',
- 117: 'f6',
- 118: 'f7',
- 119: 'f8',
- 120: 'f9',
- 121: 'f10',
- 122: 'f11',
- 123: 'f12',
- 144: 'numLock',
- 145: 'scrollLock',
- 186: 'semiColon',
- 187: 'equalSign',
- 188: 'comma',
- 189: 'dash',
- 190: 'period',
- 191: 'forwardSlash',
- 192: 'graveAccent',
- 219: 'openBracket',
- 220: 'backSlash',
- 221: 'closeBracket',
- 222: 'singleQuote',
- 224: 'meta',
-};
diff --git a/src/plugins/timelion/public/directives/saved_object_finder.html b/src/plugins/timelion/public/directives/saved_object_finder.html
deleted file mode 100644
index 1ce10efe4e0a8..0000000000000
--- a/src/plugins/timelion/public/directives/saved_object_finder.html
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-
-
-
-
diff --git a/src/plugins/timelion/public/directives/saved_object_finder.js b/src/plugins/timelion/public/directives/saved_object_finder.js
deleted file mode 100644
index 3bd6a2d9581f4..0000000000000
--- a/src/plugins/timelion/public/directives/saved_object_finder.js
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import _ from 'lodash';
-import rison from 'rison-node';
-import savedObjectFinderTemplate from './saved_object_finder.html';
-import { keyMap } from './key_map';
-import {
- PaginateControlsDirectiveProvider,
- PaginateDirectiveProvider,
-} from '../../../kibana_legacy/public';
-import { PER_PAGE_SETTING } from '../../../saved_objects/public';
-import { VISUALIZE_ENABLE_LABS_SETTING } from '../../../visualizations/public';
-
-export function initSavedObjectFinderDirective(app, savedSheetLoader, uiSettings) {
- app
- .directive('paginate', PaginateDirectiveProvider)
- .directive('paginateControls', PaginateControlsDirectiveProvider)
- .directive('savedObjectFinder', function () {
- return {
- restrict: 'E',
- scope: {
- type: '@',
- // optional make-url attr, sets the userMakeUrl in our scope
- userMakeUrl: '=?makeUrl',
- // optional on-choose attr, sets the userOnChoose in our scope
- userOnChoose: '=?onChoose',
- // optional useLocalManagement attr, removes link to management section
- useLocalManagement: '=?useLocalManagement',
- /**
- * @type {function} - an optional function. If supplied an `Add new X` button is shown
- * and this function is called when clicked.
- */
- onAddNew: '=',
- /**
- * @{type} boolean - set this to true, if you don't want the search box above the
- * table to automatically gain focus once loaded
- */
- disableAutoFocus: '=',
- },
- template: savedObjectFinderTemplate,
- controllerAs: 'finder',
- controller: function ($scope, $element, $location, history) {
- const self = this;
-
- // the text input element
- const $input = $element.find('input[ng-model=filter]');
-
- // The number of items to show in the list
- $scope.perPage = uiSettings.get(PER_PAGE_SETTING);
-
- // the list that will hold the suggestions
- const $list = $element.find('ul');
-
- // the current filter string, used to check that returned results are still useful
- let currentFilter = $scope.filter;
-
- // the most recently entered search/filter
- let prevSearch;
-
- // the list of hits, used to render display
- self.hits = [];
-
- self.service = savedSheetLoader;
- self.properties = self.service.loaderProperties;
-
- filterResults();
-
- /**
- * Boolean that keeps track of whether hits are sorted ascending (true)
- * or descending (false) by title
- * @type {Boolean}
- */
- self.isAscending = true;
-
- /**
- * Sorts saved object finder hits either ascending or descending
- * @param {Array} hits Array of saved finder object hits
- * @return {Array} Array sorted either ascending or descending
- */
- self.sortHits = function (hits) {
- self.isAscending = !self.isAscending;
- self.hits = self.isAscending
- ? _.sortBy(hits, ['title'])
- : _.sortBy(hits, ['title']).reverse();
- };
-
- /**
- * Passed the hit objects and will determine if the
- * hit should have a url in the UI, returns it if so
- * @return {string|null} - the url or nothing
- */
- self.makeUrl = function (hit) {
- if ($scope.userMakeUrl) {
- return $scope.userMakeUrl(hit);
- }
-
- if (!$scope.userOnChoose) {
- return hit.url;
- }
-
- return '#';
- };
-
- self.preventClick = function ($event) {
- $event.preventDefault();
- };
-
- /**
- * Called when a hit object is clicked, can override the
- * url behavior if necessary.
- */
- self.onChoose = function (hit, $event) {
- if ($scope.userOnChoose) {
- $scope.userOnChoose(hit, $event);
- }
-
- const url = self.makeUrl(hit);
- if (!url || url === '#' || url.charAt(0) !== '#') return;
-
- $event.preventDefault();
-
- history.push(url.substr(1));
- };
-
- $scope.$watch('filter', function (newFilter) {
- // ensure that the currentFilter changes from undefined to ''
- // which triggers
- currentFilter = newFilter || '';
- filterResults();
- });
-
- $scope.pageFirstItem = 0;
- $scope.pageLastItem = 0;
- $scope.onPageChanged = (page) => {
- $scope.pageFirstItem = page.firstItem;
- $scope.pageLastItem = page.lastItem;
- };
-
- //manages the state of the keyboard selector
- self.selector = {
- enabled: false,
- index: -1,
- };
-
- self.getLabel = function () {
- return _.words(self.properties.nouns).map(_.capitalize).join(' ');
- };
-
- //key handler for the filter text box
- self.filterKeyDown = function ($event) {
- switch (keyMap[$event.keyCode]) {
- case 'enter':
- if (self.hitCount !== 1) return;
- const hit = self.hits[0];
- if (!hit) return;
-
- self.onChoose(hit, $event);
- $event.preventDefault();
- break;
- }
- };
-
- //key handler for the list items
- self.hitKeyDown = function ($event, page, paginate) {
- switch (keyMap[$event.keyCode]) {
- case 'tab':
- if (!self.selector.enabled) break;
-
- self.selector.index = -1;
- self.selector.enabled = false;
-
- //if the user types shift-tab return to the textbox
- //if the user types tab, set the focus to the currently selected hit.
- if ($event.shiftKey) {
- $input.focus();
- } else {
- $list.find('li.active a').focus();
- }
-
- $event.preventDefault();
- break;
- case 'down':
- if (!self.selector.enabled) break;
-
- if (self.selector.index + 1 < page.length) {
- self.selector.index += 1;
- }
- $event.preventDefault();
- break;
- case 'up':
- if (!self.selector.enabled) break;
-
- if (self.selector.index > 0) {
- self.selector.index -= 1;
- }
- $event.preventDefault();
- break;
- case 'right':
- if (!self.selector.enabled) break;
-
- if (page.number < page.count) {
- paginate.goToPage(page.number + 1);
- self.selector.index = 0;
- selectTopHit();
- }
- $event.preventDefault();
- break;
- case 'left':
- if (!self.selector.enabled) break;
-
- if (page.number > 1) {
- paginate.goToPage(page.number - 1);
- self.selector.index = 0;
- selectTopHit();
- }
- $event.preventDefault();
- break;
- case 'escape':
- if (!self.selector.enabled) break;
-
- $input.focus();
- $event.preventDefault();
- break;
- case 'enter':
- if (!self.selector.enabled) break;
-
- const hitIndex = (page.number - 1) * paginate.perPage + self.selector.index;
- const hit = self.hits[hitIndex];
- if (!hit) break;
-
- self.onChoose(hit, $event);
- $event.preventDefault();
- break;
- case 'shift':
- break;
- default:
- $input.focus();
- break;
- }
- };
-
- self.hitBlur = function () {
- self.selector.index = -1;
- self.selector.enabled = false;
- };
-
- self.manageObjects = function (type) {
- $location.url('/management/kibana/objects?_a=' + rison.encode({ tab: type }));
- };
-
- self.hitCountNoun = function () {
- return (self.hitCount === 1
- ? self.properties.noun
- : self.properties.nouns
- ).toLowerCase();
- };
-
- function selectTopHit() {
- setTimeout(function () {
- //triggering a focus event kicks off a new angular digest cycle.
- $list.find('a:first').focus();
- }, 0);
- }
-
- function filterResults() {
- if (!self.service) return;
- if (!self.properties) return;
-
- // track the filter that we use for this search,
- // but ensure that we don't search for the same
- // thing twice. This is called from multiple places
- // and needs to be smart about when it actually searches
- const filter = currentFilter;
- if (prevSearch === filter) return;
-
- prevSearch = filter;
-
- const isLabsEnabled = uiSettings.get(VISUALIZE_ENABLE_LABS_SETTING);
- self.service.find(filter).then(function (hits) {
- hits.hits = hits.hits.filter(
- (hit) => isLabsEnabled || _.get(hit, 'type.stage') !== 'experimental'
- );
- hits.total = hits.hits.length;
-
- // ensure that we don't display old results
- // as we can't really cancel requests
- if (currentFilter === filter) {
- self.hitCount = hits.total;
- self.hits = _.sortBy(hits.hits, ['title']);
- }
- });
- }
- },
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/saved_object_save_as_checkbox.html b/src/plugins/timelion/public/directives/saved_object_save_as_checkbox.html
deleted file mode 100644
index a001ddc751748..0000000000000
--- a/src/plugins/timelion/public/directives/saved_object_save_as_checkbox.html
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
diff --git a/src/plugins/timelion/public/directives/saved_object_save_as_checkbox.js b/src/plugins/timelion/public/directives/saved_object_save_as_checkbox.js
deleted file mode 100644
index 865e5ea473b85..0000000000000
--- a/src/plugins/timelion/public/directives/saved_object_save_as_checkbox.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import saveObjectSaveAsCheckboxTemplate from './saved_object_save_as_checkbox.html';
-
-export function initSavedObjectSaveAsCheckBoxDirective(app) {
- app.directive('savedObjectSaveAsCheckBox', function () {
- return {
- restrict: 'E',
- template: saveObjectSaveAsCheckboxTemplate,
- replace: true,
- scope: {
- savedObject: '=',
- },
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/timelion_expression_input.html b/src/plugins/timelion/public/directives/timelion_expression_input.html
deleted file mode 100644
index 6c115118860ba..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_expression_input.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
diff --git a/src/plugins/timelion/public/directives/timelion_expression_input.js b/src/plugins/timelion/public/directives/timelion_expression_input.js
deleted file mode 100644
index c29c802914987..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_expression_input.js
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-/**
- * Timelion Expression Autocompleter
- *
- * This directive allows users to enter multiline timelion expressions. If the user has entered
- * a valid expression and then types a ".", this directive will display a list of suggestions.
- *
- * Users can navigate suggestions using the arrow keys. When a user selects a suggestion, it's
- * inserted into the expression and the caret position is updated to be inside of the newly-
- * added function's parentheses.
- *
- * Beneath the hood, we use a PEG grammar to validate the Timelion expression and detect if
- * the caret is in a position within the expression that allows functions to be suggested.
- *
- * NOTE: This directive doesn't work well with contenteditable divs. Challenges include:
- * - You have to replace markup with newline characters and spaces when passing the expression
- * to the grammar.
- * - You have to do the opposite when loading a saved expression, so that it appears correctly
- * within the contenteditable (i.e. replace newlines with markup).
- * - The Range and Selection APIs ignore newlines when providing caret position, so there is
- * literally no way to insert suggestions into the correct place in a multiline expression
- * that has more than a single consecutive newline.
- */
-
-import _ from 'lodash';
-import $ from 'jquery';
-import timelionExpressionInputTemplate from './timelion_expression_input.html';
-import {
- SUGGESTION_TYPE,
- Suggestions,
- suggest,
- insertAtLocation,
-} from './timelion_expression_input_helpers';
-import { comboBoxKeyCodes } from '@elastic/eui';
-
-export function timelionExpInput(deps) {
- return ($http, $timeout) => {
- return {
- restrict: 'E',
- scope: {
- rows: '=',
- sheet: '=',
- updateChart: '&',
- shouldPopoverSuggestions: '@',
- },
- replace: true,
- template: timelionExpressionInputTemplate,
- link: function (scope, elem) {
- const argValueSuggestions = deps.plugins.visTypeTimelion.getArgValueSuggestions();
- const expressionInput = elem.find('[data-expression-input]');
- const functionReference = {};
- let suggestibleFunctionLocation = {};
-
- scope.suggestions = new Suggestions();
-
- function init() {
- $http.get('../api/timelion/functions').then(function (resp) {
- Object.assign(functionReference, {
- byName: _.keyBy(resp.data, 'name'),
- list: resp.data,
- });
- });
- }
-
- function setCaretOffset(caretOffset) {
- // Wait for Angular to update the input with the new expression and *then* we can set
- // the caret position.
- $timeout(() => {
- expressionInput.focus();
- expressionInput[0].selectionStart = expressionInput[0].selectionEnd = caretOffset;
- scope.$apply();
- }, 0);
- }
-
- function insertSuggestionIntoExpression(suggestionIndex) {
- if (scope.suggestions.isEmpty()) {
- return;
- }
-
- const { min, max } = suggestibleFunctionLocation;
- let insertedValue;
- let insertPositionMinOffset = 0;
-
- switch (scope.suggestions.type) {
- case SUGGESTION_TYPE.FUNCTIONS: {
- // Position the caret inside of the function parentheses.
- insertedValue = `${scope.suggestions.list[suggestionIndex].name}()`;
-
- // min advanced one to not replace function '.'
- insertPositionMinOffset = 1;
- break;
- }
- case SUGGESTION_TYPE.ARGUMENTS: {
- // Position the caret after the '='
- insertedValue = `${scope.suggestions.list[suggestionIndex].name}=`;
- break;
- }
- case SUGGESTION_TYPE.ARGUMENT_VALUE: {
- // Position the caret after the argument value
- insertedValue = `${scope.suggestions.list[suggestionIndex].name}`;
- break;
- }
- }
-
- const updatedExpression = insertAtLocation(
- insertedValue,
- scope.sheet,
- min + insertPositionMinOffset,
- max
- );
- scope.sheet = updatedExpression;
-
- const newCaretOffset = min + insertedValue.length;
- setCaretOffset(newCaretOffset);
- }
-
- function scrollToSuggestionAt(index) {
- // We don't cache these because the list changes based on user input.
- const suggestionsList = $('[data-suggestions-list]');
- const suggestionListItem = $('[data-suggestion-list-item]')[index];
- // Scroll to the position of the item relative to the list, not to the window.
- suggestionsList.scrollTop(suggestionListItem.offsetTop - suggestionsList[0].offsetTop);
- }
-
- function getCursorPosition() {
- if (expressionInput.length) {
- return expressionInput[0].selectionStart;
- }
- return null;
- }
-
- async function getSuggestions() {
- const suggestions = await suggest(
- scope.sheet,
- functionReference.list,
- getCursorPosition(),
- argValueSuggestions
- );
-
- // We're using ES6 Promises, not $q, so we have to wrap this in $apply.
- scope.$apply(() => {
- if (suggestions) {
- scope.suggestions.setList(suggestions.list, suggestions.type);
- scope.suggestions.show();
- suggestibleFunctionLocation = suggestions.location;
- $timeout(() => {
- const suggestionsList = $('[data-suggestions-list]');
- suggestionsList.scrollTop(0);
- }, 0);
- return;
- }
-
- suggestibleFunctionLocation = undefined;
- scope.suggestions.reset();
- });
- }
-
- function isNavigationalKey(keyCode) {
- const keyCodes = _.values(comboBoxKeyCodes);
- return keyCodes.includes(keyCode);
- }
-
- scope.onFocusInput = () => {
- // Wait for the caret position of the input to update and then we can get suggestions
- // (which depends on the caret position).
- $timeout(getSuggestions, 0);
- };
-
- scope.onBlurInput = () => {
- scope.suggestions.hide();
- };
-
- scope.onKeyDownInput = (e) => {
- // If we've pressed any non-navigational keys, then the user has typed something and we
- // can exit early without doing any navigation. The keyup handler will pull up suggestions.
- if (!isNavigationalKey(e.keyCode)) {
- return;
- }
-
- switch (e.keyCode) {
- case comboBoxKeyCodes.UP:
- if (scope.suggestions.isVisible) {
- // Up and down keys navigate through suggestions.
- e.preventDefault();
- scope.suggestions.stepForward();
- scrollToSuggestionAt(scope.suggestions.index);
- }
- break;
-
- case comboBoxKeyCodes.DOWN:
- if (scope.suggestions.isVisible) {
- // Up and down keys navigate through suggestions.
- e.preventDefault();
- scope.suggestions.stepBackward();
- scrollToSuggestionAt(scope.suggestions.index);
- }
- break;
-
- case comboBoxKeyCodes.TAB:
- // If there are no suggestions or none is selected, the user tabs to the next input.
- if (scope.suggestions.isEmpty() || scope.suggestions.index < 0) {
- // Before letting the tab be handled to focus the next element
- // we need to hide the suggestions, otherwise it will focus these
- // instead of the time interval select.
- scope.suggestions.hide();
- return;
- }
-
- // If we have suggestions, complete the selected one.
- e.preventDefault();
- insertSuggestionIntoExpression(scope.suggestions.index);
- break;
-
- case comboBoxKeyCodes.ENTER:
- if (e.metaKey || e.ctrlKey) {
- // Re-render the chart when the user hits CMD+ENTER.
- e.preventDefault();
- scope.updateChart();
- } else if (!scope.suggestions.isEmpty()) {
- // If the suggestions are open, complete the expression with the suggestion.
- e.preventDefault();
- insertSuggestionIntoExpression(scope.suggestions.index);
- }
- break;
-
- case comboBoxKeyCodes.ESCAPE:
- e.preventDefault();
- scope.suggestions.hide();
- break;
- }
- };
-
- scope.onKeyUpInput = (e) => {
- // If the user isn't navigating, then we should update the suggestions based on their input.
- if (!isNavigationalKey(e.keyCode)) {
- getSuggestions();
- }
- };
-
- scope.onClickExpression = () => {
- getSuggestions();
- };
-
- scope.onClickSuggestion = (index) => {
- insertSuggestionIntoExpression(index);
- };
-
- scope.getActiveSuggestionId = () => {
- if (scope.suggestions.isVisible && scope.suggestions.index > -1) {
- return `timelionSuggestion${scope.suggestions.index}`;
- }
- return '';
- };
-
- init();
- },
- };
- };
-}
diff --git a/src/plugins/timelion/public/directives/timelion_expression_input_helpers.js b/src/plugins/timelion/public/directives/timelion_expression_input_helpers.js
deleted file mode 100644
index 0bc5897c49d6f..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_expression_input_helpers.js
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import _ from 'lodash';
-import { _LEGACY_ as visTypeTimelion } from '../../../vis_type_timelion/public';
-
-export const SUGGESTION_TYPE = {
- ARGUMENTS: 'arguments',
- ARGUMENT_VALUE: 'argument_value',
- FUNCTIONS: 'functions',
-};
-
-export class Suggestions {
- constructor() {
- this.reset();
- }
-
- reset() {
- this.index = -1;
- this.list = [];
- this.type = null;
- this.isVisible = false;
- }
-
- setList(list, type) {
- this.list = list.sort((a, b) => {
- if (a.name < b.name) {
- return -1;
- }
- if (a.name > b.name) {
- return 1;
- }
- // names must be equal
- return 0;
- });
- this.type = type;
-
- // Only try to position index inside of list range, when it was already focused
- // beforehand (i.e. not -1)
- if (this.index > -1) {
- // We may get a shorter list than the one we have now, so we need to make sure our index doesn't
- // fall outside of the new list's range.
- this.index = Math.max(0, Math.min(this.index, this.list.length - 1));
- }
- }
-
- getCount() {
- return this.list.length;
- }
-
- isEmpty() {
- return this.list.length === 0;
- }
-
- show() {
- this.isVisible = true;
- }
-
- hide() {
- this.isVisible = false;
- }
-
- stepForward() {
- if (this.index > 0) {
- this.index -= 1;
- }
- }
-
- stepBackward() {
- if (this.index < this.list.length - 1) {
- this.index += 1;
- }
- }
-}
-
-function inLocation(cursorPosition, location) {
- return cursorPosition >= location.min && cursorPosition <= location.max;
-}
-
-function getArgumentsHelp(functionHelp, functionArgs = []) {
- if (!functionHelp) {
- return [];
- }
-
- // Do not provide 'inputSeries' as argument suggestion for chainable functions
- const argsHelp = functionHelp.chainable ? functionHelp.args.slice(1) : functionHelp.args.slice(0);
-
- // ignore arguments that are already provided in function declaration
- const functionArgNames = functionArgs.map((arg) => {
- return arg.name;
- });
- return argsHelp.filter((arg) => {
- return !functionArgNames.includes(arg.name);
- });
-}
-
-async function extractSuggestionsFromParsedResult(
- result,
- cursorPosition,
- functionList,
- argValueSuggestions
-) {
- const activeFunc = result.functions.find((func) => {
- return cursorPosition >= func.location.min && cursorPosition < func.location.max;
- });
-
- if (!activeFunc) {
- return;
- }
-
- const functionHelp = functionList.find((func) => {
- return func.name === activeFunc.function;
- });
-
- // return function suggestion when cursor is outside of parentheses
- // location range includes '.', function name, and '('.
- const openParen = activeFunc.location.min + activeFunc.function.length + 2;
- if (cursorPosition < openParen) {
- return { list: [functionHelp], location: activeFunc.location, type: SUGGESTION_TYPE.FUNCTIONS };
- }
-
- // return argument value suggestions when cursor is inside argument value
- const activeArg = activeFunc.arguments.find((argument) => {
- return inLocation(cursorPosition, argument.location);
- });
- if (
- activeArg &&
- activeArg.type === 'namedArg' &&
- inLocation(cursorPosition, activeArg.value.location)
- ) {
- const { function: functionName, arguments: functionArgs } = activeFunc;
-
- const {
- name: argName,
- value: { text: partialInput },
- } = activeArg;
-
- let valueSuggestions;
- if (argValueSuggestions.hasDynamicSuggestionsForArgument(functionName, argName)) {
- valueSuggestions = await argValueSuggestions.getDynamicSuggestionsForArgument(
- functionName,
- argName,
- functionArgs,
- partialInput
- );
- } else {
- const { suggestions: staticSuggestions } = functionHelp.args.find((arg) => {
- return arg.name === activeArg.name;
- });
- valueSuggestions = argValueSuggestions.getStaticSuggestionsForInput(
- partialInput,
- staticSuggestions
- );
- }
- return {
- list: valueSuggestions,
- location: activeArg.value.location,
- type: SUGGESTION_TYPE.ARGUMENT_VALUE,
- };
- }
-
- // return argument suggestions
- const argsHelp = getArgumentsHelp(functionHelp, activeFunc.arguments);
- const argumentSuggestions = argsHelp.filter((arg) => {
- if (_.get(activeArg, 'type') === 'namedArg') {
- return _.startsWith(arg.name, activeArg.name);
- } else if (activeArg) {
- return _.startsWith(arg.name, activeArg.text);
- }
- return true;
- });
- const location = activeArg ? activeArg.location : { min: cursorPosition, max: cursorPosition };
- return { list: argumentSuggestions, location: location, type: SUGGESTION_TYPE.ARGUMENTS };
-}
-
-export async function suggest(expression, functionList, cursorPosition, argValueSuggestions) {
- try {
- const result = await visTypeTimelion.parseTimelionExpressionAsync(expression);
- return await extractSuggestionsFromParsedResult(
- result,
- cursorPosition,
- functionList,
- argValueSuggestions
- );
- } catch (e) {
- let message;
- try {
- // The grammar will throw an error containing a message if the expression is formatted
- // correctly and is prepared to accept suggestions. If the expression is not formatted
- // correctly the grammar will just throw a regular PEG SyntaxError, and this JSON.parse
- // attempt will throw an error.
- message = JSON.parse(e.message);
- } catch (e) {
- // The expression isn't correctly formatted, so JSON.parse threw an error.
- return;
- }
-
- switch (message.type) {
- case 'incompleteFunction': {
- let list;
- if (message.function) {
- // The user has start typing a function name, so we'll filter the list down to only
- // possible matches.
- list = functionList.filter((func) => _.startsWith(func.name, message.function));
- } else {
- // The user hasn't typed anything yet, so we'll just return the entire list.
- list = functionList;
- }
- return { list, location: message.location, type: SUGGESTION_TYPE.FUNCTIONS };
- }
- case 'incompleteArgument': {
- const { currentFunction: functionName, currentArgs: functionArgs } = message;
- const functionHelp = functionList.find((func) => func.name === functionName);
- return {
- list: getArgumentsHelp(functionHelp, functionArgs),
- location: message.location,
- type: SUGGESTION_TYPE.ARGUMENTS,
- };
- }
- case 'incompleteArgumentValue': {
- const { name: argName, currentFunction: functionName, currentArgs: functionArgs } = message;
- let valueSuggestions = [];
- if (argValueSuggestions.hasDynamicSuggestionsForArgument(functionName, argName)) {
- valueSuggestions = await argValueSuggestions.getDynamicSuggestionsForArgument(
- functionName,
- argName,
- functionArgs
- );
- } else {
- const functionHelp = functionList.find((func) => func.name === functionName);
- if (functionHelp) {
- const argHelp = functionHelp.args.find((arg) => arg.name === argName);
- if (argHelp && argHelp.suggestions) {
- valueSuggestions = argHelp.suggestions;
- }
- }
- }
- return {
- list: valueSuggestions,
- location: { min: cursorPosition, max: cursorPosition },
- type: SUGGESTION_TYPE.ARGUMENT_VALUE,
- };
- }
- }
- }
-}
-
-export function insertAtLocation(
- valueToInsert,
- destination,
- replacementRangeStart,
- replacementRangeEnd
-) {
- // Insert the value at a location caret within the destination.
- const prefix = destination.slice(0, replacementRangeStart);
- const suffix = destination.slice(replacementRangeEnd, destination.length);
- const result = `${prefix}${valueToInsert}${suffix}`;
- return result;
-}
diff --git a/src/plugins/timelion/public/directives/timelion_expression_suggestions/_index.scss b/src/plugins/timelion/public/directives/timelion_expression_suggestions/_index.scss
deleted file mode 100644
index 6fd0098aea68e..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_expression_suggestions/_index.scss
+++ /dev/null
@@ -1 +0,0 @@
-@import './timelion_expression_suggestions';
diff --git a/src/plugins/timelion/public/directives/timelion_expression_suggestions/_timelion_expression_suggestions.scss b/src/plugins/timelion/public/directives/timelion_expression_suggestions/_timelion_expression_suggestions.scss
deleted file mode 100644
index 4bf6ba24108d2..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_expression_suggestions/_timelion_expression_suggestions.scss
+++ /dev/null
@@ -1,36 +0,0 @@
-.timSuggestions {
- @include euiBottomShadowMedium;
- background-color: $euiColorLightestShade;
- color: $euiTextColor;
- border: $euiBorderThin;
- // sass-lint:disable-block no-important
- border-radius: 0 0 $euiBorderRadius $euiBorderRadius !important;
- z-index: $euiZLevel9;
- max-height: $euiSizeXL * 10;
- overflow-y: auto;
-
- &.timSuggestions-isPopover {
- position: absolute;
- top: 100%;
- }
-}
-
-.timSuggestions__item {
- border-bottom: $euiBorderThin;
- padding: $euiSizeXS $euiSizeL;
-
- &:hover,
- &.active {
- background-color: $euiColorLightShade;
- }
-}
-
-.timSuggestions__details {
- background-color: $euiColorLightestShade;
- padding: $euiSizeM;
- border-radius: $euiBorderRadius;
-
- > table {
- margin-bottom: 0;
- }
-}
diff --git a/src/plugins/timelion/public/directives/timelion_expression_suggestions/timelion_expression_suggestions.html b/src/plugins/timelion/public/directives/timelion_expression_suggestions/timelion_expression_suggestions.html
deleted file mode 100644
index ddb9f21615aee..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_expression_suggestions/timelion_expression_suggestions.html
+++ /dev/null
@@ -1,109 +0,0 @@
-
diff --git a/src/plugins/timelion/public/directives/timelion_help/timelion_help.js b/src/plugins/timelion/public/directives/timelion_help/timelion_help.js
deleted file mode 100644
index ee518a8bce75c..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_help/timelion_help.js
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import template from './timelion_help.html';
-import { i18n } from '@kbn/i18n';
-import _ from 'lodash';
-import moment from 'moment';
-
-export function initTimelionHelpDirective(app) {
- app.directive('timelionHelp', function ($http) {
- return {
- restrict: 'E',
- template,
- controller: function ($scope) {
- $scope.functions = {
- list: [],
- details: null,
- };
-
- $scope.activeTab = 'funcref';
- $scope.activateTab = function (tabName) {
- $scope.activeTab = tabName;
- };
-
- function init() {
- $scope.es = {
- invalidCount: 0,
- };
-
- $scope.translations = {
- nextButtonLabel: i18n.translate('timelion.help.nextPageButtonLabel', {
- defaultMessage: 'Next',
- }),
- previousButtonLabel: i18n.translate('timelion.help.previousPageButtonLabel', {
- defaultMessage: 'Previous',
- }),
- dontShowHelpButtonLabel: i18n.translate('timelion.help.dontShowHelpButtonLabel', {
- defaultMessage: `Don't show this again`,
- }),
- strongNextText: i18n.translate('timelion.help.welcome.content.strongNextText', {
- defaultMessage: 'Next',
- }),
- emphasizedEverythingText: i18n.translate(
- 'timelion.help.welcome.content.emphasizedEverythingText',
- {
- defaultMessage: 'everything',
- }
- ),
- notValidAdvancedSettingsPath: i18n.translate(
- 'timelion.help.configuration.notValid.advancedSettingsPathText',
- {
- defaultMessage: 'Management / Kibana / Advanced Settings',
- }
- ),
- validAdvancedSettingsPath: i18n.translate(
- 'timelion.help.configuration.valid.advancedSettingsPathText',
- {
- defaultMessage: 'Management/Kibana/Advanced Settings',
- }
- ),
- esAsteriskQueryDescription: i18n.translate(
- 'timelion.help.querying.esAsteriskQueryDescriptionText',
- {
- defaultMessage: 'hey Elasticsearch, find everything in my default index',
- }
- ),
- esIndexQueryDescription: i18n.translate(
- 'timelion.help.querying.esIndexQueryDescriptionText',
- {
- defaultMessage: 'use * as the q (query) for the logstash-* index',
- }
- ),
- strongAddText: i18n.translate('timelion.help.expressions.strongAddText', {
- defaultMessage: 'Add',
- }),
- twoExpressionsDescriptionTitle: i18n.translate(
- 'timelion.help.expressions.examples.twoExpressionsDescriptionTitle',
- {
- defaultMessage: 'Double the fun.',
- }
- ),
- customStylingDescriptionTitle: i18n.translate(
- 'timelion.help.expressions.examples.customStylingDescriptionTitle',
- {
- defaultMessage: 'Custom styling.',
- }
- ),
- namedArgumentsDescriptionTitle: i18n.translate(
- 'timelion.help.expressions.examples.namedArgumentsDescriptionTitle',
- {
- defaultMessage: 'Named arguments.',
- }
- ),
- groupedExpressionsDescriptionTitle: i18n.translate(
- 'timelion.help.expressions.examples.groupedExpressionsDescriptionTitle',
- {
- defaultMessage: 'Grouped expressions.',
- }
- ),
- };
-
- getFunctions();
- checkElasticsearch();
- }
-
- function getFunctions() {
- return $http.get('../api/timelion/functions').then(function (resp) {
- $scope.functions.list = resp.data;
- });
- }
- $scope.recheckElasticsearch = function () {
- $scope.es.valid = null;
- checkElasticsearch().then(function (valid) {
- if (!valid) $scope.es.invalidCount++;
- });
- };
-
- function checkElasticsearch() {
- return $http.get('../api/timelion/validate/es').then(function (resp) {
- if (resp.data.ok) {
- $scope.es.valid = true;
- $scope.es.stats = {
- min: moment(resp.data.min).format('LLL'),
- max: moment(resp.data.max).format('LLL'),
- field: resp.data.field,
- };
- } else {
- $scope.es.valid = false;
- $scope.es.invalidReason = (function () {
- try {
- const esResp = JSON.parse(resp.data.resp.response);
- return _.get(esResp, 'error.root_cause[0].reason');
- } catch (e) {
- if (_.get(resp, 'data.resp.message')) return _.get(resp, 'data.resp.message');
- if (_.get(resp, 'data.resp.output.payload.message'))
- return _.get(resp, 'data.resp.output.payload.message');
- return i18n.translate('timelion.help.unknownErrorMessage', {
- defaultMessage: 'Unknown error',
- });
- }
- })();
- }
- return $scope.es.valid;
- });
- }
- init();
- },
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/timelion_interval/_index.scss b/src/plugins/timelion/public/directives/timelion_interval/_index.scss
deleted file mode 100644
index 2a201f9b35a4d..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_interval/_index.scss
+++ /dev/null
@@ -1 +0,0 @@
-@import './timelion_interval';
diff --git a/src/plugins/timelion/public/directives/timelion_interval/_timelion_interval.scss b/src/plugins/timelion/public/directives/timelion_interval/_timelion_interval.scss
deleted file mode 100644
index 7ce09155cafd8..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_interval/_timelion_interval.scss
+++ /dev/null
@@ -1,30 +0,0 @@
-timelion-interval {
- display: flex;
-}
-
-.timInterval__input {
- width: $euiSizeXL * 2;
- padding: $euiSizeXS $euiSizeM;
- color: $euiColorDarkestShade;
- border: 1px solid $euiColorLightShade;
- border-radius: $euiSizeXS;
- transition: border-color .1s linear;
- font-size: 14px;
-}
-
-.timInterval__input--compact {
- border-top-right-radius: 0;
- border-bottom-right-radius: 0;
-}
-
-.timInterval__presets {
- width: $euiSizeXL * 3;
-}
-
-.timInterval__presets--compact {
- width: $euiSizeXL * 1;
- padding-left: 0;
- border-left: none;
- border-top-left-radius: 0;
- border-bottom-left-radius: 0;
-}
diff --git a/src/plugins/timelion/public/directives/timelion_interval/timelion_interval.html b/src/plugins/timelion/public/directives/timelion_interval/timelion_interval.html
deleted file mode 100644
index 49009355e49f4..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_interval/timelion_interval.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
diff --git a/src/plugins/timelion/public/directives/timelion_interval/timelion_interval.js b/src/plugins/timelion/public/directives/timelion_interval/timelion_interval.js
deleted file mode 100644
index 55f50fff132eb..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_interval/timelion_interval.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import _ from 'lodash';
-import $ from 'jquery';
-import template from './timelion_interval.html';
-
-export function TimelionInterval($timeout) {
- return {
- restrict: 'E',
- scope: {
- // The interval model
- model: '=',
- changeInterval: '=',
- },
- template,
- link: function ($scope, $elem) {
- $scope.intervalOptions = ['auto', '1s', '1m', '1h', '1d', '1w', '1M', '1y', 'other'];
- $scope.intervalLabels = {
- auto: 'auto',
- '1s': '1 second',
- '1m': '1 minute',
- '1h': '1 hour',
- '1d': '1 day',
- '1w': '1 week',
- '1M': '1 month',
- '1y': '1 year',
- other: 'other',
- };
-
- $scope.$watch('model', function (newVal, oldVal) {
- // Only run this on initialization
- if (newVal !== oldVal || oldVal == null) return;
-
- if (_.includes($scope.intervalOptions, newVal)) {
- $scope.interval = newVal;
- } else {
- $scope.interval = 'other';
- }
-
- if (newVal !== 'other') {
- $scope.otherInterval = newVal;
- }
- });
-
- $scope.$watch('interval', function (newVal, oldVal) {
- if (newVal === oldVal || $scope.model === newVal) return;
-
- if (newVal === 'other') {
- $scope.otherInterval = oldVal;
- $scope.changeInterval($scope.otherInterval);
- $timeout(function () {
- $('input', $elem).select();
- }, 0);
- } else {
- $scope.otherInterval = $scope.interval;
- $scope.changeInterval($scope.interval);
- }
- });
-
- $scope.$watch('otherInterval', function (newVal, oldVal) {
- if (newVal === oldVal || $scope.model === newVal) return;
- $scope.changeInterval(newVal);
- });
- },
- };
-}
diff --git a/src/plugins/timelion/public/directives/timelion_load_sheet.js b/src/plugins/timelion/public/directives/timelion_load_sheet.js
deleted file mode 100644
index 83b8b4c2e262b..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_load_sheet.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import template from '../partials/load_sheet.html';
-
-export function initTimelionLoadSheetDirective(app) {
- app.directive('timelionLoad', function () {
- return {
- replace: true,
- restrict: 'E',
- template,
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/timelion_options_sheet.js b/src/plugins/timelion/public/directives/timelion_options_sheet.js
deleted file mode 100644
index b3560111d4152..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_options_sheet.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import template from '../partials/sheet_options.html';
-
-export function initTimelionOptionsSheetDirective(app) {
- app.directive('timelionOptions', function () {
- return {
- replace: true,
- restrict: 'E',
- template,
- };
- });
-}
diff --git a/src/plugins/timelion/public/directives/timelion_save_sheet.js b/src/plugins/timelion/public/directives/timelion_save_sheet.js
deleted file mode 100644
index 40289b1bb8353..0000000000000
--- a/src/plugins/timelion/public/directives/timelion_save_sheet.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import saveTemplate from '../partials/save_sheet.html';
-
-export function initTimelionSaveSheetDirective(app) {
- app.directive('timelionSave', function () {
- return {
- replace: true,
- restrict: 'E',
- template: saveTemplate,
- };
- });
-}
diff --git a/src/plugins/timelion/public/index.html b/src/plugins/timelion/public/index.html
deleted file mode 100644
index 3fb518e81e882..0000000000000
--- a/src/plugins/timelion/public/index.html
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/plugins/timelion/public/index.scss b/src/plugins/timelion/public/index.scss
deleted file mode 100644
index 7a4259b2a17c8..0000000000000
--- a/src/plugins/timelion/public/index.scss
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Timelion plugin styles */
-
-// Prefix all styles with "tim" to avoid conflicts.
-// Examples
-// timChart
-// timChart__legend
-// timChart__legend--small
-// timChart__legend-isLoading
-
-@import './app';
-@import './base';
-@import './directives/index';
-
-// these styles is needed to be loaded here explicitly if the timelion visualization was not opened in browser
-// styles for timelion visualization are lazy loaded only while a vis is opened
-// this will duplicate styles only if both Timelion app and timelion visualization are loaded
-// could be left here as it is since the Timelion app is deprecated
-@import '../../vis_type_timelion/public/legacy/timelion_vis.scss';
diff --git a/src/plugins/timelion/public/index.ts b/src/plugins/timelion/public/index.ts
deleted file mode 100644
index 866d8a4ad20a2..0000000000000
--- a/src/plugins/timelion/public/index.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { PluginInitializerContext } from 'kibana/public';
-import { TimelionPlugin as Plugin } from './plugin';
-
-export function plugin(initializerContext: PluginInitializerContext) {
- return new Plugin(initializerContext);
-}
diff --git a/src/plugins/timelion/public/lib/observe_resize.js b/src/plugins/timelion/public/lib/observe_resize.js
deleted file mode 100644
index d2902a59821c3..0000000000000
--- a/src/plugins/timelion/public/lib/observe_resize.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-export default function ($elem, fn, frequency) {
- frequency = frequency || 500;
- let currentHeight = $elem.height();
- let currentWidth = $elem.width();
-
- let timeout;
-
- function checkLoop() {
- timeout = setTimeout(function () {
- if (currentHeight !== $elem.height() || currentWidth !== $elem.width()) {
- currentHeight = $elem.height();
- currentWidth = $elem.width();
-
- if (currentWidth > 0 && currentWidth > 0) fn();
- }
- checkLoop();
- }, frequency);
- }
-
- checkLoop();
-
- return function () {
- clearTimeout(timeout);
- };
-}
diff --git a/src/plugins/timelion/public/panels/panel.ts b/src/plugins/timelion/public/panels/panel.ts
deleted file mode 100644
index 333634976eba1..0000000000000
--- a/src/plugins/timelion/public/panels/panel.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { i18n } from '@kbn/i18n';
-
-interface PanelConfig {
- help?: string;
- render?: Function;
-}
-
-export class Panel {
- name: string;
- help: string;
- render: Function | undefined;
-
- constructor(name: string, config: PanelConfig) {
- this.name = name;
- this.help = config.help || '';
- this.render = config.render;
-
- if (!config.render) {
- throw new Error(
- i18n.translate('timelion.panels.noRenderFunctionErrorMessage', {
- defaultMessage: 'Panel must have a rendering function',
- })
- );
- }
- }
-}
diff --git a/src/plugins/timelion/public/panels/timechart/schema.ts b/src/plugins/timelion/public/panels/timechart/schema.ts
deleted file mode 100644
index dc26adc6ea5f5..0000000000000
--- a/src/plugins/timelion/public/panels/timechart/schema.ts
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import _ from 'lodash';
-import $ from 'jquery';
-import moment from 'moment-timezone';
-// @ts-ignore
-import observeResize from '../../lib/observe_resize';
-import { _LEGACY_ as visTypeTimelion } from '../../../../vis_type_timelion/public';
-import { TimelionVisualizationDependencies } from '../../application';
-
-const DEBOUNCE_DELAY = 50;
-
-export function timechartFn(dependencies: TimelionVisualizationDependencies) {
- const {
- $rootScope,
- $compile,
- uiSettings,
- data: {
- query: { timefilter },
- },
- } = dependencies;
-
- return function () {
- return {
- help: 'Draw a timeseries chart',
- render($scope: any, $elem: any) {
- const template = '';
- const formatters = visTypeTimelion.tickFormatters() as any;
- const getxAxisFormatter = visTypeTimelion.xaxisFormatterProvider(uiSettings);
- const generateTicks = visTypeTimelion.generateTicksProvider();
-
- // TODO: I wonder if we should supply our own moment that sets this every time?
- // could just use angular's injection to provide a moment service?
- moment.tz.setDefault(uiSettings.get('dateFormat:tz'));
-
- const render = $scope.seriesList.render || {};
-
- $scope.chart = $scope.seriesList.list;
- $scope.interval = $scope.interval;
- $scope.search = $scope.search || _.noop;
-
- let legendValueNumbers: any;
- let legendCaption: any;
- const debouncedSetLegendNumbers = _.debounce(setLegendNumbers, DEBOUNCE_DELAY, {
- maxWait: DEBOUNCE_DELAY,
- leading: true,
- trailing: false,
- });
- // ensure legend is the same height with or without a caption so legend items do not move around
- const emptyCaption = ' ';
-
- const defaultOptions = {
- xaxis: {
- mode: 'time',
- tickLength: 5,
- timezone: 'browser',
- },
- selection: {
- mode: 'x',
- color: '#ccc',
- },
- crosshair: {
- mode: 'x',
- color: '#C66',
- lineWidth: 2,
- },
- grid: {
- show: render.grid,
- borderWidth: 0,
- borderColor: null,
- margin: 10,
- hoverable: true,
- autoHighlight: false,
- },
- legend: {
- backgroundColor: 'rgb(255,255,255,0)',
- position: 'nw',
- labelBoxBorderColor: 'rgb(255,255,255,0)',
- labelFormatter(label: any, series: any) {
- const wrapperSpan = document.createElement('span');
- const labelSpan = document.createElement('span');
- const numberSpan = document.createElement('span');
-
- wrapperSpan.setAttribute('class', 'ngLegendValue');
- wrapperSpan.setAttribute('kbn-accessible-click', '');
- wrapperSpan.setAttribute('ng-click', `toggleSeries(${series._id})`);
- wrapperSpan.setAttribute('ng-focus', `focusSeries(${series._id})`);
- wrapperSpan.setAttribute('ng-mouseover', `highlightSeries(${series._id})`);
-
- labelSpan.setAttribute('ng-non-bindable', '');
- labelSpan.appendChild(document.createTextNode(label));
- numberSpan.setAttribute('class', 'ngLegendValueNumber');
-
- wrapperSpan.appendChild(labelSpan);
- wrapperSpan.appendChild(numberSpan);
-
- return wrapperSpan.outerHTML;
- },
- },
- colors: [
- '#01A4A4',
- '#C66',
- '#D0D102',
- '#616161',
- '#00A1CB',
- '#32742C',
- '#F18D05',
- '#113F8C',
- '#61AE24',
- '#D70060',
- ],
- };
-
- const originalColorMap = new Map();
- $scope.chart.forEach((series: any, seriesIndex: any) => {
- if (!series.color) {
- const colorIndex = seriesIndex % defaultOptions.colors.length;
- series.color = defaultOptions.colors[colorIndex];
- }
- originalColorMap.set(series, series.color);
- });
-
- let highlightedSeries: any;
- let focusedSeries: any;
- function unhighlightSeries() {
- if (highlightedSeries === null) {
- return;
- }
-
- highlightedSeries = null;
- focusedSeries = null;
- $scope.chart.forEach((series: any) => {
- series.color = originalColorMap.get(series); // reset the colors
- });
- drawPlot($scope.chart);
- }
- $scope.highlightSeries = _.debounce(function (id: any) {
- if (highlightedSeries === id) {
- return;
- }
-
- highlightedSeries = id;
- $scope.chart.forEach((series: any, seriesIndex: any) => {
- if (seriesIndex !== id) {
- series.color = 'rgba(128,128,128,0.1)'; // mark as grey
- } else {
- series.color = originalColorMap.get(series); // color it like it was
- }
- });
- drawPlot($scope.chart);
- }, DEBOUNCE_DELAY);
- $scope.focusSeries = function (id: any) {
- focusedSeries = id;
- $scope.highlightSeries(id);
- };
-
- $scope.toggleSeries = function (id: any) {
- const series = $scope.chart[id];
- series._hide = !series._hide;
- drawPlot($scope.chart);
- };
-
- const cancelResize = observeResize($elem, function () {
- drawPlot($scope.chart);
- });
-
- $scope.$on('$destroy', function () {
- cancelResize();
- $elem.off('plothover');
- $elem.off('plotselected');
- $elem.off('mouseleave');
- });
-
- $elem.on('plothover', function (event: any, pos: any, item: any) {
- $rootScope.$broadcast('timelionPlotHover', event, pos, item);
- });
-
- $elem.on('plotselected', function (event: any, ranges: any) {
- timefilter.timefilter.setTime({
- from: moment(ranges.xaxis.from),
- to: moment(ranges.xaxis.to),
- });
- });
-
- $elem.on('mouseleave', function () {
- $rootScope.$broadcast('timelionPlotLeave');
- });
-
- $scope.$on('timelionPlotHover', function (angularEvent: any, flotEvent: any, pos: any) {
- if (!$scope.plot) return;
- $scope.plot.setCrosshair(pos);
- debouncedSetLegendNumbers(pos);
- });
-
- $scope.$on('timelionPlotLeave', function () {
- if (!$scope.plot) return;
- $scope.plot.clearCrosshair();
- clearLegendNumbers();
- });
-
- // Shamelessly borrowed from the flotCrosshairs example
- function setLegendNumbers(pos: any) {
- unhighlightSeries();
-
- const plot = $scope.plot;
-
- const axes = plot.getAxes();
- if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max) {
- return;
- }
-
- let i;
- const dataset = plot.getData();
- if (legendCaption) {
- legendCaption.text(
- moment(pos.x).format(
- _.get(dataset, '[0]._global.legend.timeFormat', visTypeTimelion.DEFAULT_TIME_FORMAT)
- )
- );
- }
- for (i = 0; i < dataset.length; ++i) {
- const series = dataset[i];
- const useNearestPoint = series.lines.show && !series.lines.steps;
- const precision = _.get(series, '_meta.precision', 2);
-
- if (series._hide) continue;
-
- const currentPoint = series.data.find((point: any, index: number) => {
- if (index + 1 === series.data.length) {
- return true;
- }
- if (useNearestPoint) {
- return pos.x - point[0] < series.data[index + 1][0] - pos.x;
- } else {
- return pos.x < series.data[index + 1][0];
- }
- });
-
- const y = currentPoint[1];
-
- if (y != null) {
- let label = y.toFixed(precision);
- if (series.yaxis.tickFormatter) {
- label = series.yaxis.tickFormatter(label, series.yaxis);
- }
- legendValueNumbers.eq(i).text(`(${label})`);
- } else {
- legendValueNumbers.eq(i).empty();
- }
- }
- }
-
- function clearLegendNumbers() {
- if (legendCaption) {
- legendCaption.html(emptyCaption);
- }
- _.each(legendValueNumbers, function (num) {
- $(num).empty();
- });
- }
-
- let legendScope = $scope.$new();
- function drawPlot(plotConfig: any) {
- if (!$('.chart-canvas', $elem).length) $elem.html(template);
- const canvasElem = $('.chart-canvas', $elem);
-
- // we can't use `$.plot` to draw the chart when the height or width is 0
- // so, we'll need another event to trigger drawPlot to actually draw it
- if (canvasElem.height() === 0 || canvasElem.width() === 0) {
- return;
- }
-
- const title = _(plotConfig).map('_title').compact().last() as any;
- $('.chart-top-title', $elem).text(title == null ? '' : title);
-
- const options = _.cloneDeep(defaultOptions) as any;
-
- // Get the X-axis tick format
- const time = timefilter.timefilter.getBounds() as any;
- const interval = visTypeTimelion.calculateInterval(
- time.min.valueOf(),
- time.max.valueOf(),
- uiSettings.get('timelion:target_buckets') || 200,
- $scope.interval,
- uiSettings.get('timelion:min_interval') || '1ms'
- );
- const format = getxAxisFormatter(interval);
-
- // Use moment to format ticks so we get timezone correction
- options.xaxis.tickFormatter = function (val: any) {
- return moment(val).format(format);
- };
-
- // Calculate how many ticks can fit on the axis
- const tickLetterWidth = 7;
- const tickPadding = 45;
- options.xaxis.ticks = Math.floor(
- $elem.width() / (format.length * tickLetterWidth + tickPadding)
- );
-
- const series = _.map(plotConfig, function (serie: any, index) {
- serie = _.cloneDeep(
- _.defaults(serie, {
- shadowSize: 0,
- lines: {
- lineWidth: 3,
- },
- })
- );
- serie._id = index;
-
- if (serie.color) {
- const span = document.createElement('span');
- span.style.color = serie.color;
- serie.color = span.style.color;
- }
-
- if (serie._hide) {
- serie.data = [];
- serie.stack = false;
- // serie.color = "#ddd";
- serie.label = '(hidden) ' + serie.label;
- }
-
- if (serie._global) {
- _.mergeWith(options, serie._global, function (objVal, srcVal) {
- // This is kind of gross, it means that you can't replace a global value with a null
- // best you can do is an empty string. Deal with it.
- if (objVal == null) return srcVal;
- if (srcVal == null) return objVal;
- });
- }
-
- return serie;
- });
-
- if (options.yaxes) {
- options.yaxes.forEach((yaxis: any) => {
- if (yaxis && yaxis.units) {
- yaxis.tickFormatter = formatters[yaxis.units.type];
- const byteModes = ['bytes', 'bytes/s'];
- if (byteModes.includes(yaxis.units.type)) {
- yaxis.tickGenerator = generateTicks;
- }
- }
- });
- }
-
- // @ts-ignore
- $scope.plot = $.plot(canvasElem, _.compact(series), options);
-
- if ($scope.plot) {
- $scope.$emit('timelionChartRendered');
- }
-
- legendScope.$destroy();
- legendScope = $scope.$new();
- // Used to toggle the series, and for displaying values on hover
- legendValueNumbers = canvasElem.find('.ngLegendValueNumber');
- _.each(canvasElem.find('.ngLegendValue'), function (elem) {
- $compile(elem)(legendScope);
- });
-
- if (_.get($scope.plot.getData(), '[0]._global.legend.showTime', true)) {
- legendCaption = $('
');
- legendCaption.html(emptyCaption);
- canvasElem.find('div.legend table').append(legendCaption);
-
- // legend has been re-created. Apply focus on legend element when previously set
- if (focusedSeries || focusedSeries === 0) {
- const $legendLabels = canvasElem.find('div.legend table .legendLabel>span');
- $legendLabels.get(focusedSeries).focus();
- }
- }
- }
- $scope.$watch('chart', drawPlot);
- },
- };
- };
-}
diff --git a/src/plugins/timelion/public/panels/timechart/timechart.ts b/src/plugins/timelion/public/panels/timechart/timechart.ts
deleted file mode 100644
index 6af7096bcb282..0000000000000
--- a/src/plugins/timelion/public/panels/timechart/timechart.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { timechartFn } from './schema';
-import { Panel } from '../panel';
-import { TimelionVisualizationDependencies } from '../../application';
-
-export function getTimeChart(dependencies: TimelionVisualizationDependencies) {
- // Schema is broken out so that it may be extended for use in other plugins
- // Its also easier to test.
- return new Panel('timechart', timechartFn(dependencies)());
-}
diff --git a/src/plugins/timelion/public/partials/load_sheet.html b/src/plugins/timelion/public/partials/load_sheet.html
deleted file mode 100644
index 8d8cf7193416c..0000000000000
--- a/src/plugins/timelion/public/partials/load_sheet.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
diff --git a/src/plugins/timelion/public/partials/save_sheet.html b/src/plugins/timelion/public/partials/save_sheet.html
deleted file mode 100644
index 7773a9d25df71..0000000000000
--- a/src/plugins/timelion/public/partials/save_sheet.html
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/plugins/timelion/public/partials/sheet_options.html b/src/plugins/timelion/public/partials/sheet_options.html
deleted file mode 100644
index eae5709331659..0000000000000
--- a/src/plugins/timelion/public/partials/sheet_options.html
+++ /dev/null
@@ -1,36 +0,0 @@
-
diff --git a/src/plugins/timelion/public/plugin.ts b/src/plugins/timelion/public/plugin.ts
deleted file mode 100644
index 63ea9a38e2795..0000000000000
--- a/src/plugins/timelion/public/plugin.ts
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { BehaviorSubject } from 'rxjs';
-import { filter, map } from 'rxjs/operators';
-import {
- CoreSetup,
- Plugin,
- PluginInitializerContext,
- DEFAULT_APP_CATEGORIES,
- AppMountParameters,
- AppUpdater,
- ScopedHistory,
- AppNavLinkStatus,
-} from '../../../core/public';
-import { Panel } from './panels/panel';
-import { KibanaLegacyStart } from '../../kibana_legacy/public';
-import { createKbnUrlTracker } from '../../kibana_utils/public';
-import { DataPublicPluginStart, esFilters, DataPublicPluginSetup } from '../../data/public';
-import { NavigationPublicPluginStart } from '../../navigation/public';
-import { VisualizationsStart } from '../../visualizations/public';
-import { SavedObjectsStart } from '../../saved_objects/public';
-import {
- VisTypeTimelionPluginStart,
- VisTypeTimelionPluginSetup,
-} from '../../vis_type_timelion/public';
-
-export interface TimelionPluginSetupDependencies {
- data: DataPublicPluginSetup;
- visTypeTimelion: VisTypeTimelionPluginSetup;
-}
-
-export interface TimelionPluginStartDependencies {
- data: DataPublicPluginStart;
- navigation: NavigationPublicPluginStart;
- visualizations: VisualizationsStart;
- visTypeTimelion: VisTypeTimelionPluginStart;
- savedObjects: SavedObjectsStart;
- kibanaLegacy: KibanaLegacyStart;
-}
-
-/** @internal */
-export class TimelionPlugin
- implements Plugin {
- initializerContext: PluginInitializerContext;
- private appStateUpdater = new BehaviorSubject(() => ({}));
- private stopUrlTracking: (() => void) | undefined = undefined;
- private currentHistory: ScopedHistory | undefined = undefined;
-
- constructor(initializerContext: PluginInitializerContext) {
- this.initializerContext = initializerContext;
- }
-
- public setup(
- core: CoreSetup,
- {
- data,
- visTypeTimelion,
- }: { data: DataPublicPluginSetup; visTypeTimelion: VisTypeTimelionPluginSetup }
- ) {
- const timelionPanels: Map = new Map();
-
- const { appMounted, appUnMounted, stop: stopUrlTracker } = createKbnUrlTracker({
- baseUrl: core.http.basePath.prepend('/app/timelion'),
- defaultSubUrl: '#/',
- storageKey: `lastUrl:${core.http.basePath.get()}:timelion`,
- navLinkUpdater$: this.appStateUpdater,
- toastNotifications: core.notifications.toasts,
- stateParams: [
- {
- kbnUrlKey: '_g',
- stateUpdate$: data.query.state$.pipe(
- filter(
- ({ changes }) => !!(changes.globalFilters || changes.time || changes.refreshInterval)
- ),
- map(({ state }) => ({
- ...state,
- filters: state.filters?.filter(esFilters.isFilterPinned),
- }))
- ),
- },
- ],
- getHistory: () => this.currentHistory!,
- });
-
- this.stopUrlTracking = () => {
- stopUrlTracker();
- };
-
- core.application.register({
- id: 'timelion',
- title: 'Timelion',
- order: 8000,
- defaultPath: '#/',
- euiIconType: 'logoKibana',
- category: DEFAULT_APP_CATEGORIES.kibana,
- navLinkStatus:
- visTypeTimelion.isUiEnabled === false ? AppNavLinkStatus.hidden : AppNavLinkStatus.default,
- mount: async (params: AppMountParameters) => {
- const [coreStart, pluginsStart] = await core.getStartServices();
- await pluginsStart.kibanaLegacy.loadAngularBootstrap();
- this.currentHistory = params.history;
-
- appMounted();
-
- const unlistenParentHistory = params.history.listen(() => {
- window.dispatchEvent(new HashChangeEvent('hashchange'));
- });
-
- const { renderApp } = await import('./application');
- params.element.classList.add('timelionAppContainer');
- const unmount = renderApp({
- mountParams: params,
- pluginInitializerContext: this.initializerContext,
- timelionPanels,
- core: coreStart,
- plugins: pluginsStart,
- });
- return () => {
- unlistenParentHistory();
- unmount();
- appUnMounted();
- };
- },
- });
- }
-
- public start() {}
-
- public stop(): void {
- if (this.stopUrlTracking) {
- this.stopUrlTracking();
- }
- }
-}
diff --git a/src/plugins/timelion/public/services/_saved_sheet.ts b/src/plugins/timelion/public/services/_saved_sheet.ts
deleted file mode 100644
index a903c70aad69b..0000000000000
--- a/src/plugins/timelion/public/services/_saved_sheet.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { IUiSettingsClient } from 'kibana/public';
-import { SavedObjectsStart } from '../../../saved_objects/public';
-
-// Used only by the savedSheets service, usually no reason to change this
-export function createSavedSheetClass(savedObjects: SavedObjectsStart, config: IUiSettingsClient) {
- class SavedSheet extends savedObjects.SavedObjectClass {
- static type = 'timelion-sheet';
-
- // if type:sheet has no mapping, we push this mapping into ES
- static mapping = {
- title: 'text',
- hits: 'integer',
- description: 'text',
- timelion_sheet: 'text',
- timelion_interval: 'keyword',
- timelion_other_interval: 'keyword',
- timelion_chart_height: 'integer',
- timelion_columns: 'integer',
- timelion_rows: 'integer',
- version: 'integer',
- };
-
- // Order these fields to the top, the rest are alphabetical
- static fieldOrder = ['title', 'description'];
- // SavedSheet constructor. Usually you'd interact with an instance of this.
- // ID is option, without it one will be generated on save.
- constructor(id: string) {
- super({
- type: SavedSheet.type,
- mapping: SavedSheet.mapping,
-
- // if this is null/undefined then the SavedObject will be assigned the defaults
- id,
-
- // default values that will get assigned if the doc is new
- defaults: {
- title: 'New TimeLion Sheet',
- hits: 0,
- description: '',
- timelion_sheet: ['.es(*)'],
- timelion_interval: 'auto',
- timelion_chart_height: 275,
- timelion_columns: config.get('timelion:default_columns') || 2,
- timelion_rows: config.get('timelion:default_rows') || 2,
- version: 1,
- },
- });
- this.showInRecentlyAccessed = true;
- this.getFullPath = () => `/app/timelion#/${this.id}`;
- }
- }
-
- return SavedSheet as unknown;
-}
diff --git a/src/plugins/timelion/public/services/saved_sheets.ts b/src/plugins/timelion/public/services/saved_sheets.ts
deleted file mode 100644
index 373bb895c9806..0000000000000
--- a/src/plugins/timelion/public/services/saved_sheets.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { SavedObjectLoader } from '../../../saved_objects/public';
-import { createSavedSheetClass } from './_saved_sheet';
-import { RenderDeps } from '../application';
-
-export function initSavedSheetService(app: angular.IModule, deps: RenderDeps) {
- const savedObjectsClient = deps.core.savedObjects.client;
- const SavedSheet = createSavedSheetClass(deps.plugins.savedObjects, deps.core.uiSettings);
-
- const savedSheetLoader = new SavedObjectLoader(SavedSheet, savedObjectsClient);
- savedSheetLoader.urlFor = (id) => `#/${encodeURIComponent(id)}`;
- // Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'.
- savedSheetLoader.loaderProperties = {
- name: 'timelion-sheet',
- noun: 'Saved Sheets',
- nouns: 'saved sheets',
- };
- // This is the only thing that gets injected into controllers
- app.service('savedSheets', function () {
- return savedSheetLoader;
- });
-
- return savedSheetLoader;
-}
diff --git a/src/plugins/timelion/public/timelion_app_state.ts b/src/plugins/timelion/public/timelion_app_state.ts
deleted file mode 100644
index 348a97583d37b..0000000000000
--- a/src/plugins/timelion/public/timelion_app_state.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { createStateContainer, syncState, IKbnUrlStateStorage } from '../../kibana_utils/public';
-
-import { TimelionAppState, TimelionAppStateTransitions } from './types';
-
-const STATE_STORAGE_KEY = '_a';
-
-interface Arguments {
- kbnUrlStateStorage: IKbnUrlStateStorage;
- stateDefaults: TimelionAppState;
-}
-
-export function initTimelionAppState({ stateDefaults, kbnUrlStateStorage }: Arguments) {
- const urlState = kbnUrlStateStorage.get(STATE_STORAGE_KEY);
- const initialState = {
- ...stateDefaults,
- ...urlState,
- };
-
- /*
- make sure url ('_a') matches initial state
- Initializing appState does two things - first it translates the defaults into AppState,
- second it updates appState based on the url (the url trumps the defaults). This means if
- we update the state format at all and want to handle BWC, we must not only migrate the
- data stored with saved vis, but also any old state in the url.
- */
- kbnUrlStateStorage.set(STATE_STORAGE_KEY, initialState, { replace: true });
-
- const stateContainer = createStateContainer(
- initialState,
- {
- set: (state) => (prop, value) => ({ ...state, [prop]: value }),
- updateState: (state) => (newValues) => ({ ...state, ...newValues }),
- }
- );
-
- const { start: startStateSync, stop: stopStateSync } = syncState({
- storageKey: STATE_STORAGE_KEY,
- stateContainer: {
- ...stateContainer,
- set: (state) => {
- if (state) {
- // syncState utils requires to handle incoming "null" value
- stateContainer.set(state);
- }
- },
- },
- stateStorage: kbnUrlStateStorage,
- });
-
- // start syncing the appState with the ('_a') url
- startStateSync();
-
- return { stateContainer, stopStateSync };
-}
diff --git a/src/plugins/timelion/public/types.ts b/src/plugins/timelion/public/types.ts
deleted file mode 100644
index bfdbd3878ec23..0000000000000
--- a/src/plugins/timelion/public/types.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-export interface TimelionAppState {
- sheet: string[];
- selected: number;
- columns: number;
- rows: number;
- interval: string;
-}
-
-export interface TimelionAppStateTransitions {
- set: (
- state: TimelionAppState
- ) => (prop: T, value: TimelionAppState[T]) => TimelionAppState;
- updateState: (
- state: TimelionAppState
- ) => (newValues: Partial) => TimelionAppState;
-}
diff --git a/src/plugins/timelion/server/config.ts b/src/plugins/timelion/server/config.ts
deleted file mode 100644
index d74c4c237b2b7..0000000000000
--- a/src/plugins/timelion/server/config.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { schema, TypeOf } from '@kbn/config-schema';
-
-export const configSchema = {
- schema: schema.object({
- graphiteUrls: schema.maybe(schema.arrayOf(schema.string())),
- enabled: schema.boolean({ defaultValue: true }),
- ui: schema.object({
- enabled: schema.boolean({ defaultValue: true }),
- }),
- }),
-};
-
-export type TimelionConfigType = TypeOf;
diff --git a/src/plugins/timelion/server/deprecations.ts b/src/plugins/timelion/server/deprecations.ts
deleted file mode 100644
index 2358dd313b74f..0000000000000
--- a/src/plugins/timelion/server/deprecations.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import {
- CoreStart,
- SavedObjectsClient,
- Logger,
- GetDeprecationsContext,
- DeprecationsDetails,
-} from 'src/core/server';
-
-export const getTimelionSheetsCount = async (
- savedObjectsClient: Pick
-) => {
- const { total } = await savedObjectsClient.find({ type: 'timelion-sheet', perPage: 1 });
- return total;
-};
-
-export const showWarningMessageIfTimelionSheetWasFound = async (
- core: CoreStart,
- logger: Logger
-) => {
- const { savedObjects } = core;
- const savedObjectsClient = savedObjects.createInternalRepository();
- const count = await getTimelionSheetsCount(savedObjectsClient);
- if (count > 0) {
- logger.warn(
- 'Deprecated since 7.0, the Timelion app will be removed in 7.16. To continue using your Timelion worksheets, migrate them to a dashboard. See https://www.elastic.co/guide/en/kibana/current/create-panels-with-timelion.html.'
- );
- }
-};
-
-/**
- * Deprecated since 7.0, the Timelion app will be removed in 8.0.
- * To continue using your Timelion worksheets, migrate them to a dashboard.
- *
- * @link https://www.elastic.co/guide/en/kibana/master/timelion.html#timelion-deprecation
- **/
-export async function getDeprecations({
- savedObjectsClient,
-}: GetDeprecationsContext): Promise {
- const deprecations: DeprecationsDetails[] = [];
- const count = await getTimelionSheetsCount(savedObjectsClient);
-
- if (count > 0) {
- deprecations.push({
- title: 'Found Timelion worksheets',
- message: `You have ${count} Timelion worksheets. The Timelion app will be removed in 7.16. To continue using your Timelion worksheets, migrate them to a dashboard.`,
- documentationUrl:
- 'https://www.elastic.co/guide/en/kibana/current/create-panels-with-timelion.html',
- level: 'warning',
- correctiveActions: {
- manualSteps: [
- 'Navigate to the Kibana Dashboard and click "Create dashboard".',
- 'Select Timelion from the "New Visualization" window.',
- 'Open a new tab, open the Timelion app, select the chart you want to copy, then copy the chart expression.',
- 'Go to Timelion, paste the chart expression in the Timelion expression field, then click Update.',
- 'In the toolbar, click Save.',
- 'On the Save visualization window, enter the visualization Title, then click Save and return.',
- ],
- },
- });
- }
-
- return deprecations;
-}
diff --git a/src/plugins/timelion/server/index.ts b/src/plugins/timelion/server/index.ts
deleted file mode 100644
index fb77df100766a..0000000000000
--- a/src/plugins/timelion/server/index.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { PluginInitializerContext, PluginConfigDescriptor } from 'src/core/server';
-import { TimelionPlugin } from './plugin';
-import { configSchema, TimelionConfigType } from './config';
-
-export const config: PluginConfigDescriptor = {
- schema: configSchema.schema,
-};
-
-export const plugin = (context: PluginInitializerContext) =>
- new TimelionPlugin(context);
diff --git a/src/plugins/timelion/server/plugin.ts b/src/plugins/timelion/server/plugin.ts
deleted file mode 100644
index edbba9b565ae4..0000000000000
--- a/src/plugins/timelion/server/plugin.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { CoreSetup, CoreStart, Plugin, PluginInitializerContext, Logger } from 'src/core/server';
-import { i18n } from '@kbn/i18n';
-import { schema } from '@kbn/config-schema';
-import { TimelionConfigType } from './config';
-import { timelionSheetSavedObjectType } from './saved_objects';
-import { getDeprecations, showWarningMessageIfTimelionSheetWasFound } from './deprecations';
-
-export class TimelionPlugin implements Plugin {
- private logger: Logger;
-
- constructor(context: PluginInitializerContext) {
- this.logger = context.logger.get();
- }
-
- public setup(core: CoreSetup) {
- core.capabilities.registerProvider(() => ({
- timelion: {
- save: true,
- show: true,
- },
- }));
- core.savedObjects.registerType(timelionSheetSavedObjectType);
-
- core.uiSettings.register({
- 'timelion:showTutorial': {
- name: i18n.translate('timelion.uiSettings.showTutorialLabel', {
- defaultMessage: 'Show tutorial',
- }),
- value: false,
- description: i18n.translate('timelion.uiSettings.showTutorialDescription', {
- defaultMessage: 'Should I show the tutorial by default when entering the timelion app?',
- }),
- category: ['timelion'],
- schema: schema.boolean(),
- },
- 'timelion:default_columns': {
- name: i18n.translate('timelion.uiSettings.defaultColumnsLabel', {
- defaultMessage: 'Default columns',
- }),
- value: 2,
- description: i18n.translate('timelion.uiSettings.defaultColumnsDescription', {
- defaultMessage: 'Number of columns on a timelion sheet by default',
- }),
- category: ['timelion'],
- schema: schema.number(),
- },
- 'timelion:default_rows': {
- name: i18n.translate('timelion.uiSettings.defaultRowsLabel', {
- defaultMessage: 'Default rows',
- }),
- value: 2,
- description: i18n.translate('timelion.uiSettings.defaultRowsDescription', {
- defaultMessage: 'Number of rows on a timelion sheet by default',
- }),
- category: ['timelion'],
- schema: schema.number(),
- },
- });
-
- core.deprecations.registerDeprecations({ getDeprecations });
- }
- start(core: CoreStart) {
- showWarningMessageIfTimelionSheetWasFound(core, this.logger);
- }
- stop() {}
-}
diff --git a/src/plugins/timelion/server/saved_objects/index.ts b/src/plugins/timelion/server/saved_objects/index.ts
deleted file mode 100644
index 0dd070958d09a..0000000000000
--- a/src/plugins/timelion/server/saved_objects/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-export { timelionSheetSavedObjectType } from './timelion_sheet';
diff --git a/src/plugins/timelion/server/saved_objects/timelion_sheet.ts b/src/plugins/timelion/server/saved_objects/timelion_sheet.ts
deleted file mode 100644
index 231e049280bb1..0000000000000
--- a/src/plugins/timelion/server/saved_objects/timelion_sheet.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import { SavedObjectsType } from 'kibana/server';
-
-export const timelionSheetSavedObjectType: SavedObjectsType = {
- name: 'timelion-sheet',
- hidden: false,
- namespaceType: 'single',
- management: {
- icon: 'visTimelion',
- defaultSearchField: 'title',
- importableAndExportable: true,
- getTitle(obj) {
- return obj.attributes.title;
- },
- getInAppUrl(obj) {
- return {
- path: `/app/timelion#/${encodeURIComponent(obj.id)}`,
- uiCapabilitiesPath: 'timelion.show',
- };
- },
- },
- mappings: {
- properties: {
- description: { type: 'text' },
- hits: { type: 'integer' },
- kibanaSavedObjectMeta: {
- properties: {
- searchSourceJSON: { type: 'text' },
- },
- },
- timelion_chart_height: { type: 'integer' },
- timelion_columns: { type: 'integer' },
- timelion_interval: { type: 'keyword' },
- timelion_other_interval: { type: 'keyword' },
- timelion_rows: { type: 'integer' },
- timelion_sheet: { type: 'text' },
- title: { type: 'text' },
- version: { type: 'integer' },
- },
- },
-};
diff --git a/src/plugins/timelion/tsconfig.json b/src/plugins/timelion/tsconfig.json
deleted file mode 100644
index 594901c3cc1ed..0000000000000
--- a/src/plugins/timelion/tsconfig.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "extends": "../../../tsconfig.base.json",
- "compilerOptions": {
- "outDir": "./target/types",
- "emitDeclarationOnly": true,
- "declaration": true,
- "declarationMap": true
- },
- "include": [
- "public/**/*",
- "server/**/*"
- ],
- "references": [
- { "path": "../../core/tsconfig.json" },
- { "path": "../data/tsconfig.json" },
- { "path": "../visualizations/tsconfig.json" },
- { "path": "../navigation/tsconfig.json" },
- { "path": "../vis_type_timelion/tsconfig.json" },
- { "path": "../saved_objects/tsconfig.json" },
- { "path": "../kibana_legacy/tsconfig.json" },
- ]
-}
diff --git a/src/plugins/vis_type_timelion/config.ts b/src/plugins/vis_type_timelion/config.ts
index aa88d786af51e..cfd3d13c277e9 100644
--- a/src/plugins/vis_type_timelion/config.ts
+++ b/src/plugins/vis_type_timelion/config.ts
@@ -8,14 +8,9 @@
import { schema, TypeOf } from '@kbn/config-schema';
-export const configSchema = schema.object(
- {
- enabled: schema.boolean({ defaultValue: true }),
- ui: schema.object({ enabled: schema.boolean({ defaultValue: false }) }),
- graphiteUrls: schema.maybe(schema.arrayOf(schema.string())),
- },
- // This option should be removed as soon as we entirely migrate config from legacy Timelion plugin.
- { unknowns: 'allow' }
-);
+export const configSchema = schema.object({
+ graphiteUrls: schema.maybe(schema.arrayOf(schema.string())),
+ enabled: schema.boolean({ defaultValue: true }),
+});
export type ConfigSchema = TypeOf;
diff --git a/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx b/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx
index d518d9718d5e7..569ddf03c941b 100644
--- a/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx
+++ b/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx
@@ -96,7 +96,7 @@ function TimelionExpressionInput({ value, setValue }: TimelionExpressionInputPro