diff --git a/Pipfile b/Pipfile index 63763ed87..0c118a0a9 100644 --- a/Pipfile +++ b/Pipfile @@ -22,6 +22,7 @@ mkdocstrings = "*" mkdocs = "*" mkdocs-material = "*" pyjwt = "*" +django-cors-headers = "*" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 275e87ce4..6e9463fab 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "507b95b335e8c86a1ba3a39f06e3ca0861f33f5f54706a10ee0e8bfd96767edb" + "sha256": "2f73388c25153cf171165440620730c277b4693303111e8aca781c6dc4b83704" }, "pipfile-spec": 6, "requires": { @@ -187,29 +187,31 @@ }, "cryptography": { "hashes": [ - "sha256:0a3bf09bb0b7a2c93ce7b98cb107e9170a90c51a0162a20af1c61c765b90e60b", - "sha256:1f64a62b3b75e4005df19d3b5235abd43fa6358d5516cfc43d87aeba8d08dd51", - "sha256:32db5cc49c73f39aac27574522cecd0a4bb7384e71198bc65a0d23f901e89bb7", - "sha256:4881d09298cd0b669bb15b9cfe6166f16fc1277b4ed0d04a22f3d6430cb30f1d", - "sha256:4e2dddd38a5ba733be6a025a1475a9f45e4e41139d1321f412c6b360b19070b6", - "sha256:53e0285b49fd0ab6e604f4c5d9c5ddd98de77018542e88366923f152dbeb3c29", - "sha256:70f8f4f7bb2ac9f340655cbac89d68c527af5bb4387522a8413e841e3e6628c9", - "sha256:7b2d54e787a884ffc6e187262823b6feb06c338084bbe80d45166a1cb1c6c5bf", - "sha256:7be666cc4599b415f320839e36367b273db8501127b38316f3b9f22f17a0b815", - "sha256:8241cac0aae90b82d6b5c443b853723bcc66963970c67e56e71a2609dc4b5eaf", - "sha256:82740818f2f240a5da8dfb8943b360e4f24022b093207160c77cadade47d7c85", - "sha256:8897b7b7ec077c819187a123174b645eb680c13df68354ed99f9b40a50898f77", - "sha256:c2c5250ff0d36fd58550252f54915776940e4e866f38f3a7866d92b32a654b86", - "sha256:ca9f686517ec2c4a4ce930207f75c00bf03d94e5063cbc00a1dc42531511b7eb", - "sha256:d2b3d199647468d410994dbeb8cec5816fb74feb9368aedf300af709ef507e3e", - "sha256:da73d095f8590ad437cd5e9faf6628a218aa7c387e1fdf67b888b47ba56a17f0", - "sha256:e167b6b710c7f7bc54e67ef593f8731e1f45aa35f8a8a7b72d6e42ec76afd4b3", - "sha256:ea634401ca02367c1567f012317502ef3437522e2fc44a3ea1844de028fa4b84", - "sha256:ec6597aa85ce03f3e507566b8bcdf9da2227ec86c4266bd5e6ab4d9e0cc8dab2", - "sha256:f64b232348ee82f13aac22856515ce0195837f6968aeaa94a3d0353ea2ec06a6" + "sha256:0234bdb18620ed16bf186f0591aea0bbc321ecaf59c859d5f5cbe7b646d8377e", + "sha256:183d6a540659c6a729c08971f09f3fb1044c89dd5af9d6f18da824a071f5445d", + "sha256:1af4f31870ef2180aba1c04f6d957461a570c8cabcc4b5ac7fabf2b4a0364ea0", + "sha256:2d3d8a69d262ba27923466194bef637150aef286b11b160e087992206ac32f0c", + "sha256:2dfd682771c04c7e85a4b4ea6aa1682a3fd6f4d9845468fa6ba512b80a560a8d", + "sha256:4c52cb32ea0b9798234823d37c93cab8004c574b2d224f048cd5829d0639387b", + "sha256:57273f69b334c6d30f4d27abc7fb9c919ef4c6193af64420572808302bb45768", + "sha256:5a761fc1ff0eae360a80656bea462c3163dfaa8093b2fa0f72af929217b14a97", + "sha256:5c2517a2c58213ee62b36ee9ece4a710179ddb07db90e31d7619e7ea472c9dc3", + "sha256:710b9041fb97cc576e288b5f96583578ed352dd60608a402045405c388522b94", + "sha256:8921428ca6403d7eb52ee0e728e8b02601060a5791f6d64c8a3a12b5722064af", + "sha256:bc54780dd8f7236874ac29fc155c5cf811f7d910e5f0575932a38bdaac3b5146", + "sha256:bf893131cd79dc8eaf4940b3aa2f4a68eba050471f5deacfaedea6aab04f574f", + "sha256:cab59c774125596fa72f1decc5805894313b40f370a7c75597e37f0211027944", + "sha256:d119feb387ce2df9bfb92e5785df9094325cfa974e2e6aa08c8e4a8b56786afe", + "sha256:d426093df7f00de859bad45d6a09fdab9b8e4c6e46ea897dd0a302b94c7f6871", + "sha256:d886b2c9f8d1ab0916673bc3c89dd04fc6e6591861872c9f08402b0ab2843b82", + "sha256:d97479d943d549d4a78f044b0620a7d349191ed40933ffabff1cc5875e20682c", + "sha256:db1b9516e3072e0342287e06779bec84118bd780f794c8c07bd5da142a526103", + "sha256:e86734f28656f6fd5993ab32bd2d2680c3b8341d6f875faf5212bc78715db2a4", + "sha256:ebdc9c4b3577bb76b0defebe4ef8b866da5228a1c53fbbf394b7677fe292fee9", + "sha256:eee79c6c16949ed817c8cf288e6e124c4b8996e3312d9e7884c71cf9bdda212e" ], "markers": "python_version >= '3.6'", - "version": "==36.0.2" + "version": "==37.0.0" }, "deprecated": { "hashes": [ @@ -227,6 +229,14 @@ "markers": "python_version >= '3.8'", "version": "==4.0.4" }, + "django-cors-headers": { + "hashes": [ + "sha256:a22be2befd4069c4fc174f11cf067351df5c061a3a5f94a01650b4e928b0372b", + "sha256:eb98389bf7a2afc5d374806af4a9149697e3a6955b5a2dc2bf049f7d33647456" + ], + "index": "pypi", + "version": "==3.11.0" + }, "django-ninja": { "hashes": [ "sha256:31a5c040a36c620deb4c20731c094540e3245a7b885a7f9d28e85098886595fc", @@ -255,7 +265,7 @@ "sha256:1208431ca90a8cca1a6b8af391bb53c1a2db74e5d1cef6ddced95d4b2062edc6", "sha256:ea4c597ebf37142f827b8f39299579e31685c31d3a438b59f469406afd0f2539" ], - "markers": "python_version < '3.10'", + "markers": "python_version >= '3.7'", "version": "==4.11.3" }, "jinja2": { @@ -362,11 +372,11 @@ }, "mkdocs-material": { "hashes": [ - "sha256:c177ff180b024bc061714c9483a8d26d36e1b9fdef4be8e70e243770416fe9d7", - "sha256:fbe39baa57c70fdbe9d1a24c6c2d0625e255e74f22b20aff43abb64157446f4d" + "sha256:4a3631ba22cff7ceca00c39465a8db5b2116fcd74f3abd82b801f7711cceb699", + "sha256:af6bbd608a54b8493cb5fa0d2f2cf29cde3bf348837ab718afb1be0a8bea6509" ], "index": "pypi", - "version": "==8.2.9" + "version": "==8.2.11" }, "mkdocs-material-extensions": { "hashes": [ @@ -630,7 +640,7 @@ "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14", "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_full_version < '4.0.0'", "version": "==1.26.9" }, "vine": { @@ -766,14 +776,6 @@ } }, "develop": { - "appnope": { - "hashes": [ - "sha256:02bd91c4de869fbb1e1c50aafc4098827a7a54ab2f39d9dcba6c9547ed920e24", - "sha256:265a455292d0bd8a72453494fa24df5a11eb18373a60c7c0430889f22548605e" - ], - "markers": "sys_platform == 'darwin'", - "version": "==0.1.3" - }, "astroid": { "hashes": [ "sha256:4e5ba10571e197785e312966ea5efb2f5783176d4c1a73fa922d474ae2be59f7", @@ -852,11 +854,11 @@ }, "identify": { "hashes": [ - "sha256:3f3244a559290e7d3deb9e9adc7b33594c1bc85a9dd82e0f1be519bf12a1ec17", - "sha256:5f06b14366bd1facb88b00540a1de05b69b310cbc2654db3c7e07fa3a4339323" + "sha256:3acfe15a96e4272b4ec5662ee3e231ceba976ef63fd9980ed2ce9cc415df393f", + "sha256:c83af514ea50bf2be2c4a3f2fb349442b59dc87284558ae9ff54191bff3541d2" ], "markers": "python_version >= '3.7'", - "version": "==2.4.12" + "version": "==2.5.0" }, "ipython": { "hashes": [ @@ -1072,6 +1074,14 @@ "markers": "python_version >= '3.6'", "version": "==6.0" }, + "setuptools": { + "hashes": [ + "sha256:26ead7d1f93efc0f8c804d9fafafbe4a44b179580a7105754b245155f9af05a8", + "sha256:47c7b0c0f8fc10eec4cf1e71c6fdadf8decaa74ffa087e68cd1c20db7ad6a592" + ], + "markers": "python_version >= '3.7'", + "version": "==62.1.0" + }, "six": { "hashes": [ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", diff --git a/api/v1/actions/__init__.py b/api/v1/actions/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/api/v1/pages/__init__.py b/api/v1/pages/__init__.py index 80484590b..fda60888d 100644 --- a/api/v1/pages/__init__.py +++ b/api/v1/pages/__init__.py @@ -5,7 +5,13 @@ approve_manage, auth_manage, charts_manage, - data_source_manage + data_source_manage, + developer_manage, + log_manage, + mine, + permission_manage, + platform_admin, + tenant_manage ) from arkid.core import routers @@ -18,6 +24,12 @@ approve_manage.router, auth_manage.router, charts_manage.router, - data_source_manage.router + data_source_manage.router, + developer_manage.router, + log_manage.router, + mine.router, + permission_manage.router, + platform_admin.router, + tenant_manage.router ] ) diff --git a/api/v1/pages/app_manage/app_group.py b/api/v1/pages/app_manage/app_group.py index 2faa8d077..5f9bdff95 100644 --- a/api/v1/pages/app_manage/app_group.py +++ b/api/v1/pages/app_manage/app_group.py @@ -1,136 +1,94 @@ -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -app_group_tag = 'app_group' -app_group_name = '应用分组' +tag = 'app_group' +name = '应用分组' -page = pages.TreePage( - tag=app_group_tag, - name=app_group_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/app_groups/', - method=pages.FrontActionMethod.GET - ) -) - -group_apps_page = pages.TablePage( - name='组内应用', - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/app_groups/{app_group_id}/apps/', - method=pages.FrontActionMethod.GET - ), -) - -group_apps_page.add_local_action( - [ - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, - path="/api/v1/tenant/{tenant_id}/app_groups/{app_group_id}/apps/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION - ) - ] -) +page = pages.TreePage(tag=tag,name=name) +group_apps_page = pages.TablePage(name=_("组内应用")) +edit_apps_page = pages.TablePage(name=_("更新组内应用")) +edit_page = pages.FormPage(name=_("编辑应用分组")) -page.set_next(group_apps_page) -edit_page = pages.FormPage( - name=_("编辑应用分组"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/app_groups/{id}/', - method=pages.FrontActionMethod.GET - ) -) +pages.register_front_pages(page) +pages.register_front_pages(group_apps_page) +pages.register_front_pages(edit_apps_page) +pages.register_front_pages(edit_page) -edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/app_groups/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -create_page = pages.FormPage( - name=_("创建一个新的应用分组"), - init_action=pages.FrontAction( +page.create_actions( + init_action=actions.DirectAction( path='/api/v1/tenant/{tenant_id}/app_groups/', - method=pages.FrontActionMethod.POST - ) -) - -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/app_groups/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) - -page.add_local_action( - [ - pages.FrontAction( - name=_("编辑"), + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create':actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/app_groups/' + ) + }, + local_actions=[ + actions.EditAction( page=edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/app_groups/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION + ) + ], + node_actions=[ + actions.CascadeAction( + page=group_apps_page ) ] ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION +group_apps_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/app_groups/{app_group_id}/apps/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + "update":actions.OpenAction( + name=_("添加应用"), + page=edit_apps_page, ) - ] + }, + local_actions=[ + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/app_groups/{app_group_id}/apps/{id}/", + icon="icon-delete", + ) + ], ) -router = routers.FrontRouter( - path=app_group_tag, - name='应用分组', - page=page, +edit_apps_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/app_groups/{app_group_id}/select_apps/', + method=actions.FrontActionMethod.GET, + ), + select=True, + global_actions={ + 'confirm': actions.ConfirmAction( + path="/tenant/{tenant_id}/app_groups/{app_group_id}/apps/" + ), + } +) + + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/app_groups/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/app_groups/{id}/" + ), + } ) -pages.register_front_pages(group_apps_page) -pages.register_front_pages(page) -pages.register_front_pages(create_page) -pages.register_front_pages(edit_page) \ No newline at end of file diff --git a/api/v1/pages/app_manage/app_list.py b/api/v1/pages/app_manage/app_list.py index 10fd80b4b..e0116c56d 100644 --- a/api/v1/pages/app_manage/app_list.py +++ b/api/v1/pages/app_manage/app_list.py @@ -1,115 +1,51 @@ -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -app_list_tag = 'app_list' -app_list_name = '应用列表' +tag = 'app_list' +name = '应用列表' -page = pages.TablePage( - tag=app_list_tag, - name=app_list_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/apps/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑应用")) -app_edit_page = pages.FormPage( - name=_("编辑应用"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/apps/{id}/', - method=pages.FrontActionMethod.GET - ) -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -app_edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/apps/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + icon='app', + page=page, ) -app_create_page = pages.FormPage( - name=_("创建一个新的应用"), - init_action=pages.FrontAction( +page.create_actions( + init_action=actions.DirectAction( path='/api/v1/tenant/{tenant_id}/apps/', - method=pages.FrontActionMethod.POST - ) -) - -app_create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/apps/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) - -page.add_local_action( - [ - pages.FrontAction( - name=_("编辑"), - page=app_edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create':actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/apps/' + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/apps/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=app_create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] -) - - -router = routers.FrontRouter( - path=app_list_tag, - name='应用管理', - icon='app', - page=page, +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/apps/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/apps/{id}/" + ), + } ) - -pages.register_front_pages(page) -pages.register_front_pages(app_create_page) -pages.register_front_pages(app_edit_page) \ No newline at end of file diff --git a/api/v1/pages/app_manage/app_protocol.py b/api/v1/pages/app_manage/app_protocol.py index ed12897ff..fb2e2a744 100644 --- a/api/v1/pages/app_manage/app_protocol.py +++ b/api/v1/pages/app_manage/app_protocol.py @@ -1,22 +1,23 @@ -# 应用协议 -from arkid.core.routers import FrontRouter +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -from arkid.core.pages import FormPage,register_front_pages -app_protocol_tag = "app_protocol" -app_protocol_name = _("应用协议") +tag = 'app_protocol' +name = '应用协议' -page = FormPage( - name=app_protocol_name, - tag=app_protocol_tag, -) +page = pages.TablePage(tag=tag, name=name) -register_front_pages(page) +pages.register_front_pages(page) -router = FrontRouter( - path=app_protocol_tag, - name=app_protocol_name, - icon='app', +router = routers.FrontRouter( + path=tag, + name=name, page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/app_protocols/', + method=actions.FrontActionMethod.GET, + ), ) \ No newline at end of file diff --git a/api/v1/pages/approve_manage/approve_action.py b/api/v1/pages/approve_manage/approve_action.py index a10ec0157..8b2eaa54c 100644 --- a/api/v1/pages/approve_manage/approve_action.py +++ b/api/v1/pages/approve_manage/approve_action.py @@ -1,114 +1,54 @@ -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -approve_action_tag = 'approve_action' -approve_action_name = '审批动作' +tag = 'approve_actions' +name = '审批动作' -page = pages.TablePage( - tag=approve_action_tag, - name=approve_action_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/approve_actions/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑审批动作")) -edit_page = pages.FormPage( - name=_("编辑审批"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/approve_actions/{id}/', - method=pages.FrontActionMethod.GET - ) -) -edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/approve_actions/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -create_page = pages.FormPage( - name=_("创建一个新的审批"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/approve_actions/', - method=pages.FrontActionMethod.POST - ) -) -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/approve_actions/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -page.add_local_action( - [ - pages.FrontAction( - name=_("编辑"), +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/approve_actions/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/approve_actions/', + ) + }, + local_actions=[ + actions.EditAction( page=edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/approve_actions/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/approve_actions/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/approve_actions/{id}/" + ), + } ) -router = routers.FrontRouter( - path=approve_action_tag, - name=approve_action_name, - page=page, -) - -pages.register_front_pages(page) -pages.register_front_pages(create_page) -pages.register_front_pages(edit_page) \ No newline at end of file diff --git a/api/v1/pages/approve_manage/approve_system.py b/api/v1/pages/approve_manage/approve_system.py index 1d43d3059..9c62eb3f7 100644 --- a/api/v1/pages/approve_manage/approve_system.py +++ b/api/v1/pages/approve_manage/approve_system.py @@ -1,22 +1,18 @@ -# 审批系统 +# 应用协议 from arkid.core.routers import FrontRouter from arkid.core.translation import gettext_default as _ from arkid.core.pages import FormPage,register_front_pages -approve_system_tag = "approve_system" -approve_system_name = _("审批系统") +tag = "approve_system" +name = _("审批系统") -page = FormPage( - name=approve_system_name, - tag=approve_system_tag -) +page = FormPage(name=name,tag=tag) register_front_pages(page) router = FrontRouter( - path=approve_system_tag, - name=approve_system_name, - icon='app', + path=tag, + name=name, page=page, ) \ No newline at end of file diff --git a/api/v1/pages/auth_manage/auth_factor.py b/api/v1/pages/auth_manage/auth_factor.py index 5252e8e72..e74967b45 100644 --- a/api/v1/pages/auth_manage/auth_factor.py +++ b/api/v1/pages/auth_manage/auth_factor.py @@ -1,67 +1,54 @@ -# 认证因素 -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -auth_factor_tag = 'auth_factor' -auth_factor_name = '认证因素' +tag = 'auth_factor' +name = '认证因素' -page = pages.TablePage( - tag=auth_factor_tag, - name=auth_factor_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auth_factor/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑认证因素")) -create_page = pages.FormPage( - name=_("创建一个新的认证因素"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auth_factor/', - method=pages.FrontActionMethod.POST - ) -) -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/auth_factor/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +pages.register_front_pages(page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/auth_factors/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/auth_factors/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/auth_factors/{id}/", ) - ] + ], ) - -router = routers.FrontRouter( - path=auth_factor_tag, - name=auth_factor_name, - page=page, +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/auth_factors/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/auth_factors/{id}/" + ), + } ) -pages.register_front_pages(page) -pages.register_front_pages(create_page) \ No newline at end of file + diff --git a/api/v1/pages/auth_manage/auth_rules.py b/api/v1/pages/auth_manage/auth_rules.py index 772f5eb98..6393b2dd3 100644 --- a/api/v1/pages/auth_manage/auth_rules.py +++ b/api/v1/pages/auth_manage/auth_rules.py @@ -1,115 +1,54 @@ -# 认证规则 -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -auth_rule_tag = 'auth_rule' -auth_rule_name = '认证规则' +tag = 'auth_rule' +name = '认证规则' -page = pages.TablePage( - tag=auth_rule_tag, - name=auth_rule_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auth_rules/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑认证规则")) -edit_page = pages.FormPage( - name=_("编辑认证规则"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auth_rules/{id}/', - method=pages.FrontActionMethod.GET - ) -) -edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/auth_rules/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -create_page = pages.FormPage( - name=_("创建一个新的认证规则"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auth_rules/', - method=pages.FrontActionMethod.POST - ) -) -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/auth_rules/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -page.add_local_action( - [ - pages.FrontAction( - name=_("编辑"), +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/auth_rules/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/auth_rules/', + ) + }, + local_actions=[ + actions.EditAction( page=edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/auth_rules/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/auth_rules/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/auth_rules/{id}/" + ), + } ) -router = routers.FrontRouter( - path=auth_rule_tag, - name=auth_rule_name, - page=page, -) - -pages.register_front_pages(page) -pages.register_front_pages(create_page) -pages.register_front_pages(edit_page) \ No newline at end of file diff --git a/api/v1/pages/auth_manage/auto_auth.py b/api/v1/pages/auth_manage/auto_auth.py index adea7da74..ba17650ab 100644 --- a/api/v1/pages/auth_manage/auto_auth.py +++ b/api/v1/pages/auth_manage/auto_auth.py @@ -1,115 +1,54 @@ -# 自动认证 -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -auto_auth_tag = 'auto_auth' -auto_auth_name = '自动认证' +tag = 'auto_auth' +name = '自动认证' -page = pages.TablePage( - tag=auto_auth_tag, - name=auto_auth_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auto_auths/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑自动认证")) -edit_page = pages.FormPage( - name=_("编辑自动认证"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auto_auths/{id}/', - method=pages.FrontActionMethod.GET - ) -) -edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/auto_auths/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -create_page = pages.FormPage( - name=_("创建一个新的自动认证"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/auto_auths/', - method=pages.FrontActionMethod.POST - ) -) -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/auto_auths/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -page.add_local_action( - [ - pages.FrontAction( - name=_("编辑"), +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/auto_auths/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/auto_auths/', + ) + }, + local_actions=[ + actions.EditAction( page=edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/auto_auths/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/auto_auths/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/auto_auths/{id}/" + ), + } ) -router = routers.FrontRouter( - path=auto_auth_tag, - name=auto_auth_name, - page=page, -) - -pages.register_front_pages(page) -pages.register_front_pages(create_page) -pages.register_front_pages(edit_page) \ No newline at end of file diff --git a/api/v1/pages/auth_manage/third_auth.py b/api/v1/pages/auth_manage/third_auth.py index c5cdc6a1b..da8dc2129 100644 --- a/api/v1/pages/auth_manage/third_auth.py +++ b/api/v1/pages/auth_manage/third_auth.py @@ -1,115 +1,54 @@ -# 第三方认证 -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -third_auth_tag = 'third_auth' -third_auth_name = '第三方认证' +tag = 'third_auth' +name = '第三方认证' -page = pages.TablePage( - tag=third_auth_tag, - name=third_auth_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/third_auths/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑第三方认证")) -edit_page = pages.FormPage( - name=_("编辑第三方认证"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/third_auths/{id}/', - method=pages.FrontActionMethod.GET - ) -) -edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/third_auths/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -create_page = pages.FormPage( - name=_("创建一个新的第三方认证"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/third_auths/', - method=pages.FrontActionMethod.POST - ) -) -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/third_auths/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -page.add_local_action( - [ - pages.FrontAction( - name=_("编辑"), +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/third_auths/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/third_auths/', + ) + }, + local_actions=[ + actions.EditAction( page=edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/third_auths/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/third_auths/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/third_auths/{id}/" + ), + } ) -router = routers.FrontRouter( - path=third_auth_tag, - name=third_auth_name, - page=page, -) - -pages.register_front_pages(page) -pages.register_front_pages(create_page) -pages.register_front_pages(edit_page) \ No newline at end of file diff --git a/api/v1/pages/charts_manage/__init__.py b/api/v1/pages/charts_manage/__init__.py index a5ee84f6a..972ac55eb 100644 --- a/api/v1/pages/charts_manage/__init__.py +++ b/api/v1/pages/charts_manage/__init__.py @@ -1,11 +1,12 @@ # 图表展示 from arkid.core import routers -from . import bi_systems +from . import bi_systems,charts router = routers.FrontRouter( path='charts', name='图表展示', children=[ - bi_systems.router + charts.router, + bi_systems.router, ] ) \ No newline at end of file diff --git a/api/v1/pages/charts_manage/bi_systems.py b/api/v1/pages/charts_manage/bi_systems.py index e7cac61b9..9d56d09c4 100644 --- a/api/v1/pages/charts_manage/bi_systems.py +++ b/api/v1/pages/charts_manage/bi_systems.py @@ -1,21 +1,54 @@ -# BI系统 -from arkid.core.routers import FrontRouter +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -from arkid.core.pages import FormPage,register_front_pages -bi_systems_tag = "bi_systems" -bi_systems_name = _("BI系统") +tag = 'bi_system' +name = 'BI系统' -page = FormPage( - name=bi_systems_name, - tag=bi_systems_tag, -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑BI系统")) + + +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -register_front_pages(page) -router = FrontRouter( - path=bi_systems_tag, - name=bi_systems_name, +router = routers.FrontRouter( + path=tag, + name=name, page=page, -) \ No newline at end of file +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/bi_systems/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/bi_systems/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/bi_systems/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/bi_systems/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/bi_systems/{id}/" + ), + } +) + + diff --git a/api/v1/pages/charts_manage/charts.py b/api/v1/pages/charts_manage/charts.py new file mode 100644 index 000000000..4c117a350 --- /dev/null +++ b/api/v1/pages/charts_manage/charts.py @@ -0,0 +1,16 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'charts' +name = '图表分析' + + +page = pages.DescriptionPage(tag=tag, name=name) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) \ No newline at end of file diff --git a/api/v1/pages/data_source_manage/permission_sync.py b/api/v1/pages/data_source_manage/permission_sync.py index 58a445df3..61a956ef3 100644 --- a/api/v1/pages/data_source_manage/permission_sync.py +++ b/api/v1/pages/data_source_manage/permission_sync.py @@ -1,121 +1,59 @@ -# 权限数据同步 -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -permission_sync_tag = 'permission_sync' -permission_sync_name = '权限数据同步' +tag = 'permission_sync' +name = '权限同步' -page = pages.TablePage( - tag=permission_sync_tag, - name=permission_sync_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/permission_syncs/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑权限同步配置")) -edit_page = pages.FormPage( - name=_("编辑权限数据同步配置"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/permission_syncs/{id}/', - method=pages.FrontActionMethod.GET - ) -) -edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/permission_syncs/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -create_page = pages.FormPage( - name=_("创建一个新的权限数据同步配置"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/permission_syncs/', - method=pages.FrontActionMethod.POST - ) -) -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/permission_syncs/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -page.add_local_action( - [ - pages.FrontAction( +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_syncs/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/permission_syncs/', + ) + }, + local_actions=[ + actions.DirectAction( name=_("同步"), - method=pages.FrontActionMethod.GET, + method=actions.FrontActionMethod.GET, path="/api/v1/tenant/{tenant_id}/permission_syncs/{id}/sync/", - action_type=pages.FrontActionType.DIRECT_ACTION ), - pages.FrontAction( - name=_("编辑"), + actions.EditAction( page=edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/permission_syncs/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_syncs/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/permission_syncs/{id}/" + ), + } ) -router = routers.FrontRouter( - path=permission_sync_tag, - name=permission_sync_name, - page=page, -) - -pages.register_front_pages(page) -pages.register_front_pages(create_page) -pages.register_front_pages(edit_page) \ No newline at end of file diff --git a/api/v1/pages/data_source_manage/scim_sync.py b/api/v1/pages/data_source_manage/scim_sync.py index 2f512c204..d0f6c5049 100644 --- a/api/v1/pages/data_source_manage/scim_sync.py +++ b/api/v1/pages/data_source_manage/scim_sync.py @@ -1,121 +1,59 @@ -# 用户数据同步 -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -scim_sync_tag = 'scim_sync' -scim_sync_name = '用户数据同步' +tag = 'scim_sync' +name = '用户/群组数据同步' -page = pages.TablePage( - tag=scim_sync_tag, - name=scim_sync_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/scim_syncs/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑用户/群组数据同步配置")) -edit_page = pages.FormPage( - name=_("编辑用户数据同步配置"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/scim_syncs/{id}/', - method=pages.FrontActionMethod.GET - ) -) -edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/scim_syncs/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -create_page = pages.FormPage( - name=_("创建一个新的用户数据同步配置"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/scim_syncs/', - method=pages.FrontActionMethod.POST - ) -) -create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/scim_syncs/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + page=page, ) -page.add_local_action( - [ - pages.FrontAction( +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/scim_syncs/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/scim_syncs/', + ) + }, + local_actions=[ + actions.DirectAction( name=_("同步"), - method=pages.FrontActionMethod.GET, + method=actions.FrontActionMethod.GET, path="/api/v1/tenant/{tenant_id}/scim_syncs/{id}/sync/", - action_type=pages.FrontActionType.DIRECT_ACTION ), - pages.FrontAction( - name=_("编辑"), + actions.EditAction( page=edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/scim_syncs/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/scim_syncs/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/scim_syncs/{id}/" + ), + } ) -router = routers.FrontRouter( - path=scim_sync_tag, - name=scim_sync_name, - page=page, -) - -pages.register_front_pages(page) -pages.register_front_pages(create_page) -pages.register_front_pages(edit_page) \ No newline at end of file diff --git a/api/v1/pages/desktop/__init__.py b/api/v1/pages/desktop/__init__.py index 4a7968a5b..479e77457 100644 --- a/api/v1/pages/desktop/__init__.py +++ b/api/v1/pages/desktop/__init__.py @@ -3,12 +3,10 @@ from arkid.core import routers,pages router = routers.FrontRouter( - path='desktop', + path='', name='桌面', icon='home', - children=[ - app_list.router, - ], + page=app_list.page ) router.mobile_children = [ diff --git a/api/v1/pages/desktop/app_list.py b/api/v1/pages/desktop/app_list.py index c61c4c6c4..6d6df1d5d 100644 --- a/api/v1/pages/desktop/app_list.py +++ b/api/v1/pages/desktop/app_list.py @@ -1,21 +1,21 @@ -from arkid.core import routers, pages +from arkid.core import routers, pages, actions -app_list_tag = 'mine_app_list' -app_list_name = '应用市集' +tag = 'mine_app_list' +name = '应用市集' -page = pages.CardsPage( - tag = app_list_tag, - name = app_list_name, - init_action=pages.FrontAction( - path = '/api/v1/tenant/{tenant_id}/mine/apps/', - method = pages.FrontActionMethod.GET - ) -) +page = pages.CardsPage(tag = tag, name = name) + +pages.register_front_pages(page) router = routers.FrontRouter( - path=app_list_tag, - name=app_list_name, + path=tag, + name=name, page=page ) -pages.register_front_pages(page) +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/mine/tenant/{tenant_id}/apps/', + method=actions.FrontActionMethod.GET, + ) +) \ No newline at end of file diff --git a/api/v1/pages/developer_manage/api_docs.py b/api/v1/pages/developer_manage/api_docs.py index dc2199763..090f0e027 100644 --- a/api/v1/pages/developer_manage/api_docs.py +++ b/api/v1/pages/developer_manage/api_docs.py @@ -2,11 +2,11 @@ from arkid.core.routers import FrontRouter from arkid.core.translation import gettext_default as _ -api_docs_tag = "api_docs" -api_docs_name = _("API文档") +tag = "api_docs" +name = _("API文档") router = FrontRouter( - path=api_docs_tag, - name=api_docs_name, + path=tag, + name=name, url='/api/v1/redoc' ) \ No newline at end of file diff --git a/api/v1/pages/developer_manage/webhook.py b/api/v1/pages/developer_manage/webhook.py index e69de29bb..caed25200 100644 --- a/api/v1/pages/developer_manage/webhook.py +++ b/api/v1/pages/developer_manage/webhook.py @@ -0,0 +1,103 @@ +# Webhook +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'webhook' +name = 'Webhook' + + +page = pages.TablePage(tag=tag,name=name) +edit_page = pages.FormPage( name=_("编辑Webhook") ) +create_page = pages.FormPage( name=_("创建一个新的Webhook") ) +history_page = pages.TablePage( tag="webhook_history", name=_("webhook历史记录")) +history_detail_page = pages.DescriptionPage(name=_("webhook历史记录详情")) + +pages.register_front_pages(page) +pages.register_front_pages(history_page) + +pages.register_front_pages(edit_page) +pages.register_front_pages(history_detail_page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/webhooks/', + method=actions.FrontActionMethod.GET, + ), + global_actions = { + "create":actions.CreateAction( + path=create_page, + ) + }, + local_actions = [ + actions.OpenAction( + name=_("历史记录"), + page=history_page, + icon="icon-edit", + ), + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/webhooks/{id}/" + ) + ] +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/webhooks/{id}/', + method=actions.FrontActionMethod.GET, + ), + global_actions = { + "confirm": actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/webhooks/{id}/" + ), + } +) + +create_page.create_actions( + # name=_("创建一个新的Webhook"), + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/webhooks/', + method=actions.FrontActionMethod.POST + ), + global_actions = { + "confirm": actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/webhooks/" + ), + } +) + +history_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/webhooks/{webhook_id}/histories/', + method=actions.FrontActionMethod.GET, + ), + local_actions = [ + actions.OpenAction( + name=_("查阅"), + page=history_detail_page + ), + actions.DirectAction( + name=_("重试"), + path='/api/v1/tenant/{tenant_id}/webhooks/{webhook_id}/histories/{id}/retry/', + method=actions.FrontActionMethod.GET, + ), + actions.DeleteAction( + path='/api/v1/tenant/{tenant_id}/webhooks/{webhook_id}/histories/{id}/', + ) + ] +) + +history_detail_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/webhooks/{webhook_id}/histories/{id}/', + method=actions.FrontActionMethod.GET, + ) +) diff --git a/api/v1/pages/log_manage/__init__.py b/api/v1/pages/log_manage/__init__.py index 9268cdec2..44facee0b 100644 --- a/api/v1/pages/log_manage/__init__.py +++ b/api/v1/pages/log_manage/__init__.py @@ -1 +1,13 @@ -# 日志管理 \ No newline at end of file +from arkid.core import routers +from arkid.core.translation import gettext_default as _ +from . import log_config,manager_log,user_log + +router = routers.FrontRouter( + path='log_manage', + name=_('日志管理'), + children=[ + log_config.router, + manager_log.router, + user_log.router, + ] +) \ No newline at end of file diff --git a/api/v1/pages/log_manage/administrator_log.py b/api/v1/pages/log_manage/administrator_log.py deleted file mode 100644 index 57c429229..000000000 --- a/api/v1/pages/log_manage/administrator_log.py +++ /dev/null @@ -1 +0,0 @@ -# 管理员行为日志 \ No newline at end of file diff --git a/api/v1/pages/log_manage/log_config.py b/api/v1/pages/log_manage/log_config.py index 53e59f645..68010ecca 100644 --- a/api/v1/pages/log_manage/log_config.py +++ b/api/v1/pages/log_manage/log_config.py @@ -1 +1,26 @@ -# 日志配置 \ No newline at end of file +from arkid.core import routers, pages, actions + +tag = 'log_config' +name = '日志配置' + +page = pages.FormPage(tag = tag, name = name) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page +) + +page.create_actions( + init_action=actions.DirectAction( + path="/api/v1/tenant/{tenant_id}/log_config/", + method=actions.FrontActionMethod.GET, + ), + global_actions = { + "confirm": actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/log_config/" + ), + } +) \ No newline at end of file diff --git a/api/v1/pages/log_manage/manager_log.py b/api/v1/pages/log_manage/manager_log.py new file mode 100644 index 000000000..5d694e33f --- /dev/null +++ b/api/v1/pages/log_manage/manager_log.py @@ -0,0 +1,37 @@ +from arkid.core.translation import gettext_default as _ +from arkid.core import routers, pages, actions + +tag = 'manager_log' +name = '管理员行为日志' + +page = pages.TablePage(tag = tag, name = name) +detail_page = pages.DescriptionPage(name=_("日志详情")) + +pages.register_front_pages(page) +pages.register_front_pages(detail_page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/manager_log/', + method=actions.FrontActionMethod.GET, + ), + local_actions=[ + actions.OpenAction( + name=_("查阅"), + page=detail_page + ) + ] +) + +detail_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/log/{id}/', + method=actions.FrontActionMethod.GET, + ) +) \ No newline at end of file diff --git a/api/v1/pages/log_manage/user_log.py b/api/v1/pages/log_manage/user_log.py index a63cac0f3..4822d784d 100644 --- a/api/v1/pages/log_manage/user_log.py +++ b/api/v1/pages/log_manage/user_log.py @@ -1 +1,37 @@ -# 用户日志 \ No newline at end of file +from arkid.core.translation import gettext_default as _ +from arkid.core import routers, pages, actions + +tag = 'user_log' +name = '用户行为日志' + +page = pages.TablePage(tag = tag, name = name) +detail_page = pages.DescriptionPage(name=_("日志详情")) + +pages.register_front_pages(page) +pages.register_front_pages(detail_page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/user_log/', + method=actions.FrontActionMethod.GET, + ), + local_actions=[ + actions.OpenAction( + name=_("查阅"), + page=detail_page + ) + ] +) + +detail_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/log/{id}/', + method=actions.FrontActionMethod.GET, + ) +) \ No newline at end of file diff --git a/api/v1/pages/mine/__init__.py b/api/v1/pages/mine/__init__.py index f1c3a0ba2..0a24def0c 100644 --- a/api/v1/pages/mine/__init__.py +++ b/api/v1/pages/mine/__init__.py @@ -1,10 +1,17 @@ from arkid.core import routers from arkid.core.translation import gettext_default as _ +from . import profile, approve_manage,auth_manage,grant_manage,switch_tenant,logout router = routers.FrontRouter( path='mine', name=_('我的'), children=[ + profile.router, + approve_manage.router, + auth_manage.router, + grant_manage.router, + switch_tenant.router, + logout.router ] ) diff --git a/api/v1/pages/mine/approval_manage.py b/api/v1/pages/mine/approval_manage.py deleted file mode 100644 index 255081152..000000000 --- a/api/v1/pages/mine/approval_manage.py +++ /dev/null @@ -1,22 +0,0 @@ -# 审批管理 -from arkid.core.routers import FrontRouter -from arkid.core.translation import gettext_default as _ -from arkid.core.pages import FormPage,register_front_pages - -approve_action_tag = "approve_action" -approve_action_name = _("审批动作") - - -page = FormPage( - name=approve_action_name, - tag=approve_action_tag -) - -register_front_pages(page) - -router = FrontRouter( - path=approve_action_tag, - name=approve_action_name, - icon='app', - page=page, -) \ No newline at end of file diff --git a/api/v1/pages/mine/approve_manage.py b/api/v1/pages/mine/approve_manage.py new file mode 100644 index 000000000..4f4528e85 --- /dev/null +++ b/api/v1/pages/mine/approve_manage.py @@ -0,0 +1,28 @@ +# 审批管理 +from arkid.core.translation import gettext_default as _ +from arkid.core import pages,routers,actions + +tag = "mine_approve_manage" +name = _("审批动作") + + +page = pages.TablePage( + name=name, + tag=tag +) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, + icon='app', + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/mine/tenant/{tenant_id}/approves/', + method=actions.FrontActionMethod.GET, + ) +) \ No newline at end of file diff --git a/api/v1/pages/mine/auth_manage.py b/api/v1/pages/mine/auth_manage.py index 6bdd4f3e0..0a4796a0b 100644 --- a/api/v1/pages/mine/auth_manage.py +++ b/api/v1/pages/mine/auth_manage.py @@ -1 +1,10 @@ -# 认证管理 \ No newline at end of file +from arkid.core.translation import gettext_default as _ +from arkid.core import routers + +tag = "mine_auth_manage" +name = _("认证管理") + +router = routers.FrontRouter( + path=tag, + name=name, +) \ No newline at end of file diff --git a/api/v1/pages/mine/grant_manage.py b/api/v1/pages/mine/grant_manage.py index 37c79e79d..313e63b6b 100644 --- a/api/v1/pages/mine/grant_manage.py +++ b/api/v1/pages/mine/grant_manage.py @@ -1 +1,53 @@ -# 授权管理 \ No newline at end of file +# 授权管理 +from select import select +from arkid.core.translation import gettext_default as _ +from arkid.core import pages,routers,actions + +tag = "mine_grant_manage" +name = _("授权管理") + + +page = pages.TablePage( + name=name, + tag=tag +) +permission_page = pages.TablePage( + name=_("申请权限"), + select=True, +) + + +pages.register_front_pages(page) +pages.register_front_pages(permission_page) + +router = routers.FrontRouter( + path=tag, + name=name, + icon='app', + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/mine/tenant/{tenant_id}/permissions/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'open': actions.OpenAction( + name=("申请权限"), + page=permission_page + ) + } +) + +permission_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/mine/tenant/{tenant_id}/all_permissions/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/mine/tenant/{tenant_id}/permissions/" + ), + } +) \ No newline at end of file diff --git a/api/v1/pages/mine/logout.py b/api/v1/pages/mine/logout.py index 9bff41f9e..cc9bc9b3b 100644 --- a/api/v1/pages/mine/logout.py +++ b/api/v1/pages/mine/logout.py @@ -1 +1,11 @@ -# 退出登录 \ No newline at end of file +from arkid.core.translation import gettext_default as _ +from arkid.core import routers + +tag = "mine_logout" +name = _("退出登录") + +router = routers.FrontRouter( + path=tag, + name=name, + url='/mine/logout/' +) \ No newline at end of file diff --git a/api/v1/pages/mine/profile.py b/api/v1/pages/mine/profile.py new file mode 100644 index 000000000..b43ca0c40 --- /dev/null +++ b/api/v1/pages/mine/profile.py @@ -0,0 +1,29 @@ +from arkid.core.translation import gettext_default as _ +from arkid.core import actions, pages, routers + +tag = "mine_profile" +name = _("个人资料") + +page = pages.FormPage( + tag=tag, + name=name +) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/mine/tenant/{tenant_id}/profile/', + method=actions.FrontActionMethod.GET + ), + global_actions = { + "confirm": actions.ConfirmAction( + path="/mine/tenant/{tenant_id}/profile/" + ), + } +) \ No newline at end of file diff --git a/api/v1/pages/mine/switch_tenant.py b/api/v1/pages/mine/switch_tenant.py index d33f9593f..c97f43096 100644 --- a/api/v1/pages/mine/switch_tenant.py +++ b/api/v1/pages/mine/switch_tenant.py @@ -1 +1,31 @@ -# 切换租户 \ No newline at end of file +from arkid.core.translation import gettext_default as _ +from arkid.core import actions, pages, routers + +tag = "mine_switch_tenant" +name = _("切换租户") + +page = pages.CardsPage( + tag=tag, + name=name +) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/mine/tenants/', + method=actions.FrontActionMethod.GET + ), + node_actions=[ + actions.URLAction( + path='/api/v1/mine/switch_tenant/{id}/', + method=actions.FrontActionMethod.GET + ) + ] +) \ No newline at end of file diff --git a/api/v1/pages/mine/user_profile.py b/api/v1/pages/mine/user_profile.py deleted file mode 100644 index f5ae84d95..000000000 --- a/api/v1/pages/mine/user_profile.py +++ /dev/null @@ -1 +0,0 @@ -# 个人资料 \ No newline at end of file diff --git a/api/v1/pages/permission_manage/__init__.py b/api/v1/pages/permission_manage/__init__.py index e69de29bb..0f53b8286 100644 --- a/api/v1/pages/permission_manage/__init__.py +++ b/api/v1/pages/permission_manage/__init__.py @@ -0,0 +1,14 @@ +from arkid.core import routers +from arkid.core.translation import gettext_default as _ +from . import grant_rules,permission_group,permission_list,grant_manage + +router = routers.FrontRouter( + path='permission_manage', + name=_('权限管理'), + children=[ + grant_manage.router, + grant_rules.router, + permission_group.router, + permission_list.router + ] +) \ No newline at end of file diff --git a/api/v1/pages/permission_manage/grant_manage.py b/api/v1/pages/permission_manage/grant_manage.py deleted file mode 100644 index 37c79e79d..000000000 --- a/api/v1/pages/permission_manage/grant_manage.py +++ /dev/null @@ -1 +0,0 @@ -# 授权管理 \ No newline at end of file diff --git a/api/v1/pages/permission_manage/grant_manage/__init__.py b/api/v1/pages/permission_manage/grant_manage/__init__.py new file mode 100644 index 000000000..897ad9958 --- /dev/null +++ b/api/v1/pages/permission_manage/grant_manage/__init__.py @@ -0,0 +1,23 @@ +from arkid.core import routers,pages +from arkid.core.translation import gettext_default as _ +from . import user_grant,group_grant,app_grant +tag = "grant_manage" +name = _("授权管理") + +page = pages.TabsPage( + tag=tag, + name=name, + pages=[ + user_grant.page, + group_grant.page, + app_grant.page + ] +) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path='grant_manage', + name=_('授权管理'), + page=page +) \ No newline at end of file diff --git a/api/v1/pages/permission_manage/grant_manage/app_grant.py b/api/v1/pages/permission_manage/grant_manage/app_grant.py new file mode 100644 index 000000000..3bf9a710d --- /dev/null +++ b/api/v1/pages/permission_manage/grant_manage/app_grant.py @@ -0,0 +1,31 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'app_grant' +name = '所有应用' + + +page = pages.ListPage(tag=tag,name=name) +app_permission_page = pages.TablePage(name=_("该应用权限")) + +pages.register_front_pages(page) +pages.register_front_pages(app_permission_page) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/apps/', + method=actions.FrontActionMethod.GET, + ), + node_actions=[ + actions.CascadeAction( + page=app_permission_page + ) + ] +) + +app_permission_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/apps/{app_id}/permissions/', + method=actions.FrontActionMethod.GET + ) +) \ No newline at end of file diff --git a/api/v1/pages/permission_manage/grant_manage/group_grant.py b/api/v1/pages/permission_manage/grant_manage/group_grant.py new file mode 100644 index 000000000..c3c9c8c14 --- /dev/null +++ b/api/v1/pages/permission_manage/grant_manage/group_grant.py @@ -0,0 +1,56 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'group_grant' +name = '所有分组' + + +page = pages.ListPage(tag=tag,name=name) +group_permission_page = pages.TablePage(name=_("该分组权限")) +update_group_permission_page = pages.TablePage(name=_("更新用户分组权限"),select=True) + +pages.register_front_pages(page) +pages.register_front_pages(group_permission_page) +pages.register_front_pages(update_group_permission_page) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/user_groups/', + method=actions.FrontActionMethod.GET, + ), + node_actions=[ + actions.CascadeAction( + page=group_permission_page + ) + ], +) + +group_permission_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/user_groups/{user_group_id}/permissions/', + method=actions.FrontActionMethod.GET + ), + local_actions=[ + actions.DeleteAction( + path='/api/v1/tenant/{tenant_id}/user_groups/{user_group_id}/permissions/{id}/' + ) + ], + global_actions={ + 'open': actions.OpenAction( + name=("添加用户分组权限"), + page=update_group_permission_page + ) + } +) + +update_group_permission_page.create_actions( + init_action=actions.DeleteAction( + path='/api/v1/tenant/{tenant_id}/user_groups/{user_group_id}/all_permissions/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm':actions.ConfirmAction( + path='/api/v1/tenant/{tenant_id}/user_groups/{user_group_id}/permissions/', + ), + } +) \ No newline at end of file diff --git a/api/v1/pages/permission_manage/grant_manage/user_grant.py b/api/v1/pages/permission_manage/grant_manage/user_grant.py new file mode 100644 index 000000000..187ed7e7b --- /dev/null +++ b/api/v1/pages/permission_manage/grant_manage/user_grant.py @@ -0,0 +1,56 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'user_grant' +name = '所有分组' + + +page = pages.ListPage(tag=tag,name=name) +user_permission_page = pages.TablePage(name=_("该分组权限")) +update_user_permission_page = pages.TablePage(name=_("更新用户分组权限"),select=True) + +pages.register_front_pages(page) +pages.register_front_pages(user_permission_page) +pages.register_front_pages(update_user_permission_page) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/users/', + method=actions.FrontActionMethod.GET, + ), + node_actions=[ + actions.CascadeAction( + page=user_permission_page + ) + ], +) + +user_permission_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/users/{user_id}/permissions/', + method=actions.FrontActionMethod.GET + ), + local_actions=[ + actions.DeleteAction( + path='/api/v1/tenant/{tenant_id}/users/{user_id}/permissions/{id}/' + ) + ], + global_actions={ + 'open': actions.OpenAction( + name=("添加用户分组权限"), + page=update_user_permission_page + ) + } +) + +update_user_permission_page.create_actions( + init_action=actions.DeleteAction( + path='/api/v1/tenant/{tenant_id}/users/{user_id}/all_permissions/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm':actions.ConfirmAction( + path='/api/v1/tenant/{tenant_id}/users/{user_id}/permissions/', + ), + } +) \ No newline at end of file diff --git a/api/v1/pages/permission_manage/grant_rules.py b/api/v1/pages/permission_manage/grant_rules.py index 6c3d6e129..0356bce1d 100644 --- a/api/v1/pages/permission_manage/grant_rules.py +++ b/api/v1/pages/permission_manage/grant_rules.py @@ -1 +1,54 @@ -# 授权规则 \ No newline at end of file +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'grant_rule' +name = '授权规则' + + +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑授权规则")) + + +pages.register_front_pages(page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_rules/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/permission_rules/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/permission_rules/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_rules/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/permission_rules/{id}/" + ), + } +) + + diff --git a/api/v1/pages/permission_manage/permission_group.py b/api/v1/pages/permission_manage/permission_group.py index c1859475b..2bd19aaba 100644 --- a/api/v1/pages/permission_manage/permission_group.py +++ b/api/v1/pages/permission_manage/permission_group.py @@ -1 +1,98 @@ -# 权限分组 \ No newline at end of file +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'permission_group' +name = '权限分组' + + +page = pages.TreePage(tag=tag,name=name) +group_permissions_page = pages.TablePage(name=_("组内权限")) +edit_permissions_page = pages.TablePage(name=_("更新组内权限")) + +edit_page = pages.FormPage(name=_("编辑权限分组")) + + +pages.register_front_pages(page) +pages.register_front_pages(group_permissions_page) +pages.register_front_pages(edit_permissions_page) + +pages.register_front_pages(edit_page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_groups/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/permission_groups/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/permission_groups/{id}/", + ) + ], + node_actions=[ + actions.CascadeAction( + page=group_permissions_page + ) + ] +) + +group_permissions_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_groups/{permission_group_id}/permissions/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + "update":actions.OpenAction( + name=_("添加权限"), + page=edit_permissions_page, + ) + }, + local_actions=[ + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/permission_groups/{permission_group_id}/permissions/{id}/", + icon="icon-delete", + ) + ], +) + + +edit_permissions_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_groups/{permission_group_id}/select_permissions/', + method=actions.FrontActionMethod.GET, + ), + select=True, + global_actions={ + 'confirm': actions.ConfirmAction( + path="/tenant/{tenant_id}/permission_groups/{permission_group_id}/permissions/" + ), + } +) + + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permission_groups/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/permission_groups/{id}/" + ), + } +) + + diff --git a/api/v1/pages/permission_manage/permission_list.py b/api/v1/pages/permission_manage/permission_list.py index 587ae1a18..d5db8955e 100644 --- a/api/v1/pages/permission_manage/permission_list.py +++ b/api/v1/pages/permission_manage/permission_list.py @@ -1 +1,54 @@ -# 权限列表 \ No newline at end of file +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'permission_list' +name = '权限列表' + + +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑权限")) + + +pages.register_front_pages(page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permissions/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/permissions/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/permissions/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/permissions/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/permissions/{id}/" + ), + } +) + + diff --git a/api/v1/pages/platform_admin/__init__.py b/api/v1/pages/platform_admin/__init__.py index e69de29bb..3b97d0a6c 100644 --- a/api/v1/pages/platform_admin/__init__.py +++ b/api/v1/pages/platform_admin/__init__.py @@ -0,0 +1,13 @@ +from arkid.core import routers +from arkid.core.translation import gettext_default as _ +from . import extension_admin,language_admin,tenant_admin + +router = routers.FrontRouter( + path='platform_admin', + name=_('平台管理'), + children=[ + extension_admin.router, + language_admin.router, + tenant_admin.router + ] +) \ No newline at end of file diff --git a/api/v1/pages/platform_admin/extension_admin.py b/api/v1/pages/platform_admin/extension_admin.py index e69de29bb..9dedaef6e 100644 --- a/api/v1/pages/platform_admin/extension_admin.py +++ b/api/v1/pages/platform_admin/extension_admin.py @@ -0,0 +1,55 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'extension_admin' +name = '插件管理' + + +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑插件")) + + +pages.register_front_pages(page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/extensions/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/extensions/', + ) + }, + local_actions=[ + # 加载/卸载 插件 TODO + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/extensions/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/extensions/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/extensions/{id}/" + ), + } +) + + diff --git a/api/v1/pages/platform_admin/language_admin.py b/api/v1/pages/platform_admin/language_admin.py index e69de29bb..2cb5b0358 100644 --- a/api/v1/pages/platform_admin/language_admin.py +++ b/api/v1/pages/platform_admin/language_admin.py @@ -0,0 +1,37 @@ +from arkid.core.translation import gettext_default as _ +from arkid.core import routers, pages, actions + +tag = 'language_admin' +name = '语言包管理' + +page = pages.TablePage(tag = tag, name = name) +detail_page = pages.DescriptionPage(name=_("语言包详情")) + +pages.register_front_pages(page) +pages.register_front_pages(detail_page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/languages/', + method=actions.FrontActionMethod.GET, + ), + local_actions=[ + actions.OpenAction( + name=_("查阅"), + page=detail_page + ) + ] +) + +detail_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/languages/', + method=actions.FrontActionMethod.GET, + ) +) \ No newline at end of file diff --git a/api/v1/pages/platform_admin/tenant_admin.py b/api/v1/pages/platform_admin/tenant_admin.py index 20ca9801d..4fe5b4b45 100644 --- a/api/v1/pages/platform_admin/tenant_admin.py +++ b/api/v1/pages/platform_admin/tenant_admin.py @@ -1 +1,77 @@ -# 所有租户列表/租户开关 \ No newline at end of file +# 所有租户列表/租户开关 +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'tenant_admin' +name = '租户管理' + +page = pages.TabsPage(name=name,tag=tag) +platform_config_page = pages.FormPage(name=_("平台配置")) +tenant_list_page = pages.TablePage(name=_("租户管理")) +edit_page = pages.FormPage(name=_("编辑租户")) + + +pages.register_front_pages(page) +pages.register_front_pages(tenant_list_page) +pages.register_front_pages(platform_config_page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.add_pages( + [ + tenant_list_page, + platform_config_page + ] +) + +platform_config_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/platform_config/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/platform_config/" + ), + } +) + +tenant_list_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenants/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenants/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenants/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenants/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenants/{id}/" + ), + } +) + + diff --git a/api/v1/pages/tenant_manage/__init__.py b/api/v1/pages/tenant_manage/__init__.py index e69de29bb..4291fd457 100644 --- a/api/v1/pages/tenant_manage/__init__.py +++ b/api/v1/pages/tenant_manage/__init__.py @@ -0,0 +1,14 @@ +from arkid.core import routers +from arkid.core.translation import gettext_default as _ +from . import center_arkid,child_manager,tenant_config,extension_manage + +router = routers.FrontRouter( + path='tenant_manage', + name=_('租户管理'), + children=[ + center_arkid.router, + child_manager.router, + tenant_config.router, + extension_manage.router + ] +) \ No newline at end of file diff --git a/api/v1/pages/tenant_manage/center_arkid.py b/api/v1/pages/tenant_manage/center_arkid.py index 7a8842d7e..a0dd4ffc6 100644 --- a/api/v1/pages/tenant_manage/center_arkid.py +++ b/api/v1/pages/tenant_manage/center_arkid.py @@ -1 +1,28 @@ -# 中心平台 \ No newline at end of file +# 中心平台 + +from arkid.core import routers, pages, actions + +tag = 'center_arkid' +name = '中心平台' + +page = pages.FormPage(tag = tag, name = name) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page +) + +page.create_actions( + init_action=actions.DirectAction( + path="/api/v1/tenant/{tenant_id}/center_arkid/", + method=actions.FrontActionMethod.GET, + ), + global_actions = { + "confirm": actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/center_arkid/" + ), + } +) \ No newline at end of file diff --git a/api/v1/pages/tenant_manage/child_manager.py b/api/v1/pages/tenant_manage/child_manager.py index e69de29bb..50c699b7d 100644 --- a/api/v1/pages/tenant_manage/child_manager.py +++ b/api/v1/pages/tenant_manage/child_manager.py @@ -0,0 +1,54 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'child_manager' +name = '子管理员' + + +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑子管理员")) + + +pages.register_front_pages(page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/child_managers/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/child_managers/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/child_managers/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/child_managers/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/child_managers/{id}/" + ), + } +) + + diff --git a/api/v1/pages/tenant_manage/extension_manage.py b/api/v1/pages/tenant_manage/extension_manage.py index e69de29bb..3073758df 100644 --- a/api/v1/pages/tenant_manage/extension_manage.py +++ b/api/v1/pages/tenant_manage/extension_manage.py @@ -0,0 +1,55 @@ +# 租户下的 extension的settings config +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'tenant_extension_manage' +name = '插件管理' + + +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑插件")) + + +pages.register_front_pages(page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/extensions/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/extensions/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/extensions/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/extensions/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/extensions/{id}/" + ), + } +) + + diff --git a/api/v1/pages/tenant_manage/tenant_config.py b/api/v1/pages/tenant_manage/tenant_config.py index e69de29bb..33262978f 100644 --- a/api/v1/pages/tenant_manage/tenant_config.py +++ b/api/v1/pages/tenant_manage/tenant_config.py @@ -0,0 +1,26 @@ +from arkid.core import routers, pages, actions + +tag = 'tenant_config' +name = '租户配置' + +page = pages.FormPage(tag = tag, name = name) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page +) + +page.create_actions( + init_action=actions.DirectAction( + path="/api/v1/tenant/{tenant_id}/tenant_config/", + method=actions.FrontActionMethod.GET, + ), + global_actions = { + "confirm": actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/tenant_config/" + ), + } +) \ No newline at end of file diff --git a/api/v1/pages/user_manage/__init__.py b/api/v1/pages/user_manage/__init__.py index fd183e8bc..0bd2079b1 100644 --- a/api/v1/pages/user_manage/__init__.py +++ b/api/v1/pages/user_manage/__init__.py @@ -1,4 +1,4 @@ -from . import user_list +from . import user_list,user_group,devices,account_life from arkid.core import routers @@ -8,5 +8,8 @@ icon='user', children=[ user_list.router, + user_group.router, + devices.router, + account_life.router ], ) \ No newline at end of file diff --git a/api/v1/pages/user_manage/account_life.py b/api/v1/pages/user_manage/account_life.py index e69de29bb..16bce9859 100644 --- a/api/v1/pages/user_manage/account_life.py +++ b/api/v1/pages/user_manage/account_life.py @@ -0,0 +1,54 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'account_life' +name = '账号生命周期' + + +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑账号生命周期设置")) + + +pages.register_front_pages(page) +pages.register_front_pages(edit_page) + + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/account_lifes/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/account_lifes/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/account_lifes/{id}/", + ) + ], +) + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/account_lifes/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/account_lifes/{id}/" + ), + } +) + + diff --git a/api/v1/pages/user_manage/devices.py b/api/v1/pages/user_manage/devices.py index e69de29bb..8d4de09d9 100644 --- a/api/v1/pages/user_manage/devices.py +++ b/api/v1/pages/user_manage/devices.py @@ -0,0 +1,23 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'devices' +name = '设备管理' + + +page = pages.TablePage(tag=tag, name=name) + +pages.register_front_pages(page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/devices/', + method=actions.FrontActionMethod.GET, + ), +) \ No newline at end of file diff --git a/api/v1/pages/user_manage/user_group.py b/api/v1/pages/user_manage/user_group.py index e69de29bb..6b5858ce6 100644 --- a/api/v1/pages/user_manage/user_group.py +++ b/api/v1/pages/user_manage/user_group.py @@ -0,0 +1,98 @@ +from arkid.core import routers, pages, actions +from arkid.core.translation import gettext_default as _ + +tag = 'user_group' +name = '用户分组' + + +page = pages.TreePage(tag=tag,name=name) +group_users_page = pages.TablePage(name=_("组内用户")) +edit_users_page = pages.TablePage(name=_("更新组内用户")) + +edit_page = pages.FormPage(name=_("编辑用户分组")) + + +pages.register_front_pages(page) +pages.register_front_pages(group_users_page) +pages.register_front_pages(edit_users_page) + +pages.register_front_pages(edit_page) + +router = routers.FrontRouter( + path=tag, + name=name, + page=page, +) + +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/user_groups/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/user_groups/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, + ), + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/user_groups/{id}/", + ) + ], + node_actions=[ + actions.CascadeAction( + page=group_users_page + ) + ] +) + +group_users_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/user_groups/{user_group_id}/users/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + "update":actions.OpenAction( + name=_("添加用户"), + page=edit_users_page, + ) + }, + local_actions=[ + actions.DeleteAction( + path="/api/v1/tenant/{tenant_id}/user_groups/{user_group_id}/users/{id}/", + icon="icon-delete", + ) + ], +) + + +edit_users_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/user_groups/{user_group_id}/select_users/', + method=actions.FrontActionMethod.GET, + ), + select=True, + global_actions={ + 'confirm': actions.ConfirmAction( + path="/tenant/{tenant_id}/user_groups/{user_group_id}/users/" + ), + } +) + + +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/user_groups/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/user_groups/{id}/" + ), + } +) + + diff --git a/api/v1/pages/user_manage/user_list.py b/api/v1/pages/user_manage/user_list.py index 2d1c97b74..5ba487fa0 100644 --- a/api/v1/pages/user_manage/user_list.py +++ b/api/v1/pages/user_manage/user_list.py @@ -1,115 +1,55 @@ -from arkid.core import routers, pages +from arkid.core import routers, pages, actions from arkid.core.translation import gettext_default as _ -user_list_tag = 'user_list' -user_list_name = '用户列表' +tag = 'user_list' +name = '用户列表' -page = pages.TablePage( - tag=user_list_tag, - name=user_list_name, - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/users/', - method=pages.FrontActionMethod.GET - ) -) +page = pages.TablePage(tag=tag, name=name) +edit_page = pages.FormPage(name=_("编辑用户")) -user_edit_page = pages.FormPage( - name=_("编辑用户"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/users/{id}/', - method=pages.FrontActionMethod.GET - ) -) -user_edit_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/users/{id}/", - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] -) +pages.register_front_pages(page) +pages.register_front_pages(edit_page) -user_create_page = pages.FormPage( - name=_("创建一个新的用户"), - init_action=pages.FrontAction( - path='/api/v1/tenant/{tenant_id}/users/', - method=pages.FrontActionMethod.POST - ) -) -user_create_page.add_global_action( - [ - pages.FrontAction( - method=pages.FrontActionMethod.POST, - name=_("确认"), - path="/api/v1/tenant/{tenant_id}/users/", - action_type=pages.FrontActionType.DIRECT_ACTION, - icon="icon-confirm" - ), - pages.FrontAction( - name=_("取消"), - action_type=pages.FrontActionType.CANCEL_ACTION, - icon="icon-cancel" - ), - pages.FrontAction( - name=_("重置"), - action_type=pages.FrontActionType.RESET_ACTION, - icon="icon-reset" - ), - ] +router = routers.FrontRouter( + path=tag, + name=name, + icon='user', + page=page, ) -page.add_local_action( - [ - pages.FrontAction( - name=_("编辑"), - page=user_edit_page, - icon="icon-edit", - action_type=pages.FrontActionType.OPEN_ACTION +page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/users/', + method=actions.FrontActionMethod.GET, + ), + global_actions={ + 'create': actions.CreateAction( + path='/api/v1/tenant/{tenant_id}/users/', + ) + }, + local_actions=[ + actions.EditAction( + page=edit_page, ), - pages.FrontAction( - name=_("删除"), - method=pages.FrontActionMethod.DELETE, + actions.DeleteAction( path="/api/v1/tenant/{tenant_id}/users/{id}/", - icon="icon-delete", - action_type=pages.FrontActionType.DIRECT_ACTION ) - ] + ], ) -page.add_global_action( - [ - pages.FrontAction( - name="创建", - page=user_create_page, - icon="icon-create", - action_type=pages.FrontActionType.OPEN_ACTION - ) - ] +edit_page.create_actions( + init_action=actions.DirectAction( + path='/api/v1/tenant/{tenant_id}/users/{id}/', + method=actions.FrontActionMethod.GET + ), + global_actions={ + 'confirm': actions.ConfirmAction( + path="/api/v1/tenant/{tenant_id}/users/{id}/" + ), + } ) -router = routers.FrontRouter( - path=user_list_tag, - name='用户管理', - icon='user', - page=page, -) - -pages.register_front_pages(page) -pages.register_front_pages(user_create_page) -pages.register_front_pages(user_edit_page) \ No newline at end of file diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index b6c697d70..354446ee2 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -15,6 +15,21 @@ auto_auth, third_auth, permission_sync, + permission_rule, + permission, scim_sync, + webhook, send_sms, + tenant, + account_life, + app_protocol, + center_arkid, + bi_system, + child_manager, + permission_group, + platform_config, + devices, + user_group, + languape, + log, ) diff --git a/api/v1/views/account_life.py b/api/v1/views/account_life.py new file mode 100644 index 000000000..962cdf798 --- /dev/null +++ b/api/v1/views/account_life.py @@ -0,0 +1,35 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/account_lifes/", tags=["账号生命周期"],auth=None) +def get_account_life_list(request, tenant_id: str): + """ 账号生命周期配置列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/account_lifes/{id}/", tags=["账号生命周期"],auth=None) +def get_account_life(request, tenant_id: str, id: str): + """ 获取账号生命周期配置,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/account_lifes/", tags=["账号生命周期"],auth=None) +def create_account_life(request, tenant_id: str): + """ 创建账号生命周期配置,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/account_lifes/{id}/", tags=["账号生命周期"],auth=None) +def update_account_life(request, tenant_id: str, id: str): + """ 编辑账号生命周期配置,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/account_lifes/{id}/", tags=["账号生命周期"],auth=None) +def delete_account_life(request, tenant_id: str, id: str): + """ 删除账号生命周期配置,TODO + """ + return {} + + diff --git a/api/v1/views/app.py b/api/v1/views/app.py index ba76b9ab8..e5c5b11f4 100644 --- a/api/v1/views/app.py +++ b/api/v1/views/app.py @@ -51,7 +51,7 @@ class Config: @transaction.atomic -@api.post("/{tenant_id}/apps", response=AppConfigSchemaOut, tags=['应用'], auth=None) +@api.post("/tenant/{tenant_id}/apps/", response=AppConfigSchemaOut, tags=['应用'], auth=None) def create_app(request, tenant_id: str, data: AppConfigSchemaIn): ''' app创建 @@ -79,7 +79,7 @@ def create_app(request, tenant_id: str, data: AppConfigSchemaIn): break return {"app_id": app.id.hex} -@api.get("/{tenant_id}/apps", response=List[AppListSchemaOut], tags=['应用'], auth=None) +@api.get("/tenant/{tenant_id}/apps/", response=List[AppListSchemaOut], tags=['应用'], auth=None) @paginate def list_apps(request, tenant_id: str): ''' @@ -90,7 +90,7 @@ def list_apps(request, tenant_id: str): ) return apps -@api.get("/{tenant_id}/apps/{app_id}", response=AppSchemaOut, tags=['应用'], auth=None) +@api.get("/tenant/{tenant_id}/apps/{app_id}/", response=AppSchemaOut, tags=['应用'], auth=None) def get_app(request, tenant_id: str, app_id: str): ''' 获取app @@ -109,7 +109,7 @@ def get_app(request, tenant_id: str, app_id: str): } return result -@api.delete("/{tenant_id}/apps/{app_id}", tags=['应用']) +@api.delete("/tenant/{tenant_id}/apps/{app_id}/", tags=['应用'], auth=None) def delete_app(request, tenant_id: str, app_id: str): ''' 删除app @@ -123,7 +123,7 @@ def delete_app(request, tenant_id: str, app_id: str): app.delete() return {'error': ErrorCode.OK.value} -@api.put("/{tenant_id}/apps/{app_id}", tags=['应用'], auth=None) +@api.put("/tenant/{tenant_id}/apps/{app_id}/", tags=['应用'], auth=None) def update_app(request, tenant_id: str, app_id: str, data: AppConfigSchemaIn): ''' 修改app @@ -148,3 +148,9 @@ def update_app(request, tenant_id: str, app_id: str, data: AppConfigSchemaIn): extension.update_tenant_config(app.config.id, data.config.dict()) break return {'error': ErrorCode.OK.value} + +@api.get("/tenant/{tenant_id}/apps/{app_id}/permissions/",tags=["应用"],auth=None) +def get_app_permissions(request, tenant_id: str,app_id:str): + """ 应用权限列表,TODO + """ + return [] \ No newline at end of file diff --git a/api/v1/views/app_group.py b/api/v1/views/app_group.py index c618ce640..8fcb5a49b 100644 --- a/api/v1/views/app_group.py +++ b/api/v1/views/app_group.py @@ -1,45 +1,147 @@ -from arkid.core.api import api +from typing import List +from ninja import Field, ModelSchema, Query, Schema +from requests import Response +from arkid.core.api import api,operation +from arkid.core.models import AppGroup from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/app_groups/", tags=[_("应用分组")]) -def get_app_groups(request, tenant_id: str): +class AppGroupListQueryIn(Schema): + pass + +class AppGroupListOut(ModelSchema): + class Config: + model = AppGroup + model_fields = ["name"] + +@api.get("/tenant/{tenant_id}/app_groups/", response=List[AppGroupListOut],tags=["应用分组"],auth=None) +@operation(List[AppGroupListOut]) +def get_app_groups(request, tenant_id: str, query_data: AppGroupListQueryIn=Query(...)): """ 应用分组列表,TODO """ - return [] + groups = AppGroup.expand_objects.filter(tenant__id=tenant_id).all() + return groups -@api.get("/tenant/{tenant_id}/app_groups/{id}/", tags=[_("应用分组")]) -def get_app_group(request, tenant_id: str, id: str): +class AppGroupQueryIn(Schema): + pass + +class AppGroupOut(ModelSchema): + class Config: + model = AppGroup + model_fields = ["name"] + +@api.get("/tenant/{tenant_id}/app_groups/{id}/", response=AppGroupOut, tags=["应用分组"],auth=None) +@operation(AppGroupOut) +def get_app_group(request, tenant_id: str, id: str, query_data: AppGroupQueryIn=Query(...)): """ 获取应用分组,TODO """ return {} -@api.post("/tenant/{tenant_id}/app_groups/", tags=[_("应用分组")]) -def create_app_group(request, tenant_id: str): +class AppGroupCreateIn(ModelSchema): + class Config: + model = AppGroup + model_fields = ["name"] + +class AppGroupCreateQueryIn(Schema): + pass + +class AppGroupCreateOut(Schema): + pass + +@api.post("/tenant/{tenant_id}/app_groups/", response=AppGroupCreateOut, tags=["应用分组"],auth=None) +@operation(AppGroupCreateOut) +def create_app_group(request, tenant_id: str, data: AppGroupCreateIn, query_data: AppGroupCreateQueryIn=Query(...)): """ 创建应用分组,TODO """ + group = AppGroup.expand_objects.create(**data) + return {} -@api.put("/tenant/{tenant_id}/app_groups/{id}/", tags=[_("应用分组")]) -def update_app_group(request, tenant_id: str, id: str): + +class AppGroupUpdateIn(ModelSchema): + class Config: + model = AppGroup + model_fields = ["name"] + +class AppGroupUpdateQueryIn(Schema): + pass + +class AppGroupUpdateOut(Schema): + pass + +@api.put("/tenant/{tenant_id}/app_groups/{id}/", response=AppGroupUpdateOut,tags=["应用分组"],auth=None) +@operation(AppGroupUpdateOut) +def update_app_group(request, tenant_id: str, id: str,data: AppGroupUpdateIn, query_data: AppGroupUpdateQueryIn=Query(...)): """ 编辑应用分组,TODO """ return {} -@api.delete("/tenant/{tenant_id}/app_groups/{id}/", tags=[_("应用分组")]) -def delete_app_group(request, tenant_id: str, id: str): +class AppGroupDeleteQueryIn(Schema): + pass + +class AppGroupDeleteOut(Schema): + pass + +@api.delete("/tenant/{tenant_id}/app_groups/{id}/", response=AppGroupDeleteOut, tags=["应用分组"],auth=None) +@operation(AppGroupDeleteOut) +def delete_app_group(request, tenant_id: str, id: str,query_data: AppGroupDeleteQueryIn=Query(...)): """ 删除应用分组,TODO """ return {} -@api.get("/tenant/{tenant_id}/app_groups/{app_group_id}/apps/", tags=[_("应用分组")]) -def get_apps_from_group(request, tenant_id: str, group_id: str): +class GroupAppsQueryIn(Schema): + pass + +class GroupAppsOut(Schema): + pass + +@api.get("/tenant/{tenant_id}/app_groups/{app_group_id}/apps/",response=List[GroupAppsOut],tags=["应用分组"],auth=None) +@operation(List[GroupAppsOut]) +def get_apps_from_group(request, tenant_id: str, app_group_id: str, query_data: GroupAppsQueryIn=Query(...)): + """ 获取当前分组的应用列表,TODO + """ + return [] + +class GroupAppRemoveQueryIn(Schema): + pass + +class GroupAppRemoveOut(Schema): + pass + +@api.delete("/tenant/{tenant_id}/app_groups/{app_group_id}/apps/{id}/",response=GroupAppRemoveOut, tags=["应用分组"],auth=None) +@operation(GroupAppRemoveOut) +def remove_app_from_group(request, tenant_id: str, app_group_id: str,id:str, query_data: GroupAppRemoveQueryIn=Query(...)): """ 将应用移除出应用分组,TODO """ return {} -@api.delete("/tenant/{tenant_id}/app_groups/{app_group_id}/apps/{id}/", tags=[_("应用分组")]) -def remove_app_from_group(request, tenant_id: str, app_group_id: str,id:str): - """ 将应用移除出应用分组,TODO +class GroupAppUpdateIn(Schema): + pass + +class GroupAppUpdateQueryIn(Schema): + pass + +class GroupAppUpdateOut(Schema): + pass + +@api.post("/tenant/{tenant_id}/app_groups/{app_group_id}/apps/", response=GroupAppUpdateOut,tags=["应用分组"],auth=None) +@operation(GroupAppUpdateOut) +def update_apps_from_group(request, tenant_id: str, app_group_id: str,data: GroupAppUpdateIn, query_data: GroupAppUpdateQueryIn=Query(...)): + """ 更新当前分组的应用列表,TODO + """ + return {} + +class GroupAllAppQueryIn(Schema): + pass + +class GroupAllAppOut(Schema): + pass + +@api.get("/tenant/{tenant_id}/app_groups/{app_group_id}/select_apps/",response=List[GroupAllAppOut], tags=["应用分组"],auth=None) +@operation(List[GroupAllAppOut]) +def get_select_apps(request, tenant_id: str, app_group_id: str, query_data: GroupAllAppQueryIn=Query(...)): + """ 获取所有应用并附加是否在当前分组的状态,TODO """ - return {} \ No newline at end of file + return {} + + diff --git a/api/v1/views/app_protocol.py b/api/v1/views/app_protocol.py new file mode 100644 index 000000000..2ac85ebdb --- /dev/null +++ b/api/v1/views/app_protocol.py @@ -0,0 +1,9 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/app_protocols/", tags=["应用协议"],auth=None) +def get_app_protocols(request, tenant_id: str): + """ 应用协议列表,TODO + """ + return [] \ No newline at end of file diff --git a/api/v1/views/approve_action.py b/api/v1/views/approve_action.py index 571fe5af1..5d0c08d6f 100644 --- a/api/v1/views/approve_action.py +++ b/api/v1/views/approve_action.py @@ -2,31 +2,31 @@ from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/approve_actions/", tags=[_("审批动作")]) +@api.get("/tenant/{tenant_id}/approve_actions/", tags=["审批动作"],auth=None) def get_approve_actions(request, tenant_id: str): """ 审批动作列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/approve_actions/{id}/", tags=[_("审批动作")]) +@api.get(operation_id="",path="/tenant/{tenant_id}/approve_actions/{id}/", tags=["审批动作"],auth=None) def get_approve_action(request, tenant_id: str, id: str): """ 获取审批动作,TODO """ return {} -@api.post("/tenant/{tenant_id}/approve_actions/", tags=[_("审批动作")]) +@api.post("/tenant/{tenant_id}/approve_actions/", tags=["审批动作"],auth=None) def create_approve_action(request, tenant_id: str): """ 创建审批动作,TODO """ return {} -@api.put("/tenant/{tenant_id}/approve_actions/{id}/", tags=[_("审批动作")]) +@api.put("/tenant/{tenant_id}/approve_actions/{id}/", tags=["审批动作"],auth=None) def update_approve_action(request, tenant_id: str, id: str): """ 编辑审批动作,TODO """ return {} -@api.delete("/tenant/{tenant_id}/approve_actions/{id}/", tags=[_("审批动作")]) +@api.delete("/tenant/{tenant_id}/approve_actions/{id}/", tags=["审批动作"],auth=None) def delete_approve_action(request, tenant_id: str, id: str): """ 删除审批动作,TODO """ diff --git a/api/v1/views/auth_fator.py b/api/v1/views/auth_fator.py index cce6bd149..fc1b3b479 100644 --- a/api/v1/views/auth_fator.py +++ b/api/v1/views/auth_fator.py @@ -20,7 +20,7 @@ class AuthFatorSchemaOut(Schema): config_id: str @transaction.atomic -@api.post("/{tenant_id}/auth_fator/", response=AuthFatorSchemaOut, tags=['认证因素'], auth=None) +@api.post("/{tenant_id}/auth_fators/", response=AuthFatorSchemaOut, tags=['认证因素'], auth=None) def create_auth_fator(request, tenant_id: str, data: AuthFatorSchemaIn): config = TenantExtensionConfig() config.tenant = request.tenant @@ -36,8 +36,27 @@ def create_auth_fator(request, tenant_id: str, data: AuthFatorSchemaIn): class AuthFatorListSchemaOut(Schema): data: List[AuthFatorListSchemaItem] -@api.get("/{tenant_id}/auth_fator/", response=AuthFatorListSchemaOut, tags=['认证因素'], auth=None) +@api.get("/{tenant_id}/auth_fators/", response=AuthFatorListSchemaOut, tags=['认证因素'], auth=None) def get_auth_fator_list(request, tenant_id: str): extensions = Extension.active_objects.filter(type=AuthFactorExtension.TYPE).all() configs = TenantExtensionConfig.active_objects.filter(extension__in=extensions) - return {"data": configs} \ No newline at end of file + return {"data": configs} + +@api.get("/tenant/{tenant_id}/auth_fators/{id}/", tags=["认证因素"],auth=None) +def get_auth_fator(request, tenant_id: str, id: str): + """ 获取认证因素,TODO + """ + return {} + + +@api.put("/tenant/{tenant_id}/auth_fators/{id}/", tags=["认证因素"],auth=None) +def update_auth_fator(request, tenant_id: str, id: str): + """ 编辑认证因素,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/auth_fators/{id}/", tags=["认证因素"],auth=None) +def delete_auth_fator(request, tenant_id: str, id: str): + """ 删除认证因素,TODO + """ + return {} diff --git a/api/v1/views/auth_rules.py b/api/v1/views/auth_rules.py index 8df8771e5..cb5ca90ed 100644 --- a/api/v1/views/auth_rules.py +++ b/api/v1/views/auth_rules.py @@ -2,31 +2,31 @@ from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/auth_rules/", tags=[_("认证规则")]) +@api.get("/tenant/{tenant_id}/auth_rules/", tags=["认证规则"],auth=None) def get_auth_rules(request, tenant_id: str): """ 认证规则列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/auth_rules/{id}/", tags=[_("认证规则")]) +@api.get("/tenant/{tenant_id}/auth_rules/{id}/", tags=["认证规则"],auth=None) def get_auth_rule(request, tenant_id: str, id: str): """ 获取认证规则,TODO """ return {} -@api.post("/tenant/{tenant_id}/auth_rules/", tags=[_("认证规则")]) +@api.post("/tenant/{tenant_id}/auth_rules/", tags=["认证规则"],auth=None) def create_auth_rule(request, tenant_id: str): """ 创建认证规则,TODO """ return {} -@api.put("/tenant/{tenant_id}/auth_rules/{id}/", tags=[_("认证规则")]) +@api.put("/tenant/{tenant_id}/auth_rules/{id}/", tags=["认证规则"],auth=None) def update_auth_rule(request, tenant_id: str, id: str): """ 编辑认证规则,TODO """ return {} -@api.delete("/tenant/{tenant_id}/auth_rules/{id}/", tags=[_("认证规则")]) +@api.delete("/tenant/{tenant_id}/auth_rules/{id}/", tags=["认证规则"],auth=None) def delete_auth_rule(request, tenant_id: str, id: str): """ 删除认证规则,TODO """ diff --git a/api/v1/views/auto_auth.py b/api/v1/views/auto_auth.py index 854affcc4..a6077666b 100644 --- a/api/v1/views/auto_auth.py +++ b/api/v1/views/auto_auth.py @@ -2,31 +2,31 @@ from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/auto_auths/", tags=[_("自动认证")]) +@api.get("/tenant/{tenant_id}/auto_auths/", tags=["自动认证"],auth=None) def get_auto_auths(request, tenant_id: str): """ 自动认证列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/auto_auths/{id}/", tags=[_("自动认证")]) +@api.get("/tenant/{tenant_id}/auto_auths/{id}/", tags=["自动认证"],auth=None) def get_auto_auth(request, tenant_id: str, id: str): """ 获取自动认证,TODO """ return {} -@api.post("/tenant/{tenant_id}/auto_auths/", tags=[_("自动认证")]) +@api.post("/tenant/{tenant_id}/auto_auths/", tags=["自动认证"],auth=None) def create_auto_auth(request, tenant_id: str): """ 创建自动认证,TODO """ return {} -@api.put("/tenant/{tenant_id}/auto_auths/{id}/", tags=[_("自动认证")]) +@api.put("/tenant/{tenant_id}/auto_auths/{id}/", tags=["自动认证"],auth=None) def update_auto_auth(request, tenant_id: str, id: str): """ 编辑自动认证,TODO """ return {} -@api.delete("/tenant/{tenant_id}/auto_auths/{id}/", tags=[_("自动认证")]) +@api.delete("/tenant/{tenant_id}/auto_auths/{id}/", tags=["自动认证"],auth=None) def delete_auto_auth(request, tenant_id: str, id: str): """ 删除自动认证,TODO """ diff --git a/api/v1/views/bi_system.py b/api/v1/views/bi_system.py new file mode 100644 index 000000000..e774ef92c --- /dev/null +++ b/api/v1/views/bi_system.py @@ -0,0 +1,35 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/bi_systems/", tags=["BI系统"],auth=None) +def get_bi_systems(request, tenant_id: str): + """ BI系统列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/bi_systems/{id}/", tags=["BI系统"],auth=None) +def get_bi_system(request, tenant_id: str, id: str): + """ 获取BI系统,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/bi_systems/", tags=["BI系统"],auth=None) +def create_bi_system(request, tenant_id: str): + """ 创建BI系统,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/bi_systems/{id}/", tags=["BI系统"],auth=None) +def update_bi_system(request, tenant_id: str, id: str): + """ 编辑BI系统,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/bi_systems/{id}/", tags=["BI系统"],auth=None) +def delete_bi_system(request, tenant_id: str, id: str): + """ 删除BI系统,TODO + """ + return {} + + diff --git a/api/v1/views/center_arkid.py b/api/v1/views/center_arkid.py new file mode 100644 index 000000000..2b1bc2bd8 --- /dev/null +++ b/api/v1/views/center_arkid.py @@ -0,0 +1,14 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + +@api.get("/tenant/{tenant_id}/center_arkid/", tags=["中心平台"],auth=None) +def get_center_arkid(request, tenant_id: str): + """ 获取中心平台配置,TODO + """ + return [] + +@api.post("/tenant/{tenant_id}/center_arkid/", tags=["中心平台"],auth=None) +def update_center_arkid(request, tenant_id: str): + """ 更新中心平台配置,TODO + """ + return [] \ No newline at end of file diff --git a/api/v1/views/child_manager.py b/api/v1/views/child_manager.py new file mode 100644 index 000000000..6781cfdcd --- /dev/null +++ b/api/v1/views/child_manager.py @@ -0,0 +1,35 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/child_managers/", tags=["子管理员"],auth=None) +def get_child_managers(request, tenant_id: str): + """ 子管理员列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/child_managers/{id}/", tags=["子管理员"],auth=None) +def get_child_manager(request, tenant_id: str, id: str): + """ 获取子管理员,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/child_managers/", tags=["子管理员"],auth=None) +def create_child_manager(request, tenant_id: str): + """ 创建子管理员,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/child_managers/{id}/", tags=["子管理员"],auth=None) +def update_child_manager(request, tenant_id: str, id: str): + """ 编辑子管理员,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/child_managers/{id}/", tags=["子管理员"],auth=None) +def delete_child_manager(request, tenant_id: str, id: str): + """ 删除子管理员,TODO + """ + return {} + + diff --git a/api/v1/views/devices.py b/api/v1/views/devices.py new file mode 100644 index 000000000..7cea05fa9 --- /dev/null +++ b/api/v1/views/devices.py @@ -0,0 +1,9 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/devices/", tags=["设备管理"],auth=None) +def get_device_list(request, tenant_id: str): + """ 设备管理列表,TODO + """ + return [] \ No newline at end of file diff --git a/api/v1/views/extension.py b/api/v1/views/extension.py index 0f6b57242..97df2a850 100644 --- a/api/v1/views/extension.py +++ b/api/v1/views/extension.py @@ -52,13 +52,15 @@ def get_extension_profile(request, extension_id: str): extension = ExtensionModel.objects.filter(id=extension_id).first() return extension -# @api.get("/extensions", response=List[ExtensionOut]) -# def list_extensions(request, status: str = None): -# if not status: -# qs = Extension.active_objects.filter(user=request.user) -# else: -# qs = Extension.active_objects.filter(user=request.user, status=status) -# return qs +@api.get("/extensions/", tags=['平台插件']) +def list_extensions(request, status: str = None): + """ 获取平台插件列表 TODO + """ + if not status: + qs = Extension.active_objects.filter(user=request.user) + else: + qs = Extension.active_objects.filter(user=request.user, status=status) + return qs # @operation(roles=["tenant-user", "platform-user"]) @@ -96,8 +98,20 @@ def get_extension_profile(request, extension_id: str): # return {"success": True} -# @api.delete("/extensions/{extension_id}") -# def delete_extension(request, extension_id: str): -# extension = get_object_or_404(Extension, uuid=extension_id) -# extension.delete() -# return {"success": True} \ No newline at end of file +@api.delete("/extensions/{id}/",tags=['平台插件']) +def delete_extension(request, id: str): + """ 删除平台插件 TODO + """ + return {"success": True} + +@api.post("/extensions/{id}/",tags=['平台插件']) +def update_extension(request, id: str): + """ 更新平台插件 TODO + """ + return {"success": True} + +@api.get("/extensions/{id}/",tags=['平台插件']) +def get_extension(request, id: str): + """ 获取平台插件信息 TODO + """ + return {"success": True} \ No newline at end of file diff --git a/api/v1/views/languape.py b/api/v1/views/languape.py new file mode 100644 index 000000000..b565d1794 --- /dev/null +++ b/api/v1/views/languape.py @@ -0,0 +1,8 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + +@api.get("/languages/",tags=['语言包']) +def get_language_list(request): + """ 获取语言包列表 TODO + """ + return [] \ No newline at end of file diff --git a/api/v1/views/log.py b/api/v1/views/log.py new file mode 100644 index 000000000..7c1225d68 --- /dev/null +++ b/api/v1/views/log.py @@ -0,0 +1,33 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/manager_log/", tags=["日志管理"],auth=None) +def get_manager_logs(request, tenant_id: str): + """ 获取租户管理员行为日志,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/user_log/", tags=["日志管理"],auth=None) +def get_user_logs(request, tenant_id: str): + """ 获取用户行为日志,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/log/{id}/", tags=["日志管理"],auth=None) +def get_log(request, tenant_id: str,id:str): + """ 获取日志详情,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/log_config/", tags=["日志管理"],auth=None) +def get_log_config(request, tenant_id: str): + """ 获取日志配置,TODO + """ + return [] + +@api.post("/tenant/{tenant_id}/log_config/", tags=["日志管理"],auth=None) +def update_log_config(request, tenant_id: str): + """ 更新日志配置,TODO + """ + return [] diff --git a/api/v1/views/mine.py b/api/v1/views/mine.py index 97074d278..81bed2710 100644 --- a/api/v1/views/mine.py +++ b/api/v1/views/mine.py @@ -1,39 +1,78 @@ +from typing import List +from django.shortcuts import render +from ninja import ModelSchema, Schema from arkid.core.api import api +from arkid.core.models import Tenant from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/mine/apps/",tags=[_("我的")]) +@api.get("/mine/tenant/{tenant_id}/apps/",tags=["我的"],auth=None) def get_mine_apps(request, tenant_id: str): """ 我的应用列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/mine/profile/",tags=[_("我的")]) +@api.get("/mine/tenant/{tenant_id}/profile/",tags=["我的"],auth=None) def get_mine_profile(request, tenant_id: str): """ 我的个人资料,TODO """ return {} -@api.get("/tenant/{tenant_id}/mine/permissions/",tags=[_("我的")]) +@api.post("/mine/tenant/{tenant_id}/profile/",tags=["我的"],auth=None) +def update_mine_profile(request, tenant_id: str): + """ 更新我的个人资料,TODO + """ + return {} + +@api.get("/mine/tenant/{tenant_id}/permissions/",tags=["我的"],auth=None) def get_mine_permissions(request, tenant_id: str): """ 我的权限列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/mine/approves/",tags=[_("我的")]) +@api.post("/mine/tenant/{tenant_id}/permissions/",tags=["我的"],auth=None) +def update_mine_permissions(request, tenant_id: str): + """ 更新我的权限列表,TODO + """ + return [] + +@api.get("/mine/tenant/{tenant_id}/all_permissions/",tags=["我的"],auth=None) +def get_mine_all_permissions(request, tenant_id: str): + """ 获取所有权限并附带是否已授权给我的状态,TODO + """ + return [] + +@api.get("/mine/tenant/{tenant_id}/approves/",tags=["我的"],auth=None) def get_mine_approves(request, tenant_id: str): """ 我的审批列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/mine/switch_tenant/",tags=[_("我的")]) -def get_mine_switch_tenant(request, tenant_id: str): +@api.get("/mine/switch_tenant/{id}/",tags=["我的"],auth=None) +def get_mine_switch_tenant(request,id): """ 租户开关,TODO """ - return {} + context = {} + tenant = Tenant.active_objects.get(id=id) + context['tenant_id'] = id + context['slug'] = tenant.slug + + return render(request,template_name='switch_tenant.html', context=context) -@api.get("/tenant/{tenant_id}/mine/logout/",tags=[_("我的")]) -def get_mine_logout(request, tenant_id: str): +@api.get("/mine/logout/",tags=["我的"],auth=None) +def get_mine_logout(request): """ 退出登录,TODO """ - return {} \ No newline at end of file + return {} + +class MineTenantsOut(ModelSchema): + class Config: + model = Tenant + model_fields=["id","name","slug","icon"] + +@api.get("/mine/tenants/",response=List[MineTenantsOut],tags=["我的"],auth=None) +def get_mine_tenants(request): + """ 获取我的租户,TODO + """ + tenants = Tenant.active_objects.all() + return tenants \ No newline at end of file diff --git a/api/v1/views/permission.py b/api/v1/views/permission.py new file mode 100644 index 000000000..38a2f07f2 --- /dev/null +++ b/api/v1/views/permission.py @@ -0,0 +1,35 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/permissions/", tags=["权限"],auth=None) +def get_permissions(request, tenant_id: str): + """ 权限列表,TODO + """ + return [] + +@api.get(operation_id="",path="/tenant/{tenant_id}/permissions/{id}/", tags=["权限"],auth=None) +def get_permission(request, tenant_id: str, id: str): + """ 获取权限,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/permissions/", tags=["权限"],auth=None) +def create_permission(request, tenant_id: str): + """ 创建权限,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/permissions/{id}/", tags=["权限"],auth=None) +def update_permission(request, tenant_id: str, id: str): + """ 编辑权限,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/permissions/{id}/", tags=["权限"],auth=None) +def delete_permission(request, tenant_id: str, id: str): + """ 删除权限,TODO + """ + return {} + + diff --git a/api/v1/views/permission_group.py b/api/v1/views/permission_group.py new file mode 100644 index 000000000..c9597b6ab --- /dev/null +++ b/api/v1/views/permission_group.py @@ -0,0 +1,59 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/permission_groups/", tags=["权限分组"],auth=None) +def get_permission_groups(request, tenant_id: str): + """ 权限分组列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/permission_groups/{id}/", tags=["权限分组"],auth=None) +def get_permission_group(request, tenant_id: str, id: str): + """ 获取权限分组,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/permission_groups/", tags=["权限分组"],auth=None) +def create_permission_group(request, tenant_id: str): + """ 创建权限分组,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/permission_groups/{id}/", tags=["权限分组"],auth=None) +def update_permission_group(request, tenant_id: str, id: str): + """ 编辑权限分组,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/permission_groups/{id}/", tags=["权限分组"],auth=None) +def delete_permission_group(request, tenant_id: str, id: str): + """ 删除权限分组,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/permission_groups/{permission_group_id}/permissions/", tags=["权限分组"],auth=None) +def get_permissions_from_group(request, tenant_id: str, permission_group_id: str): + """ 获取当前分组的权限列表,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/permission_groups/{permission_group_id}/permissions/{id}/", tags=["权限分组"],auth=None) +def remove_permission_from_group(request, tenant_id: str, permission_group_id: str,id:str): + """ 将权限移除出权限分组,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/permission_groups/{permission_group_id}/permissions/", tags=["权限分组"],auth=None) +def update_permissions_from_group(request, tenant_id: str, permission_group_id: str): + """ 更新当前分组的权限列表,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/permission_groups/{permission_group_id}/select_permissions/", tags=["权限分组"],auth=None) +def get_select_permissions(request, tenant_id: str, permission_group_id: str): + """ 获取所有权限并附加是否在当前分组的状态,TODO + """ + return {} + + diff --git a/api/v1/views/permission_rule.py b/api/v1/views/permission_rule.py new file mode 100644 index 000000000..ee0660bae --- /dev/null +++ b/api/v1/views/permission_rule.py @@ -0,0 +1,35 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/permission_rules/", tags=["授权规则"],auth=None) +def get_permission_rules(request, tenant_id: str): + """ 授权规则列表,TODO + """ + return [] + +@api.get(operation_id="",path="/tenant/{tenant_id}/permission_rules/{id}/", tags=["授权规则"],auth=None) +def get_permission_rule(request, tenant_id: str, id: str): + """ 获取授权规则,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/permission_rules/", tags=["授权规则"],auth=None) +def create_permission_rule(request, tenant_id: str): + """ 创建授权规则,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/permission_rules/{id}/", tags=["授权规则"],auth=None) +def update_permission_rule(request, tenant_id: str, id: str): + """ 编辑授权规则,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/permission_rules/{id}/", tags=["授权规则"],auth=None) +def delete_permission_rule(request, tenant_id: str, id: str): + """ 删除授权规则,TODO + """ + return {} + + diff --git a/api/v1/views/permission_sync.py b/api/v1/views/permission_sync.py index 8ca7ad1eb..aff0cdeab 100644 --- a/api/v1/views/permission_sync.py +++ b/api/v1/views/permission_sync.py @@ -2,37 +2,37 @@ from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/permission_syncs/", tags=[_("权限数据同步配置")]) +@api.get("/tenant/{tenant_id}/permission_syncs/", tags=["权限数据同步配置"],auth=None) def get_permission_syncs(request, tenant_id: str): """ 权限数据同步配置列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/permission_syncs/{id}/", tags=[_("权限数据同步配置")]) +@api.get("/tenant/{tenant_id}/permission_syncs/{id}/", tags=["权限数据同步配置"],auth=None) def get_permission_sync(request, tenant_id: str, id: str): """ 获取权限数据同步配置,TODO """ return {} -@api.post("/tenant/{tenant_id}/permission_syncs/", tags=[_("权限数据同步配置")]) +@api.post("/tenant/{tenant_id}/permission_syncs/", tags=["权限数据同步配置"],auth=None) def create_permission_sync(request, tenant_id: str): """ 创建权限数据同步配置,TODO """ return {} -@api.put("/tenant/{tenant_id}/permission_syncs/{id}/", tags=[_("权限数据同步配置")]) +@api.put("/tenant/{tenant_id}/permission_syncs/{id}/", tags=["权限数据同步配置"],auth=None) def update_permission_sync(request, tenant_id: str, id: str): """ 编辑权限数据同步配置,TODO """ return {} -@api.delete("/tenant/{tenant_id}/permission_syncs/{id}/", tags=[_("权限数据同步配置")]) +@api.delete("/tenant/{tenant_id}/permission_syncs/{id}/", tags=["权限数据同步配置"],auth=None) def delete_permission_sync(request, tenant_id: str, id: str): """ 删除权限数据同步配置,TODO """ return {} -@api.get("/tenant/{tenant_id}/permission_syncs/{id}/sync/", tags=[_("权限数据同步配置")]) +@api.get("/tenant/{tenant_id}/permission_syncs/{id}/sync/", tags=["权限数据同步配置"],auth=None) def permission_sync(request, tenant_id: str, id: str): """ 同步权限数据,TODO """ diff --git a/api/v1/views/platform_config.py b/api/v1/views/platform_config.py new file mode 100644 index 000000000..1797a173e --- /dev/null +++ b/api/v1/views/platform_config.py @@ -0,0 +1,14 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + +@api.get("/platform_config/", tags=["平台配置"],auth=None) +def get_platform_config(request): + """ 获取平台配置,TODO + """ + return {} + +@api.post("/platform_config/", tags=["平台配置"],auth=None) +def update_platform_config(request): + """ 更新平台配置,TODO + """ + return {} \ No newline at end of file diff --git a/api/v1/views/scim_sync.py b/api/v1/views/scim_sync.py index b4a3141cb..a35a4b0d3 100644 --- a/api/v1/views/scim_sync.py +++ b/api/v1/views/scim_sync.py @@ -2,37 +2,37 @@ from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/scim_syncs/", tags=[_("用户数据同步配置")]) +@api.get("/tenant/{tenant_id}/scim_syncs/", tags=["用户数据同步配置"],auth=None) def get_scim_syncs(request, tenant_id: str): """ 用户数据同步配置列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/scim_syncs/{id}/", tags=[_("用户数据同步配置")]) +@api.get("/tenant/{tenant_id}/scim_syncs/{id}/", tags=["用户数据同步配置"],auth=None) def get_scim_sync(request, tenant_id: str, id: str): """ 获取用户数据同步配置,TODO """ return {} -@api.post("/tenant/{tenant_id}/scim_syncs/", tags=[_("用户数据同步配置")]) +@api.post("/tenant/{tenant_id}/scim_syncs/", tags=["用户数据同步配置"],auth=None) def create_scim_sync(request, tenant_id: str): """ 创建用户数据同步配置,TODO """ return {} -@api.put("/tenant/{tenant_id}/scim_syncs/{id}/", tags=[_("用户数据同步配置")]) +@api.put("/tenant/{tenant_id}/scim_syncs/{id}/", tags=["用户数据同步配置"],auth=None) def update_scim_sync(request, tenant_id: str, id: str): """ 编辑用户数据同步配置,TODO """ return {} -@api.delete("/tenant/{tenant_id}/scim_syncs/{id}/", tags=[_("用户数据同步配置")]) +@api.delete("/tenant/{tenant_id}/scim_syncs/{id}/", tags=["用户数据同步配置"],auth=None) def delete_scim_sync(request, tenant_id: str, id: str): """ 删除用户数据同步配置,TODO """ return {} -@api.get("/tenant/{tenant_id}/scim_syncs/{id}/sync/", tags=[_("用户数据同步配置")]) +@api.get("/tenant/{tenant_id}/scim_syncs/{id}/sync/", tags=["用户数据同步配置"],auth=None) def scim_sync(request, tenant_id: str, id: str): """ 同步权限数据,TODO """ diff --git a/api/v1/views/tenant.py b/api/v1/views/tenant.py new file mode 100644 index 000000000..2b8cb1347 --- /dev/null +++ b/api/v1/views/tenant.py @@ -0,0 +1,118 @@ +from typing import List +from ninja import Field, ModelSchema, Query, Schema +from arkid.core.api import api, operation +from arkid.core.models import Tenant +from arkid.core.translation import gettext_default as _ + +class TenantListQueryIn(Schema): + name:str = Field( + default=None, + ) + +class TenantListOut(ModelSchema): + class Config: + model = Tenant + model_fields = ["id","name", "slug", "icon"] + +@api.get("/tenants/", response=List[TenantListOut],tags=["租户管理"],auth=None) +# @operation(List[TenantListOut]) +def get_tenant_list(request, query_data:TenantListQueryIn=Query(...)): + """ 获取租户列表 + """ + + tenants = Tenant.active_objects.all() + + return tenants + +class TenantOut(ModelSchema): + class Config: + model = Tenant + model_fields = ["id","name"] + +@api.get("/tenants/{id}/", response=TenantOut,tags=["租户管理"],auth=None) +@operation(TenantOut) +def get_tenant(request, id: str): + """ 获取租户 + """ + tenant = Tenant.active_objects.get(id=id) + return tenant + +class TenantCreateIn(ModelSchema): + class Config: + model = Tenant + model_fields = ["name","slug","icon"] + +class TenantCreateOut(Schema): + pass + +@api.post("/tenants/",response=TenantCreateOut,tags=["租户管理"],auth=None) +def create_tenant(request, data:TenantCreateIn): + """ 创建租户 + """ + + tenant = Tenant.valid_objects.create(**data.dict()) + + return {} + +class TenantUpdateIn(ModelSchema): + class Config: + model = Tenant + model_fields = ["name"] + +class TenantUpdateOut(Schema): + pass + +@api.post("/tenants/{id}/", response=TenantUpdateOut,tags=["租户管理"],auth=None) +@operation(TenantUpdateOut) +def update_tenant(request, id: str, data:TenantUpdateIn): + """ 编辑租户 + """ + tenant = Tenant.active_objects.get(id=id) + tenant.name = data.dict().get("name") + tenant.save() + return {} + +class TenantDeleteQueryIn(Schema): + pass + +class TenantDeleteOut(Schema): + pass + +@api.delete("/tenants/{id}/", response=TenantDeleteOut, tags=["租户管理"],auth=None) +@operation(TenantDeleteOut) +def delete_tenant(request, id: str, query_data:TenantDeleteQueryIn=Query(...)): + """ 删除租户 + """ + tenant = Tenant.active_objects.get(id=id) + tenant.delete() + return {} + + +class TenantConfigQueryIn(Schema): + pass + +class TenantConfigOut(Schema): + pass + +@api.get("/tenants/{id}/config/", response=TenantConfigOut, tags=["租户管理"],auth=None) +@operation(TenantConfigOut) +def get_tenant_config(request, id: str,query_data:TenantConfigQueryIn=Query(...)): + """ 获取租户配置,TODO + """ + return {} + +class TenantConfigUpdateQueryIn(Schema): + pass + +class TenantConfigUpdateIn(Schema): + pass + +class TenantConfigUpdateOut(Schema): + pass + +@api.post("/tenants/{id}/config/", response=TenantConfigUpdateOut,tags=["租户管理"],auth=None) +@operation(TenantConfigUpdateOut) +def update_tenant_config(request, id: str,data:TenantConfigUpdateIn,query_data:TenantConfigUpdateQueryIn=Query(...)): + """ 编辑租户配置,TODO + """ + return {} \ No newline at end of file diff --git a/api/v1/views/tenant_extension.py b/api/v1/views/tenant_extension.py index 45d406c91..dab791f55 100644 --- a/api/v1/views/tenant_extension.py +++ b/api/v1/views/tenant_extension.py @@ -7,6 +7,7 @@ from arkid.core.extension import Extension from arkid.extension.models import TenantExtensionConfig, TenantExtension from arkid.core.schema import RootSchema +from arkid.core.translation import gettext_default as _ ExtensionConfigSchemaIn = Extension.create_config_schema( 'ExtensionConfigSchemaIn', @@ -102,3 +103,21 @@ def create_extension_settings(request, tenant_id: str, extension_id: str, data: # extension = get_object_or_404(Extension, uuid=extension_id) # extension.delete() # return {"success": True} + +@api.get("/tenant/{tenant_id}/extensions/", tags=["租户插件"],auth=None) +def get_extensions(request, tenant_id: str): + """ 租户插件列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/extensions/{id}/", tags=["租户插件"],auth=None) +def get_extension(request, tenant_id: str, id: str): + """ 获取租户插件,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/extensions/{id}/", tags=["租户插件"],auth=None) +def delete_extension(request, tenant_id: str, id: str): + """ 删除租户插件,TODO + """ + return {} \ No newline at end of file diff --git a/api/v1/views/third_auth.py b/api/v1/views/third_auth.py index e7174105b..0a943f368 100644 --- a/api/v1/views/third_auth.py +++ b/api/v1/views/third_auth.py @@ -2,31 +2,31 @@ from arkid.core.translation import gettext_default as _ -@api.get("/tenant/{tenant_id}/third_auths/", tags=[_("第三方认证")]) +@api.get("/tenant/{tenant_id}/third_auths/", tags=["第三方认证"],auth=None) def get_third_auths(request, tenant_id: str): """ 第三方认证列表,TODO """ return [] -@api.get("/tenant/{tenant_id}/third_auths/{id}/", tags=[_("第三方认证")]) +@api.get("/tenant/{tenant_id}/third_auths/{id}/", tags=["第三方认证"],auth=None) def get_third_auth(request, tenant_id: str, id: str): """ 获取第三方认证,TODO """ return {} -@api.post("/tenant/{tenant_id}/third_auths/", tags=[_("第三方认证")]) +@api.post("/tenant/{tenant_id}/third_auths/", tags=["第三方认证"],auth=None) def create_third_auth(request, tenant_id: str): """ 创建第三方认证,TODO """ return {} -@api.put("/tenant/{tenant_id}/third_auths/{id}/", tags=[_("第三方认证")]) +@api.put("/tenant/{tenant_id}/third_auths/{id}/", tags=["第三方认证"],auth=None) def update_third_auth(request, tenant_id: str, id: str): """ 编辑第三方认证,TODO """ return {} -@api.delete("/tenant/{tenant_id}/third_auths/{id}/", tags=[_("第三方认证")]) +@api.delete("/tenant/{tenant_id}/third_auths/{id}/", tags=["第三方认证"],auth=None) def delete_third_auth(request, tenant_id: str, id: str): """ 删除第三方认证,TODO """ diff --git a/api/v1/views/user.py b/api/v1/views/user.py index 0d1f9b780..dec05f4ca 100644 --- a/api/v1/views/user.py +++ b/api/v1/views/user.py @@ -11,18 +11,20 @@ # ------------- 用户列表接口 -------------- -class UserListInSchema(Schema): - pass +class UserListQueryIn(Schema): + name:str = Field( + default=None + ) -class UserListOutSchema(ModelSchema): +class UserListOut(ModelSchema): class Config: model = User model_fields = ['id', 'username', 'avatar', 'is_platform_user'] -@api.get("/tenant/{tenant_id}/users/",response=List[UserListOutSchema], tags=['用户'], auth=None) -@operation(List[UserListOutSchema]) -def user_list(request, tenant_id: str,data: UserListInSchema=Query(...)): - users = User.expand_objects.filter(tenant__id=tenant_id).all() +@api.get("/tenant/{tenant_id}/users/",response=List[UserListOut], tags=['用户'], auth=None) +@operation(List[UserListOut]) +def user_list(request, tenant_id: str, query_data: UserListQueryIn=Query(...)): + users = User.expand_objects.all() return users # ------------- 创建用户接口 -------------- @@ -149,4 +151,29 @@ class Config: @operation(UserOutSchema) def user_list(request, tenant_id: str,id:str,data: UserInSchema=Query(...)): user = User.expand_objects.get(tenant__id=tenant_id,id=id) - return user \ No newline at end of file + return user + + +@api.get("/tenant/{tenant_id}/users/{user_id}/permissions/",tags=["用户"],auth=None) +def get_user_permissions(request, tenant_id: str,user_id:str): + """ 用户权限列表,TODO + """ + return [] + +@api.post("/tenant/{tenant_id}/users/{user_id}/permissions/",tags=["用户"],auth=None) +def update_user_permissions(request, tenant_id: str,user_id:str): + """ 更新用户权限列表,TODO + """ + return [] + +@api.delete("/tenant/{tenant_id}/users/{user_id}/permissions/{id}/",tags=["用户"],auth=None) +def delete_user_permissions(request, tenant_id: str,user_id:str,id:str): + """ 删除用户权限,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/users/{user_id}/all_permissions/",tags=["用户"],auth=None) +def get_user_all_permissions(request, tenant_id: str,user_id:str): + """ 获取所有权限并附带是否已授权给用户状态,TODO + """ + return [] \ No newline at end of file diff --git a/api/v1/views/user_group.py b/api/v1/views/user_group.py new file mode 100644 index 000000000..876967e9b --- /dev/null +++ b/api/v1/views/user_group.py @@ -0,0 +1,80 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + +@api.get("/tenant/{tenant_id}/user_groups/", tags=["用户分组"],auth=None) +def get_user_groups(request, tenant_id: str): + """ 用户分组列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/user_groups/{id}/", tags=["用户分组"],auth=None) +def get_user_group(request, tenant_id: str, id: str): + """ 获取用户分组,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/user_groups/", tags=["用户分组"],auth=None) +def create_user_group(request, tenant_id: str): + """ 创建用户分组,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/user_groups/{id}/", tags=["用户分组"],auth=None) +def update_user_group(request, tenant_id: str, id: str): + """ 编辑用户分组,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/user_groups/{id}/", tags=["用户分组"],auth=None) +def delete_user_group(request, tenant_id: str, id: str): + """ 删除用户分组,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/user_groups/{user_group_id}/users/", tags=["用户分组"],auth=None) +def get_users_from_group(request, tenant_id: str, user_group_id: str): + """ 获取当前分组的用户列表,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/user_groups/{user_group_id}/users/{id}/", tags=["用户分组"],auth=None) +def remove_user_from_group(request, tenant_id: str, user_group_id: str,id:str): + """ 将用户移除出用户分组,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/user_groups/{user_group_id}/users/", tags=["用户分组"],auth=None) +def update_users_from_group(request, tenant_id: str, user_group_id: str): + """ 更新当前分组的用户列表,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/user_groups/{user_group_id}/select_users/", tags=["用户分组"],auth=None) +def get_select_users(request, tenant_id: str, user_group_id: str): + """ 获取所有用户并附加是否在当前分组的状态,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/user_groups/{user_group_id}/permissions/",tags=["用户分组"],auth=None) +def get_user_group_permissions(request, tenant_id: str,user_group_id:str): + """ 用户分组权限列表,TODO + """ + return [] + +@api.post("/tenant/{tenant_id}/user_groups/{user_group_id}/permissions/",tags=["用户分组"],auth=None) +def update_user_group_permissions(request, tenant_id: str,user_group_id:str): + """ 更新用户分组权限列表,TODO + """ + return [] + +@api.delete("/tenant/{tenant_id}/user_groups/{user_group_id}/permissions/{id}/",tags=["用户分组"],auth=None) +def delete_user_group_permissions(request, tenant_id: str,user_group_id:str,id:str): + """ 删除用户分组权限,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/user_groups/{user_group_id}/all_permissions/",tags=["用户分组"],auth=None) +def get_user_group_all_permissions(request, tenant_id: str,user_group_id:str): + """ 获取所有权限并附带是否已授权给用户分组状态,TODO + """ + return [] \ No newline at end of file diff --git a/api/v1/views/webhook.py b/api/v1/views/webhook.py new file mode 100644 index 000000000..4a296890b --- /dev/null +++ b/api/v1/views/webhook.py @@ -0,0 +1,69 @@ +from arkid.core.api import api +from arkid.core.translation import gettext_default as _ + + +@api.get("/tenant/{tenant_id}/webhooks/", tags=["Webhook"],auth=None) +def get_webhooks(request, tenant_id: str): + """ Webhook列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/webhooks/{id}/", tags=["Webhook"],auth=None) +def get_webhook(request, tenant_id: str, id: str): + """ 获取Webhook,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/webhooks/", tags=["Webhook"],auth=None) +def create_webhook(request, tenant_id: str): + """ 创建Webhook,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/webhooks/{id}/", tags=["Webhook"],auth=None) +def update_webhook(request, tenant_id: str, id: str): + """ 编辑Webhook,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/webhooks/{id}/", tags=["Webhook"],auth=None) +def delete_webhook(request, tenant_id: str, id: str): + """ 删除Webhook,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/webhooks/{webhook_id}/histories/", tags=["Webhook"],auth=None) +def get_webhook_histories(request, tenant_id: str, webhook_id: str): + """ 获取Webhook历史记录列表,TODO + """ + return [] + +@api.get("/tenant/{tenant_id}/webhooks/{webhook_id}/histories/{id}/", tags=["Webhook"],auth=None) +def get_webhook_history(request, tenant_id: str, webhook_id: str, id:str): + """ 获取Webhook历史记录,TODO + """ + return {} + +@api.post("/tenant/{tenant_id}/webhooks/{webhook_id}/histories/", tags=["Webhook"],auth=None) +def create_webhook_history(request, tenant_id: str, webhook_id: str): + """ 创建Webhook历史记录,TODO + """ + return {} + +@api.put("/tenant/{tenant_id}/webhooks/{webhook_id}/histories/{id}/", tags=["Webhook"],auth=None) +def update_webhook_history(request, tenant_id: str, webhook_id: str, id: str): + """ 编辑Webhook历史记录,TODO + """ + return {} + +@api.delete("/tenant/{tenant_id}/webhooks/{webhook_id}/histories/{id}/", tags=["Webhook"],auth=None) +def delete_webhook_history(request, tenant_id: str, webhook_id: str, id: str): + """ 删除Webhook历史记录,TODO + """ + return {} + +@api.get("/tenant/{tenant_id}/webhooks/{webhook_id}/histories/{id}/retry/", tags=["Webhook"],auth=None) +def retry_webhook_history(request, tenant_id: str, webhook_id: str, id:str): + """ 重试webhook历史记录,TODO + """ + return {} diff --git a/arkid/common/__init__.py b/arkid/common/__init__.py index 33c15c258..3d31e8b90 100644 --- a/arkid/common/__init__.py +++ b/arkid/common/__init__.py @@ -5,13 +5,16 @@ class DeepSN(SimpleNamespace): def dict(self): _data = {} for key,val in self.__dict__.items(): - if isinstance(val,DeepSN): _data[key] = val.dict() elif isinstance(val,list): _data[key] = [ item.dict() if isinstance(item,DeepSN) else item for item in val ] + elif isinstance(val,dict): + _data[key] = {} + for k,v in val.items(): + _data[key][k] = v.dict() if isinstance(v,DeepSN) else v else: _data[key] = val return _data \ No newline at end of file diff --git a/arkid/common/utils.py b/arkid/common/utils.py index d456153c8..4e8768ad6 100644 --- a/arkid/common/utils.py +++ b/arkid/common/utils.py @@ -2,6 +2,7 @@ from copy import deepcopy from functools import reduce from typing import Dict, List +from uuid import uuid4 def deep_merge(*dicts: List[Dict], update=False) -> Dict: @@ -178,3 +179,20 @@ def get_request_tenant(request): # 能够注册平台用户了 tenant = Tenant.active_objects.filter(id=1).first() return tenant + +global_tags = [] +def gen_tag(tag: str = None, tag_pre: str = None) -> str: + """ 生成tag + + Args: + tag (str, optional): tag字符串,可指定亦可动态生成. + tag_pre (str, optional): tag前缀,一般可为插件名称或者其他. + + Returns: + str: tag字符串 + """ + tag = tag if tag else uuid4().hex + tag = f"{tag_pre}_{tag}" if tag_pre else tag + assert tag not in global_tags + global_tags.append(tag) + return tag \ No newline at end of file diff --git a/arkid/core/actions.py b/arkid/core/actions.py new file mode 100644 index 000000000..715ef894e --- /dev/null +++ b/arkid/core/actions.py @@ -0,0 +1,216 @@ +from enum import Enum +from typing import Union, Tuple +from arkid.common import DeepSN +from arkid.common.utils import gen_tag +from arkid.core.translation import gettext_default as _ + + +class FrontActionType(Enum): + """前端动作类型枚举类 + + ActionType操作类型 [可扩展]: + ``` + - direct 直接操作类型 + - open 打开新页面类型 + - cancel 取消操作类型 + - reset 重置表单类型 + - import 导入数据类型 + - node 节点点击类型(页面中将隐藏该操作) + - url 内外链接类型 + - password 编辑密码类型 + - cascade 级联类型 + ``` + """ + + DIRECT_ACTION = 'direct' + OPEN_ACTION = 'open' + CANCEL_ACTION = 'cancel' + RESET_ACTION = 'reset' + IMPORT_ACTION = 'import' + URL_ACTION = 'url' + PASSWORD_ACTION = 'password' + CASCADE_ACTION = 'cascade' + + +class FrontActionMethod(Enum): + """ 前端动作类型枚举类 + + ActionMethod 动作方法 [可扩展]: + + ``` + - get + - post + - put + - delete + ``` + """ + + GET = 'get' + POST = 'post' + PUT = 'put' + DELETE = 'delete' + + +class FrontAction(DeepSN): + """ 前端页面动作类 + + Examples: + >>> from arkid.core import pages + >>> from arkid.core.translation import gettext_default as _ + >>> + >>> edit_action = pages.FrontAction( + >>> name=_("编辑"), + >>> page=user_edit_page, + >>> icon="icon-edit", + >>> action_type=pages.FrontActionType.OPEN_ACTION + >>> ) + >>> delete_action = pages.FrontAction( + >>> name=_("删除"), + >>> method=pages.FrontActionMethod.DELETE, + >>> path="/api/v1/tenant/{tenant_id}/users/{id}/", + >>> icon="icon-delete", + >>> action_type=pages.FrontActionType.DIRECT_ACTION + >>> ) + """ + + def __init__(self, action_type: FrontActionType, tag: str = None, path: str = None, method: FrontActionMethod = None, + name: str = None, page=None, page_tag=None, icon: str = None, tag_pre: str = None, *args, **kwargs): + """初始化函数 + + Args: + tag (str, optional): 标识. + action_type (FrontActionType): 动作类型. + name (str, optional): 名称. + page (FrontPage|str, optional): 指向页面,此处存储页面的标识. + path (str, optional): 请求路径. + method (FrontActionMethod, optional): 请求方法. + icon (str, optional): 图标名称. + tag_pre (str, optional): 标识前缀. + """ + self.type = action_type.value + + self.tag = gen_tag(tag, tag_pre) + + if name: + self.name = name + if page: + self.page = page.tag + # 指向page的tag + if page_tag: + self.page = page_tag + if path: + self.path = path + if method: + self.method = method.value + if icon: + self.icon = icon + + super().__init__(*args, **kwargs) + + def add_tag_pre(self, tag_pre: str): + """ 添加标识前缀 + + Args: + tag_pre (str): 标识前缀 + """ + self.tag = gen_tag(self.tag, tag_pre) + + +class DirectAction(FrontAction): + def __init__(self, *args, **kwargs): + super().__init__(action_type=FrontActionType.DIRECT_ACTION, *args, **kwargs) + + +class OpenAction(FrontAction): + def __init__(self, *args, **kwargs): + super().__init__(action_type=FrontActionType.OPEN_ACTION, *args, **kwargs) + + +class ImportAction(FrontAction): + def __init__(self, *args, **kwargs): + super().__init__(action_type=FrontActionType.IMPORT_ACTION, *args, **kwargs) + + +class URLAction(FrontAction): + def __init__(self, *args, **kwargs): + super().__init__(action_type=FrontActionType.URL_ACTION, *args, **kwargs) + + +class PasswordAction(FrontAction): + def __init__(self, *args, **kwargs): + super().__init__(action_type=FrontActionType.PASSWORD_ACTION, *args, **kwargs) + +class CascadeAction(FrontAction): + def __init__(self, page, *args, **kwargs): + super().__init__(action_type=FrontActionType.CASCADE_ACTION, page=page, *args, **kwargs) + + +class ConfirmAction(DirectAction): + def __init__(self, path: str, *args, **kwargs): + self.name = _("确认") + self.path = path + self.icon = "icon-confirm" + self.method = FrontActionMethod.POST.value + super().__init__(*args, **kwargs) + + +class DeleteAction(DirectAction): + def __init__(self, path: str, *args, **kwargs): + self.name = _("删除") + self.method = FrontActionMethod.DELETE.value + self.icon = "icon-delete" + self.path = path + super().__init__(*args, **kwargs) + + +class CreateAction(OpenAction): + def __init__(self, path: str, *args, **kwargs): + self.name = _("创建") + self.icon = "icon-create" + self.method = FrontActionMethod.POST.value + self.path = path + super().__init__(*args, **kwargs) + + +class EditAction(OpenAction): + def __init__(self, page, *args, **kwargs): + self.name = _("编辑") + self.icon = "icon-edit" + super().__init__(page=page, *args, **kwargs) + + + + +nav_actions = {} + + +def register_nav_actions(actions): + """注册前端页面 + + Args: + pages (List|FrontPage): 前端页面 + """ + if not isinstance(actions, tuple) or not isinstance(actions, list): + actions = [actions] + + for action in actions: + nav_actions[action.tag] = action + + +def unregister_nav_actions(actions): + """卸载页面 + + Args: + pages (List|FrontPage): 前端页面 + """ + if not isinstance(actions, tuple) or not isinstance(actions, list): + actions = [actions] + + for action in actions: + nav_actions.pop(action.tag) + + +def get_nav_actions(): + """获取页面列表 + """ + return [item.dict() for item in list(nav_actions.values())] diff --git a/arkid/core/extension/__init__.py b/arkid/core/extension/__init__.py index 5e136e533..0548aaa5a 100644 --- a/arkid/core/extension/__init__.py +++ b/arkid/core/extension/__init__.py @@ -276,7 +276,7 @@ def register_languge(self, lang_code:str = 'en', lang_maps={}): core_translation.extension_lang_maps[lang_code][self.name] = lang_maps core_translation.lang_maps = core_translation.reset_lang_maps() - def register_front_routers(self, router, primary=''): + def register_front_routers(self, router, primary:core_routers.FrontRouter=None): """ primary: 一级路由名字,由 core_routers 文件提供定义 """ diff --git a/arkid/core/openapi.py b/arkid/core/openapi.py index cab256091..822fff269 100644 --- a/arkid/core/openapi.py +++ b/arkid/core/openapi.py @@ -1,7 +1,7 @@ from typing import Optional from ninja.openapi.schema import OpenAPISchema from ninja.openapi import get_schema -from arkid.core import routers, pages, translation +from arkid.core import routers, pages, translation, actions def get_openapi_schema(self, path_prefix: Optional[str] = None) -> OpenAPISchema: @@ -10,6 +10,7 @@ def get_openapi_schema(self, path_prefix: Optional[str] = None) -> OpenAPISchema schema = get_schema(api=self, path_prefix=path_prefix) schema["routers"] = routers.get_global_routers() schema["pages"] = pages.get_global_pages() + # schema["navs"] = actions.get_nav_actions() # permissions = get_permissions(self) # schema["permissions"] = permissions diff --git a/arkid/core/operation.py b/arkid/core/operation.py new file mode 100644 index 000000000..2eca5afdf --- /dev/null +++ b/arkid/core/operation.py @@ -0,0 +1,4 @@ +operation_list = {} +def get_operation(path, method): + operation_list[path+method] = False + return path, method \ No newline at end of file diff --git a/arkid/core/pages.py b/arkid/core/pages.py index d4c6ac610..74ec3dbb0 100644 --- a/arkid/core/pages.py +++ b/arkid/core/pages.py @@ -1,22 +1,24 @@ - -from collections import OrderedDict -from uuid import uuid4 from enum import Enum +from typing import List from arkid.common import DeepSN +from arkid.common.utils import gen_tag +from arkid.core.actions import FrontAction +from arkid.core.translation import gettext_default as _ global_pages = {} + class FrontPageType(Enum): """前端页面类型枚举类 Type页面类型 [可扩展]: ``` - - 表格型页面 (table) - - 表单型页面 (form) - - 描述型页面 (description) - - 树状型页面 (tree) - - 切换型页面 (tabs)- 暂不支持 - - 列表型页面 (list)- 暂不支持 - - 卡片型页面 (cards)- 暂不支持 - - 网格型页面 (grid)- 暂不支持 + - 表格型页面 (table) + - 表单型页面 (form) + - 描述型页面 (description) + - 树状型页面 (tree) + - 切换型页面 (tabs)- 暂不支持 + - 列表型页面 (list)- 暂不支持 + - 卡片型页面 (cards)- 暂不支持 + - 网格型页面 (grid)- 暂不支持 ``` """ FORM_PAGE = 'form' @@ -28,24 +30,6 @@ class FrontPageType(Enum): CARDS_PAGE = 'cards' GRID_PAGE = 'grid' -global_tags = [] # 全局tag列表 - -def gen_tag(tag:str=None,tag_pre:str=None) -> str: - """ 为页面或者行为生成tag - - Args: - tag (str, optional): tag字符串,可指定亦可动态生成. - tag_pre (str, optional): tag前缀,一般可为插件名称或者其他. - - Returns: - str: tag字符串 - """ - tag = tag if tag else uuid4().hex - tag = f"{tag_pre}_{tag}" if tag_pre else tag - assert tag not in global_tags - global_tags.append(tag) - return tag - class FrontPage(DeepSN): """ 前端页面配置类 @@ -87,226 +71,182 @@ class FrontPage(DeepSN): >>> ] >>> ) """ - def __init__(self, name:str, tag:str=None, tag_pre:str=None, *args, **kwargs): + + def __init__(self, name: str, tag: str = None, tag_pre: str = None, type:FrontPageType=FrontPageType.TABLE_PAGE,*args, **kwargs): """初始化函数 Args: name (str): 页面名称 page_type (FrontPageType): 页面类型 init_action (FrontAction|OrderedDict): 初始化动作 + global_actions (list): 全局动作 + local_actions (list): 本地动作 tag (str, optional): 标识. tag_pre (str, optional): 标识前缀. """ - self.tag = gen_tag(tag,tag_pre) + self.tag = gen_tag(tag, tag_pre) self.name = name + self.type = type.value super().__init__(*args, **kwargs) - - def add_global_action(self, actions): + + def create_actions(self, init_action:FrontAction = None, global_actions: list = [], local_actions: list = [], node_actions:list=[]): + self.init_action = init_action + self.add_global_actions(global_actions) + self.add_local_actions(local_actions) + self.add_node_actions(node_actions) + + def add_global_actions(self, actions): """ 添加全局动作 Args: actions (FrontAction|OrderedDict)): 动作列表 """ - if not isinstance(actions, tuple) or not isinstance(actions, list): - actions = list(actions) - if not hasattr(self,"global_action"): - self.global_action = [] - self.global_action.extend(actions) - - def add_local_action(self, actions): + if not actions: + return + + # if not isinstance(actions, tuple) or not isinstance(actions, list): + # actions = list(actions) + + if not hasattr(self, "global_action"): + self.global_action = {} + + if not isinstance(actions,dict): + actions = { + gen_tag():actions + } + + self.global_action.update(actions) + + def add_local_actions(self, actions): """ 添加表单动作 Args: actions (FrontAction|OrderedDict)): 动作列表 """ + if not actions: + return + if not isinstance(actions, tuple) or not isinstance(actions, list): actions = list(actions) - if not hasattr(self,"local_action"): + if not hasattr(self, "local_action"): self.local_action = [] - self.local_action.extend(actions) - - def add_node_action(self, actions): - """ 添加树节点动作 + self.local_action.extend(actions) + + def add_node_actions(self, actions): + """ 添加表单动作 Args: actions (FrontAction|OrderedDict)): 动作列表 """ + if not actions: + return + if not isinstance(actions, tuple) or not isinstance(actions, list): actions = list(actions) - if not hasattr(self,'node'): - self.node = [] - self.node.extend(actions) + if not hasattr(self, "node_action"): + self.node_action = [] + self.node_action.extend(actions) - def add_tag_pre(self,tag_pre:str): + def add_tag_pre(self, tag_pre: str): """添加标识前缀 - 用于插件中生成页面时给页面的标识添加前缀 - Args: tag_pre (str): 前缀 """ - self.tag = gen_tag(self.tag,tag_pre) + self.tag = gen_tag(self.tag, tag_pre) def dict(self): return super().dict() + +class SelectPage(FrontPage): + """选择型页面 + """ + + def __init__(self, select: bool = False, *args, **kwargs): + if select: + self.select = select + super().__init__(*args, **kwargs) + + def create_actions(self, select:bool=False,*args, **kwargs): + if select: + self.select = select + return super().create_actions(*args, **kwargs) + + class FormPage(FrontPage): """表单页面 """ + def __init__(self, *args, **kwargs): - self.type = FrontPageType.FORM_PAGE.value - super().__init__(*args, **kwargs) + super().__init__(type=FrontPageType.FORM_PAGE, *args, **kwargs) + -class TablePage(FrontPage): +class TablePage(SelectPage): """表格页面 """ + def __init__(self, *args, **kwargs): - self.type = FrontPageType.TABLE_PAGE.value - super().__init__(*args, **kwargs) + super().__init__(type=FrontPageType.TABLE_PAGE, *args, **kwargs) + -class TreePage(FrontPage): +class TreePage(SelectPage): """树形页面 """ def __init__(self, *args, **kwargs): - self.type = FrontPageType.TREE_PAGE.value - super().__init__(*args, **kwargs) + super().__init__(type=FrontPageType.TREE_PAGE, *args, **kwargs) - def set_next(self,next): - self.next = next.tag if isinstance(next,FrontPage) else next class DescriptionPage(FrontPage): """描述页面 """ + def __init__(self, *args, **kwargs): - self.type = FrontPageType.DESCRIPTION_PAGE.value - super().__init__(*args, **kwargs) + super().__init__(type=FrontPageType.DESCRIPTION_PAGE, *args, **kwargs) -class ListPage(FrontPage): + +class ListPage(SelectPage): """列表页面 """ + def __init__(self, *args, **kwargs): - self.type = FrontPageType.LIST_PAGE.value - super().__init__(*args, **kwargs) + super().__init__(type=FrontPageType.LIST_PAGE, *args, **kwargs) + -class CardsPage(FrontPage): +class CardsPage(SelectPage): """卡片列表 """ + def __init__(self, *args, **kwargs): - self.type = FrontPageType.CARDS_PAGE.value - super().__init__(*args, **kwargs) + super().__init__(type=FrontPageType.CARDS_PAGE, *args, **kwargs) + class GridPage(FrontPage): """网格页面 """ - def __init__(self, *args, **kwargs): - self.type = FrontPageType.GRID_PAGE.value - super().__init__(*args, **kwargs) + def __init__(self, *args, **kwargs): + super().__init__(type=FrontPageType.GRID_PAGE, *args, **kwargs) -class FrontActionType(Enum): - """前端动作类型枚举类 - - ActionType操作类型 [可扩展]: - ``` - - direct 直接操作类型 - - open 打开新页面类型 - - cancel 取消操作类型 - - reset 重置表单类型 - - import 导入数据类型 - - node 节点点击类型(页面中将隐藏该操作) - - url 内外链接类型 - - password 编辑密码类型 - ``` - """ - - DIRECT_ACTION = 'direct' - OPEN_ACTION = 'open' - CANCEL_ACTION = 'cancel' - RESET_ACTION = 'reset' - IMPORT_ACTION = 'import' - NODE_ACTION = 'node' - URL_ACTION = 'url' - PASSWORD_ACTION = 'password' - -class FrontActionMethod(Enum): - """ 前端动作类型枚举类 - - ActionMethod 动作方法 [可扩展]: - - ``` - - get - - post - - put - - delete - ``` +class TabsPage(FrontPage): + """网格页面 """ - - GET = 'get' - POST = 'post' - PUT = 'put' - DELETE = 'delete' - -class FrontAction(DeepSN): - """ 前端页面动作类 - - Examples: - >>> from arkid.core import pages - >>> from arkid.core.translation import gettext_default as _ - >>> - >>> edit_action = pages.FrontAction( - >>> name=_("编辑"), - >>> page=user_edit_page, - >>> icon="icon-edit", - >>> action_type=pages.FrontActionType.OPEN_ACTION - >>> ) - >>> delete_action = pages.FrontAction( - >>> name=_("删除"), - >>> method=pages.FrontActionMethod.DELETE, - >>> path="/api/v1/tenant/{tenant_id}/users/{id}/", - >>> icon="icon-delete", - >>> action_type=pages.FrontActionType.DIRECT_ACTION - >>> ) - """ - - def __init__(self, tag:str=None, action_type:FrontActionType=None,name:str=None, page=None, path:str=None, method:FrontActionMethod=None, icon:str=None,tag_pre:str=None, *args, **kwargs): - """初始化函数 + def __init__(self, pages:list=[],*args, **kwargs): + self.add_pages(pages) + super().__init__(type=FrontPageType.TABS_PAGE, *args, **kwargs) - Args: - tag (str, optional): 标识. - action_type (FrontActionType, optional): 动作类型. - name (str, optional): 名称. - page (FrontPage|str, optional): 指向页面,此处存储页面的标识. - path (str, optional): 请求路径. - method (FrontActionMethod, optional): 请求方法. - icon (str, optional): 图标名称. - tag_pre (str, optional): 标识前缀. - """ - self.tag = gen_tag(tag,tag_pre) - - if name: - self.name = name - # 指向page的tag - if page: - self.page = page.tag if isinstance(page,FrontPage) else page - if path: - self.path = path - if method: - self.method = method.value - if icon: - self.icon = icon + def add_pages(self,pages:list=[]): + if not pages: + return - if action_type: - self.type = action_type.value - super().__init__(*args, **kwargs) - - def add_tag_pre(self,tag_pre:str): - """ 添加标识前缀 - - Args: - tag_pre (str): 标识前缀 - """ - self.tag = gen_tag(self.tag,tag_pre) + if not isinstance(pages, tuple) or not isinstance(pages, list): + pages = list(pages) + if not hasattr(self, "pages"): + self.pages = [] + + for item in pages: + self.pages.append(item.tag if isinstance(item,FrontPage) else item) def register_front_pages(pages): """注册前端页面 @@ -316,7 +256,7 @@ def register_front_pages(pages): """ if not isinstance(pages, tuple) or not isinstance(pages, list): pages = [pages] - + for page in pages: global_pages[page.tag] = page @@ -333,7 +273,8 @@ def unregister_front_pages(pages): for page in pages: global_pages.pop(page.tag) + def get_global_pages(): """获取页面列表 """ - return [ item.dict() for item in list(global_pages.values()) ] \ No newline at end of file + return [item.dict() for item in list(global_pages.values())] diff --git a/arkid/core/routers.py b/arkid/core/routers.py index fbedb79fe..eb4d5fe35 100644 --- a/arkid/core/routers.py +++ b/arkid/core/routers.py @@ -57,13 +57,13 @@ def __init__(self, path:str, name:str=None, icon:str=None, children=None, redire self.url = url super().__init__(*args, **kwargs) - def add_child(self, child): + def add_children(self, child): """添加子路由 Args: child (OrderedDict): 子路由描述 """ - if not self.children: + if not hasattr(self,"children"): self.children = [] self.children.append(child) @@ -92,7 +92,7 @@ def change_page_tag(self, header): for child in self.children: child.change_page_tag(header) -def register_front_routers(routers, primary: str = ''): +def register_front_routers(routers, primary: FrontRouter = None): """注册前端路由 Args: @@ -102,15 +102,13 @@ def register_front_routers(routers, primary: str = ''): if not isinstance(routers, tuple) or not isinstance(routers, list): routers = list(routers) - for primary_router in routers: - if primary == primary_router.path: - for router in routers: - primary_router.add_child(router) - return + if primary: + primary.add_children(routers) + return global_routers.extend(routers) -def unregister_front_routers(routers, primary: str = ''): +def unregister_front_routers(routers, primary: FrontRouter = None): """卸载前端路由 Args: @@ -120,12 +118,11 @@ def unregister_front_routers(routers, primary: str = ''): if not isinstance(routers, tuple) or not isinstance(routers, list): routers = list(routers) - for primary_router in routers: - if primary == primary_router.path: - for router in routers: - primary_router.remove_child(router) - return - + if primary: + for router in routers: + primary.remove_child(router) + return + for router in routers: global_routers.remove(router) diff --git a/arkid/core/translation.py b/arkid/core/translation.py index 79e1be28f..9b80ea4da 100644 --- a/arkid/core/translation.py +++ b/arkid/core/translation.py @@ -5,8 +5,10 @@ default_lang_maps = {} +default_lang_maps["简体中文"] = {} +default_lang_maps["English"] = {} -def gettext_default(id,msg=None,lang="zh-hans"): +def gettext_default(id,msg=None,lang="简体中文"): if not msg: msg = id diff --git a/arkid/settings.py b/arkid/settings.py index 744da7a73..b228595e5 100644 --- a/arkid/settings.py +++ b/arkid/settings.py @@ -38,12 +38,14 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'corsheaders', 'oauth2_provider', 'arkid.core', 'arkid.extension', ] MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', @@ -154,5 +156,19 @@ ] LOCALE_PATHS = [ - # '/home/guancy/longgui/arkid/extension_root/com_longgui_international_en_us/locale' -] \ No newline at end of file +] + +X_FRAME_OPTIONS = 'ALLOWALL' + +# CORS +CORS_ORIGIN_ALLOW_ALL = True +CORS_ALLOW_CREDENTIALS = True + +CORS_ALLOW_METHODS = ( + 'GET', + 'POST', + 'PUT', + 'PATCH', + 'DELETE', + 'OPTIONS', +) diff --git a/extension_root/com_longgui_translation_zh/__init__.py b/extension_root/com_longgui_translation_zh/__init__.py index 2e77ed37f..2cc887aa4 100644 --- a/extension_root/com_longgui_translation_zh/__init__.py +++ b/extension_root/com_longgui_translation_zh/__init__.py @@ -13,7 +13,7 @@ def load(self): super().load() self.register_languge( - 'zh-hans', + '简体中文', {"data":"数据"} ) diff --git a/requirements-dev.txt b/requirements-dev.txt index e4362f8fc..80d832ca2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,7 +10,6 @@ -i https://mirrors.aliyun.com/pypi/simple amqp==5.1.1; python_version >= '3.6' -appnope==0.1.3; sys_platform == 'darwin' asgiref==3.5.0; python_version >= '3.7' astroid==2.11.3; python_full_version >= '3.6.2' asttokens==2.0.5 @@ -29,19 +28,20 @@ click-didyoumean==0.3.0; python_full_version >= '3.6.2' and python_full_version click-plugins==1.1.1 click-repl==0.2.0 click==8.1.2; python_version >= '3.7' -cryptography==36.0.2; python_version >= '3.6' +cryptography==37.0.0; python_version >= '3.6' decorator==5.1.1; python_version >= '3.5' deprecated==1.2.13; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' dill==0.3.4; python_version >= '2.7' and python_version != '3.0' distlib==0.3.4 +django-cors-headers==3.11.0 django-ninja==0.17.0 django==4.0.4; python_version >= '3.8' executing==0.8.3 filelock==3.6.0; python_version >= '3.7' ghp-import==2.0.2 -identify==2.4.12; python_version >= '3.7' +identify==2.5.0; python_version >= '3.7' idna==3.3; python_version >= '3' -importlib-metadata==4.11.3; python_version < '3.10' +importlib-metadata==4.11.3; python_version >= '3.7' ipython==8.2.0 isort==5.10.1; python_version < '4.0' and python_full_version >= '3.6.1' jedi==0.18.1; python_version >= '3.6' @@ -56,7 +56,7 @@ mccabe==0.7.0; python_version >= '3.6' mergedeep==1.3.4; python_version >= '3.6' mkdocs-autorefs==0.4.1; python_version >= '3.7' mkdocs-material-extensions==1.0.3; python_version >= '3.6' -mkdocs-material==8.2.9 +mkdocs-material==8.2.11 mkdocs==1.3.0 mkdocstrings-python-legacy==0.2.2; python_version >= '3.7' mkdocstrings==0.18.1 @@ -87,6 +87,7 @@ pyyaml-env-tag==0.1; python_version >= '3.6' pyyaml==6.0; python_version >= '3.6' redis==4.2.2 requests==2.27.1 +setuptools==62.1.0; python_version >= '3.7' six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' sqlparse==0.4.2; python_version >= '3.5' stack-data==0.2.0 @@ -94,7 +95,7 @@ toml==0.10.2 tomli==2.0.1; python_version < '3.11' traitlets==5.1.1; python_version >= '3.7' typing-extensions==4.2.0; python_version >= '3.7' -urllib3==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4' +urllib3==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_full_version < '4.0.0' vine==5.0.0; python_version >= '3.6' virtualenv==20.14.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' watchdog==2.1.7; python_version >= '3.6' diff --git a/requirements.txt b/requirements.txt index 18b888121..5149dfd36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,13 +20,14 @@ click-didyoumean==0.3.0; python_full_version >= '3.6.2' and python_full_version click-plugins==1.1.1 click-repl==0.2.0 click==8.1.2; python_version >= '3.7' -cryptography==36.0.2; python_version >= '3.6' +cryptography==37.0.0; python_version >= '3.6' deprecated==1.2.13; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' +django-cors-headers==3.11.0 django-ninja==0.17.0 django==4.0.4; python_version >= '3.8' ghp-import==2.0.2 idna==3.3; python_version >= '3' -importlib-metadata==4.11.3; python_version < '3.10' +importlib-metadata==4.11.3; python_version >= '3.7' jinja2==3.1.1; python_version >= '3.7' jwcrypto==1.0 kombu==5.2.4; python_version >= '3.7' @@ -35,7 +36,7 @@ markupsafe==2.1.1; python_version >= '3.7' mergedeep==1.3.4; python_version >= '3.6' mkdocs-autorefs==0.4.1; python_version >= '3.7' mkdocs-material-extensions==1.0.3; python_version >= '3.6' -mkdocs-material==8.2.9 +mkdocs-material==8.2.11 mkdocs==1.3.0 mkdocstrings-python-legacy==0.2.2; python_version >= '3.7' mkdocstrings==0.18.1 @@ -60,7 +61,7 @@ six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3 sqlparse==0.4.2; python_version >= '3.5' toml==0.10.2 typing-extensions==4.2.0; python_version >= '3.7' -urllib3==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4' +urllib3==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_full_version < '4.0.0' vine==5.0.0; python_version >= '3.6' watchdog==2.1.7; python_version >= '3.6' wcwidth==0.2.5 diff --git a/templates/switch_tenant.html b/templates/switch_tenant.html new file mode 100644 index 000000000..151dabedb --- /dev/null +++ b/templates/switch_tenant.html @@ -0,0 +1,117 @@ + + +
+ + + +