Skip to content

Commit

Permalink
🎸 Optimize all table page (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cairry authored Dec 29, 2024
1 parent 1d7f311 commit 080a58c
Show file tree
Hide file tree
Showing 21 changed files with 270 additions and 51 deletions.
53 changes: 53 additions & 0 deletions src/pages/alert/rule/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,56 @@
margin-left: auto;
padding-left: 20px; /* 增加间距以使内容更易读 */
}

/* 状态容器 */
.status-container {
display: flex;
align-items: center;
gap: 8px;
}

/* 小圆点 */
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
position: relative;
}

/* 启用状态的小圆点 */
.status-enabled {
background-color: #52c41a; /* 绿色 */
animation: pulse-enabled 1.5s infinite;
}

/* 禁用状态的小圆点 */
.status-disabled {
background-color: #ff4d4f; /* 红色 */
animation: pulse-disabled 1.5s infinite;
}

/* 启用状态动态效果 */
@keyframes pulse-enabled {
0% {
box-shadow: 0 0 0 0 rgba(82, 196, 26, 0.4);
}
70% {
box-shadow: 0 0 0 10px rgba(82, 196, 26, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(82, 196, 26, 0);
}
}

/* 禁用状态动态效果 */
@keyframes pulse-disabled {
0% {
box-shadow: 0 0 0 0 rgba(196, 26, 26, 0.4);
}
70% {
box-shadow: 0 0 0 10px rgba(82, 196, 26, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(82, 196, 26, 0);
}
}
16 changes: 12 additions & 4 deletions src/pages/alert/rule/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ export const AlertRuleList = () => {
key: 'enabled',
width: 'auto',
render: enabled => (
enabled ?
<Tag color="success">启用</Tag> :
<Tag color="error">禁用</Tag>
<div className="status-container">
<div
className={`status-dot ${enabled ? 'status-enabled' : 'status-disabled'}`}
/>
<span>{enabled ? '启用' : '禁用'}</span>
</div>
),
},
{
Expand Down Expand Up @@ -244,6 +247,7 @@ export const AlertRuleList = () => {
}

const changeStatus = async ({ target: { value } }) => {
setPagination({ ...pagination, index: 1, size: pagination.size });
setSelectRuleStatus(value)
}

Expand Down Expand Up @@ -340,8 +344,12 @@ export const AlertRuleList = () => {
}}
onChange={handlePageChange}
scroll={{
y: height-400
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>
</>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/alert/ruleGroup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@ export const AlertRuleGroup = ({ }) => {
}}
onChange={handlePageChange}
scroll={{
y: height-400
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>
</>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/alert/tmpl/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,13 @@ export const RuleTemplate = () => {
<Table
columns={columns}
dataSource={list}
scroll={{ x: 1000, y: height - 400 }}
scroll={{
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>
</>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/alert/tmplGroup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ export const RuleTemplateGroup = () => {
<Table
columns={columns}
dataSource={list}
scroll={{ y: height - 400 }}
scroll={{
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/audit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ export const AuditLog = () => {
}}
onChange={handlePageChange}
scroll={{
y: height-400
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/dashboards/folder/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,12 @@ export const DashboardFolder = () => {
columns={columns}
dataSource={list}
scroll={{
x: 1000,
y: height-400
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>
</>
Expand Down
53 changes: 53 additions & 0 deletions src/pages/datasources/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

/* 状态容器 */
.status-container {
display: flex;
align-items: center;
gap: 8px;
}

/* 小圆点 */
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
position: relative;
}

/* 启用状态的小圆点 */
.status-enabled {
background-color: #52c41a; /* 绿色 */
animation: pulse-enabled 1.5s infinite;
}

/* 禁用状态的小圆点 */
.status-disabled {
background-color: #ff4d4f; /* 红色 */
animation: pulse-disabled 1.5s infinite;
}

/* 启用状态动态效果 */
@keyframes pulse-enabled {
0% {
box-shadow: 0 0 0 0 rgba(82, 196, 26, 0.4);
}
70% {
box-shadow: 0 0 0 10px rgba(82, 196, 26, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(82, 196, 26, 0);
}
}

/* 禁用状态动态效果 */
@keyframes pulse-disabled {
0% {
box-shadow: 0 0 0 0 rgba(196, 26, 26, 0.4);
}
70% {
box-shadow: 0 0 0 10px rgba(82, 196, 26, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(82, 196, 26, 0);
}
}
17 changes: 12 additions & 5 deletions src/pages/datasources/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ReactComponent as LokiImg } from "../alert/rule/img/L.svg"
import { ReactComponent as VMImg } from "../alert/rule/img/victoriametrics.svg"
import { ReactComponent as K8sImg } from "../alert/rule/img/Kubernetes.svg"
import { ReactComponent as ESImg } from "../alert/rule/img/ElasticSearch.svg"
import './index.css'

export const Datasources = () => {
const { Search } = Input
Expand Down Expand Up @@ -75,9 +76,12 @@ export const Datasources = () => {
dataIndex: 'enabled',
key: 'enabled',
render: enabled => (
enabled ?
<Tag color="success">启用</Tag> :
<Tag color="error">禁用</Tag>
<div className="status-container">
<div
className={`status-dot ${enabled ? 'status-enabled' : 'status-disabled'}`}
/>
<span>{enabled ? '启用' : '禁用'}</span>
</div>
),
},
{
Expand Down Expand Up @@ -208,9 +212,12 @@ export const Datasources = () => {
dataSource={list}
columns={columns}
scroll={{
x: 1000,
y: height-400
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>

Expand Down
6 changes: 5 additions & 1 deletion src/pages/duty/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ export const DutyManage = () => {
columns={columns}
dataSource={list}
scroll={{
y: height-400
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
</div>
</>
Expand Down
40 changes: 30 additions & 10 deletions src/pages/event/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export const AlertEvent = () => {
key: 'rule_name',
width: 'auto',
},
{
title: '告警指纹',
dataIndex: 'fingerprint',
key: 'fingerprint',
width: 'auto',
},
{
title: '数据源',
dataIndex: 'datasourceId',
Expand All @@ -42,8 +48,8 @@ export const AlertEvent = () => {
<div style={{display: 'flex', alignItems: 'center'}}>
<div
style={{
width: '10px',
height: '10px',
width: '8px',
height: '8px',
backgroundColor: severityColors[text],
borderRadius: '50%',
marginRight: '8px',
Expand All @@ -57,7 +63,7 @@ export const AlertEvent = () => {
title: '事件标签',
dataIndex: 'metric',
key: 'metric',
width: 350,
width: 250,
render: (text, record) => (
<span>{showMoreTags([], record)}</span>
),
Expand Down Expand Up @@ -94,7 +100,7 @@ export const AlertEvent = () => {
title: '操作',
dataIndex: 'operation',
fixed: 'right',
width: 200,
width: 100,
render: (_, record) =>
currentEventList.length >= 1 ? (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '4px' }}>
Expand All @@ -118,6 +124,12 @@ export const AlertEvent = () => {
key: 'rule_name',
width: 'auto',
},
{
title: '告警指纹',
dataIndex: 'fingerprint',
key: 'fingerprint',
width: 'auto',
},
{
title: '数据源',
dataIndex: 'datasourceId',
Expand All @@ -138,8 +150,8 @@ export const AlertEvent = () => {
<div style={{display: 'flex', alignItems: 'center'}}>
<div
style={{
width: '10px',
height: '10px',
width: '8px',
height: '8px',
backgroundColor: severityColors[text],
borderRadius: '50%',
marginRight: '8px',
Expand All @@ -153,7 +165,7 @@ export const AlertEvent = () => {
title: '事件标签',
dataIndex: 'metric',
key: 'metric',
width: 350,
width: 250,
render: (text, record) => (
<span>{showMoreTags([], record)}</span>
),
Expand All @@ -167,7 +179,7 @@ export const AlertEvent = () => {
<span>
{record.annotations && (
<span>
{record.annotations.substring(0, 100)}
{record.annotations.substring(0, 50)}
<Button type="link" onClick={() => { showDrawer(record.annotations) }}>
查看详情
</Button>
Expand Down Expand Up @@ -679,8 +691,12 @@ export const AlertEvent = () => {
}}
onChange={handleCurrentPageChange}
scroll={{
y: height-380
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
) || (
<Table
Expand All @@ -695,8 +711,12 @@ export const AlertEvent = () => {
}}
onChange={handleHistoryPageChange}
scroll={{
y: height-380
y: height - 400, // 动态设置滚动高度
x: 'max-content', // 水平滚动
}}
bordered // 添加表格边框
style={{ backgroundColor: '#fff' }} // 设置表格背景色
rowKey={(record) => record.id} // 设置行唯一键
/>
)}
</div>
Expand Down
Loading

0 comments on commit 080a58c

Please sign in to comment.