diff --git a/ui/src/pages/logs/index.tsx b/ui/src/pages/logs/index.tsx
index 065b55d510..403a8d056d 100644
--- a/ui/src/pages/logs/index.tsx
+++ b/ui/src/pages/logs/index.tsx
@@ -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) {
+
{/* {LogContents.log} */}
diff --git a/ui/src/pages/playground/content/index.tsx b/ui/src/pages/playground/content/index.tsx
index 50c69e8b80..d9b0842f2b 100644
--- a/ui/src/pages/playground/content/index.tsx
+++ b/ui/src/pages/playground/content/index.tsx
@@ -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);
};