Skip to content

Commit

Permalink
clean up comments
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
  • Loading branch information
ohltyler committed Mar 13, 2023
1 parent 10dfac3 commit 33b5c3a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 30 deletions.
2 changes: 0 additions & 2 deletions src/plugins/vis_augmenter/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export class VisAugmenterPlugin
setVisualizations(visualizations);
setCore(core);

// registers the triggers & actions defined in this plugin
// also maps any triggers to possible actions
registerTriggersAndActions(core);

const savedAugmentVisLoader = createSavedAugmentVisLoader({
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { CONTEXT_MENU_TRIGGER, EmbeddableContext } from '../../embeddable/public
import { getUiActions } from './services';

// Overriding the mappings defined in UIActions plugin so that
// the new trigger and action definitions resolve
// the new trigger and action definitions resolve.
// This is a common pattern among internal Dashboards plugins.
declare module '../../ui_actions/public' {
export interface TriggerContextMapping {
[OPEN_EVENTS_FLYOUT_TRIGGER]: AugmentVisContext;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/vis_type_vega/public/data_model/vega_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ The URL is an identifier only. OpenSearch Dashboards and your browser will never
*/
_setDefaultColors() {
// Default category coloring to the OpenSearch color scheme
// TODO: this should be fixed as part of
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3582
this._setDefaultValue({ scheme: 'category10' }, 'config', 'range', 'category');

if (this.isVegaLite) {
Expand Down
16 changes: 7 additions & 9 deletions src/plugins/vis_type_vega/public/expressions/vega_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ interface Arguments {
savedObjectId: string;
}

export type VisParams = Required<Arguments>;
export interface VisParams {
spec: string;
}

export type VegaExpressionFunctionDefinition = ExpressionFunctionDefinition<
'vega',
Expand Down Expand Up @@ -91,15 +93,11 @@ export const createVegaFn = (
async fn(input, args, context) {
const vegaRequestHandler = createVegaRequestHandler(dependencies, context);

const timeRange = get(input, 'timeRange') as TimeRange;
const query = get(input, 'query') as Query;
const filters = get(input, 'filters') as any;

const response = await vegaRequestHandler({
timeRange,
query,
filters,
visParams: { spec: args.spec, savedObjectId: args.savedObjectId },
timeRange: get(input, 'timeRange') as TimeRange,
query: get(input, 'query') as Query,
filters: get(input, 'filters') as any,
visParams: { spec: args.spec },
});

return {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/vis_type_vega/public/vega_view/vega_base_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ export class VegaBaseView {
this._addDestroyHandler(() => tthandler.hideTooltip());
}

// trigger the open events flyout UIAction if a click happens on an annotation datapoint
// TODO: The filtering on the item ('annotation datapoint' vs. regular datapoint, etc.) will be handled in
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3317
// Right now, clicking anywhere on the chart will trigger the flyout to open.
/* eslint-disable */
view.addEventListener('click', function (event, item) {
// TODO: add filtering to determine if the item is a datapoint, and whether or not it is an
// "annotation" datapoint vs. regular datapoint
const { savedObjectId } = get(view, '_opensearchDashboardsView._visInput', {});
getUiActions().getTrigger(OPEN_EVENTS_FLYOUT_TRIGGER).exec({ savedObjectId });
});
Expand Down
9 changes: 6 additions & 3 deletions src/plugins/vis_type_vega/public/vega_view/vega_tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ export class TooltipHandler {
view.tooltip(this.handler.bind(this));
}

// test handler
/**
* The handler function.
*/
handler(view, event, item, value) {
this.hideTooltip();

//console.log('item: ', item);

// hide tooltip for null, undefined, or empty string values
if (value == null || value === '') {
return;
Expand All @@ -87,6 +87,7 @@ export class TooltipHandler {
// with a large number of tests, hence suppressing eslint here.
// eslint-disable-next-line no-unsanitized/property
// el.innerHTML = createTooltipContent(value, _.escape, 2);

/* eslint-disable */
el.innerHTML = this.createTooltipHtml(value);
// add to DOM to calculate tooltip size
Expand Down Expand Up @@ -117,6 +118,8 @@ export class TooltipHandler {
el.setAttribute('style', `top: ${pos.top}px; left: ${pos.left}px`);
}

// TODO: This is where the custom tooltip will be handled - see here for details:
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3317
/* eslint-disable */
createTooltipHtml(value) {
return '<p>some custom tooltip<p>';
Expand Down
1 change: 0 additions & 1 deletion src/plugins/vis_type_vega/public/vega_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const createVegaVisualization = ({ getServiceSettings }) =>
const serviceSettings = await getServiceSettings();
const { filterManager } = this.dataPlugin.query;
const { timefilter } = this.dataPlugin.query.timefilter;

const vegaViewParams = {
parentEl: this._el,
applyFilter: this._vis.API.events.applyFilter,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/visualizations/public/expressions/vis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import { EventEmitter } from 'events';
import _ from 'lodash';
import { VisParams, PersistedState } from '../../../../plugins/visualizations/public';

import { getTypes } from '../services';
import { VisType } from '../vis_types';

Expand Down
14 changes: 3 additions & 11 deletions src/plugins/visualizations/public/legacy/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,8 @@ const adjustVislibDimensionFormmaters = (vis: Vis, dimensions: { y: any[] }): vo
};

export const buildPipelineVisFunction: BuildPipelineVisFunction = {
vega: (params, schemas, uiState, meta) => {
return `vega ${prepareString('spec', params.spec)} ${prepareString(
'savedObjectId',
meta?.savedObjectId
)}`;
vega: (params) => {
return `vega ${prepareString('spec', params.spec)}`;
},
input_control_vis: (params) => {
return `input_control_vis ${prepareJson('visConfig', params)}`;
Expand Down Expand Up @@ -424,16 +421,11 @@ export const buildPipeline = async (vis: Vis, params: BuildPipelineParams) => {

const schemas = getSchemas(vis, params);

const meta = {
savedObjectId: get(vis, 'id', ''),
};

if (buildPipelineVisFunction[vis.type.name]) {
pipeline += buildPipelineVisFunction[vis.type.name](
{ title, ...vis.params },
schemas,
uiState,
meta
uiState
);
} else if (vislibCharts.includes(vis.type.name)) {
const visConfig = { ...vis.params };
Expand Down

0 comments on commit 33b5c3a

Please sign in to comment.