+
diff --git a/app-v2/static/fonts/iconfont.js b/app-v2/static/fonts/iconfont.js
index 8e352b27..4fa36635 100644
--- a/app-v2/static/fonts/iconfont.js
+++ b/app-v2/static/fonts/iconfont.js
@@ -1 +1 @@
-!function(a){var o,h,t,l,e,c='
',v=(v=document.getElementsByTagName("script"))[v.length-1].getAttribute("data-injectcss"),m=function(a,o){o.parentNode.insertBefore(a,o)};if(v&&!a.__iconfont__svg__cssinject__){a.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}function i(){e||(e=!0,t())}function n(){try{l.documentElement.doScroll("left")}catch(a){return void setTimeout(n,50)}i()}o=function(){var a,o=document.createElement("div");o.innerHTML=c,c=null,(o=o.getElementsByTagName("svg")[0])&&(o.setAttribute("aria-hidden","true"),o.style.position="absolute",o.style.width=0,o.style.height=0,o.style.overflow="hidden",o=o,(a=document.body).firstChild?m(o,a.firstChild):a.appendChild(o))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(o,0):(h=function(){document.removeEventListener("DOMContentLoaded",h,!1),o()},document.addEventListener("DOMContentLoaded",h,!1)):document.attachEvent&&(t=o,l=a.document,e=!1,n(),l.onreadystatechange=function(){"complete"==l.readyState&&(l.onreadystatechange=null,i())})}(window);
\ No newline at end of file
+!function(a){var h,o,t,l,e,v='
',c=(c=document.getElementsByTagName("script"))[c.length-1].getAttribute("data-injectcss"),m=function(a,h){h.parentNode.insertBefore(a,h)};if(c&&!a.__iconfont__svg__cssinject__){a.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}function i(){e||(e=!0,t())}function n(){try{l.documentElement.doScroll("left")}catch(a){return void setTimeout(n,50)}i()}h=function(){var a,h=document.createElement("div");h.innerHTML=v,v=null,(h=h.getElementsByTagName("svg")[0])&&(h.setAttribute("aria-hidden","true"),h.style.position="absolute",h.style.width=0,h.style.height=0,h.style.overflow="hidden",h=h,(a=document.body).firstChild?m(h,a.firstChild):a.appendChild(h))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(h,0):(o=function(){document.removeEventListener("DOMContentLoaded",o,!1),h()},document.addEventListener("DOMContentLoaded",o,!1)):document.attachEvent&&(t=h,l=a.document,e=!1,n(),l.onreadystatechange=function(){"complete"==l.readyState&&(l.onreadystatechange=null,i())})}(window);
\ No newline at end of file
diff --git a/app-v2/stores/import.ts b/app-v2/stores/import.ts
index 724bee8b..6aecd8a5 100644
--- a/app-v2/stores/import.ts
+++ b/app-v2/stores/import.ts
@@ -98,10 +98,10 @@ export class ImportStore {
configIndex: number;
}) => {
const { schema } = this.rootStore;
- const { getTagInfo, getTagDetail } = schema;
+ const { getTagOrEdgeInfo, getTagOrEdgeDetail } = schema;
const { tag, tagIndex, configIndex } = payload;
- const { code, data } = await getTagInfo(tag);
- const createTag = await getTagDetail(tag);
+ const { code, data } = await getTagOrEdgeInfo('tag', tag);
+ const createTag = await getTagOrEdgeDetail('tag', tag);
const defaultValueFields: any[] = [];
if (!!createTag) {
const res =
@@ -147,9 +147,9 @@ export class ImportStore {
this.edgesConfig = this.edgesConfig.splice(index, 1);
} else {
const { schema } = this.rootStore;
- const { getEdgeInfo, getEdgeDetail, spaceVidType } = schema;
- const { code, data } = await getEdgeInfo(edgeType);
- const createTag = await getEdgeDetail(edgeType);
+ const { getTagOrEdgeInfo, getTagOrEdgeDetail, spaceVidType } = schema;
+ const { code, data } = await getTagOrEdgeInfo('edge', edgeType);
+ const createTag = await getTagOrEdgeDetail('edge', edgeType);
const defaultValueFields: any[] = [];
if (!!createTag) {
const res =
diff --git a/app-v2/stores/schema.ts b/app-v2/stores/schema.ts
index 104fc826..21787865 100644
--- a/app-v2/stores/schema.ts
+++ b/app-v2/stores/schema.ts
@@ -1,12 +1,11 @@
import { action, makeAutoObservable, observable } from 'mobx';
import service from '@appv2/config/service';
-import { AlterType, IAlterConfig, IEdge, IIndexList, IProperty, ISpace, ITag, ITree, IndexType } from '@appv2/interfaces/schema';
+import { IAlterForm, IEdge, IIndexList, ISchemaType, ISpace, ITag, ITree, IndexType } from '@appv2/interfaces/schema';
import { handleKeyword } from '@appv2/utils/function';
import { findIndex } from 'lodash';
import {
getAlterGQL,
getIndexCreateGQL,
- getTagOrEdgeCreateGQL,
} from '@appv2/utils/gql';
export class SchemaStore {
@@ -183,28 +182,11 @@ export class SchemaStore {
}
}
- getEdgeInfo = async(edge: string) => {
- const { code, data } = (await service.execNGQL({
- gql: 'desc edge' + '`' + edge + '`;',
- })) as any;
- return { code, data };
- }
-
- getEdgeDetail = async(name: string) => {
- const gql = `SHOW CREATE EDGE ${handleKeyword(name)}`;
- const { code, data, message } = (await service.execNGQL({
- gql,
- })) as any;
- return { code, data, message };
- }
-
getEdgeTypesFields = async(payload: { edgeTypes: any[] }) => {
const { edgeTypes } = payload;
await Promise.all(
edgeTypes.map(async item => {
- const { code, data } = await this.getEdgeInfo(
- item,
- );
+ const { code, data } = await this.getTagOrEdgeInfo('edge', item);
if (code === 0) {
const edgeFields = data.tables.map(item => item.Field);
this.addEdgesName({
@@ -233,9 +215,7 @@ export class SchemaStore {
name: item,
fields: [],
};
- const { code, data } = await this.getEdgeInfo(
- item,
- );
+ const { code, data } = await this.getTagOrEdgeInfo('edge', item);
if (code === 0) {
edge.fields = data.tables;
}
@@ -263,30 +243,6 @@ export class SchemaStore {
return { code, data, message };
}
- createEdge = async(payload: {
- name: string;
- comment?: string;
- fields?: IProperty[];
- ttlConfig?: {
- ttl_col: string;
- ttl_duration: number;
- };
- }) => {
- const gql = await getTagOrEdgeCreateGQL({ ...payload, type: 'EDGE' });
- const { code, data, message } = (await service.execNGQL(
- {
- gql,
- },
- {
- trackEventConfig: {
- category: 'schema',
- action: 'create_edge',
- },
- },
- )) as any;
- return { code, data, message };
- }
-
addEdgesName = async(payload: any) => {
const { edgeType, edgeFields } = payload;
const index = findIndex(this.edgesFields, edgeType);
@@ -317,7 +273,7 @@ export class SchemaStore {
const { tags } = payload;
await Promise.all(
tags.map(async item => {
- const { code, data } = await this.getTagInfo(item);
+ const { code, data } = await this.getTagOrEdgeInfo('tag', item);
if (code === 0) {
const tagFields = data.tables.map(item => ({
field: item.Field,
@@ -329,21 +285,6 @@ export class SchemaStore {
);
};
- getTagInfo = async(tag: string) => {
- const { code, data } = (await service.execNGQL({
- gql: 'desc tag ' + '`' + tag + '`;',
- })) as any;
- return { code, data };
- }
-
- getTagDetail = async(name: string) => {
- const gql = `SHOW CREATE TAG ${handleKeyword(name)}`;
- const { code, data, message } = (await service.execNGQL({
- gql,
- })) as any;
- return { code, data, message };
- }
-
getTagList = async() => {
const tags = await this.getTags();
if (tags) {
@@ -354,9 +295,7 @@ export class SchemaStore {
name: item,
fields: [],
};
- const { code, data } = await this.getTagInfo(
- item,
- );
+ const { code, data } = await this.getTagOrEdgeInfo('tag', item);
if (code === 0) {
tag.fields = data.tables;
}
@@ -384,16 +323,11 @@ export class SchemaStore {
return { code, data, message };
}
- createTag = async(payload: {
- name: string;
- comment?: string;
- fields?: IProperty[];
- ttlConfig?: {
- ttl_col: string;
- ttl_duration: number;
- };
+ createTagOrEdge = async(payload: {
+ type: ISchemaType,
+ gql: string
}) => {
- const gql = await getTagOrEdgeCreateGQL({ ...payload, type: 'TAG' });
+ const { type, gql } = payload;
const { code, data, message } = (await service.execNGQL(
{
gql,
@@ -401,19 +335,14 @@ export class SchemaStore {
{
trackEventConfig: {
category: 'schema',
- action: 'create_tag',
+ action: `create_${type.toLowerCase()}`,
},
},
)) as any;
return { code, data, message };
}
- alterField = async(payload: {
- type: IndexType;
- name: string;
- action: AlterType;
- config: IAlterConfig;
- }) => {
+ alterField = async(payload: IAlterForm) => {
const gql = getAlterGQL(payload);
const { code, data, message } = (await service.execNGQL(
{
@@ -429,6 +358,22 @@ export class SchemaStore {
return { code, data, message };
}
+ getTagOrEdgeDetail = async(type: ISchemaType, name: string) => {
+ const gql = `show create ${type} ${handleKeyword(name)}`;
+ const { code, data, message } = (await service.execNGQL({
+ gql,
+ })) as any;
+ return { code, data, message };
+ }
+
+ getTagOrEdgeInfo = async(type: ISchemaType, name: string) => {
+ const gql = `desc ${type} ` + '`' + name + '`;';
+ const { code, data } = (await service.execNGQL({
+ gql,
+ })) as any;
+ return { code, data };
+ }
+
// indexes
getIndexes = async(type: IndexType) => {
const { code, data } = (await service.execNGQL({
@@ -458,7 +403,7 @@ export class SchemaStore {
`,
})) as any;
if (code === 0) {
- const _type = type === 'TAG' ? 'Tag' : 'Edge';
+ const _type = type === 'tag' ? 'tag' : 'edge';
const res = data.tables[0]?.[`Create ${_type} Index`] || '';
const reg = /comment = "(.+)"/g;
const result = reg.exec(res);
@@ -520,7 +465,7 @@ export class SchemaStore {
}]
}]
}] */
- const key = type === 'TAG' ? 'tagIndexTree' : 'edgeIndexTree';
+ const key = type === 'tag' ? 'tagIndexTree' : 'edgeIndexTree';
this.update({
[key]: tree,
});
diff --git a/app-v2/utils/gql.ts b/app-v2/utils/gql.ts
index 43ecb914..12d4f112 100644
--- a/app-v2/utils/gql.ts
+++ b/app-v2/utils/gql.ts
@@ -1,6 +1,5 @@
import { handleKeyword, handleVidStringName } from '@appv2/utils/function';
-import { AlterType, IAlterConfig, IProperty, IndexType } from '@appv2/interfaces/schema';
-
+import { IAlterForm, IProperty, ISchemaType, IndexType } from '@appv2/interfaces/schema';
export const getExploreMatchGQL = (params: {
selectVertexes: any[];
@@ -108,18 +107,16 @@ export const getSpaceCreateGQL = (params: {
};
export const getTagOrEdgeCreateGQL = (params: {
- type: 'TAG' | 'EDGE';
+ type: ISchemaType;
name: string;
comment?: string;
- fields?: IProperty[];
- ttlConfig?: {
- ttl_col: string;
- ttl_duration: number;
- };
+ properties?: IProperty[];
+ ttl_col?: string;
+ ttl_duration?: number;
}) => {
- const { type, name, fields, ttlConfig, comment } = params;
- const fieldsStr = fields
- ? fields
+ const { type, name, properties, ttl_col, ttl_duration, comment } = params;
+ const propertiesStr = properties
+ ? properties
.map(item => {
let valueStr = '';
if (item.value) {
@@ -155,24 +152,19 @@ export const getTagOrEdgeCreateGQL = (params: {
})
.join(', ')
: '';
- const ttlStr = ttlConfig
- ? `TTL_DURATION = ${ttlConfig.ttl_duration ||
- ''}, TTL_COL = "${ttlConfig.ttl_col || ''}"`
+ const ttlStr = ttl_col
+ ? `TTL_DURATION = ${ttl_duration ||
+ ''}, TTL_COL = "${ttl_col || ''}"`
: '';
const gql = `CREATE ${type} ${handleKeyword(name)} ${
- fieldsStr.length > 0 ? `(${fieldsStr})` : '()'
+ propertiesStr.length > 0 ? `(${propertiesStr})` : '()'
} ${ttlStr} ${
comment ? `${ttlStr.length > 0 ? ', ' : ''}COMMENT = "${comment}"` : ''
}`;
return gql;
};
-export const getAlterGQL = (params: {
- type: IndexType;
- name: string;
- action: AlterType;
- config: IAlterConfig;
-}) => {
+export const getAlterGQL = (params: IAlterForm) => {
let content;
const { type, name, action, config } = params;
if (action === 'TTL' && config.ttl) {
diff --git a/app-v2/utils/http.ts b/app-v2/utils/http.ts
index ee499618..eb2eb60c 100644
--- a/app-v2/utils/http.ts
+++ b/app-v2/utils/http.ts
@@ -4,7 +4,7 @@ import JSONBigint from 'json-bigint';
import intl from 'react-intl-universal';
import { trackEvent } from './stat';
-import { store } from '#app/store';
+import { getRootStore } from '@appv2/stores';
const service = axios.create({
@@ -43,9 +43,7 @@ service.interceptors.response.use(
errMsg.includes('an existing connection was forcibly closed'))
) {
message.warning(intl.get('warning.connectError'));
- store.dispatch({
- type: 'nebula/asyncClearConfigServer',
- });
+ getRootStore().global.logout();
} else if (code === -1 && errMsg) {
message.warning(errMsg);
}
diff --git a/config/webpack.base.ts b/config/webpack.base.ts
index 1065b389..59f582f9 100644
--- a/config/webpack.base.ts
+++ b/config/webpack.base.ts
@@ -33,7 +33,7 @@ const commonConfig: Configuration = {
'table-header-color': '#465B7A',
'table-header-cell-split-color': '#E9EDEF',
'layout-body-background': '#F8F8F8',
- 'font-family': 'Robot, sans-serif',
+ 'font-family': 'Robot-Regular, sans-serif',
'height-base': '38px',
},
},