Explorar el Código

Merge pull request #652 from jetlinks/next-wzy

Next wzy
hear hace 3 años
padre
commit
d2758ee1a9

+ 2 - 2
src/pages/device/DashBoard/index.tsx

@@ -517,14 +517,14 @@ const DeviceBoard = () => {
                       longitude: item.geometry.coordinates?.[0],
                       latitude: item.geometry.coordinates?.[1],
                     }}
+                    offset={[-10, -34]}
                   >
-                    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
+                    <div>
                       <div
                         style={{
                           backgroundColor: '#666666',
                           color: 'white',
                           textAlign: 'center',
-                          marginBottom: 5,
                         }}
                       >
                         {item.properties.deviceName}

+ 2 - 1
src/pages/home/components/Statistics.tsx

@@ -6,6 +6,7 @@ type StatisticsItem = {
   name: string;
   value: number | string;
   children: React.ReactNode | string;
+  permission?: any;
 };
 
 interface StatisticsProps {
@@ -26,7 +27,7 @@ const Statistics = (props: StatisticsProps) => {
         {props.data.map((item) => (
           <div className={'home-guide-item'} key={item.name}>
             <div className={'item-english'}>{item.name}</div>
-            <div className={'item-title'}>{item.value}</div>
+            <div className={'item-title'}>{item.permission ? item.permission : item.value}</div>
             {typeof item.children === 'string' ? (
               <div className={`item-index`}>
                 <img src={item.children || defaultImage} />

+ 10 - 0
src/pages/home/comprehensive/index.tsx

@@ -26,7 +26,9 @@ const Comprehensive = () => {
   const linkPermission = getMenuPathByCode(MENUS_CODE['link/DashBoard']);
 
   const [productCount, setProductCount] = useState<number>(0);
+  const [productMessage, setProductMessage] = useState<string>();
   const [deviceCount, setDeviceCount] = useState<number>(0);
+  const [deviceMessage, setDeviceMessage] = useState<string>();
   const [cpuValue, setCpuValue] = useState<number>(0);
   const [jvmValue, setJvmValue] = useState<number>(0);
   const [productVisible, setProductVisible] = useState<boolean>(false);
@@ -49,6 +51,9 @@ const Comprehensive = () => {
     if (resp.status === 200) {
       setProductCount(resp.result);
     }
+    if (resp.status === 403) {
+      setProductMessage('暂无产品权限');
+    }
   };
 
   const getDeviceCount = async () => {
@@ -56,6 +61,9 @@ const Comprehensive = () => {
     if (resp.status === 200) {
       setDeviceCount(resp.result);
     }
+    if (resp.status === 403) {
+      setDeviceMessage('暂无设备权限');
+    }
   };
 
   useEffect(() => {
@@ -184,11 +192,13 @@ const Comprehensive = () => {
                   name: '产品数量',
                   value: productCount,
                   children: require('/public/images/home/top-2.png'),
+                  permission: productMessage,
                 },
                 {
                   name: '设备数量',
                   value: deviceCount,
                   children: '',
+                  permission: deviceMessage,
                 },
               ]}
               title="设备统计"

+ 23 - 33
src/pages/home/index.tsx

@@ -16,7 +16,7 @@ const Home = () => {
   const { initialState, setInitialState } = useModel<any>('@@initialState');
   const [current, setCurrent] = useState<ViewType>('init'); // 默认为初始化
   const [loading, setLoading] = useState(true);
-  const [detail, setDetail] = useState<any>({});
+  const [apiUser, setApiUser] = useState<any>();
 
   const ViewMap = {
     init: <Init changeView={(value: ViewType) => setCurrent(value)} />,
@@ -52,38 +52,28 @@ const Home = () => {
   }, []);
   useEffect(() => {
     if (isNoCommunity) {
-      service.userDetail().then((res) => {
-        if (res.status === 200) {
-          //三方用户
-          service
-            .apiDetail({
-              terms: [
-                {
-                  column: 'userId',
-                  value: res.result.id,
-                },
-              ],
-            })
-            .then((response) => {
-              if (response.status === 200) {
-                setDetail(response.result?.data);
-                service.queryViews().then((resp) => {
-                  setLoading(false);
-                  if (resp.status === 200) {
-                    if (resp.result) {
-                      setCurrent(resp.result?.content);
-                    } else {
-                      if (res.result.username === 'admin') {
-                        setCurrent('comprehensive');
-                        adminView();
-                      } else {
-                        setCurrent('init');
-                      }
-                    }
-                  }
-                });
+      service.queryCurrent().then((res) => {
+        if (res && res.status === 200) {
+          const isApiUser = res.result.dimensions.find(
+            (item: any) => item.type === 'api-client' || item.type.id === 'api-client',
+          );
+          console.log(isApiUser);
+          setApiUser(isApiUser);
+          service.queryViews().then((resp) => {
+            setLoading(false);
+            if (resp.status === 200) {
+              if (resp.result) {
+                setCurrent(resp.result?.content);
+              } else {
+                if (res.result.username === 'admin') {
+                  setCurrent('comprehensive');
+                  adminView();
+                } else {
+                  setCurrent('init');
+                }
               }
-            });
+            }
+          });
         }
       });
     } else {
@@ -101,7 +91,7 @@ const Home = () => {
   return (
     <PageContainer>
       <Skeleton loading={loading} active>
-        {detail && detail.length > 0 ? <Api /> : <>{ViewMap[current]}</>}
+        {apiUser ? <Api /> : <>{ViewMap[current]}</>}
       </Skeleton>
     </PageContainer>
   );

+ 4 - 0
src/pages/home/service.ts

@@ -47,6 +47,10 @@ class Service {
     request(`/${SystemConst.API_BASE}/system/config/${scopes}`, {
       method: 'GET',
     });
+  queryCurrent = () =>
+    request(`/${SystemConst.API_BASE}/authorize/me`, {
+      method: 'GET',
+    });
 }
 
 export default Service;

+ 14 - 14
src/pages/oauth/index.tsx

@@ -140,14 +140,14 @@ const Oauth = () => {
       setIsLogin(false);
       getCode();
       initApplication(data.client_id || params.client_id);
-      // setTimeout(()=>{
-      //   loadingRef.current=false
-      // })
+      setTimeout(() => {
+        loadingRef.current = false;
+      });
     } else {
       setIsLogin(false);
-      // setTimeout(()=>{
-      //   loadingRef.current=false
-      // })
+      setTimeout(() => {
+        loadingRef.current = false;
+      });
     }
   };
 
@@ -187,10 +187,10 @@ const Oauth = () => {
   }, []);
 
   useEffect(() => {
-    // console.log('..............')
+    console.log('..............');
     const init = async () => {
       await Promise.resolve().then(() => {
-        // console.log(1, loadingRef.current)
+        console.log(1, loadingRef.current);
         let redirectUrl;
         const items = {
           client_id: getQueryVariable('client_id'),
@@ -217,12 +217,12 @@ const Oauth = () => {
         });
       });
       // debugger;
-      await Promise.resolve().then(() => {
-        // console.log(2, loadingRef.current)
-        // debugger;
-        loadingRef.current = false;
-        // console.log(3, loadingRef.current)
-      });
+      // await Promise.resolve().then(() => {
+      //   console.log(2, loadingRef.current)
+      //   // debugger;
+      //   loadingRef.current = false;
+      //   console.log(3, loadingRef.current)
+      // });
     };
     init();
   }, [window.location]);

+ 7 - 4
src/pages/system/Apply/Save/index.tsx

@@ -250,6 +250,9 @@ const Save = () => {
     const data: any = await form.submit();
     const list = integrationModesList.map((item) => item.value);
     _.difference(list, data.integrationModes).forEach((item) => {
+      if (item === 'ssoClient') {
+        delete data['sso'];
+      }
       delete data[item];
     });
 
@@ -344,7 +347,7 @@ const Save = () => {
         layout: 'vertical',
         labelAlign: 'left',
       },
-      required: true,
+      // required: true,
       'x-component': 'Input',
       'x-component-props': {
         placeholder: '请输入回调地址',
@@ -725,7 +728,7 @@ const Save = () => {
         layout: 'vertical',
         labelAlign: 'left',
       },
-      required: true,
+      // required: true,
       'x-component': 'Input',
       'x-component-props': {
         placeholder: '请输入回调地址',
@@ -1099,7 +1102,7 @@ const Save = () => {
                   layout: 'vertical',
                   labelAlign: 'left',
                 },
-                required: true,
+                // required: true,
                 'x-component': 'Input',
                 'x-component-props': {
                   placeholder: '请输入回调地址',
@@ -1177,7 +1180,7 @@ const Save = () => {
                       labelAlign: 'left',
                       tooltip: '授权后自动跳转的页面地址',
                     },
-                    required: true,
+                    // required: true,
                     'x-component': 'Input',
                     'x-component-props': {
                       placeholder: '请输入redirectUrl',