Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/DataLinkDC/dinky into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 26, 2024
2 parents c7bec87 + 904f4fe commit 3102e0c
Show file tree
Hide file tree
Showing 12 changed files with 217 additions and 22 deletions.
4 changes: 4 additions & 0 deletions dinky-admin/src/main/java/org/dinky/Dinky.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.dinky;

import org.dinky.security.NoExitSecurityManager;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
Expand All @@ -45,6 +47,8 @@ public class Dinky {

@SneakyThrows
public static void main(String[] args) {
// Prevent System.exit calls
System.setSecurityManager(new NoExitSecurityManager());
// Initialize the JDBC Driver, because the number of packages is very large, so it needs to be executed
// asynchronously and loaded in advance
// chinese: 初始化JDBC Driver,因为包的数量特别庞大,所以这里需要异步执行,并提前加载Driver
Expand Down
29 changes: 29 additions & 0 deletions dinky-common/src/main/java/org/dinky/security/ExitException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.security;

public class ExitException extends SecurityException {
private static final long serialVersionUID = 1L;
public final int status;

public ExitException(int status) {
this.status = status;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.security;

import java.security.Permission;

public class NoExitSecurityManager extends SecurityManager {
@Override
public void checkPermission(Permission perm) {
// allow anything.
}

@Override
public void checkPermission(Permission perm, Object context) {
// allow anything.
}

@Override
public void checkExit(int status) {
super.checkExit(status);
throw new ExitException(status);
}
}
11 changes: 11 additions & 0 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ export default {
'This operation will delete the execution history of the task and all information of the task. \nPlease operate with caution! This operation is irreversible!!! \n\t\t\t\tConfirm to delete?',
'datastudio.project.import.title': 'Import json file',
'datastudio.project.import.tip': 'Click or drag file to this area to upload',
'datastudio.sqlTask.flinkJar.tip':
'The code editor on the left is the FlinkSql pre-statement, and the current form item is the EXECUTE JAR WITH syntax',
'datastudio.sqlTask.flinkJar.uri': 'Program path',
'datastudio.sqlTask.flinkJar.uri.tip': 'Please enter the path to run the program (uri)',
'datastudio.sqlTask.flinkJar.mainClass': 'Program running class (mainClass)',
'datastudio.sqlTask.flinkJar.mainClass.tip':
'Please enter the running program running class (mainClass)',
'datastudio.sqlTask.flinkJar.args': 'Program running parameters (args)',
'datastudio.sqlTask.flinkJar.args.tip': 'Please enter the program running parameters (args)',
'datastudio.sqlTask.flinkJar.allowNonRestoredState':
'Ignore undeclared state (allowNonRestoredState)',
/**
*
* devops
Expand Down
9 changes: 9 additions & 0 deletions dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ export default {
'此操作会将该任务的执行历史, 以及任务的所有信息全部删除.\n\t\t\t\t请谨慎操作! 该操作不可逆!!!\n\t\t\t\t\t确认删除吗?',
'datastudio.project.import.title': '导入 json 文件',
'datastudio.project.import.tip': '点击或拖拽文件到此区域上传',
'datastudio.sqlTask.flinkJar.tip':
'左边代码编辑器是 FlinkSql 前置语句,当前表单项是 EXECUTE JAR WITH 语法',
'datastudio.sqlTask.flinkJar.uri': '程序路径',
'datastudio.sqlTask.flinkJar.uri.tip': '请输入运行程序路径(uri)',
'datastudio.sqlTask.flinkJar.mainClass': '程序运行类(mainClass)',
'datastudio.sqlTask.flinkJar.mainClass.tip': '请输入运行程序运行类(mainClass)',
'datastudio.sqlTask.flinkJar.args': '程序运行参数(args)',
'datastudio.sqlTask.flinkJar.args.tip': '请输入程序运行参数(args)',
'datastudio.sqlTask.flinkJar.allowNonRestoredState': '忽略未声明状态(allowNonRestoredState)',
/**
*
* devops
Expand Down
81 changes: 65 additions & 16 deletions dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import {
ProFormInstance,
ProFormSwitch,
ProFormText,
ProFormTextArea
ProFormTextArea,
ProFormTreeSelect
} from '@ant-design/pro-components';
import { useAsyncEffect, useFullscreen } from 'ahooks';
import { SelectFlinkEnv } from '@/pages/DataStudio/CenterTabContent/RunToolbar/SelectFlinkEnv';
Expand Down Expand Up @@ -92,6 +93,13 @@ import DiffModal from '@/pages/DataStudio/CenterTabContent/SqlTask/DiffModal';
import TaskConfig from '@/pages/DataStudio/CenterTabContent/SqlTask/TaskConfig';
import SelectDb from '@/pages/DataStudio/CenterTabContent/RunToolbar/SelectDb';
import { SseData, Topic } from '@/models/UseWebSocketModel';
import WarpProFormTreeSelect from '@ant-design/pro-form/es/components/TreeSelect';
import { ResourceInfo } from '@/types/RegCenter/data';
import {
buildResourceTreeData,
buildResourceTreeDataAtTreeForm
} from '@/pages/RegCenter/Resource/components/FileTree/function';
import Paragraph from 'antd/es/typography/Paragraph';

export type FlinkSqlProps = {
showDesc: boolean;
Expand Down Expand Up @@ -385,9 +393,13 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => {
}, [currentState, updateCenterTab, props.tabData, sqlForm]);

const handleCheck = useCallback(async () => {
const statement =
currentState.dialect.toLowerCase() === DIALECT.FLINKJAR
? (await flinkJarFormConvertSql(sqlForm))!!
: currentState.statement;
const res = await explainSql(
l('pages.datastudio.editor.checking', '', { jobName: currentState?.name }),
{ ...currentState }
{ ...currentState, statement }
);
updateAction({
actionType: DataStudioActionType.TASK_RUN_CHECK,
Expand All @@ -398,7 +410,14 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => {
});
}, [currentState, updateAction]);
const handleDAG = useCallback(async () => {
const res = await getJobPlan(l('pages.datastudio.editor.explain.tip'), currentState);
const statement =
currentState.dialect.toLowerCase() === DIALECT.FLINKJAR
? (await flinkJarFormConvertSql(sqlForm))!!
: currentState.statement;
const res = await getJobPlan(l('pages.datastudio.editor.explain.tip'), {
...currentState,
statement
});
updateAction({
actionType: DataStudioActionType.TASK_RUN_DAG,
params: {
Expand Down Expand Up @@ -867,40 +886,70 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => {
<Panel
className={'right-toolbar-container'}
style={{ overflowY: 'auto' }}
defaultSize={30}
defaultSize={40}
>
<Flex gap={5} vertical>
{/*<Paragraph>*/}
{/* <blockquote>{l('datastudio.sqlTask.flinkJar.tip')}</blockquote>*/}
{/*</Paragraph>*/}
<ProForm
submitter={false}
initialValues={{ ...sqlForm.jarSubmitParam }}
onValuesChange={(
changedValues,
values: SqlConvertForm['jarSubmitParam']
) => {
onValuesChange={(_, values: SqlConvertForm['jarSubmitParam']) => {
setSqlForm((prevState) => ({
...prevState,
jarSubmitParam: values
}));
}}
>
<ProFormText
{/*<ProFormText*/}
{/* name={'uri'}*/}
{/* label={'程序路径'}*/}
{/* placeholder={'请输入运行程序路径'}*/}
{/*/>*/}
<ProFormTreeSelect
request={async () => {
return buildResourceTreeDataAtTreeForm(
tempData.resourceDataList as ResourceInfo[],
false,
[]
);
}}
normalize={(value) => {
return value.value;
}}
name={'uri'}
label={'程序路径'}
placeholder={'请输入运行程序路径'}
label={l('datastudio.sqlTask.flinkJar.uri')}
placeholder={l('datastudio.sqlTask.flinkJar.uri.tip')}
fieldProps={{
suffixIcon: null,
filterTreeNode: true,
showSearch: true,
treeIcon: true,
popupMatchSelectWidth: false,
labelInValue: true,
autoClearSearchValue: true,
treeLine: true,
treeDefaultExpandedKeys: ['rs:/'],
treeNodeLabelProp: 'value',
fieldNames: {
label: 'title'
}
}}
/>
<ProFormText
name={'mainClass'}
label={'程序运行类(mainClass)'}
placeholder={'请输入运行程序运行类(mainClass)'}
label={l('datastudio.sqlTask.flinkJar.mainClass')}
placeholder={l('datastudio.sqlTask.flinkJar.mainClass.tip')}
/>
<ProFormTextArea
name={'args'}
label={'程序运行参数(args)'}
placeholder={'程序运行参数(args)'}
label={l('datastudio.sqlTask.flinkJar.args')}
placeholder={l('datastudio.sqlTask.flinkJar.args.tip')}
/>
<ProFormSwitch
name={'allowNonRestoredState'}
label={'忽略未声明状态(allowNonRestoredState)'}
label={l('datastudio.sqlTask.flinkJar.allowNonRestoredState')}
/>
</ProForm>
</Flex>
Expand Down
4 changes: 4 additions & 0 deletions dinky-web/src/pages/DataStudio/DvaFunction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export const mapDispatchToProps = (dispatch: Dispatch) => {
dispatch({
type: CONFIG_MODEL_ASYNC.queryDsConfig,
payload: params
}),
queryResource: () =>
dispatch({
type: STUDIO_MODEL_ASYNC.queryResource
})
};
};
13 changes: 10 additions & 3 deletions dinky-web/src/pages/DataStudio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { useToken } from 'antd/es/theme/internal';
import { TAG_RIGHT_CONTEXT_MENU } from '@/pages/DataStudio/constants';
import { ContextMenuSpace } from '@/pages/DataStudio/ContextMenuSpace';
import { sleep } from '@antfu/utils';
import { SysConfigStateType } from '@/pages/SettingCenter/GlobalSetting/model';

const SqlTask = lazy(() => import('@/pages/DataStudio/CenterTabContent/SqlTask'));
const DataSourceDetail = lazy(() => import('@/pages/DataStudio/CenterTabContent/DataSourceDetail'));
Expand All @@ -60,6 +61,7 @@ let didMount = false;
const DataStudio: React.FC = (props: any) => {
const {
dataStudioState,
enableResource,
handleToolbarShowDesc,
handleThemeCompact,
saveToolbarLayout,
Expand All @@ -76,7 +78,8 @@ const DataStudio: React.FC = (props: any) => {
querySuggestions,
queryUserData,
queryDsConfig,
queryTaskOwnerLockingStrategy
queryTaskOwnerLockingStrategy,
queryResource
} = props;
const [_, token] = useToken();

Expand Down Expand Up @@ -137,6 +140,9 @@ const DataStudio: React.FC = (props: any) => {
await queryUserData({ id: getTenantByLocalStorage() });
await queryDsConfig();
await queryTaskOwnerLockingStrategy();
if (enableResource) {
await queryResource();
}
}, []);
useEffect(() => {
const { actionType, params } = dataStudioState.action;
Expand Down Expand Up @@ -673,8 +679,9 @@ const DataStudio: React.FC = (props: any) => {
};

export default connect(
({ DataStudio }: { DataStudio: DataStudioState }) => ({
dataStudioState: DataStudio
({ DataStudio, SysConfig }: { DataStudio: DataStudioState; SysConfig: SysConfigStateType }) => ({
dataStudioState: DataStudio,
enableResource: SysConfig.enableResource
}),
mapDispatchToProps
)(DataStudio);
22 changes: 20 additions & 2 deletions dinky-web/src/pages/DataStudio/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ import {
getEnvData,
getFlinkConfigs,
getFlinkUdfOptions,
getResourceData,
getSessionData,
querySuggestionData
} from '@/pages/DataStudio/service';
import { Alert } from '@/types/RegCenter/data';
import { Alert, ResourceInfo } from '@/types/RegCenter/data';
import { showAlertGroup } from '@/pages/RegCenter/Alert/AlertGroup/service';
import { DefaultOptionType } from 'antd/es/select';
import { getDataSourceList } from '@/pages/DataStudio/Toolbar/DataSource/service';
import { getUserData } from '@/pages/DataStudio/service';
import { UserBaseInfo } from '@/types/AuthCenter/data.d';
import { queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';

/**
* @description:
Expand Down Expand Up @@ -206,6 +209,7 @@ export type StudioModelType = {
queryDataSourceDataList: Effect;
querySuggestions: Effect;
queryUserData: Effect;
queryResource: Effect;
};
reducers: {
// 保存布局
Expand Down Expand Up @@ -283,7 +287,8 @@ const StudioModel: StudioModelType = {
flinkConfigOptions: [],
flinkUdfOptions: [],
dataSourceDataList: [],
suggestions: []
suggestions: [],
resourceDataList: []
},
layoutSize: {
leftTop: 200,
Expand Down Expand Up @@ -400,6 +405,19 @@ const StudioModel: StudioModelType = {
type: 'saveUserData',
payload: response
});
},
*queryResource({}, { call, put, select }) {
const data: [] = yield call(getResourceData);
const tempData: TempData = yield select((state: any) => state.DataStudio.tempData);

// 移除数据,并保留当前类别的属性
yield put({
type: 'saveTempData',
payload: {
...tempData,
resourceDataList: data
}
});
}
},
reducers: {
Expand Down
4 changes: 4 additions & 0 deletions dinky-web/src/pages/DataStudio/service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import { API_CONSTANTS } from '@/services/endpoints';
import { SqlConvertForm, TaskState } from '@/pages/DataStudio/type';
import { postAll } from '@/services/api';
import { ResourceInfo } from '@/types/RegCenter/data';

export async function explainSql(title: string, params: any) {
return handleOption(API_CONSTANTS.EXPLAIN_SQL, title, params);
Expand All @@ -38,6 +39,9 @@ export async function debugTask(title: string, params: any) {
export function getUserData(params: any) {
return queryDataByParams(API_CONSTANTS.GET_USER_LIST_BY_TENANTID, params);
}
export async function getResourceData() {
return await queryDataByParams<ResourceInfo[]>(API_CONSTANTS.RESOURCE_SHOW_TREE);
}

export async function getJobPlan(title: string, params: any) {
return handleOption(API_CONSTANTS.GET_JOB_PLAN, title, params);
Expand Down
Loading

0 comments on commit 3102e0c

Please sign in to comment.