Unverified Commit 1cc8c3e6 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #50 from jumpserver/dev

Dev
parents 2ba57398 3c619311
......@@ -50,8 +50,11 @@
"document": "文档",
"support": "商业支持",
"speed": "速度",
"File Manager": "文件管理",
"File": "文件管理",
"New Connection": "连接",
"Connect": "连接"
"file manager": "文件管理",
"file": "文件管理",
"new connection": "连接",
"connect": "连接",
"rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率",
"select a solution": "选择分辨率"
}
......@@ -51,6 +51,10 @@
"support": "商业支持",
"speed": "速度",
"file manager": "文件管理",
"file": "文件管理",
"new connection": "连接",
"connect": "连接"
"connect": "连接",
"rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率",
"select a solution": "选择分辨率"
}
......@@ -50,8 +50,11 @@
"document": "文档",
"support": "商业支持",
"speed": "速度",
"File Manager": "文件管理",
"File": "文件管理",
"New Connection": "连接",
"Connect": "连接"
"file manager": "文件管理",
"file": "文件管理",
"new connection": "连接",
"connect": "连接",
"rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率",
"select a solution": "选择分辨率"
}
......@@ -41,8 +41,138 @@ app = Flask(__name__, template_folder='dist')
socketio = None
nodes = [{"id":"03059e2e-06b8-4ef1-b949-72e230b706fa","key":"0:9:5","name":"部门1","value":"部门1","parent":"ea4688ef-2b65-40cd-944d-5fca39e34f42","assets_granted":[{"id":"ad594b10-9f64-4913-b7b1-135fe63561d1","hostname":"ali-windows","ip":"47.104.243.139","port":3389,"system_users_granted":[{"id":"8763b81a-bb5e-484a-abca-10514c7bb185","name":"组织1-部门1-Administrator","username":"administrator","priority":10,"protocol":"rdp","comment":"windows 服务器而已"}],"is_active":True,"system_users_join":"administrator","os":None,"domain":None,"platform":"Windows","comment":"只是个windows而已"},{"id":"d9020939-1dd7-4b18-9165-5124f20d1f77","hostname":"newwindows","ip":"10.1.10.114","port":3389,"system_users_granted":[{"id":"46b57293-c662-46f9-8bc4-dcf64f01bedc","name":"newwindows","username":"administrator","priority":10,"protocol":"rdp","comment":"只是个windows而已"},{"id":"8763b81a-bb5e-484a-abca-10514c7bb185","name":"组织1-部门1-Administrator","username":"administrator","priority":10,"protocol":"rdp","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"administrator, administrator","os":None,"domain":None,"platform":"Windows","comment":"只是个windows而已"},{"id":"9ef36bb3-1bed-455f-be09-3770d3f4bf97","hostname":"test-vm1","ip":"172.19.185.6","port":22,"system_users_granted":[{"id":"7e326f71-aee5-4688-8cc1-717919470a09","name":"root","username":"root","priority":10,"protocol":"ssh","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"root","os":None,"domain":None,"platform":"Linux","comment":"只是个windows而已"},{"id":"1600ed6d-e3b6-434c-a960-c5bb818806b6","hostname":"windows1","ip":"10.1.10.178","port":3389,"system_users_granted":[{"id":"413ea1d2-ef73-4a90-bae3-571ac1b39d93","name":"2012-test-no-passwd-rdp","username":"administrator","priority":10,"protocol":"rdp","comment":"只是个windows而已"},{"id":"46b57293-c662-46f9-8bc4-dcf64f01bedc","name":"newwindows","username":"administrator","priority":10,"protocol":"rdp","comment":"只是个windows而已"},{"id":"8763b81a-bb5e-484a-abca-10514c7bb185","name":"组织1-部门1-Administrator","username":"administrator","priority":10,"protocol":"rdp","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"administrator, administrator, administrator","os":None,"domain":None,"platform":"Windows","comment":"只是个windows而已"},{"id":"27e50edc-52d9-41ef-8c9e-1bff9d1628b2","hostname":"test-vm2","ip":"172.19.185.7","port":22,"system_users_granted":[{"id":"7e326f71-aee5-4688-8cc1-717919470a09","name":"root","username":"root","priority":10,"protocol":"ssh","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"root","os":None,"domain":None,"platform":"Linux","comment":"只是个windows而已"},{"id":"b6f16269-d02a-4055-9cd8-460fa10b1540","hostname":"test-vm3","ip":"172.19.185.8","port":22,"system_users_granted":[{"id":"7e326f71-aee5-4688-8cc1-717919470a09","name":"root","username":"root","priority":10,"protocol":"ssh","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"root","os":None,"domain":None,"platform":"Linux","comment":"只是个windows而已"},{"id":"b952a481-a624-467e-b97f-9435155f0d53","hostname":"testserver","ip":"10.1.10.192","port":22,"system_users_granted":[{"id":"7e326f71-aee5-4688-8cc1-717919470a09","name":"root","username":"root","priority":10,"protocol":"ssh","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"root","os":"CentOS","domain":"8789580f-b5ca-4478-b6d3-d0dafc4c48e8","platform":"Linux","comment":"只是个windows而已"},{"id":"969247e0-3796-4090-9aa6-3248560079e6","hostname":"test01","ip":"123.123.123.1","port":22,"system_users_granted":[{"id":"7e326f71-aee5-4688-8cc1-717919470a09","name":"root","username":"root","priority":10,"protocol":"ssh","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"root","os":None,"domain":None,"platform":"Linux","comment":"只是个windows而已"},{"id":"7e8451cb-8eb7-4c9d-b652-961a6fdce3c4","hostname":"wz-test","ip":"54.222.180.235","port":22,"system_users_granted":[{"id":"7e326f71-aee5-4688-8cc1-717919470a09","name":"root","username":"root","priority":10,"protocol":"ssh","comment":"只是个windows而已"}],"is_active":True,"system_users_join":"root","os":"RedHat","domain":None,"platform":"Linux","comment":"只是个windows而已"}],"assets_amount":9}]
nodes = [{'id': '6353b2d3-54f1-4354-bede-fe8d8eebfe0c',
'key': '4',
'name': '开发部',
'value': '开发部',
'parent': '6353b2d3-54f1-4354-bede-fe8d8eebfe0c',
'assets_granted': [{'id': '9e911ac3-7231-441b-9123-e1945e93c0b0',
'hostname': 'Test-48',
'ip': '172.15.1.48',
'port': 22,
'system_users_granted': [{'id': '859274bb-dc6e-4890-87dc-eefddf0ea8c1',
'name': '111',
'username': '1',
'priority': 20,
'protocol': 'ssh',
'comment': '',
'login_mode': 'auto'}],
'is_active': True,
'system_users_join': '1',
'os': None,
'domain': None,
'platform': 'Linux',
'comment': '',
'protocol': 'ssh',
'org_id': 'e338bd97-bdb1-47b1-95f7-4994776488b5',
'org_name': '开发部'}],
'assets_amount': 1,
'org_id': 'e338bd97-bdb1-47b1-95f7-4994776488b5'},
{'id': 'cd3c1d48-4bf0-43e1-bca1-0817a1295e22',
'key': '5:23:0:1',
'name': '新节点 2',
'value': '新节点 2',
'parent': 'a3852030-eeb5-4c0f-ba57-32cce42c8333',
'assets_granted': [{'id': '9590ebfa-5720-461d-835f-fecfe6245c67',
'hostname': 'Test-48',
'ip': '172.15.1.48',
'port': 22,
'system_users_granted': [{'id': 'e2b1900f-b0e6-4813-b90a-7216d670a1cd',
'name': 'test_SSH',
'username': 'test',
'priority': 10,
'protocol': 'ssh',
'comment': '',
'login_mode': 'auto'}],
'is_active': True,
'system_users_join': 'test',
'os': None,
'domain': None,
'platform': 'Linux',
'comment': '',
'protocol': 'ssh',
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248',
'org_name': '测试部'}],
'assets_amount': 1,
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248'},
{'id': 'a3852030-eeb5-4c0f-ba57-32cce42c8333',
'key': '5:23:0',
'name': '新节点 1',
'value': '新节点 1',
'parent': '39c0f461-e9c2-4ef5-926d-3308ae9c43d8',
'assets_granted': [],
'assets_amount': 0,
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248'},
{'id': '39c0f461-e9c2-4ef5-926d-3308ae9c43d8',
'key': '5:23',
'name': 'hbase',
'value': 'hbase',
'parent': 'd49f0fb2-ad3e-4f13-835f-12c13329f3be',
'assets_granted': [],
'assets_amount': 0,
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248'},
{'id': 'd49f0fb2-ad3e-4f13-835f-12c13329f3be',
'key': '5',
'name': '测试部',
'value': '测试部',
'parent': 'd49f0fb2-ad3e-4f13-835f-12c13329f3be',
'assets_granted': [],
'assets_amount': 0,
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248'},
{'id': 'c10cb68a-816d-4030-9a7b-e9a22a83818a',
'key': '5:12',
'name': '测试资产666',
'value': '测试资产666',
'parent': 'd49f0fb2-ad3e-4f13-835f-12c13329f3be',
'assets_granted': [{'id': '9590ebfa-5720-461d-835f-fecfe6245c67',
'hostname': 'Test-48',
'ip': '172.15.1.48',
'port': 22,
'system_users_granted': [{'id': 'e2b1900f-b0e6-4813-b90a-7216d670a1cd',
'name': 'test_SSH',
'username': 'test',
'priority': 10,
'protocol': 'ssh',
'comment': '',
'login_mode': 'auto'}],
'is_active': True,
'system_users_join': 'test',
'os': None,
'domain': None,
'platform': 'Linux',
'comment': '',
'protocol': 'ssh',
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248',
'org_name': '测试部'}],
'assets_amount': 1,
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248'},
{'id': 'c57099a1-f1fc-48d2-9d0c-611ed65560b2',
'key': '5:3',
'name': '测试资产265465',
'value': '测试资产265465',
'parent': 'd49f0fb2-ad3e-4f13-835f-12c13329f3be',
'assets_granted': [{'id': '965e86b1-b09a-4c1e-8b6c-784803fdeeaf',
'hostname': 'Test01-22',
'ip': '172.15.2.22',
'port': 22,
'system_users_granted': [{'id': 'e2b1900f-b0e6-4813-b90a-7216d670a1cd',
'name': 'test_SSH',
'username': 'test',
'priority': 10,
'protocol': 'ssh',
'comment': '',
'login_mode': 'auto'}],
'is_active': True,
'system_users_join': 'test',
'os': None,
'domain': None,
'platform': 'Linux',
'comment': '',
'protocol': 'ssh',
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248',
'org_name': '测试部'}],
'assets_amount': 1,
'org_id': '8eb2637c-e14f-41f1-b1b1-00a2dfa20248'}]
class ProxyServer:
def __init__(self, client, asset, system_user):
......@@ -169,776 +299,7 @@ def get_session_replay(pk):
@app.route('/api/perms/v1/user/nodes/children/')
def get_nodes_children():
data1 = [
{
"id": "3e1930e1-759d-430e-8935-fbd563463373",
"key": "0:3",
"value": "Node 2",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:3",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "508e8674-0c51-471c-98b5-13f0612c6aba",
"key": "0",
"value": "ROOT",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0",
"tree_parent": "",
"assets_amount": 9
},
{
"id": "52b8aa5e-5e5e-4721-a749-2f4f4655ae35",
"key": "0:0",
"value": "新节点 1",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "5904ae0e-bf06-447d-a963-c89369295d5a",
"key": "0:4",
"value": "Node 4",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:4",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "60daaa36-92ac-4d0f-b59e-f7f153ecc302",
"key": "0:1",
"value": "新节点 2",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:1",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "8e8999f3-9093-4218-af12-cc126a15cb94",
"key": "0:5",
"value": "Node 5",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:5",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "a5a2d42e-7b6d-4e45-905a-74a0bd8c2266",
"key": "0:7",
"value": "Node 37",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:7",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "b8dd922e-fac0-4f15-b70a-01263203002d",
"key": "0:2",
"value": "Node 0",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:2",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "e16c04d3-84a5-4b6d-8f10-ccb195729035",
"key": "0:6",
"value": "Node 15",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:6",
"tree_parent": "0",
"assets_amount": 9
},
{
"id": "051142d0-9090-44f7-aa9d-d8a563cc04d4",
"key": "0:0",
"value": "lillian64",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "12a542c1-f787-485e-ac46-de6421c93d2d",
"key": "0:0",
"value": "sandra76",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "2cba1640-6e7e-470a-9da7-2f736b4d0aa5",
"key": "0:0",
"value": "wanda88",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "58839e9c-5649-4e00-8e77-073b800091ff",
"key": "0:0",
"value": "mildred87",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "64ce5de9-18df-40a8-b663-8c6515e37e42",
"key": "0:0",
"value": "jessica82",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "72e26e8c-2146-49ad-8803-1c95e47d4447",
"key": "0:0",
"value": "paula79",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "aa7bb5e1-57ba-4c68-933c-aa2bc9204880",
"key": "0:0",
"value": "patricia77",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "ced63974-9ade-4081-b0ba-2befc55ea380",
"key": "0:0",
"value": "irene94",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
},
{
"id": "db152e40-8a49-4206-bea8-d05cf0cda50d",
"key": "0:0",
"value": "karen77",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:0",
"tree_parent": "0",
"assets_amount": 0
}
]
data2 = [
{
"id": "02db2050-882f-4f42-8af5-cbb2b3262f88",
"key": "0:3:3",
"value": "Node 42",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:3:3",
"tree_parent": "0:3",
"assets_amount": 27
},
{
"id": "3e1930e1-759d-430e-8935-fbd563463373",
"key": "0:3",
"value": "Node 2",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:3",
"tree_parent": "0",
"assets_amount": 27
},
{
"id": "77963655-c559-4cad-8534-a1f7e20efb61",
"key": "0:3:1",
"value": "Node 18",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:3:1",
"tree_parent": "0:3",
"assets_amount": 27
},
{
"id": "950453cd-3e1d-4d89-addc-3fa77e34e7a9",
"key": "0:3:2",
"value": "Node 28",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:3:2",
"tree_parent": "0:3",
"assets_amount": 27
},
{
"id": "e24377ec-f63e-4dd0-970b-c047ad40b3f2",
"key": "0:3:0",
"value": "Node 8",
"system_users_granted": [],
"is_node": True,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 27
},
{
"id": "00671d2e-0e45-43b8-8765-8a677676aed0",
"key": "0:3:0",
"value": "robin65",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "1495d4f8-882c-48c1-a9f4-2369f0f0ea09",
"key": "0:3:0",
"value": "phyllis94",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "1a2f4ff7-76c6-4ff2-b1dc-c81b5979ff1b",
"key": "0:3:0",
"value": "pamela84",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "1d302510-4860-437b-a3cc-f7b6a883fb87",
"key": "0:3:0",
"value": "janet89",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "40f059b2-1acf-4f16-ab7c-32403d38260a",
"key": "0:3:0",
"value": "susan63",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "52f7aba9-56a0-4af2-ad77-bf4807092123",
"key": "0:3:0",
"value": "brenda64",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "53f16504-8add-4bef-8125-f87abf52d3cc",
"key": "0:3:0",
"value": "marilyn74",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "7c17089b-67d1-43c8-8f5e-d213bde59ef1",
"key": "0:3:0",
"value": "betty90",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "80478c9a-0e7f-4d50-b94c-c7f0fd40f5b2",
"key": "0:3:0",
"value": "lisa94",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "82e8d997-923a-4fc2-8358-0c02626ecc8f",
"key": "0:3:0",
"value": "carolyn87",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "8943134f-9f3d-4731-89ad-61bd1d0b068b",
"key": "0:3:0",
"value": "ann66",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "8d7dadcf-5f09-4c7d-971b-e65413378ee1",
"key": "0:3:0",
"value": "norma78",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "8da3e293-a487-4018-87b7-3bef2405fd03",
"key": "0:3:0",
"value": "susan80",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "93326d6c-06e1-4630-8c36-3505492cfefb",
"key": "0:3:0",
"value": "janet93",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "93a0ece4-b582-425b-9103-0156eaf49f22",
"key": "0:3:0",
"value": "louise77",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "9cb0af28-ca60-4e4e-983f-bd5069579264",
"key": "0:3:0",
"value": "wanda79",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "b45f40b9-0607-42a0-9643-0e8f71a6b33d",
"key": "0:3:0",
"value": "kathryn73",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "c0ccd5d2-d6cb-49e1-ad27-6368289f407e",
"key": "0:3:0",
"value": "mildred89",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "d042c10a-a117-4ef1-96ad-e97b84c59517",
"key": "0:3:0",
"value": "patricia92",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "d0901a25-d233-4466-8f92-e6cbb069a765",
"key": "0:3:0",
"value": "joyce90",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "d621bca0-a6e8-4c95-bf93-e822faf42b0a",
"key": "0:3:0",
"value": "julia74",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "db17f755-e977-4d71-ab79-96e359b6fc76",
"key": "0:3:0",
"value": "betty78",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "db20e2d8-7f97-4d91-8c87-5a51772bcea8",
"key": "0:3:0",
"value": "kathryn74",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "df112a11-b1b6-41f9-bb58-d3a14ec2cfad",
"key": "0:3:0",
"value": "lois88",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "e1ab8523-1b35-4d07-8acd-082ca33f03b9",
"key": "0:3:0",
"value": "jennifer93",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "f3bef5a9-fb9d-4ead-be0b-a1d5f300d6a7",
"key": "0:3:0",
"value": "jacqueline83",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
},
{
"id": "f5488aac-a474-42c3-b321-a872f2d1826d",
"key": "0:3:0",
"value": "cheryl92",
"system_users_granted": [
{
"id": "f78cfcb2-d473-43b6-a72a-8cc18979aabd",
"name": "web",
"username": "web"
}
],
"is_node": False,
"org_id": "",
"tree_id": "0:3:0",
"tree_parent": "0:3",
"assets_amount": 0
}
]
data1 = nodes
if request.args.get('id'):
return jsonify(data2)
else:
......
{
"/api/perms/v1/user/nodes/children/": {
"target": "http://127.0.0.1:8080",
"secure": false
},
"/api": {
"target": "http://127.0.0.1:5001",
"secure": false
......
......@@ -26,7 +26,7 @@ import {MAT_LABEL_GLOBAL_OPTIONS} from '@angular/material';
import {Pipes} from './pipes/pipes';
import {PagesComponents} from './pages/pages.component';
import {ElementComponents} from './elements/elements.component';
import {ChangLanWarningDialogComponent} from './elements/nav/nav.component';
import {ChangLanWarningDialogComponent, RDPSolutionDialogComponent} from './elements/nav/nav.component';
import {DialogService, ElementDialogAlertComponent} from './elements/dialog/dialog.service';
import {PluginModules} from './plugins/plugins';
import {TestPageComponent} from './test-page/test-page.component';
......@@ -55,6 +55,7 @@ import {SftpComponent} from './elements/sftp/sftp.component';
AssetTreeDialogComponent,
ElementDialogAlertComponent,
ChangLanWarningDialogComponent,
RDPSolutionDialogComponent,
],
bootstrap: [AppComponent],
providers: [
......
......@@ -14,7 +14,7 @@ import {DataStore, User, Browser, i18n} from './globals';
import {environment} from '../environments/environment';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import {NGXLogger} from 'ngx-logger';
import {HostGroup} from './pages/control/cleftbar/cleftbar.component';
import {HostGroup, Node} from './pages/control/cleftbar/cleftbar.component';
import * as UUID from 'uuid-js/lib/uuid.js';
declare function unescape(s: string): string;
......@@ -66,8 +66,8 @@ export class HttpService {
return this.http.get('/api/users/v1/profile/');
}
get_my_asset_groups_assets() {
return this.http.get<Array<HostGroup>>('/api/perms/v1/user/nodes-assets/');
get_my_granted_nodes() {
return this.http.get<Array<Node>>('/api/perms/v1/user/nodes-assets/tree/');
}
get_guacamole_token(user_id: string, authToken: string) {
......@@ -89,11 +89,18 @@ export class HttpService {
}
guacamole_add_asset(user_id: string, asset_id: string, system_user_id: string) {
const params = new HttpParams()
let params = new HttpParams()
.set('user_id', user_id)
.set('asset_id', asset_id)
.set('system_user_id', system_user_id)
.set('token', DataStore.guacamole_token);
const solution = localStorage.getItem('rdpSolution') || 'Auto';
if (solution !== 'Auto') {
const width = solution.split('x')[0];
const height = solution.split('x')[1];
params = params.set('width', width).set('height', height);
}
return this.http.get(
'/guacamole/api/session/ext/jumpserver/asset/add',
{
......@@ -104,9 +111,15 @@ export class HttpService {
}
guacamole_token_add_asset(assetToken: string, token: string) {
const params = new HttpParams()
let params = new HttpParams()
.set('asset_token', assetToken)
.set('token', token);
const solution = localStorage.getItem('rdpSolution') || 'Auto';
if (solution !== 'Auto') {
const width = solution.split('x')[0];
const height = solution.split('x')[1];
params = params.set('width', width).set('height', height);
}
return this.http.get(
'/guacamole/api/ext/jumpserver/asset/token/add',
{
......
......@@ -33,25 +33,25 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
},
callback: {
onClick: this.onCzTreeOnClick.bind(this),
onRightClick: this.onRightClick.bind(this),
onAsyncSuccess: this.onzTreeAsyncSuccess.bind(this)
onRightClick: this.onRightClick.bind(this)
},
async: {
enable: true,
url: '/api/perms/v1/user/nodes/children/',
autoParam: ['node_id=id', 'name=n', 'level=lv'],
type: 'get',
dataFilter: this.nodeFilter
}
};
pos = {left: '100px', top: '200px'};
hiddenNodes: any;
expandNodes: any;
zTree: any;
searching = false;
isShowRMenu = false;
rightClickSelectNode: any;
onCzTreeOnClick(event, treeId, treeNode, clickFlag) {
if (treeNode.isParent) {
const zTreeObj = $.fn.zTree.getZTreeObj('ztree');
zTreeObj.expandNode(treeNode);
} else {
this.Connect(treeNode);
}
}
constructor(private _appService: AppService,
public _dialog: MatDialog,
public _logger: LogService) {
......@@ -67,7 +67,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
.debounceTime(300)
.distinctUntilChanged()
.subscribe((n) => {
this.searchNode();
this.filter();
});
}
......@@ -80,53 +80,9 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
}
nodeFilter(treeId, parentNode, childNodes) {
$.each(childNodes, function (index, value) {
value['node_id'] = value['id'];
value['id'] = value['tree_id'];
if (value['tree_id'] !== value['tree_parent']) {
value['pId'] = value['tree_parent'];
} else {
value['isParent'] = true;
}
value['name'] = value['value'];
if (!value['is_node']) {
const platform = value['asset']['platform'].toLowerCase().indexOf('win') === 0 ? 'windows' : 'linux';
value['title'] = value['asset']['ip'] || value['name'];
value['iconSkin'] = platform;
}
value['isParent'] = value['is_node'];
});
return childNodes;
}
onzTreeAsyncSuccess(event, treeId, treeNode, msg) {
// 代表第一次加载
if (!treeNode) {
this.zTree = $.fn.zTree.getZTreeObj(treeId);
if (this.searching) {
this.zTree.expandAll(true);
} else {
const root = this.zTree.getNodes()[0];
this.zTree.expandNode(root, true);
}
}
}
onCzTreeOnClick(event, treeId, treeNode, clickFlag) {
if (treeNode.isParent) {
const zTreeObj = $.fn.zTree.getZTreeObj('ztree');
zTreeObj.expandNode(treeNode);
} else {
this.Connect(treeNode.asset);
}
}
draw() {
$.fn.zTree.init($('#ztree'), this.setting, this.nodes);
// this.zTree = $.fn.zTree.getZTreeObj('ztree');
// const root = this.zTree.getNodes()[0];
// this.zTree.expandNode(root, true);
$.fn.zTree.init($('#ztree'), this.setting, this.Data);
this.zTree = $.fn.zTree.getZTreeObj('ztree');
}
showRMenu(left, top) {
......@@ -140,9 +96,13 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
onRightClick(event, treeId, treeNode) {
if (!treeNode || treeNode.isParent || treeNode.asset.platform.toLowerCase() === 'windows') {
if (!treeNode || treeNode.isParent ) {
return null;
}
const host = treeNode.meta.asset;
if (host.protocol.toLowerCase() === 'rdp') {
alert('Windows 请使用Ctrl+Shift+Alt呼出侧边栏上传下载');
}
if (!treeNode && event.target.tagName.toLowerCase() !== 'button' && $(event.target).parents('a').length === 0) {
this.zTree.cancelSelectedNode();
this.showRMenu(event.clientX, event.clientY);
......@@ -153,22 +113,24 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
}
Connect(host) {
Connect(node) {
const system_users = node.meta.system_users;
const host = node.meta.asset;
let user: any;
if (host.system_users_granted.length > 1) {
user = this.checkPriority(host.system_users_granted);
if (system_users.length > 1) {
user = this.checkPriority(system_users);
if (user) {
this.login(host, user);
} else {
const dialogRef = this._dialog.open(AssetTreeDialogComponent, {
height: '200px',
width: '300px',
data: {users: host.system_users_granted}
data: {users: system_users}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
for (const i of host.system_users_granted) {
for (const i of system_users) {
if (i.id.toString() === result.toString()) {
user = i;
break;
......@@ -178,8 +140,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
});
}
} else if (host.system_users_granted.length === 1) {
user = host.system_users_granted[0];
} else if (system_users.length === 1) {
user = system_users[0];
this.login(host, user);
} else {
alert('该主机没有授权登录用户');
......@@ -187,7 +149,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
connectFileManager() {
const host = this.rightClickSelectNode.asset;
const host = this.rightClickSelectNode.meta.asset;
const id = NavList.List.length - 1;
if (host) {
NavList.List[id].nick = '[FILE]' + host.hostname;
......@@ -209,6 +171,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
login(host, user) {
const id = NavList.List.length - 1;
this._logger.debug(NavList);
this._logger.debug(host);
if (user) {
NavList.List[id].nick = host.hostname;
NavList.List[id].connected = true;
......@@ -241,25 +205,78 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
return user;
}
searchNode() {
recurseParent(node) {
const parentNode = node.getParentNode();
if (parentNode && parentNode.pId) {
return [parentNode, ...this.recurseParent(parentNode)];
} else if (parentNode) {
return [parentNode];
} else {
return [];
}
}
recurseChildren(node) {
if (!node.isParent) {
return [];
}
const children = node.children;
if (!children) {
return [];
}
let all_children = [];
children.forEach((n) => {
all_children = [...children, ...this.recurseChildren(n)];
});
return all_children;
}
filter() {
const zTreeObj = $.fn.zTree.getZTreeObj('ztree');
if (!zTreeObj) {
return null;
}
const _keywords = this.query;
const nodes = zTreeObj.transformToArray(zTreeObj.getNodes());
if (!_keywords) {
// 第一次刷新
if (!this.searching) {
return null;
if (this.hiddenNodes) {
zTreeObj.showNodes(this.hiddenNodes);
this.hiddenNodes = null;
}
// 以后搜索后回来
this.searching = false;
zTreeObj.setting.async.url = '/api/perms/v1/user/nodes/children/';
} else {
this.searching = true;
zTreeObj.setting.async.url = `/api/perms/v1/user/nodes/children/?search=${_keywords}`;
if (this.expandNodes) {
this.expandNodes.forEach((node) => {
if (node.id !== nodes[0].id) {
zTreeObj.expandNode(node, false);
}
});
this.expandNodes = null;
}
return null;
}
zTreeObj.reAsyncChildNodes(null, 'refresh');
let shouldShow = [];
const matchedNodes = zTreeObj.getNodesByFilter(function(node) {
if (node.meta.type === 'asset') {
const host = node.meta.asset;
return host.hostname.indexOf(_keywords) !== -1 || host.ip.indexOf(_keywords) !== -1;
} else {
return node.name.indexOf(_keywords) !== -1;
}
});
matchedNodes.forEach((node) => {
const parents = this.recurseParent(node);
const children = this.recurseChildren(node);
shouldShow = [...shouldShow, ...parents, ...children, node];
});
this.hiddenNodes = nodes;
this.expandNodes = shouldShow;
zTreeObj.hideNodes(nodes);
zTreeObj.showNodes(shouldShow);
shouldShow.forEach((node) => {
if (node.isParent) {
zTreeObj.expandNode(node, true);
}
});
// zTreeObj.expandAll(true);
}
}
......
......@@ -14,6 +14,7 @@ import {ElementDialogAlertComponent} from './dialog/dialog.service';
import {ElementGuacamoleComponent} from './guacamole/guacamole.component';
import {ElementSshTermComponent} from './ssh-term/ssh-term.component';
import {AssetTreeDialogComponent, ElementAssetTreeComponent} from './asset-tree/asset-tree.component';
import {RDPSolutionDialogComponent} from './nav/nav.component';
export const ElementComponents = [
ElementLeftbarComponent,
......@@ -31,5 +32,6 @@ export const ElementComponents = [
ElementGuacamoleComponent,
ElementAssetTreeComponent,
ElementSshTermComponent,
AssetTreeDialogComponent
AssetTreeDialogComponent,
RDPSolutionDialogComponent
];
......@@ -106,6 +106,26 @@ export class ElementNavComponent implements OnInit {
window.open('https://market.aliyun.com/products/53690006/cmgj026011.html?spm=5176.730005.0.0.cY2io1');
break;
}
case 'SetResolution': {
const dialog = this._dialog.open(
RDPSolutionDialogComponent,
{
height: '200px',
width: '300px',
data: {
title: 'Warning',
note: 'The page will be reload, can you acceptable?',
cancel: 'Cancel',
confirm: 'Confirm',
},
});
dialog.afterClosed().subscribe(result => {
if (result) {
console.log(result);
}
});
break;
}
case 'EnterLicense': {
this.EnterLicense();
break;
......@@ -175,12 +195,6 @@ export class ElementNavComponent implements OnInit {
}
getnav() {
this._logger.log('getnav');
// this._http.get('/api/nav')
// .map(res => res.json())
// .subscribe(response => {
// DataStore.Nav = response;
// });
DataStore.Nav = [{
'id': 'File',
'name': 'Server',
......@@ -195,35 +209,6 @@ export class ElementNavComponent implements OnInit {
'click': 'DisconnectAll',
'name': 'Disconnect all'
},
// {
// 'id': 'Duplicate',
// 'href': '',
// 'name': 'Duplicate',
// 'disable': true
// },
// {
// 'id': 'Upload',
// 'href': '',
// 'name': 'Upload',
// 'disable': true
// },
// {
// 'id': 'Download',
// 'href': '',
// 'name': 'Download',
// 'disable': true
// },
// {
// 'id': ' Search',
// 'href': '',
// 'name': 'Search',
// 'disable': true
// },
// {
// 'id': 'Reload',
// 'click': 'ReloadLeftbar',
// 'name': 'Reload'
// }
]
}, {
'id': 'FileManager',
......@@ -245,6 +230,11 @@ export class ElementNavComponent implements OnInit {
'click': 'HideLeft',
'name': 'Hide left manager'
},
{
'id': 'RDPResolution',
'click': 'SetResolution',
'name': 'RDP Resolution'
},
{
'id': 'SplitVertical',
'href': '',
......@@ -369,3 +359,34 @@ export class ChangLanWarningDialogComponent implements OnInit {
this.dialogRef.close();
}
}
@Component({
selector: 'elements-rdp-solution-dialog',
templateUrl: 'rdpSolutionDialog.html',
})
export class RDPSolutionDialogComponent implements OnInit {
solutions = ['Auto', '1024x768', '1366x768', '1400x900'];
solution: string;
cacheKey = 'rdpSolution';
constructor(public dialogRef: MatDialogRef<RDPSolutionDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
ngOnInit() {
this.solution = localStorage.getItem(this.cacheKey) || 'Auto';
}
setSolution(value: string) {
localStorage.setItem(this.cacheKey, value);
}
onSubmit() {
this.setSolution(this.solution);
this.dialogRef.close();
}
onNoClick(): void {
this.dialogRef.close();
}
}
<h1 mat-dialog-title>{{"Set RDP solution"|trans}}</h1>
<mat-form-field>
<mat-select [(value)]="solution"
placeholder="{{'Select a solution'|trans}}" >
<mat-option *ngFor="let s of solutions" value="{{s}}">{{s}}</mat-option>
</mat-select>
</mat-form-field>
<div style="float: right">
<button mat-raised-button (click)="onNoClick()">{{"Cancel"|trans}}</button>
<button mat-raised-button color="primary" (click)="onSubmit()">{{"Confirm"|trans}}</button>
</div>
......@@ -5,8 +5,9 @@
* @date 2017-11-07
* @author liuzheng <liuzheng712@gmail.com>
*/
import {Component} from '@angular/core';
import {Component, HostListener} from '@angular/core';
import {DataStore} from '../globals';
import { environment } from '../../environments/environment';
@Component({
selector: 'app-root',
......@@ -16,4 +17,14 @@ import {DataStore} from '../globals';
export class AppComponent {
DataStore = DataStore;
constructor() {}
@HostListener('window:beforeunload', ['$event'])
unloadNotification($event: any) {
if (environment.production) {
$event.returnValue = true;
}
}
}
......@@ -25,6 +25,18 @@ export interface HostGroup {
children: Array<Host>;
}
export interface Node {
id: string;
name: string;
comment: string;
title: string;
isParent: boolean;
pId: string;
open: boolean;
iconSkin: string;
meta: object;
}
export class Host {
name: string;
id: string;
......@@ -93,7 +105,7 @@ export class CleftbarComponent implements OnInit {
}
ngOnInit() {
this._http.get_my_asset_groups_assets()
this._http.get_my_granted_nodes()
.subscribe(response => {
this.zNodes = response;
// this.HostGroups = response;
......
......@@ -2,5 +2,5 @@ export const environment = {
production: true
};
// export const version = '1.3.0-{{BUILD_NUMBER}} GPLv2.';
export const version = '1.4.4-101 GPLv2.';
export const version = '1.4.5-101 GPLv2.';
// export const version = '1.4.1-{{BUILD_NUMBER}} GPLv2.';
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