Skip to content

Commit 6585610

Browse files
committed
A 系统设置-关于页面
1 parent 6eea69e commit 6585610

File tree

6 files changed

+74
-8
lines changed

6 files changed

+74
-8
lines changed

spug_api/apps/setting/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .views import *
77

88
urlpatterns = [
9+
url(r'^$', SettingView.as_view()),
910
url(r'^ldap_test/$', ldap_test),
10-
url('', SettingView.as_view()),
11+
url(r'^about/$', get_about)
1112
]

spug_api/apps/setting/views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
22
# Copyright: (c) <[email protected]>
33
# Released under the MIT License.
4+
import django
45
from django.views.generic import View
6+
from django.conf import settings
57
from libs import JsonParser, Argument, json_response
68
from apps.setting.utils import AppSetting
79
from apps.setting.models import Setting
10+
import platform
811
import ldap
912

1013

@@ -41,5 +44,13 @@ def ldap_test(request):
4144
return json_response(error=error)
4245

4346

47+
def get_about(request):
48+
return json_response({
49+
'python_version': platform.python_version(),
50+
'system_version': platform.platform(),
51+
'spug_version': settings.SPUG_VERSION,
52+
'django_version': django.get_version()
53+
})
54+
4455

4556

spug_api/spug/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
re.compile('/apis/.*'),
122122
)
123123

124+
SPUG_VERSION = 'v2.2.0'
125+
124126
# override default config
125127
try:
126128
from spug.overrides import *
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
3+
* Copyright (c) <[email protected]>
4+
* Released under the MIT License.
5+
*/
6+
import React from 'react';
7+
import styles from './index.module.css';
8+
import { Descriptions, Spin } from "antd";
9+
import { observer } from 'mobx-react'
10+
import { http } from 'libs';
11+
12+
13+
@observer
14+
class About extends React.Component {
15+
constructor(props) {
16+
super(props);
17+
this.state = {
18+
fetching: true,
19+
info: {}
20+
}
21+
}
22+
23+
componentDidMount() {
24+
http.get('/api/setting/about/')
25+
.then(res => this.setState({info: res}))
26+
.finally(() => this.setState({fetching: false}))
27+
}
28+
29+
30+
render() {
31+
const {info, fetching} = this.state;
32+
return (
33+
<Spin spinning={fetching}>
34+
<div className={styles.title}>关于</div>
35+
<Descriptions column={1}>
36+
<Descriptions.Item label="操作系统">{info['system_version']}</Descriptions.Item>
37+
<Descriptions.Item label="Python版本">{info['python_version']}</Descriptions.Item>
38+
<Descriptions.Item label="Django版本">{info['django_version']}</Descriptions.Item>
39+
<Descriptions.Item label="Spug版本">{info['spug_version']}</Descriptions.Item>
40+
<Descriptions.Item label="官网文档">
41+
<a href="https://spug.dev" target="_blank">https://spug.dev</a>
42+
</Descriptions.Item>
43+
</Descriptions>
44+
</Spin>
45+
)
46+
}
47+
}
48+
49+
export default About

spug_web/src/pages/system/setting/LDAPSetting.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,38 @@ class LDAPSetting extends React.Component {
5454
return (
5555
<React.Fragment>
5656
<div className={styles.title}>LDAP设置</div>
57-
<Form style={{maxWidth: 400}}>
58-
<Form.Item labelCol={{span: 8}} wrapperCol={{span: 16}} required label="LDAP服务地址">
57+
<Form style={{maxWidth: 400}} labelCol={{span: 8}} wrapperCol={{span: 16}}>
58+
<Form.Item required label="LDAP服务地址">
5959
{getFieldDecorator('server', {initialValue: this.setting['server'],
6060
rules: [{required: true, message: '请输入LDAP服务地址'}]})(
6161
<Input placeholder="请输入LDAP服务地址"/>
6262
)}
6363
</Form.Item>
64-
<Form.Item labelCol={{span: 8}} wrapperCol={{span: 16}} required label="LDAP服务端口">
64+
<Form.Item required label="LDAP服务端口">
6565
{getFieldDecorator('port', {initialValue: this.setting['port'],
6666
rules: [{required: true, message: '请输入LDAP服务端口'}]})(
6767
<Input placeholder="例如:389"/>
6868
)}
6969
</Form.Item>
70-
<Form.Item labelCol={{span: 8}} wrapperCol={{span: 16}} required label="管理员DN">
70+
<Form.Item required label="管理员DN">
7171
{getFieldDecorator('admin_dn', {initialValue: this.setting['admin_dn'],
7272
rules: [{required: true, message: '请输入LDAP管理员DN'}]})(
7373
<Input placeholder="例如:cn=admin,dc=spug,dc=dev"/>
7474
)}
7575
</Form.Item>
76-
<Form.Item labelCol={{span: 8}} wrapperCol={{span: 16}} required label="管理员密码">
76+
<Form.Item required label="管理员密码">
7777
{getFieldDecorator('password', {initialValue: this.setting['password'],
7878
rules: [{required: true, message: '请输入LDAP管理员密码'}]})(
7979
<Input.Password placeholder="请输入LDAP管理员密码"/>
8080
)}
8181
</Form.Item>
82-
<Form.Item labelCol={{span: 8}} wrapperCol={{span: 16}} required label="LDAP搜索规则">
82+
<Form.Item required label="LDAP搜索规则">
8383
{getFieldDecorator('rules', {initialValue: this.setting['rules'],
8484
rules: [{required: true, message: '请输入LDAP搜索规则'}]})(
8585
<Input placeholder="例如:cn"/>
8686
)}
8787
</Form.Item>
88-
<Form.Item labelCol={{span: 8}} wrapperCol={{span: 16}} required label="基本DN">
88+
<Form.Item required label="基本DN">
8989
{getFieldDecorator('base_dn', {initialValue: this.setting['base_dn'],
9090
rules: [{required: true, message: '请输入LDAP基本DN'}]})(
9191
<Input placeholder="例如:dc=spug,dc=dev"/>

spug_web/src/pages/system/setting/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import BasicSetting from './BasicSetting';
1010
import AlarmSetting from './AlarmSetting';
1111
import LDAPSetting from './LDAPSetting';
1212
import OpenService from './OpenService';
13+
import About from './About';
1314
import styles from './index.module.css';
1415
import store from './store';
1516

@@ -40,13 +41,15 @@ class Index extends React.Component {
4041
<Menu.Item key="ldap">LDAP设置</Menu.Item>
4142
<Menu.Item key="alarm">报警服务设置</Menu.Item>
4243
<Menu.Item key="service">开放服务设置</Menu.Item>
44+
<Menu.Item key="about">关于</Menu.Item>
4345
</Menu>
4446
</div>
4547
<div className={styles.right}>
4648
{selectedKeys[0] === 'basic' && <BasicSetting />}
4749
{selectedKeys[0] === 'ldap' && <LDAPSetting />}
4850
{selectedKeys[0] === 'alarm' && <AlarmSetting />}
4951
{selectedKeys[0] === 'service' && <OpenService />}
52+
{selectedKeys[0] === 'about' && <About />}
5053
</div>
5154
</AuthDiv>
5255
)

0 commit comments

Comments
 (0)