-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
258 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
flex-direction: column; | ||
|
||
min-width: 300px; | ||
height: max-content; | ||
} | ||
|
||
&__modal { | ||
|
9 changes: 9 additions & 0 deletions
9
src/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/TenantMemory.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,9 @@ | ||
import {TopNodesByMemory} from './TopNodesByMemory'; | ||
|
||
interface TenantMemoryProps { | ||
path: string; | ||
} | ||
|
||
export function TenantMemory({path}: TenantMemoryProps) { | ||
return <TopNodesByMemory path={path} />; | ||
} |
55 changes: 55 additions & 0 deletions
55
src/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/TopNodesByMemory.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,55 @@ | ||
import {useDispatch} from 'react-redux'; | ||
import {useCallback} from 'react'; | ||
|
||
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks'; | ||
import { | ||
getTopNodesByMemory, | ||
selectTopNodesByMemory, | ||
setDataWasNotLoaded, | ||
} from '../../../../../store/reducers/tenantOverview/topNodesByMemory/topNodesByMemory'; | ||
import type {AdditionalNodesProps} from '../../../../../types/additionalProps'; | ||
import {getTopNodesByMemoryColumns} from '../../../../Nodes/getNodesColumns'; | ||
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout'; | ||
|
||
import i18n from '../i18n'; | ||
|
||
interface TopNodesByMemoryProps { | ||
path: string; | ||
additionalNodesProps?: AdditionalNodesProps; | ||
} | ||
|
||
export function TopNodesByMemory({path, additionalNodesProps}: TopNodesByMemoryProps) { | ||
const dispatch = useDispatch(); | ||
|
||
const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByMemory); | ||
const {autorefresh} = useTypedSelector((state) => state.schema); | ||
const topNodes = useTypedSelector(selectTopNodesByMemory); | ||
const columns = getTopNodesByMemoryColumns({ | ||
getNodeRef: additionalNodesProps?.getNodeRef, | ||
}); | ||
|
||
const fetchNodes = useCallback( | ||
(isBackground) => { | ||
if (!isBackground) { | ||
dispatch(setDataWasNotLoaded()); | ||
} | ||
|
||
dispatch(getTopNodesByMemory({tenant: path})); | ||
}, | ||
[dispatch, path], | ||
); | ||
|
||
useAutofetcher(fetchNodes, [fetchNodes], autorefresh); | ||
|
||
return ( | ||
<TenantOverviewTableLayout | ||
data={topNodes || []} | ||
columns={columns} | ||
title="Top nodes by memory" | ||
loading={loading} | ||
wasLoaded={wasLoaded} | ||
error={error} | ||
emptyDataMessage={i18n('top-nodes.empty-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
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
87 changes: 87 additions & 0 deletions
87
src/store/reducers/tenantOverview/topNodesByMemory/topNodesByMemory.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,87 @@ | ||
import type {Reducer} from 'redux'; | ||
|
||
import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants'; | ||
import {createApiRequest, createRequestActionTypes} from '../../../utils'; | ||
import {prepareNodesData} from '../../nodes/utils'; | ||
import type {NodesApiRequestParams} from '../../nodes/types'; | ||
import type {TopNodesByMemoryAction, TopNodesByMemoryState, TopNodesByMemorySlice} from './types'; | ||
|
||
export const FETCH_TOP_NODES_BY_MEMORY = createRequestActionTypes( | ||
'topNodesByMemory', | ||
'FETCH_TOP_NODES_BY_MEMORY', | ||
); | ||
const SET_DATA_WAS_NOT_LOADED = 'topNodesByMemory/SET_DATA_WAS_NOT_LOADED'; | ||
|
||
const initialState = { | ||
loading: false, | ||
wasLoaded: false, | ||
}; | ||
|
||
export const topNodesByMemory: Reducer<TopNodesByMemoryState, TopNodesByMemoryAction> = ( | ||
state = initialState, | ||
action, | ||
) => { | ||
switch (action.type) { | ||
case FETCH_TOP_NODES_BY_MEMORY.REQUEST: { | ||
return { | ||
...state, | ||
loading: true, | ||
}; | ||
} | ||
case FETCH_TOP_NODES_BY_MEMORY.SUCCESS: { | ||
return { | ||
...state, | ||
data: action.data?.Nodes, | ||
loading: false, | ||
wasLoaded: true, | ||
error: undefined, | ||
}; | ||
} | ||
case FETCH_TOP_NODES_BY_MEMORY.FAILURE: { | ||
if (action.error?.isCancelled) { | ||
return state; | ||
} | ||
|
||
return { | ||
...state, | ||
error: action.error, | ||
loading: false, | ||
}; | ||
} | ||
case SET_DATA_WAS_NOT_LOADED: { | ||
return { | ||
...state, | ||
wasLoaded: false, | ||
}; | ||
} | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
const concurrentId = 'getTopNodeByMemory'; | ||
|
||
export function getTopNodesByMemory({ | ||
type = 'any', | ||
sortOrder = -1, | ||
sortValue = 'Memory', | ||
limit = TENANT_OVERVIEW_TABLES_LIMIT, | ||
...params | ||
}: NodesApiRequestParams) { | ||
return createApiRequest({ | ||
request: window.api.getNodes( | ||
{type, sortOrder, sortValue, limit, ...params}, | ||
{concurrentId}, | ||
), | ||
actions: FETCH_TOP_NODES_BY_MEMORY, | ||
dataHandler: prepareNodesData, | ||
}); | ||
} | ||
|
||
export const selectTopNodesByMemory = (state: TopNodesByMemorySlice) => state.topNodesByMemory.data; | ||
|
||
export const setDataWasNotLoaded = () => { | ||
return { | ||
type: SET_DATA_WAS_NOT_LOADED, | ||
} as const; | ||
}; |
29 changes: 29 additions & 0 deletions
29
src/store/reducers/tenantOverview/topNodesByMemory/types.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,29 @@ | ||
import type {IResponseError} from '../../../../types/api/error'; | ||
import type {ApiRequestAction} from '../../../utils'; | ||
import type {NodesPreparedEntity} from '../../nodes/types'; | ||
import {FETCH_TOP_NODES_BY_MEMORY, setDataWasNotLoaded} from './topNodesByMemory'; | ||
|
||
export interface TopNodesByMemoryState { | ||
loading: boolean; | ||
wasLoaded: boolean; | ||
data?: NodesPreparedEntity[]; | ||
error?: IResponseError; | ||
} | ||
|
||
export interface TopNodesByMemoryHandledResponse { | ||
Nodes?: NodesPreparedEntity[]; | ||
} | ||
|
||
type TopNodesByMemoryApiRequestAction = ApiRequestAction< | ||
typeof FETCH_TOP_NODES_BY_MEMORY, | ||
TopNodesByMemoryHandledResponse, | ||
IResponseError | ||
>; | ||
|
||
export type TopNodesByMemoryAction = | ||
| TopNodesByMemoryApiRequestAction | ||
| ReturnType<typeof setDataWasNotLoaded>; | ||
|
||
export interface TopNodesByMemorySlice { | ||
topNodesByMemory: TopNodesByMemoryState; | ||
} |
Oops, something went wrong.