[chore](ui) execute selected code in sql editor. (#16906)
* ui playground support selection sql to execute * ui playground support selection sql to execute
This commit is contained in:
@ -40,6 +40,7 @@ export default function Logs(params: any) {
|
||||
container.current.innerHTML = res.data.LogContents.log;
|
||||
}
|
||||
setLogContents(res.data.LogContents);
|
||||
container.current.scrollTop = container.current.scrollHeight;
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
@ -81,7 +82,7 @@ export default function Logs(params: any) {
|
||||
<p>Log path is: {LogContents.logPath}</p>
|
||||
<p>{LogContents.showingLast}</p>
|
||||
</Paragraph>
|
||||
<div ref={container} style={{background: '#f9f9f9', padding: '20px'}}>
|
||||
<div ref={container} style={{background: '#f9f9f9', padding: '20px', overflowY: 'scroll', height: '800px'}}>
|
||||
{/* {LogContents.log} */}
|
||||
</div>
|
||||
<BackTop></BackTop>
|
||||
|
||||
@ -59,7 +59,7 @@ export function AdHocContent(props: any) {
|
||||
() =>
|
||||
AdHocAPI.doQuery({
|
||||
db_name:getDbName().db_name,
|
||||
body:{stmt:code},
|
||||
body:{stmt:getCodeSql()},
|
||||
}),
|
||||
{
|
||||
manual: true,
|
||||
@ -67,12 +67,12 @@ export function AdHocContent(props: any) {
|
||||
// const endTime = getTimeNow();
|
||||
const {db_name, tbl_name} = getDbName();
|
||||
if (isSuccess(res)) {
|
||||
res.sqlCode = code;
|
||||
res.sqlCode = getCodeSql();
|
||||
res = {...res, db_name, tbl_name}
|
||||
props.history.push({pathname:`/Playground/result/${db_name}-${tbl_name}`,state: res});
|
||||
runSQLSuccessSubject.next(true);
|
||||
} else {
|
||||
res.sqlCode = code;
|
||||
res.sqlCode = getCodeSql();
|
||||
res = {...res, db_name, tbl_name}
|
||||
props.history.push({pathname:`/Playground/result/${db_name}-${tbl_name}`,state: res});
|
||||
runSQLSuccessSubject.next(false);
|
||||
@ -93,6 +93,14 @@ export function AdHocContent(props: any) {
|
||||
return () => subscription.unsubscribe();
|
||||
}, []);
|
||||
|
||||
const getCodeSql = () => {
|
||||
const sqlCodeSelection = editorInstance.getSelection();
|
||||
if (sqlCodeSelection != "") {
|
||||
return sqlCodeSelection;
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
const handleChange = (_editor, _data, value) => {
|
||||
setCode(value);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user