-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Correlation CRUD operations #417
Merged
Merged
Changes from all commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
24bb27f
Correlation route and page setup
fdd6389
Added logTable toolbar
praveen5959 66b8237
Added sidebar and collapsable config
praveen5959 f37f28c
Added sidebar and collapsable config
praveen5959 544b400
Added new UX few items
praveen5959 baf8901
Added new desing flow for correlation
praveen5959 84ccdb8
correlation
praveen5959 edc3b90
Created Correlation store and new UX changes
praveen5959 c532cf2
Created Correlation store and new UX changes
praveen5959 ea155f3
Merge pull request #3 from praveen5959/main
praveen5959 71637c3
Moved useCorrelationQueryLogs to react-query
praveen5959 aae5b1e
A seperate hook for schema call
praveen5959 85a7254
Added stream-prefix
praveen5959 c4688e8
Moved to two stream approach
praveen5959 9a6eef3
Added correltation query logic
praveen5959 2a90341
Moved Querier to new component
praveen5959 c63df2a
fix: Add or update OFFSET clause in query (#376)
praveen5959 d8ffd31
fix: handle null userRoles in stream metadata fetching logic (#383)
praveen5959 b63380f
feat: improve UX and DX in delete and reset modals (#382)
pranavgoel29 721da8a
Moved Querier to new component
praveen5959 3c2dc2c
Added event lint graph to correlation
praveen5959 313e5a0
Added multi line graph to events
praveen5959 d650324
feat: collapsible explore page sidebar. (#378)
praveen5959 5cba882
feat: move timeRange to AppStore (#384)
praveen5959 9328b52
Rebased
praveen5959 38b876b
Rebased
praveen5959 bb53abd
Moved Querier to new component
praveen5959 10b3e76
Rebased to main
praveen5959 bfa07c1
Fixed extra schema call issue
praveen5959 4f6205c
Fixed the Event Graph queries
praveen5959 a98e889
Fixed the SQL query with alias
praveen5959 1f6d3ab
UI CHanges
praveen5959 3bcb3f4
Fixed SQL query
praveen5959 cddf346
Added Legend color to ChartTooltip
praveen5959 9ee3269
Fixed the EventGraph issue
praveen5959 827b26a
Fixed FieldItem Width issue
praveen5959 df67dec
Added loaders and removed dead code
praveen5959 202b024
Handled delete stream row bug
praveen5959 eb233e4
Resolved merge conflicts
praveen5959 5c98cb1
Added new CorrelationICon for navbar
praveen5959 751ae35
Added stepper for placeholder
praveen5959 4f3ec2a
Resolved lint issues
praveen5959 b5497ee
Fixed the after correltaion col addition bug
praveen5959 177431a
Fixed the deep nest warning in Log Table
praveen5959 f676bb0
Fixed the timeRange and other data view issues
praveen5959 6ece5d5
Fixed the pagination issues
praveen5959 bf5f3a7
Added loading state on schema call
praveen5959 01657d3
Merge branch 'main' of https://github.com/praveen5959/console into co…
praveen5959 2d5d674
Refactored CorrelationProvider
praveen5959 cba8817
Moved FieldItem to seperate component
praveen5959 bc44b05
Removed lodash dep from Correlation index.tsx
praveen5959 85a7fc1
Merge branch 'main' of https://github.com/praveen5959/console into co…
praveen5959 4dd31d3
Added Tooltips to the field item
praveen5959 7f19d6d
Big fixes reagarding delete field & Joins
praveen5959 a994d64
Fixed the scroll area CSS
praveen5959 5f42766
FIxed Empty rows case and loading states
praveen5959 06e61b0
Merge branch 'main' of https://github.com/praveen5959/console into co…
praveen5959 05fc7a0
fix: Pagination pageData
praveen5959 137f95f
fix: Totalpages count on pagination fixed
praveen5959 c2e4ebb
Bug fixes (timeRange page count, Share Btn)
praveen5959 f9f3a5e
Merge branch 'main' of https://github.com/praveen5959/console into co…
praveen5959 ae25fc2
Added URL params
praveen5959 961ac61
CRUD operations of correlations
praveen5959 2bce8ae
Removed unused files
praveen5959 801ce01
Removed empty file
praveen5959 006298b
Resolved merge conflicts
praveen5959 28a4351
Removed QueryEngine Logic
praveen5959 e2ff453
Improved the CorelationIcon logic
praveen5959 a5c4777
Resolved conflicts
praveen5959 32ef792
Rebased with base branch
praveen5959 d7d4a05
Added placeholder txt for query
praveen5959 a5572f9
Add streamData in store as per streamName in response
praveen5959 35e8a88
fix: Correlate button disable states fixed
praveen5959 667f685
Removed logs
praveen5959 55eb994
Resolved conflicts
praveen5959 52064f3
Update saved correlations fix
praveen5959 12da404
Merge branch 'main' of https://github.com/praveen5959/console into co…
praveen5959 e90643e
Merge branch 'correlation' of https://github.com/praveen5959/console …
praveen5959 0aedb67
Bug fixes
praveen5959 4ce85b9
fix: Correlate btn and explore page changes
praveen5959 d592b75
Merge branch 'correlation' of https://github.com/praveen5959/console …
praveen5959 118b11f
Resolved merge conflicts
praveen5959 5b57f6c
Lint fixes
praveen5959 c4af613
Merge branch 'correlation' of https://github.com/praveen5959/console …
praveen5959 f9e6098
Added update correlation logic
praveen5959 b6d229b
Merge branch 'main' into correlation-save
praveen5959 447cd5d
fix: Graph call fixes
praveen5959 c467bfe
fix: FIxed Update correlation btn text
praveen5959 5d167c1
Merge branch 'main' of https://github.com/praveen5959/console into co…
praveen5959 d055f68
fix: Graph fixes and other bug fixes
praveen5959 433f753
fix: Removed v1 text from correlation APIs
praveen5959 ca41faa
fix: Styles of join and table configs chagned
praveen5959 949ecae
fix: Changed /counts api response key names
praveen5959 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type Correlation = { | ||
version: string; | ||
id: string; | ||
title: string; | ||
tableConfigs: Array<{ | ||
selectedFields: string[]; | ||
tableName: string; | ||
}>; | ||
joinConfig: { | ||
joinConditions: Array<{ | ||
tableName: string; | ||
field: string; | ||
}>; | ||
}; | ||
filter: null; | ||
startTime: string; | ||
endTime: string; | ||
}; |
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,28 @@ | ||
import { Correlation } from '@/@types/parseable/api/correlation'; | ||
import { Axios } from './axios'; | ||
import { | ||
DELETE_SAVED_CORRELATION_URL, | ||
GET_SAVED_CORRELATION_URL, | ||
LIST_CORRELATIONS, | ||
UPDATE_CORRELATION_URL, | ||
} from './constants'; | ||
|
||
export const getCorrelations = () => { | ||
return Axios().get<Correlation[]>(LIST_CORRELATIONS); | ||
}; | ||
|
||
export const getCorrelationById = (correlationId: string) => { | ||
return Axios().get(GET_SAVED_CORRELATION_URL(correlationId)); | ||
}; | ||
|
||
export const deleteSavedCorrelation = (correlationId: string) => { | ||
return Axios().delete(DELETE_SAVED_CORRELATION_URL(correlationId)); | ||
}; | ||
|
||
export const saveCorrelation = (correlationData: Correlation) => { | ||
return Axios().post(LIST_CORRELATIONS, correlationData); | ||
}; | ||
|
||
export const updateCorrelation = (correlationData: Correlation) => { | ||
return Axios().put(UPDATE_CORRELATION_URL(correlationData.id), correlationData); | ||
}; |
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,157 @@ | ||
import { useMutation, useQuery } from 'react-query'; | ||
import _ from 'lodash'; | ||
|
||
import { | ||
deleteSavedCorrelation, | ||
getCorrelationById, | ||
getCorrelations, | ||
saveCorrelation, | ||
updateCorrelation, | ||
} from '@/api/correlations'; | ||
import { correlationStoreReducers, useCorrelationStore } from '@/pages/Correlation/providers/CorrelationProvider'; | ||
import { notifyError, notifySuccess } from '@/utils/notification'; | ||
import { AxiosError, isAxiosError } from 'axios'; | ||
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; | ||
import dayjs from 'dayjs'; | ||
|
||
const { | ||
setCorrelations, | ||
setActiveCorrelation, | ||
setCorrelationId, | ||
setSavedCorrelationId, | ||
cleanCorrelationStore, | ||
toggleSavedCorrelationsModal, | ||
} = correlationStoreReducers; | ||
const { setTimeRange, syncTimeRange } = appStoreReducers; | ||
export const useCorrelationsQuery = () => { | ||
const [{ correlationId }, setCorrelatedStore] = useCorrelationStore((store) => store); | ||
const [, setAppStore] = useAppStore((store) => store); | ||
const { | ||
isError: fetchCorrelationsError, | ||
isSuccess: fetchCorrelationsSuccess, | ||
isLoading: fetchCorrelationsLoading, | ||
refetch: fetchCorrelations, | ||
} = useQuery(['correlations'], () => getCorrelations(), { | ||
retry: false, | ||
enabled: false, | ||
refetchOnWindowFocus: false, | ||
onSuccess: (data) => { | ||
setCorrelatedStore((store) => setCorrelations(store, data.data || [])); | ||
}, | ||
onError: () => { | ||
setCorrelatedStore((store) => setCorrelations(store, [])); | ||
notifyError({ message: 'Failed to fetch correlations' }); | ||
}, | ||
}); | ||
|
||
const { | ||
mutate: getCorrelationByIdMutation, | ||
isError: fetchCorrelationIdError, | ||
isSuccess: fetchCorrelationIdSuccess, | ||
isLoading: fetchCorrelationIdLoading, | ||
} = useMutation((correlationId: string) => getCorrelationById(correlationId), { | ||
onSuccess: (data: any) => { | ||
data.data.startTime && | ||
data.data.endTime && | ||
setAppStore((store) => | ||
setTimeRange(store, { | ||
startTime: dayjs(data.data.startTime), | ||
endTime: dayjs(data.data.endTime), | ||
type: 'custom', | ||
}), | ||
); | ||
setCorrelatedStore((store) => setCorrelationId(store, data.data.id)); | ||
setCorrelatedStore((store) => setActiveCorrelation(store, data.data)); | ||
}, | ||
onError: () => { | ||
notifyError({ message: 'Failed to fetch correlation' }); | ||
}, | ||
}); | ||
|
||
const { mutate: deleteSavedCorrelationMutation, isLoading: isDeleting } = useMutation( | ||
(data: { correlationId: string; onSuccess?: () => void }) => deleteSavedCorrelation(data.correlationId), | ||
{ | ||
onSuccess: (_data, variables) => { | ||
variables.onSuccess && variables.onSuccess(); | ||
if (variables.correlationId === correlationId) { | ||
setCorrelatedStore(cleanCorrelationStore); | ||
setAppStore(syncTimeRange); | ||
} | ||
fetchCorrelations(); | ||
setCorrelatedStore((store) => toggleSavedCorrelationsModal(store, false)); | ||
notifySuccess({ message: 'Deleted Successfully' }); | ||
}, | ||
onError: (data: AxiosError) => { | ||
if (isAxiosError(data) && data.response) { | ||
const error = data.response?.data as string; | ||
typeof error === 'string' && notifyError({ message: error }); | ||
} else if (data.message && typeof data.message === 'string') { | ||
notifyError({ message: data.message }); | ||
} | ||
}, | ||
}, | ||
); | ||
|
||
const { mutate: saveCorrelationMutation, isLoading: isCorrelationSaving } = useMutation( | ||
(data: { correlationData: any; onSuccess?: () => void }) => saveCorrelation(data.correlationData), | ||
{ | ||
onSuccess: (data, variables) => { | ||
variables.onSuccess && variables.onSuccess(); | ||
setCorrelatedStore((store) => setCorrelationId(store, data.data.id)); | ||
setCorrelatedStore((store) => setSavedCorrelationId(store, data.data.id)); | ||
fetchCorrelations(); | ||
notifySuccess({ message: 'Correlation saved successfully' }); | ||
}, | ||
onError: (data: AxiosError) => { | ||
if (isAxiosError(data) && data.response) { | ||
const error = data.response?.data as string; | ||
typeof error === 'string' && notifyError({ message: error }); | ||
} else if (data.message && typeof data.message === 'string') { | ||
notifyError({ message: data.message }); | ||
} | ||
}, | ||
}, | ||
); | ||
|
||
const { mutate: updateCorrelationMutation, isLoading: isCorrelationUpdating } = useMutation( | ||
(data: { correlationData: any; onSuccess?: () => void }) => updateCorrelation(data.correlationData), | ||
{ | ||
onSuccess: (data, variables) => { | ||
variables.onSuccess && variables.onSuccess(); | ||
setCorrelatedStore((store) => setCorrelationId(store, data.data.id)); | ||
setCorrelatedStore((store) => setActiveCorrelation(store, data.data)); | ||
fetchCorrelations(); | ||
notifySuccess({ message: 'Correlation updated successfully' }); | ||
}, | ||
onError: (data: AxiosError) => { | ||
if (isAxiosError(data) && data.response) { | ||
const error = data.response?.data as string; | ||
typeof error === 'string' && notifyError({ message: error }); | ||
} else if (data.message && typeof data.message === 'string') { | ||
notifyError({ message: data.message }); | ||
} | ||
}, | ||
}, | ||
); | ||
|
||
return { | ||
fetchCorrelationsError, | ||
fetchCorrelationsSuccess, | ||
fetchCorrelationsLoading, | ||
fetchCorrelations, | ||
|
||
deleteSavedCorrelationMutation, | ||
isDeleting, | ||
|
||
fetchCorrelationIdError, | ||
fetchCorrelationIdSuccess, | ||
fetchCorrelationIdLoading, | ||
getCorrelationByIdMutation, | ||
|
||
saveCorrelationMutation, | ||
isCorrelationSaving, | ||
|
||
updateCorrelationMutation, | ||
isCorrelationUpdating, | ||
}; | ||
}; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
instead of returning the entire store u can return nil which will still return the setAppStore reducer