Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Feb 8, 2021
1 parent 0cfecae commit e50def3
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 55 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/maps/anomaly_job_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AnomalyJobSelector extends Component<Props, State> {
})}
display="columnCompressed"
>
<EuiComboBox singleSelection={true} onChange={this.onJobIdSelect} options={} />
<EuiComboBox singleSelection={true} onChange={this.onJobIdSelect} options={[]} />
</EuiFormRow>
);
}
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/ml/public/maps/anomaly_layer_wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { i18n } from '@kbn/i18n';
// @ts-expect-error
import React from 'react';
import uuid from 'uuid';
import { LAYER_WIZARD_CATEGORY, STYLE_TYPE } from '../../../maps/common/constants';
Expand Down
119 changes: 68 additions & 51 deletions x-pack/plugins/ml/public/maps/anomaly_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import {
MapQuery,
VectorSourceSyncMeta,
} from '../../../maps/common/descriptor_types';
import { ITooltipProperty, LICENSED_FEATURES } from '../../../maps/public';
import { RecordScoreField, RecordScoreTooltipProperty } from './record_score_field';
import type { Adapters } from '../../../../../src/plugins/inspector/common/adapters';
import type { GeoJsonWithMeta } from '../../../maps/public';
import type { IField } from '../../../maps/public';
import type { Attribution, ImmutableSourceProperty, PreIndexedShape } from '../../../maps/public';
import type { BoundsFilters } from '../../../maps/public';
import { LICENSED_FEATURES } from '../../../maps/public';
import { RecordScoreField } from './record_score_field';
import type { SourceEditorArgs } from '../../../maps/public';
import { ITooltipProperty } from '../../../maps/public';
import type { DataRequest } from '../../../maps/public';
import type { SourceTooltipConfig } from '../../../maps/public';
import type { IVectorSource } from '../../../maps/public';
Expand Down Expand Up @@ -100,8 +99,8 @@ export class AnomalySource implements IVectorSource {
return new RecordScoreField({ source: this });
}

createFieldFormatter(field: IField): Promise<FieldFormatter | null> {
return undefined;
async createFieldFormatter(field: IField): Promise<FieldFormatter | null> {
return null;
}

destroy(): void {}
Expand Down Expand Up @@ -141,6 +140,11 @@ export class AnomalySource implements IVectorSource {
return null;
}

showJoinEditor(): boolean {
// Ignore, only show if joins are enabled for current configuration
return false;
}

getFieldNames(): string[] {
return ['record_score'];
}
Expand All @@ -153,6 +157,10 @@ export class AnomalySource implements IVectorSource {
return 0;
}

isBoundsAware(): boolean {
return false;
}

async getImmutableProperties(): Promise<ImmutableSourceProperty[]> {
return [
{
Expand All @@ -164,24 +172,17 @@ export class AnomalySource implements IVectorSource {
];
}

getIndexPatternIds(): string[] {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return [];
}

getInspectorAdapters(): Adapters | undefined {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return undefined;
async isTimeAware(): Promise<boolean> {
return true;
}

getJoinsDisabledReason(): string | null {
// IGNORE: This is only relevant if your source can be joined to other data
renderSourceSettingsEditor(sourceEditorArgs: SourceEditorArgs): React.ReactElement<any> | null {
return null;
}

async getLeftJoinFields(): Promise<IField[]> {
// IGNORE: This is only relevant if your source can be joined to other data
return [];
async supportsFitToBounds(): Promise<boolean> {
// Return true if you can compute bounds of data
return true;
}

async getLicensedFeatures(): Promise<LICENSED_FEATURES[]> {
Expand All @@ -196,78 +197,94 @@ export class AnomalySource implements IVectorSource {
return MIN_ZOOM;
}

async getPreIndexedShape(
properties: { [p: string]: any } | null
): Promise<PreIndexedShape | null> {
// IGNORE: This is only relevant if your source is backed by an index-pattern
getSourceTooltipContent(sourceDataRequest?: DataRequest): SourceTooltipConfig {
throw new Error('not implemented');
}

async getSupportedShapeTypes(): Promise<VECTOR_SHAPE_TYPE[]> {
return [VECTOR_SHAPE_TYPE.POINT];
}

getSyncMeta(): VectorSourceSyncMeta | null {
return null;
}

getQueryableIndexPatternIds(): string[] {
async getTooltipProperties(properties: { [p: string]: any } | null): Promise<ITooltipProperty[]> {
const tooltipProperties: ITooltipProperty[] = [];
for (const key in properties) {
if (key === 'record_score') {
tooltipProperties.push(new RecordScoreTooltipProperty('Record score', properties[key]));
}
}
return tooltipProperties;
}

// This is for type-ahead support in the UX for by-value styling
async getValueSuggestions(field: IField, query: string): Promise<string[]> {
return [];
}

getSourceTooltipContent(sourceDataRequest?: DataRequest): SourceTooltipConfig {
return undefined;
// -----------------
// API ML probably can ignore

getIndexPatternIds(): string[] {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return [];
}

getSupportedShapeTypes(): Promise<VECTOR_SHAPE_TYPE[]> {
getInspectorAdapters(): Adapters | undefined {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return undefined;
}

getSyncMeta(): VectorSourceSyncMeta | null {
return undefined;
getJoinsDisabledReason(): string | null {
// IGNORE: This is only relevant if your source can be joined to other data
return null;
}

getTooltipProperties(properties: { [p: string]: any } | null): Promise<ITooltipProperty[]> {
return undefined;
async getLeftJoinFields(): Promise<IField[]> {
// IGNORE: This is only relevant if your source can be joined to other data
return [];
}

getValueSuggestions(field: IField, query: string): Promise<string[]> {
return undefined;
async getPreIndexedShape(
properties: { [p: string]: any } | null
): Promise<PreIndexedShape | null> {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return null;
}

isBoundsAware(): boolean {
return false;
getQueryableIndexPatternIds(): string[] {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return [];
}

isESSource(): boolean {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return false;
}

isFieldAware(): boolean {
return false;
return true;
}

isFilterByMapBounds(): boolean {
// Only implement if you can query this data with a bounding-box
return false;
}

isGeoGridPrecisionAware(): boolean {
// Ignore: only implement if your data is scale-dependent (probably not)
return false;
}

isQueryAware(): boolean {
// IGNORE: This is only relevant if your source is backed by an index-pattern
return false;
}

isRefreshTimerAware(): boolean {
return false;
}

async isTimeAware(): Promise<boolean> {
return true;
}

renderSourceSettingsEditor(sourceEditorArgs: SourceEditorArgs): React.ReactElement<any> | null {
return null;
}

showJoinEditor(): boolean {
return false;
}

async supportsFitToBounds(): Promise<boolean> {
// Allow force-refresh when user clicks "refresh" button in the global time-picker
return true;
}
}
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/maps/record_score_field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AnomalySource } from './anomaly_source';
import { ITooltipProperty } from '../../../maps/public';
import { Filter } from '../../../../../src/plugins/data/public';

class RecordScoreTooltipProperty implements ITooltipProperty {
export class RecordScoreTooltipProperty implements ITooltipProperty {
private readonly _label: string;
private readonly _value: string;

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/maps/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ml } from '../../../../services/ml_api_service';
// import { ml } from '../../../../services/ml_api_service';

const DUMMY_JOB_LIST = [
{
Expand Down

0 comments on commit e50def3

Please sign in to comment.