Skip to content

Commit

Permalink
[Data Explorer] Clean out angular contents in Discover
Browse files Browse the repository at this point in the history
Issue Resolve
opensearch-project#4459

Signed-off-by: ananzh <ananzh@amazon.com>
  • Loading branch information
ananzh committed Jun 30, 2023
1 parent 5f99b6a commit 14cdfd2
Show file tree
Hide file tree
Showing 20 changed files with 798 additions and 450 deletions.
164 changes: 0 additions & 164 deletions src/plugins/discover/public/application/_discover.scss

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* 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 { uniq } from 'lodash';
import { Duration, Moment } from 'moment';
import { Unit } from '@elastic/datemath';

import { SerializedFieldFormat } from '../../../../../expressions/common/types';

export interface Column {
id: string;
name: string;
}

export interface Row {
[key: string]: number | 'NaN';
}

export interface Table {
columns: Column[];
rows: Row[];
}

interface HistogramParams {
date: true;
interval: Duration;
intervalOpenSearchValue: number;
intervalOpenSearchUnit: Unit;
format: string;
bounds: {
min: Moment;
max: Moment;
};
}
export interface Dimension {
accessor: 0 | 1;
format: SerializedFieldFormat<{ pattern: string }>;
}

export interface Dimensions {
x: Dimension & { params: HistogramParams };
y: Dimension;
}

interface Ordered {
date: true;
interval: Duration;
intervalOpenSearchUnit: string;
intervalOpenSearchValue: number;
min: Moment;
max: Moment;
}
export interface Chart {
values: Array<{
x: number;
y: number;
}>;
xAxisOrderedValues: number[];
xAxisFormat: Dimension['format'];
xAxisLabel: Column['name'];
yAxisLabel?: Column['name'];
ordered: Ordered;
}

export const buildPointSeriesData = (table: Table, dimensions: Dimensions) => {
const { x, y } = dimensions;
const xAccessor = table.columns[x.accessor].id;
const yAccessor = table.columns[y.accessor].id;
const chart = {} as Chart;

chart.xAxisOrderedValues = uniq(table.rows.map((r) => r[xAccessor] as number));
chart.xAxisFormat = x.format;
chart.xAxisLabel = table.columns[x.accessor].name;

const { intervalOpenSearchUnit, intervalOpenSearchValue, interval, bounds } = x.params;
chart.ordered = {
date: true,
interval,
intervalOpenSearchUnit,
intervalOpenSearchValue,
min: bounds.min,
max: bounds.max,
};

chart.yAxisLabel = table.columns[y.accessor].name;

chart.values = table.rows
.filter((row) => row && row[yAccessor] !== 'NaN')
.map((row) => ({
x: row[xAccessor] as number,
y: row[yAccessor] as number,
}));

return chart;
};

This file was deleted.

11 changes: 6 additions & 5 deletions src/plugins/discover/public/application/components/discover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import { DiscoverSidebar } from './sidebar';
import { DataGridTable } from './data_grid/data_grid_table';
import { getServices, IndexPattern } from '../../opensearch_dashboards_services';
// @ts-ignore
import { DiscoverNoResults } from '../angular/directives/no_results';
import { DiscoverUninitialized } from '../angular/directives/uninitialized';
import { DiscoverHistogram } from '../angular/directives/histogram';
import { DiscoverNoResults } from './no_results/no_results';
import { DiscoverUninitialized } from './uninitialized/uninitialized';
import { DiscoverHistogram } from './histogram/histogram';
import { LoadingSpinner } from './loading_spinner/loading_spinner';
import { SkipBottomButton } from './skip_bottom_button';
import {
Expand All @@ -37,8 +37,9 @@ import {
Query,
IndexPatternAttributes,
} from '../../../../data/public';
import { Chart } from '../angular/helpers/point_series';
import { AppState } from '../angular/discover_state';
import { Chart } from './chart/point_series';
// TODO: Move to Data Explorer??
// import { AppState } from '../angular/discover_state';
import { SavedSearch } from '../../saved_searches';

import { SavedObject } from '../../../../../core/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ interface Props {
}
/**
* Responsible for rendering a tab provided by a render function.
* So any other framework can be used (E.g. legacy Angular 3rd party plugin code)
* The provided `render` function is called with a reference to the
* component's `HTMLDivElement` as 1st arg and `renderProps` as 2nd arg
*/
Expand Down
Loading

0 comments on commit 14cdfd2

Please sign in to comment.