-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1599 from merico-dev/1596-force-enable-timequery-…
…mmq-for-some-metric-or-dimension 1596 force enable timequery mmq for some metric or dimension
- Loading branch information
Showing
11 changed files
with
109 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/time-query-switch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Box, Switch, Tooltip } from '@mantine/core'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { useEffect } from 'react'; | ||
import { QueryModelInstance } from '~/dashboard-editor/model'; | ||
import { DataSourceModelInstance } from '~/dashboard-editor/model/datasources/datasource'; | ||
import { MericoMetricQueryMetaInstance } from '~/model'; | ||
|
||
type Props = { | ||
queryModel: QueryModelInstance; | ||
}; | ||
|
||
export const TimeQuerySwitch = observer(({ queryModel }: Props) => { | ||
const config = queryModel.config as MericoMetricQueryMetaInstance; | ||
const ds = queryModel.datasource as DataSourceModelInstance; | ||
const mmInfo = ds.mericoMetricInfo; | ||
const metric = mmInfo.metricDetail; | ||
const trendingDateCol = metric.trendingDateCol; | ||
|
||
const enabled = config.timeQuery.enabled; | ||
useEffect(() => { | ||
if (!enabled && metric.requireTrendingReason) { | ||
config.setTimeQueryEnabled(true); | ||
return; | ||
} | ||
}, [metric.requireTrendingReason, enabled]); | ||
|
||
if (!metric.supportTrending) { | ||
return ( | ||
<Tooltip label="由于指标未设定时序维度,所以不具备时间序列展示功能。"> | ||
<Box> | ||
<Switch size="xs" color="red" disabled={!trendingDateCol} /> | ||
</Box> | ||
</Tooltip> | ||
); | ||
} | ||
if (metric.requireTrendingReason) { | ||
return ( | ||
<Tooltip label={metric.requireTrendingReason}> | ||
<Box> | ||
<Switch size="xs" color="red" checked readOnly styles={{ track: { cursor: 'not-allowed' } }} /> | ||
</Box> | ||
</Tooltip> | ||
); | ||
} | ||
return ( | ||
<Switch | ||
size="xs" | ||
color="red" | ||
checked={enabled} | ||
onChange={(e) => config.setTimeQueryEnabled(e.currentTarget.checked)} | ||
styles={{ track: { cursor: 'pointer' } }} | ||
/> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@devtable/root", | ||
"version": "14.3.6", | ||
"version": "14.4.1", | ||
"private": true, | ||
"workspaces": [ | ||
"api", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters