mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
[ML] Making creation of data view during file upload optional (#210208)
Adds an option override to tell the file uploader not to create a data view once ingest has finished. This is currently not used but should be used in the near future when creating lookup indices from the es|ql query bar. The PR also contains some typing clean up to remove duplication. **Before**  **After** 
This commit is contained in:
parent
d34ee93dcf
commit
9fa8ec42a6
10 changed files with 50 additions and 23 deletions
|
@ -18,4 +18,5 @@ export interface OpenFileUploadLiteContext {
|
||||||
onUploadComplete?: (results: FileUploadResults | null) => void;
|
onUploadComplete?: (results: FileUploadResults | null) => void;
|
||||||
indexSettings?: IndicesIndexSettings;
|
indexSettings?: IndicesIndexSettings;
|
||||||
autoAddInference?: string;
|
autoAddInference?: string;
|
||||||
|
autoCreateDataView?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ export class FileManager {
|
||||||
indexCreated: STATUS.NOT_STARTED,
|
indexCreated: STATUS.NOT_STARTED,
|
||||||
pipelineCreated: STATUS.NOT_STARTED,
|
pipelineCreated: STATUS.NOT_STARTED,
|
||||||
modelDeployed: STATUS.NA,
|
modelDeployed: STATUS.NA,
|
||||||
dataViewCreated: STATUS.NA,
|
dataViewCreated: STATUS.NOT_STARTED,
|
||||||
pipelinesDeleted: STATUS.NOT_STARTED,
|
pipelinesDeleted: STATUS.NOT_STARTED,
|
||||||
fileImport: STATUS.NOT_STARTED,
|
fileImport: STATUS.NOT_STARTED,
|
||||||
filesStatus: [],
|
filesStatus: [],
|
||||||
|
@ -91,6 +91,7 @@ export class FileManager {
|
||||||
private http: HttpSetup,
|
private http: HttpSetup,
|
||||||
private dataViewsContract: DataViewsServicePublic,
|
private dataViewsContract: DataViewsServicePublic,
|
||||||
private autoAddInferenceEndpointName: string | null = null,
|
private autoAddInferenceEndpointName: string | null = null,
|
||||||
|
private autoCreateDataView: boolean = true,
|
||||||
private removePipelinesAfterImport: boolean = true,
|
private removePipelinesAfterImport: boolean = true,
|
||||||
indexSettingsOverride: IndicesIndexSettings | undefined = undefined
|
indexSettingsOverride: IndicesIndexSettings | undefined = undefined
|
||||||
) {
|
) {
|
||||||
|
@ -225,10 +226,7 @@ export class FileManager {
|
||||||
return files.map((file) => file.getPipeline());
|
return files.map((file) => file.getPipeline());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async import(
|
public async import(indexName: string): Promise<FileUploadResults | null> {
|
||||||
indexName: string,
|
|
||||||
createDataView: boolean = true
|
|
||||||
): Promise<FileUploadResults | null> {
|
|
||||||
if (this.mappings === null || this.pipelines === null || this.commonFileFormat === null) {
|
if (this.mappings === null || this.pipelines === null || this.commonFileFormat === null) {
|
||||||
this.setStatus({
|
this.setStatus({
|
||||||
overallImportStatus: STATUS.FAILED,
|
overallImportStatus: STATUS.FAILED,
|
||||||
|
@ -239,6 +237,7 @@ export class FileManager {
|
||||||
|
|
||||||
this.setStatus({
|
this.setStatus({
|
||||||
overallImportStatus: STATUS.STARTED,
|
overallImportStatus: STATUS.STARTED,
|
||||||
|
dataViewCreated: this.autoCreateDataView ? STATUS.NOT_STARTED : STATUS.NA,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.importer = await this.fileUpload.importerFactory(this.commonFileFormat, {});
|
this.importer = await this.fileUpload.importerFactory(this.commonFileFormat, {});
|
||||||
|
@ -372,7 +371,7 @@ export class FileManager {
|
||||||
|
|
||||||
const dataView = '';
|
const dataView = '';
|
||||||
let dataViewResp;
|
let dataViewResp;
|
||||||
if (createDataView) {
|
if (this.autoCreateDataView) {
|
||||||
this.setStatus({
|
this.setStatus({
|
||||||
dataViewCreated: STATUS.STARTED,
|
dataViewCreated: STATUS.STARTED,
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,7 @@ export interface Props {
|
||||||
getAdditionalLinks?: GetAdditionalLinks;
|
getAdditionalLinks?: GetAdditionalLinks;
|
||||||
setUploadResults?: (results: FileUploadResults) => void;
|
setUploadResults?: (results: FileUploadResults) => void;
|
||||||
autoAddInference?: string;
|
autoAddInference?: string;
|
||||||
|
autoCreateDataView?: boolean;
|
||||||
indexSettings?: IndicesIndexSettings;
|
indexSettings?: IndicesIndexSettings;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,7 @@ export const FileDataVisualizerLite: FC<Props> = ({
|
||||||
resultLinks,
|
resultLinks,
|
||||||
setUploadResults,
|
setUploadResults,
|
||||||
autoAddInference,
|
autoAddInference,
|
||||||
|
autoCreateDataView,
|
||||||
indexSettings,
|
indexSettings,
|
||||||
onClose,
|
onClose,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -60,6 +62,7 @@ export const FileDataVisualizerLite: FC<Props> = ({
|
||||||
capabilities={coreStart.application.capabilities}
|
capabilities={coreStart.application.capabilities}
|
||||||
setUploadResults={setUploadResults}
|
setUploadResults={setUploadResults}
|
||||||
autoAddInference={autoAddInference}
|
autoAddInference={autoAddInference}
|
||||||
|
autoCreateDataView={autoCreateDataView}
|
||||||
indexSettings={indexSettings}
|
indexSettings={indexSettings}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -44,6 +44,7 @@ export function createOpenFileUploadLiteAction(
|
||||||
async execute({
|
async execute({
|
||||||
onUploadComplete,
|
onUploadComplete,
|
||||||
autoAddInference,
|
autoAddInference,
|
||||||
|
autoCreateDataView,
|
||||||
indexSettings,
|
indexSettings,
|
||||||
}: OpenFileUploadLiteContext) {
|
}: OpenFileUploadLiteContext) {
|
||||||
try {
|
try {
|
||||||
|
@ -52,6 +53,7 @@ export function createOpenFileUploadLiteAction(
|
||||||
createFlyout(coreStart, share, data, {
|
createFlyout(coreStart, share, data, {
|
||||||
onUploadComplete,
|
onUploadComplete,
|
||||||
autoAddInference,
|
autoAddInference,
|
||||||
|
autoCreateDataView,
|
||||||
indexSettings,
|
indexSettings,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ interface Props {
|
||||||
getAdditionalLinks?: GetAdditionalLinks;
|
getAdditionalLinks?: GetAdditionalLinks;
|
||||||
setUploadResults?: (results: FileUploadResults) => void;
|
setUploadResults?: (results: FileUploadResults) => void;
|
||||||
autoAddInference?: string;
|
autoAddInference?: string;
|
||||||
|
autoCreateDataView?: boolean;
|
||||||
indexSettings?: IndicesIndexSettings;
|
indexSettings?: IndicesIndexSettings;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +59,7 @@ export const FileUploadLiteView: FC<Props> = ({
|
||||||
dataStart,
|
dataStart,
|
||||||
setUploadResults,
|
setUploadResults,
|
||||||
autoAddInference,
|
autoAddInference,
|
||||||
|
autoCreateDataView,
|
||||||
indexSettings,
|
indexSettings,
|
||||||
onClose,
|
onClose,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -71,10 +73,11 @@ export const FileUploadLiteView: FC<Props> = ({
|
||||||
http,
|
http,
|
||||||
dataStart.dataViews,
|
dataStart.dataViews,
|
||||||
autoAddInference ?? null,
|
autoAddInference ?? null,
|
||||||
|
autoCreateDataView,
|
||||||
true,
|
true,
|
||||||
indexSettings
|
indexSettings
|
||||||
),
|
),
|
||||||
[autoAddInference, dataStart.dataViews, fileUpload, http, indexSettings]
|
[autoAddInference, autoCreateDataView, dataStart.dataViews, fileUpload, http, indexSettings]
|
||||||
);
|
);
|
||||||
const deleteFile = useCallback((i: number) => fm.removeFile(i), [fm]);
|
const deleteFile = useCallback((i: number) => fm.removeFile(i), [fm]);
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,24 @@ export const FileDataVisualizerLiteWrapper: FC<{
|
||||||
resultLinks?: ResultLinks;
|
resultLinks?: ResultLinks;
|
||||||
setUploadResults?: (results: FileUploadResults) => void;
|
setUploadResults?: (results: FileUploadResults) => void;
|
||||||
autoAddInference?: string;
|
autoAddInference?: string;
|
||||||
|
autoCreateDataView?: boolean;
|
||||||
indexSettings?: IndicesIndexSettings;
|
indexSettings?: IndicesIndexSettings;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
}> = ({ resultLinks, setUploadResults, autoAddInference, indexSettings, onClose }) => {
|
}> = ({
|
||||||
|
resultLinks,
|
||||||
|
setUploadResults,
|
||||||
|
autoAddInference,
|
||||||
|
autoCreateDataView,
|
||||||
|
indexSettings,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<React.Suspense fallback={<div />}>
|
<React.Suspense fallback={<div />}>
|
||||||
<FileDataVisualizerLiteComponent
|
<FileDataVisualizerLiteComponent
|
||||||
resultLinks={resultLinks}
|
resultLinks={resultLinks}
|
||||||
setUploadResults={setUploadResults}
|
setUploadResults={setUploadResults}
|
||||||
autoAddInference={autoAddInference}
|
autoAddInference={autoAddInference}
|
||||||
|
autoCreateDataView={autoCreateDataView}
|
||||||
indexSettings={indexSettings}
|
indexSettings={indexSettings}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
/>
|
/>
|
||||||
|
@ -38,6 +47,7 @@ export function getFileDataVisualizerLiteWrapper(
|
||||||
resultLinks?: ResultLinks,
|
resultLinks?: ResultLinks,
|
||||||
setUploadResults?: (results: FileUploadResults) => void,
|
setUploadResults?: (results: FileUploadResults) => void,
|
||||||
autoAddInference?: string,
|
autoAddInference?: string,
|
||||||
|
autoCreateDataView?: boolean,
|
||||||
indexSettings?: IndicesIndexSettings,
|
indexSettings?: IndicesIndexSettings,
|
||||||
onClose?: () => void
|
onClose?: () => void
|
||||||
) {
|
) {
|
||||||
|
@ -46,6 +56,7 @@ export function getFileDataVisualizerLiteWrapper(
|
||||||
resultLinks={resultLinks}
|
resultLinks={resultLinks}
|
||||||
setUploadResults={setUploadResults}
|
setUploadResults={setUploadResults}
|
||||||
autoAddInference={autoAddInference}
|
autoAddInference={autoAddInference}
|
||||||
|
autoCreateDataView={autoCreateDataView}
|
||||||
indexSettings={indexSettings}
|
indexSettings={indexSettings}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -38,7 +38,7 @@ export function createFlyout(
|
||||||
});
|
});
|
||||||
|
|
||||||
let results: FileUploadResults | null = null;
|
let results: FileUploadResults | null = null;
|
||||||
const { onUploadComplete, autoAddInference, indexSettings } = props;
|
const { onUploadComplete, autoAddInference, autoCreateDataView, indexSettings } = props;
|
||||||
|
|
||||||
const onFlyoutClose = () => {
|
const onFlyoutClose = () => {
|
||||||
flyoutSession.close();
|
flyoutSession.close();
|
||||||
|
@ -54,7 +54,7 @@ export function createFlyout(
|
||||||
coreStart={coreStart}
|
coreStart={coreStart}
|
||||||
share={share}
|
share={share}
|
||||||
data={data}
|
data={data}
|
||||||
props={{ autoAddInference, indexSettings }}
|
props={{ autoAddInference, autoCreateDataView, indexSettings }}
|
||||||
onFlyoutClose={onFlyoutClose}
|
onFlyoutClose={onFlyoutClose}
|
||||||
setUploadResults={(res) => {
|
setUploadResults={(res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ interface Props {
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
setUploadResults?: (results: FileUploadResults) => void;
|
setUploadResults?: (results: FileUploadResults) => void;
|
||||||
autoAddInference?: string;
|
autoAddInference?: string;
|
||||||
|
autoCreateDataView?: boolean;
|
||||||
indexSettings?: IndicesIndexSettings;
|
indexSettings?: IndicesIndexSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +24,14 @@ export const FileUploadLiteFlyoutContents: FC<Props> = ({
|
||||||
onClose,
|
onClose,
|
||||||
setUploadResults,
|
setUploadResults,
|
||||||
autoAddInference,
|
autoAddInference,
|
||||||
|
autoCreateDataView,
|
||||||
indexSettings,
|
indexSettings,
|
||||||
}) => {
|
}) => {
|
||||||
const Wrapper = getFileDataVisualizerLiteWrapper(
|
const Wrapper = getFileDataVisualizerLiteWrapper(
|
||||||
undefined,
|
undefined,
|
||||||
setUploadResults,
|
setUploadResults,
|
||||||
autoAddInference,
|
autoAddInference,
|
||||||
|
autoCreateDataView,
|
||||||
indexSettings,
|
indexSettings,
|
||||||
onClose
|
onClose
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,7 +27,7 @@ export const FlyoutContents: FC<Props> = ({
|
||||||
coreStart,
|
coreStart,
|
||||||
share,
|
share,
|
||||||
data,
|
data,
|
||||||
props: { autoAddInference, indexSettings },
|
props: { autoAddInference, autoCreateDataView, indexSettings },
|
||||||
onFlyoutClose,
|
onFlyoutClose,
|
||||||
setUploadResults,
|
setUploadResults,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -41,6 +41,7 @@ export const FlyoutContents: FC<Props> = ({
|
||||||
>
|
>
|
||||||
<FileUploadLiteFlyoutContents
|
<FileUploadLiteFlyoutContents
|
||||||
autoAddInference={autoAddInference}
|
autoAddInference={autoAddInference}
|
||||||
|
autoCreateDataView={autoCreateDataView}
|
||||||
indexSettings={indexSettings}
|
indexSettings={indexSettings}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
onFlyoutClose();
|
onFlyoutClose();
|
||||||
|
|
|
@ -80,13 +80,21 @@ export const OverallUploadStatus: FC<Props> = ({ filesStatus, uploadStatus }) =>
|
||||||
),
|
),
|
||||||
status: generateStatus([uploadStatus.fileImport]),
|
status: generateStatus([uploadStatus.fileImport]),
|
||||||
},
|
},
|
||||||
{
|
...(uploadStatus.dataViewCreated === STATUS.NA
|
||||||
title: i18n.translate('xpack.dataVisualizer.file.overallUploadStatus.creatingDataView', {
|
? []
|
||||||
defaultMessage: 'Creating data view',
|
: [
|
||||||
}),
|
{
|
||||||
children: <></>,
|
title: i18n.translate(
|
||||||
status: generateStatus([uploadStatus.dataViewCreated]),
|
'xpack.dataVisualizer.file.overallUploadStatus.creatingDataView',
|
||||||
},
|
{
|
||||||
|
defaultMessage: 'Creating data view',
|
||||||
|
}
|
||||||
|
),
|
||||||
|
children: <></>,
|
||||||
|
status: generateStatus([uploadStatus.dataViewCreated]),
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
|
||||||
{
|
{
|
||||||
title: i18n.translate('xpack.dataVisualizer.file.overallUploadStatus.uploadComplete', {
|
title: i18n.translate('xpack.dataVisualizer.file.overallUploadStatus.uploadComplete', {
|
||||||
defaultMessage: 'Upload complete',
|
defaultMessage: 'Upload complete',
|
||||||
|
@ -96,9 +104,5 @@ export const OverallUploadStatus: FC<Props> = ({ filesStatus, uploadStatus }) =>
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return <EuiSteps steps={steps} titleSize="xxs" css={css} />;
|
||||||
<>
|
|
||||||
<EuiSteps steps={steps} titleSize="xxs" css={css} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue