A web终端支持搜索 ip

pull/462/head
vapao 2022-02-18 21:29:07 +08:00
parent 02d9563367
commit ee58ee1845
2 changed files with 2 additions and 2 deletions

View File

@ -93,7 +93,7 @@ class Group(models.Model, ModelMixin):
response = dict(key=self.id, value=self.id, title=self.name, children=[]) response = dict(key=self.id, value=self.id, title=self.name, children=[])
if with_hosts: if with_hosts:
def make_item(x): def make_item(x):
return dict(title=x.name, key=f'{self.id}_{x.id}', id=x.id, isLeaf=True) return dict(title=x.name, hostname=x.hostname, key=f'{self.id}_{x.id}', id=x.id, isLeaf=True)
response['children'] = [make_item(x) for x in self.hosts.all()] response['children'] = [make_item(x) for x in self.hosts.all()]
return response return response

View File

@ -37,7 +37,7 @@ function WebSSH(props) {
useEffect(() => { useEffect(() => {
if (searchValue) { if (searchValue) {
const newTreeData = rawHostList.filter(x => includes(x.title, searchValue)) const newTreeData = rawHostList.filter(x => includes([x.title, x.hostname], searchValue))
setTreeData(newTreeData) setTreeData(newTreeData)
} else { } else {
setTreeData(rawTreeData) setTreeData(rawTreeData)