2424 * IN THE SOFTWARE.
2525 */
2626import Select from 'antd/es/select' ;
27+ import Switch from 'antd/es/switch' ;
2728import React from 'react' ;
2829import { EditMode } from 'typings/metric' ;
2930
3031import { getEnByName } from '../utils/utils' ;
3132import AliasInput from './alias-input' ;
3233import EditorForm from './editor-form' ;
33- export type AddvanceSettingKey = 'format' | 'promqlAlias' | 'step' | 'type' ;
34+ export type AddvanceSettingKey = 'enableDownSampling' | ' format' | 'promqlAlias' | 'step' | 'type' ;
3435export interface IAddvanceSettingProps {
3536 format : string ;
3637 mode : EditMode ;
@@ -42,6 +43,7 @@ export interface IAddvanceSettingProps {
4243 promqlAlias : string ;
4344 step : string ;
4445 type : string ;
46+ enableDownSampling : boolean ;
4547}
4648
4749interface IAddvanceState {
@@ -87,7 +89,7 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
8789
8890 render ( ) : JSX . Element {
8991 const { showContent } = this . state ;
90- const { format, mode, onChange, promqlAlias, step, type } = this . props ;
92+ const { format, mode, onChange, promqlAlias, step, type, enableDownSampling } = this . props ;
9193 const getHeaderContent = ( ) => (
9294 < div className = 'header-content' >
9395 { mode === 'code' && < span className = 'header-content-item' > Min Step: { step || 'auto' } </ span > }
@@ -102,6 +104,9 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
102104 < span className = 'header-content-item' >
103105 { getEnByName ( '类型' ) } : { typeList . find ( item => item . id === type ) ?. name || 'Range' }
104106 </ span >
107+ < span className = 'header-content-item' >
108+ { getEnByName ( '降采样' ) } : { enableDownSampling ? getEnByName ( '开启' ) : getEnByName ( '关闭' ) }
109+ </ span >
105110 </ div >
106111 ) ;
107112 const uiForm = ( ) => (
@@ -136,6 +141,17 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
136141 ) ) }
137142 </ Select >
138143 </ EditorForm >
144+ < EditorForm title = { getEnByName ( '降采样' ) } >
145+ < div className = 'down-sample-wrapper' >
146+ < Switch
147+ checked = { enableDownSampling }
148+ checkedChildren = { getEnByName ( '开启' ) }
149+ size = 'small'
150+ unCheckedChildren = { getEnByName ( '关闭' ) }
151+ onChange = { v => onChange ( 'enableDownSampling' , v ) }
152+ />
153+ </ div >
154+ </ EditorForm >
139155 </ EditorForm >
140156 </ >
141157 ) ;
@@ -202,6 +218,17 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
202218 ) ) }
203219 </ Select >
204220 </ EditorForm >
221+ < EditorForm title = { getEnByName ( '降采样' ) } >
222+ < div className = 'down-sample-wrapper' >
223+ < Switch
224+ checked = { enableDownSampling }
225+ checkedChildren = { getEnByName ( '开启' ) }
226+ size = 'small'
227+ unCheckedChildren = { getEnByName ( '关闭' ) }
228+ onChange = { v => onChange ( 'enableDownSampling' , v ) }
229+ />
230+ </ div >
231+ </ EditorForm >
205232 </ EditorForm >
206233 ) : (
207234 uiForm ( )
0 commit comments