-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tyler Ohlsen <[email protected]>
- Loading branch information
Showing
38 changed files
with
831 additions
and
31 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
6 changes: 6 additions & 0 deletions
6
src/plugins/ui_actions/public/triggers/open_events_flyout_trigger.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,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const OPEN_EVENTS_FLYOUT_TRIGGER = 'OPEN_EVENTS_FLYOUT_TRIGGER'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { OPEN_EVENTS_FLYOUT_ACTION, OpenEventsFlyoutAction } from './open_events_flyout_action'; |
32 changes: 32 additions & 0 deletions
32
src/plugins/vis_augmenter/public/actions/open_events_flyout.tsx
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,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import React from 'react'; | ||
import { CoreStart } from 'src/core/public'; | ||
import { toMountPoint } from '../../../opensearch_dashboards_react/public'; | ||
import { ViewEventsFlyout } from '../components'; | ||
|
||
interface Props { | ||
core: CoreStart; | ||
savedObjectId: string; | ||
} | ||
|
||
export async function openViewEventsFlyout(props: Props) { | ||
const flyoutSession = props.core.overlays.openFlyout( | ||
toMountPoint( | ||
<ViewEventsFlyout | ||
onClose={() => { | ||
if (flyoutSession) { | ||
flyoutSession.close(); | ||
} | ||
}} | ||
savedObjectId={props.savedObjectId} | ||
/> | ||
), | ||
{ | ||
'data-test-subj': 'viewEventsFlyout', | ||
ownFocus: true, | ||
} | ||
); | ||
} |
48 changes: 48 additions & 0 deletions
48
src/plugins/vis_augmenter/public/actions/open_events_flyout_action.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,48 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { i18n } from '@osd/i18n'; | ||
import { CoreStart } from 'opensearch-dashboards/public'; | ||
import { | ||
Action, | ||
ActionExecutionContext, | ||
IncompatibleActionError, | ||
} from '../../../ui_actions/public'; | ||
import { AugmentVisContext } from '../triggers'; | ||
import { openViewEventsFlyout } from './open_events_flyout'; | ||
|
||
export const OPEN_EVENTS_FLYOUT_ACTION = 'OPEN_EVENTS_FLYOUT_ACTION'; | ||
|
||
export class OpenEventsFlyoutAction implements Action<AugmentVisContext> { | ||
public readonly type = OPEN_EVENTS_FLYOUT_ACTION; | ||
public readonly id = OPEN_EVENTS_FLYOUT_ACTION; | ||
public order = 1; | ||
|
||
constructor(private core: CoreStart) {} | ||
|
||
public getIconType(context: ActionExecutionContext<AugmentVisContext>) { | ||
return undefined; | ||
} | ||
|
||
public getDisplayName() { | ||
return i18n.translate('visAugmenter.displayName', { | ||
defaultMessage: 'Open View Events flyout', | ||
}); | ||
} | ||
|
||
public async isCompatible({ savedObjectId }: AugmentVisContext) { | ||
return true; | ||
} | ||
|
||
public async execute({ savedObjectId }: AugmentVisContext) { | ||
if (!(await this.isCompatible({ savedObjectId }))) { | ||
throw new IncompatibleActionError(); | ||
} | ||
openViewEventsFlyout({ | ||
core: this.core, | ||
savedObjectId, | ||
}); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/plugins/vis_augmenter/public/components/base_vis_item.tsx
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,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { getEmbeddable } from '../services'; | ||
import { VisualizeEmbeddable } from '../../../visualizations/public'; | ||
import './styles.scss'; | ||
|
||
interface Props { | ||
embeddable: VisualizeEmbeddable; | ||
} | ||
|
||
export function BaseVisItem(props: Props) { | ||
const PanelComponent = getEmbeddable().getEmbeddablePanel(); | ||
|
||
return ( | ||
<EuiFlexGroup direction="row" gutterSize="s"> | ||
<EuiFlexItem className="view-events-flyout__visDescription" grow={false} /> | ||
<EuiFlexItem grow={true} className="view-events-flyout__baseVis"> | ||
<PanelComponent | ||
embeddable={props.embeddable} | ||
hideHeader={true} | ||
hasBorder={false} | ||
hasShadow={false} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
} |
70 changes: 70 additions & 0 deletions
70
src/plugins/vis_augmenter/public/components/date_range_item.tsx
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,70 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import moment from 'moment'; | ||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiText, | ||
EuiIcon, | ||
prettyDuration, | ||
EuiButton, | ||
} from '@elastic/eui'; | ||
import './styles.scss'; | ||
import { TimeRange } from '../../../data/common'; | ||
import { DATE_RANGE_FORMAT } from './view_events_flyout'; | ||
|
||
interface Props { | ||
timeRange: TimeRange; | ||
reload: () => void; | ||
} | ||
|
||
export function DateRangeItem(props: Props) { | ||
const [lastUpdatedTime, setLastUpdatedTime] = useState<string>( | ||
moment(Date.now()).format(DATE_RANGE_FORMAT) | ||
); | ||
|
||
const durationText = prettyDuration( | ||
props.timeRange.from, | ||
props.timeRange.to, | ||
[], | ||
DATE_RANGE_FORMAT | ||
); | ||
|
||
return ( | ||
<EuiFlexGroup | ||
direction="row" | ||
gutterSize="m" | ||
alignItems="center" | ||
className="view-events-flyout__dateRangeHeader" | ||
> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type="calendar" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>{durationText}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton | ||
iconType={'refresh'} | ||
isDisabled={false} | ||
onClick={() => { | ||
props.reload(); | ||
setLastUpdatedTime(moment(Date.now()).format(DATE_RANGE_FORMAT)); | ||
}} | ||
> | ||
Refresh | ||
</EuiButton> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="s" color="subdued" style={{ whiteSpace: 'pre-line' }}> | ||
{`This view is not updated to load the latest events automatically. | ||
Last updated: ${lastUpdatedTime}`} | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
} |
47 changes: 47 additions & 0 deletions
47
src/plugins/vis_augmenter/public/components/event_vis_item.tsx
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,47 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiLink, EuiNotificationBadge } from '@elastic/eui'; | ||
import { getEmbeddable, getCore } from '../services'; | ||
import './styles.scss'; | ||
import { EventVisEmbeddableItem } from './'; | ||
|
||
interface Props { | ||
item: EventVisEmbeddableItem; | ||
} | ||
|
||
export function EventVisItem(props: Props) { | ||
const PanelComponent = getEmbeddable().getEmbeddablePanel(); | ||
const baseUrl = getCore().http.basePath; | ||
const { name, urlPath } = props.item.visLayer.pluginResource; | ||
|
||
return ( | ||
<> | ||
<EuiSpacer size="l" /> | ||
<EuiFlexGroup direction="row" gutterSize="s"> | ||
<EuiFlexItem grow={false} className="view-events-flyout__visDescription"> | ||
<EuiFlexGroup alignItems="center"> | ||
<EuiFlexItem> | ||
<EuiLink href={`${baseUrl.prepend(`${urlPath}`)}`}>{name}</EuiLink> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiNotificationBadge color="subdued">3</EuiNotificationBadge> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem grow={true} className="view-events-flyout__eventVis"> | ||
<PanelComponent | ||
embeddable={props.item.embeddable} | ||
hideHeader={true} | ||
hasBorder={false} | ||
hasShadow={false} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
); | ||
} |
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,10 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { | ||
ViewEventsFlyout, | ||
EventVisEmbeddablesMap, | ||
EventVisEmbeddableItem, | ||
} from './view_events_flyout'; |
19 changes: 19 additions & 0 deletions
19
src/plugins/vis_augmenter/public/components/loading_flyout.tsx
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,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFlyoutBody, EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui'; | ||
|
||
export function LoadingFlyout() { | ||
return ( | ||
<EuiFlyoutBody> | ||
<EuiFlexGroup justifyContent="spaceAround"> | ||
<EuiFlexItem grow={false}> | ||
<EuiLoadingSpinner size="xl" /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlyoutBody> | ||
); | ||
} |
Oops, something went wrong.