This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 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 0f7a5ea  [Fix] Fix some issues (#33)
0f7a5ea is described below

commit 0f7a5eac3e31cd005874e0e22fef2645857631f7
Author: s7monk <[email protected]>
AuthorDate: Thu Aug 24 13:52:54 2023 +0800

    [Fix] Fix some issues (#33)
---
 .../web/server/configrue/SaTokenConfigure.java     |   2 +-
 .../paimon/web/server/data/model/SysMenu.java      |   2 ++
 .../web/server/service/impl/UserServiceImpl.java   |   7 +++---
 .../src/main/resources/application.yml             |   2 +-
 paimon-web-ui/src/api/http.ts                      |  20 ++++++++---------
 paimon-web-ui/src/assets/img/empty.png             | Bin 0 -> 3354 bytes
 .../LeftContent/components/CatalogTree/index.tsx   |  12 ++++++++++-
 .../Metadata/components/RightContent/index.tsx     |  24 ++++++++++++++++++++-
 .../RightContent/right-content.module.less         |  18 ++++++++++++++--
 paimon-web-ui/src/pages/Metadata/index.tsx         |   7 +++---
 paimon-web-ui/src/pages/Other/Login/index.tsx      |  19 +++++++++++++---
 paimon-web-ui/src/router/index.tsx                 |  12 +++++------
 paimon-web-ui/src/store/tableStore.ts              |   4 ++++
 paimon-web-ui/src/types/User/data.d.ts             |   2 +-
 14 files changed, 98 insertions(+), 33 deletions(-)

diff --git 
a/paimon-web-server/src/main/java/org/apache/paimon/web/server/configrue/SaTokenConfigure.java
 
b/paimon-web-server/src/main/java/org/apache/paimon/web/server/configrue/SaTokenConfigure.java
index 2497037..cdeff25 100644
--- 
a/paimon-web-server/src/main/java/org/apache/paimon/web/server/configrue/SaTokenConfigure.java
+++ 
b/paimon-web-server/src/main/java/org/apache/paimon/web/server/configrue/SaTokenConfigure.java
@@ -31,6 +31,6 @@ public class SaTokenConfigure implements WebMvcConfigurer {
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(new SaInterceptor(handle -> 
StpUtil.checkLogin()))
                 .addPathPatterns("/**")
-                .excludePathPatterns("/***");
+                .excludePathPatterns("/api/login");
     }
 }
diff --git 
a/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/model/SysMenu.java
 
b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/model/SysMenu.java
index 846b68b..609f0c1 100644
--- 
a/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/model/SysMenu.java
+++ 
b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/model/SysMenu.java
@@ -18,6 +18,7 @@
 
 package org.apache.paimon.web.server.data.model;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -74,6 +75,7 @@ public class SysMenu extends BaseModel {
     private String remark;
 
     /** children menu. */
+    @TableField(exist = false)
     private List<SysMenu> children = new ArrayList<SysMenu>();
 
     private static final long serialVersionUID = 1L;
diff --git 
a/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/impl/UserServiceImpl.java
 
b/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/impl/UserServiceImpl.java
index 6cae557..a827efe 100644
--- 
a/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/impl/UserServiceImpl.java
+++ 
b/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/impl/UserServiceImpl.java
@@ -27,7 +27,6 @@ import org.apache.paimon.web.server.data.model.User;
 import org.apache.paimon.web.server.data.model.UserRole;
 import org.apache.paimon.web.server.data.result.exception.BaseException;
 import 
org.apache.paimon.web.server.data.result.exception.user.UserDisabledException;
-import 
org.apache.paimon.web.server.data.result.exception.user.UserNotBindTenantException;
 import 
org.apache.paimon.web.server.data.result.exception.user.UserNotExistsException;
 import 
org.apache.paimon.web.server.data.result.exception.user.UserPasswordNotMatchException;
 import org.apache.paimon.web.server.data.vo.UserInfoVo;
@@ -46,7 +45,6 @@ import 
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -84,9 +82,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, 
User> implements Us
         }
         // query user info
         UserInfoVo userInfoVo = getUserInfoVo(user);
-        if (CollectionUtils.isEmpty(userInfoVo.getTenantList())) {
+        // todo: Currently do not bind tenants
+        /*if (CollectionUtils.isEmpty(userInfoVo.getTenantList())) {
             throw new UserNotBindTenantException();
-        }
+        }*/
 
         StpUtil.login(user.getId(), loginDto.isRememberMe());
 
diff --git a/paimon-web-server/src/main/resources/application.yml 
b/paimon-web-server/src/main/resources/application.yml
index 688ffc3..c978065 100644
--- a/paimon-web-server/src/main/resources/application.yml
+++ b/paimon-web-server/src/main/resources/application.yml
@@ -20,7 +20,7 @@ server:
 spring:
   # Paimon Web Service Name
   application:
-    name: Paimon Web UI
+    name: Paimon-Web-UI
   profiles:
     active: dev
   messages:
diff --git a/paimon-web-ui/src/api/http.ts b/paimon-web-ui/src/api/http.ts
index e46d663..5c32cf6 100644
--- a/paimon-web-ui/src/api/http.ts
+++ b/paimon-web-ui/src/api/http.ts
@@ -16,7 +16,7 @@ specific language governing permissions and limitations
 under the License. */
 
 import axios, { AxiosResponse, AxiosError } from 'axios';
-import { Notification } from '@douyinfe/semi-ui';
+/*import { Notification } from '@douyinfe/semi-ui';*/
 import {UserState} from "@src/types/User/data";
 import {Result} from "@src/types/Public/data";
 
@@ -33,12 +33,14 @@ const httpClient = axios.create({
 httpClient.interceptors.request.use(
     (config: any) => {
 
-        console.log(localStorage.getItem('token'))
+        /*console.log(localStorage.getItem('token'))*/
 
         // Here you can set request headers like:config.headers['Token'] = 
localStorage.getItem('Token').
-       config.headers = {
+        config.headers['Authorization'] = localStorage.getItem('token');
+
+        /*config.headers = {
             "Authorization": localStorage.getItem('token')
-        }
+        }*/
         return config;
     },
     (error: AxiosError) => {
@@ -51,24 +53,22 @@ httpClient.interceptors.request.use(
 // response interceptor.
 httpClient.interceptors.response.use(
     (response: AxiosResponse) => {
-
         // Here you can process the response data.
         const { data: reponseData , config: reponseConfig} = response;
 
         // 处理 config 获取 baseUrl 和 url  拼接 判断是登录接口 , 如果是 拿到相应的数据 存储到 
localStorage 中 并设置到请求头中
         if (reponseConfig.url === '/login') {
-            // todo: has a bug
             const {data} = reponseData as Result<UserState>
-            console.log('登录接口', data)
+            /*console.log('登录接口', data)*/
             //todo: use store
-            localStorage.setItem('token', data.tokenInfo.tokenValue)
+            localStorage.setItem('token', data.saTokenInfo.tokenValue)
         }
 
         // Handle response data
-        Notification.error({
+       /* Notification.error({
             title: 'Error',
             content: `${reponseData.msg}`
-        });
+        });*/
         return response;
     },
     (error: AxiosError) => {
diff --git a/paimon-web-ui/src/assets/img/empty.png 
b/paimon-web-ui/src/assets/img/empty.png
new file mode 100644
index 0000000..90e6251
Binary files /dev/null and b/paimon-web-ui/src/assets/img/empty.png differ
diff --git 
a/paimon-web-ui/src/pages/Metadata/components/LeftContent/components/CatalogTree/index.tsx
 
b/paimon-web-ui/src/pages/Metadata/components/LeftContent/components/CatalogTree/index.tsx
index ae8322f..304cd12 100644
--- 
a/paimon-web-ui/src/pages/Metadata/components/LeftContent/components/CatalogTree/index.tsx
+++ 
b/paimon-web-ui/src/pages/Metadata/components/LeftContent/components/CatalogTree/index.tsx
@@ -70,6 +70,8 @@ const CatalogTree = () => {
     const [expandedKeys, setExpandedKeys] = useState<string[]>([]);
     const [selectedKey, setSelectedKey] = useState(null);
 
+    const setTableNodeClicked = useTableStore((state) => 
state.setTableNodeClicked);
+
     useEffect(() => {
         // Fetch the catalog data when the component mounts
         fetchTables();
@@ -142,7 +144,7 @@ const CatalogTree = () => {
                             value: tableItem.tableName,
                             type: "table" as "table",
                             catalogId: item.id,
-                            key: databaseKey + "-" + tableItem.tableName
+                            key: item.catalogName + "#" + dbItem.databaseName 
+ "#" + tableItem.tableName
                         }));
                     return {
                         label: dbItem.databaseName,
@@ -276,6 +278,13 @@ const CatalogTree = () => {
         return null;
     };
 
+    const onTreeNodeClick = (key: any) => {
+        const node = findNodeByKey(key, treeData);
+        if (node && node.type === 'table') {
+            setTableNodeClicked(key);
+        }
+    };
+
     const onExpand = (_: string[], info: any) => {
         const key = info.node.key;
         const expanded = info.expanded;
@@ -362,6 +371,7 @@ const CatalogTree = () => {
                 expandedKeys={expandedKeys}
                 onExpand={onExpand}
                 selectedKey={selectedKey}
+                onSelect={onTreeNodeClick}
                 searchPlaceholder={t('common.filter')}
                 searchRender={({ prefix, ...restProps }) => (
                     <Input suffix={<IconSearch 
className={styles['catalog-tree-input-icon']}/>} {...restProps} 
className={styles['catalog-tree-input']}></Input>
diff --git a/paimon-web-ui/src/pages/Metadata/components/RightContent/index.tsx 
b/paimon-web-ui/src/pages/Metadata/components/RightContent/index.tsx
index ae52e89..94254da 100644
--- a/paimon-web-ui/src/pages/Metadata/components/RightContent/index.tsx
+++ b/paimon-web-ui/src/pages/Metadata/components/RightContent/index.tsx
@@ -16,12 +16,34 @@ specific language governing permissions and limitations
 under the License. */
 
 import TableTab from 
"@pages/Metadata/components/RightContent/components/MainContent/Table";
+import { Breadcrumb } from '@douyinfe/semi-ui';
+import {useTableStore} from "@src/store/tableStore.ts";
 import styles from "./right-content.module.less"
+import emptyImg from "@assets/img/empty.png";
 
 const MetadataRightContent = () => {
+    const tableNodeClicked = useTableStore((state) => state.tableNodeClicked);
+
+    if (!tableNodeClicked) {
+        return (
+            <div className={styles['empty-container']}>
+                <div className={styles['el-empty__image']}>
+                    <img src={emptyImg}/>
+                </div>
+                <div className={styles['el-empty__description']}>
+                    <p>请在左侧选择 Table</p>
+                </div>
+            </div>
+        )
+    }
+
     return(
         <div className={styles.container}>
-            <span style={{color: 
"var(--semi-color-text-0)"}}>paimon_table_01</span>
+            <Breadcrumb separator={'>'} compact={false}>
+                
<Breadcrumb.Item>{tableNodeClicked.split("#")[0]}</Breadcrumb.Item>
+                
<Breadcrumb.Item>{tableNodeClicked.split("#")[1]}</Breadcrumb.Item>
+                
<Breadcrumb.Item>{tableNodeClicked.split("#")[2]}</Breadcrumb.Item>
+            </Breadcrumb>
             <TableTab/>
         </div>
     )
diff --git 
a/paimon-web-ui/src/pages/Metadata/components/RightContent/right-content.module.less
 
b/paimon-web-ui/src/pages/Metadata/components/RightContent/right-content.module.less
index 322353c..bf17e01 100644
--- 
a/paimon-web-ui/src/pages/Metadata/components/RightContent/right-content.module.less
+++ 
b/paimon-web-ui/src/pages/Metadata/components/RightContent/right-content.module.less
@@ -17,5 +17,19 @@ under the License. */
 
 .container {
   flex: 1;
-  padding: 10px 15px 0 15px;
-}
\ No newline at end of file
+  padding: 10px 20px 0 20px;
+}
+
+.empty-container {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: calc(100vh - 350px);
+  width: 100vw;
+  flex-direction: column;
+}
+
+.el-empty__description {
+  font-size: 14px;
+  color: #888;
+}
diff --git a/paimon-web-ui/src/pages/Metadata/index.tsx 
b/paimon-web-ui/src/pages/Metadata/index.tsx
index 86987d8..45fa324 100644
--- a/paimon-web-ui/src/pages/Metadata/index.tsx
+++ b/paimon-web-ui/src/pages/Metadata/index.tsx
@@ -20,14 +20,15 @@ import {Divider} from "@douyinfe/semi-ui";
 import MetadataRightContent from "@pages/Metadata/components/RightContent";
 import styles from "./metadata.module.less";
 
-const Index = () => {
+const RightContent = () => {
+
     return(
         <div className={styles.container}>
             <MetadataSidebar/>
             <Divider layout="vertical" margin='396px' 
className={styles.divider}/>
-            <MetadataRightContent/>
+            <MetadataRightContent />
         </div>
     )
 }
 
-export default Index;
+export default RightContent;
diff --git a/paimon-web-ui/src/pages/Other/Login/index.tsx 
b/paimon-web-ui/src/pages/Other/Login/index.tsx
index 306d116..449a3b5 100644
--- a/paimon-web-ui/src/pages/Other/Login/index.tsx
+++ b/paimon-web-ui/src/pages/Other/Login/index.tsx
@@ -26,13 +26,15 @@ import http from "@api/http.ts";
 import {API_ENDPOINTS} from "@api/endpoints.ts";
 import {Col, Row} from "antd";
 import "@douyinfe/semi-foundation/lib/es/button/button.css?inline"
-import {LoginParams} from "@src/types/User/data";
+import {LoginParams, UserState} from "@src/types/User/data";
+import {useNavigate} from "react-router";
 
 
 const Login = () => {
     // const dispatch = useDispatch();
-    // const navigate = useNavigate();
+    const navigate = useNavigate();
 
+    // @ts-ignore
     const [ldapEnabled, setLdapEnabled] = useState(false);
     const [submitting, setSubmitting] = useState(false);
 
@@ -51,7 +53,18 @@ const Login = () => {
     const handleClickLogin = async () => {
         setSubmitting(true);
         const values = await form.validateFields();
-        await http.httpPost(API_ENDPOINTS.LOGIN, {...values}, () => 
setSubmitting(true), () => setSubmitting(false))
+        const response = await http.httpPost<UserState, typeof values>(
+            API_ENDPOINTS.LOGIN,
+            {...values},
+            () => setSubmitting(true),
+            () => setSubmitting(false)
+        );
+
+        if (response.status) {
+            navigate('/playground')
+        } else {
+            console.error('Login failed:', response.saTokenInfo);
+        }
     };
 
     const proFormSubmitter: SubmitterProps = {
diff --git a/paimon-web-ui/src/router/index.tsx 
b/paimon-web-ui/src/router/index.tsx
index 8285513..c912a87 100644
--- a/paimon-web-ui/src/router/index.tsx
+++ b/paimon-web-ui/src/router/index.tsx
@@ -22,18 +22,18 @@ import LayoutPage from '@src/pages/Layout';
 import PlaygroundPage from '@src/pages/Playground';
 import MetaDataPage from '@pages/Metadata';
 import DevStatus from "@pages/Abnormal/Dev";
-import Login from "@pages/Other/Login";
+/*import Login from "@pages/Other/Login";*/
 
 /*const Editor = lazy(() => import('@src/pages/Playground'))
 const Studio = lazy(() => import('@src/pages/Metadata'))*/
 
 const routeList: RouteObject[] = [
-    {
+   /* {
         path: '/',
         element: <Login/>,
-    },
+    },*/
     {
-        path: '/layout',
+        path: '/',
         element: <LayoutPage/>,
         children: [
             {
@@ -54,10 +54,10 @@ const routeList: RouteObject[] = [
             }
         ]
     },
-    {
+    /*{
         path: '*',
         element: <Login/>
-    }
+    }*/
 ]
 
 function RenderRouter() {
diff --git a/paimon-web-ui/src/store/tableStore.ts 
b/paimon-web-ui/src/store/tableStore.ts
index 1c07932..b0d8ad6 100644
--- a/paimon-web-ui/src/store/tableStore.ts
+++ b/paimon-web-ui/src/store/tableStore.ts
@@ -25,6 +25,8 @@ type Store = {
     inputs: Array<{}>;
     configs: Array<{}>;
     tableItemList: TableItem[];
+    tableNodeClicked: string;
+    setTableNodeClicked: (newTableNodeClicked: string) => void;
     setInputs: (newInputs: Array<{}>) => void;
     setConfigs: (newConfigs: Array<{}>) => void;
     createTable: (tableProp: TableItem) => Promise<void>;
@@ -35,6 +37,8 @@ export const useTableStore = create<Store>((set) => ({
     inputs: [{}],
     configs: [],
     tableItemList: [],
+    tableNodeClicked: "",
+    setTableNodeClicked: (newTableNodeClicked) => set(() => ({ 
tableNodeClicked: newTableNodeClicked })),
     setInputs: (newInputs) => set(() => ({ inputs: newInputs })),
     setConfigs: (newConfigs) => set(() => ({ configs: newConfigs })),
     createTable: async (tableProp) => {
diff --git a/paimon-web-ui/src/types/User/data.d.ts 
b/paimon-web-ui/src/types/User/data.d.ts
index 1debcc2..e7fa3e2 100644
--- a/paimon-web-ui/src/types/User/data.d.ts
+++ b/paimon-web-ui/src/types/User/data.d.ts
@@ -34,7 +34,7 @@ interface LoginParams {
  */
 export interface UserState {
     status: boolean;
-    tokenInfo: SaTokenInfo;
+    saTokenInfo: SaTokenInfo;
     roleList: Role[];
     tenantList: Tenant[];
     menuList: SysMenu[];

Reply via email to