-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify to use loader to get index pattern & Add dataSourceRef #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -43,7 +43,13 @@ import { IndexPatternField, IIndexPatternFieldList, fieldList } from '../fields' | |||||||||||||||||||||||||||||||||
import { formatHitProvider } from './format_hit'; | ||||||||||||||||||||||||||||||||||
import { flattenHitWrapper } from './flatten_hit'; | ||||||||||||||||||||||||||||||||||
import { FieldFormatsStartCommon, FieldFormat } from '../../field_formats'; | ||||||||||||||||||||||||||||||||||
import { IndexPatternSpec, TypeMeta, SourceFilter, IndexPatternFieldMap } from '../types'; | ||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||
IndexPatternSpec, | ||||||||||||||||||||||||||||||||||
TypeMeta, | ||||||||||||||||||||||||||||||||||
SourceFilter, | ||||||||||||||||||||||||||||||||||
IndexPatternFieldMap, | ||||||||||||||||||||||||||||||||||
DataSourceRef, | ||||||||||||||||||||||||||||||||||
} from '../types'; | ||||||||||||||||||||||||||||||||||
import { SerializedFieldFormat } from '../../../../expressions/common'; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
interface IndexPatternDeps { | ||||||||||||||||||||||||||||||||||
|
@@ -86,7 +92,8 @@ export class IndexPattern implements IIndexPattern { | |||||||||||||||||||||||||||||||||
// savedObject version | ||||||||||||||||||||||||||||||||||
public version: string | undefined; | ||||||||||||||||||||||||||||||||||
public sourceFilters?: SourceFilter[]; | ||||||||||||||||||||||||||||||||||
public dataSourcesJSON: string | undefined; | ||||||||||||||||||||||||||||||||||
public dataSourcesJSON?: string; // todo: cleanup, only keep one | ||||||||||||||||||||||||||||||||||
public dataSourceRef?: DataSourceRef; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
private originalSavedObjectBody: SavedObjectBody = {}; | ||||||||||||||||||||||||||||||||||
private shortDotsEnable: boolean = false; | ||||||||||||||||||||||||||||||||||
|
@@ -132,8 +139,18 @@ export class IndexPattern implements IIndexPattern { | |||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
this.dataSourcesJSON = spec.dataSourcesJSON; | ||||||||||||||||||||||||||||||||||
this.dataSourceRef = this.getDataSourceRef(spec.dataSourcesJSON); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
getDataSourceRef = (dataSourcesJSON?: string) => { | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's just extracting some info from another field There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are following similar pattern to add OpenSearch-Dashboards/src/plugins/dashboard/server/saved_objects/dashboard.ts Lines 57 to 65 in e41efcc
OpenSearch-Dashboards/src/plugins/data/server/saved_objects/index_patterns.ts Lines 59 to 65 in e41efcc
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good question, index pattern indeed have lots fields not added to map, e,g, fields, timeFieldName etc. My guess is it's due to they are optional fields. |
||||||||||||||||||||||||||||||||||
if (dataSourcesJSON) { | ||||||||||||||||||||||||||||||||||
const refs = JSON.parse(dataSourcesJSON); | ||||||||||||||||||||||||||||||||||
if (!_.isEmpty(refs)) { | ||||||||||||||||||||||||||||||||||
return refs[0]; // only support 1-1 mapping now | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* Get last saved saved object fields | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share more about what's blocking you to clean up this field? I mean we don't need to be rush, I can wait for you to complete the clean up and then merge my PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dataSourcesJSON is currently used by the UI side as well, so to clean it up, extra work is involved, however, for your side, just rely on
dataSourceRef
will do the trick. -- I will merge this PR, so we move fast to testing the read from dataSourceRef on visualization side. Just wanna callout that the cleanup is transparent to your side :)