Переглянути джерело

feat: add web-ui shortcut (#842)

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 2 тижнів тому
батько
коміт
1cdb97bcf1

+ 17 - 0
client/src/components/icons/Icons.tsx

@@ -1010,6 +1010,23 @@ const icons: { [x in IconsType]: (props?: any) => React.ReactElement } = {
       ></path>
     </SvgIcon>
   ),
+  newWindow: (props = {}) => (
+    <SvgIcon
+      width="15"
+      height="15"
+      viewBox="0 0 15 15"
+      fill="none"
+      xmlns="http://www.w3.org/2000/svg"
+      {...props}
+    >
+      <path
+        fillRule="evenodd"
+        clipRule="evenodd"
+        d="M12 13C12.5523 13 13 12.5523 13 12V3C13 2.44771 12.5523 2 12 2H3C2.44771 2 2 2.44771 2 3V6.5C2 6.77614 2.22386 7 2.5 7C2.77614 7 3 6.77614 3 6.5V3H12V12H8.5C8.22386 12 8 12.2239 8 12.5C8 12.7761 8.22386 13 8.5 13H12ZM9 6.5C9 6.5001 9 6.50021 9 6.50031V6.50035V9.5C9 9.77614 8.77614 10 8.5 10C8.22386 10 8 9.77614 8 9.5V7.70711L2.85355 12.8536C2.65829 13.0488 2.34171 13.0488 2.14645 12.8536C1.95118 12.6583 1.95118 12.3417 2.14645 12.1464L7.29289 7H5.5C5.22386 7 5 6.77614 5 6.5C5 6.22386 5.22386 6 5.5 6H8.5C8.56779 6 8.63244 6.01349 8.69139 6.03794C8.74949 6.06198 8.80398 6.09744 8.85143 6.14433C8.94251 6.23434 8.9992 6.35909 8.99999 6.49708L8.99999 6.49738"
+        fill="currentColor"
+      ></path>
+    </SvgIcon>
+  ),
 };
 
 export default icons;

+ 2 - 1
client/src/components/icons/Types.ts

@@ -62,4 +62,5 @@ export type IconsType =
   | 'img'
   | 'fileplus'
   | 'file'
-  | 'eye';
+  | 'eye'
+  | 'newWindow';

+ 20 - 6
client/src/pages/index.tsx

@@ -42,7 +42,7 @@ const useStyles = makeStyles((theme: Theme) => ({
 
 function Index() {
   // context
-  const { isAuth, isManaged, isDedicated } = useContext(authContext);
+  const { isAuth, isManaged, isDedicated, authReq } = useContext(authContext);
   const { database } = useContext(dataContext);
   const { versionInfo } = useContext(rootContext);
   // i18n
@@ -89,6 +89,7 @@ function Index() {
       label: navTrans('overview'),
       onClick: () => navigate('/'),
     },
+
     {
       icon: icons.database,
       label: navTrans('database'),
@@ -110,11 +111,24 @@ function Index() {
   }
 
   if (!isManaged) {
-    menuItems.push({
-      icon: icons.navSystem,
-      label: navTrans('system'),
-      onClick: () => navigate('/system'),
-    });
+    menuItems.push(
+      {
+        icon: icons.navSystem,
+        label: navTrans('system'),
+        onClick: () => navigate('/system'),
+      },
+      {
+        icon: icons.newWindow,
+        label: 'Milvus WebUI',
+        onClick: () => {
+          // open a link
+          window.open(
+            `http://${authReq.address.split(':')[0]}:9091/webui`,
+            '_blank'
+          );
+        },
+      }
+    );
   }
 
   // check if is connected