-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: Static Info Pages * fix: 代码格式化,使用Select组件 * fix: 优化Select组件和表格联动 * fix: ./Info.less error not found. * fix: Format code * fix: delete console.log() * fix: Optimized code * fix: Optimized code * fix: Modify data, wait for api. * feat: integrate with API * fix: format codes * fix: i18n * fix: link to instructions for use * fix: format codes * fix: format codes * fix: format codes * fix: node type * Update web/src/pages/ServerInfo/List.tsx Co-authored-by: litesun <[email protected]> * fix: format codes Co-authored-by: 琚致远 <[email protected]> Co-authored-by: litesun <[email protected]>
- Loading branch information
1 parent
4667e6e
commit 4f12ae6
Showing
11 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Select, Empty, Form } from 'antd'; | ||
import { PageContainer } from '@ant-design/pro-layout'; | ||
import { useIntl } from 'umi'; | ||
|
||
import { fetchInfoList } from './service'; | ||
import styles from './style.less'; | ||
|
||
const ServerInfo: React.FC = () => { | ||
const [data, setData] = useState<ServerInfoModule.Node>(); | ||
const [nodeList, setNodeList] = useState<ServerInfoModule.Node[]>([]); | ||
const { formatMessage } = useIntl(); | ||
const { Option } = Select; | ||
|
||
const [form] = Form.useForm(); | ||
|
||
useEffect(() => { | ||
fetchInfoList().then((list) => { | ||
setNodeList(list); | ||
if (list.length) { | ||
form.setFieldsValue({ | ||
nodeId: list[0].id, | ||
}); | ||
|
||
setData(list[0]); | ||
} | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<PageContainer title={formatMessage({ id: 'page.serverinfo.pageContainer.title' })}> | ||
<div className={styles.select}> | ||
<Form form={form}> | ||
<Form.Item wrapperCol={{ span: 5 }} style={{ marginBottom: 0 }} name="nodeId"> | ||
<Select | ||
placeholder={formatMessage({ id: 'page.serverinfo.select.placeholder' })} | ||
onChange={(value) => { | ||
setData( | ||
nodeList.find((item) => { | ||
return item.id === value; | ||
}) | ||
); | ||
}} | ||
> | ||
{nodeList.map((item) => ( | ||
<Option key={item.hostname} value={item.id}> | ||
{item.hostname} | ||
</Option> | ||
))} | ||
; | ||
</Select> | ||
</Form.Item> | ||
<Form.Item style={{ marginBottom: 0, fontSize: '12px', color: '#00000073' }}> | ||
{formatMessage({ id: 'page.serverinfo.desc' })} | ||
<a | ||
href="https://github.com/apache/apisix/blob/master/doc/plugins/server-info.md" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
{formatMessage({ id: 'page.serverinfo.link' })} | ||
</a> | ||
</Form.Item> | ||
</Form> | ||
</div> | ||
<div className={styles.wrap}> | ||
{nodeList.length === 0 && <Empty />} | ||
{nodeList.length > 0 && ( | ||
<table className={styles.table}> | ||
<tbody> | ||
{Object.entries(data || {}).map((item) => ( | ||
<tr> | ||
<td>{item[0]}</td> | ||
<td>{item[1]}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
)} | ||
</div> | ||
</PageContainer> | ||
); | ||
}; | ||
|
||
export default ServerInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export { default } from './List'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export default { | ||
'page.serverinfo.pageContainer.title': 'Server Info', | ||
'page.serverinfo.select.placeholder': 'Please select node', | ||
'page.serverinfo.desc': 'The relevant plugin need to be enabled to report server info.', | ||
'page.serverinfo.link': 'How to enable?', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export default { | ||
'page.serverinfo.pageContainer.title': '服务端信息', | ||
'page.serverinfo.select.placeholder': '请选择节点', | ||
'page.serverinfo.desc': '需启用相关插件,才能获取信息。', | ||
'page.serverinfo.link': '如何启用?', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { request } from 'umi'; | ||
|
||
export const fetchInfoList = () => { | ||
return request<Res<ResListData<ServerInfoModule.Node>>>( | ||
'/server_info', | ||
).then(({ data }) => data.rows); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
.select { | ||
margin-bottom: 15px; | ||
padding: 12px 24px; | ||
background-color: #fff; | ||
} | ||
|
||
.wrap { | ||
width: 100%; | ||
margin: 0 auto; | ||
padding: 16px 24px; | ||
background-color: #fff; | ||
} | ||
|
||
.table { | ||
width: 100%; | ||
color: rgba(0, 0, 0, 0.45); | ||
border-collapse: collapse; | ||
|
||
th, | ||
td { | ||
padding: 12px 8px; | ||
} | ||
|
||
td:nth-child(2) { | ||
text-align: right; | ||
} | ||
|
||
tr:nth-child(odd) { | ||
background-color: #f3f4f5; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
declare namespace ServerInfoModule { | ||
type Node = { | ||
id: string; | ||
last_report_time: integer; | ||
up_time: integer; | ||
boot_time: integer; | ||
etcd_version: string; | ||
hostname: string; | ||
version: string; | ||
}; | ||
} |