fix issue

pull/342/head
vapao 2021-06-25 16:08:51 +08:00
parent ac8437266d
commit 1539512e5c
4 changed files with 13 additions and 5 deletions

View File

@ -111,5 +111,7 @@ class GroupView(View):
return json_response(error='请移除子分组后再尝试删除')
if group.hosts.exists():
return json_response(error='请移除分组下的主机后再尝试删除')
if Group.objects.exclude(pk=form.id).exists():
return json_response(error='请至少保留一个分组')
group.delete()
return json_response(error=error)

View File

@ -145,7 +145,7 @@ export default observer(function () {
<Form.Item name="desc" label="备注信息">
<Input.TextArea placeholder="请输入主机备注信息"/>
</Form.Item>
<Form.Item wrapperCol={{span: 14, offset: 6}}>
<Form.Item wrapperCol={{span: 17, offset: 5}}>
<Alert showIcon type="info" message="首次验证时需要输入登录用户名对应的密码,该密码会用于配置密钥连接,不会存储该密码。" />
</Form.Item>
</Form>

View File

@ -5,7 +5,7 @@
*/
import React, { useState, useEffect } from 'react';
import { observer } from 'mobx-react';
import { Input, Card, Tree, Dropdown, Menu, Switch, message } from 'antd';
import { Input, Card, Tree, Dropdown, Menu, Switch, Tooltip, message } from 'antd';
import {
FolderOutlined,
FolderAddOutlined,
@ -13,7 +13,8 @@ import {
DeleteOutlined,
CopyOutlined,
ScissorOutlined,
LoadingOutlined
LoadingOutlined,
QuestionCircleOutlined
} from '@ant-design/icons';
import { AuthFragment } from 'components';
import { hasPermission, http } from 'libs';
@ -155,6 +156,7 @@ export default observer(function () {
onChange={setDraggable}
checkedChildren="排版"
unCheckedChildren="浏览"/>
<Tooltip title="右键点击分组进行编辑,开启排版模式后可通过拖拽分组进行快速排序。"><QuestionCircleOutlined style={{marginLeft: 8, color: '#999'}}/></Tooltip>
</AuthFragment>)}>
<Dropdown
overlay={menus}
@ -163,6 +165,7 @@ export default observer(function () {
onVisibleChange={v => v || setVisible(v)}>
<Tree.DirectoryTree
autoExpandParent
expandAction="doubleClick"
draggable={draggable}
treeData={store.treeData}
titleRender={treeRender}
@ -174,6 +177,9 @@ export default observer(function () {
onRightClick={handleRightClick}
/>
</Dropdown>
{store.records && store.treeData.length === 0 && (
<div style={{color: '#999'}}>你还没有可访问的主机分组请联系管理员分配主机权限</div>
)}
</Card>
)
})

View File

@ -30,7 +30,7 @@ class Store {
@computed get dataSource() {
let records = [];
if (this.group.all_host_ids) 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_host) records = records.filter(x => x.hostname.toLowerCase().includes(this.f_host.toLowerCase()));
return records
@ -67,7 +67,7 @@ class Store {
.then(http.spread((res1, res2) => {
this.records = res1;
this.records.map(item => this.idMap[item.id] = item);
this.group = res2.treeData[0];
this.group = res2.treeData[0] || {};
this.groups = res2.groups;
this._makeCounter();
this.refreshCounter(res2.treeData)