Skip to content

Commit 1daf629

Browse files
committed
fix: fix bug
1 parent 63bd4a0 commit 1daf629

8 files changed

Lines changed: 244 additions & 147 deletions

File tree

src/frontend/platform/public/locales/en-US/dashboard.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
"selectCharts": "Select Linked Charts",
77
"selectAll": "Select All",
8+
"unSelectAll":"Deselect All",
89
"unnamedChart": "Unnamed Chart",
910
"noDataset": "No dataset",
1011

src/frontend/platform/public/locales/ja/dashboard.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
"selectCharts": "関連グラフを選択",
77
"selectAll": "すべて選択",
8+
"unSelectAll":"すべて選択解除",
89
"unnamedChart": "無名グラフ",
910
"noDataset": "データセット未設定",
1011

src/frontend/platform/public/locales/zh-Hans/dashboard.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"componentName": "组件:{{componentName}}",
55
"selectCharts": "选择关联图表",
66
"selectAll": "全选",
7+
"unSelectAll":"取消全选",
78
"unnamedChart": "未命名图表",
89
"noDataset": "未设置数据集",
910
"config": "查询条件配置",

src/frontend/platform/src/controllers/API/dashboard.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,20 @@ export async function queryChartData(params: {
263263
}
264264

265265
// 获取字段枚举列表
266-
export async function getFieldEnums({ dataset_code, field, page, pageSize = 20 }: {
266+
export async function getFieldEnums({ dataset_code, field, page, pageSize = 20, keywords = "" }: {
267267
dataset_code: string
268268
field: string
269269
page: number
270270
pageSize?: number
271+
keywords?: string
271272
}): Promise<any> {
272273
return await axios.get(`/api/v1/telemetry/dashboard/dataset/field/enums`, {
273274
params: {
274275
index_name: dataset_code,
275276
field,
276277
page,
277-
size: pageSize
278+
size: pageSize,
279+
keywords
278280
}
279281
});
280282
}

src/frontend/platform/src/pages/Dashboard/components/config/ChartSelector.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export interface ChartLinkConfig {
2727
dateRange: {
2828
start: string
2929
end: string
30+
shortcutKey?: string
31+
isDynamic?: boolean
3032
}
3133
}
3234

@@ -38,7 +40,6 @@ interface ChartSelectorProps {
3840
/* ================== 组件 ================== */
3941
export default function ChartSelector({
4042
onSave,
41-
// onCancel
4243
}: ChartSelectorProps) {
4344
const { t } = useTranslation("dashboard")
4445
const [selectedCharts, setSelectedCharts] = useState<string[]>([])
@@ -87,16 +88,25 @@ export default function ChartSelector({
8788
setIsDefault(queryCond.hasDefaultValue)
8889
}
8990

90-
// 处理时间范围
91-
if (queryCond.hasDefaultValue && queryCond.defaultValue?.type === 'custom') {
91+
// 处理时间范围 - 修改这里
92+
if (queryCond.hasDefaultValue) {
9293
try {
9394
const startTime = queryCond.defaultValue.startDate
9495
const endTime = queryCond.defaultValue.endDate
96+
const mode = queryCond.defaultValue.mode || "fixed"
97+
98+
// 处理shortcutKey
99+
let shortcutKey = ''
100+
if (queryCond.defaultValue.type === 'recent_days') {
101+
shortcutKey = `last_${queryCond.defaultValue.shortcutKey}`
102+
}
95103

96104
if (startTime && endTime) {
97105
setTimeFilter({
98106
startTime: startTime,
99-
endTime: endTime
107+
endTime: endTime,
108+
shortcutKey: shortcutKey,
109+
isDynamic: mode === "dynamic"
100110
})
101111
} else {
102112
setTimeFilter(null)
@@ -155,11 +165,20 @@ export default function ChartSelector({
155165
try {
156166
const startTime = queryCond.defaultValue.startDate
157167
const endTime = queryCond.defaultValue.endDate
168+
const mode = queryCond.defaultValue.mode || "fixed"
169+
170+
// 处理shortcutKey
171+
let shortcutKey = ''
172+
if (queryCond.defaultValue.type === 'recent_days' && queryCond.defaultValue.recentDays) {
173+
shortcutKey = `last_${queryCond.defaultValue.recentDays}`
174+
}
158175

159176
if (startTime && endTime) {
160177
setTimeFilter({
161178
startTime: startTime,
162-
endTime: endTime
179+
endTime: endTime,
180+
shortcutKey: shortcutKey,
181+
isDynamic: mode === "dynamic"
163182
})
164183
} else {
165184
setTimeFilter(null)
@@ -234,7 +253,9 @@ export default function ChartSelector({
234253
isDefault,
235254
dateRange: {
236255
start: timeFilter?.startTime ?? "",
237-
end: timeFilter?.endTime ?? ""
256+
end: timeFilter?.endTime ?? "",
257+
shortcutKey: timeFilter?.shortcutKey,
258+
isDynamic: timeFilter?.isDynamic
238259
}
239260
}
240261

@@ -290,7 +311,6 @@ export default function ChartSelector({
290311
</div>
291312
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={() => setCollapsed(true)}>
292313
<ListIndentIncrease className="h-4 w-4" />
293-
294314
</Button>
295315
</div>
296316

src/frontend/platform/src/pages/Dashboard/components/config/ComponentConfigDrawer.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,18 @@ export function ComponentConfigDrawer() {
463463
}, [filterGroup, handleAddFilter])
464464

465465
const handleSaveFilter = useCallback((newFilterGroup: any) => {
466+
if (editingComponent) {
467+
// 获取当前的数据配置
468+
const currentDataConfig = editingComponent.data_config || {}
469+
470+
updateEditingComponent({
471+
data_config: {
472+
...currentDataConfig,
473+
filters: newFilterGroup.conditions,
474+
filtersLogic: newFilterGroup.logic
475+
}
476+
})
477+
}
466478
setFilterGroup(newFilterGroup)
467479
setFilterDialogOpen(false)
468480
}, [])
@@ -698,7 +710,8 @@ export function ComponentConfigDrawer() {
698710
chartLinkConfig.timeGranularity === "年月日时" ? "year_month_day_hour" : "year_month_day",
699711
hasDefaultValue: chartLinkConfig.isDefault,
700712
defaultValue: chartLinkConfig.isDefault ? {
701-
type: 'custom' as const,
713+
type: chartLinkConfig.dateRange.shortcutKey ? "recent_days" : "custom",
714+
shortcutKey: chartLinkConfig.dateRange.shortcutKey ? parseInt(chartLinkConfig.dateRange.shortcutKey.replace('last_', '')) : undefined,
702715
startDate: new Date(chartLinkConfig.dateRange.start).getTime(),
703716
endDate: new Date(chartLinkConfig.dateRange.end).getTime()
704717
} : {

0 commit comments

Comments
 (0)