优化资产管理、我的资产页面排序

This commit is contained in:
dushixiang 2022-11-13 22:42:24 +08:00
parent 39a0678bb9
commit 76baf3e41e
3 changed files with 25 additions and 6 deletions

View File

@ -99,9 +99,13 @@ func (r assetRepository) Find(c context.Context, pageIndex, pageSize int, name,
order = "desc" order = "desc"
} }
if field == "name" { switch field {
field = "name" case "name":
} else { case "protocol":
case "ip":
case "active":
default:
field = "created" field = "created"
} }
@ -319,9 +323,13 @@ func (r assetRepository) FindMyAssets(c context.Context, pageIndex, pageSize int
order = "desc" order = "desc"
} }
if field == "name" { switch field {
field = "name" case "name":
} else { case "protocol":
case "ip":
case "active":
default:
field = "created" field = "created"
} }

View File

@ -71,6 +71,7 @@ const Asset = () => {
{ {
title: '名称', title: '名称',
dataIndex: 'name', dataIndex: 'name',
sorter: true,
render: (text, record) => { render: (text, record) => {
if (record['description'] === '-') { if (record['description'] === '-') {
record['description'] = ''; record['description'] = '';
@ -93,6 +94,7 @@ const Asset = () => {
title: '协议', title: '协议',
dataIndex: 'protocol', dataIndex: 'protocol',
key: 'protocol', key: 'protocol',
sorter: true,
render: (text, record) => { render: (text, record) => {
return ( return (
<Tag color={PROTOCOL_COLORS[text]}>{text}</Tag> <Tag color={PROTOCOL_COLORS[text]}>{text}</Tag>
@ -116,6 +118,7 @@ const Asset = () => {
title: '网络', title: '网络',
dataIndex: 'network', dataIndex: 'network',
key: 'network', key: 'network',
sorter: true,
fieldProps: { fieldProps: {
placeholder: '示例: 127.0.0.1:22' placeholder: '示例: 127.0.0.1:22'
}, },
@ -154,6 +157,7 @@ const Asset = () => {
title: '状态', title: '状态',
dataIndex: 'active', dataIndex: 'active',
key: 'active', key: 'active',
sorter: true,
render: (text, record) => { render: (text, record) => {
if (record['testing'] === true) { if (record['testing'] === true) {
return ( return (
@ -198,6 +202,7 @@ const Asset = () => {
title: '创建时间', title: '创建时间',
key: 'created', key: 'created',
dataIndex: 'created', dataIndex: 'created',
sorter: true,
hideInSearch: true, hideInSearch: true,
}, },
{ {
@ -345,6 +350,9 @@ const Asset = () => {
let order = ''; let order = '';
if (Object.keys(sort).length > 0) { if (Object.keys(sort).length > 0) {
field = Object.keys(sort)[0]; field = Object.keys(sort)[0];
if (field === 'network') {
field = 'ip';
}
order = Object.values(sort)[0]; order = Object.values(sort)[0];
} }

View File

@ -21,6 +21,7 @@ const MyAsset = () => {
{ {
title: '名称', title: '名称',
dataIndex: 'name', dataIndex: 'name',
sorter: true,
render: (text, record) => { render: (text, record) => {
if (record['description'] === '-') { if (record['description'] === '-') {
record['description'] = ''; record['description'] = '';
@ -38,6 +39,7 @@ const MyAsset = () => {
title: '协议', title: '协议',
dataIndex: 'protocol', dataIndex: 'protocol',
key: 'protocol', key: 'protocol',
sorter: true,
render: (text, record) => { render: (text, record) => {
return ( return (
<Tag color={PROTOCOL_COLORS[text]}>{text}</Tag> <Tag color={PROTOCOL_COLORS[text]}>{text}</Tag>
@ -89,6 +91,7 @@ const MyAsset = () => {
title: '状态', title: '状态',
dataIndex: 'active', dataIndex: 'active',
key: 'active', key: 'active',
sorter: true,
render: (text, record) => { render: (text, record) => {
if (record['testing'] === true) { if (record['testing'] === true) {
return ( return (