[ML] Use data view name in anomaly detection job wizards (#138255) (#138370)

* [ML] Use data view name in anomaly detection job wizards

* adding to data recognizer

(cherry picked from commit 1bcd865363)

Co-authored-by: James Gowdy <jgowdy@elastic.co>
This commit is contained in:
Kibana Machine 2022-08-09 07:02:28 -04:00 committed by GitHub
parent c332f5bbb3
commit 62ed40b0aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 4 deletions

View file

@ -51,6 +51,7 @@ export class JobCreator {
protected _indexPattern: DataView;
protected _savedSearch: SavedSearchSavedObject | null;
protected _indexPatternTitle: IndexPatternTitle = '';
protected _indexPatternDisplayName: string = '';
protected _job_config: Job;
protected _calendars: Calendar[];
protected _datafeed_config: Datafeed;
@ -79,7 +80,11 @@ export class JobCreator {
constructor(indexPattern: DataView, savedSearch: SavedSearchSavedObject | null, query: object) {
this._indexPattern = indexPattern;
this._savedSearch = savedSearch;
this._indexPatternTitle = indexPattern.title;
const title = this._indexPattern.title;
const name = this._indexPattern.getName();
this._indexPatternDisplayName = name === title ? name : `${name} (${title})`;
this._indexPatternTitle = title;
this._job_config = createEmptyJob();
this._calendars = [];
@ -104,6 +109,10 @@ export class JobCreator {
return this._indexPatternTitle;
}
public get indexPatternDisplayName(): string {
return this._indexPatternDisplayName;
}
protected _addDetector(detector: Detector, agg: Aggregation, field: Field) {
this._detectors.push(detector);
this._aggs.push(agg);

View file

@ -72,7 +72,7 @@ export const Page: FC = () => {
})
: i18n.translate('xpack.ml.newJob.wizard.jobType.dataViewPageTitleLabel', {
defaultMessage: 'data view {dataViewName}',
values: { dataViewName: currentDataView.title },
values: { dataViewName: currentDataView.getName() },
});
const recognizerResults = {

View file

@ -216,7 +216,7 @@ export const Page: FC<PageProps> = ({ existingJobsAndGroups, jobType }) => {
<FormattedMessage
id="xpack.ml.newJob.page.createJob.dataViewName"
defaultMessage="Using data view {dataViewName}"
values={{ dataViewName: jobCreator.indexPatternTitle }}
values={{ dataViewName: jobCreator.indexPatternDisplayName }}
/>
</EuiPageContentHeaderSection>
</EuiPageContentHeader>

View file

@ -101,7 +101,7 @@ export const Page: FC<PageProps> = ({ moduleId, existingGroupIds }) => {
})
: i18n.translate('xpack.ml.newJob.recognize.dataViewPageTitle', {
defaultMessage: 'data view {dataViewName}',
values: { dataViewName: dataView.title },
values: { dataViewName: dataView.getName() },
});
const displayQueryWarning = savedSearch !== null;
const tempQuery = savedSearch === null ? undefined : combinedQuery;