mirror of https://github.com/openspug/spug
fix issues
parent
916c70a16b
commit
f273e44b63
|
@ -69,6 +69,7 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
|
margin-right: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.option {
|
.option {
|
||||||
|
|
|
@ -36,10 +36,13 @@ export function hasPermission(strCode) {
|
||||||
|
|
||||||
export function includes(s, key) {
|
export function includes(s, key) {
|
||||||
key = key.toLowerCase();
|
key = key.toLowerCase();
|
||||||
if (s) {
|
if (Array.isArray(s)) {
|
||||||
return s.toLowerCase().includes(key)
|
for (let i of s) {
|
||||||
} else {
|
if (i && i.toLowerCase().includes(key)) return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
|
} else {
|
||||||
|
return s && s.toLowerCase().includes(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ export default observer(function () {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
title="分组列表"
|
title="分组列表"
|
||||||
|
style={{height: '100%'}}
|
||||||
loading={store.grpFetching}
|
loading={store.grpFetching}
|
||||||
extra={(
|
extra={(
|
||||||
<AuthFragment auth="admin">
|
<AuthFragment auth="admin">
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { Table, Modal, Dropdown, Button, Menu, Avatar, Tooltip, Space, Tag, Radio, message } from 'antd';
|
import { Table, Modal, Dropdown, Button, Menu, Avatar, Tooltip, Space, Tag, Radio, Input, message } from 'antd';
|
||||||
import { PlusOutlined, DownOutlined, SyncOutlined } from '@ant-design/icons';
|
import { PlusOutlined, DownOutlined, SyncOutlined, FormOutlined } from '@ant-design/icons';
|
||||||
import { Action, TableCard, AuthButton, AuthFragment } from 'components';
|
import { Action, TableCard, AuthButton, AuthFragment } from 'components';
|
||||||
import { http, hasPermission } from 'libs';
|
import { http, hasPermission } from 'libs';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
|
@ -30,6 +30,8 @@ function ComTable() {
|
||||||
function handleImport(menu) {
|
function handleImport(menu) {
|
||||||
if (menu.key === 'excel') {
|
if (menu.key === 'excel') {
|
||||||
store.importVisible = true
|
store.importVisible = true
|
||||||
|
} else if (menu.key === 'form') {
|
||||||
|
store.showForm()
|
||||||
} else {
|
} else {
|
||||||
store.cloudImport = menu.key
|
store.cloudImport = menu.key
|
||||||
}
|
}
|
||||||
|
@ -48,24 +50,20 @@ function ComTable() {
|
||||||
return (
|
return (
|
||||||
<TableCard
|
<TableCard
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
title={<TableCard.Search keys={['f_name/主机名称', 'f_host/连接地址']} onChange={(k, v) => store[k] = v}/>}
|
title={<Input placeholder="输入检索" style={{maxWidth: 250}} onChange={e => store.f_word = e.target.value}/>}
|
||||||
loading={store.isFetching}
|
loading={store.isFetching}
|
||||||
dataSource={store.dataSource}
|
dataSource={store.dataSource}
|
||||||
onReload={store.fetchRecords}
|
onReload={store.fetchRecords}
|
||||||
actions={[
|
actions={[
|
||||||
<AuthButton
|
<AuthFragment auth="host.host.add">
|
||||||
auth="host.host.add"
|
|
||||||
type="primary"
|
|
||||||
icon={<PlusOutlined/>}
|
|
||||||
onClick={() => store.showForm()}>新建</AuthButton>,
|
|
||||||
<AuthButton
|
|
||||||
auth="host.host.add"
|
|
||||||
type="primary"
|
|
||||||
icon={<SyncOutlined/>}
|
|
||||||
onClick={() => store.showSync()}>批量验证</AuthButton>,
|
|
||||||
<AuthFragment auth="host.host.import">
|
|
||||||
<Dropdown overlay={(
|
<Dropdown overlay={(
|
||||||
<Menu onClick={handleImport}>
|
<Menu onClick={handleImport}>
|
||||||
|
<Menu.Item key="form">
|
||||||
|
<Space>
|
||||||
|
<FormOutlined style={{fontSize: 16, marginRight: 4, color: '#1890ff'}}/>
|
||||||
|
<span>新建主机</span>
|
||||||
|
</Space>
|
||||||
|
</Menu.Item>
|
||||||
<Menu.Item key="excel">
|
<Menu.Item key="excel">
|
||||||
<Space>
|
<Space>
|
||||||
<Avatar shape="square" size={20} src={icons.excel}/>
|
<Avatar shape="square" size={20} src={icons.excel}/>
|
||||||
|
@ -86,9 +84,14 @@ function ComTable() {
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
)}>
|
)}>
|
||||||
<Button type="primary">批量导入 <DownOutlined/></Button>
|
<Button type="primary" icon={<PlusOutlined/>}>新建 <DownOutlined/></Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</AuthFragment>,
|
</AuthFragment>,
|
||||||
|
<AuthButton
|
||||||
|
auth="host.host.add"
|
||||||
|
type="primary"
|
||||||
|
icon={<SyncOutlined/>}
|
||||||
|
onClick={() => store.showSync()}>验证</AuthButton>,
|
||||||
<Radio.Group value={store.f_status} onChange={e => store.f_status = e.target.value}>
|
<Radio.Group value={store.f_status} onChange={e => store.f_status = e.target.value}>
|
||||||
<Radio.Button value="">全部</Radio.Button>
|
<Radio.Button value="">全部</Radio.Button>
|
||||||
<Radio.Button value={false}>未验证</Radio.Button>
|
<Radio.Button value={false}>未验证</Radio.Button>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import { observable, computed } from 'mobx';
|
import { observable, computed } from 'mobx';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import http from 'libs/http';
|
import { http, includes } from 'libs';
|
||||||
import lds from 'lodash';
|
import lds from 'lodash';
|
||||||
|
|
||||||
class Store {
|
class Store {
|
||||||
|
@ -26,15 +26,13 @@ class Store {
|
||||||
@observable detailVisible = false;
|
@observable detailVisible = false;
|
||||||
@observable selectorVisible = false;
|
@observable selectorVisible = false;
|
||||||
|
|
||||||
@observable f_name;
|
@observable f_word;
|
||||||
@observable f_host;
|
|
||||||
@observable f_status = '';
|
@observable f_status = '';
|
||||||
|
|
||||||
@computed get dataSource() {
|
@computed get dataSource() {
|
||||||
let records = [];
|
let records = [];
|
||||||
if (this.group.all_host_ids) records = this.records ? this.records.filter(x => this.group.all_host_ids.includes(x.id)) : [];
|
if (this.group.all_host_ids) records = this.records ? this.records.filter(x => this.group.all_host_ids.includes(x.id)) : [];
|
||||||
if (this.f_name) records = records.filter(x => x.name.toLowerCase().includes(this.f_name.toLowerCase()));
|
if (this.f_word) records = records.filter(x => includes(x.name, this.f_word) || includes(x.public_ip_address, this.f_word) || includes(x.private_ip_address, this.f_word));
|
||||||
if (this.f_host) records = records.filter(x => x.hostname.toLowerCase().includes(this.f_host.toLowerCase()));
|
|
||||||
if (this.f_status !== '') records = records.filter(x => this.f_status === x.is_verified);
|
if (this.f_status !== '') records = records.filter(x => this.f_status === x.is_verified);
|
||||||
return records
|
return records
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ export default [{
|
||||||
perms: [
|
perms: [
|
||||||
{key: 'view', label: '查看主机'},
|
{key: 'view', label: '查看主机'},
|
||||||
{key: 'add', label: '新建主机'},
|
{key: 'add', label: '新建主机'},
|
||||||
{key: 'import', label: '批量导入'},
|
|
||||||
{key: 'edit', label: '编辑主机'},
|
{key: 'edit', label: '编辑主机'},
|
||||||
{key: 'del', label: '删除主机'},
|
{key: 'del', label: '删除主机'},
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue