diff --git a/spug_api/apps/host/group.py b/spug_api/apps/host/group.py
index 5bf93ba..591f791 100644
--- a/spug_api/apps/host/group.py
+++ b/spug_api/apps/host/group.py
@@ -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)
diff --git a/spug_web/src/pages/host/Form.js b/spug_web/src/pages/host/Form.js
index 01c9851..06a3a9d 100644
--- a/spug_web/src/pages/host/Form.js
+++ b/spug_web/src/pages/host/Form.js
@@ -145,7 +145,7 @@ export default observer(function () {
-
+
diff --git a/spug_web/src/pages/host/Group.js b/spug_web/src/pages/host/Group.js
index 413d9ab..39ed96b 100644
--- a/spug_web/src/pages/host/Group.js
+++ b/spug_web/src/pages/host/Group.js
@@ -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="浏览"/>
+
)}>
v || setVisible(v)}>
+ {store.records && store.treeData.length === 0 && (
+ 你还没有可访问的主机分组,请联系管理员分配主机权限。
+ )}
)
})
diff --git a/spug_web/src/pages/host/store.js b/spug_web/src/pages/host/store.js
index 9668e61..50394a1 100644
--- a/spug_web/src/pages/host/store.js
+++ b/spug_web/src/pages/host/store.js
@@ -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)