Browse Source

feat: show $meta field in the schema page (#887)

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 month ago
parent
commit
642ab551b5

+ 13 - 7
client/src/pages/databases/collections/schema/Schema.tsx

@@ -33,6 +33,7 @@ import CopyButton from '@/components/advancedSearch/CopyButton';
 import RefreshButton from '@/components/customButton/RefreshButton';
 import { CollectionService } from '@/http';
 import type { FieldObject } from '@server/types';
+import { DYNAMIC_FIELD } from '@/consts';
 
 const Overview = () => {
   const { fetchCollection, collections, loading, database } =
@@ -75,7 +76,18 @@ const Overview = () => {
       formatter(f: FieldObject) {
         return (
           <NameWrapper>
-            {f.name}
+            <Typography
+              variant="body1"
+              sx={{
+                color: f.name === '$meta' ? 'secondary.dark' : 'inherit',
+                fontStyle: f.name === '$meta' ? 'italic' : 'inherit',
+              }}
+            >
+              {f.name}
+            </Typography>
+            {f.name === '$meta' && (
+              <StyledChip size="small" label="Dynamic field" />
+            )}
             {f.is_primary_key && <StyledChip size="small" label="ID" />}
             {f.is_partition_key && (
               <StyledChip size="small" label="Partition key" />
@@ -549,12 +561,6 @@ const Overview = () => {
                       size="small"
                     />
                   </Tooltip>
-                  {collection?.schema?.enable_dynamic_field && (
-                    <StyledChip
-                      label={collectionTrans('dynamicSchema')}
-                      size="small"
-                    />
-                  )}
                   <Tooltip title={collectionTrans('mmapTooltip')} arrow>
                     <StyledChip
                       label={collectionTrans('mmapSettings')}

+ 3 - 3
client/src/styles/theme.ts

@@ -43,9 +43,9 @@ const getCommonThemes = (mode: PaletteMode) => ({
       dark: mode === 'light' ? '#08a568' : '#078b63',
     },
     secondary: {
-      light: mode === 'light' ? '#7EE3D0' : '#4DBB9C',
-      main: '#10C998',
-      dark: mode === 'light' ? '#0BA978' : '#08845B',
+      light: mode === 'light' ? '#E6F4FF' : '#003A8C',
+      main: '#1890FF',
+      dark: mode === 'light' ? '#096DD9' : '#0050B3',
     },
     error: {
       main: '#ff4605',

+ 7 - 4
server/src/collections/collections.service.ts

@@ -174,6 +174,8 @@ export class CollectionsService {
             autoID: false,
             fieldID: '',
             state: '',
+            nullable: false,
+            default_value: null,
             dataType: DataType.JSON,
             is_function_output: false,
             is_primary_key: false,
@@ -181,6 +183,10 @@ export class CollectionsService {
         ]
       : [];
 
+    if (res.schema.enable_dynamic_field) {
+      res.schema.fields.push(res.schema.dynamicFields[0]);
+    }
+
     return res;
   }
 
@@ -735,10 +741,7 @@ export class CollectionsService {
           getKeyValueListFromJsonString(paramsJSONstring as string)) ||
         [];
 
-      index.indexParameterPairs = [
-        ...indexParams,
-        ...params,
-      ];
+      index.indexParameterPairs = [...indexParams, ...params];
     });
 
     // Return the response from the Milvus SDK's describeIndex function