Skip to content

Commit

Permalink
Add VisLayer interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
  • Loading branch information
ohltyler committed Dec 20, 2022
1 parent e58b8a6 commit c961d3f
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 105 deletions.
2 changes: 1 addition & 1 deletion src/plugins/plugin_integration/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"version": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["data", "visualizations", "savedObjects", "opensearchDashboardsUtils"]
"requiredPlugins": ["data", "savedObjects", "opensearchDashboardsUtils"]
}
36 changes: 10 additions & 26 deletions src/plugins/plugin_integration/public/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
/*
* Copyright OpenSearch Contributors
* 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 { PluginInitializerContext } from 'src/core/public';
Expand All @@ -35,3 +10,12 @@ export function plugin(initializerContext: PluginInitializerContext) {
return new PluginIntegrationPlugin(initializerContext);
}
export { PluginIntegrationSetup, PluginIntegrationStart };

export {
VisLayer,
VisLayers,
PointInTimeEventsVisLayer,
PointInTimeEvent,
PointInTimeEventMetadata,
isPointInTimeEventsVisLayer,
} from './types';
27 changes: 1 addition & 26 deletions src/plugins/plugin_integration/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
/*
* Copyright OpenSearch Contributors
* 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 { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../core/public';
Expand Down
33 changes: 33 additions & 0 deletions src/plugins/plugin_integration/public/types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { VisLayer, isPointInTimeEventsVisLayer } from './types';

describe('isPointInTimeEventsVisLayer()', function () {
it('should return false if no events field', function () {
const visLayer = {
id: 'visLayerId',
name: 'visLayerName',
field1: 'value1',
field2: 'value2',
} as VisLayer;
expect(isPointInTimeEventsVisLayer(visLayer)).toBe(false);
});

it('should return true if events field exists', function () {
const visLayer = {
id: 'testId',
name: 'testName',
events: [
{
timestamp: 123,
resourceId: 'testId',
resourceName: 'testName',
},
],
} as VisLayer;
expect(isPointInTimeEventsVisLayer(visLayer)).toBe(true);
});
});
34 changes: 34 additions & 0 deletions src/plugins/plugin_integration/public/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export interface VisLayer {
// will be used as the column ID
id: string;
// will be used as the name when hovering over the tooltip
name: string;
}

export type VisLayers = VisLayer[];

export interface PointInTimeEventMetadata {
resourceId: string;
resourceName: string;
tooltip?: string;
}

export interface PointInTimeEvent {
timestamp: number;
metadata: PointInTimeEventMetadata;
}

export interface PointInTimeEventsVisLayer extends VisLayer {
events: PointInTimeEvent[];
}

// used to determine what vis layer's interface is being implemented.
// currently PointInTimeEventsLayer is the only interface extending VisLayer
export const isPointInTimeEventsVisLayer = (obj: any) => {
return 'events' in obj;
};
27 changes: 1 addition & 26 deletions src/plugins/plugin_integration/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
/*
* Copyright OpenSearch Contributors
* 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 { PluginInitializerContext } from '../../../core/server';
Expand Down
27 changes: 1 addition & 26 deletions src/plugins/plugin_integration/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
/*
* Copyright OpenSearch Contributors
* 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 {
Expand Down

0 comments on commit c961d3f

Please sign in to comment.