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 = { ...@@ -318,6 +318,7 @@ default_config = {
'REPLAY_STORAGE': {'TYPE': 'server'}, 'REPLAY_STORAGE': {'TYPE': 'server'},
'LANGUAGE_CODE': 'zh', 'LANGUAGE_CODE': 'zh',
'SECURITY_MAX_IDLE_TIME': 60, 'SECURITY_MAX_IDLE_TIME': 60,
'ASSET_LIST_PAGE_SIZE': 'auto',
} }
config = Config(root_path, default_config) config = Config(root_path, default_config)
......
...@@ -24,6 +24,7 @@ PAGE_DOWN = 'down' ...@@ -24,6 +24,7 @@ PAGE_DOWN = 'down'
PAGE_UP = 'up' PAGE_UP = 'up'
BACK = 'back' BACK = 'back'
PROXY = 'proxy' PROXY = 'proxy'
PAGE_SIZE_ALL = 100000000
class InteractiveServer: class InteractiveServer:
...@@ -47,7 +48,14 @@ class InteractiveServer: ...@@ -47,7 +48,14 @@ class InteractiveServer:
@property @property
def page_size(self): def page_size(self):
return self.client.request.meta['height'] - 8 _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 @property
def search_result(self): def search_result(self):
...@@ -58,10 +66,6 @@ class InteractiveServer: ...@@ -58,10 +66,6 @@ class InteractiveServer:
@search_result.setter @search_result.setter
def search_result(self, value): def search_result(self, value):
if not value:
self._search_result = value
return
value = self.filter_system_users(value)
self._search_result = value self._search_result = value
def display_logo(self): def display_logo(self):
...@@ -122,6 +126,7 @@ class InteractiveServer: ...@@ -122,6 +126,7 @@ class InteractiveServer:
def search_assets(self, q): def search_assets(self, q):
if not self.finish: if not self.finish:
assets = app_service.get_search_user_granted_assets(self.client.user, q) assets = app_service.get_search_user_granted_assets(self.client.user, q)
assets = self.filter_system_users(assets)
return assets return assets
assets = self.assets_list assets = self.assets_list
result = [] result = []
...@@ -194,7 +199,7 @@ class InteractiveServer: ...@@ -194,7 +199,7 @@ class InteractiveServer:
self.display_nodes_tree() self.display_nodes_tree()
return return
assets = self.nodes[_id - 1].assets_granted assets = self.nodes[_id-1].assets_granted
self.display_result_paging(assets) self.display_result_paging(assets)
def display_search_result(self): def display_search_result(self):
...@@ -234,6 +239,7 @@ class InteractiveServer: ...@@ -234,6 +239,7 @@ class InteractiveServer:
def get_user_nodes(self): def get_user_nodes(self):
self.nodes = app_service.get_user_asset_groups(self.client.user) self.nodes = app_service.get_user_asset_groups(self.client.user)
self.filter_nodes_assets_system_user()
self.sort_nodes() self.sort_nodes()
self.construct_nodes_tree() self.construct_nodes_tree()
...@@ -265,6 +271,10 @@ class InteractiveServer: ...@@ -265,6 +271,10 @@ class InteractiveServer:
asset.system_users_granted = system_users_cleaned asset.system_users_granted = system_users_cleaned
return assets 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): def get_user_assets_paging(self):
while not self.closed: while not self.closed:
assets, total = app_service.get_user_assets_paging( assets, total = app_service.get_user_assets_paging(
...@@ -278,6 +288,7 @@ class InteractiveServer: ...@@ -278,6 +288,7 @@ class InteractiveServer:
if not self.total_assets: if not self.total_assets:
self.total_assets = total self.total_assets = total
self.total_count = total self.total_count = total
assets = self.filter_system_users(assets)
self.assets_list.extend(assets) self.assets_list.extend(assets)
self.offset += self.limit self.offset += self.limit
...@@ -393,6 +404,9 @@ class InteractiveServer: ...@@ -393,6 +404,9 @@ class InteractiveServer:
page -= 1 page -= 1
left -= self.page_size left -= self.page_size
else: else:
if self.page_size == PAGE_SIZE_ALL:
# 如果全部显示左下标不做修改
continue
# PAGE_DOWN # PAGE_DOWN
page += 1 page += 1
left += len(result) left += len(result)
......
...@@ -360,6 +360,11 @@ class TelnetServer(BaseServer): ...@@ -360,6 +360,11 @@ class TelnetServer(BaseServer):
self.system_user = system_user self.system_user = system_user
super(TelnetServer, self).__init__(chan=sock) super(TelnetServer, self).__init__(chan=sock)
@property
def closed(self):
""" self.chan: socket object """
return getattr(self.chan, '_closed', False)
class Server(BaseServer): 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