Skip to content

Commit

Permalink
[Optimization] move web some url to constants (#3197)
Browse files Browse the repository at this point in the history
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Feb 28, 2024
1 parent 1ec4d28 commit 9f000ed
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

import { postAll } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints';

export async function jsonToSql(params: any) {
return (await postAll('/api/tools/jsonToFlinkSql', params)).data;
return (await postAll(API_CONSTANTS.JSON_TO_FLINK_SQL, params)).data;
}
3 changes: 2 additions & 1 deletion dinky-web/src/pages/DataStudio/FooterContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import JobRunningModal from '@/pages/DataStudio/FooterContainer/JobRunningModal'
import { getCurrentTab } from '@/pages/DataStudio/function';
import { StateType, TabsPageType, VIEW } from '@/pages/DataStudio/model';
import { getSseData } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints';
import { l } from '@/utils/intl';
import { connect } from '@@/exports';
import { Button, GlobalToken, Space } from 'antd';
Expand Down Expand Up @@ -59,7 +60,7 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
const currentTab = getCurrentTab(tabs.panes ?? [], tabs.activeKey);

useEffect(() => {
const eventSource = getSseData('/api/monitor/getJvmInfo');
const eventSource = getSseData(API_CONSTANTS.BASE_URL + API_CONSTANTS.GET_JVM_INFO);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data).data;
setMemDetailInfo(
Expand Down
15 changes: 9 additions & 6 deletions dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ const HeaderContainer = (props: connect) => {
const dinkyTaskId = currentData?.id;
const dolphinTaskList: DolphinTaskMinInfo[] | undefined = await queryDataByParams<
DolphinTaskMinInfo[]
>('/api/scheduler/queryUpstreamTasks', { dinkyTaskId });
>(API_CONSTANTS.SCHEDULER_QUERY_UPSTREAM_TASKS, { dinkyTaskId });
const dolphinTaskDefinition: DolphinTaskDefinition | undefined =
await queryDataByParams<DolphinTaskDefinition>('/api/scheduler/queryTaskDefinition', {
dinkyTaskId
});
await queryDataByParams<DolphinTaskDefinition>(
API_CONSTANTS.SCHEDULER_QUERY_TASK_DEFINITION,
{
dinkyTaskId
}
);
setPushDolphinState((prevState) => ({
...prevState,
buttonLoading: true,
Expand All @@ -154,7 +157,7 @@ const HeaderContainer = (props: connect) => {
};

const handleSave = async () => {
const saved = await handlePutDataJson('/api/task', currentData);
const saved = await handlePutDataJson(API_CONSTANTS.TASK, currentData);
saveTabs({ ...props.tabs });
if (currentTab) currentTab.isModified = false;
return saved;
Expand Down Expand Up @@ -505,7 +508,7 @@ const HeaderContainer = (props: connect) => {
const handlePushDolphinSubmit = async (value: DolphinTaskDefinition) => {
setPushDolphinState((prevState) => ({ ...prevState, loading: true }));
await handleOption(
'/api/scheduler/createOrUpdateTaskDefinition',
API_CONSTANTS.SCHEDULER_CREATE_OR_UPDATE_TASK_DEFINITION,
`推送任务[${currentData?.name}]至 DolphinScheduler`,
value
);
Expand Down
10 changes: 5 additions & 5 deletions dinky-web/src/pages/DataStudio/HeaderContainer/service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import { handleGetOption, handleOption } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';

export async function explainSql(title: string, params: any) {
return handleOption('/api/task/explainSql', title, params);
return handleOption(API_CONSTANTS.EXPLAIN_SQL, title, params);
}

export async function getJobPlan(title: string, params: any) {
return handleOption('/api/task/getJobPlan', title, params);
return handleOption(API_CONSTANTS.GET_JOB_PLAN, title, params);
}

export async function debugTask(title: string, params: any) {
return handleOption('/api/task/debugTask', title, params);
return handleOption(API_CONSTANTS.DEBUG_TASK, title, params);
}

export async function executeSql(title: string, id: number) {
return handleGetOption('/api/task/submitTask', title, { id });
return handleGetOption(API_CONSTANTS.SUBMIT_TASK, title, { id });
}

export function cancelTask(
Expand All @@ -53,5 +53,5 @@ export function savePointTask(title: string, taskId: number, savePointType: stri
}

export function changeTaskLife(title = '', id: number, life: number) {
return handleGetOption('api/task/changeTaskLife', title, { taskId: id, lifeCycle: life });
return handleGetOption(API_CONSTANTS.CHANGE_TASK_LIFE, title, { taskId: id, lifeCycle: life });
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@

import { StudioMetaStoreParam } from '@/pages/DataStudio/LeftContainer/Catalog/data';
import { postAll } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints';

export async function getMSSchemaInfo(params: StudioMetaStoreParam) {
return (await postAll('/api/studio/getMSSchemaInfo', params)).data;
return (await postAll(API_CONSTANTS.STUDIO_GET_MSSCHEMA_INFO, params)).data;
}
export async function getMSCatalogs(params: StudioMetaStoreParam) {
return (await postAll('/api/studio/getMSCatalogs', params)).data;
return (await postAll(API_CONSTANTS.STUDIO_GET_MSCATALOGS, params)).data;
}
export async function getMSColumns(params: StudioMetaStoreParam) {
return (await postAll('/api/studio/getMSColumns', params)).data;
return (await postAll(API_CONSTANTS.STUDIO_GET_MSCOLUMNS, params)).data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import { TaskDataType } from '@/pages/DataStudio/model';
import { postAll, putDataJson } from '@/services/api';
import { queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';

export async function getTaskData() {
return (await postAll('/api/catalogue/getCatalogueTreeData')).data;
return (await postAll(API_CONSTANTS.CATALOGUE_GET_CATALOGUE_TREE_DATA)).data;
}
export function getTaskDetails(id: number): Promise<TaskDataType | undefined> {
return queryDataByParams('/api/task', { id: id });
return queryDataByParams(API_CONSTANTS.TASK, { id: id });
}
export function putTask(params: any) {
return putDataJson('/api/task', params);
return putDataJson(API_CONSTANTS.TASK, params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@
*/

import { getDataByParams, queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';

export function getSessionData() {
return queryDataByParams('api/cluster/listSessionEnable');
return queryDataByParams(API_CONSTANTS.CLUSTER_INSTANCE_SESSION);
}
export function getEnvData() {
return queryDataByParams('/api/task/listFlinkSQLEnv');
return queryDataByParams(API_CONSTANTS.LIST_FLINK_SQL_ENV);
}
export function getClusterConfigurationData() {
return queryDataByParams('/api/clusterConfiguration/listEnabledAll');
return queryDataByParams(API_CONSTANTS.CLUSTER_CONFIGURATION_LIST_ENABLE_ALL);
}

export function getFlinkConfigs() {
return queryDataByParams('/api/flinkConf/configOptions');
return queryDataByParams(API_CONSTANTS.FLINK_CONF_CONFIG_OPTIONS);
}

export function querySuggessionData(params: any) {
return getDataByParams('/api/suggestion/queryAllSuggestions', params);
return getDataByParams(API_CONSTANTS.SUGGESTION_QUERY_ALL_SUGGESTIONS, params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { cancelTask, savePointTask } from '@/pages/DataStudio/HeaderContainer/se
import { isStatusDone } from '@/pages/DevOps/function';
import EditJobInstanceForm from '@/pages/DevOps/JobDetail/JobOperator/components/EditJobInstanceForm';
import RestartForm from '@/pages/DevOps/JobDetail/JobOperator/components/RestartForm';
import { API_CONSTANTS } from '@/services/endpoints';
import { Jobs } from '@/types/DevOps/data';
import { l } from '@/utils/intl';
import { EllipsisOutlined, RedoOutlined } from '@ant-design/icons';
Expand All @@ -39,7 +40,7 @@ export type OperatorType = {
};
const JobOperator = (props: OperatorType) => {
const { jobDetail, refesh } = props;
const webUri = `/api/flink/${jobDetail?.clusterInstance?.jobManagerHost}/#/job/running/${jobDetail?.instance?.jid}/overview`;
const webUri = `${API_CONSTANTS.BASE_URL}/api/flink/${jobDetail?.clusterInstance?.jobManagerHost}/#/job/running/${jobDetail?.instance?.jid}/overview`;

const handleJobOperator = (key: string) => {
Modal.confirm({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { RUN_MODE } from '@/services/constants';
import { API_CONSTANTS } from '@/services/endpoints';
import { Cluster } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { Typography } from 'antd';
Expand Down Expand Up @@ -62,7 +63,7 @@ export const renderWebUiRedirect = (record: Cluster.Instance) => {
) {
return (
<Link
href={`/api/flink/${record.jobManagerHost}/#/overview`}
href={`${API_CONSTANTS.BASE_URL}/api/flink/${record.jobManagerHost}/#/overview`}
key={`${record.id}_webui`}
target='_blank'
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
}
// 这里不要代理。sse使用代理会变成同步
// const eventSource = new EventSource("http://127.0.0.1:8888" + API_CONSTANTS.GIT_PROJECT_BUILD_STEP_LOGS + "?id=" + values.id);
const eventSource = getSseData(API_CONSTANTS.GIT_PROJECT_BUILD_STEP_LOGS + '?id=' + values.id);
const eventSource = getSseData(
API_CONSTANTS.BASE_URL + API_CONSTANTS.GIT_PROJECT_BUILD_STEP_LOGS + '?id=' + values.id
);

let stepArray: BuildStepsState[] = []; // 步骤数组
let globalCurrentStep: number = 0;
Expand Down
Loading

0 comments on commit 9f000ed

Please sign in to comment.