Skip to content

Commit 719fa5c

Browse files
minor: 解决冲突
2 parents 5da12e3 + aeb104a commit 719fa5c

File tree

5 files changed

+47
-4
lines changed

5 files changed

+47
-4
lines changed

src/common/lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"开启": "on",
7777
"关闭": "off",
7878
"降采样": "Down Sampling",
79+
"最新数据点": "Latest data points",
7980
"方法": "Formula",
8081
"数据名称": "Data name",
8182
"数据类型": "Data types",

src/timeseries/src/components/addvance-setting.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import type { EditMode } from '../typings/metric';
3131
import { t } from 'common/utils/utils';
3232
import AliasInput from './alias-input';
3333
import EditorForm from './editor-form';
34-
export type AddvanceSettingKey = 'enableDownSampling' | 'format' | 'promqlAlias' | 'step' | 'type';
34+
export type AddvanceSettingKey = 'enableDownSampling' | 'format' | 'promqlAlias' | 'step' | 'type' | 'showLastPoint';
3535
export interface IAddvanceSettingProps {
3636
format: string;
3737
mode: EditMode;
@@ -44,6 +44,7 @@ export interface IAddvanceSettingProps {
4444
step: string;
4545
type: string;
4646
enableDownSampling: boolean;
47+
showLastPoint: boolean;
4748
}
4849

4950
interface IAddvanceState {
@@ -89,7 +90,7 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
8990

9091
render(): JSX.Element {
9192
const { showContent } = this.state;
92-
const { format, mode, onChange, promqlAlias, step, type, enableDownSampling } = this.props;
93+
const { format, mode, onChange, promqlAlias, step, type, enableDownSampling, showLastPoint } = this.props;
9394
const getHeaderContent = () => (
9495
<div className='header-content'>
9596
{mode === 'code' && <span className='header-content-item'>Min Step: {step || 'auto'}</span>}
@@ -107,6 +108,9 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
107108
<span className='header-content-item'>
108109
{t('降采样')}: {enableDownSampling ? t('开启') : t('关闭')}
109110
</span>
111+
<span className='header-content-item'>
112+
{t('最新数据点')}: {showLastPoint ? t('开启') : t('关闭')}
113+
</span>
110114
</div>
111115
);
112116
const uiForm = () => (
@@ -152,6 +156,17 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
152156
/>
153157
</div>
154158
</EditorForm>
159+
<EditorForm title={t('最新数据点')}>
160+
<div className='down-sample-wrapper'>
161+
<Switch
162+
checked={showLastPoint}
163+
checkedChildren={t('开启')}
164+
size='small'
165+
unCheckedChildren={t('关闭')}
166+
onChange={v => onChange('showLastPoint', v)}
167+
/>
168+
</div>
169+
</EditorForm>
155170
</EditorForm>
156171
</>
157172
);
@@ -229,6 +244,17 @@ export default class AddvanceSetting extends React.PureComponent<IAddvanceSettin
229244
/>
230245
</div>
231246
</EditorForm>
247+
<EditorForm title={t('最新数据点')}>
248+
<div className='down-sample-wrapper'>
249+
<Switch
250+
checked={showLastPoint}
251+
checkedChildren={t('开启')}
252+
size='small'
253+
unCheckedChildren={t('关闭')}
254+
onChange={v => onChange('showLastPoint', v)}
255+
/>
256+
</div>
257+
</EditorForm>
232258
</EditorForm>
233259
) : (
234260
uiForm()

src/timeseries/src/components/query-editor.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ interface IQueryEditorState {
9999
enableDownSampling: boolean;
100100
showErrorAlert: boolean;
101101
errorAlertMessage: string;
102+
showLastPoint: boolean;
102103
}
103104
export default class MonitorQueryEditor extends React.PureComponent<IQueryEditorProps, IQueryEditorState> {
104105
constructor(props, context) {
@@ -140,6 +141,8 @@ export default class MonitorQueryEditor extends React.PureComponent<IQueryEditor
140141
if (enableDownSampling === undefined) {
141142
enableDownSampling = stateMode !== 'code';
142143
}
144+
let showLastPoint = ['true', true].includes(query?.showLastPoint);
145+
143146
this.state = {
144147
cluster,
145148
editorStatus: 'default',
@@ -159,6 +162,7 @@ export default class MonitorQueryEditor extends React.PureComponent<IQueryEditor
159162
source,
160163
step,
161164
enableDownSampling,
165+
showLastPoint,
162166
type: query.type ?? 'range',
163167
showErrorAlert: false,
164168
errorAlertMessage: '',
@@ -992,7 +996,7 @@ export default class MonitorQueryEditor extends React.PureComponent<IQueryEditor
992996
return letter;
993997
}
994998
handleGetQueryData(metricList: MetricDetail[]) {
995-
const { cluster, expressionList, host, module, promqlAlias, enableDownSampling } = this.state;
999+
const { cluster, expressionList, host, module, promqlAlias, enableDownSampling, showLastPoint } = this.state;
9961000
// const curExpression = typeof expression === 'undefined' ? this.state.expression : expression;
9971001
// const curDisplay = typeof display === 'undefined' ? this.state.display : display;
9981002
return {
@@ -1008,6 +1012,7 @@ export default class MonitorQueryEditor extends React.PureComponent<IQueryEditor
10081012
module,
10091013
promqlAlias,
10101014
enableDownSampling,
1015+
showLastPoint,
10111016
query_configs: metricList
10121017
.filter(item => item.metricMetaId)
10131018
.map(item => {
@@ -1479,6 +1484,7 @@ export default class MonitorQueryEditor extends React.PureComponent<IQueryEditor
14791484
{
14801485
<AddvanceSetting
14811486
enableDownSampling={this.state.enableDownSampling}
1487+
showLastPoint={this.state.showLastPoint}
14821488
format={this.state.format}
14831489
mode={mode}
14841490
promqlAlias={promqlAlias}

src/timeseries/src/datasource/datasource.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ export default class DashboardDatasource extends DataSourceApi<QueryData, QueryO
181181
text,
182182
value,
183183
};
184+
if (key?.includes?.('.')) {
185+
monitorScopedVars[`${keyPrefix}${key}`.replace(/\./g, '_')] = {
186+
text,
187+
value,
188+
};
189+
}
184190
}
185191
if (rawKey && !(rawKey in monitorScopedVars)) {
186192
monitorScopedVars[rawKey] = {
@@ -843,6 +849,7 @@ export default class DashboardDatasource extends DataSourceApi<QueryData, QueryO
843849
data: {
844850
display: config.display,
845851
down_sample_range: item.enableDownSampling !== false ? down_sample_range : undefined,
852+
time_alignment: item.showLastPoint === true ? false : undefined,
846853
end_time: options.range.to.unix(),
847854
expression: config.refId || '',
848855
format: item.format,
@@ -881,6 +888,7 @@ export default class DashboardDatasource extends DataSourceApi<QueryData, QueryO
881888
const params = {
882889
data: {
883890
down_sample_range: item.enableDownSampling === true ? down_sample_range : undefined, // promql 原来默认是不开启的
891+
time_alignment: item.showLastPoint === true ? false : undefined,
884892
end_time: options.range.to.unix(),
885893
format: item.format,
886894
promql: this.buildPromqlVariables(item.source!, replaceScopedVars),
@@ -909,14 +917,15 @@ export default class DashboardDatasource extends DataSourceApi<QueryData, QueryO
909917
}),
910918
);
911919
} else {
912-
const { cluster, expressionList, host, module, enableDownSampling } = item;
920+
const { cluster, expressionList, host, module, enableDownSampling, showLastPoint } = item;
913921
// biome-ignore lint/complexity/noForEach: <explanation>
914922
expressionList?.forEach(exp => {
915923
if (exp.expression && exp.active) {
916924
const p = {
917925
data: {
918926
display: exp.active,
919927
down_sample_range: enableDownSampling !== false ? down_sample_range : undefined,
928+
time_alignment: showLastPoint === true ? false : undefined,
920929
end_time: options.range.to.unix(),
921930
expression: exp.expression,
922931
format: item.format,

src/timeseries/src/typings/datasource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export interface QueryData extends DataQuery {
6969
step?: string;
7070
type?: string;
7171
enableDownSampling?: boolean;
72+
showLastPoint?: boolean;
7273
}
7374

7475
export const DIM_NULL_ID = '';

0 commit comments

Comments
 (0)