-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/add-vis-consistency-sample-dashboard
Signed-off-by: Josh Romero <rmerqg@amazon.com>
- Loading branch information
Showing
21 changed files
with
657 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/plugins/home/server/services/sample_data/data_sets/util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { SavedObject } from 'opensearch-dashboards/server'; | ||
|
||
export const appendDataSourceId = (id: string) => { | ||
return (dataSourceId?: string) => (dataSourceId ? `${dataSourceId}_` + id : id); | ||
}; | ||
|
||
export const getSavedObjectsWithDataSource = ( | ||
saveObjectList: SavedObject[], | ||
dataSourceId?: string, | ||
dataSourceTitle?: string | ||
): SavedObject[] => { | ||
if (dataSourceId) { | ||
return saveObjectList.map((saveObject) => { | ||
saveObject.id = `${dataSourceId}_` + saveObject.id; | ||
// update reference | ||
if (saveObject.type === 'dashboard') { | ||
saveObject.references.map((reference) => { | ||
if (reference.id) { | ||
reference.id = `${dataSourceId}_` + reference.id; | ||
} | ||
}); | ||
} | ||
|
||
// update reference | ||
if (saveObject.type === 'visualization' || saveObject.type === 'search') { | ||
const searchSourceString = saveObject.attributes?.kibanaSavedObjectMeta?.searchSourceJSON; | ||
const visStateString = saveObject.attributes?.visState; | ||
|
||
if (searchSourceString) { | ||
const searchSource = JSON.parse(searchSourceString); | ||
if (searchSource.index) { | ||
searchSource.index = `${dataSourceId}_` + searchSource.index; | ||
saveObject.attributes.kibanaSavedObjectMeta.searchSourceJSON = JSON.stringify( | ||
searchSource | ||
); | ||
} | ||
} | ||
|
||
if (visStateString) { | ||
const visState = JSON.parse(visStateString); | ||
const controlList = visState.params?.controls; | ||
if (controlList) { | ||
controlList.map((control) => { | ||
if (control.indexPattern) { | ||
control.indexPattern = `${dataSourceId}_` + control.indexPattern; | ||
} | ||
}); | ||
} | ||
saveObject.attributes.visState = JSON.stringify(visState); | ||
} | ||
} | ||
|
||
// update reference | ||
if (saveObject.type === 'index-pattern') { | ||
saveObject.references = [ | ||
{ | ||
id: `${dataSourceId}`, | ||
type: 'data-source', | ||
name: 'dataSource', | ||
}, | ||
]; | ||
} | ||
|
||
if (dataSourceTitle) { | ||
if ( | ||
saveObject.type === 'dashboard' || | ||
saveObject.type === 'visualization' || | ||
saveObject.type === 'search' | ||
) { | ||
saveObject.attributes.title = saveObject.attributes.title + `_${dataSourceTitle}`; | ||
} | ||
} | ||
|
||
return saveObject; | ||
}); | ||
} | ||
|
||
return saveObjectList; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.