-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: client changes for query stats (#5706)
* feat: changes for the query stats websockets * chore: remove unwanted files * fix: work on random id rather than hash * fix: improve the icons and design * feat: webpack and docker file changes * fix: test cases * chore: format the units * chore: address review comments * chore: update the id to uuid package * fix: build issues * chore: remove docker file changes * chore: remove docker file changes
- Loading branch information
1 parent
65280cf
commit 1b9683d
Showing
15 changed files
with
197 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
import getLocalStorageApi from 'api/browser/localstorage/get'; | ||
import { ENVIRONMENT } from 'constants/env'; | ||
import { LOCALSTORAGE } from 'constants/localStorage'; | ||
|
||
export interface WsDataEvent { | ||
read_rows: number; | ||
read_bytes: number; | ||
elapsed_ms: number; | ||
} | ||
interface GetQueryStatsProps { | ||
queryId: string; | ||
setData: React.Dispatch<React.SetStateAction<WsDataEvent | undefined>>; | ||
} | ||
|
||
export function getQueryStats(props: GetQueryStatsProps): void { | ||
const { queryId, setData } = props; | ||
|
||
const token = getLocalStorageApi(LOCALSTORAGE.AUTH_TOKEN) || ''; | ||
const socket = new WebSocket( | ||
`${ENVIRONMENT.wsURL}api/v3/query_progress?q=${queryId}`, | ||
token, | ||
); | ||
|
||
socket.addEventListener('message', (event) => { | ||
try { | ||
const parsedData = JSON.parse(event?.data); | ||
setData(parsedData); | ||
} catch { | ||
setData(event?.data); | ||
} | ||
}); | ||
} |
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
4 changes: 4 additions & 0 deletions
4
frontend/src/container/LogsExplorerViews/QueryStatus.styles.scss
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,4 @@ | ||
.query-status { | ||
display: flex; | ||
align-items: center; | ||
} |
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,42 @@ | ||
import './QueryStatus.styles.scss'; | ||
|
||
import { LoadingOutlined } from '@ant-design/icons'; | ||
import { Color } from '@signozhq/design-tokens'; | ||
import { Spin } from 'antd'; | ||
import { CircleCheck } from 'lucide-react'; | ||
import React, { useMemo } from 'react'; | ||
|
||
interface IQueryStatusProps { | ||
loading: boolean; | ||
error: boolean; | ||
success: boolean; | ||
} | ||
|
||
export default function QueryStatus( | ||
props: IQueryStatusProps, | ||
): React.ReactElement { | ||
const { loading, error, success } = props; | ||
|
||
const content = useMemo((): React.ReactElement => { | ||
if (loading) { | ||
return <Spin spinning size="small" indicator={<LoadingOutlined spin />} />; | ||
} | ||
if (error) { | ||
return ( | ||
<img | ||
src="/Icons/solid-x-circle.svg" | ||
alt="header" | ||
className="error" | ||
style={{ height: '14px', width: '14px' }} | ||
/> | ||
); | ||
} | ||
if (success) { | ||
return ( | ||
<CircleCheck className="success" size={14} fill={Color.BG_ROBIN_500} /> | ||
); | ||
} | ||
return <div />; | ||
}, [error, loading, success]); | ||
return <div className="query-status">{content}</div>; | ||
} |
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