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: update frequency select #221

Merged
merged 1 commit into from
Mar 17, 2023
Merged
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
36 changes: 36 additions & 0 deletions src/components/MetricsFilterPanel/FrequencySelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { Select } from 'antd';

import { IntervalFrequencyItem, INTERVAL_FREQUENCY_LIST } from '@/utils/service';
import Icon from '@/components/Icon';

import styles from './index.module.less';

interface Props {
value?: number;
onChange?: (value: number) => void;
handleRefresh?: () => void;
timeOptions?: IntervalFrequencyItem[];
}

function FrequencySelect(props: Props) {
const { value, onChange, handleRefresh, timeOptions } = props;
return (
<div className={styles.frequency}>
<div onClick={handleRefresh} className={styles.freshIcon}><Icon className={styles.freshIconItem} icon="#iconrefresh" /></div>
<Select
className={styles.frequencySelect}
onChange={onChange}
value={value}
>
{
(timeOptions || INTERVAL_FREQUENCY_LIST).map(item => (
<Select.Option key={item.value} value={item.value}>{item.type}</Select.Option>
))
}
</Select>
</div>
)
}

export default FrequencySelect;
28 changes: 3 additions & 25 deletions src/components/MetricsFilterPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,12 @@ import React, { forwardRef, useEffect, useImperativeHandle, useMemo } from 'reac
import { Form, FormInstance, Select, TreeSelect } from 'antd';
import intl from 'react-intl-universal';

import { INTERVAL_FREQUENCY_LIST } from '@/utils/service';
import TimeSelect from '../TimeSelect';

import styles from './index.module.less';
import TimeSelect from '@/components/TimeSelect';
import { TIME_OPTION_TYPE } from '@/utils/dashboard';
import Icon from '../Icon';
import { isCloudVersion } from '@/utils';
import FrequencySelect from './FrequencySelect';


export function FrequencySelect(props: { value?, onChange?, handleRefresh?}) {
const { value, onChange, handleRefresh } = props;
return (
<div className={styles.frequency}>
<div onClick={handleRefresh} className={styles.freshIcon}><Icon className={styles.freshIconItem} icon="#iconrefresh" /></div>
<Select
className={styles.frequencySelect}
onChange={onChange}
value={value}
>
{
INTERVAL_FREQUENCY_LIST.map(item => (
<Select.Option key={item.value} value={item.value}>{item.type}</Select.Option>
))
}
</Select>
</div>
)
}
import styles from './index.module.less';

interface IProps {
instanceList: string[];
Expand Down
2 changes: 1 addition & 1 deletion src/utils/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ export interface IPanelConfig {
[ServiceName.MetadListener]: IServicePanelConfig[];
[ServiceName.StoragedListener]: IServicePanelConfig[];
[ServiceName.Drainer]: IServicePanelConfig[];
}
}
8 changes: 7 additions & 1 deletion src/utils/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const SERVICE_DEFAULT_RANGE = 6 * 60 * 60 * 1000;

export enum INTERVAL_FREQUENCY_TYPE {
OFF = 'Off',
S2 = '2s',
S5 = '5s',
S10 = '10s',
S15 = '15s',
Expand All @@ -17,7 +18,12 @@ export enum INTERVAL_FREQUENCY_TYPE {
M30 = '30m',
}

export const INTERVAL_FREQUENCY_LIST = [
export interface IntervalFrequencyItem {
type: INTERVAL_FREQUENCY_TYPE;
value: number;
}

export const INTERVAL_FREQUENCY_LIST: IntervalFrequencyItem[] = [
{
type: INTERVAL_FREQUENCY_TYPE.OFF,
value: 0,
Expand Down