mirror of https://github.com/jumpserver/jumpserver
fix: 修复系统设置中关闭magnus 和razor 不生效 (#9563)
* fix: 修复系统设置中关闭magnus 和razor 不生效 * perf: 优化代码 --------- Co-authored-by: Aaron3S <chenyang@fit2cloud.com>pull/9567/head
parent
3d7428e828
commit
1ec20a8f98
|
@ -18,7 +18,7 @@ class ConnectMethodListApi(generics.ListAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
os = get_request_os(self.request)
|
os = get_request_os(self.request)
|
||||||
return ConnectMethodUtil.get_protocols_connect_methods(os)
|
return ConnectMethodUtil.get_filtered_protocols_connect_methods(os)
|
||||||
|
|
||||||
def list(self, request, *args, **kwargs):
|
def list(self, request, *args, **kwargs):
|
||||||
queryset = self.get_queryset()
|
queryset = self.get_queryset()
|
||||||
|
|
|
@ -211,6 +211,22 @@ class ConnectMethodUtil:
|
||||||
def refresh_methods(cls):
|
def refresh_methods(cls):
|
||||||
cls._all_methods = None
|
cls._all_methods = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_filtered_protocols_connect_methods(cls, os):
|
||||||
|
methods = dict(cls.get_protocols_connect_methods(os))
|
||||||
|
component_setting = {
|
||||||
|
'razor': 'TERMINAL_RAZOR_ENABLED',
|
||||||
|
'magnus': 'TERMINAL_MAGNUS_ENABLED',
|
||||||
|
}
|
||||||
|
disabled_component = [comp for comp, attr in component_setting.items() if not getattr(settings, attr)]
|
||||||
|
if not disabled_component:
|
||||||
|
return methods
|
||||||
|
|
||||||
|
for protocol, ms in methods.items():
|
||||||
|
filtered_methods = [m for m in ms if m['component'] not in disabled_component]
|
||||||
|
methods[protocol] = filtered_methods
|
||||||
|
return methods
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_protocols_connect_methods(cls, os):
|
def get_protocols_connect_methods(cls, os):
|
||||||
if cls._all_methods is not None:
|
if cls._all_methods is not None:
|
||||||
|
|
Loading…
Reference in New Issue