Update ChannelsTable.js

This commit is contained in:
analogpvt 2023-05-19 23:51:35 +05:30 committed by GitHub
parent 92dab4e0b3
commit ecb4c1bff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ function renderType(type) {
for (let i = 0; i < CHANNEL_OPTIONS.length; i++) { for (let i = 0; i < CHANNEL_OPTIONS.length; i++) {
type2label[CHANNEL_OPTIONS[i].value] = CHANNEL_OPTIONS[i]; type2label[CHANNEL_OPTIONS[i].value] = CHANNEL_OPTIONS[i];
} }
type2label[0] = { value: 0, text: '未知类型', color: 'grey' }; type2label[0] = { value: 0, text: 'Unknown type.', color: 'grey' };
} }
return <Label basic color={type2label[type].color}>{type2label[type].text}</Label>; return <Label basic color={type2label[type].color}>{type2label[type].text}</Label>;
} }
@ -91,7 +91,7 @@ const ChannelsTable = () => {
} }
const { success, message } = res.data; const { success, message } = res.data;
if (success) { if (success) {
showSuccess('操作成功完成'); showSuccess('Operation completed successfully.');
let channel = res.data.data; let channel = res.data.data;
let newChannels = [...channels]; let newChannels = [...channels];
let realIdx = (activePage - 1) * ITEMS_PER_PAGE + idx; let realIdx = (activePage - 1) * ITEMS_PER_PAGE + idx;
@ -109,17 +109,17 @@ const ChannelsTable = () => {
const renderStatus = (status) => { const renderStatus = (status) => {
switch (status) { switch (status) {
case 1: case 1:
return <Label basic color='green'>已启用</Label>; return <Label basic color='green'>Enabled</Label>;
case 2: case 2:
return ( return (
<Label basic color='red'> <Label basic color='red'>
已禁用 Disabled
</Label> </Label>
); );
default: default:
return ( return (
<Label basic color='grey'> <Label basic color='grey'>
未知状态 Unknown status
</Label> </Label>
); );
} }
@ -127,9 +127,9 @@ const ChannelsTable = () => {
const renderResponseTime = (responseTime) => { const renderResponseTime = (responseTime) => {
let time = responseTime / 1000; let time = responseTime / 1000;
time = time.toFixed(2) + " "; time = time.toFixed(2) + " seconds";
if (responseTime === 0) { if (responseTime === 0) {
return <Label basic color='grey'>未测试</Label>; return <Label basic color='grey'>Not tested.</Label>;
} else if (responseTime <= 1000) { } else if (responseTime <= 1000) {
return <Label basic color='green'>{time}</Label>; return <Label basic color='green'>{time}</Label>;
} else if (responseTime <= 3000) { } else if (responseTime <= 3000) {
@ -169,7 +169,7 @@ const ChannelsTable = () => {
newChannels[realIdx].response_time = time * 1000; newChannels[realIdx].response_time = time * 1000;
newChannels[realIdx].test_time = Date.now() / 1000; newChannels[realIdx].test_time = Date.now() / 1000;
setChannels(newChannels); setChannels(newChannels);
showInfo(`通道 ${name} 测试成功,耗时 ${time.toFixed(2)}`); showInfo(`Channels ${name} Test successful, time taken ${time.toFixed(2)} seconds`);
} else { } else {
showError(message); showError(message);
} }
@ -179,7 +179,7 @@ const ChannelsTable = () => {
const res = await API.get(`/api/channel/test`); const res = await API.get(`/api/channel/test`);
const { success, message } = res.data; const { success, message } = res.data;
if (success) { if (success) {
showInfo("已成功开始测试所有已启用通道,请刷新页面查看结果。"); showInfo("All enabled channels have been successfully tested. Please refresh the page to view the results。");
} else { } else {
showError(message); showError(message);
} }
@ -210,7 +210,7 @@ const ChannelsTable = () => {
icon='search' icon='search'
fluid fluid
iconPosition='left' iconPosition='left'
placeholder='搜索渠道的 ID 和名称 ...' placeholder='Search by channel ID and name. ...'
value={searchKeyword} value={searchKeyword}
loading={searching} loading={searching}
onChange={handleKeywordChange} onChange={handleKeywordChange}
@ -234,7 +234,7 @@ const ChannelsTable = () => {
sortChannel('name'); sortChannel('name');
}} }}
> >
名称 Name
</Table.HeaderCell> </Table.HeaderCell>
<Table.HeaderCell <Table.HeaderCell
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}
@ -242,7 +242,7 @@ const ChannelsTable = () => {
sortChannel('type'); sortChannel('type');
}} }}
> >
类型 Type
</Table.HeaderCell> </Table.HeaderCell>
<Table.HeaderCell <Table.HeaderCell
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}
@ -250,7 +250,7 @@ const ChannelsTable = () => {
sortChannel('status'); sortChannel('status');
}} }}
> >
状态 Status
</Table.HeaderCell> </Table.HeaderCell>
<Table.HeaderCell <Table.HeaderCell
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}
@ -258,7 +258,7 @@ const ChannelsTable = () => {
sortChannel('response_time'); sortChannel('response_time');
}} }}
> >
响应时间 Response time
</Table.HeaderCell> </Table.HeaderCell>
<Table.HeaderCell <Table.HeaderCell
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}
@ -266,9 +266,9 @@ const ChannelsTable = () => {
sortChannel('test_time'); sortChannel('test_time');
}} }}
> >
测试时间 Test time
</Table.HeaderCell> </Table.HeaderCell>
<Table.HeaderCell>操作</Table.HeaderCell> <Table.HeaderCell>Actions</Table.HeaderCell>
</Table.Row> </Table.Row>
</Table.Header> </Table.Header>
@ -283,11 +283,11 @@ const ChannelsTable = () => {
return ( return (
<Table.Row key={channel.id}> <Table.Row key={channel.id}>
<Table.Cell>{channel.id}</Table.Cell> <Table.Cell>{channel.id}</Table.Cell>
<Table.Cell>{channel.name ? channel.name : ''}</Table.Cell> <Table.Cell>{channel.name ? channel.name : 'none'}</Table.Cell>
<Table.Cell>{renderType(channel.type)}</Table.Cell> <Table.Cell>{renderType(channel.type)}</Table.Cell>
<Table.Cell>{renderStatus(channel.status)}</Table.Cell> <Table.Cell>{renderStatus(channel.status)}</Table.Cell>
<Table.Cell>{renderResponseTime(channel.response_time)}</Table.Cell> <Table.Cell>{renderResponseTime(channel.response_time)}</Table.Cell>
<Table.Cell>{channel.test_time ? renderTimestamp(channel.test_time) : "未测试"}</Table.Cell> <Table.Cell>{channel.test_time ? renderTimestamp(channel.test_time) : "Not tested."}</Table.Cell>
<Table.Cell> <Table.Cell>
<div> <div>
<Button <Button
@ -297,12 +297,12 @@ const ChannelsTable = () => {
testChannel(channel.id, channel.name, idx); testChannel(channel.id, channel.name, idx);
}} }}
> >
测试 Test
</Button> </Button>
<Popup <Popup
trigger={ trigger={
<Button size='small' negative> <Button size='small' negative>
删除 Delete
</Button> </Button>
} }
on='click' on='click'
@ -315,7 +315,7 @@ const ChannelsTable = () => {
manageChannel(channel.id, 'delete', idx); manageChannel(channel.id, 'delete', idx);
}} }}
> >
删除渠道 {channel.name} Delete Channel {channel.name}
</Button> </Button>
</Popup> </Popup>
<Button <Button
@ -328,14 +328,14 @@ const ChannelsTable = () => {
); );
}} }}
> >
{channel.status === 1 ? '禁用' : '启用'} {channel.status === 1 ? 'Disable' : 'Enable'}
</Button> </Button>
<Button <Button
size={'small'} size={'small'}
as={Link} as={Link}
to={'/channel/edit/' + channel.id} to={'/channel/edit/' + channel.id}
> >
编辑 Edit
</Button> </Button>
</div> </div>
</Table.Cell> </Table.Cell>
@ -348,10 +348,10 @@ const ChannelsTable = () => {
<Table.Row> <Table.Row>
<Table.HeaderCell colSpan='7'> <Table.HeaderCell colSpan='7'>
<Button size='small' as={Link} to='/channel/add' loading={loading}> <Button size='small' as={Link} to='/channel/add' loading={loading}>
添加新的渠道 Add New Channel
</Button> </Button>
<Button size='small' loading={loading} onClick={testAllChannels}> <Button size='small' loading={loading} onClick={testAllChannels}>
测试所有已启用通道 Test All Enabled Channels.
</Button> </Button>
<Pagination <Pagination
floated='right' floated='right'
@ -364,7 +364,7 @@ const ChannelsTable = () => {
(channels.length % ITEMS_PER_PAGE === 0 ? 1 : 0) (channels.length % ITEMS_PER_PAGE === 0 ? 1 : 0)
} }
/> />
<Button size='small' onClick={refresh} loading={loading}>刷新</Button> <Button size='small' onClick={refresh} loading={loading}>Refresh</Button>
</Table.HeaderCell> </Table.HeaderCell>
</Table.Row> </Table.Row>
</Table.Footer> </Table.Footer>