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