From b3d8443103c23b0affb9f8dcedd950a0a6515aa7 Mon Sep 17 00:00:00 2001 From: Ashwin P Chandran Date: Tue, 19 Sep 2023 00:08:50 +0000 Subject: [PATCH] Deangular: removes angular paginate, cleanup data plugin and tilemap Signed-off-by: Ashwin P Chandran --- .../common/search/aggs/utils/prop_filter.ts | 2 +- .../search/aggs/utils/to_angular_json.ts | 1 + .../public/index.ts | 1 - .../public/paginate/_paginate.scss | 58 ----- .../public/paginate/paginate.d.ts | 32 --- .../public/paginate/paginate.js | 242 ------------------ .../public/paginate/paginate_controls.html | 98 ------- src/plugins/tile_map/public/plugin.ts | 2 - yarn.lock | 5 - 9 files changed, 2 insertions(+), 439 deletions(-) delete mode 100644 src/plugins/opensearch_dashboards_legacy/public/paginate/_paginate.scss delete mode 100644 src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.d.ts delete mode 100644 src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.js delete mode 100644 src/plugins/opensearch_dashboards_legacy/public/paginate/paginate_controls.html diff --git a/src/plugins/data/common/search/aggs/utils/prop_filter.ts b/src/plugins/data/common/search/aggs/utils/prop_filter.ts index 341032e47bf6..2670e3d26b82 100644 --- a/src/plugins/data/common/search/aggs/utils/prop_filter.ts +++ b/src/plugins/data/common/search/aggs/utils/prop_filter.ts @@ -37,7 +37,7 @@ type FilterFunc

= (item: T[P]) => boolean; * - fieldType filters a list of fields by their type property * - aggFilter filters a list of aggs by their name property * - * @returns the filter function which can be registered with angular + * @returns the filter function */ export function propFilter

(prop: P) { /** diff --git a/src/plugins/data/common/search/aggs/utils/to_angular_json.ts b/src/plugins/data/common/search/aggs/utils/to_angular_json.ts index 0efafa7884a1..3eac6a1fcfe4 100644 --- a/src/plugins/data/common/search/aggs/utils/to_angular_json.ts +++ b/src/plugins/data/common/search/aggs/utils/to_angular_json.ts @@ -33,6 +33,7 @@ * https://github.com/angular/angular.js/blob/master/src/Angular.js#L1312 * * @internal + * @deprecated This function will be removed in the next major version. */ export function toAngularJSON(obj: any, pretty?: any): string { if (obj === undefined) return ''; diff --git a/src/plugins/opensearch_dashboards_legacy/public/index.ts b/src/plugins/opensearch_dashboards_legacy/public/index.ts index ec74afc903f6..453bfd64dc82 100644 --- a/src/plugins/opensearch_dashboards_legacy/public/index.ts +++ b/src/plugins/opensearch_dashboards_legacy/public/index.ts @@ -36,6 +36,5 @@ export const plugin = (initializerContext: PluginInitializerContext) => export * from './plugin'; -export { PaginateDirectiveProvider, PaginateControlsDirectiveProvider } from './paginate/paginate'; export * from './notify'; export * from './utils'; diff --git a/src/plugins/opensearch_dashboards_legacy/public/paginate/_paginate.scss b/src/plugins/opensearch_dashboards_legacy/public/paginate/_paginate.scss deleted file mode 100644 index ec346aa843c1..000000000000 --- a/src/plugins/opensearch_dashboards_legacy/public/paginate/_paginate.scss +++ /dev/null @@ -1,58 +0,0 @@ -/* stylelint-disable-next-line selector-type-no-unknown */ -paginate { - display: block; - - /* stylelint-disable-next-line selector-type-no-unknown */ - paginate-controls { - display: flex; - align-items: center; - padding: $euiSizeXS $euiSizeXS $euiSizeS; - text-align: center; - - .pagination-other-pages { - flex: 1 0 auto; - display: flex; - justify-content: center; - } - - .pagination-other-pages-list { - flex: 0 0 auto; - display: flex; - justify-content: center; - padding: 0; - margin: 0; - list-style: none; - - > li { - flex: 0 0 auto; - user-select: none; - - a { - text-decoration: none; - background-color: $euiColorLightestShade; - margin-left: $euiSizeXS / 2; - padding: $euiSizeS $euiSizeM; - } - - a:hover { - text-decoration: underline; - } - - &.active a { - text-decoration: none !important; - font-weight: $euiFontWeightBold; - color: $euiColorDarkShade; - cursor: default; - } - } - } - - .pagination-size { - flex: 0 0 auto; - - input[type="number"] { - width: 3em; - } - } - } -} diff --git a/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.d.ts b/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.d.ts deleted file mode 100644 index 60f462aa5ffe..000000000000 --- a/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Any modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export function PaginateDirectiveProvider($parse: any, $compile: any): any; -export function PaginateControlsDirectiveProvider(): any; diff --git a/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.js b/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.js deleted file mode 100644 index 1f78a7f715d9..000000000000 --- a/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate.js +++ /dev/null @@ -1,242 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Any modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import _ from 'lodash'; -import { i18n } from '@osd/i18n'; -import './_paginate.scss'; -import paginateControlsTemplate from './paginate_controls.html'; - -export function PaginateDirectiveProvider($parse, $compile) { - return { - restrict: 'E', - scope: true, - link: { - pre: function ($scope, $el, attrs) { - if (_.isUndefined(attrs.bottomControls)) attrs.bottomControls = true; - if ($el.find('paginate-controls.paginate-bottom').length === 0 && attrs.bottomControls) { - $el.append($compile('')($scope)); - } - }, - post: function ($scope, $el, attrs) { - if (_.isUndefined(attrs.topControls)) attrs.topControls = false; - if ($el.find('paginate-controls.paginate-top').length === 0 && attrs.topControls) { - $el.prepend($compile('')($scope)); - } - - const paginate = $scope.paginate; - - // add some getters to the controller powered by attributes - paginate.getList = $parse(attrs.list); - paginate.perPageProp = attrs.perPageProp; - - if (attrs.perPage) { - paginate.perPage = attrs.perPage; - $scope.showSelector = false; - } else { - $scope.showSelector = true; - } - - paginate.otherWidthGetter = $parse(attrs.otherWidth); - - paginate.init(); - }, - }, - controllerAs: 'paginate', - controller: function ($scope, $document) { - const self = this; - const ALL = 0; - const allSizeTitle = i18n.translate( - 'opensearch_dashboards_legacy.paginate.size.allDropDownOptionLabel', - { - defaultMessage: 'All', - } - ); - - self.sizeOptions = [ - { title: '10', value: 10 }, - { title: '25', value: 25 }, - { title: '100', value: 100 }, - { title: allSizeTitle, value: ALL }, - ]; - - // setup the watchers, called in the post-link function - self.init = function () { - self.perPage = _.parseInt(self.perPage) || $scope[self.perPageProp]; - - $scope.$watchMulti(['paginate.perPage', self.perPageProp, self.otherWidthGetter], function ( - vals, - oldVals - ) { - const intChanges = vals[0] !== oldVals[0]; - - if (intChanges) { - if (!setPerPage(self.perPage)) { - // if we are not able to set the external value, - // render now, otherwise wait for the external value - // to trigger the watcher again - self.renderList(); - } - return; - } - - self.perPage = _.parseInt(self.perPage) || $scope[self.perPageProp]; - if (self.perPage == null) { - self.perPage = ALL; - return; - } - - self.renderList(); - }); - - $scope.$watch('page', self.changePage); - $scope.$watchCollection(self.getList, function (list) { - $scope.list = list; - self.renderList(); - }); - }; - - self.goToPage = function (number) { - if (number) { - if (number.hasOwnProperty('number')) number = number.number; - $scope.page = $scope.pages[number - 1] || $scope.pages[0]; - } - }; - - self.goToTop = function goToTop() { - $document.scrollTop(0); - }; - - self.renderList = function () { - $scope.pages = []; - if (!$scope.list) return; - - const perPage = _.parseInt(self.perPage); - const count = perPage ? Math.ceil($scope.list.length / perPage) : 1; - - _.times(count, function (i) { - let page; - - if (perPage) { - const start = perPage * i; - page = $scope.list.slice(start, start + perPage); - } else { - page = $scope.list.slice(0); - } - - page.number = i + 1; - page.i = i; - - page.count = count; - page.first = page.number === 1; - page.last = page.number === count; - page.firstItem = (page.number - 1) * perPage + 1; - page.lastItem = Math.min(page.number * perPage, $scope.list.length); - - page.prev = $scope.pages[i - 1]; - if (page.prev) page.prev.next = page; - - $scope.pages.push(page); - }); - - // set the new page, or restore the previous page number - if ($scope.page && $scope.page.i < $scope.pages.length) { - $scope.page = $scope.pages[$scope.page.i]; - } else { - $scope.page = $scope.pages[0]; - } - - if ($scope.page && $scope.onPageChanged) { - $scope.onPageChanged($scope.page); - } - }; - - self.changePage = function (page) { - if (!page) { - $scope.otherPages = null; - return; - } - - // setup the list of the other pages to link to - $scope.otherPages = []; - const width = +self.otherWidthGetter($scope) || 5; - let left = page.i - Math.round((width - 1) / 2); - let right = left + width - 1; - - // shift neg count from left to right - if (left < 0) { - right += 0 - left; - left = 0; - } - - // shift extra right nums to left - const lastI = page.count - 1; - if (right > lastI) { - right = lastI; - left = right - width + 1; - } - - for (let i = left; i <= right; i++) { - const other = $scope.pages[i]; - - if (!other) continue; - - $scope.otherPages.push(other); - if (other.last) $scope.otherPages.containsLast = true; - if (other.first) $scope.otherPages.containsFirst = true; - } - - if ($scope.onPageChanged) { - $scope.onPageChanged($scope.page); - } - }; - - function setPerPage(val) { - let $ppParent = $scope; - - while ($ppParent && !_.has($ppParent, self.perPageProp)) { - $ppParent = $ppParent.$parent; - } - - if ($ppParent) { - $ppParent[self.perPageProp] = val; - return true; - } - } - }, - }; -} - -export function PaginateControlsDirectiveProvider() { - // this directive is automatically added by paginate if not found within it's $el - return { - restrict: 'E', - template: paginateControlsTemplate, - }; -} diff --git a/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate_controls.html b/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate_controls.html deleted file mode 100644 index 3cabb2c61ede..000000000000 --- a/src/plugins/opensearch_dashboards_legacy/public/paginate/paginate_controls.html +++ /dev/null @@ -1,98 +0,0 @@ - - -

-
    -
  • - -
  • -
  • - -
  • - -
  • - - ... -
  • - -
  • - -
  • - -
  • - ... - -
  • - -
  • - -
  • -
  • - -
  • -
-
- -
-
- - -
-
diff --git a/src/plugins/tile_map/public/plugin.ts b/src/plugins/tile_map/public/plugin.ts index 37d6d3e14c00..220c6870ef3e 100644 --- a/src/plugins/tile_map/public/plugin.ts +++ b/src/plugins/tile_map/public/plugin.ts @@ -37,8 +37,6 @@ import { } from 'opensearch-dashboards/public'; import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public'; import { VisualizationsSetup } from '../../visualizations/public'; -// TODO: Determine why visualizations don't populate without this -// import 'angular-sanitize'; // @ts-ignore import { createTileMapFn } from './tile_map_fn'; diff --git a/yarn.lock b/yarn.lock index 6df97ecb5926..98c4cd2b4219 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13047,11 +13047,6 @@ next-tick@1, next-tick@^1.1.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== -ngreact@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/ngreact/-/ngreact-0.5.2.tgz#d48180b578b186ad70861a3de9ba508b3f22b2ae" - integrity sha512-FCQGtTkDrnI3ywhvK9wUf7C6SYfqKDdRW+cPvy358GFe3AnA4rfvWisDVUQyf5YwNr439ito9xUuuEv80QXhSQ== - nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"