You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by ni...@apache.org on 2024/01/02 03:42:04 UTC
(incubator-paimon-webui) branch main updated: [Feature] Introduce role management page (#125)
This is an automated email from the ASF dual-hosted git repository.
nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-paimon-webui.git
The following commit(s) were added to refs/heads/main by this push:
new 467ed98 [Feature] Introduce role management page (#125)
467ed98 is described below
commit 467ed98f32473d826a641c692ed33dbffc183ade
Author: yangyang zhong <35...@users.noreply.github.com>
AuthorDate: Tue Jan 2 11:41:59 2024 +0800
[Feature] Introduce role management page (#125)
---
.../src/{locales/en => api/models/role}/index.ts | 24 +++++-----
.../models/role/types/role.ts} | 17 +++----
paimon-web-ui-new/src/locales/en/index.ts | 6 ++-
.../{zh/modules/layout.ts => en/modules/common.ts} | 20 ++++----
.../en/modules/system.ts} | 22 +++++----
paimon-web-ui-new/src/locales/zh/index.ts | 6 ++-
.../locales/zh/modules/{layout.ts => common.ts} | 20 ++++----
paimon-web-ui-new/src/locales/zh/modules/layout.ts | 2 +-
.../zh/modules/system.ts} | 21 ++++----
.../src/views/system/role/index.module.scss | 10 +---
paimon-web-ui-new/src/views/system/role/index.tsx | 30 +++++++++++-
.../src/views/system/role/use-constants.ts | 52 ++++++++++++++++++++
.../src/views/system/role/use-table.ts | 56 ++++++++++++++++++++++
13 files changed, 212 insertions(+), 74 deletions(-)
diff --git a/paimon-web-ui-new/src/locales/en/index.ts b/paimon-web-ui-new/src/api/models/role/index.ts
similarity index 71%
copy from paimon-web-ui-new/src/locales/en/index.ts
copy to paimon-web-ui-new/src/api/models/role/index.ts
index 69456ab..ffc0b3f 100644
--- a/paimon-web-ui-new/src/locales/en/index.ts
+++ b/paimon-web-ui-new/src/api/models/role/index.ts
@@ -15,18 +15,16 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. */
-import layout from './modules/layout'
-import login from './modules/login'
-import playground from './modules/playground'
-import metadata from './modules/metadata'
-import cdc from './modules/cdc'
-import job from './modules/job'
+import httpRequest from '../../request'
+import type { ResponseOptions } from '@/api/types'
+import type { Role } from './types/role'
-export default {
- login,
- layout,
- playground,
- metadata,
- cdc,
- job
+/**
+ * # List roles
+ */
+export const listRoles = () => {
+ return httpRequest.createHooks!<ResponseOptions<Role[]>, any[]>({
+ url: '/role/list',
+ method: 'get',
+ })
}
diff --git a/paimon-web-ui-new/src/views/system/role/index.module.scss b/paimon-web-ui-new/src/api/models/role/types/role.ts
similarity index 83%
copy from paimon-web-ui-new/src/views/system/role/index.module.scss
copy to paimon-web-ui-new/src/api/models/role/types/role.ts
index fe437d9..961613e 100644
--- a/paimon-web-ui-new/src/views/system/role/index.module.scss
+++ b/paimon-web-ui-new/src/api/models/role/types/role.ts
@@ -15,14 +15,11 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. */
-.container {
- display: flex;
- width: 100%;
- height: 100%;
-
- .content {
- display: flex;
- width: calc(100% - 60px);
- height: 100%;
- }
+export interface SysRole {
+ roleName: string;
+ roleKey?: string;
+ sort?: number;
+ enabled: boolean;
+ remark?: string;
+ menuIds?: number[]
}
diff --git a/paimon-web-ui-new/src/locales/en/index.ts b/paimon-web-ui-new/src/locales/en/index.ts
index 69456ab..11c64c9 100644
--- a/paimon-web-ui-new/src/locales/en/index.ts
+++ b/paimon-web-ui-new/src/locales/en/index.ts
@@ -21,6 +21,8 @@ import playground from './modules/playground'
import metadata from './modules/metadata'
import cdc from './modules/cdc'
import job from './modules/job'
+import system from './modules/system'
+import common from './modules/common'
export default {
login,
@@ -28,5 +30,7 @@ export default {
playground,
metadata,
cdc,
- job
+ job,
+ system,
+ common
}
diff --git a/paimon-web-ui-new/src/locales/zh/modules/layout.ts b/paimon-web-ui-new/src/locales/en/modules/common.ts
similarity index 74%
copy from paimon-web-ui-new/src/locales/zh/modules/layout.ts
copy to paimon-web-ui-new/src/locales/en/modules/common.ts
index 241367d..d45a14f 100644
--- a/paimon-web-ui-new/src/locales/zh/modules/layout.ts
+++ b/paimon-web-ui-new/src/locales/en/modules/common.ts
@@ -16,14 +16,14 @@ specific language governing permissions and limitations
under the License. */
export default {
- playground: '查询控制台',
- metadata: '元数据管理',
- cdc_ingestion: 'CDC 集成',
- system: '系统管理',
- light: '浅色',
- dark: '暗色',
- cancel: '取消',
- confirm: '确认',
- user:'用户管理',
- role:'权限管理'
+ success:'Success',
+ add_success:'Add success',
+ update_success:'Update success',
+ delete_success:'Delete success',
+ create_user:'Create user',
+ create_time:'Create time',
+ update_time:'Update time',
+ search:'Search',
+ yes:'Yes',
+ no:'No'
}
diff --git a/paimon-web-ui-new/src/views/system/role/index.module.scss b/paimon-web-ui-new/src/locales/en/modules/system.ts
similarity index 76%
copy from paimon-web-ui-new/src/views/system/role/index.module.scss
copy to paimon-web-ui-new/src/locales/en/modules/system.ts
index fe437d9..c1c5c31 100644
--- a/paimon-web-ui-new/src/views/system/role/index.module.scss
+++ b/paimon-web-ui-new/src/locales/en/modules/system.ts
@@ -15,14 +15,18 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. */
-.container {
- display: flex;
- width: 100%;
- height: 100%;
+const user = {
+ add: 'Add',
+ username: 'Username',
+ nickname: 'Nickname',
+ mobile: 'Mobile',
+ email: 'Email'
+}
- .content {
- display: flex;
- width: calc(100% - 60px);
- height: 100%;
- }
+const role = {
+ role_name: 'Role name',
+ role_key: 'Role Key',
+ enabled: 'Enabled'
}
+
+export default { user, role }
diff --git a/paimon-web-ui-new/src/locales/zh/index.ts b/paimon-web-ui-new/src/locales/zh/index.ts
index 69456ab..11c64c9 100644
--- a/paimon-web-ui-new/src/locales/zh/index.ts
+++ b/paimon-web-ui-new/src/locales/zh/index.ts
@@ -21,6 +21,8 @@ import playground from './modules/playground'
import metadata from './modules/metadata'
import cdc from './modules/cdc'
import job from './modules/job'
+import system from './modules/system'
+import common from './modules/common'
export default {
login,
@@ -28,5 +30,7 @@ export default {
playground,
metadata,
cdc,
- job
+ job,
+ system,
+ common
}
diff --git a/paimon-web-ui-new/src/locales/zh/modules/layout.ts b/paimon-web-ui-new/src/locales/zh/modules/common.ts
similarity index 74%
copy from paimon-web-ui-new/src/locales/zh/modules/layout.ts
copy to paimon-web-ui-new/src/locales/zh/modules/common.ts
index 241367d..b2a9b0e 100644
--- a/paimon-web-ui-new/src/locales/zh/modules/layout.ts
+++ b/paimon-web-ui-new/src/locales/zh/modules/common.ts
@@ -16,14 +16,14 @@ specific language governing permissions and limitations
under the License. */
export default {
- playground: '查询控制台',
- metadata: '元数据管理',
- cdc_ingestion: 'CDC 集成',
- system: '系统管理',
- light: '浅色',
- dark: '暗色',
- cancel: '取消',
- confirm: '确认',
- user:'用户管理',
- role:'权限管理'
+ success:'成功',
+ add_success:'新增成功',
+ update_success:'更新成功',
+ delete_success:'删除成功',
+ create_user:'创建用户',
+ create_time:'创建时间',
+ update_time:'修改时间',
+ search:'搜索',
+ yes:'是',
+ no:'否'
}
diff --git a/paimon-web-ui-new/src/locales/zh/modules/layout.ts b/paimon-web-ui-new/src/locales/zh/modules/layout.ts
index 241367d..6fc3144 100644
--- a/paimon-web-ui-new/src/locales/zh/modules/layout.ts
+++ b/paimon-web-ui-new/src/locales/zh/modules/layout.ts
@@ -25,5 +25,5 @@ export default {
cancel: '取消',
confirm: '确认',
user:'用户管理',
- role:'权限管理'
+ role:'角色管理'
}
diff --git a/paimon-web-ui-new/src/views/system/role/index.module.scss b/paimon-web-ui-new/src/locales/zh/modules/system.ts
similarity index 75%
copy from paimon-web-ui-new/src/views/system/role/index.module.scss
copy to paimon-web-ui-new/src/locales/zh/modules/system.ts
index fe437d9..578d752 100644
--- a/paimon-web-ui-new/src/views/system/role/index.module.scss
+++ b/paimon-web-ui-new/src/locales/zh/modules/system.ts
@@ -15,14 +15,17 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. */
-.container {
- display: flex;
- width: 100%;
- height: 100%;
+const user = {
+ add: '新增',
+ username: '用户名',
+ nickname: '昵称',
+ mobile: '手机号',
+ email: '邮箱'
+}
- .content {
- display: flex;
- width: calc(100% - 60px);
- height: 100%;
- }
+const role = {
+ role_name: '角色名称',
+ role_key: '角色编码',
+ enabled: '是否启用'
}
+export default { user, role }
diff --git a/paimon-web-ui-new/src/views/system/role/index.module.scss b/paimon-web-ui-new/src/views/system/role/index.module.scss
index fe437d9..4182641 100644
--- a/paimon-web-ui-new/src/views/system/role/index.module.scss
+++ b/paimon-web-ui-new/src/views/system/role/index.module.scss
@@ -17,12 +17,6 @@ under the License. */
.container {
display: flex;
- width: 100%;
- height: 100%;
-
- .content {
- display: flex;
- width: calc(100% - 60px);
- height: 100%;
- }
+ width: calc(100% - 60px);
+ padding: 30px;
}
diff --git a/paimon-web-ui-new/src/views/system/role/index.tsx b/paimon-web-ui-new/src/views/system/role/index.tsx
index 3c895f2..b8e504a 100644
--- a/paimon-web-ui-new/src/views/system/role/index.tsx
+++ b/paimon-web-ui-new/src/views/system/role/index.tsx
@@ -16,15 +16,41 @@ specific language governing permissions and limitations
under the License. */
import styles from './index.module.scss';
+import { useConstants } from './use-constants';
+import { useTable } from './use-table';
export default defineComponent({
name: 'RolePage',
setup() {
- return {}
+ const { t } = useLocaleHooks()
+ const { tableVariables, getTableData, roleList,loading} = useTable()
+ const { columns } = useConstants()
+ getTableData()
+ return { ...toRefs(tableVariables), getTableData, t, columns, roleList,loading }
},
render() {
return (
- <div class={styles.container}>RolePage</div>
+ <n-space class={styles.container} vertical justify="center">
+ <n-card >
+ <n-space vertical>
+ <n-space justify="space-between">
+ <n-space>
+ <n-button type="primary">{this.t('system.user.add')}</n-button>
+ </n-space>
+ <n-space>
+ <></>
+ </n-space>
+ </n-space>
+ <n-data-table
+ columns={this.columns}
+ data={this.roleList?.data || []}
+ remote
+ loading={this.loading}
+ pagination={this.pagination}
+ />
+ </n-space>
+ </n-card>
+ </n-space>
)
}
})
diff --git a/paimon-web-ui-new/src/views/system/role/use-constants.ts b/paimon-web-ui-new/src/views/system/role/use-constants.ts
new file mode 100644
index 0000000..ffb250f
--- /dev/null
+++ b/paimon-web-ui-new/src/views/system/role/use-constants.ts
@@ -0,0 +1,52 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License. */
+
+export const useConstants = () => {
+ const { t } = useLocaleHooks()
+ const columns = [
+ {
+ title: t('system.role.role_name'),
+ key: 'roleName',
+ resizable: true
+ },
+ {
+ title: t('system.role.role_key'),
+ key: 'roleKey',
+ resizable: true
+ },
+ {
+ title: t('system.role.enabled'),
+ key: 'enabled',
+ resizable: true,
+ render: (row: any) => {
+ return row.enabled ? t('common.yes') : t('common.no')
+ }
+ },
+ {
+ title: t('common.create_time'),
+ key: 'createTime',
+ resizable: true
+ },
+ {
+ title: t('common.update_time'),
+ key: 'updateTime',
+ resizable: true
+ },
+ ]
+
+ return { columns }
+}
diff --git a/paimon-web-ui-new/src/views/system/role/use-table.ts b/paimon-web-ui-new/src/views/system/role/use-table.ts
new file mode 100644
index 0000000..801e557
--- /dev/null
+++ b/paimon-web-ui-new/src/views/system/role/use-table.ts
@@ -0,0 +1,56 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License. */
+
+import { listRole } from '@/api/models/role';
+export const useTable = () => {
+ const tableVariables = reactive({
+ searchForm: {
+ roleName: ''
+ },
+ pagination: {
+ showQuickJumper: true,
+ showSizePicker: true,
+ pageSize: 10,
+ page: 1,
+ itemCount: 0,
+ onUpdatePage: (page: number) => {
+ tableVariables.pagination.page = page
+ getTableData()
+ },
+ }
+ })
+ const [roleList, useRoleList, { loading }] = listRole()
+ const getTableData = () => {
+ let params = {
+ roleName: tableVariables.searchForm.roleName,
+ currentPage: tableVariables.pagination.page,
+ pageSize: tableVariables.pagination.pageSize
+ }
+ useRoleList({ params })
+ }
+ const handleResetage = () => {
+ tableVariables.pagination.page = 1
+ getTableData()
+ }
+ return {
+ tableVariables,
+ getTableData,
+ handleResetage,
+ roleList,
+ loading
+ }
+}