Unverified Commit c3c35e84 authored by ZackYoung's avatar ZackYoung Committed by GitHub

remove_task_config_field (#2194)

parent a497d7e5
......@@ -19,7 +19,6 @@
package org.dinky.configure;
import org.dinky.data.annotation.PublicInterface;
import org.dinky.data.constant.BaseConstant;
import org.dinky.interceptor.LocaleChangeInterceptor;
import org.dinky.interceptor.TenantInterceptor;
......@@ -28,7 +27,6 @@ import java.util.Locale;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
......@@ -105,18 +103,7 @@ public class AppConfig implements WebMvcConfigurer {
// .excludePathPatterns("/druid/**")
// .excludePathPatterns("/openapi/**");
registry.addInterceptor(
new SaInterceptor(
handler -> {
if (handler instanceof HandlerMethod) {
if (((HandlerMethod) handler)
.getMethodAnnotation(PublicInterface.class)
!= null) {
return;
}
StpUtil.checkLogin();
}
}))
registry.addInterceptor(new SaInterceptor(handler -> StpUtil.checkLogin()))
.addPathPatterns("/api/**")
.excludePathPatterns(
"/api/login", "/api/ldap/ldapEnableStatus",
......
......@@ -20,7 +20,6 @@
package org.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.annotation.PublicInterface;
import org.dinky.data.dto.GitProjectDTO;
import org.dinky.data.dto.TreeNodeDTO;
import org.dinky.data.enums.BusinessType;
......@@ -41,7 +40,6 @@ import java.util.concurrent.TimeUnit;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -227,8 +225,6 @@ public class GitController {
* @return {@link Result} of {@link Void}
*/
@GetMapping(path = "/build-step-logs", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@CrossOrigin("*")
@PublicInterface
@Log(title = "GitProject Build Step Logs", businessType = BusinessType.QUERY)
@ApiOperation("GitProject Build Step Logs")
public SseEmitter buildStepLogs(@RequestParam("id") Integer id) {
......
......@@ -20,7 +20,6 @@
package org.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.annotation.PublicInterface;
import org.dinky.data.dto.MetricsLayoutDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.model.Metrics;
......@@ -65,7 +64,6 @@ public class MonitorController {
}
@GetMapping(value = "/getLastUpdateData", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@PublicInterface
@ApiOperation("Get Last Update Data")
public SseEmitter getLastUpdateData(Long lastTime) {
SseEmitter emitter = new SseEmitterUTF8(TimeUnit.MINUTES.toMillis(30));
......
......@@ -19,14 +19,12 @@
package org.dinky.controller;
import org.dinky.data.annotation.PublicInterface;
import org.dinky.service.MonitorService;
import org.dinky.sse.SseEmitterUTF8;
import java.util.concurrent.TimeUnit;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -44,8 +42,6 @@ public class SseController {
private final MonitorService monitorService;
@GetMapping(value = "/getLastUpdateData", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@CrossOrigin("*")
@PublicInterface
@ApiOperation("Get Last Update Data")
public SseEmitter getLastUpdateData(Long lastTime) {
SseEmitter emitter = new SseEmitterUTF8(TimeUnit.MINUTES.toMillis(30));
......@@ -54,8 +50,6 @@ public class SseController {
}
@GetMapping(value = "/getJvmInfo", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@CrossOrigin("*")
@PublicInterface
@ApiOperation("Get JVM Info")
public SseEmitter getJvmInfo(Long lastTime) {
SseEmitter emitter = new SseEmitterUTF8(TimeUnit.MINUTES.toMillis(30));
......
/*
*
* 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.data.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface PublicInterface {}
......@@ -21,17 +21,14 @@ package org.dinky.interceptor;
import org.dinky.assertion.Asserts;
import org.dinky.context.TenantContextHolder;
import org.dinky.data.annotation.PublicInterface;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.exception.NotLoginException;
import cn.hutool.core.lang.Opt;
import lombok.extern.slf4j.Slf4j;
......@@ -62,14 +59,6 @@ public class TenantInterceptor implements AsyncHandlerInterceptor {
}
}
}
if (!isPass) {
if (handler instanceof HandlerMethod) {
if (((HandlerMethod) handler).getMethodAnnotation(PublicInterface.class) != null) {
return true;
}
}
throw new NotLoginException("请先登录", "login", "login");
}
return AsyncHandlerInterceptor.super.preHandle(request, response, handler);
}
}
......@@ -20,14 +20,14 @@ import {FlexCenterDiv} from "@/components/StyledComponents";
import {DataStudioParams, StateType, TabsPageType, VIEW} from "@/pages/DataStudio/model";
import {Breadcrumb, Button, Descriptions, message, Modal, notification, Space} from "antd";
import {
EnvironmentOutlined,
FlagTwoTone,
MoreOutlined,
PauseCircleTwoTone,
PlayCircleTwoTone,
SafetyCertificateTwoTone,
SaveTwoTone,
SmileOutlined
EnvironmentOutlined,
FlagTwoTone,
MoreOutlined,
PauseCircleTwoTone,
PlayCircleTwoTone,
SafetyCertificateTwoTone,
SaveTwoTone,
SmileOutlined
} from "@ant-design/icons";
import React from "react";
import {l} from "@/utils/intl";
......@@ -42,103 +42,105 @@ import {buildGraphData} from "@/pages/DataStudio/HeaderContainer/FlinkGraph/func
import {ErrorNotification} from "@/utils/messages";
const headerStyle: React.CSSProperties = {
display: "inline-flex",
lineHeight: VIEW.headerHeight + 'px',
height: VIEW.headerHeight,
fontStyle: "normal",
fontWeight: "bold",
fontSize: "16px",
padding: "4px 10px",
display: "inline-flex",
lineHeight: VIEW.headerHeight + 'px',
height: VIEW.headerHeight,
fontStyle: "normal",
fontWeight: "bold",
fontSize: "16px",
padding: "4px 10px",
};
type ButtonRoute = {
icon: React.ReactNode,
title: string,
click: () => void,
hotKey?: (e: KeyboardEvent) => boolean,
hotKeyDesc?: string,
isShow?: (type?: TabsPageType, subType?: string, data?: any) => boolean;
icon: React.ReactNode,
title: string,
click: () => void,
hotKey?: (e: KeyboardEvent) => boolean,
hotKeyDesc?: string,
isShow?: (type?: TabsPageType, subType?: string, data?: any) => boolean;
}
const HeaderContainer = (props: any) => {
const {
size, activeBreadcrumbTitle,
tabs: {panes, activeKey},
saveTabs,
updateJobRunningMsg,
} = props;
const {
size, activeBreadcrumbTitle,
tabs: {panes, activeKey},
saveTabs,
updateJobRunningMsg,
} = props;
const [modal, contextHolder] = Modal.useModal();
const [notificationApi, notificationContextHolder] = notification.useNotification();
const [messageApi, messageContextHolder] = message.useMessage();
const handlerStop = () => {
const current = getCurrentData(panes, activeKey);
modal.confirm({
title: l('pages.datastudio.editor.stop.job'),
content: l('pages.datastudio.editor.stop.jobConfirm', '', {jobName: current.name}),
okText: l('button.confirm'),
cancelText: l('button.cancel'),
onOk: async () => {
offLineTask(l('pages.datastudio.editor.stop.job'), current.id, "canceljob")
.then((result) => {
(getCurrentTab(panes, activeKey)?.params as DataStudioParams).taskData.jobInstanceId = 0;
saveTabs({...props.tabs})
});
}
});
const [modal, contextHolder] = Modal.useModal();
const [notificationApi, notificationContextHolder] = notification.useNotification();
const [messageApi, messageContextHolder] = message.useMessage();
const handlerStop = () => {
const current = getCurrentData(panes, activeKey);
modal.confirm({
title: l('pages.datastudio.editor.stop.job'),
content: l('pages.datastudio.editor.stop.jobConfirm', '', {jobName: current.name}),
okText: l('button.confirm'),
cancelText: l('button.cancel'),
onOk: async () => {
offLineTask(l('pages.datastudio.editor.stop.job'), current.id, "canceljob")
.then((result) => {
(getCurrentTab(panes, activeKey)?.params as DataStudioParams).taskData.jobInstanceId = 0;
saveTabs({...props.tabs})
});
}
});
}
const handlerExec = () => {
const current = getCurrentData(panes, activeKey);
if (!isSql(current.dialect) && !isOnline(current.type)) {
messageApi.warning(l('pages.datastudio.editor.execute.warn', '', {type: current.type}));
return;
}
const handlerExec = () => {
const current = getCurrentData(panes, activeKey);
if (!isSql(current.dialect) && !isOnline(current.type)) {
messageApi.warning(l('pages.datastudio.editor.execute.warn', '', {type: current.type}));
return;
}
const param: any = {
...current,
jobName: current.name,
taskId: current.id,
};
const key = current.key;
const taskKey = (Math.random() * 1000) + '';
const param: any = {
...current,
jobName: current.name,
taskId: current.id,
};
const key = current.key;
const taskKey = (Math.random() * 1000) + '';
notificationApi.success({
message: l('pages.datastudio.editor.submiting', '', {jobName: param.name}),
description: param.statement.substring(0, 40) + '...',
duration: null,
key: taskKey,
icon: <SmileOutlined style={{color: '#108ee9'}}/>,
});
notificationApi.success({
message: l('pages.datastudio.editor.submiting', '', {jobName: param.name}),
description: param.statement.substring(0, 40) + '...',
duration: null,
key: taskKey,
icon: <SmileOutlined style={{color: '#108ee9'}}/>,
});
executeSql(l('pages.datastudio.editor.submiting', '', {jobName: param.name}), param).then(res => {
console.log(res)
updateJobRunningMsg({
taskId: current.id,
jobName: current.name,
jobState: res.datas.status,
runningLog: res.msg,
})
notificationApi.destroy(taskKey)
if (res.datas.success) {
messageApi.success(l('pages.datastudio.editor.exec.success'));
(getCurrentTab(panes, activeKey)?.params as DataStudioParams).taskData.jobInstanceId = res.datas.jobInstanceId;
saveTabs({...props.tabs})
} else {
ErrorNotification(res.datas.error, l("pages.datastudio.editor.exec.error", '', {jobName: param.name}), null)
executeSql(l('pages.datastudio.editor.submiting', '', {jobName: param.name}), param).then(res => {
notificationApi.destroy(taskKey)
if (!res) {
return
}
updateJobRunningMsg({
taskId: current.id,
jobName: current.name,
jobState: res.datas.status,
runningLog: res.msg,
})
if (res.datas.success) {
messageApi.success(l('pages.datastudio.editor.exec.success'));
(getCurrentTab(panes, activeKey)?.params as DataStudioParams).taskData.jobInstanceId = res.datas.jobInstanceId;
saveTabs({...props.tabs})
} else {
ErrorNotification(res.datas.error, l("pages.datastudio.editor.exec.error", '', {jobName: param.name}), null)
}
}
// let newTabs = tabs;
// for (const element of newTabs.panes) {
// if (element.key == key) {
// element.console.result = res.datas;
// break;
// }
// }
// props.saveTabs(newTabs);
// useSession && showTables(currentSession.session, dispatch);
})
}
// let newTabs = tabs;
// for (const element of newTabs.panes) {
// if (element.key == key) {
// element.console.result = res.datas;
// break;
// }
// }
// props.saveTabs(newTabs);
// useSession && showTables(currentSession.session, dispatch);
})
}
const routes: ButtonRoute[] = [
// 保存按钮 icon
......@@ -147,7 +149,7 @@ const HeaderContainer = (props: any) => {
title: l('button.save'),
click: () => {
const current = getCurrentData(panes, activeKey);
handlePutDataJson("/api/task", current).then(()=>saveTabs({...props.tabs}))
handlePutDataJson("/api/task", current).then(() => saveTabs({...props.tabs}))
},
hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's',
hotKeyDesc: "Ctrl+S",
......@@ -165,7 +167,7 @@ const HeaderContainer = (props: any) => {
cancelButtonProps: {style: {display: 'none'}},
});
},
isShow:projectCommonShow
isShow: projectCommonShow
// hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's'
},
{
......@@ -246,81 +248,81 @@ const HeaderContainer = (props: any) => {
title: "More",
click: () => {
},
isShow:()=>true
isShow: () => true
// hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's'
},
]
/**
* @description: 生成面包屑
* @type {({title: JSX.Element} | {title: string})[]}
*/
const renderBreadcrumbItems = () => {
if (!activeBreadcrumbTitle) {
return <Space><EnvironmentOutlined/><span>Guide Page</span></Space>
}
/**
* @description: 生成面包屑
* @type {({title: JSX.Element} | {title: string})[]}
*/
const renderBreadcrumbItems = () => {
if (!activeBreadcrumbTitle) {
return <Space><EnvironmentOutlined/><span>Guide Page</span></Space>
}
return <>
<FlexCenterDiv style={{width: (size.width - 2 * VIEW.paddingInline) / 2}}>
<Breadcrumb separator={">"} items={buildBreadcrumbItems(activeBreadcrumbTitle)}/>
</FlexCenterDiv>
</>
};
const renderHotkey = () => {
document.onkeydown = e => {
routes.forEach(r => {
if (r.hotKey && r.hotKey(e)) {
r.click()
e.preventDefault()
}
})
return <>
<FlexCenterDiv style={{width: (size.width - 2 * VIEW.paddingInline) / 2}}>
<Breadcrumb separator={">"} items={buildBreadcrumbItems(activeBreadcrumbTitle)}/>
</FlexCenterDiv>
</>
};
const renderHotkey = () => {
document.onkeydown = e => {
routes.forEach(r => {
if (r.hotKey && r.hotKey(e)) {
r.click()
e.preventDefault()
}
})
}
renderHotkey()
}
renderHotkey()
/**
* @description: 渲染右侧按钮
* @returns {JSX.Element}
*/
const renderRightButtons = () => {
return <>
<Space size={'middle'} align={"center"} direction={"horizontal"} wrap>
{routes.filter(x => {
if (x.isShow) {
const currentTab = getCurrentTab(panes, activeKey);
if (currentTab) {
return x.isShow(currentTab?.type, currentTab?.subType, (currentTab?.params as DataStudioParams).taskData)
}
}
return false
}).map((route) => {
const {icon, title, click, hotKeyDesc} = route;
return <Button key={title} size={"small"} type={"text"} icon={icon}
title={title + (hotKeyDesc ? " " + hotKeyDesc : "")} onClick={click}/>
})}
</Space>
{contextHolder}
{notificationContextHolder}
{messageContextHolder}
</>
};
/**
* render
*/
/**
* @description: 渲染右侧按钮
* @returns {JSX.Element}
*/
const renderRightButtons = () => {
return <>
<Descriptions column={2} size={'middle'} layout={'horizontal'} key={"h"} style={headerStyle}>
<Descriptions.Item>
{renderBreadcrumbItems()}
</Descriptions.Item>
<Descriptions.Item contentStyle={{display: "flex", flexDirection: "row-reverse"}}>
{renderRightButtons()}
</Descriptions.Item>
</Descriptions>
<Space size={'middle'} align={"center"} direction={"horizontal"} wrap>
{routes.filter(x => {
if (x.isShow) {
const currentTab = getCurrentTab(panes, activeKey);
if (currentTab) {
return x.isShow(currentTab?.type, currentTab?.subType, (currentTab?.params as DataStudioParams).taskData)
}
}
return false
}).map((route) => {
const {icon, title, click, hotKeyDesc} = route;
return <Button key={title} size={"small"} type={"text"} icon={icon}
title={title + (hotKeyDesc ? " " + hotKeyDesc : "")} onClick={click}/>
})}
</Space>
{contextHolder}
{notificationContextHolder}
{messageContextHolder}
</>
};
/**
* render
*/
return <>
<Descriptions column={2} size={'middle'} layout={'horizontal'} key={"h"} style={headerStyle}>
<Descriptions.Item>
{renderBreadcrumbItems()}
</Descriptions.Item>
<Descriptions.Item contentStyle={{display: "flex", flexDirection: "row-reverse"}}>
{renderRightButtons()}
</Descriptions.Item>
</Descriptions>
</>
}
export default connect(({Studio}: { Studio: StateType }) => ({
tabs: Studio.tabs,
tabs: Studio.tabs,
}), mapDispatchToProps)(HeaderContainer);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment