Skip to content

Commit 69b84fa

Browse files
committed
feat: replace location.orign with window.COORDINATOR_URL
1 parent 3624d90 commit 69b84fa

File tree

9 files changed

+51
-38
lines changed

9 files changed

+51
-38
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
interface Window {
22
GS_ENGINE_TYPE: 'groot' | 'interactive' | 'gart';
3+
COORDINATOR_URL: string;
34
}

packages/studio-website/src/layouts/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function StudioLayout() {
1616
engineType: 'interactive',
1717
});
1818
const depolymentInfo = async () => {
19-
return await DeploymentApiFactory(undefined, location.origin)
19+
return await DeploymentApiFactory(undefined, window.COORDINATOR_URL)
2020
.getDeploymentInfo()
2121
.then(res => {
2222
const { data } = res;
@@ -78,6 +78,8 @@ export default function StudioLayout() {
7878
};
7979
useEffect(() => {
8080
(async () => {
81+
const coordinator = queryCoordinator();
82+
debugger;
8183
const engineType = (await depolymentInfo()) as 'interactive' | 'groot';
8284
setState(preState => {
8385
return {
@@ -125,3 +127,13 @@ export default function StudioLayout() {
125127

126128
return <GlobalSpin />;
127129
}
130+
131+
function queryCoordinator() {
132+
const coordinatorURL = Utils.getSearchParams('coordinator');
133+
if (coordinatorURL) {
134+
Utils.storage.set('coordinator', coordinatorURL);
135+
}
136+
const coordinator = Utils.storage.get<string>('coordinator') || location.origin;
137+
window.COORDINATOR_URL = coordinator;
138+
return coordinator;
139+
}

packages/studio-website/src/layouts/services.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const getSupportFeature = (): Features => {
5454
};
5555

5656
export const listGraphs = async () => {
57-
const status = await ServiceApiFactory(undefined, location.origin)
57+
const status = await ServiceApiFactory(undefined, window.COORDINATOR_URL)
5858
.listServiceStatus()
5959
.then(res => {
6060
if (res.status === 200) {
@@ -68,7 +68,7 @@ export const listGraphs = async () => {
6868

6969
let graphs;
7070

71-
graphs = await GraphApiFactory(undefined, location.origin)
71+
graphs = await GraphApiFactory(undefined, window.COORDINATOR_URL)
7272
.listGraphs()
7373
.then(res => {
7474
if (res.status === 200) {

packages/studio-website/src/pages/extension/service.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { CreateStoredProcRequest, UpdateStoredProcRequest } from '@graphsco
33
import { notification } from '../../pages/utils';
44
/** 获取插件列表 */
55
export const listProcedures = async () => {
6-
const message = await GraphApiFactory(undefined, location.origin)
6+
const message = await GraphApiFactory(undefined, window.COORDINATOR_URL)
77
.listGraphs()
88
.then(res => {
99
if (res.status === 200) {
@@ -19,7 +19,7 @@ export const listProcedures = async () => {
1919
};
2020
/** 创建插件 */
2121
export const createProcedure = async (graphId: string, procedure: CreateStoredProcRequest) => {
22-
return await StoredProcedureApiFactory(undefined, location.origin)
22+
return await StoredProcedureApiFactory(undefined, window.COORDINATOR_URL)
2323
.createStoredProcedure(graphId, procedure)
2424
.then(res => {
2525
if (res.status === 200) {
@@ -33,7 +33,7 @@ export const createProcedure = async (graphId: string, procedure: CreateStoredPr
3333
};
3434
/** 删除插件 */
3535
export const deleteProcedure = async (graphId: string, procedureName: string) => {
36-
return await StoredProcedureApiFactory(undefined, location.origin)
36+
return await StoredProcedureApiFactory(undefined, window.COORDINATOR_URL)
3737
.deleteStoredProcedureById(graphId, procedureName)
3838
.then(res => {
3939
if (res.status === 200) {
@@ -47,7 +47,7 @@ export const deleteProcedure = async (graphId: string, procedureName: string) =>
4747
};
4848
/** 修改插件 */
4949
export const updateProcedure = async (graphId: string, procedureId: string, procedure: UpdateStoredProcRequest) => {
50-
return await StoredProcedureApiFactory(undefined, location.origin)
50+
return await StoredProcedureApiFactory(undefined, window.COORDINATOR_URL)
5151
.updateStoredProcedureById(graphId, procedureId, procedure)
5252
.then(res => {
5353
if (res.status === 200) {
@@ -61,7 +61,7 @@ export const updateProcedure = async (graphId: string, procedureId: string, proc
6161
};
6262
/** 获取某条插件数据 */
6363
export const getProcedure = async (graphId: string, procedureId: string) => {
64-
return await StoredProcedureApiFactory(undefined, location.origin)
64+
return await StoredProcedureApiFactory(undefined, window.COORDINATOR_URL)
6565
.getStoredProcedureById(graphId, procedureId)
6666
.then(res => {
6767
if (res.status === 200) {
@@ -75,7 +75,7 @@ export const getProcedure = async (graphId: string, procedureId: string) => {
7575
};
7676
/** 获取 Binding graph 列表 */
7777
export const listGraphs = async () => {
78-
const deployments = await GraphApiFactory(undefined, location.origin)
78+
const deployments = await GraphApiFactory(undefined, window.COORDINATOR_URL)
7979
.listGraphs()
8080
.then(res => {
8181
if (res.status === 200) {

packages/studio-website/src/pages/importing/services.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { FieldType } from './start-load';
77

88
/** upload file */
99
export const uploadFile = async (file: File) => {
10-
return UtilsApiFactory(undefined, location.origin)
10+
return UtilsApiFactory(undefined, window.COORDINATOR_URL)
1111
.uploadFile(file)
1212
.then(res => {
1313
if (res.status === 200) {
@@ -22,7 +22,7 @@ export const uploadFile = async (file: File) => {
2222

2323
export const bindDatasourceInBatch = async (graph_id: string, options: any): Promise<any> => {
2424
const schema = transformImportOptionsToSchemaMapping(options);
25-
return await DataSourceApiFactory(undefined, location.origin).bindDatasourceInBatch(graph_id, schema);
25+
return await DataSourceApiFactory(undefined, window.COORDINATOR_URL).bindDatasourceInBatch(graph_id, schema);
2626
};
2727
/** 数据绑定 dataMap(nodes/edges集合)*/
2828
export const submitDataloadingJob = async (graph_id: string, graphSchema: any, loadConfig: FieldType): Promise<any> => {
@@ -53,7 +53,7 @@ export const submitDataloadingJob = async (graph_id: string, graphSchema: any, l
5353
: {
5454
quoting: loadConfig.quoting,
5555
};
56-
return JobApiFactory(undefined, location.origin).submitDataloadingJob(graph_id, {
56+
return JobApiFactory(undefined, window.COORDINATOR_URL).submitDataloadingJob(graph_id, {
5757
...schema,
5858
loading_config: {
5959
import_option: loadConfig.import_option,
@@ -74,7 +74,7 @@ export const submitDataloadingJob = async (graph_id: string, graphSchema: any, l
7474
export const getSchema = async (graph_id: string) => {
7575
let schema;
7676
if (window.GS_ENGINE_TYPE === 'interactive' || window.GS_ENGINE_TYPE === 'gart') {
77-
schema = await GraphApiFactory(undefined, location.origin)
77+
schema = await GraphApiFactory(undefined, window.COORDINATOR_URL)
7878
.getGraphById(graph_id)
7979
.then(res => {
8080
if (res.status === 200) {
@@ -87,7 +87,7 @@ export const getSchema = async (graph_id: string) => {
8787
});
8888
}
8989
if (window.GS_ENGINE_TYPE === 'groot') {
90-
schema = await GraphApiFactory(undefined, location.origin)
90+
schema = await GraphApiFactory(undefined, window.COORDINATOR_URL)
9191
.getSchemaById(graph_id)
9292
.then(res => {
9393
if (res.status === 200) {
@@ -104,7 +104,7 @@ export const getSchema = async (graph_id: string) => {
104104

105105
/** getDatasourceById 获取数据源信息 */
106106
export const getDatasourceById = async (graph_id: string) => {
107-
const schemaMapping = await DataSourceApiFactory(undefined, location.origin)
107+
const schemaMapping = await DataSourceApiFactory(undefined, window.COORDINATOR_URL)
108108
.getDatasourceById(graph_id!)
109109
.then(res => res.data)
110110
.catch(error => {

packages/studio-website/src/pages/instance/lists/service.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { DataloadingJobConfig } from '@graphscope/studio-server';
33
import { notification } from '../../../pages/utils';
44

55
export const listGraphs = async () => {
6-
const _status = await ServiceApiFactory(undefined, location.origin)
6+
const _status = await ServiceApiFactory(undefined, window.COORDINATOR_URL)
77
.listServiceStatus()
88
.then(res => {
99
if (res.status === 200) {
@@ -18,7 +18,7 @@ export const listGraphs = async () => {
1818
// const { GS_ENGINE_TYPE } = window;
1919
let graphs;
2020
// if (GS_ENGINE_TYPE === 'interactive') {
21-
graphs = await GraphApiFactory(undefined, location.origin)
21+
graphs = await GraphApiFactory(undefined, window.COORDINATOR_URL)
2222
.listGraphs()
2323
.then(res => {
2424
if (res.status === 200) {
@@ -31,7 +31,7 @@ export const listGraphs = async () => {
3131
// }
3232

3333
// if (GS_ENGINE_TYPE === 'groot') {
34-
// graphs = await LegacyApiFactory(undefined, location.origin)
34+
// graphs = await LegacyApiFactory(undefined,window.COORDINATOR_URL)
3535
// .listGrootGraph()
3636
// .then(res => {
3737
// if (res.status === 200) {
@@ -77,7 +77,7 @@ export const listGraphs = async () => {
7777
};
7878

7979
export const deleteGraph = async (graph_id: string) => {
80-
return await GraphApiFactory(undefined, location.origin)
80+
return await GraphApiFactory(undefined, window.COORDINATOR_URL)
8181
.deleteGraphById(graph_id)
8282
.then(res => {
8383
if (res.status === 200) {
@@ -94,7 +94,7 @@ export const deleteGraph = async (graph_id: string) => {
9494
};
9595

9696
export const startService = async (graph_id: string) => {
97-
return await ServiceApiFactory(undefined, location.origin)
97+
return await ServiceApiFactory(undefined, window.COORDINATOR_URL)
9898
.startService({
9999
graph_id,
100100
})
@@ -112,7 +112,7 @@ export const startService = async (graph_id: string) => {
112112
});
113113
};
114114
export const stopService = async (graph_id: string) => {
115-
return await ServiceApiFactory(undefined, location.origin)
115+
return await ServiceApiFactory(undefined, window.COORDINATOR_URL)
116116
.stopService({
117117
graph_id,
118118
})
@@ -131,7 +131,7 @@ export const stopService = async (graph_id: string) => {
131131
};
132132
/** 获取是否已经导入 */
133133
export const getDataloadingConfig = async (graph_id: string, dataloadingJobConfig: DataloadingJobConfig) => {
134-
return await JobApiFactory(undefined, location.origin)
134+
return await JobApiFactory(undefined, window.COORDINATOR_URL)
135135
.getDataloadingJobConfig(graph_id!, dataloadingJobConfig)
136136
.then(res => {
137137
if (res.status === 200) {

packages/studio-website/src/pages/job/service.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type IJobType = {
1414
};
1515
};
1616
export const listJobs = async () => {
17-
const message = await JobApiFactory(undefined, location.origin)
17+
const message = await JobApiFactory(undefined, window.COORDINATOR_URL)
1818
.listJobs()
1919
.then(res => {
2020
if (res.status === 200) {
@@ -26,7 +26,7 @@ export const listJobs = async () => {
2626
notification('error', error);
2727
return [];
2828
});
29-
const graphs = await GraphApiFactory(undefined, location.origin)
29+
const graphs = await GraphApiFactory(undefined, window.COORDINATOR_URL)
3030
.listGraphs()
3131
.then(res => {
3232
if (res.status === 200) {
@@ -60,7 +60,7 @@ export const listJobs = async () => {
6060
return info;
6161
};
6262
export const deleteJobById = async (jobId: string) => {
63-
return await JobApiFactory(undefined, location.origin)
63+
return await JobApiFactory(undefined, window.COORDINATOR_URL)
6464
.deleteJobById(jobId)
6565
.then(res => {
6666
if (res.status === 200) {
@@ -73,7 +73,7 @@ export const deleteJobById = async (jobId: string) => {
7373
});
7474
};
7575
export const getJobById = async (jobId: string) => {
76-
return await JobApiFactory(undefined, location.origin)
76+
return await JobApiFactory(undefined, window.COORDINATOR_URL)
7777
.getJobById(jobId)
7878
.then(res => {
7979
if (res.status === 200) {

packages/studio-website/src/pages/modeling/services.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export const createGraph = async (params: { graphName: string; nodes: any[]; edg
1717
description: '',
1818
schema: schemaJSON,
1919
};
20-
graphs = await GraphApiFactory(undefined, location.origin).createGraph(data);
20+
graphs = await GraphApiFactory(undefined, window.COORDINATOR_URL).createGraph(data);
2121
}
2222
/** groot 创建 */
2323
if (GS_ENGINE_TYPE === 'groot' && graph_id) {
2424
// const schemagrootJSON = transOptionsToGrootSchema(cloneDeep({ nodes: nodes, edges: edges }));
25-
graphs = await GraphApiFactory(undefined, location.origin)
25+
graphs = await GraphApiFactory(undefined, window.COORDINATOR_URL)
2626
.importSchemaById(graph_id, schemaJSON)
2727
.then(res => {
2828
if (res.status === 200) {
@@ -39,7 +39,7 @@ export const createGraph = async (params: { graphName: string; nodes: any[]; edg
3939
};
4040
/** upload file */
4141
export const uploadFile = async (file: File) => {
42-
return UtilsApiFactory(undefined, location.origin)
42+
return UtilsApiFactory(undefined, window.COORDINATOR_URL)
4343
.uploadFile(file)
4444
.then(res => {
4545
if (res.status === 200) {
@@ -54,7 +54,7 @@ export const uploadFile = async (file: File) => {
5454
export const getSchema = async (graph_id: string) => {
5555
let schema;
5656
if (window.GS_ENGINE_TYPE === 'interactive' || window.GS_ENGINE_TYPE === 'gart') {
57-
schema = await GraphApiFactory(undefined, location.origin)
57+
schema = await GraphApiFactory(undefined, window.COORDINATOR_URL)
5858
.getGraphById(graph_id)
5959
.then(res => {
6060
if (res.status === 200) {
@@ -68,7 +68,7 @@ export const getSchema = async (graph_id: string) => {
6868
});
6969
}
7070
if (window.GS_ENGINE_TYPE === 'groot') {
71-
schema = await GraphApiFactory(undefined, location.origin)
71+
schema = await GraphApiFactory(undefined, window.COORDINATOR_URL)
7272
.getSchemaById(graph_id)
7373
.then(res => {
7474
if (res.status === 200) {
@@ -101,7 +101,7 @@ export const deleteVertexTypeOrEdgeType = async (
101101
const graph_id = getSearchParams('graph_id') || '';
102102
if (type === 'nodes') {
103103
try {
104-
const res = await GraphApiFactory(undefined, location.origin).deleteVertexTypeByName(graph_id, label);
104+
const res = await GraphApiFactory(undefined, window.COORDINATOR_URL).deleteVertexTypeByName(graph_id, label);
105105
response = true;
106106
notification('success', res.data);
107107
} catch (error) {
@@ -110,7 +110,7 @@ export const deleteVertexTypeOrEdgeType = async (
110110
}
111111
if (type === 'edges' && sourceVertexType && destinationVertexType) {
112112
try {
113-
const res = await GraphApiFactory(undefined, location.origin).deleteEdgeTypeByName(
113+
const res = await GraphApiFactory(undefined, window.COORDINATOR_URL).deleteEdgeTypeByName(
114114
graph_id,
115115
label,
116116
sourceVertexType,
@@ -139,7 +139,7 @@ export const createVertexTypeOrEdgeType = async (
139139
//@ts-ignore
140140
const { vertex_types } = transOptionsToSchema({ nodes: [params], edges: [] });
141141
try {
142-
const res = await GraphApiFactory(undefined, location.origin).createVertexType(graph_id, vertex_types[0]);
142+
const res = await GraphApiFactory(undefined, window.COORDINATOR_URL).createVertexType(graph_id, vertex_types[0]);
143143
notification('success', res.data);
144144
response = true;
145145
} catch (error) {
@@ -151,7 +151,7 @@ export const createVertexTypeOrEdgeType = async (
151151
const { edge_types } = transOptionsToSchema({ nodes: nodes, edges: [params] });
152152
console.log('edge_types', edge_types, params);
153153
try {
154-
const res = await GraphApiFactory(undefined, location.origin).createEdgeType(graph_id, edge_types[0]);
154+
const res = await GraphApiFactory(undefined, window.COORDINATOR_URL).createEdgeType(graph_id, edge_types[0]);
155155
notification('success', res.data);
156156
response = true;
157157
} catch (error) {

packages/studio-website/src/pages/query/services.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ export const queryEndpoint = async (): Promise<{
4141
};
4242

4343
export const queryInfo = async (id: string) => {
44-
const result = await ServiceApiFactory(undefined, location.origin)
44+
const result = await ServiceApiFactory(undefined, window.COORDINATOR_URL)
4545
.getServiceStatusById(id)
4646
.then(res => handleResponse(res))
4747
.catch(error => handleError(error));
4848

4949
return result;
5050
};
5151
export const queryGraphSchema = async (graph_id: string): Promise<CypherSchemaData> => {
52-
const schema = await GraphApiFactory(undefined, location.origin)
52+
const schema = await GraphApiFactory(undefined, window.COORDINATOR_URL)
5353
.getSchemaById(graph_id)
5454
.then(res => handleResponse(res))
5555
.catch(error => handleError(error));
@@ -86,7 +86,7 @@ export const queryStatements: IStudioQueryProps['queryStatements'] = async type
8686
if (!graph_id) {
8787
return [];
8888
}
89-
return await StoredProcedureApiFactory(undefined, location.origin)
89+
return await StoredProcedureApiFactory(undefined, window.COORDINATOR_URL)
9090
.listStoredProcedures(graph_id)
9191
.then(res => {
9292
if (res.status === 200) {

0 commit comments

Comments
 (0)