Skip to content

Commit ea6ac58

Browse files
committed
[IDG-Apollo-platform-5369]Merge branch 'v8.0-v2x_profile' add v2x frontend api
Change-Id: I8f74f58f763125fe40f10dee4df0859116d1ae30
2 parents bb38e5c + 30c0da2 commit ea6ac58

File tree

10 files changed

+2385
-2505
lines changed

10 files changed

+2385
-2505
lines changed

modules/dreamview/frontend/dist/app.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/dreamview/frontend/dist/app.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/dreamview/frontend/dist/parameters.json

Lines changed: 1 addition & 403 deletions
Large diffs are not rendered by default.

modules/dreamview/frontend/dist/worker.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/dreamview/frontend/dist/worker.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/dreamview/frontend/proto_bundle/sim_world_proto_bundle.json

Lines changed: 2046 additions & 2062 deletions
Large diffs are not rendered by default.
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import React, { useEffect, useState } from 'react';
2+
import { Empty, Tag } from 'antd';
3+
import {
4+
CheckCircleOutlined,
5+
ExclamationCircleOutlined,
6+
MinusCircleOutlined,
7+
SyncOutlined,
8+
} from '@ant-design/icons';
9+
import { vehicleInfoMap } from 'utils/vehicleInfoMap';
10+
import { PLUGIN_WS } from 'store/websocket';
11+
import VehicleListItem from 'components/DataProfile/VehicleListItem';
12+
13+
14+
function V2xList() {
15+
/**
16+
* @type {{
17+
* v2xId: string,
18+
* obu_in: string,
19+
* }[]}
20+
*/
21+
const [v2xInfoList, setV2xInfoList] = useState([]);
22+
const [v2xUpdateStatus, setV2xUpdateStatus] = useState(0);
23+
24+
useEffect(() => {
25+
PLUGIN_WS.getV2xInfo().then((data) => {
26+
const v2x = [];
27+
Object.keys(data).forEach((key) => {
28+
v2x.push({
29+
v2xId: key,
30+
...data[key],
31+
});
32+
});
33+
setV2xInfoList(v2x);
34+
// 更新完成状态
35+
setV2xUpdateStatus(1);
36+
});
37+
}, []);
38+
39+
return (<div className='remote-vehicle-list'>
40+
{/* 更新后 没有存在v2x设备 */}
41+
{(v2xInfoList.length === 0 && v2xUpdateStatus !== 0) &&
42+
<div className='remote-vehicle-list_empty'>
43+
<Empty
44+
style={{color: '#fff'}}
45+
image={Empty.PRESENTED_IMAGE_SIMPLE}
46+
description="There is no v2x under your account."/>
47+
</div>}
48+
{/* 更新后 存在v2x设备 */}
49+
{
50+
(v2xInfoList.length > 0 && v2xUpdateStatus !== 0) &&
51+
v2xInfoList.map((item) =>
52+
<div className='remote-vehicle-list-item-container' key={item.v2xId} >
53+
<V2xListItem value={item.v2xId} item={item}/>
54+
</div>
55+
)
56+
}
57+
</div>);
58+
}
59+
60+
61+
function V2xListItem(props) {
62+
/**
63+
* @type {{
64+
* v2xId: string,
65+
* obu_in: string,
66+
* }}
67+
*/
68+
const { item } = props;
69+
70+
const [status, setStatus] = React.useState('unknown');
71+
72+
const handleClick = (event) => {
73+
event.stopPropagation();
74+
const content = event.target.textContent;
75+
if (content === 'Reset') {
76+
setStatus('resetting');
77+
PLUGIN_WS.resetV2xConf(item.v2xId).then(() => {
78+
setStatus('clean');
79+
},
80+
() => {
81+
setStatus('error');
82+
});
83+
}
84+
if (content === 'Refresh') {
85+
setStatus('refreshing');
86+
PLUGIN_WS.refreshV2xConf(item.v2xId).then(() => {
87+
setStatus('clean');
88+
},
89+
() => {
90+
setStatus('error');
91+
});
92+
}
93+
if (content === 'Upload') {
94+
setStatus('uploading');
95+
PLUGIN_WS.uploadV2xConf(item.v2xId).then(() => {
96+
setStatus('clean');
97+
},
98+
() => {
99+
setStatus('error');
100+
});
101+
}
102+
};
103+
return (
104+
<div className='vehicle-list-item'>
105+
<div className='vehicle-list-item_name'>{
106+
item.obu_in
107+
}</div>
108+
<V2xListItemStatus status={status} />
109+
{/* 按钮组 */}
110+
<div className='vehicle-list-item_btns'>
111+
<button className='vehicle-list-item_btns_btn' onClick={handleClick}>Refresh</button>
112+
<button className='vehicle-list-item_btns_btn' onClick={handleClick}>Upload</button>
113+
<button className='vehicle-list-item_btns_btn' onClick={handleClick}>Reset</button>
114+
</div>
115+
</div>
116+
);
117+
}
118+
119+
/**
120+
* 更新状态
121+
* @param props {{
122+
* status: "refreshing" | "resetting" | "clean" | "unknown" | "error"| "uploading",
123+
* }}
124+
* @return {JSX.Element}
125+
* @constructor
126+
*/
127+
function V2xListItemStatus(props) {
128+
const { status } = props;
129+
let icon = null;
130+
const color = '#000000';
131+
switch (status) {
132+
case 'refreshing':
133+
icon = <SyncOutlined spin style={{ color: '#1D9063' }} />;
134+
break;
135+
case 'resetting':
136+
icon = <SyncOutlined spin style={{ color: '#1D9063' }} />;
137+
break;
138+
case 'clean':
139+
icon = <CheckCircleOutlined style={{ color: '#1D9063' }} />;
140+
break;
141+
case 'unknown':
142+
icon = <MinusCircleOutlined style={{ color: '#faad14' }} />;
143+
break;
144+
case 'error':
145+
icon = <ExclamationCircleOutlined style={{ color: '#f5222d' }} />;
146+
break;
147+
case 'uploading':
148+
icon = <SyncOutlined spin style={{ color: '#1D9063' }} />;
149+
break;
150+
default:
151+
break;
152+
}
153+
return (
154+
<Tag className='vehicle-list-item_status' icon={icon} color={color}>
155+
{status.toUpperCase()}
156+
</Tag>
157+
);
158+
}
159+
160+
export default V2xList;

modules/dreamview/frontend/src/components/DataProfile/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ScenarioCertificateInvalid, ScenarioNoCertificate }
1313
from './ScenarioNoCertificate';
1414
import RemoteResourseItem from './RemoteResourseItem';
1515
import VehicleListItem from './VehicleListItem';
16+
import V2xList from './V2xList';
1617

1718
const RadioGroup = Radio.Group;
1819

@@ -42,6 +43,10 @@ export default class DataProfile extends React.Component {
4243
title: 'Vehicle Profiles',
4344
key: 'vehicleProfiles',
4445
},
46+
{
47+
title: 'v2x Profiles',
48+
key: 'v2xProfiles',
49+
},
4550
],
4651
};
4752
}
@@ -176,6 +181,9 @@ export default class DataProfile extends React.Component {
176181
</div>);
177182
};
178183

184+
// 渲染v2x tab
185+
renderV2xProfilesList = () => <V2xList />;
186+
179187
render() {
180188

181189
const { store } = this.props;
@@ -316,6 +324,7 @@ export default class DataProfile extends React.Component {
316324
{currentKey === 'dynamicModel' && this.renderDynamicModelList()}
317325
{currentKey === 'recordProfiles' && this.renderRecordProfilesList()}
318326
{currentKey === 'vehicleProfiles' && this.renderVehicleProfilesList()}
327+
{currentKey === 'v2xProfiles' && this.renderV2xProfilesList()}
319328
</div>
320329
</div>
321330
</div>

modules/dreamview/frontend/src/store/websocket/websocket_camera.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default class CameraDataWebSocketEndpoint {
9393
} else if (message?.data?.name === 'GetCameraChannelListFail') {
9494
reject(message?.data);
9595
}
96-
});
96+
}, { once: true });
9797
}
9898
);
9999
}

0 commit comments

Comments
 (0)