-
Notifications
You must be signed in to change notification settings - Fork 78
Refactor Saved objects and add visualization embeddable #341
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
Changes from all commits
30968c0
31ad03a
eddeb8d
d77e0d0
bcbd556
ed12d1f
aa672f0
62b1428
0fd0f1d
e27a98d
928fb51
c0a544f
79862f7
4d30c97
187af13
040ccff
83cf1c9
41af428
bc43414
9eb68bf
a2b9858
dac21f4
436bf2b
928612a
7027b01
bb31a6d
fb2cbed
cf9bd18
7138ea6
4eb6ff8
2ddab52
2cb37dc
d65345f
aa6b047
2880b2f
5f0b804
4d8ba6f
b3dccec
6a24e75
947764f
8abc0c3
2d6c7a9
573172c
0cb11bd
331251f
ced9040
35e2e3a
c90b58f
50dce49
ebdd3ea
bdfce75
27b2505
87de648
941f497
dde94bc
9f829cb
1189139
6bcefe3
786034d
4578974
8d0e517
6a0cf3c
a939098
0ab84f2
40cc1f2
5c2605a
a18f389
ece07f5
5fe84f0
415e9e5
e9647ef
2a25130
ad665d5
6813b03
a6552b9
617482f
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { SavedObjectAttributes } from '../../../../src/core/types'; | ||
| import { SavedVisualization } from './explorer'; | ||
|
|
||
| export const VISUALIZATION_SAVED_OBJECT = 'observability-visualization'; | ||
| export const OBSERVABILTY_SAVED_OBJECTS = [VISUALIZATION_SAVED_OBJECT] as const; | ||
| export const SAVED_OBJECT_VERSION = 1; | ||
|
|
||
| export interface VisualizationSavedObjectAttributes extends SavedObjectAttributes { | ||
| title: string; | ||
| description: string; | ||
| version: number; | ||
| createdTimeMs: number; | ||
| savedVisualization: SavedVisualization; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { | ||
| HttpStart, | ||
| IUiSettingsClient, | ||
| NotificationsStart, | ||
| SavedObjectsClientContract, | ||
| ToastInput, | ||
| } from '../../../../src/core/public'; | ||
| import { createGetterSetter } from '../../../../src/plugins/opensearch_dashboards_utils/common'; | ||
| import PPLService from '../../public/services/requests/ppl'; | ||
| import { QueryManager } from '../query_manager'; | ||
|
|
||
| let uiSettings: IUiSettingsClient; | ||
| let notifications: NotificationsStart; | ||
|
|
||
| export const uiSettingsService = { | ||
| init: (client: IUiSettingsClient, notificationsStart: NotificationsStart) => { | ||
| uiSettings = client; | ||
| notifications = notificationsStart; | ||
| }, | ||
| get: (key: string, defaultOverride?: any) => { | ||
| return uiSettings?.get(key, defaultOverride) || ''; | ||
| }, | ||
| set: (key: string, value: any) => { | ||
| return uiSettings?.set(key, value) || Promise.reject('uiSettings client not initialized.'); | ||
| }, | ||
| addToast: (toast: ToastInput) => { | ||
| return notifications.toasts.add(toast); | ||
| }, | ||
| }; | ||
|
|
||
| export const [getPPLService, setPPLService] = createGetterSetter<PPLService>('PPLService'); | ||
| export const [getOSDHttp, setOSDHttp] = createGetterSetter<HttpStart>('http'); | ||
| export const [getOSDSavedObjectsClient, setOSDSavedObjectsClient] = createGetterSetter< | ||
| SavedObjectsClientContract | ||
| >('SavedObjectsClient'); | ||
| export const [getQueryManager, setQueryManager] = createGetterSetter<QueryManager>('QueryManager'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,5 @@ export { | |
| composeFinalQuery, | ||
| removeBacktick, | ||
| } from './query_utils'; | ||
| export { uiSettingsService } from './settings_service'; | ||
|
|
||
| export * from './core_services'; | ||
|
Member
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. Should we use
Member
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. lint didn't complain but I was going to remove functions in |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ import { | |
| PPL_INDEX_INSERT_POINT_REGEX, | ||
| PPL_INDEX_REGEX, | ||
| PPL_NEWLINE_REGEX, | ||
| PPL_STATS_REGEX, | ||
| } from '../../common/constants/shared'; | ||
|
|
||
| /** | ||
|
|
@@ -42,6 +41,7 @@ export const preprocessQuery = ({ | |
| selectedPatternField, | ||
| patternRegex, | ||
| filteredPattern, | ||
| whereClause, | ||
| }: { | ||
| rawQuery: string; | ||
| startTime: string; | ||
|
|
@@ -51,6 +51,7 @@ export const preprocessQuery = ({ | |
| selectedPatternField?: string; | ||
| patternRegex?: string; | ||
| filteredPattern?: string; | ||
| whereClause?: string; | ||
| }) => { | ||
| let finalQuery = ''; | ||
|
|
||
|
|
@@ -65,7 +66,13 @@ export const preprocessQuery = ({ | |
|
|
||
| finalQuery = `${tokens![1]}=${ | ||
| tokens![2] | ||
| } | where ${timeField} >= '${start}' and ${timeField} <= '${end}'${tokens![3]}`; | ||
| } | where ${timeField} >= '${start}' and ${timeField} <= '${end}'`; | ||
|
|
||
| if (whereClause) { | ||
| finalQuery += ` AND ${whereClause}`; | ||
| } | ||
|
Comment on lines
+71
to
+73
Member
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. nice. 😄
Member
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 temporary and will change when we support DSL in PPL where clauses |
||
|
|
||
| finalQuery += tokens![3]; | ||
|
|
||
| if (isLiveQuery) { | ||
| finalQuery = finalQuery + ` | sort - ${timeField}`; | ||
|
|
||
This file was deleted.
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.
I see that we are using the public service for SavedObjects. The server service has more options for something like version: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/416eb508b3b22fe81231b726dcfce09e3aad9bfb/src/core/server/saved_objects/service/saved_objects_client.ts#L47-L71
Did we take a look at it?
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.
version can be passed as a create option in server but not in frontend. https://github.com/opensearch-project/opensearch-dashboards/blob/11b98ec05483269917c335fcb1900bf98da8cac6/src/core/public/saved_objects/saved_objects_client.ts#L54
If we want to use it then saved object client should be called in server? But this seems to be the version of a specific object that will change on each update, not sure if it would be useful for us
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.
That isn't required then. 👍🏽