Skip to content
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

feat: implement namespaces list table in infra monitoring #6617

Open
wants to merge 8 commits into
base: feat/infra-monitoring-k8s
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions frontend/src/api/infraMonitoring/getK8sNamespacesList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { ApiBaseInstance } from 'api';
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
import { AxiosError } from 'axios';
import { ErrorResponse, SuccessResponse } from 'types/api';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';

export interface K8sNamespacesListPayload {
filters: TagFilter;
groupBy?: BaseAutocompleteData[];
offset?: number;
limit?: number;
orderBy?: {
columnName: string;
order: 'asc' | 'desc';
};
}

export interface K8sNamespacesData {
namespaceName: string;
cpuUsage: number;
memoryUsage: number;
meta: {
k8s_cluster_name: string;
k8s_namespace_uid: string;
};
}

export interface K8sNamespacesListResponse {
status: string;
data: {
type: string;
records: K8sNamespacesData[];
groups: null;
total: number;
sentAnyHostMetricsData: boolean;
isSendingK8SAgentMetrics: boolean;
};
}

export const getK8sNamespacesList = async (
props: K8sNamespacesListPayload,
signal?: AbortSignal,
headers?: Record<string, string>,
): Promise<SuccessResponse<K8sNamespacesListResponse> | ErrorResponse> => {
try {
const response = await ApiBaseInstance.post('/namespaces/list', props, {
signal,
headers,
});

return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);
}
};
1 change: 1 addition & 0 deletions frontend/src/constants/reactQueryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export const REACT_QUERY_KEY = {
GET_HOST_LIST: 'GET_HOST_LIST',
UPDATE_ALERT_RULE: 'UPDATE_ALERT_RULE',
GET_ACTIVE_LICENSE_V3: 'GET_ACTIVE_LICENSE_V3',
GET_NAMESPACE_LIST: 'GET_NAMESPACE_LIST',
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
StatefulsetsQuickFiltersConfig,
VolumesQuickFiltersConfig,
} from './constants';
import K8sNamespacesList from './Namespaces/K8sNamespacesList';
import K8sPodLists from './Pods/K8sPodLists';
import Volumes from './Volumes/Volumes';

Expand Down Expand Up @@ -323,6 +324,13 @@ export default function InfraMonitoringK8s(): JSX.Element {
/>
)}

{selectedCategory === K8sCategories.NAMESPACES && (
<K8sNamespacesList
isFiltersVisible={showFilters}
handleFilterVisibilityChange={handleFilterVisibilityChange}
/>
)}

{selectedCategory === K8sCategories.VOLUMES && <Volumes />}
</div>
</div>
Expand Down
28 changes: 18 additions & 10 deletions frontend/src/container/InfraMonitoringK8s/K8sHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import './InfraMonitoringK8s.styles.scss';

import { Button, Select } from 'antd';
Expand All @@ -14,15 +15,15 @@ import { IPodColumn } from './utils';

interface K8sHeaderProps {
selectedGroupBy: BaseAutocompleteData[];
defaultAddedColumns: IPodColumn[];
groupByOptions: { value: string; label: string }[];
addedColumns: IPodColumn[];
isLoadingGroupByFilters: boolean;
availableColumns: IPodColumn[];
handleFiltersChange: (value: IBuilderQuery['filters']) => void;
handleGroupByChange: (value: IBuilderQuery['groupBy']) => void;
onAddColumn: (column: IPodColumn) => void;
onRemoveColumn: (column: IPodColumn) => void;
defaultAddedColumns: IPodColumn[];
addedColumns?: IPodColumn[];
availableColumns?: IPodColumn[];
onAddColumn?: (column: IPodColumn) => void;
onRemoveColumn?: (column: IPodColumn) => void;
handleFilterVisibilityChange: () => void;
isFiltersVisible: boolean;
}
Expand All @@ -32,12 +33,12 @@ function K8sHeader({
defaultAddedColumns,
groupByOptions,
isLoadingGroupByFilters,
addedColumns,
availableColumns,
addedColumns = [],
availableColumns = [],
handleFiltersChange,
handleGroupByChange,
onAddColumn,
onRemoveColumn,
onAddColumn = () => {},
onRemoveColumn = () => {},
handleFilterVisibilityChange,
isFiltersVisible,
}: K8sHeaderProps): JSX.Element {
Expand Down Expand Up @@ -125,7 +126,7 @@ function K8sHeader({
<Button
type="text"
className="periscope-btn ghost"
disabled={selectedGroupBy.length > 0}
disabled={selectedGroupBy?.length > 0}
onClick={(): void => setIsFiltersSidePanelOpen(true)}
>
<SlidersHorizontal size={14} />
Expand All @@ -150,4 +151,11 @@ function K8sHeader({
);
}

K8sHeader.defaultProps = {
addedColumns: [],
availableColumns: [],
onAddColumn: () => {},
onRemoveColumn: () => {},
};

export default K8sHeader;
Loading
Loading