Commit ca56fd97 authored by ibuler's avatar ibuler

Merge branch 'dev' of github.com:jumpserver/coco into dev

parents a2c6f101 9abb0b35
......@@ -318,6 +318,7 @@ default_config = {
'REPLAY_STORAGE': {'TYPE': 'server'},
'LANGUAGE_CODE': 'zh',
'SECURITY_MAX_IDLE_TIME': 60,
'ASSET_LIST_PAGE_SIZE': 'auto',
}
config = Config(root_path, default_config)
......
......@@ -24,6 +24,7 @@ PAGE_DOWN = 'down'
PAGE_UP = 'up'
BACK = 'back'
PROXY = 'proxy'
PAGE_SIZE_ALL = 100000000
class InteractiveServer:
......@@ -47,7 +48,14 @@ class InteractiveServer:
@property
def page_size(self):
_page_size = config['ASSET_LIST_PAGE_SIZE']
if _page_size.isdigit():
return int(_page_size)
elif _page_size == 'auto':
return self.client.request.meta['height'] - 8
else:
return PAGE_SIZE_ALL
@property
def search_result(self):
......@@ -58,10 +66,6 @@ class InteractiveServer:
@search_result.setter
def search_result(self, value):
if not value:
self._search_result = value
return
value = self.filter_system_users(value)
self._search_result = value
def display_logo(self):
......@@ -122,6 +126,7 @@ class InteractiveServer:
def search_assets(self, q):
if not self.finish:
assets = app_service.get_search_user_granted_assets(self.client.user, q)
assets = self.filter_system_users(assets)
return assets
assets = self.assets_list
result = []
......@@ -194,7 +199,7 @@ class InteractiveServer:
self.display_nodes_tree()
return
assets = self.nodes[_id - 1].assets_granted
assets = self.nodes[_id-1].assets_granted
self.display_result_paging(assets)
def display_search_result(self):
......@@ -234,6 +239,7 @@ class InteractiveServer:
def get_user_nodes(self):
self.nodes = app_service.get_user_asset_groups(self.client.user)
self.filter_nodes_assets_system_user()
self.sort_nodes()
self.construct_nodes_tree()
......@@ -265,6 +271,10 @@ class InteractiveServer:
asset.system_users_granted = system_users_cleaned
return assets
def filter_nodes_assets_system_user(self):
for node in self.nodes:
node.assets_granted = self.filter_system_users(node.assets_granted)
def get_user_assets_paging(self):
while not self.closed:
assets, total = app_service.get_user_assets_paging(
......@@ -278,6 +288,7 @@ class InteractiveServer:
if not self.total_assets:
self.total_assets = total
self.total_count = total
assets = self.filter_system_users(assets)
self.assets_list.extend(assets)
self.offset += self.limit
......@@ -393,6 +404,9 @@ class InteractiveServer:
page -= 1
left -= self.page_size
else:
if self.page_size == PAGE_SIZE_ALL:
# 如果全部显示左下标不做修改
continue
# PAGE_DOWN
page += 1
left += len(result)
......
......@@ -360,6 +360,11 @@ class TelnetServer(BaseServer):
self.system_user = system_user
super(TelnetServer, self).__init__(chan=sock)
@property
def closed(self):
""" self.chan: socket object """
return getattr(self.chan, '_closed', False)
class Server(BaseServer):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment