Skip to content

Commit

Permalink
A 增加功能权限文件管理器 #176
Browse files Browse the repository at this point in the history
  • Loading branch information
vapao committed Aug 26, 2020
1 parent 9b18af1 commit 367f21a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion spug_web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import ReactDOM from 'react-dom';
import { Router } from 'react-router-dom';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN';
import history from 'libs/history';
import { history, updatePermissions } from 'libs';
import './index.css';
import App from './App';
import moment from 'moment';
import 'moment/locale/zh-cn';
import * as serviceWorker from './serviceWorker';

moment.locale('zh-cn');
updatePermissions()

ReactDOM.render(
<Router history={history}>
Expand Down
8 changes: 4 additions & 4 deletions spug_web/src/libs/functools.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ let Permission = {
permissions: []
};

export function updatePermissions(isSupper, hostPerms, data) {
Permission.isSuper = isSupper;
Permission.hostPerms = hostPerms;
Permission.permissions = data;
export function updatePermissions() {
Permission.isSuper = localStorage.getItem('is_supper') === 'true';
Permission.hostPerms = JSON.parse(localStorage.getItem('host_perms') || []);
Permission.permissions = JSON.parse(localStorage.getItem('permissions') || []);
}

// 前端页面的权限判断(仅作为前端功能展示的控制,具体权限控制应在后端实现)
Expand Down
2 changes: 2 additions & 0 deletions spug_web/src/libs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* Released under the AGPL-3.0 License.
*/
import _http from './http';
import _history from './history';

export * from './functools';
export * from './router';
export const http = _http;
export const history = _history;
export const VERSION = 'v2.3.8';
2 changes: 1 addition & 1 deletion spug_web/src/pages/deploy/request/Ext2Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import React from 'react';
import { observer } from 'mobx-react';
import { Modal, Form, Input, Tag, Upload, message, Button, Icon } from 'antd';
import { Modal, Form, Input, Tag, Upload, message, Button } from 'antd';
import hostStore from 'pages/host/store';
import http from 'libs/http';
import store from './store';
Expand Down
2 changes: 1 addition & 1 deletion spug_web/src/pages/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class LoginIndex extends React.Component {
localStorage.setItem('is_supper', data['is_supper']);
localStorage.setItem('permissions', JSON.stringify(data['permissions']));
localStorage.setItem('host_perms', JSON.stringify(data['host_perms']));
updatePermissions(data['is_supper'], data['host_perms'], data['permissions']);
updatePermissions();
if (history.location.state && history.location.state['from']) {
history.push(history.location.state['from'])
} else {
Expand Down
8 changes: 6 additions & 2 deletions spug_web/src/pages/ssh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import React from 'react';
import { Button } from 'antd';
import { AuthDiv } from 'components';
import { Terminal } from 'xterm';
import { FitAddon } from 'xterm-addon-fit';
import FileManager from './FileManager';
Expand Down Expand Up @@ -82,12 +83,15 @@ class WebSSH extends React.Component {
<div className={styles.container}>
<div className={styles.header}>
<div>{host.name} | {host.username}@{host.hostname}:{host.port}</div>
<Button disabled={managerDisabled} type="primary" icon="folder-open" onClick={this.handleShow}>文件管理器</Button>
<AuthDiv auth="host.console.manager">
<Button disabled={managerDisabled} type="primary" icon="folder-open"
onClick={this.handleShow}>文件管理器</Button>
</AuthDiv>
</div>
<div className={styles.terminal}>
<div ref={ref => this.container = ref}/>
</div>
<FileManager id={this.id} visible={visible} onClose={this.handleShow} />
<FileManager id={this.id} visible={visible} onClose={this.handleShow}/>
</div>
)
}
Expand Down
6 changes: 6 additions & 0 deletions spug_web/src/pages/system/role/codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export default [{
{key: 'del', label: '删除主机'},
{key: 'console', label: 'Console'},
]
}, {
key: 'console',
label: 'Console',
perms: [
{key: 'manager', label: '文件管理器'},
]
}]
}, {
key: 'exec',
Expand Down

0 comments on commit 367f21a

Please sign in to comment.