Skip to content

Commit d6c18fb

Browse files
committed
frontend: fix bugs of icon
1 parent fac4682 commit d6c18fb

File tree

16 files changed

+73
-73
lines changed

16 files changed

+73
-73
lines changed

frontend/src/components/CardView.tsx

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect, useRef } from "react";
2-
import { Card, Tag, Pagination, Dropdown, Tooltip, Empty, Popover } from "antd";
2+
import { Tag, Pagination, Dropdown, Tooltip, Empty, Popover } from "antd";
33
import {
44
EllipsisOutlined,
55
ClockCircleOutlined,
@@ -22,7 +22,7 @@ interface BaseCardDataType {
2222
description: string;
2323
tags?: string[];
2424
statistics?: { label: string; value: string | number }[];
25-
lastModified: string;
25+
updatedAt?: string;
2626
}
2727

2828
interface CardViewProps<T> {
@@ -180,27 +180,29 @@ function CardView<T extends BaseCardDataType>(props: CardViewProps<T>) {
180180
{/* Header */}
181181
<div className="flex items-start justify-between">
182182
<div className="flex items-center gap-3 min-w-0">
183-
<div
184-
className={`flex-shrink-0 w-10 h-10 ${
185-
item.iconColor ||
186-
"bg-gradient-to-br from-blue-100 to-blue-200"
187-
} rounded-lg flex items-center justify-center`}
188-
>
189-
{item.icon}
190-
</div>
183+
{item?.icon && (
184+
<div
185+
className={`flex-shrink-0 w-12 h-12 ${
186+
item?.iconColor ||
187+
"bg-gradient-to-br from-blue-100 to-blue-200"
188+
} rounded-lg flex items-center justify-center`}
189+
>
190+
{item?.icon}
191+
</div>
192+
)}
191193
<div className="flex-1 min-w-0">
192194
<div className="flex items-center gap-2 mb-1">
193195
<h3
194196
className="text-base flex-1 text-ellipsis overflow-hidden whitespace-nowrap font-semibold text-gray-900 truncate cursor-pointer hover:text-blue-600"
195197
onClick={() => onView?.(item)}
196198
>
197-
{item.name}
199+
{item?.name}
198200
</h3>
199-
{item.status && (
200-
<Tag color={item.status.color}>
201+
{item?.status && (
202+
<Tag color={item?.status?.color}>
201203
<div className="flex items-center gap-2 text-xs py-0.5">
202-
<span>{item.status.icon}</span>
203-
<span>{item.status.label}</span>
204+
<span>{item?.status?.icon}</span>
205+
<span>{item?.status?.label}</span>
204206
</div>
205207
</Tag>
206208
)}
@@ -221,20 +223,24 @@ function CardView<T extends BaseCardDataType>(props: CardViewProps<T>) {
221223

222224
<div className="flex-1 flex flex-col justify-end">
223225
{/* Tags */}
224-
<TagsRenderer tags={item?.tags} />
226+
<TagsRenderer tags={item?.tags || []} />
225227

226228
{/* Description */}
227229
<p className="text-gray-600 text-xs text-ellipsis overflow-hidden whitespace-nowrap text-xs line-clamp-2 mt-2">
228-
<Tooltip title={item.description}>{item.description}</Tooltip>
230+
<Tooltip title={item?.description}>
231+
{item?.description}
232+
</Tooltip>
229233
</p>
230234

231235
{/* Statistics */}
232236
<div className="grid grid-cols-2 gap-4 py-3">
233-
{item.statistics?.map((stat, idx) => (
237+
{item?.statistics?.map((stat, idx) => (
234238
<div key={idx}>
235-
<div className="text-sm text-gray-500">{stat.label}:</div>
239+
<div className="text-sm text-gray-500">
240+
{stat?.label}:
241+
</div>
236242
<div className="text-base font-semibold text-gray-900">
237-
{stat.value}
243+
{stat?.value}
238244
</div>
239245
</div>
240246
))}
@@ -246,7 +252,7 @@ function CardView<T extends BaseCardDataType>(props: CardViewProps<T>) {
246252
<div className=" text-gray-500 text-right">
247253
<div className="flex items-center gap-1">
248254
<ClockCircleOutlined className="w-4 h-4" />{" "}
249-
{formatDateTime(item.updatedAt)}
255+
{formatDateTime(item?.updatedAt)}
250256
</div>
251257
</div>
252258
<Dropdown

frontend/src/components/DetailHeader.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ interface OperationItem {
2020
danger?: boolean;
2121
}
2222

23-
interface BaseDataItem {
24-
id: number;
25-
icon?: React.ReactNode;
26-
status?: {
27-
label: string;
28-
icon?: React.ReactNode;
29-
color?: string;
30-
};
31-
name: string;
32-
description: string;
33-
createdAt: string;
34-
lastUpdated: string;
35-
}
36-
3723
interface DetailHeaderProps<T> {
3824
data: T;
3925
statistics: StatisticItem[];
@@ -71,6 +57,15 @@ const DetailHeader: React.FC<DetailHeaderProps<any>> = <T,>({
7157
)}
7258
</div>
7359
<p className="text-gray-700 mb-4">{data.description}</p>
60+
{data?.tags?.map((tag) => (
61+
<Tag
62+
key={tag.id}
63+
className="mr-1"
64+
style={{ background: tag.color }}
65+
>
66+
{tag.name}
67+
</Tag>
68+
))}
7469
<div className="flex items-center gap-6 text-sm">
7570
{statistics.map((stat, idx) => (
7671
<div key={idx} className="flex items-center gap-1">

frontend/src/pages/DataCollection/Create/CreateTask.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "antd";
1414
import { Link, useNavigate } from "react-router";
1515
import { ArrowLeft } from "lucide-react";
16-
import { createTaskUsingPost } from "../collection-apis";
16+
import { createTaskUsingPost } from "../collection.apis";
1717

1818
const { TextArea } = Input;
1919

frontend/src/pages/DataCollection/Home/DataCollection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
2-
import { Button, Card, Tabs } from "antd";
2+
import { Button, Tabs } from "antd";
33
import { PlusOutlined } from "@ant-design/icons";
44
import TaskManagement from "./components/TaskManagement";
55
import ExecutionLog from "./components/ExecutionLog";

frontend/src/pages/DataCollection/Home/components/ExecutionLog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Card, Badge, Table } from "antd";
22
import type { ColumnsType } from "antd/es/table";
33
import { SearchControls } from "@/components/SearchControls";
4-
import type { CollectionLog } from "@/pages/DataCollection/collection-model";
5-
import { queryExecutionLogUsingPost } from "../../collection-apis";
6-
import { LogStatusMap, LogTriggerTypeMap } from "../../collection-const";
4+
import type { CollectionLog } from "@/pages/DataCollection/collection.model";
5+
import { queryExecutionLogUsingPost } from "../../collection.apis";
6+
import { LogStatusMap, LogTriggerTypeMap } from "../../collection.const";
77
import useFetchData from "@/hooks/useFetchData";
88

99
const filterOptions = [

frontend/src/pages/DataCollection/Home/components/TaskManagement.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {
66
executeTaskByIdUsingPost,
77
queryTasksUsingPost,
88
stopTaskByIdUsingPost,
9-
} from "../../collection-apis";
10-
import { TaskStatus, type CollectionTask } from "../../collection-model";
11-
import { StatusMap, SyncModeMap } from "../../collection-const";
9+
} from "../../collection.apis";
10+
import { TaskStatus, type CollectionTask } from "../../collection.model";
11+
import { StatusMap, SyncModeMap } from "../../collection.const";
1212
import useFetchData from "@/hooks/useFetchData";
1313

1414
export default function TaskManagement() {
File renamed without changes.

frontend/src/pages/DataCollection/collection-const.ts renamed to frontend/src/pages/DataCollection/collection.const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LogStatus, SyncMode, TaskStatus, TriggerType } from "./collection-model";
1+
import { LogStatus, SyncMode, TaskStatus, TriggerType } from "./collection.model";
22

33
export const StatusMap: Record<
44
TaskStatus,
File renamed without changes.

frontend/src/pages/DataEvaluation/Home/DataEvaluation.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
import { useState, useEffect } from "react";
42
import { Button, Card, Badge, Progress, Table } from "antd";
53
import {

0 commit comments

Comments
 (0)