Skip to content

Commit 1756389

Browse files
committed
fix:fix bug
1 parent 0057be5 commit 1756389

10 files changed

Lines changed: 103 additions & 70 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@
11291129
"actionBehavior": "Action Behavior",
11301130
"createChat": "Create chat",
11311131
"deleteChat": "Delete chat",
1132-
"createBuild": "Create build",
1132+
"createBuild": "Create Agent",
11331133
"updateBuild": "Update build",
11341134
"deleteBuild": "Delete build",
11351135
"createKnowledge": "Create knowledge base",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@
303303
"warn": {
304304
"invalidFieldType": "Field type {{fieldType}} cannot be dragged to {{section}} area",
305305
"maxStackDimension": "Only one stack dimension is allowed, please delete the existing stack dimension first",
306-
"maxCategoryDimensions": "Maximum 2 category dimensions are allowed"
306+
"maxCategoryDimensions": "Maximum 2 category dimensions are allowed",
307+
"fieldExists": "This field has already been added"
307308
}
308309
},
309310
"renameSuccess": "Renamed successfully",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@
304304
"warn": {
305305
"invalidFieldType": "フィールドタイプ {{fieldType}} を {{section}} エリアにドラッグすることはできません",
306306
"maxStackDimension": "スタックディメンションは1つだけ許可されます。既存のスタックディメンションを先に削除してください",
307-
"maxCategoryDimensions": "カテゴリーディメンションは最大2つまで許可されます"
307+
"maxCategoryDimensions": "カテゴリーディメンションは最大2つまで許可されます",
308+
"fieldExists": "このフィールドは既に追加されています"
308309
}
309310
},
310311
"renameSuccess": "名前を変更しました",

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,7 @@
11201120
"createDashboard":"新建看板",
11211121
"deleteDashboard":"删除看板",
11221122
"updateDashboard":"修改看板",
1123-
1124-
1125-
1123+
"createBuild": "新建应用",
11261124
"create_chat": "新建会话",
11271125
"delete_chat": "删除会话",
11281126
"create_build": "新建应用",

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"confirm": "确认"
7979
},
8080
"toast": {
81-
"fieldAlreadyExists": "字段已存在于{{section}}中",
81+
"fieldAlreadyExists": "该字段已存在",
8282
"dimensionLimitReached": "当前维度数量已达到上限",
8383
"metricReached": "不支持拖拽维度至指标",
8484
"metricLimitReached": "当前指标数量已达到上限",
@@ -279,10 +279,11 @@
279279
"metric": "指标"
280280
},
281281
"warn": {
282-
"invalidFieldType": "字段类型 {{fieldType}} 不能拖拽到 {{section}} 区域",
283-
"maxStackDimension": "堆叠维度只能有一个,请先删除现有的堆叠维度",
282+
"invalidFieldType": "不支持拖拽{{fieldType}}{{section}}",
283+
"maxStackDimension": "当前维度数量已达到上限",
284284
"metricLimitReached": "当前指标数量已达到上限",
285-
"maxCategoryDimensions": "类别维度最多只能有 2 个"
285+
"maxCategoryDimensions": "类别维度最多只能有 2 个",
286+
"fieldExists":"该字段已添加"
286287
}
287288
},
288289
"renameSuccess": "已重命名",

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,15 @@ export default function ChartSelector({
161161
/* 保存 */
162162
const handleSave = (e) => {
163163

164-
// const startDateObj = new Date(timeFilter.startTime * 1000)
165-
// const endDateObj = new Date(timeFilter.endTime * 1000)
166164

167165
const config: ChartLinkConfig = {
168166
chartIds: selectedCharts,
169167
displayType,
170168
timeGranularity,
171169
isDefault,
172170
dateRange: {
173-
start: timeFilter.startTime, // 直接传秒级时间戳
174-
end: timeFilter.endTime // 直接传秒级时间戳
171+
start: timeFilter?.startTime ?? "",
172+
end: timeFilter?.endTime ?? ""
175173
}
176174
}
177175

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function ComponentConfigDrawer() {
6060
// 使用自定义Hook管理所有图表状态
6161
const chartState = useChartState(editingComponent)
6262
const [isMetricCard, setIsMetricCard] = useState(true)
63+
console.log(editingComponent, 3434343434);
6364

6465
// 从Hook中解构状态和方法
6566
const {
@@ -206,13 +207,13 @@ export function ComponentConfigDrawer() {
206207
}
207208

208209
// 多个虚拟指标
209-
if (currentIsVirtual && hasVirtualMetric) {
210-
toast({
211-
description: t("componentConfigDrawer.toast.multipleVirtualMetric"),
212-
variant: "warning"
213-
})
214-
return
215-
}
210+
// if (currentIsVirtual && hasVirtualMetric) {
211+
// toast({
212+
// description: t("componentConfigDrawer.toast.multipleVirtualMetric"),
213+
// variant: "warning"
214+
// })
215+
// return
216+
// }
216217
}
217218

218219
if (isFieldAlreadyAdded(safeFieldId, 'value')) {
@@ -363,9 +364,9 @@ export function ComponentConfigDrawer() {
363364
return { isValid: false, errorKey: 'datasetRequired' };
364365
}
365366

366-
if (currentChartHasStack && stackDimensions.length === 0) {
367-
return { isValid: false, errorKey: 'stackRequired' };
368-
}
367+
// if (currentChartHasStack && stackDimensions.length === 0) {
368+
// return { isValid: false, errorKey: 'stackRequired' };
369+
// }
369370

370371
return { isValid: true };
371372
};
@@ -398,7 +399,9 @@ export function ComponentConfigDrawer() {
398399

399400
const dataConfig = getDataConfig(limitType, limitValue, editingComponent.data_config?.timeFilter)
400401
dataConfig.isConfigured = e.isTrusted
401-
402+
if (styleConfig.title === '' && editingComponent?.data_config?.metrics?.[0]?.fieldName) {
403+
styleConfig.title = editingComponent?.data_config?.metrics?.[0]?.fieldName
404+
}
402405
updateEditingComponent({
403406
data_config: dataConfig,
404407
type: chartType,
@@ -668,6 +671,7 @@ export function ComponentConfigDrawer() {
668671
<DimensionBlock
669672
invalidIds={invalidFieldIds}
670673
isDimension={true}
674+
isStack={'stack'}
671675
dimensions={stackDimensions}
672676
isDragOver={dragOverSection === 'stack'}
673677
onDragOver={(e) => handleDragOver(e, 'stack')}

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

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type MetricFormat = {
4949
export function DimensionBlock({
5050
isDimension,
5151
dimensions = [],
52+
isStack,
5253
maxDimensions,
5354
isDragOver = false,
5455
onDragOver,
@@ -97,6 +98,8 @@ export function DimensionBlock({
9798

9899
// 选项配置
99100
const isVirtualMetric = (dimension: DimensionItem) => {
101+
console.log(12312312312312312, dimension);
102+
100103
return dimension.fieldType === 'metric' && dimension.isVirtual === true;
101104
};
102105
const aggregationOptions = [
@@ -127,7 +130,6 @@ export function DimensionBlock({
127130
setHoveredMenuItem({ dimensionId, menuType })
128131
}
129132
}
130-
131133
return (
132134
<div className="space-y-3"
133135
onDragOver={(e) => {
@@ -196,51 +198,58 @@ export function DimensionBlock({
196198
<div
197199
className="absolute right-full top-0 mr-1 bg-white border rounded-md shadow-lg z-20 p-2 min-w-[120px]"
198200
onClick={(e) => e.stopPropagation()}
199-
onMouseLeave={() => setHoveredMenuItem(null)}
201+
200202
>
201203
{/* 维度菜单 */}
202204
{dimension.fieldType === 'dimension' ? (
203205
<>
204206
{/* 排序 */}
205-
<div className="relative">
206-
<div
207-
className={`flex items-center justify-between px-2 py-1 text-xs rounded cursor-pointer ${hoveredMenuItem?.dimensionId === dimension.id && hoveredMenuItem?.menuType === 'sort' ? 'bg-gray-100' : 'hover:bg-gray-100'}`}
208-
onMouseEnter={() => handleMenuItemHover(dimension.id, 'sort')}
209-
>
210-
<span>{t('dimensionBlock.menu.sort')}</span>
211-
<ChevronRight className="h-3 w-3" />
212-
</div>
213-
214-
{/* 排序子菜单 */}
215-
{hoveredMenuItem?.dimensionId === dimension.id && hoveredMenuItem?.menuType === 'sort' && (
216-
<div
217-
className="absolute left-full top-0 ml-1 bg-white border rounded-md shadow-lg z-30 p-2 min-w-[90px]"
218-
onMouseEnter={() => handleMenuItemHover(dimension.id, 'sort')}
219-
onMouseLeave={() => setHoveredMenuItem(null)}
220-
>
221-
{sortOptions.map((option) => (
222-
<button
223-
key={option.value}
224-
className={`flex items-center justify-between w-full px-2 py-1 text-xs rounded ${dimension.sort === option.value ? 'bg-blue-100 text-blue-700' : 'hover:bg-gray-100'}`}
225-
onClick={() => {
226-
onSortChange?.(dimension.id, option.value as null | 'asc' | 'desc')
227-
setOpenMenuId(null)
228-
setHoveredMenuItem(null)
229-
}}
207+
{isStack !== "stack" &&
208+
<>
209+
<div className="relative">
210+
<div
211+
className={`flex items-center justify-between px-2 py-1 text-xs rounded cursor-pointer ${hoveredMenuItem?.dimensionId === dimension.id && hoveredMenuItem?.menuType === 'sort' ? 'bg-gray-100' : 'hover:bg-gray-100'}`}
212+
onMouseEnter={() => handleMenuItemHover(dimension.id, 'sort')}
213+
>
214+
<span>{t('dimensionBlock.menu.sort')}</span>
215+
<ChevronRight className="h-3 w-3" />
216+
</div>
217+
218+
{/* 排序子菜单 */}
219+
{hoveredMenuItem?.dimensionId === dimension.id && hoveredMenuItem?.menuType === 'sort' && (
220+
<div
221+
className="absolute left-full top-0 ml-1 bg-white border rounded-md shadow-lg z-30 p-2 min-w-[90px]"
222+
onMouseEnter={() => handleMenuItemHover(dimension.id, 'sort')}
223+
onMouseLeave={() => setHoveredMenuItem(null)}
230224
>
231-
<span>{option.label}</span>
232-
{dimension.sort === option.value && <Check className="h-3 w-3" />}
233-
</button>
234-
))}
225+
{sortOptions.map((option) => (
226+
<button
227+
key={option.value}
228+
className={`flex items-center justify-between w-full px-2 py-1 text-xs rounded ${dimension.sort === option.value ? 'bg-blue-100 text-blue-700' : 'hover:bg-gray-100'}`}
229+
onClick={() => {
230+
onSortChange?.(dimension.id, option.value as null | 'asc' | 'desc')
231+
setOpenMenuId(null)
232+
setHoveredMenuItem(null)
233+
}}
234+
>
235+
<span>{option.label}</span>
236+
{dimension.sort === option.value && <Check className="h-3 w-3" />}
237+
</button>
238+
))}
239+
</div>
240+
)}
235241
</div>
236-
)}
237-
</div>
238242

239-
<div className="h-px bg-gray-200 my-1"></div>
243+
<div className="h-px bg-gray-200 my-1"></div>
244+
</>
245+
}
240246

241247
{/* 编辑显示名称 */}
242248
<button
243249
className="block w-full text-left px-2 py-1 text-xs hover:bg-gray-100 rounded"
250+
onMouseEnter={() => {
251+
setHoveredMenuItem(null);
252+
}}
244253
onClick={() => {
245254
onEditDisplayName(dimension.id, dimension.originalName, dimension.displayName)
246255
setOpenMenuId(null)
@@ -334,6 +343,9 @@ export function DimensionBlock({
334343
{/* 数值格式 */}
335344
<button
336345
className="flex items-center justify-between w-full px-2 py-1 text-xs rounded hover:bg-gray-100"
346+
onMouseEnter={() => {
347+
setHoveredMenuItem(null);
348+
}}
337349
onClick={() => {
338350
setEditingMetric(dimension)
339351
setLocalFormat(
@@ -358,6 +370,9 @@ export function DimensionBlock({
358370
{/* 编辑显示名称 */}
359371
<button
360372
className="block w-full text-left px-2 py-1 text-xs hover:bg-gray-100 rounded"
373+
onMouseEnter={() => {
374+
setHoveredMenuItem(null);
375+
}}
361376
onClick={() => {
362377
onEditDisplayName(dimension.id, dimension.originalName, dimension.displayName)
363378
setOpenMenuId(null)
@@ -487,7 +502,10 @@ export function DimensionBlock({
487502
<div>
488503
<div className="text-sm font-medium mb-2">{t('dimensionBlock.dialog.unit')}</div>
489504
<Select
490-
value={localFormat.unit || "none"}
505+
value={localFormat.unit ||
506+
(localFormat.type === 'storage' ? 'B' :
507+
localFormat.type === 'duration' ? 'ms' :
508+
'none')}
491509
onValueChange={(value) => {
492510
let unitVal = value === "none" ? "" : value;
493511
setLocalFormat({ ...localFormat, unit: unitVal })

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ export function StyleConfigPanel({ config, onChange, type }: StyleConfigPanelPro
722722
/>
723723
</FormBlock>
724724
</CollapsibleBlock>
725-
725+
{console.log(editingComponent, editingComponent?.type, 454545454)}
726726
{/* 图表选项 */}
727727
<CollapsibleBlock
728728
title={t('styleConfigPanel.sections.chartOptions')}
@@ -738,27 +738,28 @@ export function StyleConfigPanel({ config, onChange, type }: StyleConfigPanelPro
738738
/>
739739
{t('styleConfigPanel.options.legend')}
740740
</label>
741-
<label className="flex items-center gap-2 text-sm">
741+
{editingComponent.type !== "donut" && editingComponent.type !== "pie" && <label className="flex items-center gap-2 text-sm">
742742
<Checkbox
743743
checked={localConfig.showAxis}
744744
onCheckedChange={(v) => handleChange("showAxis", v)}
745745
/>
746746
{t('styleConfigPanel.options.axis')}
747-
</label>
747+
</label>}
748748
<label className="flex items-center gap-2 text-sm">
749749
<Checkbox
750750
checked={localConfig.showDataLabel}
751751
onCheckedChange={(v) => handleChange("showDataLabel", v)}
752752
/>
753753
{t('styleConfigPanel.options.dataLabel')}
754754
</label>
755-
<label className="flex items-center gap-2 text-sm">
755+
756+
{editingComponent.type !== "donut" && editingComponent.type !== "pie" && <label className="flex items-center gap-2 text-sm">
756757
<Checkbox
757758
checked={localConfig.showGrid}
758759
onCheckedChange={(v) => handleChange("showGrid", v)}
759760
/>
760761
{t('styleConfigPanel.options.gridLine')}
761-
</label>
762+
</label>}
762763
</div>
763764
</CollapsibleBlock>
764765
</>

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export function useChartState(initialComponent: any) {
3535

3636
}, [initialComponent, updateEditingComponent, refreshChart]);
3737

38-
const isStackedChart = (type: ChartType) => type.startsWith('stacked-')
38+
const isStackedChart = (type: ChartType) =>
39+
type.startsWith('stacked-') || type.startsWith('grouped-');
3940
// 初始化逻辑
4041
useEffect(() => {
4142
const componentId = initialComponent?.id
@@ -98,7 +99,6 @@ export function useChartState(initialComponent: any) {
9899
setStackDimensions([formattedStackDim])
99100
console.log('设置堆叠维度:', formattedStackDim)
100101
}
101-
102102
// 3. 初始化指标(value)
103103
if (dc.metrics && dc.metrics.length > 0) {
104104
const valueDims = dc.metrics.map((metric, index) => ({
@@ -110,6 +110,7 @@ export function useChartState(initialComponent: any) {
110110
sort: metric.sort || null,
111111
sortPriority: 0,
112112
fieldType: 'metric',
113+
isVirtual: metric.isVirtual || false,
113114
aggregation: metric.aggregation || 'sum',
114115
numberFormat: metric.numberFormat || {
115116
type: 'number',
@@ -284,8 +285,10 @@ export function useChartState(initialComponent: any) {
284285
setDragOverSection(null)
285286
return
286287
}
288+
const STACKED_CHART_TYPES = new Set(['stacked-bar', 'stacked-horizontal-bar', 'stacked-line']);
289+
const maxMetricCount = STACKED_CHART_TYPES.has(chartType) ? 3 : 1;
287290
//指标维度只能有一个
288-
if (section === 'value' && valueDimensions.length >= 1) {
291+
if (section === 'value' && valueDimensions.length >= maxMetricCount) {
289292
console.warn('指标维度只能有一个,请先删除现有的指标维度')
290293
toast({
291294
description: t('useChartState.warn.metricLimitReached'),
@@ -303,7 +306,15 @@ export function useChartState(initialComponent: any) {
303306
if (section === 'value') currentDimensions = valueDimensions
304307

305308
const alreadyExists = currentDimensions.some(dim => dim.fieldId === fieldId)
306-
if (alreadyExists) return
309+
if (alreadyExists) {
310+
console.warn('该字段已存在')
311+
toast({
312+
description: t('useChartState.warn.fieldExists'),
313+
variant: "warning",
314+
})
315+
setDragOverSection(null)
316+
return
317+
}
307318

308319
const displayName = data.displayName || name
309320
const originalName = data.name || name
@@ -425,7 +436,7 @@ export function useChartState(initialComponent: any) {
425436
fieldCode: metric.name,
426437
displayName: metric.displayName,
427438
sort: metric.sort,
428-
isVirtual: false,
439+
isVirtual: metric.isVirtual,
429440
aggregation: metric.aggregation || 'sum',
430441
numberFormat: metric.numberFormat || {
431442
type: 'number' as const,

0 commit comments

Comments
 (0)