Skip to content

Commit

Permalink
refactor consts export/import
Browse files Browse the repository at this point in the history
Signed-off-by: ruiyi.jiang <[email protected]>
  • Loading branch information
shanghaikid committed Aug 7, 2023
1 parent 9713865 commit 8271ddc
Show file tree
Hide file tree
Showing 38 changed files with 69 additions and 70 deletions.
2 changes: 1 addition & 1 deletion client/src/components/__test__/status/Status.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Status from '../../status/Status';
import { LOADING_STATE } from '../../../consts/Milvus';
import { LOADING_STATE } from '@/consts';
import { render, screen } from '@testing-library/react';
import { vi } from 'vitest';

Expand Down
4 changes: 2 additions & 2 deletions client/src/components/advancedSearch/Condition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
import CloseIcon from '@material-ui/icons/Close';
import { ConditionProps, Field } from './Types';
import CustomSelector from '../customSelector/CustomSelector';
import { LOGICAL_OPERATORS } from '../../consts/Util';
import { DataTypeStringEnum } from '../../pages/collections/Types';
import { LOGICAL_OPERATORS } from '@/consts';
import { DataTypeStringEnum } from '@/pages/collections/Types';
import { formatValue, checkValue } from './utils';

const Condition: FC<ConditionProps> = props => {
Expand Down
3 changes: 1 addition & 2 deletions client/src/components/layout/GlobalEffect.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useContext } from 'react';
import axiosInstance from '@/http/Axios';
import { rootContext, authContext } from '@/context';
import { HTTP_STATUS_CODE } from '@/consts/Http';
import { MILVUS_ADDRESS } from '@/consts/Localstorage';
import { HTTP_STATUS_CODE, MILVUS_ADDRESS } from '@/consts';

let axiosResInterceptor: number | null = null;
// let timer: Record<string, ReturnType<typeof setTimeout> | number>[] = [];
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { makeStyles, Theme, createStyles, Typography } from '@material-ui/core';
import { useNavigate } from 'react-router-dom';
import { navContext, databaseContext, authContext } from '@/context';
import { MilvusHttp } from '@/http/Milvus';
import { MILVUS_ADDRESS } from '@/consts/Localstorage';
import { MILVUS_ADDRESS } from '@/consts';
import CustomSelector from '@/components/customSelector/CustomSelector';
import icons from '../icons/Icons';
import { HeaderType } from './Types';
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/status/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Typography,
useTheme,
} from '@material-ui/core';
import { LOADING_STATE } from '../../consts/Milvus';
import { LOADING_STATE } from '@/consts';
import StatusIcon from './StatusIcon';

const useStyles = makeStyles((theme: Theme) =>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/status/Types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LOADING_STATE } from '../../consts/Milvus';
import { LOADING_STATE } from '@/consts';

// export enum StatusEnum {
// 'unloaded',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataTypeEnum } from '../pages/collections/Types';
import { DataTypeEnum } from '@/pages/collections/Types';

export const MILVUS_URL =
((window as any)._env_ && (window as any)._env_.MILVUS_URL) || '';
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions client/src/consts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './Http';
export * from './Insert';
export * from './Localstorage';
export * from './Milvus';
export * from './Prometheus';
export * from './Util';
2 changes: 1 addition & 1 deletion client/src/context/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext, useEffect, useState } from 'react';
import { MILVUS_ADDRESS } from '@/consts/Localstorage';
import { MILVUS_ADDRESS } from '@/consts';
import { MilvusHttp } from '@/http/Milvus';
import { AuthContextType } from './Types';

Expand Down
8 changes: 3 additions & 5 deletions client/src/context/Prometheus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import {
LAST_TIME_PROMETHEUS_ADDRESS,
LAST_TIME_PROMETHEUS_INSTANCE,
LAST_TIME_PROMETHEUS_NAMESPACE,
} from '@/consts/Localstorage';
import { formatPrometheusAddress } from '@/utils';
import { PrometheusHttp } from '@/http/Prometheus';
import {
PROMETHEUS_ADDRESS,
PROMETHEUS_INSTANCE_NAME,
PROMETHEUS_NAMESPACE,
WITH_PROMETHEUS,
} from '@/consts/Prometheus';
} from '@/consts';
import { formatPrometheusAddress } from '@/utils';
import { PrometheusHttp } from '@/http/Prometheus';

export const prometheusContext = createContext<PrometheusContextType>({
withPrometheus: false,
Expand Down
2 changes: 1 addition & 1 deletion client/src/context/WebSocket.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext, useContext, useEffect, useState, useRef } from 'react';
import { io, Socket } from 'socket.io-client';
import { WS_EVENTS, WS_EVENTS_TYPE } from '@/consts/Http';
import { WS_EVENTS, WS_EVENTS_TYPE } from '@/consts';
import { authContext } from '@/context';
import { url } from '@/http/Axios';
import { CollectionHttp } from '@/http/Collection';
Expand Down
3 changes: 1 addition & 2 deletions client/src/http/Axios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import { MILVUS_ADDRESS } from '../consts/Localstorage';
// import { SESSION } from '../consts/Localstorage';
import { MILVUS_ADDRESS } from '@/consts';

// console.log(import.meta.env.NODE_ENV, 'api:', import.meta.env.VITE_BASE_URL);
// console.log('docker env', (window as any)._env_);
Expand Down
6 changes: 3 additions & 3 deletions client/src/http/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {
Replica,
} from '../pages/collections/Types';
import { LoadSampleParam } from '../pages/dialogs/Types';
import { Field } from '../pages/schema/Types';
import { Field } from '@/pages/schema/Types';
import { VectorSearchParam } from '../types/SearchTypes';
import { QueryParam } from '../pages/query/Types';
import { QueryParam } from '@/pages/query/Types';
import { IndexState, ShowCollectionsType } from '../types/Milvus';
import { formatNumber } from '../utils/Common';
import BaseModel from './BaseModel';
import { FieldHttp } from './Field';
import dayjs from 'dayjs';
import { LOADING_STATE } from '../consts/Milvus';
import { LOADING_STATE } from '@/consts';

export class CollectionHttp extends BaseModel implements CollectionView {
private aliases!: string[];
Expand Down
2 changes: 1 addition & 1 deletion client/src/http/Milvus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WS_EVENTS, WS_EVENTS_TYPE } from '../consts/Http';
import { WS_EVENTS, WS_EVENTS_TYPE } from '@/consts';
import BaseModel from './BaseModel';

export class MilvusHttp extends BaseModel {
Expand Down
8 changes: 4 additions & 4 deletions client/src/http/Partition.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import dayjs from 'dayjs';
import { LOADING_STATE } from '../consts/Milvus';
import { LOADING_STATE } from '@/consts';
import {
PartitionManageParam,
PartitionParam,
PartitionData,
} from '../pages/partitions/Types';
import { formatNumber } from '../utils/Common';
} from '@/pages/partitions/Types';
import { formatNumber } from '@/utils';
import BaseModel from './BaseModel';

export class PartitionHttp extends BaseModel implements PartitionData {
Expand Down Expand Up @@ -82,7 +82,7 @@ export class PartitionHttp extends BaseModel implements PartitionData {

get _status() {
// @TODO replace mock data
return LOADING_STATE.UNLOADED
return LOADING_STATE.UNLOADED;
}

// Befor milvus-2.0-rc3 will return '0'.
Expand Down
3 changes: 1 addition & 2 deletions client/src/pages/collections/Collections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import RenameCollectionDialog from '../dialogs/RenameCollectionDialog';
import InsertDialog from '../dialogs/insert/Dialog';
import ImportSampleDialog from '../dialogs/ImportSampleDialog';
import { MilvusHttp } from '@/http/Milvus';
import { LOADING_STATE } from '@/consts/Milvus';
import { WS_EVENTS, WS_EVENTS_TYPE } from '@/consts/Http';
import { LOADING_STATE, WS_EVENTS, WS_EVENTS_TYPE } from '@/consts';
import { checkIndexBuilding, checkLoading } from '@/utils';
import Aliases from './Aliases';

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/collections/Types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, ReactElement, SetStateAction } from 'react';
import { ChildrenStatusType } from '@/components/status/Types';
import { LOADING_STATE } from '../../consts/Milvus';
import { LOADING_STATE } from '@/consts';
import { FieldData } from '../schema/Types';

export interface CollectionData {
Expand Down
4 changes: 1 addition & 3 deletions client/src/pages/connect/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import { formatForm } from '@/utils';
import { MilvusHttp } from '@/http/Milvus';
import { useNavigate } from 'react-router-dom';
import { rootContext, authContext, prometheusContext } from '@/context';
import {} from '@/context/Auth';
import { MILVUS_ADDRESS, LAST_TIME_ADDRESS } from '@/consts/Localstorage';
import { MILVUS_URL } from '@/consts/Milvus';
import { MILVUS_ADDRESS, LAST_TIME_ADDRESS, MILVUS_URL } from '@/consts';
import { CustomRadio } from '@/components/customRadio/CustomRadio';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/dialogs/LoadCollectionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ITextfieldConfig } from '@/components/customInput/Types';
import DialogTemplate from '@/components/customDialog/DialogTemplate';
import { MilvusHttp } from '@/http/Milvus';
import CustomToolTip from '@/components/customToolTip/CustomToolTip';
import { MILVUS_NODE_TYPE, MILVUS_DEPLOY_MODE } from '@/consts/Milvus';
import { MILVUS_NODE_TYPE, MILVUS_DEPLOY_MODE } from '@/consts';
import icons from '@/components/icons/Icons';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/dialogs/insert/Import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { makeStyles, Theme, Divider, Typography } from '@material-ui/core';
import CustomSelector from '@/components/customSelector/CustomSelector';
import { InsertImportProps } from './Types';
import Uploader from '@/components/uploader/Uploader';
import { INSERT_CSV_SAMPLE, INSERT_MAX_SIZE } from '../../../consts/Insert';
import { INSERT_MAX_SIZE } from '@/consts';
import { parseByte } from '@/utils';

const getStyles = makeStyles((theme: Theme) => ({
Expand Down Expand Up @@ -180,7 +180,7 @@ const InsertImport: FC<InsertImportProps> = ({
{insertTrans('noteTitle')}
</Typography>
<ul className="noteList">
{insertTrans('notes').map(note => (
{insertTrans('notes').map((note: string) => (
<li key={note} className="text noteItem">
<Typography>{note}</Typography>
</li>
Expand Down
3 changes: 1 addition & 2 deletions client/src/pages/overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useTranslation } from 'react-i18next';
import { rootContext, webSocketContext, databaseContext } from '@/context';
import EmptyCard from '@/components/cards/EmptyCard';
import icons from '@/components/icons/Icons';
import { WS_EVENTS, WS_EVENTS_TYPE } from '@/consts/Http';
import { LOADING_STATE } from '@/consts/Milvus';
import { WS_EVENTS, WS_EVENTS_TYPE, LOADING_STATE } from '@/consts';
import { useNavigationHook } from '@/hooks';
import { CollectionHttp } from '@/http/Collection';
import { MilvusHttp } from '@/http/Milvus';
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/overview/collectionCard/CollectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { FC, useContext } from 'react';
import CustomButton from '@/components/customButton/CustomButton';
import icons from '@/components/icons/Icons';
import Status from '@/components/status/Status';
import { CollectionCardProps } from './Types';
import { useTranslation } from 'react-i18next';
import CustomIconButton from '@/components/customButton/CustomIconButton';
import { useNavigate, Link } from 'react-router-dom';
import { LOADING_STATE } from '@/consts/Milvus';
import ReleaseCollectionDialog from '../../dialogs/ReleaseCollectionDialog';
import { LOADING_STATE } from '@/consts';
import { rootContext } from '@/context';
import ReleaseCollectionDialog from '../../dialogs/ReleaseCollectionDialog';
import { CollectionCardProps } from './Types';

const useStyles = makeStyles((theme: Theme) => ({
wrapper: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/partitions/Types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactElement } from 'react';
import { LOADING_STATE } from '../../consts/Milvus';
import { LOADING_STATE } from '@/consts';
import { ManageRequestMethods } from '../../types/Common';

export interface PartitionData {
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ToolBarConfig } from '@/components/grid/Types';
import CustomToolBar from '@/components/grid/ToolBar';
import { generateVector } from '@/utils';
import { DataTypeEnum } from '@/pages/collections/Types';
import { INDEX_CONFIG, DEFAULT_SEARCH_PARAM_VALUE_MAP } from '@/consts/Milvus';
import { INDEX_CONFIG, DEFAULT_SEARCH_PARAM_VALUE_MAP } from '@/consts';

const Preview: FC<{
collectionName: string;
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/schema/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
INDEX_CONFIG,
INDEX_OPTIONS_MAP,
METRIC_TYPES_VALUES,
} from '@/consts/Milvus';
} from '@/consts';
import { useFormValidation } from '@/hooks';
import { getCreateIndexJSCode } from '@/utils/code/Js';
import { getCreateIndexPYCode } from '@/utils/code/Py';
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/schema/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useTranslation } from 'react-i18next';
import { ITextfieldConfig } from '@/components/customInput/Types';
import CustomInput from '@/components/customInput/CustomInput';
import CustomSelector from '@/components/customSelector/CustomSelector';
import { m_OPTIONS } from '../../consts/Milvus';
import { FormHelperType } from '../../types/Common';
import { Option } from '@/components/customSelector/Types';
import { m_OPTIONS } from '@/consts';
import { FormHelperType } from '../../types/Common';

const useStyles = makeStyles((theme: Theme) => ({
wrapper: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/schema/Types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactElement } from 'react';
import { MetricType } from '../../consts/Milvus';
import { MetricType } from '@/consts';
import { DataTypeStringEnum } from '../collections/Types';

export enum INDEX_TYPES_ENUM {
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/search/SearchParams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
INDEX_CONFIG,
METRIC_OPTIONS_MAP,
searchKeywordsType,
} from '@/consts/Milvus';
} from '@/consts';
import { rootContext } from '@/context';
import { useFormValidation } from '@/hooks';
import { formatForm } from '@/utils';
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/search/Types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Option } from '@/components/customSelector/Types';
import { searchKeywordsType } from '../../consts/Milvus';
import { searchKeywordsType } from '@/consts';
import {
DataTypeEnum,
DataTypeStringEnum,
Expand Down
3 changes: 1 addition & 2 deletions client/src/pages/search/VectorSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import {
cloneObj,
generateVector,
} from '@/utils';
import { LOADING_STATE } from '@/consts/Milvus';
import { DEFAULT_METRIC_VALUE_MAP } from '@/consts/Milvus';
import { LOADING_STATE, DEFAULT_METRIC_VALUE_MAP } from '@/consts';
import { getLabelDisplayedRows } from './Utils';
import SearchParams from './SearchParams';
import { getVectorSearchStyles } from './Styles';
Expand Down
15 changes: 7 additions & 8 deletions client/src/pages/systemHealthy/SystemHealthyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { useTranslation } from 'react-i18next';
import { useNavigationHook, useInterval } from '@/hooks';
import { PrometheusHttp } from '@/http/Prometheus';
import { ALL_ROUTER_TYPES } from '@/router/Types';
import {
LAST_TIME_HEALTHY_THRESHOLD_CPU,
LAST_TIME_HEALTHY_THRESHOLD_MEMORY,
DEFAULT_HEALTHY_THRESHOLD_CPU,
DEFAULT_HEALTHY_THRESHOLD_MEMORY,
} from '@/consts';
import {
ENodeService,
ILineChartData,
Expand All @@ -16,14 +22,7 @@ import Topology from './Topology';
import { reconNodeTree } from './dataHandler';
import HealthyIndexOverview from './HealthyIndexOverview';
import { timeRangeOptions } from './consts';
import {
LAST_TIME_HEALTHY_THRESHOLD_CPU,
LAST_TIME_HEALTHY_THRESHOLD_MEMORY,
} from '@/consts/Localstorage';
import {
DEFAULT_HEALTHY_THRESHOLD_CPU,
DEFAULT_HEALTHY_THRESHOLD_MEMORY,
} from '@/consts/Prometheus';


const getStyles = makeStyles((theme: Theme) => ({
root: {
Expand Down
8 changes: 4 additions & 4 deletions client/src/types/SearchTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Option } from '../components/customSelector/Types';
import { searchKeywordsType } from '../consts/Milvus';
import { DataTypeEnum, DataTypeStringEnum } from '../pages/collections/Types';
import { IndexView } from '../pages/schema/Types';
import { Option } from '@/components/customSelector/Types';
import { searchKeywordsType } from '@/consts';
import { DataTypeEnum, DataTypeStringEnum } from '@/pages/collections/Types';
import { IndexView } from '@/pages/schema/Types';

export interface SearchParamsProps {
// if user created index, pass metric type choosed when creating
Expand Down
2 changes: 1 addition & 1 deletion client/src/utils/Form.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Option } from '@/components/customSelector/Types';
import { METRIC_TYPES_VALUES } from '@/consts/Milvus';
import { METRIC_TYPES_VALUES } from '@/consts';
import { IForm } from '@/hooks';
import { DataTypeStringEnum } from '@/pages/collections/Types';
import { IndexType } from '@/pages/schema/Types';
Expand Down
9 changes: 6 additions & 3 deletions client/src/utils/Format.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { BYTE_UNITS } from '../consts/Util';
import { DEFAULT_MILVUS_PORT, DEFAULT_PROMETHEUS_PORT } from '../consts/Milvus';
import {
BYTE_UNITS,
DEFAULT_MILVUS_PORT,
DEFAULT_PROMETHEUS_PORT,
} from '@/consts';
import {
CreateFieldType,
DataTypeEnum,
Field,
} from '../pages/collections/Types';
} from '@/pages/collections/Types';

/**
* transform large capacity to capacity in b.
Expand Down
2 changes: 1 addition & 1 deletion client/src/utils/Metric.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MILVUS_NODE_TYPE } from '../consts/Milvus';
import { MILVUS_NODE_TYPE } from '@/consts';

export const parseJson = (jsonData: any) => {
const nodes: any[] = [];
Expand Down
4 changes: 2 additions & 2 deletions client/src/utils/Validation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChildrenStatusType } from '../components/status/Types';
import { MetricType, METRIC_TYPES_VALUES } from '../consts/Milvus';
import { ChildrenStatusType } from '@/components/status/Types';
import { MetricType, METRIC_TYPES_VALUES } from '@/consts';

export type ValidType =
| 'email'
Expand Down
2 changes: 1 addition & 1 deletion client/src/utils/__test__/Format.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseByte } from '../Format';
import { BYTE_UNITS } from '../../consts/Util';
import { BYTE_UNITS } from '@/consts';
describe('Test Fromat utils', () => {
it('Test parse byte', () => {
expect(parseByte('10m')).toEqual(10 * BYTE_UNITS.m);
Expand Down

0 comments on commit 8271ddc

Please sign in to comment.